-
-
Notifications
You must be signed in to change notification settings - Fork 141
Expand file tree
/
Copy pathHooks.cpp
More file actions
629 lines (482 loc) · 16.8 KB
/
Copy pathHooks.cpp
File metadata and controls
629 lines (482 loc) · 16.8 KB
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
#include "Body.h"
#include <Ext/Anim/Body.h>
#include <Ext/Techno/Body.h>
#include <Ext/WeaponType/Body.h>
#include <unordered_set>
// has everything inited except SpawnNextAnim at this point
DEFINE_HOOK(0x466556, BulletClass_Init, 0x6)
{
GET(BulletClass*, pThis, ECX);
if (auto const pExt = BulletExt::ExtMap.TryFind(pThis))
{
auto const pType = pThis->Type;
pExt->FirerHouse = pThis->Owner ? pThis->Owner->Owner : nullptr;
pExt->CurrentStrength = pType->Strength;
pExt->TypeExtData = BulletTypeExt::ExtMap.Find(pType);
if (!pType->Inviso)
pExt->InitializeLaserTrails();
}
return 0;
}
// Set in BulletClass::AI and guaranteed to be valid within it.
namespace BulletAITemp
{
BulletExt::ExtData* ExtData;
BulletTypeExt::ExtData* TypeExtData;
}
DEFINE_HOOK(0x4666F7, BulletClass_AI, 0x6)
{
GET(BulletClass*, pThis, EBP);
const auto pBulletExt = BulletExt::ExtMap.Find(pThis);
const auto pBulletTypeExt = pBulletExt->TypeExtData;
BulletAITemp::ExtData = pBulletExt;
BulletAITemp::TypeExtData = pBulletTypeExt;
if (pBulletExt->InterceptedStatus & InterceptedStatus::Targeted)
{
if (const auto pTarget = abstract_cast<BulletClass*>(pThis->Target))
{
const auto pTargetExt = BulletExt::ExtMap.Find(pTarget);
if (!pTargetExt->TypeExtData->Armor.isset())
pTargetExt->InterceptedStatus |= InterceptedStatus::Locked;
}
}
if (pBulletExt->InterceptedStatus & InterceptedStatus::Intercepted)
{
if (const auto pTarget = abstract_cast<BulletClass*>(pThis->Target))
BulletExt::ExtMap.Find(pTarget)->InterceptedStatus &= ~InterceptedStatus::Locked;
if (pBulletExt->DetonateOnInterception)
pThis->Detonate(pThis->GetCoords());
pThis->Limbo();
pThis->UnInit();
const auto pTechno = pThis->Owner;
const auto pWeapon = pThis->WeaponType;
if (pTechno
&& pTechno->InLimbo
&& pWeapon
&& pWeapon->LimboLaunch)
{
pThis->SetTarget(nullptr);
auto damage = pTechno->Health * 2;
pTechno->SetLocation(pThis->GetCoords());
pTechno->ReceiveDamage(&damage, 0, RulesClass::Instance->C4Warhead, nullptr, true, false, nullptr);
}
}
//Because the laser trails will be drawn before the calculation of changing the velocity direction in each frame.
//This will cause the laser trails to be drawn in the wrong position too early, resulting in a visual appearance resembling a "bouncing".
//Let trajectories draw their own laser trails after the Trajectory's OnAI() to avoid predicting incorrect positions or pass through targets.
if (!pBulletExt->Trajectory && pBulletExt->LaserTrails.size())
{
const CoordStruct location = pThis->GetCoords();
const BulletVelocity& velocity = pThis->Velocity;
// We adjust LaserTrails to account for vanilla bug of drawing stuff one frame ahead.
// Pretty meh solution but works until we fix the bug - Kerbiter
CoordStruct drawnCoords
{
(int)(location.X + velocity.X),
(int)(location.Y + velocity.Y),
(int)(location.Z + velocity.Z)
};
for (const auto& pTrail : pBulletExt->LaserTrails)
{
// We insert initial position so the first frame of trail doesn't get skipped - Kerbiter
// TODO move hack to BulletClass creation
if (!pTrail->LastLocation.isset())
pTrail->LastLocation = location;
pTrail->Update(drawnCoords);
}
}
if (pThis->HasParachute)
{
int fallRate = pBulletExt->ParabombFallRate - pBulletTypeExt->Parachuted_FallRate;
const int maxFallRate = pBulletTypeExt->Parachuted_MaxFallRate.Get(RulesClass::Instance->ParachuteMaxFallRate);
if (fallRate < maxFallRate)
fallRate = maxFallRate;
pBulletExt->ParabombFallRate = fallRate;
pThis->FallRate = fallRate;
}
return 0;
}
DEFINE_HOOK(0x466897, BulletClass_AI_Trailer, 0x6)
{
enum { SkipGameCode = 0x4668BD };
GET(BulletClass*, pThis, EBP);
REF_STACK(const CoordStruct, coords, STACK_OFFSET(0x1A8, -0x184));
auto const pTrailerAnim = GameCreate<AnimClass>(pThis->Type->Trailer, coords, 1, 1);
auto const pTrailerAnimExt = AnimExt::ExtMap.Find(pTrailerAnim);
auto const pOwner = pThis->Owner ? pThis->Owner->Owner : BulletAITemp::ExtData->FirerHouse;
AnimExt::SetAnimOwnerHouseKind(pTrailerAnim, pOwner, nullptr, false, true);
pTrailerAnimExt->SetInvoker(pThis->Owner);
return SkipGameCode;
}
// Inviso bullets behave differently in BulletClass::AI when their target is bullet and
// seemingly (at least partially) adopt characteristics of a vertical projectile.
// This is a potentially slightly hacky solution to that, as proper solution
// would likely require making sense of BulletClass::AI and ain't nobody got time for that.
DEFINE_HOOK(0x4668BD, BulletClass_AI_Interceptor_InvisoSkip, 0x6)
{
enum { DetonateBullet = 0x467F9B };
GET(BulletClass*, pThis, EBP);
if (auto const pExt = BulletAITemp::ExtData)
{
if (pThis->Type->Inviso && pExt->InterceptorTechnoType)
return DetonateBullet;
}
return 0;
}
#pragma region Gravity
#define APPLYGRAVITY(pType)\
auto const nGravity = BulletTypeExt::GetAdjustedGravity(pType);\
__asm { fld nGravity };\
DEFINE_HOOK(0x4671B9, BulletClass_AI_ApplyGravity, 0x6)
{
GET(BulletTypeClass* const, pType, EAX);
APPLYGRAVITY(pType);
return 0x4671BF;
}
DEFINE_HOOK(0x6F7481, TechnoClass_Targeting_ApplyGravity, 0x6)
{
GET(WeaponTypeClass* const, pWeaponType, EDX);
APPLYGRAVITY(pWeaponType->Projectile);
return 0x6F74A4;
}
DEFINE_HOOK(0x6FDAA6, TechnoClass_FireAngle_6FDA00_ApplyGravity, 0x5)
{
GET(WeaponTypeClass* const, pWeaponType, EDI);
APPLYGRAVITY(pWeaponType->Projectile);
return 0x6FDACE;
}
DEFINE_HOOK(0x6FECB2, TechnoClass_FireAt_ApplyGravity, 0x6)
{
GET(BulletTypeClass* const, pType, EAX);
APPLYGRAVITY(pType);
return 0x6FECD1;
}
DEFINE_HOOK_AGAIN(0x44D2AE, BuildingClass_Mission_Missile_ApplyGravity, 0x6)
DEFINE_HOOK_AGAIN(0x44D264, BuildingClass_Mission_Missile_ApplyGravity, 0x6)
DEFINE_HOOK(0x44D074, BuildingClass_Mission_Missile_ApplyGravity, 0x6)
{
GET(WeaponTypeClass* const, pWeaponType, EBP);
APPLYGRAVITY(pWeaponType->Projectile);
switch (R->Origin())
{
case 0x44D074:
return 0x44D07A;
break;
case 0x44D264:
return 0x44D26A;
break;
case 0x44D2AE:
return 0x44D2B4;
break;
default:
__assume(0);
}
}
#pragma endregion
namespace ShrapnelTemp
{
BuildingClass* InitialTargetBuilding = nullptr;
std::unordered_set<ObjectClass*> TargetsToIgnore;
}
DEFINE_HOOK(0x46A3D6, BulletClass_Shrapnel_Forced, 0xA)
{
enum { Shrapnel = 0x46A40C, Skip = 0x46ADCD };
GET(BulletClass*, pThis, EDI);
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
ShrapnelTemp::InitialTargetBuilding = nullptr;
ShrapnelTemp::TargetsToIgnore.clear();
if (auto const pObject = pThis->GetCell()->FirstObject)
{
auto const rtti = pObject->WhatAmI();
if (rtti != AbstractType::Building)
{
return Shrapnel;
}
else if (pTypeExt->Shrapnel_AffectsBuildings)
{
ShrapnelTemp::InitialTargetBuilding = static_cast<BuildingClass*>(pObject);
return Shrapnel;
}
}
else if (pTypeExt->Shrapnel_AffectsGround)
{
return Shrapnel;
}
return Skip;
}
DEFINE_HOOK(0x46A4FB, BulletClass_Shrapnel_Targeting, 0x6)
{
enum { SkipObject = 0x46A8EA, Continue = 0x46A50F };
GET(BulletClass*, pThis, EDI);
GET(ObjectClass*, pObject, EBP);
GET(TechnoClass*, pSource, EAX);
GET(WeaponTypeClass*, pShrapnelWeapon, ESI);
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
bool isBuilding = pObject->WhatAmI() == AbstractType::Building;
bool ignorePreviouslyHit = pTypeExt->Shrapnel_IgnoreHitBuildings.Get(RulesExt::Global()->Shrapnel_IgnoreHitBuildings);
if (isBuilding)
{
// Do not fire shrapnels on the building itself if bouncing off one.
if (pObject == ShrapnelTemp::InitialTargetBuilding)
return SkipObject;
if (ignorePreviouslyHit && ShrapnelTemp::TargetsToIgnore.contains(pObject))
return SkipObject;
}
auto const pOwner = pSource->Owner;
if (pTypeExt->Shrapnel_UseWeaponTargeting)
{
auto const pWeaponExt = WeaponTypeExt::ExtMap.Find(pShrapnelWeapon);
auto const pType = pObject->GetType();
if (!pType->LegalTarget)
return SkipObject;
if (!pWeaponExt->SkipWeaponPicking && !EnumFunctions::IsCellEligible(pObject->GetCell(), pWeaponExt->CanTarget, true, true))
return SkipObject;
auto const pWH = pShrapnelWeapon->Warhead;
auto armorType = pType->Armor;
if (auto const pTechno = abstract_cast<TechnoClass*, true>(pObject))
{
if (!pWeaponExt->SkipWeaponPicking)
{
if (!EnumFunctions::CanTargetHouse(pWeaponExt->CanTargetHouses, pOwner, pTechno->Owner) || !EnumFunctions::IsTechnoEligible(pTechno, pWeaponExt->CanTarget)
|| !pWeaponExt->IsHealthInThreshold(pTechno) || !pWeaponExt->IsVeterancyInThreshold(pTechno) || !pWeaponExt->HasRequiredAttachedEffects(pTechno, pSource))
{
return SkipObject;
}
}
auto const pShield = TechnoExt::ExtMap.Find(pTechno)->Shield.get();
if (pShield && pShield->IsActive() && !pShield->CanBePenetrated(pWH))
armorType = pShield->GetArmorType();
}
if (GeneralUtils::GetWarheadVersusArmor(pWH, armorType) == 0.0)
return SkipObject;
}
else if (pOwner->IsAlliedWith(pObject))
{
return SkipObject;
}
if (isBuilding && ignorePreviouslyHit)
ShrapnelTemp::TargetsToIgnore.insert(pObject);
return Continue;
}
DEFINE_HOOK(0x46902C, BulletClass_Explode_Cluster, 0x6)
{
enum { SkipGameCode = 0x469091 };
GET(BulletClass*, pThis, ESI);
REF_STACK(const CoordStruct, origCoords, STACK_OFFSET(0x3C, -0x30));
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
const int min = pTypeExt->ClusterScatter_Min.Get();
const int max = pTypeExt->ClusterScatter_Max.Get();
auto coords = origCoords;
auto& random = ScenarioClass::Instance->Random;
for (int i = 0; i < pThis->Type->Cluster; i++)
{
pThis->Detonate(coords);
if (!pThis->IsAlive)
break;
const int distance = random.RandomRanged(min, max);
coords = MapClass::GetRandomCoordsNear(origCoords, distance, false);
}
return SkipGameCode;
}
constexpr bool CheckTrajectoryCanNotAlwaysSnap(const TrajectoryFlag flag)
{
return flag != TrajectoryFlag::Invalid;
/* return flag == TrajectoryFlag::Straight
|| flag == TrajectoryFlag::Bombard
|| flag == TrajectoryFlag::Parabola;*/
}
DEFINE_HOOK(0x467CCA, BulletClass_AI_TargetSnapChecks, 0x6)
{
enum { SkipChecks = 0x467CDE };
GET(BulletClass*, pThis, EBP);
auto const pType = pThis->Type;
// Do not require Airburst=no to check target snapping for Inviso / Trajectory=Straight projectiles
if (pType->Inviso)
{
R->EAX(pType);
return SkipChecks;
}
else if (auto const pExt = BulletAITemp::ExtData)
{
if (pExt->Trajectory && CheckTrajectoryCanNotAlwaysSnap(pExt->Trajectory->Flag()))
{
R->EAX(pType);
return SkipChecks;
}
}
return 0;
}
DEFINE_HOOK(0x468E61, BulletClass_Explode_TargetSnapChecks1, 0x6)
{
enum { Snap = 0x468E7B, SkipChecks = 0x468FF4 };
GET(BulletClass*, pThis, ESI);
auto const pExt = BulletExt::ExtMap.Find(pThis);
if (pExt->IsInstantDetonation)
return SkipChecks;
auto const pType = pThis->Type;
// Do not require Airburst=no to check target snapping for Inviso / Trajectory=Straight projectiles
if (pType->Inviso)
{
R->EAX(pType);
return Snap;
}
else if (pType->Arcing || pType->ROT > 0)
{
return 0;
}
if (pExt->Trajectory && CheckTrajectoryCanNotAlwaysSnap(pExt->Trajectory->Flag()) && !pExt->SnappedToTarget)
{
R->EAX(pType);
return Snap;
}
return 0;
}
DEFINE_HOOK(0x468E9F, BulletClass_Explode_TargetSnapChecks2, 0x6)
{
enum { SkipInitialChecksOnly = 0x468EC7, SkipSetCoordinate = 0x468F23, SkipChecks = 0x468FF4 };
GET(BulletClass*, pThis, ESI);
auto const pExt = BulletExt::ExtMap.Find(pThis);
if (pExt->IsInstantDetonation)
return SkipChecks;
auto const pType = pThis->Type;
// Do not require EMEffect=no & Airburst=no to check target coordinate snapping for Inviso projectiles.
if (pType->Inviso)
{
R->EAX(pType);
return SkipInitialChecksOnly;
}
else if (pType->Arcing || pType->ROT > 0)
{
return 0;
}
// Do not force Trajectory=Straight projectiles to detonate at target coordinates under certain circumstances.
// Fixes issues with walls etc.
if (pExt->Trajectory && CheckTrajectoryCanNotAlwaysSnap(pExt->Trajectory->Flag()) && !pExt->SnappedToTarget)
return SkipSetCoordinate;
return 0;
}
DEFINE_HOOK(0x468D3F, BulletClass_ShouldExplode_AirTarget, 0x6)
{
enum { SkipCheck = 0x468D73 };
GET(BulletClass*, pThis, ESI);
auto const pExt = BulletExt::ExtMap.Find(pThis);
if (pExt->Trajectory && CheckTrajectoryCanNotAlwaysSnap(pExt->Trajectory->Flag()))
return SkipCheck;
return 0;
}
DEFINE_HOOK(0x4687F8, BulletClass_Unlimbo_FlakScatter, 0x6)
{
GET(BulletClass*, pThis, EBX);
GET_STACK(const float, mult, STACK_OFFSET(0x5C, -0x44));
if (pThis->WeaponType)
{
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
const int defaultValue = RulesClass::Instance->BallisticScatter;
const int min = pTypeExt->BallisticScatter_Min.Get(Leptons(0));
const int max = pTypeExt->BallisticScatter_Max.Get(Leptons(defaultValue));
const int result = (int)((mult * ScenarioClass::Instance->Random.RandomRanged(2 * min, 2 * max)) / pThis->WeaponType->Range);
R->EAX(result);
}
return 0;
}
// Skip a forced detonation check for Level=true projectiles that is now handled in Hooks.Obstacles.cpp.
DEFINE_JUMP(LJMP, 0x468D08, 0x468D2F);
DEFINE_HOOK(0x6FF008, TechnoClass_Fire_BeforeMoveTo, 0x8)
{
GET(BulletClass* const, pBullet, EBX);
const auto pBulletType = pBullet->Type;
if (pBulletType->Arcing && !BulletTypeExt::ExtMap.Find(pBulletType)->Arcing_AllowElevationInaccuracy)
{
REF_STACK(BulletVelocity, velocity, STACK_OFFSET(0xB0, -0x60));
REF_STACK(const CoordStruct, crdSrc, STACK_OFFSET(0xB0, -0x6C));
REF_STACK(const CoordStruct, crdOffset, STACK_OFFSET(0xB0, -0x1C));
REF_STACK(const CoordStruct, fireCoords, STACK_OFFSET(0xB0, -0x6C));
const auto crdTgt = crdOffset + fireCoords;
BulletExt::ApplyArcingFix(pBullet, crdSrc, crdTgt, velocity);
}
return 0;
}
DEFINE_HOOK(0x44D46E, BuildingClass_Mission_Missile_BeforeMoveTo, 0x8)
{
GET(BulletClass* const, pBullet, EDI);
const auto pBulletType = pBullet->Type;
if (pBulletType->Arcing && !BulletTypeExt::ExtMap.Find(pBulletType)->Arcing_AllowElevationInaccuracy)
{
REF_STACK(BulletVelocity, velocity, STACK_OFFSET(0xE8, -0xD0));
REF_STACK(const CoordStruct, crdSrc, STACK_OFFSET(0xE8, -0x8C));
REF_STACK(const CoordStruct, crdTgt, STACK_OFFSET(0xE8, -0x4C));
BulletExt::ApplyArcingFix(pBullet, crdSrc, crdTgt, velocity);
}
return 0;
}
// Vanilla inertia effect only for bullets with ROT=0
DEFINE_HOOK(0x415F25, AircraftClass_Fire_TrajectorySkipInertiaEffect, 0x6)
{
enum { SkipCheck = 0x4160BC };
GET(BulletClass*, pThis, ESI);
if (BulletExt::ExtMap.Find(pThis)->Trajectory)
return SkipCheck;
return 0;
}
#pragma region Parabombs
// Patch out Ares parabomb implementation.
DEFINE_PATCH(0x46867F, 0x6A, 0x00, 0x8B, 0xD9, 0x50);
// Add in our own.
static bool __fastcall ObjectClass_Unlimbo_Parachuted_Wrapper(BulletClass* pThis, void*, const CoordStruct& coords, DirType facing)
{
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
if (pTypeExt->Parachuted)
return pThis->SpawnParachuted(coords);
return pThis->Unlimbo(coords, facing);
}
DEFINE_FUNCTION_JUMP(CALL, 0x468684, ObjectClass_Unlimbo_Parachuted_Wrapper);
// Set parachute animation on projectile.
DEFINE_HOOK(0x5F5A62, ObjectClass_SpawnParachuted_BombParachute, 0x5)
{
enum { SkipGameCode = 0x5F5A99 };
GET(BulletClass*, pThis, ESI);
GET(CoordStruct*, coords, EDI);
auto const pTypeExt = BulletTypeExt::ExtMap.Find(pThis->Type);
auto const pAnimType = pTypeExt->BombParachute.Get(RulesClass::Instance->BombParachute);
AnimClass* pAnim = nullptr;
if (pAnimType)
{
pAnim = GameCreate<AnimClass>(pAnimType, *coords);
pAnim->Owner = pThis->Owner ? pThis->Owner->Owner : BulletExt::ExtMap.Find(pThis)->FirerHouse;
const int schemeIndex = pAnim->Owner ? pAnim->Owner->ColorSchemeIndex : RulesExt::Global()->AnimRemapDefaultColorScheme;
pAnim->LightConvert = ColorScheme::Array[schemeIndex]->LightConvert;
pThis->Parachute = pAnim;
}
R->EAX(pAnim);
return SkipGameCode;
}
DEFINE_HOOK(0x467AB2, BulletClass_AI_Parabomb, 0x7)
{
enum { SkipGameCode = 0x467B1A };
GET(BulletClass*, pThis, EBP);
if (pThis->HasParachute)
return SkipGameCode;
return 0;
}
#pragma endregion
// Replaces Ares' handling of Ranged=true projectiles.
DEFINE_HOOK(0x467BA4, BulletClass_AI_Ranged, 0x6)
{
GET(BulletClass*, pThis, EBP);
REF_STACK(CoordStruct, coordNew, STACK_OFFSET(0x1A8, -0x184));
REF_STACK(bool, shouldExplode, STACK_OFFSET(0x1A8, -0x190));
if (pThis->Type->Ranged)
{
auto const pExt = BulletExt::ExtMap.Find(pThis);
pExt->DistanceTraveled += Game::F2I(coordNew.DistanceFrom(pThis->GetCoords()));
int maxRange = pThis->Range;
if (maxRange > 0 && pThis->WeaponType && pThis->Owner
&& WeaponTypeExt::ExtMap.Find(pThis->WeaponType)->ProjectileRange_ApplyModifiers)
{
maxRange = WeaponTypeExt::GetRangeWithModifiers(pThis->WeaponType, pThis->Owner, maxRange);
}
shouldExplode |= pExt->DistanceTraveled >= maxRange;
}
pThis->SetLocation(coordNew);
return 0;
}