mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-29 04:42:18 -05:00
Add gravity support
This commit is contained in:
parent
d5f8dbfeea
commit
9e54c6d4ff
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "debugconsole.h"
|
#include "debugconsole.h"
|
||||||
#include "../libultraship/ImGuiImpl.h"
|
#include "../libultraship/ImGuiImpl.h"
|
||||||
|
#include "../libultraship/Utils.h"
|
||||||
#include "savestates.h"
|
#include "savestates.h"
|
||||||
#include "Console.h"
|
#include "Console.h"
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ extern GlobalContext* gGlobalCtx;
|
|||||||
uint32_t defenseModifier;
|
uint32_t defenseModifier;
|
||||||
uint32_t giantLink;
|
uint32_t giantLink;
|
||||||
uint32_t minishLink;
|
uint32_t minishLink;
|
||||||
uint32_t highGravity;
|
uint32_t gravityLevel;
|
||||||
uint32_t resetLinkScale;
|
uint32_t resetLinkScale;
|
||||||
uint32_t noUi;
|
uint32_t noUi;
|
||||||
uint32_t invisibleLink;
|
uint32_t invisibleLink;
|
||||||
@ -90,7 +91,6 @@ static bool ActorSpawnHandler(std::shared_ptr<Ship::Console> Console, const std:
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool KillPlayerHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>&) {
|
static bool KillPlayerHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>&) {
|
||||||
gSaveContext.health = 0;
|
gSaveContext.health = 0;
|
||||||
SohImGui::console->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?");
|
SohImGui::console->SendInfoMessage("[SOH] You've met with a terrible fate, haven't you?");
|
||||||
@ -123,7 +123,6 @@ static bool SetPlayerHealthHandler(std::shared_ptr<Ship::Console> Console, const
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool LoadSceneHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>&) {
|
static bool LoadSceneHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>&) {
|
||||||
gSaveContext.respawnFlag = 0;
|
gSaveContext.respawnFlag = 0;
|
||||||
gSaveContext.seqId = 0xFF;
|
gSaveContext.seqId = 0xFF;
|
||||||
@ -387,17 +386,86 @@ static bool InvisibleHandler(std::shared_ptr<Ship::Console> Console, const std::
|
|||||||
return CMD_FAILED;
|
return CMD_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invisible;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
invisible = std::stoi(args[1], nullptr, 10);
|
invisibleLink = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1;
|
||||||
|
return CMD_SUCCESS;
|
||||||
} catch (std::invalid_argument const& ex) {
|
} catch (std::invalid_argument const& ex) {
|
||||||
SohImGui::console->SendErrorMessage("[SOH] Invisible value must be a number.");
|
SohImGui::console->SendErrorMessage("[SOH] Invisible value must be a number.");
|
||||||
return CMD_FAILED;
|
return CMD_FAILED;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool GiantLinkHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
|
if (args.size() != 2) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
giantLink = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1;
|
||||||
|
if (giantLink)
|
||||||
|
minishLink = 0;
|
||||||
|
else
|
||||||
|
resetLinkScale = 1;
|
||||||
|
|
||||||
invisibleLink = invisible;
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
|
} catch (std::invalid_argument const& ex) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Giant value must be a number.");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool MinishLinkHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
|
if (args.size() != 2) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
resetLinkScale = 1;
|
||||||
|
minishLink = std::stoi(args[1], nullptr, 10) == 0 ? 0 : 1;
|
||||||
|
|
||||||
|
if (minishLink)
|
||||||
|
giantLink = 0;
|
||||||
|
else
|
||||||
|
resetLinkScale = 1;
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
} catch (std::invalid_argument const& ex) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Minish value must be a number.");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool AddHeartContainerHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
|
if (gSaveContext.healthCapacity >= 0x140)
|
||||||
|
return CMD_FAILED;
|
||||||
|
|
||||||
|
gSaveContext.healthCapacity += 0x10;
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool RemoveHeartContainerHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
|
if ((gSaveContext.healthCapacity - 0x10) < 3)
|
||||||
|
return CMD_FAILED;
|
||||||
|
|
||||||
|
gSaveContext.healthCapacity -= 0x10;
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool GravityHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
|
if (args.size() != 2) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Unexpected arguments passed");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
gravityLevel = Ship::Math::clamp(std::stoi(args[1], nullptr, 10), 0.0f, 2.0f);
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
} catch (std::invalid_argument const& ex) {
|
||||||
|
SohImGui::console->SendErrorMessage("[SOH] Minish value must be a number.");
|
||||||
|
return CMD_FAILED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VARTYPE_INTEGER 0
|
#define VARTYPE_INTEGER 0
|
||||||
@ -460,7 +528,6 @@ static bool SetCVarHandler(std::shared_ptr<Ship::Console> Console, const std::ve
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool GetCVarHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
static bool GetCVarHandler(std::shared_ptr<Ship::Console> Console, const std::vector<std::string>& args) {
|
||||||
if (args.size() < 2)
|
if (args.size() < 2)
|
||||||
return CMD_FAILED;
|
return CMD_FAILED;
|
||||||
@ -546,8 +613,25 @@ void DebugConsole_Init(void) {
|
|||||||
{ "Slot number", Ship::ArgumentType::NUMBER, }
|
{ "Slot number", Ship::ArgumentType::NUMBER, }
|
||||||
}});
|
}});
|
||||||
|
|
||||||
CMD_REGISTER("invisible", { InvisibleHandler, "Toggles invisibility.", {
|
// Console effects
|
||||||
{ "invisible", Ship::ArgumentType::NUMBER }
|
CMD_REGISTER("invisible", { InvisibleHandler, "Activate Link's Elvish cloak, making him appear invisible.", {
|
||||||
|
{ "value", Ship::ArgumentType::NUMBER }
|
||||||
|
}});
|
||||||
|
|
||||||
|
CMD_REGISTER("giant_link", { GiantLinkHandler, "Turn Link into a giant Lonky boi.", {
|
||||||
|
{ "value", Ship::ArgumentType::NUMBER }
|
||||||
|
}});
|
||||||
|
|
||||||
|
CMD_REGISTER("minish_link", { MinishLinkHandler, "Turn Link into a minish boi.", {
|
||||||
|
{ "value", Ship::ArgumentType::NUMBER }
|
||||||
|
}});
|
||||||
|
|
||||||
|
CMD_REGISTER("add_heart_container", { AddHeartContainerHandler, "Give Link a heart! The maximum amount of hearts is 20!" });
|
||||||
|
|
||||||
|
CMD_REGISTER("remove_heart_container", { RemoveHeartContainerHandler, "Remove a heart from Link. The minimal amount of hearts is 3." });
|
||||||
|
|
||||||
|
CMD_REGISTER("gravity", { GravityHandler, "Set gravity level.", {
|
||||||
|
{ "value", Ship::ArgumentType::NUMBER }
|
||||||
}});
|
}});
|
||||||
|
|
||||||
CVar_Load();
|
CVar_Load();
|
||||||
|
@ -8,7 +8,7 @@ extern "C" {
|
|||||||
extern uint32_t defenseModifier;
|
extern uint32_t defenseModifier;
|
||||||
extern uint32_t giantLink;
|
extern uint32_t giantLink;
|
||||||
extern uint32_t minishLink;
|
extern uint32_t minishLink;
|
||||||
extern uint32_t highGravity;
|
extern uint32_t gravityLevel;
|
||||||
extern uint32_t resetLinkScale;
|
extern uint32_t resetLinkScale;
|
||||||
extern uint32_t noUi;
|
extern uint32_t noUi;
|
||||||
extern uint32_t invisibleLink;
|
extern uint32_t invisibleLink;
|
||||||
|
@ -1559,7 +1559,7 @@ void RemoveEffect(const char* effectId) {
|
|||||||
Player_SetBootData(gGlobalCtx, player);
|
Player_SetBootData(gGlobalCtx, player);
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(effectId, "high_gravity") == 0 || strcmp(effectId, "low_gravity") == 0) {
|
} else if (strcmp(effectId, "high_gravity") == 0 || strcmp(effectId, "low_gravity") == 0) {
|
||||||
highGravity = 0;
|
gravityLevel = 1;
|
||||||
return;
|
return;
|
||||||
} else if (strcmp(effectId, "no_ui") == 0) {
|
} else if (strcmp(effectId, "no_ui") == 0) {
|
||||||
noUi = 0;
|
noUi = 0;
|
||||||
@ -1597,10 +1597,10 @@ u8 ExecuteEffect(const char* effectId, uint32_t value) {
|
|||||||
|
|
||||||
if (player != NULL && !Player_InBlockingCsMode(gGlobalCtx, player) && gGlobalCtx->pauseCtx.state == 0) {
|
if (player != NULL && !Player_InBlockingCsMode(gGlobalCtx, player) && gGlobalCtx->pauseCtx.state == 0) {
|
||||||
if (strcmp(effectId, "high_gravity") == 0) {
|
if (strcmp(effectId, "high_gravity") == 0) {
|
||||||
highGravity = 1;
|
gravityLevel = 2;
|
||||||
return 1;
|
return 1;
|
||||||
} else if (strcmp(effectId, "low_gravity") == 0) {
|
} else if (strcmp(effectId, "low_gravity") == 0) {
|
||||||
highGravity = 2;
|
gravityLevel = 0;
|
||||||
return 1;
|
return 1;
|
||||||
} else if (strcmp(effectId, "giant_link") == 0) {
|
} else if (strcmp(effectId, "giant_link") == 0) {
|
||||||
giantLink = 1;
|
giantLink = 1;
|
||||||
|
@ -11128,11 +11128,11 @@ void Player_Update(Actor* thisx, GlobalContext* globalCtx) {
|
|||||||
resetLinkScale = 0;
|
resetLinkScale = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highGravity == 1) {
|
if (gravityLevel == 2) {
|
||||||
this->actor.gravity = -4.0f;
|
this->actor.gravity = -4.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (highGravity == 2) {
|
if (gravityLevel == 0) {
|
||||||
this->actor.gravity = -0.3f;
|
this->actor.gravity = -0.3f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user