1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-15 04:14:34 +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;