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

Function CollideTrain

TombEngine/Objects/TR3/Trap/train.cpp:111–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109 }
110
111 void CollideTrain(short itemNumber, ItemInfo* playerItem, CollisionInfo* coll)
112 {
113 auto& item = g_Level.Items[itemNumber];
114 auto& player = GetLaraInfo(*playerItem);
115
116 if (!TestBoundsCollide(&item, playerItem, coll->Setup.Radius))
117 return;
118
119 if (!HandleItemSphereCollision(item, *playerItem))
120 return;
121
122 if (item.ItemFlags[1] < item.ItemFlags[0])
123 {
124 ObjectCollision(itemNumber, playerItem, coll);
125 return;
126 }
127
128 SoundEffect(SFX_TR4_LARA_GENERAL_DEATH, &playerItem->Pose, SoundEnvironment::Always);
129 SoundEffect(SFX_TR4_LARA_HIGH_FALL_DEATH, &playerItem->Pose, SoundEnvironment::Always);
130
131 SetAnimation(playerItem, ID_LARA_EXTRA_ANIMS, LEA_TRAIN_DEATH_START);
132 playerItem->Animation.IsAirborne = false;
133 playerItem->Animation.Velocity.y = 0.0f;
134 playerItem->Animation.Velocity.z = 0.0f;
135 playerItem->Pose.Orientation.y = item.Pose.Orientation.y;
136
137 DoDamage(playerItem, INT_MAX);
138
139 AnimateItem(playerItem);
140
141 player.ExtraAnim = 1;
142 player.Control.HandStatus = HandStatus::Busy;
143 player.Control.Weapon.GunType = LaraWeaponType::None;
144 player.HitDirection = NO_VALUE;
145 player.Status.Air = NO_VALUE;
146
147 item.ItemFlags[1] = 160;
148
149 float sinY = phd_sin(item.Pose.Orientation.y);
150 float cosY = phd_cos(item.Pose.Orientation.y);
151
152 long x = playerItem->Pose.Position.x + CLICK(1) * sinY;
153 long z = playerItem->Pose.Position.z + CLICK(1) * cosY;
154
155 DoLotsOfBlood(x, playerItem->Pose.Position.y - CLICK(2), z, BLOCK(1), item.Pose.Orientation.y, playerItem->RoomNumber, 15);
156 }
157}

Callers

nothing calls this directly

Calls 10

TestBoundsCollideFunction · 0.85
ObjectCollisionFunction · 0.85
SoundEffectFunction · 0.85
SetAnimationFunction · 0.85
DoDamageFunction · 0.85
AnimateItemFunction · 0.85
phd_sinFunction · 0.85
phd_cosFunction · 0.85
DoLotsOfBloodFunction · 0.85

Tested by

no test coverage detected