1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-04 23:14:37 +00:00

Defines for Actor#bgCheckFlags (#1126)

* First pass, tool assisted bgCheckFlags

* Few manual bgCheckFlags

* Run formatter

* Remove fake bgCheckFlags 10-15

* Move existing documentation to the defines

* Comment on `bgCheckFlags` and rephrase some doc

* Name obvious flags, and some cleanup

* Comment on flag 9 being wall-interaction-related (thanks engineer and fig)

* Run formatter

* `BGCHECKFLAG_7` -> `BGCHECKFLAG_GROUND_STRICT`

* Touch up water-related bgcheckflags doc

* `BGCHECKFLAG_9` -> `BGCHECKFLAG_PLAYER_WALL_INTERACT`
This commit is contained in:
Dragorn421 2022-02-19 03:16:19 +01:00 committed by GitHub
parent 251d90301c
commit 67f294774b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
121 changed files with 711 additions and 652 deletions

View file

@ -188,7 +188,7 @@ void ActorShadow_DrawFeet(Actor* actor, Lights* lights, GlobalContext* globalCtx
floorHeightPtr++;
}
if (!(actor->bgCheckFlags & 1)) {
if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
actor->shape.feetFloorFlags = 0;
} else if (actor->shape.feetFloorFlags == 3) {
f32 footDistY = actor->shape.feetPos[FOOT_LEFT].y - actor->shape.feetPos[FOOT_RIGHT].y;
@ -1153,9 +1153,9 @@ s32 Actor_ActorAIsFacingAndNearActorB(Actor* actorA, Actor* actorB, f32 range, s
}
s32 func_8002E234(Actor* actor, f32 arg1, s32 arg2) {
if ((actor->bgCheckFlags & 0x1) && (arg1 < -11.0f)) {
actor->bgCheckFlags &= ~0x1;
actor->bgCheckFlags |= 0x4;
if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND) && (arg1 < -11.0f)) {
actor->bgCheckFlags &= ~BGCHECKFLAG_GROUND;
actor->bgCheckFlags |= BGCHECKFLAG_GROUND_LEAVE;
if ((actor->velocity.y < 0.0f) && (arg2 & 0x10)) {
actor->velocity.y = 0.0f;
@ -1175,7 +1175,7 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->floorHeight =
BgCheck_EntityRaycastFloor5(globalCtx, &globalCtx->colCtx, &actor->floorPoly, &floorBgId, actor, arg2);
actor->bgCheckFlags &= ~0x0086;
actor->bgCheckFlags &= ~(BGCHECKFLAG_GROUND_TOUCH | BGCHECKFLAG_GROUND_LEAVE | BGCHECKFLAG_GROUND_STRICT);
if (actor->floorHeight <= BGCHECK_Y_MIN) {
return func_8002E234(actor, BGCHECK_Y_MIN, arg3);
@ -1185,12 +1185,12 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->floorBgId = floorBgId;
if (floorHeightDiff >= 0.0f) { // actor is on or below the ground
actor->bgCheckFlags |= 0x80;
actor->bgCheckFlags |= BGCHECKFLAG_GROUND_STRICT;
if (actor->bgCheckFlags & 0x10) {
if (actor->bgCheckFlags & BGCHECKFLAG_CEILING) {
if (floorBgId != sCurCeilingBgId) {
if (floorHeightDiff > 15.0f) {
actor->bgCheckFlags |= 0x100;
actor->bgCheckFlags |= BGCHECKFLAG_CRUSHED;
}
} else {
actor->world.pos.x = actor->prevPos.x;
@ -1201,19 +1201,19 @@ s32 func_8002E2AC(GlobalContext* globalCtx, Actor* actor, Vec3f* arg2, s32 arg3)
actor->world.pos.y = actor->floorHeight;
if (actor->velocity.y <= 0.0f) {
if (!(actor->bgCheckFlags & 0x1)) {
actor->bgCheckFlags |= 0x2;
if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
actor->bgCheckFlags |= BGCHECKFLAG_GROUND_TOUCH;
} else if ((arg3 & 0x8) && (actor->gravity < 0.0f)) {
actor->velocity.y = -4.0f;
} else {
actor->velocity.y = 0.0f;
}
actor->bgCheckFlags |= 0x1;
actor->bgCheckFlags |= BGCHECKFLAG_GROUND;
func_80043334(&globalCtx->colCtx, actor, actor->floorBgId);
}
} else { // actor is above ground
if ((actor->bgCheckFlags & 0x1) && (floorHeightDiff >= -11.0f)) {
if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND) && (floorHeightDiff >= -11.0f)) {
func_80043334(&globalCtx->colCtx, actor, actor->floorBgId);
}
@ -1237,7 +1237,7 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp74 = actor->world.pos.y - actor->prevPos.y;
if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & 1)) {
if ((actor->floorBgId != BGCHECK_SCENE) && (actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
func_800433A4(&globalCtx->colCtx, actor->floorBgId, actor);
}
@ -1251,10 +1251,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
wallPoly = actor->wallPoly;
Math_Vec3f_Copy(&actor->world.pos, &sp64);
actor->wallYaw = Math_Atan2S(wallPoly->normal.z, wallPoly->normal.x);
actor->bgCheckFlags |= 8;
actor->bgCheckFlags |= BGCHECKFLAG_WALL;
actor->wallBgId = bgId;
} else {
actor->bgCheckFlags &= ~8;
actor->bgCheckFlags &= ~BGCHECKFLAG_WALL;
}
}
@ -1265,10 +1265,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
sp64.y = actor->prevPos.y + 10.0f;
if (BgCheck_EntityCheckCeiling(&globalCtx->colCtx, &sp58, &sp64, (ceilingCheckHeight + sp74) - 10.0f,
&sCurCeilingPoly, &sCurCeilingBgId, actor)) {
actor->bgCheckFlags |= 0x10;
actor->bgCheckFlags |= BGCHECKFLAG_CEILING;
actor->world.pos.y = (sp58 + sp74) - 10.0f;
} else {
actor->bgCheckFlags &= ~0x10;
actor->bgCheckFlags &= ~BGCHECKFLAG_CEILING;
}
}
@ -1280,10 +1280,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
&waterBoxYSurface, &waterBox)) {
actor->yDistToWater = waterBoxYSurface - actor->world.pos.y;
if (actor->yDistToWater < 0.0f) {
actor->bgCheckFlags &= ~0x60;
actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH);
} else {
if (!(actor->bgCheckFlags & 0x20)) {
actor->bgCheckFlags |= 0x40;
if (!(actor->bgCheckFlags & BGCHECKFLAG_WATER)) {
actor->bgCheckFlags |= BGCHECKFLAG_WATER_TOUCH;
if (!(flags & 0x40)) {
ripplePos.x = actor->world.pos.x;
ripplePos.y = waterBoxYSurface;
@ -1293,10 +1293,10 @@ void Actor_UpdateBgCheckInfo(GlobalContext* globalCtx, Actor* actor, f32 wallChe
EffectSsGRipple_Spawn(globalCtx, &ripplePos, 100, 500, 8);
}
}
actor->bgCheckFlags |= 0x20;
actor->bgCheckFlags |= BGCHECKFLAG_WATER;
}
} else {
actor->bgCheckFlags &= ~0x60;
actor->bgCheckFlags &= ~(BGCHECKFLAG_WATER | BGCHECKFLAG_WATER_TOUCH);
actor->yDistToWater = BGCHECK_Y_MIN;
}
}
@ -1699,7 +1699,7 @@ void Audio_PlayActorSound2(Actor* actor, u16 sfxId) {
void func_8002F850(GlobalContext* globalCtx, Actor* actor) {
s32 sfxId;
if (actor->bgCheckFlags & 0x20) {
if (actor->bgCheckFlags & BGCHECKFLAG_WATER) {
if (actor->yDistToWater < 20.0f) {
sfxId = NA_SE_PL_WALK_WATER0 - SFX_FLAG;
} else {
@ -3420,7 +3420,7 @@ s16 Actor_TestFloorInDirection(Actor* actor, GlobalContext* globalCtx, f32 dista
Math_Vec3f_Copy(&actor->world.pos, &prevActorPos);
ret = actor->bgCheckFlags & 1;
ret = actor->bgCheckFlags & BGCHECKFLAG_GROUND;
actor->bgCheckFlags = prevBgCheckFlags;
return ret;
@ -3936,10 +3936,10 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx) {
case 0:
if (Actor_HasParent(actor, globalCtx)) {
actor->params = 1;
} else if (!(actor->bgCheckFlags & 1)) {
} else if (!(actor->bgCheckFlags & BGCHECKFLAG_GROUND)) {
Actor_MoveForward(actor);
Math_SmoothStepToF(&actor->speedXZ, 0.0f, 1.0f, 0.1f, 0.0f);
} else if ((actor->bgCheckFlags & 2) && (actor->velocity.y < -4.0f)) {
} else if ((actor->bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) && (actor->velocity.y < -4.0f)) {
ret = 1;
} else {
actor->shape.rot.x = actor->shape.rot.z = 0;

View file

@ -278,18 +278,18 @@ void EnAObj_BoulderFragment(EnAObj* this, GlobalContext* globalCtx) {
this->dyna.actor.shape.rot.x += this->dyna.actor.world.rot.x >> 1;
this->dyna.actor.shape.rot.z += this->dyna.actor.world.rot.z >> 1;
if (this->dyna.actor.speedXZ != 0.0f && this->dyna.actor.bgCheckFlags & 0x8) {
if (this->dyna.actor.speedXZ != 0.0f && this->dyna.actor.bgCheckFlags & BGCHECKFLAG_WALL) {
this->dyna.actor.world.rot.y =
this->dyna.actor.wallYaw - this->dyna.actor.world.rot.y + this->dyna.actor.wallYaw - 0x8000;
if (1) {}
this->dyna.actor.bgCheckFlags &= ~0x8;
this->dyna.actor.bgCheckFlags &= ~BGCHECKFLAG_WALL;
}
if (this->dyna.actor.bgCheckFlags & 0x2) {
if (this->dyna.actor.bgCheckFlags & BGCHECKFLAG_GROUND_TOUCH) {
if (this->dyna.actor.velocity.y < -8.0f) {
this->dyna.actor.velocity.y *= -0.6f;
this->dyna.actor.speedXZ *= 0.6f;
this->dyna.actor.bgCheckFlags &= ~0x3;
this->dyna.actor.bgCheckFlags &= ~(BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH);
} else {
Actor_Kill(&this->dyna.actor);
}

View file

@ -597,7 +597,7 @@ void func_8001DFC8(EnItem00* this, GlobalContext* globalCtx) {
}
}
if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & 0x0001)) {
if ((this->actor.gravity != 0.0f) && !(this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) {
EnItem00_SetupAction(this, func_8001E1C8);
}
}
@ -618,14 +618,14 @@ void func_8001E1C8(EnItem00* this, GlobalContext* globalCtx) {
&sEffectEnvColor);
}
if (this->actor.bgCheckFlags & 0x0003) {
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
originalVelocity = this->actor.velocity.y;
if (originalVelocity > -2.0f) {
EnItem00_SetupAction(this, func_8001DFC8);
this->actor.velocity.y = 0.0f;
} else {
this->actor.velocity.y = originalVelocity * -0.8f;
this->actor.bgCheckFlags &= ~1;
this->actor.bgCheckFlags &= ~BGCHECKFLAG_GROUND;
}
}
}
@ -677,7 +677,7 @@ void func_8001E304(EnItem00* this, GlobalContext* globalCtx) {
&sEffectEnvColor);
}
if (this->actor.bgCheckFlags & 0x0003) {
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
EnItem00_SetupAction(this, func_8001DFC8);
this->actor.shape.rot.z = 0;
this->actor.velocity.y = 0.0f;
@ -746,7 +746,7 @@ void EnItem00_Update(Actor* thisx, GlobalContext* globalCtx) {
this->actor.scale.y = this->actor.scale.x;
if (this->actor.gravity) {
if (this->actor.bgCheckFlags & 0x0003) {
if (this->actor.bgCheckFlags & (BGCHECKFLAG_GROUND | BGCHECKFLAG_GROUND_TOUCH)) {
if (*temp != globalCtx->gameplayFrames) {
D_80157D90 = globalCtx->gameplayFrames;
D_80157D94[0] = 0;

View file

@ -436,7 +436,7 @@ void func_8008EDF0(Player* this) {
}
void func_8008EE08(Player* this) {
if ((this->actor.bgCheckFlags & 1) ||
if ((this->actor.bgCheckFlags & BGCHECKFLAG_GROUND) ||
(this->stateFlags1 & (PLAYER_STATE1_21 | PLAYER_STATE1_23 | PLAYER_STATE1_27)) ||
(!(this->stateFlags1 & (PLAYER_STATE1_18 | PLAYER_STATE1_19)) &&
((this->actor.world.pos.y - this->actor.floorHeight) < 100.0f))) {
@ -619,7 +619,7 @@ s32 func_8008F2F8(GlobalContext* globalCtx) {
var = 0;
} else if ((this->unk_840 > 80) &&
((this->currentBoots == PLAYER_BOOTS_IRON) || (this->unk_840 >= 300))) { // Deep underwater
var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & 1)) ? 1 : 3;
var = ((this->currentBoots == PLAYER_BOOTS_IRON) && (this->actor.bgCheckFlags & BGCHECKFLAG_GROUND)) ? 1 : 3;
} else if (this->stateFlags1 & PLAYER_STATE1_27) { // Swimming
var = 2;
} else {