Skip to content

Commit

Permalink
Added level changing when starting a preview test
Browse files Browse the repository at this point in the history
  • Loading branch information
TerraMonster5 committed Jun 3, 2024
1 parent 90e61db commit a30d05c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/pvz-preview/states/levelMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def __init__(self, level: dict) -> None:
def __runSim(self) -> None:
import pvz

name = self.__level["name"]

levelID = (int(name.split("-")[0])-1)*10+int(name.split("-")[1])

iterations = int(self.__iterations.get())
IDs = self.__level["zombies"]
waves = self.__level["waves"]
Expand All @@ -36,6 +40,8 @@ def __runSim(self) -> None:
df = pd.DataFrame(index=range(iterations),
columns=list(zombieNames+previewNames),
dtype=float)

pvz.WriteMemory("int", levelID, 0x6a9ec0, 0x82c, 0x24)

for i in range(iterations):
pvz.set_internal_spawn([z for z in IDs])
Expand All @@ -56,8 +62,8 @@ def __runSim(self) -> None:
df.loc[i, zombieNames[l]] = zombies.count(val)

preview = []
zombiesCountMax = pvz.ReadMemory("unsigned int", 0x6A9EC0, 0x768, 0x94)
zombiesOffset = pvz.ReadMemory("unsigned int", 0x6A9EC0, 0x768, 0x90)
zombiesCountMax = pvz.ReadMemory("unsigned int", 0x6a9ec0, 0x768, 0x94)
zombiesOffset = pvz.ReadMemory("unsigned int", 0x6a9ec0, 0x768, 0x90)

for m in range(zombiesCountMax): # type: ignore
zombieDead = pvz.ReadMemory("bool", zombiesOffset + 0xec + m * 0x15c) # type: ignore
Expand Down

0 comments on commit a30d05c

Please sign in to comment.