Skip to content

Commit c3828e5

Browse files
authored
Merge pull request #22 from monkeyman192/update/155983.0
Update/155983.0
2 parents 19bd024 + 4cc26c2 commit c3828e5

File tree

7 files changed

+185
-40
lines changed

7 files changed

+185
-40
lines changed

nmspy/common.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@
66
class GameData:
77
GcApplication: nms.cGcApplication = None # type: ignore
88

9+
@property
10+
def environment(self) -> Optional[nms.cGcEnvironment]:
11+
if (sim := self.simulation) is not None:
12+
return sim.mEnvironment
13+
14+
@property
15+
def player_environment(self) -> Optional[nms.cGcPlayerEnvironment]:
16+
if (env := self.environment) is not None:
17+
return env.mPlayerEnvironment
18+
919
@property
1020
def game_state(self) -> Optional[nms.cGcGameState]:
1121
if self.GcApplication is not None:

nmspy/data/enums/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
StateEnum,
77
eStormState,
88
eLanguageRegion,
9+
EnvironmentLocation,
910
)
1011

1112
# The following list is auto-generated.

nmspy/data/enums/internal_enums.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,23 @@ class eLanguageRegion(IntEnum):
7777
SimplifiedChinese = 0xE
7878
TencentChinese = 0xF
7979
Korean = 0x10
80+
81+
82+
class EnvironmentLocation:
83+
class Enum(IntEnum):
84+
None_ = 0x0
85+
Default = 0x1
86+
SpaceStation = 0x2
87+
PlanetOnFoot = 0x3
88+
PlanetInShip = 0x4
89+
PlanetInVehicle = 0x5
90+
Underwater = 0x6
91+
Cave = 0x7
92+
IndoorInBase = 0x8
93+
Freighter = 0x9
94+
FreighterInternals = 0xA
95+
AbandonedFreighter = 0xB
96+
InFleet = 0xC
97+
InSpaceObject = 0xD
98+
Nexus = 0xE
99+
Anomaly = 0xF

nmspy/data/types.py

Lines changed: 122 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ class cGcPlayerState(Structure):
247247
muUnits: Annotated[int, Field(c_uint32, 0x1BC)]
248248
muNanites: Annotated[int, Field(c_uint32, 0x1C0)]
249249
muSpecials: Annotated[int, Field(c_uint32, 0x1C4)]
250+
# Found in cGcPlayerShipOwnership::SpawnNewShip
251+
miPrimaryShip: Annotated[int, Field(c_uint32, 0xC4F0)]
250252

