forked from Bad-Scientists/AF-Script-Packet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spatialState.d
231 lines (190 loc) · 6.7 KB
/
spatialState.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
func void zCAIPlayer_CalcStateVars (var int aiPlayerPtr) {
//0x004FE8D0 private: void __thiscall zCAIPlayer::CalcStateVars(void)
const int zCAIPlayer__CalcStateVars_G1 = 5236944;
//0x0050E440 private: void __thiscall zCAIPlayer::CalcStateVars(void)
const int zCAIPlayer__CalcStateVars_G2 = 5301312;
if (!aiPlayerPtr) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL__thiscall (_@ (aiPlayerPtr), MEMINT_SwitchG1G2 (zCAIPlayer__CalcStateVars_G1, zCAIPlayer__CalcStateVars_G2));
call = CALL_End();
};
};
/*
* zCVob_GetCollisionObject
*/
func int zCVob_GetCollisionObject (var int vobPtr) {
//0x005F10C0 public: class zCCollisionObject * __thiscall zCVob::GetCollisionObject(void)const
const int zCVob__GetCollisionObject_G1 = 6230208;
//0x0061E650 public: class zCCollisionObject * __thiscall zCVob::GetCollisionObject(void)const
const int zCVob__GetCollisionObject_G2 = 6415952;
if (!vobPtr) { return 0; };
var int retVal;
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__thiscall (_@ (vobPtr), MEMINT_SwitchG1G2 (zCVob__GetCollisionObject_G1, zCVob__GetCollisionObject_G2));
call = CALL_End();
};
return + retVal;
};
/*
* Vob_GetSpatialState
*/
func int Vob_GetSpatialState (var int vobPtr) {
//Same offset size for G1 & G2 NoTR
//zTSpatialState m_oSpatialState; // sizeof 20h offset C0h
//zTSpatialState m_oSpatialState; // sizeof 20h offset C0h
const int m_oSpatialState_offset = 192;
if (!vobPtr) { return 0; };
var int collObjectPtr; collObjectPtr = zCVob_GetCollisionObject (vobPtr);
if (!collObjectPtr) { return 0; };
return + (collObjectPtr + m_oSpatialState_offset);
};
/*
* Vob_GetConfig
*/
func int Vob_GetConfig (var int vobPtr) {
//Same offset size for G1 & G2 NoTR
//zTConfig m_oConfig; // sizeof 10h offset FCh
//zTConfig m_oConfig; // sizeof 10h offset FCh
const int m_oConfig_offset = 252;
if (!vobPtr) { return 0; };
var int collObjectPtr; collObjectPtr = zCVob_GetCollisionObject (vobPtr);
if (!collObjectPtr) { return 0; };
return + (collObjectPtr + m_oConfig_offset);
};
//float
func int zCAIPlayer_GetWaterLevel (var int aiPlayerPtr) {
if (!aiPlayerPtr) { return FLOATNULL; };
var zCAIPlayer aiPlayer; aiPlayer = _^ (aiPlayerPtr);
return aiPlayer.waterLevel;
};
//float
func int zCAIPlayer_GetFeetY (var int aiPlayerPtr) {
if (!aiPlayerPtr) { return FLOATNULL; };
var zCAIPlayer aiPlayer; aiPlayer = _^ (aiPlayerPtr);
return aiPlayer.feetY;
};
//float
func int zCAIPlayer_GetHeadY (var int aiPlayerPtr) {
if (!aiPlayerPtr) { return FLOATNULL; };
var zCAIPlayer aiPlayer; aiPlayer = _^ (aiPlayerPtr);
return aiPlayer.headY;
};
//float
func int zCAIPlayer_GetAboveFloor (var int aiPlayerPtr) {
if (!aiPlayerPtr) { return FLOATNULL; };
var zCAIPlayer aiPlayer; aiPlayer = _^ (aiPlayerPtr);
return aiPlayer.aboveFloor;
};
//float
func int zCAIPlayer_GetFallDownDistanceY (var int aiPlayerPtr) {
if (!aiPlayerPtr) { return FLOATNULL; };
var zCAIPlayer aiPlayer; aiPlayer = _^ (aiPlayerPtr);
return aiPlayer.fallDownDistanceY;
};
//float
func int Vob_GetFloorY (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_fFloorY;
};
//float
func int Vob_GetLastFloorY (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_fLastFloorY;
};
//float
func int Vob_GetWaterY (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_fWaterY;
};
//float
func int Vob_GetCeilingY (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_fCeilingY;
};
//zCPolygon*
func int Vob_GetFloorPoly (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_poFloorPoly;
};
//zCPolygon*
func int Vob_GetWaterPoly (var int vobPtr) {
var int spatialStatePtr; spatialStatePtr = Vob_GetSpatialState (vobPtr);
if (!spatialStatePtr) { return FLOATNULL; };
var zTSpatialState spatialState; spatialState = _^ (spatialStatePtr);
return spatialState.m_poWaterPoly;
};
//-- Wrapper functions for Npcs
//zTConfig*
func int Npc_GetConfig (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return 0; };
return + Vob_GetConfig (_@ (slf));
};
//float
func int Npc_GetFeetY (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return FLOATNULL; };
if (!slf.aniCtrl) { return FLOATNULL; };
return + zCAIPlayer_GetFeetY (slf.aniCtrl);
};
//float
func int Npc_GetAboveFloor (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return FLOATNULL; };
if (!slf.aniCtrl) { return FLOATNULL; };
return + zCAIPlayer_GetAboveFloor (slf.aniCtrl);
};
//float
func int Npc_GetWaterY (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return FLOATNULL; };
return + Vob_GetWaterY (_@ (slf));
};
//floor
func int Npc_GetFloorY (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return FLOATNULL; };
return + Vob_GetFloorY (_@ (slf));
};
//float
func int Npc_GetHeadY (var int slfInstance) {
var oCNpc slf; slf = Hlp_GetNpc (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return FLOATNULL; };
return + zCAIPlayer_GetHeadY (slf.aniCtrl);
};
//float
func int Npc_GetWaterDepthKnee (var int slfInstance) {
//Check if Npc is flying - if yes - return 0 water depth
var int configPtr; configPtr = Npc_GetConfig (slfInstance);
if (configPtr) {
var zTConfig config; config = _^ (configPtr);
if (config.bitfield[1] & bitfield1_m_eState == zCONFIG_STATE_FLY)
|| (config.bitfield[1] & bitfield1_m_eState == zCONFIG_STATE_SLIDE)
{
return FLOATNULL;
};
};
//Return water - knees difference
var int feetY; feetY = Npc_GetFeetY (slfInstance);
var int waterY; waterY = Npc_GetWaterY (slfInstance);
//If water is underneath feet - return 0
if (lf (waterY, feetY)) {
return FLOATNULL;
};
//Get water depth knee
var int waterDepthKnee; waterDepthKnee = subF (waterY, feetY);
return + waterDepthKnee;
};