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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 62 additions and 52 deletions

View File

@ -609,8 +609,8 @@ void Flags_SetCollectible(PlayState* play, s32 flag);
void TitleCard_InitBossName(GameState* gameState, TitleCardContext* titleCtx, TexturePtr texture, s16 x, s16 y, u8 width, u8 height);
s32 func_800B648C(PlayState* play, s32 arg1, s32 timer, f32 arg3, Vec3f* arg4);
f32 func_800B64FC(PlayState* play, f32 arg1, Vec3f* arg2, u32* arg3);
s32 Actor_SetPlayerImpact(PlayState* play, PlayerImpactType type, s32 timer, f32 dist, Vec3f* pos);
f32 Actor_GetPlayerImpact(PlayState* play, f32 range, Vec3f* pos, PlayerImpactType* type);
void* func_800B6584(PlayState* play, s16 id, void* arg2, size_t size);
void* func_800B6608(PlayState* play, s16 id);
void* func_800B6680(PlayState* play, s16 id);

View File

@ -389,12 +389,18 @@ typedef struct {
/* 0xE */ s16 intensity;
} TitleCardContext; // size = 0x10
typedef struct ActorContext_unk_1F4 {
/* 0x00 */ u8 unk_00;
typedef enum {
/* 0 */ PLAYER_IMPACT_GORON_GROUND_POUND,
/* 1 */ PLAYER_IMPACT_ZORA_BARRIER,
/* 2 */ PLAYER_IMPACT_BONK // also activated by goron attack
} PlayerImpactType;
typedef struct PlayerImpact {
/* 0x00 */ u8 type;
/* 0x01 */ u8 timer;
/* 0x04 */ f32 unk_04;
/* 0x08 */ Vec3f unk_08;
} ActorContext_unk_1F4; // size = 0x14
/* 0x04 */ f32 dist;
/* 0x08 */ Vec3f pos;
} PlayerImpact; // size = 0x14
typedef struct ActorContext_unk_20C {
/* 0x0 */ s16 id;
@ -458,7 +464,7 @@ typedef struct ActorContext {
/* 0x120 */ TargetContext targetContext;
/* 0x1B8 */ ActorContextSceneFlags sceneFlags;
/* 0x1E4 */ TitleCardContext titleCtxt;
/* 0x1F4 */ ActorContext_unk_1F4 unk_1F4;
/* 0x1F4 */ PlayerImpact playerImpact;
/* 0x208 */ UNK_TYPE1 unk_208[0x4];
/* 0x20C */ ActorContext_unk_20C unk_20C[8];
/* 0x24C */ UNK_TYPE1 unk_24C[0x4];

View File

@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "stack.h"
#include "stackcheck.h"

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);
}

View File

@ -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;

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;
}

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;
}
}

View File

@ -696,10 +696,10 @@
0x800B5E68:("TitleCard_Update",),
0x800B5F24:("TitleCard_Draw",),
0x800B6434:("func_800B6434",),
0x800B6468:("func_800B6468",),
0x800B6474:("func_800B6474",),
0x800B648C:("func_800B648C",),
0x800B64FC:("func_800B64FC",),
0x800B6468:("Actor_InitPlayerImpact",),
0x800B6474:("Actor_UpdatePlayerImpact",),
0x800B648C:("Actor_SetPlayerImpact",),
0x800B64FC:("Actor_GetPlayerImpact",),
0x800B6584:("func_800B6584",),
0x800B6608:("func_800B6608",),
0x800B6680:("func_800B6680",),

View File

