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

Function GetPatrickTarget

src/SB/Game/zEntPlayer.cpp:2910–3070  ·  view source on GitHub ↗

Close, some float mismatches + regswaps

Source from the content-addressed store, hash-verified

2908
2909// Close, some float mismatches + regswaps
2910static xEnt* GetPatrickTarget(xEnt* ent)
2911{
2912 xEnt* result = NULL;
2913 zPlatform* plat =
2914 ent->collis->colls[0].flags & 1 ? (zPlatform*)ent->collis->colls[0].optr : NULL;
2915
2916 if (plat && plat->baseType == eBaseTypePlatform && plat->plat_flags & 2)
2917 {
2918 xCollis* coll;
2919 xVec3 relpos;
2920 xMat4x3Tolocal(&relpos, (xMat4x3*)plat->model->Mat, (xVec3*)&ent->model->Mat->pos);
2921
2922 relpos.z -= 2.0f;
2923 if (SQR(relpos.x) + SQR(relpos.z))
2924 {
2925 xVec3 worldpos;
2926 worldpos.x = 0.0f;
2927 worldpos.y = 1.23f;
2928 worldpos.z = -2.0f;
2929 xMat4x3Toworld(&worldpos, (xMat4x3*)plat->model->Mat, &worldpos);
2930
2931 if (ent->model->Mat->at.x * (worldpos.x - ent->model->Mat->pos.x) +
2932 ent->model->Mat->at.z * (worldpos.z - ent->model->Mat->pos.z) >
2933 0.0f)
2934 {
2935 globals.player.carry.targetRot =
2936 xatan2(worldpos.x - globals.player.ent.frame->mat.pos.x,
2937 worldpos.z - globals.player.ent.frame->mat.pos.z);
2938 globals.player.carry.throwTargetRotRate =
2939 globals.player.carry.targetRot - ent->frame->rot.angle;
2940 CLAMP_ANGLE(globals.player.carry.throwTargetRotRate);
2941 globals.player.carry.throwTargetRotRate /= 0.2f;
2942 return plat;
2943 }
2944 }
2945 }
2946
2947 F32 bestTargetDot = -1.0f;
2948 xVec3* bestTargetPos;
2949 zScene* zsc = globals.sceneCur;
2950 S32 grabbedIsFruit = zThrown_IsFruit(globals.player.carry.grabbed, NULL);
2951 for (U32 i = 0; i < zsc->num_ents; i++)
2952 {
2953 xEnt* tgtent = zsc->ents[i];
2954 if (tgtent == globals.player.carry.grabbed || (tgtent->flags & 1) == 0)
2955 {
2956 continue;
2957 }
2958 F32 maxHeight = globals.player.carry.throwMaxHeight;
2959
2960 if (tgtent->baseType == eBaseTypeStatic)
2961 {
2962 if (!grabbedIsFruit || !(tgtent->moreFlags & 0x8))
2963 {
2964 continue;
2965 }
2966 if (zThrown_IsFruit(tgtent, NULL) == 0)
2967 {

Callers 1

PatrickGrabThrowCBFunction · 0.70

Calls 6

xMat4x3TolocalFunction · 0.85
xMat4x3ToworldFunction · 0.85
xatan2Function · 0.85
xsqrtFunction · 0.85
SelfTypeMethod · 0.80
zThrown_IsFruitFunction · 0.70

Tested by

no test coverage detected