Skip to content

Commit b049df4

Browse files
authored
Add files via upload
1 parent 95411a6 commit b049df4

File tree

3 files changed

+86
-15
lines changed

3 files changed

+86
-15
lines changed

FFX_Battle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,15 +867,15 @@ def Geneaux():
867867
FFX_Screen.awaitTurn()
868868
if not FFX_Screen.turnTidus():
869869
while not FFX_Screen.turnTidus():
870-
if FFX_Screen.battleScreen():
870+
if FFX_memory.battleScreen():
871871
defend()
872872

873873
attack('none')
874874

875875
FFX_Screen.clickToBattle()
876876
if not FFX_Screen.turnYuna():
877877
while not FFX_Screen.turnYuna():
878-
if FFX_Screen.battleScreen():
878+
if FFX_memory.battleScreen():
879879
defend()
880880

881881
aeonSummon(0) # Summon Valefor

FFX_memory.py

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import time
44
import FFX_Screen
55
FFXC = FFX_Xbox.FFXC
6+
from math import cos, sin
67

78
def float_from_integer(integer):
89
return struct.unpack('!f', struct.pack('!I', integer))[0]
@@ -2220,8 +2221,8 @@ def eggX(eggNum):
22202221
global process
22212222
global baseValue
22222223
eggNum += 23
2223-
basePointer = baseValue + 0x1FC44E4 # equivalent to the pointer FFX.exe+EA22A0
2224-
basePointerAddress = process.read(basePointer) # pseudocode function to get the hex value from basePointer to figure out the address of the start of the actor array
2224+
basePointer = baseValue + 0x1FC44E4
2225+
basePointerAddress = process.read(basePointer)
22252226
key = basePointerAddress + (0x880 * eggNum) + 0x0C
22262227
retVal = float_from_integer(process.read(key))
22272228
#print("Egg ", eggNum," X value: ", retVal)
@@ -2231,8 +2232,8 @@ def eggY(eggNum):
22312232
global process
22322233
global baseValue
22332234
eggNum += 23
2234-
basePointer = baseValue + 0x1FC44E4 # equivalent to the pointer FFX.exe+EA22A0
2235-
basePointerAddress = process.read(basePointer) # pseudocode function to get the hex value from basePointer to figure out the address of the start of the actor array
2235+
basePointer = baseValue + 0x1FC44E4
2236+
basePointerAddress = process.read(basePointer)
22362237
key = basePointerAddress + (0x880 * eggNum) + 0x14
22372238
retVal = float_from_integer(process.read(key))
22382239
#print("Egg ", eggNum," Y value: ", retVal)
@@ -2300,3 +2301,71 @@ def buildEggs():
23002301
for x in range(10):
23012302
retArray[x] = egg(x)
23022303
return retArray
2304+
2305+
def iceX(actor):
2306+
global process
2307+
global baseValue
2308+
offset = actor + 7 #Icicle 0 is actor 7 in the array, incremented for each additional icicle.
2309+
2310+
basePointer = baseValue + 0x1fc44e4
2311+
basePointerAddress = process.read(basePointer)
2312+
key = basePointerAddress + (0x880 * offset) + 0x0C
2313+
retVal = float_from_integer(process.read(key))
2314+
return retVal
2315+
2316+
2317+
def iceY(actor):
2318+
global process
2319+
global baseValue
2320+
offset = actor + 7 #Icicle 0 is actor 7 in the array, incremented for each additional icicle.
2321+
2322+
basePointer = baseValue + 0x1fc44e4
2323+
basePointerAddress = process.read(basePointer)
2324+
key = basePointerAddress + (0x880 * offset) + 0x14
2325+
retVal = float_from_integer(process.read(key))
2326+
return retVal
2327+
2328+
def getIceDistance(iceNum):
2329+
global process
2330+
global baseValue
2331+
basePointer = baseValue + 0xF270B8
2332+
basePointerAddress = process.read(basePointer)
2333+
key = basePointerAddress + 0x1C0CC + (0x40 * iceNum)
2334+
retVal = float_from_integer(process.read(key))
2335+
return retVal
2336+
2337+
def getIceLife(iceNum):
2338+
global process
2339+
global baseValue
2340+
basePointer = baseValue + 0xF270B8
2341+
basePointerAddress = process.read(basePointer)
2342+
key = basePointerAddress + 0x1C0CC + (0x40 * iceNum) + 4
2343+
retVal = process.readBytes(key,1)
2344+
return retVal
2345+
2346+
2347+
class icicle:
2348+
def __init__(self, icenum):
2349+
self.num = icenum
2350+
self.x = iceX(self.num)
2351+
self.y = iceY(self.num)
2352+
#self.distance = getIceDistance(self.num)
2353+
#self.iceLife = getEggLife(icenum)
2354+
#self.eggPicked = getEggPicked(icenum)
2355+
2356+
#if self.distance != 0: #Either we're in battle or the icicle is not active.
2357+
# self.isActive = True
2358+
#else:
2359+
# self.isActive = False
2360+
self.isActive = True
2361+
2362+
def reportVars(self):
2363+
varArray = [self.num, self.x, self.y]
2364+
print("Ice_num, X, Y")
2365+
print(varArray)
2366+
2367+
def buildIcicles():
2368+
retArray = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
2369+
for x in range(16):
2370+
retArray[x] = icicle(x)
2371+
return retArray

zz_eggHuntAuto.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import FFX_core
77
import FFX_memory
88
import FFX_Logs
9+
from math import copysign
910

1011
FFXC = FFX_Xbox.FFXC
1112

@@ -46,6 +47,7 @@ def engage():
4647
target = [-20,20]
4748
#print("Building egg array")
4849
eggArray = FFX_memory.buildEggs()
50+
iceArray = FFX_memory.buildIcicles() #Added for additional pathing needs
4951
currentTime = time.time()
5052
if activeEgg == 99:
5153
for marker in range(10): #Only print active eggs/icicles
@@ -88,19 +90,19 @@ def engage():
8890
rX = right[0]
8991
rY = right[1]
9092

91-
Lx = fX*(eX-pX) + rX*(eY-pY)
92-
Ly = fY*(eX-pX) + rY(eY-pY)
93-
sumsUp = Lx+Ly
93+
Ly = fX * (eX-pX) + rX * (eY-pY)
94+
Lx = fY * (eX-pX) + rY * (eY-pY)
95+
sumsUp = abs(Lx)+abs(Ly)
9496
if sumsUp == 0:
9597
sumsUp = 0.01
9698
Lx /= sumsUp
9799
Ly /= sumsUp
98-
if Lx > Ly:
99-
Ly = Ly/Lx
100-
Lx = 1
101-
else:
102-
Lx = Lx/Ly
103-
Ly = 1
100+
if abs(Lx) > abs(Ly):
101+
Ly = copysign(Ly/Lx if Lx else 0, Ly)
102+
Lx = copysign(1, Lx)
103+
elif abs(Ly) > abs(Lx):
104+
Lx = copysign(Lx/Ly if Ly else 0, Lx)
105+
Ly = copysign(1, Ly)
104106

105107
FFXC.set_value('AxisLx', Lx)
106108
FFXC.set_value('AxisLy', Ly)

0 commit comments

Comments
 (0)