Randomized Enemy Sizes (#3321)

This commit is contained in:
aMannus 2023-11-05 14:54:23 +01:00 committed by GitHub
parent 39a7437fc8
commit 13a8a1a5cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View File

@ -1038,6 +1038,39 @@ void RegisterRandomizerSheikSpawn() {
});
}
void RegisterRandomizedEnemySizes() {
GameInteractor::Instance->RegisterGameHook<GameInteractor::OnActorInit>([](void* refActor) {
// Randomized Enemy Sizes
Player* player = GET_PLAYER(gPlayState);
Actor* actor = static_cast<Actor*>(refActor);
// Only apply to enemies and bosses. Exclude the wobbly platforms in Jabu because they need to act like platforms.
if (!CVarGetInteger("gRandomizedEnemySizes", 0) || (actor->category != ACTORCAT_ENEMY && actor->category != ACTORCAT_BOSS) || actor->id == ACTOR_EN_BROB) {
return;
}
float randomNumber;
float randomScale;
uint8_t bigActor = rand() % 2;
// Big actor. Dodongo and Volvagia are always smaller because they're impossible when bigger.
if (bigActor && actor->id != ACTOR_BOSS_DODONGO && actor->id != ACTOR_BOSS_FD &&
actor->id != ACTOR_BOSS_FD2) {
randomNumber = rand() % 200;
// Between 100% and 300% size.
randomScale = 1.0f + (randomNumber / 100);
// Small actor
} else {
randomNumber = rand() % 90;
// Between 10% and 100% size.
randomScale = 0.1f + (randomNumber / 100);
}
Actor_SetScale(actor, actor->scale.z * randomScale);
});
}
void InitMods() {
RegisterTTS();
RegisterInfiniteMoney();
@ -1065,5 +1098,6 @@ void InitMods() {
RegisterEnemyDefeatCounts();
RegisterAltTrapTypes();
RegisterRandomizerSheikSpawn();
RegisterRandomizedEnemySizes();
NameTag_RegisterHooks();
}

View File

@ -1115,6 +1115,9 @@ void DrawEnhancementsMenu() {
"- Random (Seeded): Enemies are randomized based on the current randomizer seed/file\n"
);
UIWidgets::PaddedEnhancementCheckbox("Randomized Enemy Sizes", "gRandomizedEnemySizes", true, false);
UIWidgets::Tooltip("Enemies and Bosses spawn with random sizes.");
UIWidgets::PaddedEnhancementCheckbox("Ivan the Fairy (Coop Mode)", "gIvanCoopModeEnabled", true, false);
UIWidgets::Tooltip("Enables Ivan the Fairy upon the next map change. Player 2 can control Ivan and "
"press the C-Buttons to use items and mess with Player 1!");