2015-08-17 22:05:00 +00:00
|
|
|
#include "CPlayerState.hpp"
|
2016-03-19 19:19:43 +00:00
|
|
|
#include "IOStreams.hpp"
|
2016-03-23 20:38:01 +00:00
|
|
|
#include "zeus/Math.hpp"
|
2016-09-15 07:26:35 +00:00
|
|
|
#include "CStateManager.hpp"
|
|
|
|
#include "Camera/CCameraManager.hpp"
|
|
|
|
#include "Camera/CFirstPersonCamera.hpp"
|
2017-02-06 03:21:58 +00:00
|
|
|
#include "CMemoryCardSys.hpp"
|
|
|
|
#include "GameGlobalObjects.hpp"
|
2015-08-17 22:05:00 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
namespace urde
|
2015-08-17 22:05:00 +00:00
|
|
|
{
|
2016-03-23 20:38:01 +00:00
|
|
|
const u32 CPlayerState::PowerUpMaxValues[41] =
|
2016-03-19 19:19:43 +00:00
|
|
|
{ 1, 1, 1, 1, 250, 1, 1, 8, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
|
|
1, 1, 1, 14, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
|
|
|
|
};
|
|
|
|
|
|
|
|
const char* PowerUpNames[41]=
|
|
|
|
{
|
2016-03-23 20:38:01 +00:00
|
|
|
"Power Beam",
|
|
|
|
"Ice Beam",
|
|
|
|
"Wave Beam",
|
|
|
|
"Plasma Beam",
|
2016-03-19 19:19:43 +00:00
|
|
|
"Missiles",
|
2016-03-23 20:38:01 +00:00
|
|
|
"Scan Visor",
|
|
|
|
"Morph Ball Bombs",
|
2016-03-19 19:19:43 +00:00
|
|
|
"Power Bombs",
|
2016-03-23 20:38:01 +00:00
|
|
|
"Flamethrower",
|
|
|
|
"Thermal Visor",
|
|
|
|
"Charge Beam",
|
|
|
|
"Super Missile",
|
|
|
|
"GrappleBeam",
|
|
|
|
"X-Ray Visor",
|
|
|
|
"Ice Spreader",
|
|
|
|
"Space Jump Boots",
|
|
|
|
"Morph Ball",
|
|
|
|
"Combat Visor",
|
|
|
|
"Boost Ball",
|
|
|
|
"Spider Ball",
|
|
|
|
"Power Suit",
|
|
|
|
"Gravity Suit",
|
|
|
|
"Varia Suit",
|
|
|
|
"Phazon Suit",
|
2016-03-19 19:19:43 +00:00
|
|
|
"Energy Tanks",
|
2016-03-23 20:38:01 +00:00
|
|
|
"Unknown Item 1",
|
|
|
|
"Health Refill",
|
|
|
|
"Unknown Item 2",
|
|
|
|
"Wavebuster",
|
|
|
|
"Artifact of Truth",
|
|
|
|
"Artifact of Strength",
|
|
|
|
"Artifact of Elder",
|
|
|
|
"Artifact of Wild",
|
|
|
|
"Artifact of Lifegiver",
|
|
|
|
"Artifact of Warrior",
|
|
|
|
"Artifact of Chozo",
|
|
|
|
"Artifact of Nature",
|
|
|
|
"Artifact of Sun",
|
|
|
|
"Artifact of World",
|
|
|
|
"Artifact of Spirit",
|
|
|
|
"Artifact of Newborn",
|
2016-03-19 19:19:43 +00:00
|
|
|
};
|
|
|
|
|
2017-02-06 03:21:58 +00:00
|
|
|
CPlayerState::CPlayerState()
|
|
|
|
: x188_staticIntf(5)
|
|
|
|
{
|
2017-02-18 02:19:50 +00:00
|
|
|
x0_24_alive = true;
|
2018-02-15 04:37:21 +00:00
|
|
|
x24_powerups.resize(41);
|
2017-02-06 03:21:58 +00:00
|
|
|
}
|
|
|
|
|
2016-03-28 08:54:02 +00:00
|
|
|
CPlayerState::CPlayerState(CBitStreamReader& stream)
|
2017-02-06 03:21:58 +00:00
|
|
|
: x188_staticIntf(5)
|
2015-08-20 02:52:07 +00:00
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
x4_enabledItems = stream.ReadEncoded(0x20);
|
2016-03-28 08:54:02 +00:00
|
|
|
u32 tmp = stream.ReadEncoded(0x20);
|
2016-06-30 19:33:38 +00:00
|
|
|
xc_health.SetHP(*reinterpret_cast<float*>(&tmp));
|
2016-03-28 08:54:02 +00:00
|
|
|
x8_currentBeam = EBeamId(stream.ReadEncoded(CBitStreamReader::GetBitCount(5)));
|
|
|
|
x20_currentSuit = EPlayerSuit(stream.ReadEncoded(CBitStreamReader::GetBitCount(4)));
|
2018-02-15 04:37:21 +00:00
|
|
|
x24_powerups.resize(41);
|
2016-03-28 08:54:02 +00:00
|
|
|
for (u32 i = 0; i < x24_powerups.size(); ++i)
|
2016-03-19 19:19:43 +00:00
|
|
|
{
|
2016-03-28 08:54:02 +00:00
|
|
|
if (PowerUpMaxValues[i] == 0)
|
|
|
|
continue;
|
2016-03-19 19:19:43 +00:00
|
|
|
|
2016-03-28 08:54:02 +00:00
|
|
|
u32 a = stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i]));
|
|
|
|
u32 b = stream.ReadEncoded(CBitStreamReader::GetBitCount(PowerUpMaxValues[i]));
|
|
|
|
x24_powerups[i] = CPowerUp(a, b);
|
|
|
|
}
|
2016-03-19 19:19:43 +00:00
|
|
|
|
2017-02-06 03:21:58 +00:00
|
|
|
const auto& scanStates = g_MemoryCardSys->GetScanStates();
|
2018-04-05 06:58:11 +00:00
|
|
|
x170_scanTimes.reserve(scanStates.size());
|
2017-02-06 03:21:58 +00:00
|
|
|
for (const auto& state : scanStates)
|
2016-03-28 08:54:02 +00:00
|
|
|
{
|
2017-02-06 03:21:58 +00:00
|
|
|
float time = stream.ReadEncoded(1) ? 1.f : 0.f;
|
|
|
|
x170_scanTimes.emplace_back(state.first, time);
|
2016-03-28 08:54:02 +00:00
|
|
|
}
|
2016-03-19 19:19:43 +00:00
|
|
|
|
2017-07-31 05:19:05 +00:00
|
|
|
x180_scanCompletionRate.first = stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100));
|
|
|
|
x180_scanCompletionRate.second = stream.ReadEncoded(CBitStreamReader::GetBitCount(0x100));
|
2016-03-28 08:54:02 +00:00
|
|
|
}
|
2016-03-19 19:19:43 +00:00
|
|
|
|
2017-07-31 05:19:05 +00:00
|
|
|
void CPlayerState::PutTo(CBitStreamWriter& stream)
|
2016-03-28 08:54:02 +00:00
|
|
|
{
|
2017-08-13 05:26:14 +00:00
|
|
|
stream.WriteEncoded(x4_enabledItems, 32);
|
2016-06-30 19:33:38 +00:00
|
|
|
float hp = xc_health.GetHP();
|
2017-02-08 06:48:43 +00:00
|
|
|
stream.WriteEncoded(*reinterpret_cast<u32*>(&hp), 32);
|
|
|
|
stream.WriteEncoded(u32(x8_currentBeam), CBitStreamWriter::GetBitCount(5));
|
|
|
|
stream.WriteEncoded(u32(x20_currentSuit), CBitStreamWriter::GetBitCount(4));
|
2016-03-28 08:54:02 +00:00
|
|
|
for (u32 i = 0; i < x24_powerups.size(); ++i)
|
|
|
|
{
|
|
|
|
const CPowerUp& pup = x24_powerups[i];
|
|
|
|
stream.WriteEncoded(pup.x0_amount, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
|
|
|
|
stream.WriteEncoded(pup.x4_capacity, CBitStreamWriter::GetBitCount(PowerUpMaxValues[i]));
|
|
|
|
}
|
2016-03-19 19:19:43 +00:00
|
|
|
|
2016-03-28 08:54:02 +00:00
|
|
|
for (const auto& scanTime : x170_scanTimes)
|
|
|
|
{
|
|
|
|
if (scanTime.second >= 1.f)
|
|
|
|
stream.WriteEncoded(true, 1);
|
|
|
|
else
|
|
|
|
stream.WriteEncoded(false, 1);
|
|
|
|
}
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2017-07-31 05:19:05 +00:00
|
|
|
stream.WriteEncoded(x180_scanCompletionRate.first, CBitStreamWriter::GetBitCount(0x100));
|
|
|
|
stream.WriteEncoded(x180_scanCompletionRate.second, CBitStreamWriter::GetBitCount(0x100));
|
2016-03-28 08:54:02 +00:00
|
|
|
}
|
2015-08-20 02:52:07 +00:00
|
|
|
|
2017-09-10 00:36:21 +00:00
|
|
|
static const u32 costs[] =
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
2016-04-15 03:26:01 +00:00
|
|
|
5, 10, 10, 10, 1
|
|
|
|
};
|
2016-03-23 20:38:01 +00:00
|
|
|
|
2016-04-15 03:26:01 +00:00
|
|
|
u32 CPlayerState::GetMissileCostForAltAttack() const
|
|
|
|
{
|
2016-03-28 08:54:02 +00:00
|
|
|
return costs[u32(x8_currentBeam)];
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
|
2017-09-10 00:36:21 +00:00
|
|
|
static const float ComboAmmoPeriods[] =
|
|
|
|
{
|
|
|
|
0.2f, 0.1f, 0.2f, 0.2f, 1.f
|
|
|
|
};
|
|
|
|
|
|
|
|
float CPlayerState::GetComboFireAmmoPeriod() const
|
|
|
|
{
|
|
|
|
return ComboAmmoPeriods[u32(x8_currentBeam)];
|
|
|
|
}
|
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
u32 CPlayerState::CalculateItemCollectionRate() const
|
|
|
|
{
|
|
|
|
u32 total = GetItemCapacity(EItemType::PowerBombs);
|
|
|
|
|
|
|
|
if (total >= 4)
|
|
|
|
total -= 3;
|
|
|
|
total += GetItemCapacity(EItemType::WaveBeam);
|
|
|
|
total += GetItemCapacity(EItemType::IceBeam);
|
|
|
|
total += GetItemCapacity(EItemType::PlasmaBeam);
|
|
|
|
total += GetItemCapacity(EItemType::Missiles) / 5;
|
|
|
|
total += GetItemCapacity(EItemType::MorphBallBombs);
|
|
|
|
total += GetItemCapacity(EItemType::Flamethrower);
|
|
|
|
total += GetItemCapacity(EItemType::ThermalVisor);
|
|
|
|
total += GetItemCapacity(EItemType::ChargeBeam);
|
|
|
|
total += GetItemCapacity(EItemType::SuperMissile);
|
|
|
|
total += GetItemCapacity(EItemType::GrappleBeam);
|
|
|
|
total += GetItemCapacity(EItemType::XRayVisor);
|
|
|
|
total += GetItemCapacity(EItemType::IceSpreader);
|
|
|
|
total += GetItemCapacity(EItemType::SpaceJumpBoots);
|
|
|
|
total += GetItemCapacity(EItemType::MorphBall);
|
|
|
|
total += GetItemCapacity(EItemType::BoostBall);
|
|
|
|
total += GetItemCapacity(EItemType::SpiderBall);
|
|
|
|
total += GetItemCapacity(EItemType::GravitySuit);
|
|
|
|
total += GetItemCapacity(EItemType::VariaSuit);
|
|
|
|
total += GetItemCapacity(EItemType::EnergyTanks);
|
2017-09-12 15:27:48 +00:00
|
|
|
total += GetItemCapacity(EItemType::Truth);
|
|
|
|
total += GetItemCapacity(EItemType::Strength);
|
|
|
|
total += GetItemCapacity(EItemType::Elder);
|
|
|
|
total += GetItemCapacity(EItemType::Wild);
|
|
|
|
total += GetItemCapacity(EItemType::Lifegiver);
|
|
|
|
total += GetItemCapacity(EItemType::Warrior);
|
|
|
|
total += GetItemCapacity(EItemType::Chozo);
|
|
|
|
total += GetItemCapacity(EItemType::Nature);
|
|
|
|
total += GetItemCapacity(EItemType::Sun);
|
|
|
|
total += GetItemCapacity(EItemType::World);
|
|
|
|
total += GetItemCapacity(EItemType::Spirit);
|
|
|
|
total += GetItemCapacity(EItemType::Newborn);
|
2016-03-23 20:38:01 +00:00
|
|
|
return total + GetItemCapacity(EItemType::Wavebuster);
|
|
|
|
}
|
|
|
|
|
2016-06-30 19:33:38 +00:00
|
|
|
CHealthInfo& CPlayerState::HealthInfo()
|
|
|
|
{
|
|
|
|
return xc_health;
|
|
|
|
}
|
|
|
|
|
2017-01-15 03:59:37 +00:00
|
|
|
const CHealthInfo& CPlayerState::GetHealthInfo() const
|
2016-06-30 19:33:38 +00:00
|
|
|
{
|
|
|
|
return xc_health;
|
|
|
|
}
|
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
CPlayerState::EPlayerSuit CPlayerState::GetCurrentSuit() const
|
|
|
|
{
|
2016-12-29 21:38:59 +00:00
|
|
|
if (IsFusionEnabled())
|
2016-03-23 20:38:01 +00:00
|
|
|
return EPlayerSuit::FusionPower;
|
|
|
|
|
|
|
|
return x20_currentSuit;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPlayerState::CanVisorSeeFog(const CStateManager& stateMgr) const
|
|
|
|
{
|
2017-02-09 07:37:00 +00:00
|
|
|
EPlayerVisor activeVisor = GetActiveVisor(stateMgr);
|
|
|
|
if (activeVisor == EPlayerVisor::Combat || activeVisor == EPlayerVisor::Scan)
|
2016-03-23 20:38:01 +00:00
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CPlayerState::EPlayerVisor CPlayerState::GetActiveVisor(const CStateManager& stateMgr) const
|
|
|
|
{
|
2017-02-08 06:48:43 +00:00
|
|
|
const CFirstPersonCamera* cam =
|
|
|
|
static_cast<const CFirstPersonCamera*>(
|
|
|
|
stateMgr.GetCameraManager()->GetCurrentCamera(stateMgr));
|
2016-09-15 07:26:35 +00:00
|
|
|
return (cam ? x14_currentVisor : EPlayerVisor::Combat);
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
|
2017-08-16 05:34:02 +00:00
|
|
|
void CPlayerState::UpdateStaticInterference(CStateManager& stateMgr, float dt)
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
|
|
|
x188_staticIntf.Update(stateMgr, dt);
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
void CPlayerState::SetScanTime(CAssetId res, float time)
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
2017-02-09 07:37:00 +00:00
|
|
|
auto it = std::find_if(x170_scanTimes.begin(), x170_scanTimes.end(), [&](const auto& test) -> bool{
|
|
|
|
return test.first == res;
|
|
|
|
});
|
2016-03-28 08:54:02 +00:00
|
|
|
|
2017-02-09 07:37:00 +00:00
|
|
|
if (it != x170_scanTimes.end())
|
|
|
|
it->second = time;
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
float CPlayerState::GetScanTime(CAssetId res) const
|
2017-02-09 07:37:00 +00:00
|
|
|
{
|
|
|
|
const auto it = std::find_if(x170_scanTimes.cbegin(), x170_scanTimes.cend(), [&](const auto& test) -> bool{
|
|
|
|
return test.first == res;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (it == x170_scanTimes.end())
|
|
|
|
return 0.f;
|
|
|
|
|
|
|
|
return it->second;
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CPlayerState::GetIsVisorTransitioning() const
|
|
|
|
{
|
2018-01-06 06:50:42 +00:00
|
|
|
return x14_currentVisor != x18_transitioningVisor || x1c_visorTransitionFactor < 0.2f;
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
float CPlayerState::GetVisorTransitionFactor() const
|
|
|
|
{
|
2018-01-06 06:50:42 +00:00
|
|
|
return x1c_visorTransitionFactor / 0.2f;
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::UpdateVisorTransition(float dt)
|
|
|
|
{
|
|
|
|
if (!GetIsVisorTransitioning())
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (x14_currentVisor == x18_transitioningVisor)
|
|
|
|
{
|
|
|
|
x1c_visorTransitionFactor += dt;
|
|
|
|
if (x1c_visorTransitionFactor > 0.2)
|
|
|
|
x1c_visorTransitionFactor = 0.2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
x1c_visorTransitionFactor -= dt;
|
|
|
|
if (x1c_visorTransitionFactor < 0.f)
|
|
|
|
{
|
|
|
|
x14_currentVisor = x18_transitioningVisor;
|
2018-01-06 06:50:42 +00:00
|
|
|
x1c_visorTransitionFactor = std::fabs(x1c_visorTransitionFactor);
|
|
|
|
if (x1c_visorTransitionFactor > 0.19999f)
|
|
|
|
x1c_visorTransitionFactor = 0.19999f;
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPlayerState::StartVisorTransition(CPlayerState::EPlayerVisor visor)
|
|
|
|
{
|
|
|
|
x18_transitioningVisor = visor;
|
|
|
|
return x14_currentVisor == x18_transitioningVisor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::ResetVisor()
|
|
|
|
{
|
|
|
|
x18_transitioningVisor = x14_currentVisor = EPlayerVisor::Combat;
|
|
|
|
x1c_visorTransitionFactor = 0.0f;
|
|
|
|
}
|
|
|
|
|
2017-08-25 06:18:09 +00:00
|
|
|
bool CPlayerState::ItemEnabled(CPlayerState::EItemType type) const
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
|
|
|
if (HasPowerUp(type))
|
2017-08-13 05:26:14 +00:00
|
|
|
return (x4_enabledItems & (1 << u32(type)));
|
2016-03-23 20:38:01 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-08-13 05:26:14 +00:00
|
|
|
void CPlayerState::EnableItem(CPlayerState::EItemType type)
|
|
|
|
{
|
|
|
|
if (HasPowerUp(type))
|
|
|
|
x4_enabledItems |= (1 << u32(type));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::DisableItem(CPlayerState::EItemType type)
|
|
|
|
{
|
|
|
|
if (HasPowerUp(type))
|
|
|
|
x4_enabledItems &= ~(1 << u32(type));
|
|
|
|
}
|
|
|
|
|
2017-08-25 06:18:09 +00:00
|
|
|
bool CPlayerState::HasPowerUp(CPlayerState::EItemType type) const
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
|
|
|
if (type < EItemType::Max)
|
|
|
|
return x24_powerups[u32(type)].x4_capacity != 0;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CPlayerState::GetItemCapacity(CPlayerState::EItemType type) const
|
|
|
|
{
|
|
|
|
if (type < EItemType::Max)
|
|
|
|
return x24_powerups[u32(type)].x4_capacity;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 CPlayerState::GetItemAmount(CPlayerState::EItemType type) const
|
|
|
|
{
|
2016-08-18 18:34:06 +00:00
|
|
|
if (type == EItemType::SpaceJumpBoots ||
|
|
|
|
type == EItemType::PowerBombs ||
|
|
|
|
type == EItemType::Flamethrower ||
|
|
|
|
type == EItemType::EnergyTanks ||
|
|
|
|
type == EItemType::Missiles ||
|
2017-09-12 15:27:48 +00:00
|
|
|
(type >= EItemType::Truth && type <= EItemType::Newborn))
|
2016-08-18 18:34:06 +00:00
|
|
|
{
|
2016-03-23 20:38:01 +00:00
|
|
|
return x24_powerups[u32(type)].x0_amount;
|
2016-08-18 18:34:06 +00:00
|
|
|
}
|
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::DecrPickup(CPlayerState::EItemType type, s32 amount)
|
|
|
|
{
|
|
|
|
if (type >= EItemType::Max)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ((type == EItemType::Missiles || type >= EItemType::PowerBombs) && type < EItemType::ThermalVisor)
|
|
|
|
x24_powerups[u32(type)].x0_amount -= amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::IncrPickup(EItemType type, s32 amount)
|
|
|
|
{
|
|
|
|
if (type >= EItemType::Max)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (amount < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case EItemType::Missiles:
|
|
|
|
case EItemType::PowerBombs:
|
|
|
|
case EItemType::ChargeBeam:
|
|
|
|
case EItemType::SpaceJumpBoots:
|
|
|
|
case EItemType::EnergyTanks:
|
2017-09-12 15:27:48 +00:00
|
|
|
case EItemType::Truth:
|
|
|
|
case EItemType::Strength:
|
|
|
|
case EItemType::Elder:
|
|
|
|
case EItemType::Wild:
|
|
|
|
case EItemType::Lifegiver:
|
|
|
|
case EItemType::Warrior:
|
|
|
|
case EItemType::Chozo:
|
|
|
|
case EItemType::Nature:
|
|
|
|
case EItemType::Sun:
|
|
|
|
case EItemType::World:
|
|
|
|
case EItemType::Spirit:
|
|
|
|
case EItemType::Newborn:
|
2016-03-23 20:38:01 +00:00
|
|
|
{
|
|
|
|
CPowerUp& pup = x24_powerups[u32(type)];
|
|
|
|
pup.x0_amount = std::min(pup.x0_amount + amount, pup.x4_capacity);
|
2018-01-06 06:50:42 +00:00
|
|
|
|
2016-03-23 20:38:01 +00:00
|
|
|
if (type == EItemType::EnergyTanks)
|
|
|
|
IncrPickup(EItemType::HealthRefill, 9999);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case EItemType::HealthRefill:
|
|
|
|
{
|
|
|
|
float health = CalculateHealth(amount);
|
2016-06-30 19:33:38 +00:00
|
|
|
xc_health.SetHP(std::min(health, xc_health.GetHP() + amount));
|
2016-03-23 20:38:01 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::ResetAndIncrPickUp(CPlayerState::EItemType type, s32 amount)
|
|
|
|
{
|
|
|
|
x24_powerups[u32(type)].x0_amount = 0;
|
|
|
|
IncrPickup(type, amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
float CPlayerState::CalculateHealth(u32 health)
|
|
|
|
{
|
|
|
|
return (GetBaseHealthCapacity() + (health * GetEnergyTankCapacity()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::InitializePowerUp(CPlayerState::EItemType type, u32 capacity)
|
|
|
|
{
|
|
|
|
if (type >= EItemType::Max)
|
|
|
|
return;
|
|
|
|
|
|
|
|
CPowerUp& pup = x24_powerups[(u32)type];
|
2017-12-19 03:05:50 +00:00
|
|
|
pup.x4_capacity = zeus::clamp(u32(0), pup.x4_capacity + capacity, PowerUpMaxValues[u32(type)]);
|
2016-03-23 20:38:01 +00:00
|
|
|
pup.x0_amount = std::min(pup.x0_amount, pup.x4_capacity);
|
|
|
|
if (type >= EItemType::PowerSuit && type <= EItemType::PhazonSuit)
|
|
|
|
{
|
|
|
|
if (HasPowerUp(EItemType::PhazonSuit))
|
|
|
|
x20_currentSuit = EPlayerSuit::Phazon;
|
|
|
|
else if (HasPowerUp(EItemType::GravitySuit))
|
|
|
|
x20_currentSuit = EPlayerSuit::Gravity;
|
|
|
|
else if (HasPowerUp(EItemType::VariaSuit))
|
|
|
|
x20_currentSuit = EPlayerSuit::Varia;
|
|
|
|
else
|
|
|
|
x20_currentSuit = EPlayerSuit::Power;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPlayerState::ReInitalizePowerUp(CPlayerState::EItemType type, u32 capacity)
|
|
|
|
{
|
|
|
|
x24_powerups[u32(type)].x4_capacity = 0;
|
|
|
|
InitializePowerUp(type, capacity);
|
2015-08-20 02:52:07 +00:00
|
|
|
}
|
|
|
|
|
2017-02-06 03:21:58 +00:00
|
|
|
void CPlayerState::InitializeScanTimes()
|
|
|
|
{
|
|
|
|
if (x170_scanTimes.size())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto& scanStates = g_MemoryCardSys->GetScanStates();
|
2018-04-05 06:58:11 +00:00
|
|
|
x170_scanTimes.reserve(scanStates.size());
|
2017-02-06 03:21:58 +00:00
|
|
|
for (const auto& state : scanStates)
|
|
|
|
x170_scanTimes.emplace_back(state.first, 0.f);
|
|
|
|
}
|
|
|
|
|
2015-08-17 22:05:00 +00:00
|
|
|
}
|