mirror of https://github.com/AxioDL/metaforce.git
Implement god mode, and CWeaponMgr
This commit is contained in:
parent
4d8cf17078
commit
de952f8e8b
|
@ -128,6 +128,8 @@ private:
|
||||||
std::vector<std::pair<CAssetId, float>> x170_scanTimes;
|
std::vector<std::pair<CAssetId, float>> x170_scanTimes;
|
||||||
std::pair<u32, u32> x180_scanCompletionRate = {};
|
std::pair<u32, u32> x180_scanCompletionRate = {};
|
||||||
CStaticInterference x188_staticIntf;
|
CStaticInterference x188_staticIntf;
|
||||||
|
|
||||||
|
bool m_canTakeDamage = true;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
u32 GetMissileCostForAltAttack() const;
|
u32 GetMissileCostForAltAttack() const;
|
||||||
|
@ -186,6 +188,8 @@ public:
|
||||||
void PutTo(CBitStreamWriter& stream);
|
void PutTo(CBitStreamWriter& stream);
|
||||||
static u32 GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; }
|
static u32 GetPowerUpMaxValue(EItemType type) { return PowerUpMaxValues[u32(type)]; }
|
||||||
static EItemType ItemNameToType(std::string_view name);
|
static EItemType ItemNameToType(std::string_view name);
|
||||||
|
bool CanTakeDamage() const { return m_canTakeDamage; }
|
||||||
|
void SetCanTakeDamage(bool c) { m_canTakeDamage = c; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1706,23 +1706,28 @@ bool CStateManager::ApplyLocalDamage(const zeus::CVector3f& vec1, const zeus::CV
|
||||||
|
|
||||||
if (player)
|
if (player)
|
||||||
{
|
{
|
||||||
if (x870_cameraManager->IsInCinematicCamera() ||
|
if (GetPlayerState()->CanTakeDamage())
|
||||||
(weapMode.GetType() == EWeaponType::Phazon &&
|
{
|
||||||
x8b8_playerState->HasPowerUp(CPlayerState::EItemType::PhazonSuit)))
|
if (x870_cameraManager->IsInCinematicCamera() ||
|
||||||
return false;
|
(weapMode.GetType() == EWeaponType::Phazon &&
|
||||||
|
x8b8_playerState->HasPowerUp(CPlayerState::EItemType::PhazonSuit)))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (g_GameState->GetHardMode())
|
if (g_GameState->GetHardMode())
|
||||||
mulDam *= g_GameState->GetHardModeDamageMultiplier();
|
mulDam *= g_GameState->GetHardModeDamageMultiplier();
|
||||||
|
|
||||||
float damReduction = 0.f;
|
float damReduction = 0.f;
|
||||||
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::VariaSuit))
|
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::VariaSuit))
|
||||||
damReduction = g_tweakPlayer->GetVariaDamageReduction();
|
damReduction = g_tweakPlayer->GetVariaDamageReduction();
|
||||||
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::GravitySuit))
|
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::GravitySuit))
|
||||||
damReduction = std::max(g_tweakPlayer->GetGravityDamageReduction(), damReduction);
|
damReduction = std::max(g_tweakPlayer->GetGravityDamageReduction(), damReduction);
|
||||||
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::PhazonSuit))
|
if (x8b8_playerState->HasPowerUp(CPlayerState::EItemType::PhazonSuit))
|
||||||
damReduction = std::max(g_tweakPlayer->GetPhazonDamageReduction(), damReduction);
|
damReduction = std::max(g_tweakPlayer->GetPhazonDamageReduction(), damReduction);
|
||||||
|
|
||||||
mulDam = -(damReduction * mulDam - mulDam);
|
mulDam = -(damReduction * mulDam - mulDam);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mulDam = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float newHp = hInfo->GetHP() - mulDam;
|
float newHp = hInfo->GetHP() - mulDam;
|
||||||
|
|
|
@ -515,6 +515,18 @@ void CMain::Give(hecl::Console* console, const std::vector<std::string>& args)
|
||||||
console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!");
|
console->report(hecl::Console::Level::Info, "Cheater....., Greatly increasing Metroid encounters, have fun!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMain::God(hecl::Console* con, const std::vector<std::string> &)
|
||||||
|
{
|
||||||
|
if (g_GameState && g_GameState->GetPlayerState())
|
||||||
|
{
|
||||||
|
g_GameState->GetPlayerState()->SetCanTakeDamage(!g_GameState->GetPlayerState()->CanTakeDamage());
|
||||||
|
if (!g_GameState->GetPlayerState()->CanTakeDamage())
|
||||||
|
con->report(hecl::Console::Level::Info, "God Mode Enabled");
|
||||||
|
else
|
||||||
|
con->report(hecl::Console::Level::Info, "God Mode Disabled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMain::Teleport(hecl::Console *, const std::vector<std::string>& args)
|
void CMain::Teleport(hecl::Console *, const std::vector<std::string>& args)
|
||||||
{
|
{
|
||||||
if (!g_StateManager || args.size() < 3)
|
if (!g_StateManager || args.size() < 3)
|
||||||
|
@ -655,6 +667,7 @@ void CMain::Init(const hecl::Runtime::FileStoreManager& storeMgr,
|
||||||
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
|
m_console->registerCommand("quit"sv, "Quits the game immediately"sv, ""sv, std::bind(&CMain::quit, this, std::placeholders::_1, std::placeholders::_2));
|
||||||
m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
|
m_console->registerCommand("Give"sv, "Gives the player the specified item, maxing it out"sv, ""sv, std::bind(&CMain::Give, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
|
||||||
m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer));
|
m_console->registerCommand("Teleport"sv, "Teleports the player to the specified coordinates in worldspace"sv, "x y z [dX dY dZ]"sv, std::bind(&CMain::Teleport, this, std::placeholders::_1, std::placeholders::_2), (hecl::SConsoleCommand::ECommandFlags::Cheat | hecl::SConsoleCommand::ECommandFlags::Developer));
|
||||||
|
m_console->registerCommand("God"sv, "Disables damage given by enemies and objects"sv, ""sv, std::bind(&CMain::God, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Cheat);
|
||||||
m_console->registerCommand("listWorlds"sv, "Lists loaded worlds"sv, ""sv, std::bind(&CMain::ListWorlds, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal);
|
m_console->registerCommand("listWorlds"sv, "Lists loaded worlds"sv, ""sv, std::bind(&CMain::ListWorlds, this, std::placeholders::_1, std::placeholders::_2), hecl::SConsoleCommand::ECommandFlags::Normal);
|
||||||
|
|
||||||
InitializeSubsystems(storeMgr);
|
InitializeSubsystems(storeMgr);
|
||||||
|
|
|
@ -332,6 +332,7 @@ public:
|
||||||
m_doQuit = true;
|
m_doQuit = true;
|
||||||
}
|
}
|
||||||
void Give(hecl::Console*, const std::vector<std::string>&);
|
void Give(hecl::Console*, const std::vector<std::string>&);
|
||||||
|
void God(hecl::Console*, const std::vector<std::string>&);
|
||||||
void Teleport(hecl::Console*, const std::vector<std::string>&);
|
void Teleport(hecl::Console*, const std::vector<std::string>&);
|
||||||
void ListWorlds(hecl::Console*, const std::vector<std::string>&);
|
void ListWorlds(hecl::Console*, const std::vector<std::string>&);
|
||||||
hecl::Console* Console() const { return m_console.get(); }
|
hecl::Console* Console() const { return m_console.get(); }
|
||||||
|
|
|
@ -3,34 +3,54 @@
|
||||||
namespace urde
|
namespace urde
|
||||||
{
|
{
|
||||||
|
|
||||||
void CWeaponMgr::Add(TUniqueId, EWeaponType)
|
void CWeaponMgr::Add(TUniqueId uid, EWeaponType type)
|
||||||
{
|
{
|
||||||
|
x0_weapons.insert(std::make_pair(uid, rstl::reserved_vector<s32, 10>()));
|
||||||
|
x0_weapons[uid].resize(10);
|
||||||
|
++x0_weapons[uid][u32(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWeaponMgr::Remove(TUniqueId)
|
void CWeaponMgr::Remove(TUniqueId uid)
|
||||||
{
|
{
|
||||||
|
s32 totalActive = 0;
|
||||||
|
for (u32 i = 0; i < 10; ++i)
|
||||||
|
totalActive += x0_weapons[uid][i];
|
||||||
|
|
||||||
|
if (totalActive == 0)
|
||||||
|
x0_weapons.erase(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWeaponMgr::IncrCount(TUniqueId, EWeaponType)
|
void CWeaponMgr::IncrCount(TUniqueId uid, EWeaponType type)
|
||||||
{
|
{
|
||||||
|
if (GetIndex(uid) < 0)
|
||||||
|
Add(uid, type);
|
||||||
|
else
|
||||||
|
x0_weapons[uid][u32(type)]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CWeaponMgr::DecrCount(TUniqueId, EWeaponType)
|
void CWeaponMgr::DecrCount(TUniqueId uid, EWeaponType type)
|
||||||
{
|
{
|
||||||
|
if (GetIndex(uid) < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
x0_weapons[uid][u32(type)]--;
|
||||||
|
if (x0_weapons[uid][u32(type)] <= 0)
|
||||||
|
Remove(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CWeaponMgr::GetNumActive(TUniqueId, EWeaponType) const
|
s32 CWeaponMgr::GetNumActive(TUniqueId uid, EWeaponType type) const
|
||||||
{
|
{
|
||||||
return 0;
|
if (GetIndex(uid) < 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return x0_weapons.at(uid)[u32(type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 CWeaponMgr::GetIndex(TUniqueId) const
|
s32 CWeaponMgr::GetIndex(TUniqueId uid) const
|
||||||
{
|
{
|
||||||
return 0;
|
if (x0_weapons.find(uid) == x0_weapons.end())
|
||||||
|
return -1;
|
||||||
|
return s32(std::distance(x0_weapons.begin(), x0_weapons.find(uid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue