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

Function LaraTargetInfo

TombEngine/Game/Lara/lara_fire.cpp:1129–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1127}
1128
1129void LaraTargetInfo(ItemInfo& laraItem, const WeaponInfo& weaponInfo)
1130{
1131 auto& player = *GetLaraInfo(&laraItem);
1132
1133 if (player.TargetEntity == nullptr)
1134 {
1135 player.RightArm.AimDelay = player.LeftArm.AimDelay = 0;
1136 player.RightArm.Locked = player.LeftArm.Locked = false;
1137 player.TargetArmOrient = EulerAngles::Identity;
1138 return;
1139 }
1140
1141 auto origin1 = GameVector(laraItem.Pose.Position.x, GetJointPosition(&laraItem, LM_RHAND).y, laraItem.Pose.Position.z, laraItem.RoomNumber);
1142 auto origin2 = GameVector(laraItem.Pose.Position.x, GetJointPosition(&laraItem, LM_HEAD).y - LARA_HEADROOM, laraItem.Pose.Position.z, laraItem.RoomNumber);
1143 auto target = GetTargetPoint(*player.TargetEntity);
1144
1145 auto orient = Geometry::GetOrientToPoint(origin1.ToVector3(), target.ToVector3()) - laraItem.Pose.Orientation;
1146
1147 // Do two-pass LOS test to make sure enemy is visible from both gun and head positions.
1148 if (LOS(&origin1, &target) && LOS(&origin2, &target))
1149 player.RightArm.AimDelay = player.LeftArm.AimDelay++;
1150 else
1151 player.RightArm.AimDelay = player.LeftArm.AimDelay = 0;
1152
1153 // Filter out targets that have been in sight for less than 3 frames to avoid stuttering.
1154 if (player.RightArm.AimDelay > 3 || player.LeftArm.AimDelay > 3)
1155 {
1156 if (orient.x >= weaponInfo.LockOrientConstraint.first.x &&
1157 orient.y >= weaponInfo.LockOrientConstraint.first.y &&
1158 orient.x <= weaponInfo.LockOrientConstraint.second.x &&
1159 orient.y <= weaponInfo.LockOrientConstraint.second.y)
1160 {
1161 player.RightArm.Locked = true;
1162 player.LeftArm.Locked = true;
1163 }
1164 else
1165 {
1166 if (player.LeftArm.Locked)
1167 {
1168 if (orient.x < weaponInfo.LeftOrientConstraint.first.x ||
1169 orient.y < weaponInfo.LeftOrientConstraint.first.y ||
1170 orient.x > weaponInfo.LeftOrientConstraint.second.x ||
1171 orient.y > weaponInfo.LeftOrientConstraint.second.y)
1172 {
1173 player.LeftArm.Locked = false;
1174 }
1175 }
1176
1177 if (player.RightArm.Locked)
1178 {
1179 if (orient.x < weaponInfo.RightOrientConstraint.first.x ||
1180 orient.y < weaponInfo.RightOrientConstraint.first.y ||
1181 orient.x > weaponInfo.RightOrientConstraint.second.x ||
1182 orient.y > weaponInfo.RightOrientConstraint.second.y)
1183 {
1184 player.RightArm.Locked = false;
1185 }
1186 }

Callers 3

FindNewTargetFunction · 0.85
RifleHandlerFunction · 0.85
HandlePistolsFunction · 0.85

Calls 6

GetJointPositionFunction · 0.85
GetTargetPointFunction · 0.85
GetOrientToPointFunction · 0.85
LOSFunction · 0.85
GameVectorClass · 0.50
ToVector3Method · 0.45

Tested by

no test coverage detected