MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / ShotLara

Function ShotLara

TombEngine/Game/people.cpp:19–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17using namespace TEN::Collision::Point;
18
19bool ShotLara(ItemInfo* item, AI_INFO* AI, const CreatureBiteInfo& gun, short extraRotation, int damage)
20{
21 auto* creature = GetCreatureInfo(item);
22 auto* enemy = creature->Enemy;
23
24 if (enemy == nullptr)
25 return false;
26
27 bool hasHit = false;
28 bool isTargetable = false;
29
30 if (AI->distance <= SQUARE(MAX_VISIBILITY_DISTANCE) && Targetable(item, AI))
31 {
32 int distance = phd_sin(AI->enemyFacing) * enemy->Animation.Velocity.z * pow(MAX_VISIBILITY_DISTANCE, 2) / 300;
33 distance = SQUARE(distance) + AI->distance;
34 if (distance <= SQUARE(MAX_VISIBILITY_DISTANCE))
35 {
36 int random = (SQUARE(MAX_VISIBILITY_DISTANCE) - AI->distance) / (SQUARE(MAX_VISIBILITY_DISTANCE) / 0x5000) + 8192;
37 hasHit = GetRandomControl() < random;
38 }
39 else
40 {
41 hasHit = false;
42 }
43
44 isTargetable = true;
45 }
46 else
47 {
48 hasHit = false;
49 isTargetable = false;
50 }
51
52 if (damage)
53 {
54 if (enemy->IsLara())
55 {
56 if (hasHit)
57 {
58 DoDamage(enemy, damage);
59 CreatureEffect(item, gun, &GunHit);
60 }
61 else if (isTargetable)
62 CreatureEffect(item, gun, &GunMiss);
63 }
64 else
65 {
66 CreatureEffect(item, gun, &GunShot);
67 if (hasHit)
68 {
69 enemy->HitStatus = true;
70 enemy->HitPoints += damage / -10;
71
72 int random = GetRandomControl() & 0xF;
73 if (random > 14)
74 random = 0;
75
76 auto pos = GetJointPosition(enemy, random);

Callers 15

SilencerControlFunction · 0.85
ShootWorkerMachineGunFunction · 0.85
SkidooManControlFunction · 0.85
ShootWorkerShotgunFunction · 0.85
WorkerDualGunControlFunction · 0.85
MercenaryUziControlFunction · 0.85
MPGunControlFunction · 0.85
ControlKoldFunction · 0.85
SkateboardKidShootFunction · 0.85
CowboyControlFunction · 0.85
GuardControlFunction · 0.85

Calls 9

GetCreatureInfoFunction · 0.85
TargetableFunction · 0.85
phd_sinFunction · 0.85
GetRandomControlFunction · 0.85
DoDamageFunction · 0.85
CreatureEffectFunction · 0.85
GetJointPositionFunction · 0.85
DoBloodSplatFunction · 0.85
IsLaraMethod · 0.80

Tested by

no test coverage detected