251253
@function_hook(
252254
"48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC ? 44 8B 81 ? ? ? ? 48 8D 2D"
@@ -274,9 +276,59 @@ def StoreCurrentSystemSpaceStationEndpoint(
274276
): ...
275277

276278

279+
@partial_struct
280+
class cGcPlayerShipOwnership(Structure):
281+
@partial_struct
282+
class sGcShipData(Structure):
283+
_total_size_ = 0x48
284+
285+
mPlayerShipSeed: Annotated[basic.cTkSeed, 0x0]
286+
287+
@function_hook(
288+
"48 89 5C 24 ? 55 56 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 45"
289+
)
290+
def UpdateMeshRefresh(self, this: "_Pointer[cGcPlayerShipOwnership]"): ...
291+
292+
@function_hook(
293+
"48 8B C4 55 53 56 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 80 B9 ? ? ? ? ? 48 8B F1"
294+
)
295+
def Update(
296+
self,
297+
this: "_Pointer[cGcPlayerShipOwnership]",
298+
lfTimestep: Annotated[float, c_float],
299+
): ...
300+
301+
@function_hook("44 89 44 24 ? 48 89 54 24 ? 55 56 41 54 41 56 41 57 48 8D 6C 24")
302+
def SpawnNewShip(
303+
self,
304+
this: "_Pointer[cGcPlayerShipOwnership]",
305+
lMatrix: _Pointer[basic.cTkMatrix34],
306+
leLandingGearState: c_uint32, # cGcPlayerShipOwnership::ShipSpawnLandingGearState
307+
liShipIndex: c_int32,
308+
lbSpawnShipOverride: c_bool,
309+
) -> c_bool: ...
310+
311+
@function_hook(
312+
"48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 48 8B 35 ? ? ? ? 8B DA"
313+
)
314+
def DestroyShip(
315+
self,
316+
this: "_Pointer[cGcPlayerShipOwnership]",
317+
liShipIndex: c_int32,
318+
) -> c_bool: ...
319+
320+
# Not sure about this...
321+
mShips: Annotated[list[sGcShipData], Field(sGcShipData * 12, 0x58)]
322+
# Both these found at the top of cGcPlayerShipOwnership::UpdateMeshRefresh
323+
mbShouldRefreshMesh: Annotated[bool, Field(c_bool, 0xA690)]
324+
mMeshRefreshState: Annotated[int, Field(c_uint32, 0xA694)]
325+
326+
277327
@partial_struct
278328
class cGcGameState(Structure):
279329
mPlayerState: Annotated[cGcPlayerState, 0xA950]
330+
# Found in cGcGameState::Update
331+
mPlayerShipOwnership: Annotated[cGcPlayerShipOwnership, 0xA2BD0]
280332

281333
@function_hook("48 89 5C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 88 54 24")
282334
def OnSaveProgressCompleted(
@@ -292,11 +344,18 @@ def OnSaveProgressCompleted(
292344
def LoadFromPersistentStorage(
293345
self,
294346
this: "_Pointer[cGcGameState]",
295-
leSlot: c_uint32,
347+
leSlot: Annotated[int, c_uint32],
296348
a3: c_int32,
297349
lbNetworkClientLoad: Annotated[bool, c_bool],
298350
) -> c_uint64: ...
299351

352+
@function_hook(
353+
"48 8B C4 48 89 58 ? 48 89 70 ? 48 89 78 ? 55 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? F3 0F 10 91"
354+
)
355+
def Update(
356+
self, this: "_Pointer[cGcGameState]", lfTimeStep: Annotated[float, c_float]
357+
): ...
358+
300359

301360
class cTkFSM(Structure):
302361
@function_hook(
@@ -553,8 +612,59 @@ def Update(
553612
): ...
554613

555614

615+
@partial_struct
616+
class cGcPlayerEnvironment(Structure):
617+
mPlayerTM: Annotated[basic.cTkMatrix34, Field(basic.cTkMatrix34, 0x0)]
618+
mUp: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x40)]
619+
620+
# Found below the call to cTkDynamicGravityControl::GetGravity in cGcPlayerEnvironment::Update
621+
miNearestPlanetIndex: Annotated[int, Field(c_uint32, 0x2BC)]
622+
mfDistanceFromPlanet: Annotated[float, Field(c_float, 0x2C0)]
623+
mfNearestPlanetSealevel: Annotated[float, Field(c_float, 0x2C4)]
624+
mNearestPlanetPos: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x2D0)]
625+
mbInsidePlanetAtmosphere: Annotated[bool, Field(c_bool, 0x2EC)]
626+
meLocation: Annotated[
627+
enums.EnvironmentLocation.Enum,
628+
Field(c_enum32[enums.EnvironmentLocation.Enum], 0x458),
629+
]
630+
meLocationStable: Annotated[
631+
enums.EnvironmentLocation.Enum,
632+
Field(c_enum32[enums.EnvironmentLocation.Enum], 0x464),
633+
]
634+
635+
@function_hook("48 83 EC ? 80 B9 ? ? ? ? ? C6 04 24")
636+
def IsOnboardOwnFreighter(
637+
self, this: "_Pointer[cGcPlayerEnvironment]"
638+
) -> c_bool: ...
639+
640+
@function_hook("8B 81 ? ? ? ? 83 E8 ? 83 F8 ? 0F 96 C0 C3 48 83 EC")
641+
def IsOnPlanet(self, this: "_Pointer[cGcPlayerEnvironment]") -> c_bool: ...
642+
643+
@function_hook("48 8B C4 F3 0F 11 48 ? 55 53 41 54")
644+
def Update(
645+
self,
646+
this: "_Pointer[cGcPlayerEnvironment]",
647+
lfTimeStep: Annotated[float, c_float],
648+
): ...
649+
650+
651+
@partial_struct
652+
class cGcEnvironment(Structure):
653+
# Passed into multiple cGcPlayerEnvironment methods.
654+
mPlayerEnvironment: Annotated[cGcPlayerEnvironment, 0x8A0]
655+
656+
@function_hook(
657+
"48 8B C4 48 89 48 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 4C 8B E9"
658+
)
659+
def UpdateRender(self, this: "_Pointer[cGcEnvironment]"):
660+
# TODO: There could be a few good functions to get which are called in here...
661+
...
662+
663+
556664
@partial_struct
557665
class cGcSimulation(Structure):
666+
# Found in cGcSimulation::Update. Passed into cGcEnvironment::Update.
667+
mEnvironment: Annotated[cGcEnvironment, 0xAF790]
558668
mPlayer: Annotated[cGcPlayer, 0x24DE40]
559669
# Found in cGcSimulation::Update. Passed into cGcSolarSystem::Update.
560670
mpSolarSystem: Annotated[_Pointer[cGcSolarSystem], 0x24C670]
@@ -825,34 +935,6 @@ def UpdateGravityPoint(
825935
]
826936

