mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-12-03 06:42:19 -05:00
Boulder Shuffle - Shuffles all Boulders randomly (#4554)
This commit is contained in:
parent
d9d831f241
commit
d459043644
@ -2,6 +2,7 @@
|
||||
#include "Holiday.hpp"
|
||||
#include "soh/Notification/Notification.h"
|
||||
#include "soh/Enhancements/gameplaystats.h"
|
||||
#include "soh/Enhancements/game-interactor/GameInteractor.h"
|
||||
|
||||
extern "C" {
|
||||
#include "macros.h"
|
||||
@ -17,6 +18,8 @@ uint64_t GetUnixTimestamp();
|
||||
bool isDisabled = false;
|
||||
float fontScale = 1.0f;
|
||||
|
||||
std::vector<ActorID> boulderList = { ACTOR_OBJ_BOMBIWA, ACTOR_BG_ICE_SHELTER, ACTOR_EN_ISHI, ACTOR_OBJ_HAMISHI };
|
||||
|
||||
std::string formatTimestampIceTrapFever(uint32_t value) {
|
||||
uint32_t sec = value / 10;
|
||||
uint32_t hh = sec / 3600;
|
||||
@ -40,8 +43,66 @@ int32_t calculateRemainingTime() {
|
||||
return timeRemaining;
|
||||
}
|
||||
|
||||
static void OnConfigurationChanged() {
|
||||
isDisabled = !CVarGetInteger(CVAR("Enabled"), 0);
|
||||
s32 ActorSnapToFloor(Actor* refActor, PlayState* play, f32 arg2) {
|
||||
CollisionPoly* poly;
|
||||
Vec3f pos;
|
||||
s32 bgId;
|
||||
f32 floorY;
|
||||
|
||||
pos.x = refActor->world.pos.x;
|
||||
pos.y = refActor->world.pos.y + 30.0f;
|
||||
pos.z = refActor->world.pos.z;
|
||||
floorY = BgCheck_EntityRaycastFloor4(&play->colCtx, &poly, &bgId, refActor, &pos);
|
||||
if (floorY > BGCHECK_Y_MIN) {
|
||||
refActor->world.pos.y = floorY + arg2;
|
||||
Math_Vec3f_Copy(&refActor->home.pos, &refActor->world.pos);
|
||||
}
|
||||
return refActor->world.pos.y;
|
||||
}
|
||||
|
||||
void RandomizeBoulder(Actor* refActor) {
|
||||
Actor* actor = (Actor*) refActor;
|
||||
int16_t param = actor->params;
|
||||
int32_t yAdj = 0;
|
||||
uint32_t roll = rand() % boulderList.size();
|
||||
if (boulderList[roll] == ACTOR_EN_ISHI) {
|
||||
param = 3;
|
||||
}
|
||||
yAdj = ActorSnapToFloor(actor, gPlayState, 0.0f);
|
||||
//if (actor->id != ACTOR_EN_ISHI && boulderList[roll] == ACTOR_EN_ISHI) {
|
||||
// yAdj = 20;
|
||||
//}
|
||||
//if (actor->id == ACTOR_EN_ISHI && boulderList[roll] != ACTOR_EN_ISHI) {
|
||||
// yAdj = -20;
|
||||
//}
|
||||
|
||||
Actor_Spawn(&gPlayState->actorCtx, gPlayState, boulderList[roll], actor->world.pos.x, ActorSnapToFloor(actor, gPlayState, 0.0f),
|
||||
actor->world.pos.z, 0, 0, 0, param, false);
|
||||
Actor_Kill(actor);
|
||||
}
|
||||
|
||||
static void OnBlitzChange() {
|
||||
COND_HOOK(OnSceneSpawnActors, CVarGetInteger(CVAR("Blitz.Enabled"), 0), []() {
|
||||
if (!gPlayState) {
|
||||
return;
|
||||
}
|
||||
ActorListEntry boulders = gPlayState->actorCtx.actorLists[ACTORCAT_PROP];
|
||||
Actor* currentActor = boulders.head;
|
||||
if (currentActor != nullptr) {
|
||||
while (currentActor != nullptr) {
|
||||
for (auto& boulderActor : boulderList) {
|
||||
if (currentActor->id == boulderActor) {
|
||||
RandomizeBoulder(currentActor);
|
||||
}
|
||||
}
|
||||
currentActor = currentActor->next;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void OnFeverConfigurationChanged() {
|
||||
isDisabled = !CVarGetInteger(CVAR("Fever.Enabled"), 0);
|
||||
fontScale = CVarGetFloat(CVAR("FontScale"), 1.0f);
|
||||
if (fontScale < 1.0f) {
|
||||
fontScale = 1.0f;
|
||||
@ -55,7 +116,7 @@ static void OnConfigurationChanged() {
|
||||
}
|
||||
|
||||
void CaladiusWindow::Draw() {
|
||||
if (!CVarGetInteger(CVAR("Enabled"), 0)) {
|
||||
if (!CVarGetInteger(CVAR("Fever.Enabled"), 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -80,24 +141,31 @@ void CaladiusWindow::Draw() {
|
||||
|
||||
static void DrawMenu() {
|
||||
ImGui::SeparatorText(AUTHOR);
|
||||
if (UIWidgets::EnhancementCheckbox("Holiday Fever", CVAR("Enabled"))) {
|
||||
OnConfigurationChanged();
|
||||
if (UIWidgets::EnhancementCheckbox("Holiday Fever", CVAR("Fever.Enabled"))) {
|
||||
OnFeverConfigurationChanged();
|
||||
}
|
||||
UIWidgets::Tooltip("Can you beat your objective before the Fever sets in?\n"
|
||||
UIWidgets::Tooltip("Can you beat your objective before the Fever sets in?/n"
|
||||
"- Obtaining Ice Traps extends your timer.");
|
||||
ImGui::Text("Options");
|
||||
if (UIWidgets::PaddedEnhancementSliderFloat("", "##FontScale", CVAR("FontScale"),
|
||||
1.0f, 5.0f, "%.1fx", 1.0f, false, false, false, false, isDisabled)) {
|
||||
OnConfigurationChanged();
|
||||
OnFeverConfigurationChanged();
|
||||
}
|
||||
UIWidgets::PaddedEnhancementSliderInt("Starting Timer: %d minutes", "##StartTime", CVAR("StartTimer"),
|
||||
5, 30, "", 15, true, true, false, isDisabled);
|
||||
UIWidgets::PaddedEnhancementSliderInt("Time Extensions: %d minutes", "##ExtendTime", CVAR("ExtendTimer"),
|
||||
1, 10, "", 5, true, true, false, isDisabled);
|
||||
UIWidgets::PaddedSeparator();
|
||||
|
||||
if (UIWidgets::EnhancementCheckbox("Boulder Blitz", CVAR("Blitz.Enabled"))) {
|
||||
OnBlitzChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void RegisterMod() {
|
||||
OnConfigurationChanged();
|
||||
OnFeverConfigurationChanged();
|
||||
OnBlitzChange();
|
||||
}
|
||||
|
||||
static Holiday holiday(DrawMenu, RegisterMod);
|
||||
|
@ -3297,7 +3297,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
|
||||
|
||||
objBankIndex = Object_GetIndex(&gPlayState->objectCtx, dbEntry->objectId);
|
||||
|
||||
if (objBankIndex < 0 && (!gMapLoading || CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0))) {
|
||||
if (objBankIndex < 0 && (!gMapLoading || CVarGetInteger(CVAR_ENHANCEMENT("RandomizedEnemies"), 0) || CVarGetInteger("gHoliday.Caladius.Blitz.Enabled", 0))) {
|
||||
objBankIndex = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user