Player Impact Documentation From ActorContext (#1226)

* playerImpact

* discord feedback

* namefixer

* rm comment

* adjust not-logic

* pr review

* fix bss
This commit is contained in:
engineer124
2023-05-17 05:04:23 +10:00
committed by GitHub
parent 858d10a38b
commit 83ac58d739
10 changed files with 62 additions and 52 deletions
-1
View File
@@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "stack.h"
#include "stackcheck.h"
+19 -22
View File
@@ -908,41 +908,38 @@ s32 func_800B6434(PlayState* play, TitleCardContext* titleCtx) {
return true;
}
// ActorContext_1F4 Init
void func_800B6468(PlayState* play) {
play->actorCtx.unk_1F4.timer = 0;
void Actor_InitPlayerImpact(PlayState* play) {
play->actorCtx.playerImpact.timer = 0;
}
// ActorContext_1F4 Update
void func_800B6474(PlayState* play) {
DECR(play->actorCtx.unk_1F4.timer);
void Actor_UpdatePlayerImpact(PlayState* play) {
DECR(play->actorCtx.playerImpact.timer);
}
// ActorContext_1F4 setter something
s32 func_800B648C(PlayState* play, s32 arg1, s32 timer, f32 arg3, Vec3f* arg4) {
if ((play->actorCtx.unk_1F4.timer != 0) && (arg3 < play->actorCtx.unk_1F4.unk_04)) {
s32 Actor_SetPlayerImpact(PlayState* play, PlayerImpactType type, s32 timer, f32 dist, Vec3f* pos) {
if ((play->actorCtx.playerImpact.timer != 0) && (dist < play->actorCtx.playerImpact.dist)) {
return false;
}
play->actorCtx.unk_1F4.unk_00 = arg1;
play->actorCtx.unk_1F4.timer = timer;
play->actorCtx.unk_1F4.unk_04 = arg3;
Math_Vec3f_Copy(&play->actorCtx.unk_1F4.unk_08, arg4);
play->actorCtx.playerImpact.type = type;
play->actorCtx.playerImpact.timer = timer;
play->actorCtx.playerImpact.dist = dist;
Math_Vec3f_Copy(&play->actorCtx.playerImpact.pos, pos);
return true;
}
// ActorContext_1F4 getter something
f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3) {
f32 temp_f8;
f32 Actor_GetPlayerImpact(PlayState* play, f32 range, Vec3f* pos, PlayerImpactType* type) {
f32 dist;
if ((play->actorCtx.unk_1F4.timer == 0) || (arg1 == 0.0f)) {
if ((play->actorCtx.playerImpact.timer == 0) || (range == 0.0f)) {
return -1.0f;
}
temp_f8 = Math_Vec3f_DistXYZ(&play->actorCtx.unk_1F4.unk_08, arg2) / arg1;
*arg3 = play->actorCtx.unk_1F4.unk_00;
return play->actorCtx.unk_1F4.unk_04 - temp_f8;
dist = Math_Vec3f_DistXYZ(&play->actorCtx.playerImpact.pos, pos) / range;
*type = play->actorCtx.playerImpact.type;
return play->actorCtx.playerImpact.dist - dist;
}
/**
@@ -2303,7 +2300,7 @@ void Actor_InitContext(PlayState* play, ActorContext* actorCtx, ActorEntry* acto
actorCtx->sceneFlags.clearedRoom = cycleFlags->clearedRoom;
TitleCard_ContextInit(&play->state, &actorCtx->titleCtxt);
func_800B6468(play);
Actor_InitPlayerImpact(play);
actorCtx->absoluteSpace = NULL;
@@ -2559,7 +2556,7 @@ void Actor_UpdateAll(PlayState* play, ActorContext* actorCtx) {
}
TitleCard_Update(&play->state, &actorCtx->titleCtxt);
func_800B6474(play);
Actor_UpdatePlayerImpact(play);
DynaPoly_UpdateBgActorTransforms(play, &play->colCtx.dyna);
}
@@ -725,7 +725,7 @@ void EnDragon_Dead(EnDragon* this, PlayState* play) {
void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) {
Player* player = GET_PLAYER(play);
u32 sp30;
PlayerImpactType playerImpactType;
if (this->action == DEEP_PYTHON_ACTION_EXTEND) {
if ((this->collider.elements[2].info.bumperFlags & BUMP_HIT) ||
@@ -753,7 +753,8 @@ void EnDragon_UpdateDamage(EnDragon* this, PlayState* play) {
if ((this->action == DEEP_PYTHON_ACTION_EXTEND) && (this->grabWaitTimer == 0) &&
(player->invincibilityTimer == 0) && (this->collider.elements[0].info.ocElemFlags & OCELEM_HIT) &&
(!(func_800B64FC(play, 1000.0f, &this->actor.world.pos, &sp30) >= 0.0f) || (sp30 != 1))) {
!((Actor_GetPlayerImpact(play, 1000.0f, &this->actor.world.pos, &playerImpactType) >= 0.0f) &&
(playerImpactType == PLAYER_IMPACT_ZORA_BARRIER))) {
this->actor.speed = 0.0f;
this->action = DEEP_PYTHON_ACTION_GRAB;
this->actor.flags |= ACTOR_FLAG_100000;
+2 -2
View File
@@ -504,8 +504,8 @@ s32 func_808D99C8(EnSw* this, PlayState* play) {
return false;
}
if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (play->actorCtx.unk_1F4.timer != 0) &&
(play->actorCtx.unk_1F4.unk_00 == 0)) {
if ((this->actor.xyzDistToPlayerSq < ((sREG(16) * 10) + 60000)) && (play->actorCtx.playerImpact.timer != 0) &&
(play->actorCtx.playerImpact.type == PLAYER_IMPACT_GORON_GROUND_POUND)) {
this->actor.colChkInfo.damage = 4;
phi_v1 = true;
}
+4 -5
View File
@@ -34,18 +34,17 @@ ActorInit TG_Sw_InitVars = {
void TGSw_ActionDecider(TGSw* this, PlayState* play) {
f32 scaledAbsoluteRotZ;
f32 scaledAbsoluteRotY;
u8 unk1F4;
PlayerImpactType playerImpactType;
// Maybe actorCtx Debug Flag?
if (play->actorCtx.unk_1F4.timer != 0) {
if (play->actorCtx.playerImpact.timer != 0) {
scaledAbsoluteRotY = ABS_ALT(this->actor.world.rot.y) * 4.0f;
scaledAbsoluteRotZ = ABS_ALT(this->actor.world.rot.z) * 4.0f;
if ((scaledAbsoluteRotZ < this->actor.xzDistToPlayer) || (scaledAbsoluteRotY < this->actor.playerHeightRel)) {
return;
}
unk1F4 = play->actorCtx.unk_1F4.unk_00;
if (unk1F4 == 2 || unk1F4 == 0) {
playerImpactType = play->actorCtx.playerImpact.type;
if ((playerImpactType == PLAYER_IMPACT_BONK) || (playerImpactType == PLAYER_IMPACT_GORON_GROUND_POUND)) {
this->actionFunc = TGSw_ActionExecuteOneShot;
}
}