827937

828-
@partial_struct
829-
class cGcPlayerEnvironment(Structure):
830-
mPlayerTM: Annotated[basic.cTkMatrix34, Field(basic.cTkMatrix34, 0x0)]
831-
mUp: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x40)]
832-
833-
# Found below the call to cTkDynamicGravityControl::GetGravity in cGcPlayerEnvironment::Update
834-
miNearestPlanetIndex: Annotated[int, Field(c_uint32, 0x2BC)]
835-
mfDistanceFromPlanet: Annotated[float, Field(c_float, 0x2C0)]
836-
mfNearestPlanetSealevel: Annotated[float, Field(c_float, 0x2C4)]
837-
mNearestPlanetPos: Annotated[basic.Vector3f, Field(basic.Vector3f, 0x2D0)]
838-
mbInsidePlanetAtmosphere: Annotated[bool, Field(c_bool, 0x2EC)]
839-
840-
@function_hook("48 83 EC ? 80 B9 ? ? ? ? ? C6 04 24")
841-
def IsOnboardOwnFreighter(
842-
self, this: "_Pointer[cGcPlayerEnvironment]"
843-
) -> c_bool: ...
844-
845-
@function_hook("8B 81 ? ? ? ? 83 E8 ? 83 F8 ? 0F 96 C0 C3 48 83 EC")
846-
def IsOnPlanet(self, this: "_Pointer[cGcPlayerEnvironment]") -> c_bool: ...
847-
848-
@function_hook("48 8B C4 F3 0F 11 48 ? 55 53 41 54")
849-
def Update(
850-
self,
851-
this: "_Pointer[cGcPlayerEnvironment]",
852-
lfTimeStep: Annotated[float, c_float],
853-
): ...
854-
855-
856938
class Engine:
857939
@static_function_hook("40 53 48 83 EC ? 44 8B D1 44 8B C1")
858940
@staticmethod
@@ -1096,15 +1178,6 @@ def StateChange(
10961178
): ...
10971179

10981180

