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

Function PatrickGrabCB

src/SB/Game/zEntPlayer.cpp:2756–2836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2754}
2755
2756static U32 PatrickGrabCB(xAnimTransition* tran, xAnimSingle*, void*)
2757{
2758 zEntPlayer_SNDPlay(ePlayerSnd_Lift1, 0.0f);
2759 if ((xrand() & 3) == 3)
2760 {
2761 zEntPlayer_SNDPlayStream(ePlayerStreamSnd_Lift1);
2762 }
2763
2764 globals.player.carry.grabbed = sGrabFound;
2765 globals.player.carry.grabTarget = 1;
2766 globals.player.carry.grabYclear = 0;
2767
2768 if (sGrabFound->baseType == eBaseTypeBoulder)
2769 {
2770 globals.player.carry.targetRot =
2771 xatan2(sGrabFound->bound.sph.center.x - globals.player.ent.frame->mat.pos.x,
2772 sGrabFound->bound.sph.center.z - globals.player.ent.frame->mat.pos.z);
2773 }
2774 else
2775 {
2776 globals.player.carry.targetRot =
2777 xatan2(sGrabFound->model->Mat->pos.x - globals.player.ent.frame->mat.pos.x,
2778 sGrabFound->model->Mat->pos.z - globals.player.ent.frame->mat.pos.z);
2779 }
2780
2781 globals.player.carry.grabLerpLast = 0.0f;
2782
2783 xAnimState* stat =
2784 xAnimTableGetState(globals.player.ent.model->Anim->Table, "Carry_PickupItem");
2785 if (stat)
2786 {
2787 xVec3 tmptran;
2788 xQuat tmpquat;
2789 iAnimEval(stat->Data->RawData[0], 1.0 / 30.0f, 1, &tmptran, &tmpquat);
2790
2791 xMat4x3 objMat;
2792 xQuatToMat(&tmpquat, &objMat);
2793 xMat4x3 targetMat;
2794 objMat.pos = tmptran;
2795 xMat3x3Rot(&targetMat, &g_Y3, globals.player.carry.targetRot);
2796 targetMat.pos = globals.player.ent.frame->mat.pos;
2797
2798 xMat4x3Mul(&objMat, &objMat, &targetMat);
2799
2800 if (globals.player.carry.grabbed->baseType == '/')
2801 {
2802 globals.player.carry.grabOffset.x = objMat.pos.x - sGrabFound->bound.sph.center.x;
2803 globals.player.carry.grabOffset.y =
2804 sGrabFound->bound.sph.r + (objMat.pos.y - sGrabFound->bound.sph.center.y);
2805 globals.player.carry.grabOffset.z = objMat.pos.z - sGrabFound->bound.sph.center.z;
2806 }
2807 else
2808 {
2809 globals.player.carry.grabOffset.x = objMat.pos.x - sGrabFound->model->Mat->pos.x;
2810 globals.player.carry.grabOffset.y = objMat.pos.y - sGrabFound->model->Mat->pos.y;
2811 globals.player.carry.grabOffset.z = objMat.pos.z - sGrabFound->model->Mat->pos.z;
2812 }
2813 }

Callers

nothing calls this directly

Calls 13

zEntPlayer_SNDPlayFunction · 0.85
xrandFunction · 0.85
zEntPlayer_SNDPlayStreamFunction · 0.85
xatan2Function · 0.85
xAnimTableGetStateFunction · 0.85
iAnimEvalFunction · 0.85
xMat3x3RotFunction · 0.85
xMat4x3MulFunction · 0.85
xVec3InitFunction · 0.85
zThrown_AddFruitFunction · 0.85
xQuatToMatFunction · 0.50
xMat3x3MulFunction · 0.50

Tested by

no test coverage detected