-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcop.cpp
695 lines (589 loc) · 12.8 KB
/
cop.cpp
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
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
#include "cop.h"
#include "validate.h"
#include "ps2lowsfx.h"
#include "mem.h"
#include "utils.h"
#include "spidey.h"
#include "exp.h"
#include "ai.h"
EXPORT CCop* gCopGlobal;
static unsigned char gAttackFlagsRelated;
extern CVector gGlobalNormal;
extern CPlayer *MechList;
extern CBaddy *BaddyList;
EXPORT CCop* gCopList;
// @SMALLTODO
CCopLaserPing::CCopLaserPing(CVector*, CVector*, CVector*, u8, u8, u8)
{
printf("CCopLaserPing::CCopLaserPing(CVector*, CVector*, CVector*, u8, u8, u8)");
}
// @Ok
CCopLaserPing::~CCopLaserPing(void)
{
}
// @MEDIUMTODO
i32 CCop::WallHitCheck(CVector*, CVector*, i32)
{
printf("i32 CCop::WallHitCheck(CVector*, CVector*, i32)");
return 0x29072024;
}
// @Ok
void CCop::Acknowledge(void)
{
switch (this->dumbAssPad)
{
case 0:
this->mCBodyFlags |= 0x10u;
this->Neutralize();
this->RunAnim(2, 0, -1);
if ( Mem_RecoverPointer(&this->field_34C) )
{
new CAIProc_LookAt(
this,
reinterpret_cast<CBody*>(this->field_34C.field_0),
0,
2,
70,
200);
}
SFX_PlayPos(0x800Eu, &this->mPos, 0);
this->dumbAssPad++;
break;
case 1:
if ( this->field_142 )
{
this->field_31C.bothFlags = 28;
this->dumbAssPad = 0;
}
break;
default:
print_if_false(0, "Unknown substate!");
break;
}
}
// @Ok
INLINE void CCop::CheckToShoot(i32 a2, i32 a3)
{
if ( MechList->field_57C && !gCopList && !MechList->mHeldObject)
{
if ( ((this->field_218 & 0x800) && a2 < this->field_37C)
||
(this->field_324 && a2 < 1500 && (a3 != -1 || this->PathCheck(&this->mPos, &MechList->mPos, 0, 55))))
{
this->Neutralize();
gCopList = this;
this->field_31C.bothFlags = 9;
this->dumbAssPad = 0;
}
}
}
// @SMALLTODO
i32 CCop::SetUpLaser(CGPolyLine**, CVector*, CVector*)
{
printf("i32 CCop::SetUpLaser(CGPolyLine**, CVector*, CVector*)");
return 0x25042024;
}
// @Ok
INLINE i32 CCop::DrawBarrelFlash(
CVector *a2,
CVector *a3,
SLineInfo *a4,
u8 a5,
u8 a6,
u8 a7)
{
new CGlowFlash(a2, 5, a5, a6, a7, 32, 0, 0, 0, 0, 50, 20, 1, 20, 10, 40, 20, 10, 1);
return CCop::SetUpLaser(&this->field_380, a2, a3);
}
// @Ok
// @Test
void CCop::GetAttackPosition(CVector* pAttackerPos)
{
*pAttackerPos = MechList->mPos;
if (!(this->field_390 & 1) && (this->field_390 & 2))
{
if (this->field_391 & 0xEE)
{
pAttackerPos->vx += (this->field_391 & 0xAA ? 0x12C000 : 0x190000) * (this->field_391 > 8 ? 0xFFFFFFFF : 1);
}
if (this->field_391 & 0xBB)
{
pAttackerPos->vz += (this->field_391 & 0x83 ? 1 : -1) * (this->field_391 & 0xAA ? 0x12C000 : 0x190000);
}
}
}
// @Ok
void CCop::SetParamByIndex(i32 Index, i32 Param)
{
switch ( Index )
{
case 1:
this->field_364 = Param;
break;
case 2:
this->field_360 = Param;
break;
case 3:
this->field_368 = Param;
break;
case 4:
this->field_36C = Param;
break;
case 5:
this->field_370 = Param;
break;
case 8:
this->field_374 = Param;
break;
case 9:
this->field_1FC = Param;
break;
case 10:
this->field_37C = Param;
break;
case 11:
if ( Param )
this->field_218 |= 0x800;
else
this->field_218 &= 0xFFFFF7FF;
break;
default:
print_if_false(0, "Unknown index in C_SET_PARAMETER_BY_INDEX");
break;
}
}
// @Ok
INLINE i32 CCop::TryAddingCollidePointToPath(CVector *a2)
{
if (Utils_CrapDist(*a2, this->mPos) < 0x64)
return 0;
CVector v6 = *a2 - this->mPos;
v6 >>= 12;
v6 *= 3700;
v6 += this->mPos;
return this->AddPointToPath(&v6, 0);
}
// @NotOk
// does baddy not have 324???
void CCop::WarnOtherCops(void)
{
CCop *nearest = reinterpret_cast<CCop*>(this->GetClosest(306, 0));
if ( (nearest || ((nearest = reinterpret_cast<CCop*>(this->GetClosest(320, 0))) != 0))
&& !nearest->field_324)
{
new CMessage(this, nearest, 7, 0);
}
}
// @Ok
INLINE void CCop::StopShooting(void)
{
switch (this->dumbAssPad)
{
case 0:
this->RunAnim(12, 0, -1);
this->dumbAssPad++;
break;
case 1:
if (this->field_142)
{
this->field_31C.bothFlags = 28;
this->dumbAssPad = 0;
}
break;
default:
print_if_false(0, "Unknown substate!");
break;
}
}
// @NotOk
// globals flags :(
u8 CCop::Grab(CVector* a2)
{
if ( (this->CheckStateFlags(reinterpret_cast<SStateFlags*>(0x549220), 17) & 2)
|| !this->AddPointToPath(a2, 0) )
{
return 0;
}
this->field_31C.bothFlags = 20;
this->dumbAssPad = 0;
this->field_2A8 |= 0x40;
return 1;
}
// @Ok
void CCop::CreateCombatImpactEffect(CVector *a2, i32)
{
new CCombatImpactRing(a2, 0x6Cu, 108, 18, 384, 1792, 144);
new CCombatImpactRing(a2, 0x90u, 144, 72, 192, 896, 72);
}
// @Ok
void CCop::DieAfterFlyingAcrossRoom(void)
{
if (this->ShouldFall(200, 0x5F000))
{
this->field_218 &= 0xFFFFFFFD;
this->field_31C.bothFlags = 22;
}
else
{
this->PlayHitWallSound();
this->SetHeight(1, 100, 600);
this->field_31C.bothFlags = 26;
}
this->dumbAssPad = 0;
}
// @Ok
INLINE void CCop::StandStill(void)
{
switch (this->dumbAssPad)
{
case 0:
this->Neutralize();
this->CycleAnim(17, 1);
this->dumbAssPad++;
break;
default:
print_if_false(0, "Unknown substate.");
break;
}
}
// @Ok
void CCop::PlayHitWallSound(void)
{
if ( !this->field_1F8 )
{
if ( (this->field_218 & 0x400) != 0 )
SFX_PlayPos(0x802Fu, &this->mPos, 0);
else
SFX_PlayPos(0x802Eu, &this->mPos, 0);
}
}
// @Ok
INLINE void CCop::SetAttacker(void)
{
if (gCopGlobal != this)
{
this->ClearAttackFlags();
if (gCopGlobal)
{
gCopGlobal->ClearAttackFlags();
}
gCopGlobal = this;
this->field_390 = 1;
}
}
// @BIGTODO
void CCop::RunToWhereTheActionIs(CVector*)
{}
// @Ok
void CCop::HelpOutBuddy(CMessage *pMessage)
{
if (this->field_31C.bothFlags == 2 || this->field_31C.bothFlags == 1)
{
CItem *pItem = reinterpret_cast<CItem*>(Mem_RecoverPointer(&pMessage->mHandle));
if (pItem)
this->RunToWhereTheActionIs(&pItem->mPos);
}
}
// @Ok
INLINE i32 CCop::SpideyAnimUppercut(void)
{
return MechList->field_12A == 106
|| MechList->field_12A == 113
|| MechList->field_12A == 284;
}
// @NotOk
// figure type of 380
CCop::~CCop(void)
{
if (this->field_380)
delete this->field_380;
this->field_380 = 0;
if (this->field_384)
Mem_Delete(static_cast<void*>(this->field_384));
this->field_384 = 0;
if (gCopList == this)
gCopList = 0;
this->ClearAttackFlags();
this->DeleteFrom(reinterpret_cast<CBody**>(BaddyList));
}
// @Ok
i32 CCop::GetLaunched(CVector* a2, i32 a3, i32 a4, i32 a5)
{
CVector v13;
v13.vx = 0;
v13.vy = 0;
v13.vz = 0;
v13 = this->mPos;
v13.vx += a2->vx * (a4 + 1);
v13.vz += a2->vz * (a4 + 1);
i32 v10 = this->WallHitCheck(&v13, a2, a4);
if (v10 == 3)
return 0;
this->Neutralize();
this->mAccellorVel = *a2;
this->mAccellorVel.vy = 0;
if (!a3 || v10 == 2)
{
new CAIProc_LookAt(this, 0, &v13, 0, 80, 200);
}
return 10;
}
// @Ok
u8 CCop::TugImpulse(
CVector* a2,
CVector* a3,
CVector* a4)
{
this->field_2A8 &= ~8;
if (a4)
{
this->field_31C.bothFlags = 16;
this->dumbAssPad = 0;
if ( this->field_384 )
Mem_Delete(this->field_384);
this->field_384 = a4;
return 1;
}
i32 Launched = this->GetLaunched(a3, 0, 80, 0);
if (!Launched)
{
return 0;
}
if ( this->field_E2 <= 50 )
{
if ( Launched == 1 )
this->field_2A8 |= 0x10;
else
this->field_2A8 &= 0xFFFFFFEF;
}
this->field_31C.bothFlags = 14;
this->field_218 |= 0x4000;
this->dumbAssPad = 0;
return 1;
}
// @Ok
void CCop::LookForPlayer(void)
{
CVector v5;
v5.vx = 0;
v5.vy = 0;
v5.vz = 0;
switch (this->dumbAssPad)
{
case 0:
this->Neutralize();
this->CycleAnim(this->field_298.Bytes[0], 1);
this->dumbAssPad++;
this->field_21D = Rnd(64);
this->field_1F8 = 0;
break;
case 1:
CVector *mPos;
if (this->field_1F8 < 64)
mPos = &MechList->mPos;
else
mPos = &this->mPos;
this->GetWaypointNearTarget(mPos, 409600, this->field_21D, &v5);
this->field_21D++;
if ( !this->PathCheck(&this->mPos, &v5, 0, 55)
&& (this->AddPointToPath(&v5, 0)
|| this->AddPointToPath(&this->mPos, 0)
&& this->AddPointToPath(&v5, 0)) )
{
this->field_31C.bothFlags = 24;
this->dumbAssPad = 0;
}
else
{
if ( this->field_1F8++ > 128 )
{
this->field_324 = 0;
this->field_31C.bothFlags = 2;
this->dumbAssPad = 0;
}
}
break;
default:
print_if_false(0, "Unknown substate!");
break;
}
}
// @Ok
// @Matching
void CCopBulletTracer::Move(void)
{
this->SetWidth();
if (this->mMaxWidth)
this->mMaxWidth = mMaxWidth - 1;
this->mpRibbon->mpPoints[this->field_C].r = 0;
this->mpRibbon->mpPoints[this->field_C].g = 0;
this->mpRibbon->mpPoints[this->field_C].b = 0;
this->mpRibbon2->mpPoints[this->field_C].r = 0;
this->mpRibbon2->mpPoints[this->field_C].g = 0;
this->mpRibbon2->mpPoints[this->field_C].b = 0;
if ( this->field_C < 4 )
this->field_C++;
else
this->Die();
}
// @Ok
// @Matching
void CCopBulletTracer::SetWidth(void)
{
print_if_false(this->mpRibbon && this->mpRibbon2, "NULL mpRibbon and mpRibbon2");
for (i32 i = 0; i < 5; i++)
{
this->mpRibbon->mpPoints[i].Width = (u16)(this->mMaxWidth) * 2 + Rnd(this->mMaxWidth);
this->mpRibbon2->mpPoints[i].Width = Rnd(this->mMaxWidth);
}
this->mpRibbon->mpPoints[0].Width = 0;
this->mpRibbon->mpPoints[4].Width = Rnd(this->mMaxWidth);
this->mpRibbon2->mpPoints[0].Width = 0;
this->mpRibbon2->mpPoints[4].Width = 0;
}
// @SMALLTODO
CCopBulletTracer::CCopBulletTracer(CVector*, CVector*, CSuper*, SLineInfo*, u8, u8, u8)
{
printf("CCopBulletTracer::CCopBulletTracer(CVector*, CVector*, CSuper*, SLineInfo*, u8, u8, u8)");
}
// @Ok
CCopBulletTracer::~CCopBulletTracer(void)
{
delete this->mpRibbon;
delete this->mpRibbon2;
this->mpRibbon = 0;
this->mpRibbon2 = 0;
}
// @Ok
CCopPing::CCopPing(CSuper* pHost, SHook* pHook)
: CSimpleAnim(&gGlobalNormal, 10, 0, 1, 0, -1)
{
this->field_78.Part.vx = 0;
this->field_78.Part.vy = 0;
this->field_78.Part.vz = 0;
print_if_false(pHost != 0, "NULL pHost");
print_if_false(pHook != 0, "NULL pHook");
this->field_78 = *pHook;
this->field_70 = Mem_MakeHandle(pHost);
this->SetFrame(1);
this->SetTint(128, 128, 128);
this->field_58 = Rnd(1024);
if (Rnd(2))
this->field_58 *= -1;
this->mScale = 400;
this->SetPosition();
}
// @Ok
CCopPing::~CCopPing(void)
{
}
// @NotOk
// globals
CCop::CCop(int* a2, int a3)
{
i16 *v5 = this->SquirtAngles(reinterpret_cast<i16*>(this->SquirtPos(a2)));
this->ShadowOn();
this->field_D0 = 50;
this->AttachTo(reinterpret_cast<CBody**>(0x56E9900));
this->field_230 = 0;
this->field_1F4 = a3;
this->field_DE = a3;
__int16 v6 = this->field_38;
this->field_216 = 32;
this->field_D8 = 64;
this->field_31C.bothFlags = 0;
this->field_DC = v6 != 306 ? 150 : 96;
this->field_2A8 |= 1;
this->field_370 = v6 != 306 ? 400 : 300;
this->field_340 = *dword_5FCCF4;
this->field_360 = 3500;
this->field_364 = 400;
this->field_368 = 2047;
this->field_36C = 100;
this->field_374 = 10;
this->field_1FC = 10;
this->field_37C = 2000;
this->ParseScript(reinterpret_cast<unsigned __int16*>(v5));
this->field_212 = 60;
}
// @Ok
void Cop_CreateCop(const unsigned int *stack, unsigned int *result)
{
int* v2 = reinterpret_cast<int*>(*stack);
int v3 = static_cast<int>(stack[1]);
*result = reinterpret_cast<unsigned int>(new CCop(v2, v3));
}
// @Ok
void CCop::Victorious(void)
{
SFX_PlayPos(0x8024, &this->mPos, 0);
}
// @Ok
void __inline CCopPing::SetPosition(void)
{
CSuper* v2 = reinterpret_cast<CSuper*>(Mem_RecoverPointer(&this->field_70));
if (!v2)
this->Die();
else
M3dUtils_GetDynamicHookPosition(
reinterpret_cast<VECTOR*>(&this->mPos),
v2,
&this->field_78);
}
// @Ok
void CCopPing::Move(void)
{
this->SetPosition();
Bit_ReduceRGB(&this->mCodeBGR, 7);
if ((this->mCodeBGR & 0xFFFFFF) == 0)
this->Die();
}
// @NotOk
// globals
void CCop::ClearAttackFlags(void)
{
if (gCopGlobal == this)
{
gCopGlobal = NULL;
}
else if((this->field_390 & 2))
{
gAttackFlagsRelated &= ~this->field_391;
}
this->field_390 = 0;
this->field_391 = 0;
}
void validate_CCop(void){
VALIDATE_SIZE(CCop, 0x394);
VALIDATE(CCop, field_324, 0x324);
VALIDATE(CCop, field_340, 0x340);
VALIDATE(CCop, field_34C, 0x34C);
VALIDATE(CCop, field_360, 0x360);
VALIDATE(CCop, field_364, 0x364);
VALIDATE(CCop, field_368, 0x368);
VALIDATE(CCop, field_36C, 0x36C);
VALIDATE(CCop, field_370, 0x370);
VALIDATE(CCop, field_374, 0x374);
VALIDATE(CCop, field_37C, 0x37C);
VALIDATE(CCop, field_380, 0x380);
VALIDATE(CCop, field_384, 0x384);
VALIDATE(CCop, field_390, 0x390);
VALIDATE(CCop, field_391, 0x391);
}
void validate_CCopPing(void)
{
VALIDATE_SIZE(CCopPing, 0x80);
VALIDATE(CCopPing, field_70, 0x70);
VALIDATE(CCopPing, field_78, 0x78);
}
void validate_CCopBulletTracer(void)
{
VALIDATE_SIZE(CCopBulletTracer, 0x48);
VALIDATE(CCopBulletTracer, mpRibbon, 0x3C);
VALIDATE(CCopBulletTracer, mpRibbon2, 0x40);
VALIDATE(CCopBulletTracer, mMaxWidth, 0x44);
}
void validate_CCopLaserPing(void)
{
VALIDATE_SIZE(CCopLaserPing, 0xAC);
}