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

Function zNPCMsg_AreaPlayerStun

src/SB/Game/zNPCMessenger.cpp:388–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

386}
387
388void zNPCMsg_AreaPlayerStun(F32 stuntime, F32 radius, xVec3* pos)
389{
390 st_XORDEREDARRAY* npclist = zNPCMgr_GetNPCList();
391 xVec3 from;
392
393 if (pos != NULL)
394 {
395 xVec3Copy(&from, pos);
396 }
397 else
398 {
399 xVec3Copy(&from, xEntGetPos(&globals.player.ent));
400 }
401
402 F32 ds2_discard = SQ(radius);
403
404 for (S32 i = 0; i < npclist->cnt; i++)
405 {
406 zNPCCommon* npc = (zNPCCommon*)npclist->list[i];
407
408 if (((npc->baseFlags & 0x40) == 0) &&
409 (npc->model == NULL || (npc->model->Flags & 0x400) == 0) &&
410 (npc->flg_vuln & 0x10000000))
411 {
412 U32 ntyp = npc->SelfType();
413
414 if ((ntyp & 0xFFFFFF00) == 'NTR\0')
415 {
416 zNPCRobot* robo = (zNPCRobot*)npc;
417 if (robo->IsDying())
418 {
419 continue;
420 }
421 }
422 else
423 {
424 if (!npc->IsAlive())
425 {
426 continue;
427 }
428 }
429
430 xVec3 diff;
431 npc->XYZVecToPos(&diff, &from);
432
433 if (FABS(diff.y) > radius)
434 {
435 continue;
436 }
437 diff.y = 0.0f;
438 if (xVec3Length2(&diff) > ds2_discard)
439 {
440 continue;
441 }
442 npc->Stun(stuntime);
443 }
444 }
445}

Callers

nothing calls this directly

Calls 9

zNPCMgr_GetNPCListFunction · 0.85
xVec3CopyFunction · 0.85
xEntGetPosFunction · 0.85
xVec3Length2Function · 0.85
SelfTypeMethod · 0.80
IsDyingMethod · 0.80
XYZVecToPosMethod · 0.80
StunMethod · 0.80
IsAliveMethod · 0.45

Tested by

no test coverage detected