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

Function CheckPickupAgainstPlayer

src/SB/Game/zEntPickup.cpp:613–774  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611}
612
613static S32 CheckPickupAgainstPlayer(xEnt* cbent, void*)
614{
615 if (cbent->baseType != eBaseTypePickup)
616 {
617 return 1;
618 }
619
620 zEntPickup* ent = (zEntPickup*)cbent;
621
622 if ((ent->state & 0x40) && 0.0f == ent->timer && !(ent->state & 0x8) && !(ent->state & 0x4) &&
623 !(ent->state & 0x20) && globals.player.Health != 0)
624 {
625 ent->fx_scale = 1.0f;
626
627 if (ent->pickupFlags & 0x1)
628 {
629 ent->baseFlags &= 0x7f;
630 }
631
632 F32 distance;
633 zEnt* plent = &globals.player.ent;
634 F32 distsqr;
635 F32 dx__ = plent->bound.sph.center.x - ent->model->Mat->pos.x;
636 F32 dy__ = plent->bound.sph.center.y - ent->model->Mat->pos.y;
637 F32 dz__ = plent->bound.sph.center.z - ent->model->Mat->pos.z;
638 F32 chkdist = 4.0f * plent->bound.sph.r;
639
640 distance = SQR(dx__) + SQR(dy__) + SQR(dz__);
641
642 if (distance <= SQR(chkdist))
643 {
644 if (ent->pickupFlags & 0x2)
645 {
646 if (ent->p->pickupType == PICKUP_TYPE_SHINY)
647 {
648 zEntPickup_DoPickup(ent);
649 }
650
651 if (ent->p->pickupType == PICKUP_TYPE_1)
652 {
653 switch (ent->p->pickupIndex)
654 {
655 case PICKUP_UNDERWEAR:
656 {
657 if (globals.player.Health < globals.player.MaxHealth)
658 {
659 zEntPickup_DoPickup(ent);
660 }
661
662 break;
663 }
664 case PICKUP_SOCK:
665 {
666 for (S32 i = 0; i < 5; i++)
667 {
668 xFXFireworksLaunch(0.5f + xurand(), (xVec3*)&ent->model->Mat->pos,
669 0.5f * xurand() + 0.1f);
670 }

Callers

nothing calls this directly

Calls 6

zEntPickup_DoPickupFunction · 0.85
xurandFunction · 0.85
xVec3CopyFunction · 0.85
zEntPlayer_SNDPlayFunction · 0.85
zEntPlayerControlOffFunction · 0.70
xFXFireworksLaunchFunction · 0.50

Tested by

no test coverage detected