MCPcopy Create free account
hub / github.com/bfbbdecomp/bfbb / ConvertHitEvent

Method ConvertHitEvent

src/SB/Game/zNPCTypeCommon.cpp:1267–1340  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1265}
1266
1267void zNPCCommon::ConvertHitEvent(xBase* from, xBase* to, U32 toEvent, const F32* toParam,
1268 xBase* toParamWidget, S32* handled)
1269{
1270 xVec3 pos_cruiser = {};
1271 xVec3* vec_hit = NULL;
1272 F32 mag;
1273 en_NPC_DAMAGE_TYPE what = DMGTYP_UNDECIDED;
1274
1275 if (from)
1276 {
1277 switch (from->baseType)
1278 {
1279 case eBaseTypePlayer:
1280 {
1281 U32 mvinf = zEntPlayer_MoveInfo();
1282 if (mvinf & 0x8)
1283 {
1284 what = DMGTYP_BELOW;
1285 }
1286 else if (mvinf & 0x10)
1287 {
1288 what = DMGTYP_ABOVE;
1289 }
1290 else if (mvinf & 0x20)
1291 {
1292 what = DMGTYP_SIDE;
1293 }
1294 else
1295 {
1296 what = DMGTYP_SIDE;
1297 }
1298
1299 xVec3Sub(&pos_cruiser, xEntGetPos(&globals.player.ent), xEntGetPos(this));
1300 vec_hit = &pos_cruiser;
1301 break;
1302 }
1303 case eBaseTypeCruiseBubble:
1304 what = DMGTYP_CRUISEBUBBLE;
1305
1306 if (toParam)
1307 {
1308 pos_cruiser.x = toParam[0];
1309 pos_cruiser.y = toParam[1];
1310 pos_cruiser.z = toParam[2];
1311
1312 mag = xVec3Length(&pos_cruiser);
1313 if (mag > 0.001f)
1314 {
1315 xVec3SubFrom(&pos_cruiser, xEntGetPos(this));
1316 xVec3SMulBy(&pos_cruiser, 2.0f / mag);
1317
1318 vec_hit = &pos_cruiser;
1319 }
1320 }
1321
1322 break;
1323 case eBaseTypeProjectile:
1324 what = DMGTYP_PROJECTILE;

Callers 1

SysEventMethod · 0.95

Calls 7

DamageMethod · 0.95
xVec3SubFunction · 0.85
xEntGetPosFunction · 0.85
xVec3LengthFunction · 0.85
xVec3SubFromFunction · 0.85
xVec3SMulByFunction · 0.85
zEntPlayer_MoveInfoFunction · 0.70

Tested by

no test coverage detected