Advertisement
fggkyle

Untitled

Sep 23rd, 2020
1,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.05 KB | None | 0 0
  1. void func_808C12A4(ArmsHook* this, GlobalContext* globalCtx) {
  2.     ActorPlayer* player = PLAYER;
  3.     Actor* touchedActor;
  4.     Actor* grabbed;
  5.     Vec3f bodyDistDiffVec;
  6.     Vec3f newPos;
  7.     f32 bodyDistDiff;
  8.     f32 phi_f16;
  9.     DynaPolyActor* dynaPolyActor;
  10.     f32 sp94;
  11.     f32 sp90;
  12.     s32 pad;
  13.     BgPolygon* poly;
  14.     u32 dynaPolyID;
  15.     Vec3f sp78;
  16.     Vec3f prevFrameDiff;
  17.     Vec3f sp60;
  18.     f32 sp5C;
  19.     f32 sp58;
  20.     f32 velocity;
  21.    
  22.     if ((this->actor.parent == NULL) || (!func_801240C8(player))) {
  23.         func_808C1198(this);
  24.         Actor_MarkForDeath(&this->actor);
  25.         return;
  26.     }
  27.  
  28.     func_800B8F98(&player->base, 0x100B);
  29.     func_808C11C0(this);
  30.  
  31.     if (this->timer != 0) {
  32.         if ((this->collider.base.flagsAT & 2) && (this->collider.body.unk20->unk14 != 4)) {
  33.             touchedActor = this->collider.base.collisionAT;
  34.             if ((touchedActor->update != NULL) && (touchedActor->flags & 0x600)) {
  35.                 if (this->collider.body.unk20->unk16 & 4) {
  36.                     func_808C125C(this, touchedActor);
  37.                     if ((touchedActor->flags & 0x400) == 0x400) {
  38.                         func_808C1154(this);
  39.                     }
  40.                 }
  41.             }
  42.             this->timer = 0;
  43.             func_8019F1C0(&this->actor.projectedPos, 0x1814);
  44.             return;
  45.         }
  46.     }
  47.    
  48.     if (DECR(this->timer) == 0) {
  49.         grabbed = this->grabbed;
  50.         if (grabbed != NULL) {
  51.             if ((grabbed->update == NULL) || (grabbed->flags & 0x2000) != 0x2000) {
  52.                 grabbed = NULL;
  53.                 this->grabbed = NULL;
  54.             } else {
  55.                 if (this->actor.child != NULL) {
  56.                     sp94 = Actor_DistanceBetweenActors(this, grabbed);
  57.                     sp90 =
  58.                         sqrtf(SQ(this->unk_1FC.x) + SQ(this->unk_1FC.y) + SQ(this->unk_1FC.z));
  59.                     Math_Vec3f_Diff(&grabbed->currPosRot.pos, &this->unk_1FC, &this->actor.currPosRot.pos);
  60.                     if (50.0f < (sp94 - sp90)) {
  61.                         func_808C1198(this);
  62.                         grabbed = NULL;
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.  
  68.         bodyDistDiff = Math_Vec3f_DistXYZAndStoreDiff(&player->unk368, &this->actor.currPosRot.pos, &bodyDistDiffVec);
  69.         if (bodyDistDiff < 30.0f) {
  70.             velocity = 0.0f;
  71.             phi_f16 = 0.0f;
  72.         } else {
  73.             if (this->actor.child != NULL) {
  74.                 velocity = 30.0f;
  75.             } else {
  76.                 if (grabbed != NULL) {
  77.                     velocity = 50.0f;
  78.                 } else {
  79.                     velocity = 200.0f;
  80.                 }
  81.             }
  82.             phi_f16 = bodyDistDiff - velocity;
  83.             if (bodyDistDiff <= velocity) {
  84.                 phi_f16 = 0.0f;
  85.             }
  86.             velocity = phi_f16 / bodyDistDiff;
  87.         }
  88.  
  89.         newPos.x = bodyDistDiffVec.x * velocity;
  90.         newPos.y = bodyDistDiffVec.y * velocity;
  91.         newPos.z = bodyDistDiffVec.z * velocity;
  92.  
  93.         if (this->actor.child == NULL) {
  94.             Math_Vec3f_Sum(&player->unk368, &newPos, &this->actor.currPosRot.pos);
  95.             if (grabbed != NULL) {
  96.                 Math_Vec3f_Sum(&this->actor.currPosRot.pos, &this->unk_1FC, &grabbed->currPosRot.pos);
  97.             }      
  98.         } else {
  99.             Math_Vec3f_Diff(&bodyDistDiffVec, &newPos, &player->base.velocity);
  100.             player->base.currPosRot.rot.x =
  101.                 atans_flip(sqrtf(SQ(bodyDistDiffVec.x) + SQ(bodyDistDiffVec.z)), -bodyDistDiffVec.y);
  102.         }
  103.         if (phi_f16 < 50.0f) {
  104.             func_808C1198(this);
  105.             if (phi_f16 == 0.0f) {
  106.                 func_808C1030(this, func_808C10F8);
  107.                 if (func_808C1168(this, player)) {
  108.                     Math_Vec3f_Diff(&this->actor.currPosRot.pos, &player->base.currPosRot.pos, &player->base.velocity);
  109.                     player->base.velocity.y -= 20.0f;
  110.                     return;
  111.                 }
  112.             }
  113.         }
  114.     } else {
  115.         Actor_SetVelocityAndMoveYRotationAndGravity(&this->actor);
  116.         Math_Vec3f_Diff(&this->actor.currPosRot.pos, &this->actor.lastPos, &prevFrameDiff);
  117.         Math_Vec3f_Sum(&this->unk_1E0, &prevFrameDiff, &this->unk_1E0);
  118.         this->actor.shape.rot.x = atans_flip(this->actor.speedXZ, -this->actor.velocity.y);
  119.         sp60.x = this->unk_1EC.x - (this->unk_1E0.x - this->unk_1EC.x);
  120.         sp60.y = this->unk_1EC.y - (this->unk_1E0.y - this->unk_1EC.y);
  121.         sp60.z = this->unk_1EC.z - (this->unk_1E0.z - this->unk_1EC.z);
  122.         if (func_800C55C4(&globalCtx->colCtx, &sp60, &this->unk_1E0, &sp78, &poly, 1, 1, 1, 1, &dynaPolyID) != 0) {
  123.             if (func_800B90AC(globalCtx, &this->actor, poly, dynaPolyID, &sp78) || func_800C576C(&globalCtx->colCtx, &sp60, &this->unk_1EC, &sp78, &poly, 1, 1, 1, 1, &dynaPolyID)) {
  124.                 sp5C = poly->normal.x * (1 / SHT_MAX);
  125.                 sp58 = poly->normal.z * (1 / SHT_MAX);
  126.                 Math_Vec3f_Copy(&this->actor.currPosRot.pos, &sp78);
  127.                 this->actor.currPosRot.pos.x += 10.0f * sp5C;
  128.                 this->actor.currPosRot.pos.z += 10.0f * sp58;
  129.                 this->timer = 1;
  130.                 if (func_800C9CEC(&globalCtx->colCtx, poly, dynaPolyID) != 0) {
  131.                     if (dynaPolyID != 0x32) {
  132.                         dynaPolyActor = BgCheck_GetActorOfMesh(&globalCtx->colCtx, dynaPolyID);
  133.                         if (dynaPolyActor != NULL) {
  134.                             func_808C125C(this, &dynaPolyActor->actor);
  135.                         }
  136.                     }
  137.                     func_808C1154(this);
  138.                     func_8019F1C0(&this->actor.projectedPos, 0x1829);
  139.                     return;
  140.                 }
  141.                 func_800E8668(globalCtx, &this->actor.currPosRot.pos);
  142.                 func_8019F1C0(&this->actor.projectedPos, 0x1813);
  143.                 return;
  144.             }
  145.         }
  146.         if ((globalCtx->state.input[0].pressEdge.buttons & 0xC01F)) {
  147.             this->timer = 1;
  148.         }
  149.     }
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement