-
Notifications
You must be signed in to change notification settings - Fork 2
/
camera.d
417 lines (335 loc) · 11.4 KB
/
camera.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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
/*
* zCCamera_Get_activeCam
* - gets active camera
*/
func int zCCamera_Get_activeCam () {
//0x00873240 public: static class zCCamera * zCCamera::activeCam
const int activeCam_addr_G1 = 8860224;
//0x008D7F94 public: static class zCCamera * zCCamera::activeCam
const int activeCam_addr_G2 = 9273236;
return + MEMINT_SwitchG1G2 (activeCam_addr_G1, activeCam_addr_G2);
};
/*
* zCCamera_Activate
* - activates camera - updates camMatrix
*/
func void zCCamera_Activate (var int camera) {
//0x005364C0 public: void __thiscall zCCamera::Activate(void)
const int zCCamera__Activate_G1 = 5465280;
//0x0054A700 public: void __thiscall zCCamera::Activate(void)
const int zCCamera__Activate_G2 = 5547776;
if (!camera) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL__thiscall (camera, MEMINT_SwitchG1G2 (zCCamera__Activate_G1, zCCamera__Activate_G2));
call = CALL_End();
};
};
/*
* zCCamera_ProjectF
* - projects 3D points in the world to screen coordinates X & Y (floats)
*/
func void zCCamera_ProjectF (var int camera, var int posPtr, var int xscrPtrF, var int yscrPtrF) {
//0x0051D7F0 public: void __thiscall zCCamera::Project(class zVEC3 const * const,float &,float &)const
const int zCCamera__Project_G1 = 5363696;
//0x00530030 public: void __thiscall zCCamera::Project(class zVEC3 const * const,float &,float &)const
const int zCCamera__Project_G2 = 5439536;
if (!camera) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PtrParam ( _@ (yscrPtrF));
CALL_PtrParam ( _@ (xscrPtrF));
CALL_PtrParam ( _@ (posPtr));
CALL__thiscall (camera, MEMINT_SwitchG1G2 (zCCamera__Project_G1, zCCamera__Project_G2));
call = CALL_End();
};
};
/*
* zCCamera_Project
* - projects 3D points in the world to screen coordinates X & Y (ints)
*/
func void zCCamera_Project (var int camera, var int posPtr, var int xscrPtr, var int yscrPtr) {
//0x005606D0 public: void __thiscall zCCamera::Project(class zVEC3 const * const,int &,int &)
const int zCCamera__Project_G1 = 5637840;
//0x0057A440 public: void __thiscall zCCamera::Project(class zVEC3 const * const,int &,int &)
const int zCCamera__Project_G2 = 5743680;
if (!camera) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PtrParam ( _@ (yscrPtr));
CALL_PtrParam ( _@ (xscrPtr));
CALL_PtrParam ( _@ (posPtr));
CALL__thiscall (camera, MEMINT_SwitchG1G2 (zCCamera__Project_G1, zCCamera__Project_G2));
call = CALL_End();
};
};
/*
* zCAIBase_Release
* - ai camera destructor
*/
func void zCAIBase_Release (var int ai) {
//0x004841F0 protected: virtual __thiscall zCAIBase::~zCAIBase(void)
const int zCAIBase__zCAIBase_G1 = 4735472;
//0x0048BE50 protected: virtual __thiscall zCAIBase::~zCAIBase(void)
const int zCAIBase__zCAIBase_G2 = 4767312;
if (!ai) { return; };
zCObject_Release (ai);
};
/*
* oCNpc_ActivateDialogCam
* - activates dialogue camera between Npcs (overrides oCNpc.talkOther pointer)
*/
func int oCNpc_ActivateDialogCam (var int slfInstance, var int othInstance, var int durationF) {
//0x006B2430 public: int __thiscall oCNpc::ActivateDialogCam(float)
const int oCNpc__ActivateDialogCam_G1 = 7021616;
//0x00758130 public: int __thiscall oCNpc::ActivateDialogCam(float)
const int oCNpc__ActivateDialogCam_G2 = 7700784;
var oCNpc slf; slf = Hlp_GetNPC (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return 0; };
var oCNpc oth; oth = Hlp_GetNPC (othInstance);
if (!Hlp_IsValidNpc (oth)) { return 0; };
var int retVal;
var int slfPtr; slfPtr = _@ (slf);
slf.talkOther = _@ (oth);
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL_FloatParam (_@ (durationF));
CALL__thiscall (_@ (slfPtr), MEMINT_SwitchG1G2 (oCNpc__ActivateDialogCam_G1, oCNpc__ActivateDialogCam_G2));
call = CALL_End();
};
return + retVal;
};
/*
* oCNpc_DeactivateDialogCam
* - deactivates dialogue camera
*/
func int oCNpc_DeactivateDialogCam (var int slfInstance) {
//0x006B2670 public: int __thiscall oCNpc::DeactivateDialogCam(void)
const int oCNpc__DeactivateDialogCam_G1 = 7022192;
//0x00758360 public: int __thiscall oCNpc::DeactivateDialogCam(void)
const int oCNpc__DeactivateDialogCam_G2 = 7701344;
var oCNpc slf; slf = Hlp_GetNPC (slfInstance);
if (!Hlp_IsValidNpc (slf)) { return 0; };
var int retVal;
var int slfPtr; slfPtr = _@ (slf);
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__thiscall (_@ (slfPtr), MEMINT_SwitchG1G2 (oCNpc__DeactivateDialogCam_G1, oCNpc__DeactivateDialogCam_G2));
call = CALL_End();
};
return + retVal;
};
/*
* zCSession_GetCameraVob
* - returns camera vob zCVob *
*/
func int zCSession_GetCameraVob () {
//0x005B7290 public: virtual class zCVob * __thiscall zCSession::GetCameraVob(void)const
const int zCSession__GetCameraVob_G1 = 5993104;
//0x005DE7B0 public: virtual class zCVob * __thiscall zCSession::GetCameraVob(void)const
const int zCSession__GetCameraVob_G2 = 6154160;
//TODO: Can we use oCGame here: class oCGame : public zCSession { ?
//Or do we need to get session via:
//0x005F9C40 public: class zCSession * __thiscall zCWorld::GetOwnerSession(void)
//0x00628480 public: class zCSession * __thiscall zCWorld::GetOwnerSession(void)
var int retVal;
var int gamePtr; gamePtr = _@ (MEM_Game);
if (!gamePtr) { return 0; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__thiscall (_@ (gamePtr), MEMINT_SwitchG1G2 (zCSession__GetCameraVob_G1, zCSession__GetCameraVob_G2));
call = CALL_End();
};
return + retVal;
};
/*
* zCAICamera_SetVob
* - sets up camera zCVob *
*/
func void zCAICamera_SetVob (var int aiPtr, var int vobPtr) {
//0x00499910 public: void __thiscall zCAICamera::SetVob(class zCVob *)
const int zCAICamera__SetVob_G1 = 4823312;
//0x004A0E60 public: void __thiscall zCAICamera::SetVob(class zCVob *)
const int zCAICamera__SetVob_G2 = 4853344;
if (!aiPtr) { return; };
if (!vobPtr) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PtrParam (_@ (vobPtr));
CALL__thiscall (_@ (aiPtr), MEMINT_SwitchG1G2 (zCAICamera__SetVob_G1, zCAICamera__SetVob_G2));
call = CALL_End();
};
};
/*
* zCSession_GetCamera
* - returns camera zCCamera *
*/
func int zCSession_GetCamera () {
//0x005B7270 public: virtual class zCCamera * __thiscall zCSession::GetCamera(void)const
const int zCSession__GetCamera_G1 = 5993072;
//0x005DE790 public: virtual class zCCamera * __thiscall zCSession::GetCamera(void)const
const int zCSession__GetCamera_G2 = 6154128;
var int retVal;
var int gamePtr; gamePtr = _@ (MEM_Game);
if (!gamePtr) { return 0; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__thiscall (_@ (gamePtr), MEMINT_SwitchG1G2 (zCSession__GetCamera_G1, zCSession__GetCamera_G2));
call = CALL_End();
};
return + retVal;
};
/*
* zCSession_GetCameraAI
* - returns camera zCAICamera *
* (same as zCSession_GetCameraAI)
*/
func int zCSession_GetCameraAI () {
//0x005B7280 public: virtual class zCAICamera * __thiscall zCSession::GetCameraAI(void)const
const int zCSession__GetCameraAI_G1 = 5993088;
//0x005DE7A0 public: virtual class zCAICamera * __thiscall zCSession::GetCameraAI(void)const
const int zCSession__GetCameraAI_G2 = 6154144;
var int retVal;
var int gamePtr; gamePtr = _@ (MEM_Game);
if (!gamePtr) { return 0; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__thiscall (_@ (gamePtr), MEMINT_SwitchG1G2 (zCSession__GetCameraAI_G1, zCSession__GetCameraAI_G2));
call = CALL_End();
};
return + retVal;
};
/*
* zCAICamera_GetCurrent
* - returns camera zCAICamera *
*/
func int zCAICamera_GetCurrent () {
//0x004988E0 public: static class zCAICamera * __cdecl zCAICamera::GetCurrent(void)
const int zCSession__GetCurrent_G1 = 4819168;
//0x0049FD20 public: static class zCAICamera * __cdecl zCAICamera::GetCurrent(void)
const int zCSession__GetCurrent_G2 = 4848928;
var int retVal;
const int call = 0;
if (CALL_Begin(call)) {
CALL_PutRetValTo (_@ (retVal));
CALL__cdecl (MEMINT_SwitchG1G2 (zCSession__GetCurrent_G1, zCSession__GetCurrent_G2));
call = CALL_End();
};
return + retVal;
};
/*
* zCAICamera_SetTarget
* - sets target for camera ai
*/
func void zCAICamera_SetTarget (var int aiPtr, var int vobPtr) {
//0x00499BC0 public: void __thiscall zCAICamera::SetTarget(class zCVob *)
const int zCAICamera__SetTarget_G1 = 4824000;
//0x004A1120 public: void __thiscall zCAICamera::SetTarget(class zCVob *)
const int zCAICamera__SetTarget_G2 = 4854048;
if (!aiPtr) { return; };
if (!vobPtr) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PtrParam (_@ (vobPtr));
CALL__thiscall (_@ (aiPtr), MEMINT_SwitchG1G2 (zCAICamera__SetTarget_G1, zCAICamera__SetTarget_G2));
call = CALL_End();
};
};
/*
* zCAICamera_ReceiveMsg
* - msgPtr has to be pointer to message type!
*/
func void zCAICamera_ReceiveMsg (var int aiPtr, var int msgPtr) {
//0x004998E0 public: void __thiscall zCAICamera::ReceiveMsg(enum zTAICamMsg const &)
const int zCAICamera__ReceiveMsg_G1 = 4823264;
//0x004A0E30 public: void __thiscall zCAICamera::ReceiveMsg(enum zTAICamMsg const &)
const int zCAICamera__ReceiveMsg_G2 = 4853296;
if (!aiPtr) { return; };
if (!msgPtr) { return; };
const int call = 0;
if (CALL_Begin(call)) {
CALL_PtrParam (_@ (msgPtr));
CALL__thiscall (_@ (aiPtr), MEMINT_SwitchG1G2 (zCAICamera__ReceiveMsg_G1, zCAICamera__ReceiveMsg_G2));
call = CALL_End();
};
};
/*
* Camera_GetTarget
* - returns target of camera ai
*/
func int Camera_GetTarget () {
var int aiPtr; aiPtr = zCSession_GetCameraAI ();
if (!aiPtr) { return 0; };
var zCAICamera ai; ai = _^ (aiPtr);
return ai.target;
};
/*
* Camera_SetTarget
* - sets target for camera ai (zPLAYER_BEAMED message will switch to target immediately)
*/
func void Camera_SetTarget (var int vobPtr) {
var int aiPtr; aiPtr = zCSession_GetCameraAI ();
zCAICamera_SetTarget (aiPtr, vobPtr);
zCAICamera_ReceiveMsg (aiPtr, _@ (zPLAYER_BEAMED));
};
/*
* Dangerous - can despawn player if you are not careful :)
* Engine function is unstable if called multiple times - accesses pointer to an Npc which might be meanwhile invalid?
*
* !!! use 'safe' version of the function below !!!
*/
//func void oCGame_SwitchCamToNextNpc () {
// //0x0065EDD0 public: void __thiscall oCGame::SwitchCamToNextNpc(void)
// const int oCGame_SwitchCamToNextNpc_G1 = 6680016;
//
// //0x006FBF40 public: void __thiscall oCGame::SwitchCamToNextNpc(void)
// const int oCGame_SwitchCamToNextNpc_G2 = 7323456;
//
// var int gamePtr; gamePtr = _@ (MEM_Game);
// if (!gamePtr) { return; };
//
// //const int call = 0;
// //if (CALL_Begin(call)) {
// CALL__thiscall (gamePtr, MEMINT_SwitchG1G2 (oCGame_SwitchCamToNextNpc_G1, oCGame_SwitchCamToNextNpc_G2));
// // call = CALL_End();
// //};
//};
var int watchNpcNr;
func void oCGame_SwitchCamToNextNpc_Reset () {
watchNpcNr = 0;
};
/*
* oCGame_SwitchCamToNextNpc
* - switches camera to next Npc npc voblist
* - returns pointer of target Npc
*/
func int oCGame_SwitchCamToNextNpc () {
var int listPtr;
listPtr = MEM_World_Get_voblist_npcs ();
var int npcNr; npcNr = -1;
var int npcPtr; npcPtr = 0;
var zCListSort list;
while (listPtr);
list = _^ (listPtr);
if (zCVob_GetHomeWorld (list.data)) {
npcNr += 1;
if (npcNr == watchNpcNr) {
npcPtr = list.data;
watchNpcNr += 1;
break;
};
};
listPtr = list.next;
end;
if (npcPtr) {
Camera_SetTarget (npcPtr);
} else {
watchNpcNr = 0;
};
return + npcPtr;
};