Enemy rando, fix healthy big Guays not dying (#7065)

This commit is contained in:
djevangelia
2026-08-15 22:37:15 +02:00
committed by GitHub
parent 3a3d93f732
commit 917a9b78d9
3 changed files with 49 additions and 2 deletions
@@ -6,6 +6,8 @@
extern "C" {
#include "functions.h"
#include "src/overlays/actors/ovl_En_Fz/z_en_fz.h"
#include "src/overlays/actors/ovl_En_Crow/z_en_crow.h"
extern void EnCrow_TurnAway(EnCrow*, PlayState*);
}
static constexpr int32_t CVAR_RANDO_ENEMY_SIZE_DEFAULT = 0;
@@ -61,6 +63,35 @@ static void RandomizedEnemySizes(void* refActor) {
static void RegisterRandomizedEnemySizes() {
COND_HOOK(OnActorInit, CVAR_RANDO_ENEMY_SIZE_VALUE, RandomizedEnemySizes);
// Guays try to die on any damage, but EnCrow_Update doesn't let them reach ground if health != 0
// Makeshift "damaged but not dead" action setup
COND_VB_SHOULD(VB_GUAY_SETUP_DAMAGED, CVAR_RANDO_ENEMY_SIZE_VALUE && CVAR_ENEMY_SCALE_HEALTH_VALUE, {
EnCrow* enCrow = va_arg(args, EnCrow*);
if (enCrow->actor.colChkInfo.damage < enCrow->actor.colChkInfo.health) {
*should = false;
Actor_ApplyDamage(&enCrow->actor);
enCrow->actor.colorFilterTimer = 40;
Actor_SetColorFilter(&enCrow->actor, 0x4000, 255, 0, 40);
Audio_PlayActorSound2(&enCrow->actor, NA_SE_EN_KAICHO_DEAD);
enCrow->timer = 50;
enCrow->actor.speedXZ = 3.5f;
enCrow->aimRotX = -0x1000;
enCrow->aimRotY = enCrow->actor.yawTowardsPlayer + 0x8000;
enCrow->skelAnime.playSpeed = 2.0f;
enCrow->actionFunc = EnCrow_TurnAway;
}
});
// Clamp distance from ground due to hard to hit with Kokiri
COND_VB_SHOULD(VB_GUAY_ALIVE_MOVE_HEIGHT_OFFSET, CVAR_RANDO_ENEMY_SIZE_VALUE && CVAR_ENEMY_SCALE_HEALTH_VALUE, {
f32* scale = va_arg(args, f32*);
if (*should && *scale > 2.0f) {
*scale = 2.0f;
}
});
}
static void RegisterFreezardHealthScale() {
@@ -1376,6 +1376,22 @@ typedef enum {
// - `*EnCrow`
VB_GUAY_FORCE_FLY_AWAY,
// #### `result`
// ```c
// true
// ```
// #### `args`
// - `*EnCrow`
VB_GUAY_SETUP_DAMAGED,
// #### `result`
// ```c
// this->actor.colChkInfo.health != 0
// ```
// #### `args`
// - `*f32` (scale)
VB_GUAY_ALIVE_MOVE_HEIGHT_OFFSET,
// #### `result`
// ```c
// true
@@ -424,7 +424,7 @@ void EnCrow_UpdateDamage(EnCrow* this, PlayState* play) {
if ((this->actor.colChkInfo.damageEffect != 0) || (this->actor.colChkInfo.damage != 0)) {
if (this->actor.colChkInfo.damageEffect == 1) { // Deku Nuts
EnCrow_SetupTurnAway(this);
} else {
} else if (GameInteractor_Should(VB_GUAY_SETUP_DAMAGED, true, this)) {
Actor_ApplyDamage(&this->actor);
this->actor.flags &= ~ACTOR_FLAG_ATTENTION_ENABLED;
Enemy_StartFinishingBlow(play, &this->actor);
@@ -447,7 +447,7 @@ void EnCrow_Update(Actor* thisx, PlayState* play) {
this->actor.world.rot.x = -this->actor.shape.rot.x;
if (this->actionFunc != EnCrow_Respawn) {
if (this->actor.colChkInfo.health != 0) {
if (GameInteractor_Should(VB_GUAY_ALIVE_MOVE_HEIGHT_OFFSET, this->actor.colChkInfo.health != 0, &scale)) {
height = 20.0f * scale;
Actor_MoveXYZ(&this->actor);
} else {