1099-
class cGcEnvironment(Structure):
1100-
@function_hook(
1101-
"48 8B C4 48 89 48 ? 55 53 56 57 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 0F 29 70 ? 4C 8B E9"
1102-
)
1103-
def UpdateRender(self, this: "_Pointer[cGcEnvironment]"):
1104-
# TODO: There could be a few good functions to get which are called in here...
1105-
...
1106-
1107-
11081181
class cGcPlayerNotifications(Structure):
11091182
@function_hook("48 89 5C 24 ? 48 89 74 24 ? 57 48 81 EC ? ? ? ? 44 8B 81")
11101183
def AddTimedMessage(
@@ -1236,7 +1309,15 @@ def GetPulseDriveFuelFactor(
12361309
) -> c_float: ...
12371310

12381311

1312+
@partial_struct
12391313
class cGcSpaceshipWeapons(Structure):
1314+
# These can be found in cGcSpaceshipWeapons::GetHeatFactor and cGcSpaceshipWeapons::GetOverheatProgress
1315+
# This enum corresponds to the element in the following 3 arrays by index.
1316+
meWeaponMode: Annotated[c_enum32[enums.cGcShipWeapons], 0xA4]
1317+
mafWeaponHeat: Annotated[list[float], Field(c_float * 7, 0x5FA4)]
1318+
mafWeaponOverheatTimer: Annotated[list[float], Field(c_float * 7, 0x5FC0)]
1319+
mabWeaponOverheated: Annotated[list[bool], Field(c_bool * 7, 0x5FDC)]
1320+
12401321
@function_hook("48 63 81 ?? ?? 00 00 80 BC 08 ?? ?? 00 00 00 74 12")
12411322
def GetOverheatProgress(self, this: "_Pointer[cGcSpaceshipWeapons]") -> c_float: ...
12421323

@@ -1257,6 +1338,9 @@ def GetCurrentShootPoints(
12571338
) -> c_uint64: # cGcShootPoint *
12581339
...
12591340

1341+
@function_hook("48 63 81 ? ? ? ? F3 0F 10 84 81")
1342+
def GetHeatFactor(self, this: "_Pointer[cGcSpaceshipWeapons]") -> c_float: ...
1343+
12601344

12611345
class cGcPlayerCharacterComponent(Structure):
12621346
@function_hook("48 8B C4 55 53 56 57 41 56 48 8D 68 A1 48 81 EC 90 00 00")

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ classifiers = [
2626
dependencies = [
2727
"pymhf[gui]>=0.2.1"
2828
]
29-
version = "155759.0"
29+
version = "155983.0"
3030

3131
[dependency-groups]
3232
dev = [

tools/data.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,5 +743,35 @@
743743
"name": "Engine::AddGroupNode",
744744
"signature": "48 89 5C 24 ? 57 48 81 EC ? ? ? ? 44 8B D2 44 8B CA 41 C1 EA ? 41 81 E1 ? ? ? ? 48 8B D9 45 85 D2 0F 84 ? ? ? ? 41 81 F9 ? ? ? ? 0F 84 ? ? ? ? 8B CA 48 8B 15 ? ? ? ? 81 E1 ? ? ? ? 48 8B 82 ? ? ? ? 48 63 0C 88 48 8B 82 ? ? ? ? 48 8B 3C C8 48 85 FF 74 ? 8B 4F ? 8B C1 25 ? ? ? ? 41 3B C1 75 ? C1 E9 ? 41 3B CA 75 ? 4C 8B CF 48 8D 4C 24 ? BA ? ? ? ? E8 ? ? ? ? 48 8B 0D ? ? ? ? 48 8D 05 ? ? ? ? 4C 8D 4C 24 ? 48 89 44 24 ? 41 B8 ? ? ? ? 48 89 7C 24 ? 48 8B D3 E8 ? ? ? ? 48 8D 4C 24 ? E8 ? ? ? ? EB ? C7 03 ? ? ? ? 48 8B C3 48 8B 9C 24 ? ? ? ? 48 81 C4 ? ? ? ? 5F C3 CC CC CC CC CC 48 89 5C 24",
745745
"mangled_name": "?AddGroupNode@Engine@@YA?AVTkHandle@@V2@PEBD@Z"
746+
},
747+
{
748+
"name": "cGcPlayerShipOwnership::UpdateMeshRefresh",
749+
"signature": "48 89 5C 24 ? 55 56 57 41 54 41 56 48 8D AC 24 ? ? ? ? 48 81 EC ? ? ? ? 45",
750+
"mangled_name": "?UpdateMeshRefresh@cGcPlayerShipOwnership@@AEAAXXZ"
751+
},
752+
{
753+
"name": "cGcPlayerShipOwnership::Update",
754+
"signature": "48 8B C4 55 53 56 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? 80 B9 ? ? ? ? ? 48 8B F1",
755+
"mangled_name": "?Update@cGcPlayerShipOwnership@@QEAAXM@Z"
756+
},
757+
{
758+
"name": "cGcGameState::Update",
759+
"signature": "48 8B C4 48 89 58 ? 48 89 70 ? 48 89 78 ? 55 41 54 41 55 41 56 41 57 48 8D A8 ? ? ? ? 48 81 EC ? ? ? ? F3 0F 10 91",
760+
"mangled_name": "?Update@cGcGameState@@QEAAXM@Z"
761+
},
762+
{
763+
"name": "cGcPlayerShipOwnership::SpawnNewShip",
764+
"signature": "44 89 44 24 ? 48 89 54 24 ? 55 56 41 54 41 56 41 57 48 8D 6C 24",
765+
"mangled_name": "?SpawnNewShip@cGcPlayerShipOwnership@@QEAA_NAEBVcTkMatrix34@@W4ShipSpawnLandingGearState@1@H_N@Z"
766+
},
767+
{
768+
"name": "cGcPlayerShipOwnership::DestroyShip",
769+
"signature": "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 48 89 7C 24 ? 41 56 48 83 EC ? 48 8B 35 ? ? ? ? 8B DA",
770+
"mangled_name": "?DestroyShip@cGcPlayerShipOwnership@@QEAA_NH@Z"
771+
},
772+
{
773+
"name": "cGcSpaceshipWeapons::GetHeatFactor",
774+
"signature": "48 63 81 ? ? ? ? F3 0F 10 84 81",
775+
"mangled_name": "?GetHeatFactor@cGcSpaceshipWeapons@@UEBAMXZ"
746776
}
747777
]

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)