@ -164,6 +164,10 @@ wordReplace = {
"Actor_DistanceToPoint": "Actor_WorldDistXYZToPoint",
"Actor_XZDistanceBetweenActors": "Actor_WorldDistXZToActor",
"Actor_XZDistanceToPoint": "Actor_WorldDistXZToPoint",
"func_800B6468": "Actor_InitPlayerImpact",
"func_800B6474": "Actor_UpdatePlayerImpact",
"func_800B648C": "Actor_SetPlayerImpact",
"func_800B64FC": "Actor_GetPlayerImpact",
"Audio_PlaySoundAtPosition": "SoundSource_PlaySfxAtFixedWorldPos",
"func_800F0590": "SoundSource_PlaySfxEachFrameAtFixedWorldPos",
"func_8016970C": "Play_SetCameraAtEye",
@ -931,10 +935,14 @@ wordReplace = {
"play->roomCtx.unk31": "play->roomCtx.status",
"actorCtx.unkC": "actorCtx.halfDaysBit",
"actorCtx.unk1F4": "actorCtx.unk_1F4.unk_00",
"actorCtx.unk1F5": "actorCtx.unk_1F4.timer",
"actorCtx.unk1F8": "actorCtx.unk_1F4.unk_04",
"actorCtx.unk1FC": "actorCtx.unk_1F4.unk_08",
"actorCtx.unk1F4": "actorCtx.playerImpact.type",
"actorCtx.unk1F5": "actorCtx.playerImpact.timer",
"actorCtx.unk1F8": "actorCtx.playerImpact.dist",
"actorCtx.unk1FC": "actorCtx.playerImpact.pos",
"actorCtx.unk_1F4.unk_00": "actorCtx.playerImpact.type",
"actorCtx.unk_1F4.timer": "actorCtx.playerImpact.timer",
"actorCtx.unk_1F4.unk_04": "actorCtx.playerImpact.dist",
"actorCtx.unk_1F4.unk_08": "actorCtx.playerImpact.pos",
"gSaveContext.unk_3DC8": "gSaveContext.timerOsTime",
"gSaveContext.unk_3DD0": "gSaveContext.timerStates",

View File

@ -210,10 +210,10 @@ asm/non_matchings/code/z_actor/TitleCard_InitPlaceName.s,TitleCard_InitPlaceName
asm/non_matchings/code/z_actor/TitleCard_Update.s,TitleCard_Update,0x800B5E68,0x2F
asm/non_matchings/code/z_actor/TitleCard_Draw.s,TitleCard_Draw,0x800B5F24,0x144
asm/non_matchings/code/z_actor/func_800B6434.s,func_800B6434,0x800B6434,0xD
asm/non_matchings/code/z_actor/func_800B6468.s,func_800B6468,0x800B6468,0x3
asm/non_matchings/code/z_actor/func_800B6474.s,func_800B6474,0x800B6474,0x6
asm/non_matchings/code/z_actor/func_800B648C.s,func_800B648C,0x800B648C,0x1C
asm/non_matchings/code/z_actor/func_800B64FC.s,func_800B64FC,0x800B64FC,0x22
asm/non_matchings/code/z_actor/Actor_InitPlayerImpact.s,Actor_InitPlayerImpact,0x800B6468,0x3
asm/non_matchings/code/z_actor/Actor_UpdatePlayerImpact.s,Actor_UpdatePlayerImpact,0x800B6474,0x6
asm/non_matchings/code/z_actor/Actor_SetPlayerImpact.s,Actor_SetPlayerImpact,0x800B648C,0x1C
asm/non_matchings/code/z_actor/Actor_GetPlayerImpact.s,Actor_GetPlayerImpact,0x800B64FC,0x22
asm/non_matchings/code/z_actor/func_800B6584.s,func_800B6584,0x800B6584,0x21
asm/non_matchings/code/z_actor/func_800B6608.s,func_800B6608,0x800B6608,0x1E
asm/non_matchings/code/z_actor/func_800B6680.s,func_800B6680,0x800B6680,0x23

1 asm/non_matchings/code/z_en_a_keep/EnAObj_Init.s EnAObj_Init 0x800A5AC0 0x2B
210 asm/non_matchings/code/z_actor/TitleCard_Update.s TitleCard_Update 0x800B5E68 0x2F
211 asm/non_matchings/code/z_actor/TitleCard_Draw.s TitleCard_Draw 0x800B5F24 0x144
212 asm/non_matchings/code/z_actor/func_800B6434.s func_800B6434 0x800B6434 0xD
213 asm/non_matchings/code/z_actor/func_800B6468.s asm/non_matchings/code/z_actor/Actor_InitPlayerImpact.s func_800B6468 Actor_InitPlayerImpact 0x800B6468 0x3
214 asm/non_matchings/code/z_actor/func_800B6474.s asm/non_matchings/code/z_actor/Actor_UpdatePlayerImpact.s func_800B6474 Actor_UpdatePlayerImpact 0x800B6474 0x6
215 asm/non_matchings/code/z_actor/func_800B648C.s asm/non_matchings/code/z_actor/Actor_SetPlayerImpact.s func_800B648C Actor_SetPlayerImpact 0x800B648C 0x1C
216 asm/non_matchings/code/z_actor/func_800B64FC.s asm/non_matchings/code/z_actor/Actor_GetPlayerImpact.s func_800B64FC Actor_GetPlayerImpact 0x800B64FC 0x22
217 asm/non_matchings/code/z_actor/func_800B6584.s func_800B6584 0x800B6584 0x21
218 asm/non_matchings/code/z_actor/func_800B6608.s func_800B6608 0x800B6608 0x1E
219 asm/non_matchings/code/z_actor/func_800B6680.s func_800B6680 0x800B6680 0x23