From adc7dd050f3a2fd13b85b2d799154061d196ef09 Mon Sep 17 00:00:00 2001 From: MegaMech Date: Sun, 20 Jul 2025 17:13:35 -0600 Subject: Add Rulesets (#494) --- src/engine/Rulesets.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/engine/Rulesets.cpp (limited to 'src/engine/Rulesets.cpp') diff --git a/src/engine/Rulesets.cpp b/src/engine/Rulesets.cpp new file mode 100644 index 000000000..acdbfde2a --- /dev/null +++ b/src/engine/Rulesets.cpp @@ -0,0 +1,48 @@ +#include "Rulesets.h" +#include "objects/Thwomp.h" +#include "objects/Trophy.h" + +extern "C" { +#include "code_800029B0.h" +#include "memory.h" +} + +// Before the game is loaded, and before vertices and displaylists are unpacked. +// Only runs a single time at the beginning of a track. +void Rulesets::PreLoad() { +} + +// Just before BeginPlay() (used to spawn actors) is ran. +// Only runs a single time at the beginning of a track. +void Rulesets::PreInit() { + if (CVarGetInteger("gDisableItemboxes", false) == true) { + gPlaceItemBoxes = false; + } else { + gPlaceItemBoxes = true; + } +} + +// Just after BeginPlay() is ran. +// Only runs a single time at the beginning of a track. +void Rulesets::PostInit() { + if (CVarGetInteger("gAllThwompsAreMarty", false) == true) { + for (auto object : gWorldInstance.Objects) { + if (OThwomp* thwomp = dynamic_cast(object)) { + gObjectList[thwomp->_objectIndex].unk_0D5 = OThwomp::States::JAILED; // Sets all the thwomp behaviour flags to marty + thwomp->State = OThwomp::States::JAILED; + } + } + } + + if (CVarGetInteger("gAllBombKartsChase", false) == true) { + for (auto object : gWorldInstance.Objects) { + if (OBombKart* kart = dynamic_cast(object)) { + kart->State = OBombKart::States::CHASE; + } + } + } + + if (CVarGetInteger("gGoFish", false) == true) { + gWorldInstance.AddObject(new OTrophy(FVector(0,0,0), OTrophy::TrophyType::GOLD, OTrophy::Behaviour::GO_FISH)); + } +} -- cgit v1.2.3