Initial PAL/JP/Trilogy imps, various cleanup

This commit is contained in:
Phillip Stephens 2020-04-15 22:26:14 -07:00
parent 3487ea92c7
commit 582d8a6999
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
20 changed files with 285 additions and 91 deletions

View File

@ -21,6 +21,9 @@ struct ITweakPlayerRes : ITweak {
ResId x18_minesBreakSecondTopIcon; ResId x18_minesBreakSecondTopIcon;
ResId x1c_minesBreakSecondBottomIcon; ResId x1c_minesBreakSecondBottomIcon;
ResId rs5_mapArrowUp;
ResId rs5_mapArrowDown;
/* N, U, UL, L, DL, D, DR, R, UR */ /* N, U, UL, L, DL, D, DR, R, UR */
std::array<ResId, 9> x24_lStick; std::array<ResId, 9> x24_lStick;
std::array<ResId, 9> x4c_cStick; std::array<ResId, 9> x4c_cStick;

View File

@ -30,6 +30,7 @@
#include "PATH.hpp" #include "PATH.hpp"
#include "DataSpec/DNACommon/Tweaks/TweakWriter.hpp" #include "DataSpec/DNACommon/Tweaks/TweakWriter.hpp"
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
#include "Tweaks/CTweakPlayerRes.hpp" #include "Tweaks/CTweakPlayerRes.hpp"
#include "Tweaks/CTweakGunRes.hpp" #include "Tweaks/CTweakGunRes.hpp"
#include "Tweaks/CTweakPlayer.hpp" #include "Tweaks/CTweakPlayer.hpp"
@ -237,8 +238,8 @@ void PAKBridge::addCMDLRigPairs(PAKRouter<PAKBridge>& pakRouter, CharacterAssoci
if (animResInfo.evntId.isValid()) { if (animResInfo.evntId.isValid()) {
PAK::Entry* evntEnt = (PAK::Entry*)m_pak.lookupEntry(animResInfo.evntId); PAK::Entry* evntEnt = (PAK::Entry*)m_pak.lookupEntry(animResInfo.evntId);
evntEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_evnt"), id, animResInfo.name); evntEnt->name = fmt::format(FMT_STRING("ANCS_{}_{}_evnt"), id, animResInfo.name);
charAssoc.m_cskrToCharacter[animResInfo.evntId] = charAssoc.m_cskrToCharacter[animResInfo.evntId] = std::make_pair(
std::make_pair(entry.id, fmt::format(FMT_STRING("{}_{}.evnt.yaml"), animResInfo.name, animResInfo.evntId)); entry.id, fmt::format(FMT_STRING("{}_{}.evnt.yaml"), animResInfo.name, animResInfo.evntId));
} }
} }
} else if (entry.type == FOURCC('MREA')) { } else if (entry.type == FOURCC('MREA')) {
@ -275,8 +276,8 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
hecl::ProjectPath mlvlDirPath = pakRouter.getWorking(&entry).getParentPath(); hecl::ProjectPath mlvlDirPath = pakRouter.getWorking(&entry).getParentPath();
if (mlvl.worldNameId.isValid()) if (mlvl.worldNameId.isValid())
pathOverrides[mlvl.worldNameId] = hecl::ProjectPath(mlvlDirPath, pathOverrides[mlvl.worldNameId] =
fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId)); hecl::ProjectPath(mlvlDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), mlvl.worldNameId));
for (const MLVL::Area& area : mlvl.areas) { for (const MLVL::Area& area : mlvl.areas) {
{ {
@ -292,8 +293,8 @@ void PAKBridge::addMAPATransforms(PAKRouter<PAKBridge>& pakRouter,
hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath(); hecl::ProjectPath areaDirPath = pakRouter.getWorking(area.areaMREAId).getParentPath();
if (area.areaNameId.isValid()) if (area.areaNameId.isValid())
pathOverrides[area.areaNameId] = hecl::ProjectPath(areaDirPath, pathOverrides[area.areaNameId] =
fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), area.areaNameId)); hecl::ProjectPath(areaDirPath, fmt::format(FMT_STRING(_SYS_STR("!name_{}.yaml")), area.areaNameId));
} }
if (mlvl.worldMap.isValid()) { if (mlvl.worldMap.isValid()) {
@ -383,8 +384,14 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const nod::Node& pakNode, con
std::string catalogueName; std::string catalogueName;
std::string name = pak.bestEntryName(pakNode, entry, catalogueName); std::string name = pak.bestEntryName(pakNode, entry, catalogueName);
if (!catalogueName.empty()) { if (!catalogueName.empty()) {
if (catalogueName == "PlayerRes"sv) if (catalogueName == "PlayerRes"sv) {
return {ExtractTweak<CTweakPlayerRes>, {_SYS_STR(".yaml")}}; if (isCurrentSpecWii() || getCurrentRegion() == ERegion::PAL || getCurrentRegion() == ERegion::NTSC_J) {
/* We need to use the new rep for these tweaks */
return {ExtractTweak<CTweakPlayerRes<true>>, {_SYS_STR(".yaml")}};
}
/* We need to use the old rep for these tweaks */
return {ExtractTweak<CTweakPlayerRes<false>>, {_SYS_STR(".yaml")}};
}
if (catalogueName == "GunRes"sv) if (catalogueName == "GunRes"sv)
return {ExtractTweak<CTweakGunRes>, {_SYS_STR(".yaml")}}; return {ExtractTweak<CTweakGunRes>, {_SYS_STR(".yaml")}};
if (catalogueName == "Player"sv) if (catalogueName == "Player"sv)
@ -395,8 +402,14 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const nod::Node& pakNode, con
return {ExtractTweak<CTweakSlideShow>, {_SYS_STR(".yaml")}}; return {ExtractTweak<CTweakSlideShow>, {_SYS_STR(".yaml")}};
if (catalogueName == "Game"sv) if (catalogueName == "Game"sv)
return {ExtractTweak<CTweakGame>, {_SYS_STR(".yaml")}}; return {ExtractTweak<CTweakGame>, {_SYS_STR(".yaml")}};
if (catalogueName == "Targeting"sv) if (catalogueName == "Targeting"sv) {
return {ExtractTweak<CTweakTargeting>, {_SYS_STR(".yaml")}}; if (isCurrentSpecWii() || getCurrentRegion() == ERegion::PAL || getCurrentRegion() == ERegion::NTSC_J) {
/* We need to use the new rep for these tweaks */
return {ExtractTweak<CTweakTargeting<true>>, {_SYS_STR(".yaml")}};
}
/* We need to use the old rep for these tweaks */
return {ExtractTweak<CTweakTargeting<false>>, {_SYS_STR(".yaml")}};
}
if (catalogueName == "Gui"sv) if (catalogueName == "Gui"sv)
return {ExtractTweak<CTweakGui>, {_SYS_STR(".yaml")}}; return {ExtractTweak<CTweakGui>, {_SYS_STR(".yaml")}};
if (catalogueName == "AutoMapper"sv) if (catalogueName == "AutoMapper"sv)

View File

@ -4,7 +4,8 @@
namespace DataSpec::DNAMP1 { namespace DataSpec::DNAMP1 {
struct CTweakPlayerRes final : ITweakPlayerRes { template <bool NewRep>
struct AT_SPECIALIZE_PARMS(true, false) CTweakPlayerRes final : ITweakPlayerRes {
AT_DECL_DNA_YAML AT_DECL_DNA_YAML
String<-1> m_saveStationIcon; String<-1> m_saveStationIcon;
@ -16,6 +17,9 @@ struct CTweakPlayerRes final : ITweakPlayerRes {
String<-1> m_minesBreakSecondTopIcon; String<-1> m_minesBreakSecondTopIcon;
String<-1> m_minesBreakSecondBottomIcon; String<-1> m_minesBreakSecondBottomIcon;
String<AT_DNA_COUNT(NewRep==true ? -1 : 0)> m_mapArrowDown;
String<AT_DNA_COUNT(NewRep==true ? -1 : 0)> m_mapArrowUp;
String<-1> m_lStickN; String<-1> m_lStickN;
String<-1> m_lStickU; String<-1> m_lStickU;
String<-1> m_lStickUL; String<-1> m_lStickUL;

View File

@ -3,7 +3,8 @@
#include "../../DNACommon/Tweaks/ITweakTargeting.hpp" #include "../../DNACommon/Tweaks/ITweakTargeting.hpp"
namespace DataSpec::DNAMP1 { namespace DataSpec::DNAMP1 {
struct CTweakTargeting final : public ITweakTargeting { template<bool NewRep>
struct AT_SPECIALIZE_PARMS(true, false) CTweakTargeting final : public ITweakTargeting {
AT_DECL_DNA_YAML AT_DECL_DNA_YAML
Value<atUint32> x4_targetRadiusMode; Value<atUint32> x4_targetRadiusMode;
Value<float> x8_currLockOnExitDuration; Value<float> x8_currLockOnExitDuration;
@ -132,6 +133,69 @@ struct CTweakTargeting final : public ITweakTargeting {
Value<float> x220_scanTargetClampMax; Value<float> x220_scanTargetClampMax;
Value<float> x224_angularLagSpeed; Value<float> x224_angularLagSpeed;
// RS5
Vector<float, AT_DNA_COUNT(NewRep == true ? 1 : 0)> x218_;
Vector<float, AT_DNA_COUNT(NewRep == true ? 1 : 0)> x21c_;
bool x224_ = true;
bool x225_ = false;
bool x226_ = true;
bool x227_ = true;
bool x22c_ = true;
bool x22d_ = false;
bool x22e_ = true;
bool x22f_ = true;
bool x234_ = true;
bool x235_ = false;
bool x236_ = true;
bool x237_ = true;
zeus::CVector3f x23c_ = zeus::skZero3f;
float x2c8_ = 0.25f;
float x2cc_ = 0.35f;
zeus::CColor x2d0_ = (zeus::Comp32)0xb6e6ffff;
float x2d4_ = 0.39215687f;
zeus::CColor x2d8_ = (zeus::Comp32)0xa82a00ff;
float x2dc_ = 0.78431374f;
zeus::CVector3f x2e0_ = zeus::CVector3f(0.f, 0.f, 0.46f);
float x2ec_ = 0.25f;
float x2f0_ = 0.25f;
float x2f4_ = 120.f;
float x2f8_ = 0.25f;
float x2fc_ = 3.5f;
float x300_ = 0.35f;
zeus::CColor x304_ = (zeus::Comp32)0xa82a00ff;
float x308_ = 0.78431374f;
zeus::CColor x30c_ = (zeus::Comp32)0x89d6ffff;
float x310_ = 0.5019608f;
float x314_ = 11.25f;
float x318_ = 0.25f;
float x31c_ = 0.125f;
zeus::CColor x320_ = (zeus::Comp32)0xffca28ff;
float x324_ = 0.78431374f;
zeus::CColor x328_ = (zeus::Comp32)0x89d6ffff;
float x32c_ = 0.19607843f;
float x330_ = 0.f;
float x334_ = 0.25f;
float x338_ = 3.f;
float x33c_ = 0.25f;
float x340_ = 0.25f;
float x344_ = 0.25f;
float x348_ = 0.25f;
float x34c_ = 45.f;
float x350_ = 0.5f;
float x354_ = 0.65f;
float x358_ = 1.5f;
float x35c_ = 0.18f;
float x360_ = 0.15f;
float x364_ = 0.25f;
zeus::CColor x368_ = (zeus::Comp32)0x56c1fb9f;
zeus::CColor x36c_ = (zeus::Comp32)0x49c3f6a0;
zeus::CColor x370_ = (zeus::Comp32)0x49c3f631;
zeus::CColor x374_ = (zeus::Comp32)0xff8930ff;
zeus::CColor x378_ = (zeus::Comp32)0xff2f28ff;
zeus::CColor x37c_ = (zeus::Comp32)0x93e9ffff;
zeus::CColor x380_ = (zeus::Comp32)0xff6b60ff;
CTweakTargeting() = default; CTweakTargeting() = default;
CTweakTargeting(athena::io::IStreamReader& r) { CTweakTargeting(athena::io::IStreamReader& r) {
this->read(r); this->read(r);

View File

@ -39,6 +39,12 @@ static const hecl::SystemChar* MomErr[] = {_SYS_STR("Your metroid is in another
constexpr uint32_t MomErrCount = std::extent<decltype(MomErr)>::value; constexpr uint32_t MomErrCount = std::extent<decltype(MomErr)>::value;
static ERegion g_CurRegion = ERegion::Invalid;
static bool g_CurSpecIsWii = false;
ERegion getCurrentRegion() { return g_CurRegion; }
bool isCurrentSpecWii() { return g_CurSpecIsWii; }
SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc) SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: hecl::Database::IDataSpec(specEntry) : hecl::Database::IDataSpec(specEntry)
, m_project(project) , m_project(project)
@ -94,6 +100,9 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
break; break;
} }
setCurRegion(m_region);
setCurSpecIsWii(m_isWii);
if (m_standalone) if (m_standalone)
return checkFromStandaloneDisc(*m_disc, *regstr, info.extractArgs, reps); return checkFromStandaloneDisc(*m_disc, *regstr, info.extractArgs, reps);
else else
@ -1223,4 +1232,11 @@ void SpecBase::WriteVersionInfo(hecl::Database::Project& project, const hecl::Pr
athena::io::FileWriter writer(versionPath.getAbsolutePath()); athena::io::FileWriter writer(versionPath.getAbsolutePath());
athena::io::ToYAMLStream(info, writer); athena::io::ToYAMLStream(info, writer);
} }
void SpecBase::setCurRegion(ERegion region) {
g_CurRegion = region;
}
void SpecBase::setCurSpecIsWii(bool isWii) {
g_CurSpecIsWii = isWii;
}
} // namespace DataSpec } // namespace DataSpec

View File

@ -12,7 +12,6 @@
#include "hecl/Blender/Token.hpp" #include "hecl/Blender/Token.hpp"
#include "Runtime/RetroTypes.hpp" #include "Runtime/RetroTypes.hpp"
namespace nod { namespace nod {
class DiscBase; class DiscBase;
class Node; class Node;
@ -26,6 +25,9 @@ class YAMLDocWriter;
namespace DataSpec { namespace DataSpec {
enum class ERegion; enum class ERegion;
enum class EGame; enum class EGame;
ERegion getCurrentRegion();
bool isCurrentSpecWii();
struct SpecBase : hecl::Database::IDataSpec { struct SpecBase : hecl::Database::IDataSpec {
/* HECL Adaptors */ /* HECL Adaptors */
void setThreadProject() override; void setThreadProject() override;
@ -181,8 +183,8 @@ protected:
bool m_backgroundRunning = false; bool m_backgroundRunning = false;
void readCatalog(const hecl::ProjectPath& catalogPath, athena::io::YAMLDocWriter& nameWriter); void readCatalog(const hecl::ProjectPath& catalogPath, athena::io::YAMLDocWriter& nameWriter);
void insertPathTag(athena::io::YAMLDocWriter& cacheWriter, const urde::SObjectTag& tag, void insertPathTag(athena::io::YAMLDocWriter& cacheWriter, const urde::SObjectTag& tag, const hecl::ProjectPath& path,
const hecl::ProjectPath& path, bool dump = true); bool dump = true);
bool addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDocWriter& cacheWriter); bool addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDocWriter& cacheWriter);
void backgroundIndexRecursiveProc(const hecl::ProjectPath& path, athena::io::YAMLDocWriter& cacheWriter, void backgroundIndexRecursiveProc(const hecl::ProjectPath& path, athena::io::YAMLDocWriter& cacheWriter,
athena::io::YAMLDocWriter& nameWriter, int level); athena::io::YAMLDocWriter& nameWriter, int level);
@ -206,6 +208,9 @@ protected:
std::string m_version; std::string m_version;
void WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath); void WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath);
static void setCurRegion(ERegion region);
static void setCurSpecIsWii(bool isWii);
}; };
bool IsPathAudioGroup(const hecl::ProjectPath& path); bool IsPathAudioGroup(const hecl::ProjectPath& path);

View File

@ -428,7 +428,9 @@ struct SpecMP1 : SpecBase {
return true; return true;
else if (classType == DNAFont::FONT<UniqueID32>::DNAType()) else if (classType == DNAFont::FONT<UniqueID32>::DNAType())
return true; return true;
else if (classType == DNAMP1::CTweakPlayerRes::DNAType()) else if (classType == DNAMP1::CTweakPlayerRes<true>::DNAType())
return true;
else if (classType == DNAMP1::CTweakPlayerRes<false>::DNAType())
return true; return true;
else if (classType == DNAMP1::CTweakGunRes::DNAType()) else if (classType == DNAMP1::CTweakGunRes::DNAType())
return true; return true;
@ -442,7 +444,9 @@ struct SpecMP1 : SpecBase {
return true; return true;
else if (classType == DNAMP1::CTweakAutoMapper::DNAType()) else if (classType == DNAMP1::CTweakAutoMapper::DNAType())
return true; return true;
else if (classType == DNAMP1::CTweakTargeting::DNAType()) else if (classType == DNAMP1::CTweakTargeting<true>::DNAType())
return true;
else if (classType == DNAMP1::CTweakTargeting<false>::DNAType())
return true; return true;
else if (classType == DNAMP1::CTweakGui::DNAType()) else if (classType == DNAMP1::CTweakGui::DNAType())
return true; return true;
@ -583,13 +587,15 @@ struct SpecMP1 : SpecBase {
} else if (className == DataSpec::DNAMP1::SCAN::DNAType()) { } else if (className == DataSpec::DNAMP1::SCAN::DNAType()) {
resTag.type = SBIG('SCAN'); resTag.type = SBIG('SCAN');
return true; return true;
} else if (className == DataSpec::DNAMP1::CTweakPlayerRes::DNAType() || } else if (className == DataSpec::DNAMP1::CTweakPlayerRes<true>::DNAType() ||
className == DataSpec::DNAMP1::CTweakPlayerRes<false>::DNAType() ||
className == DataSpec::DNAMP1::CTweakGunRes::DNAType() || className == DataSpec::DNAMP1::CTweakGunRes::DNAType() ||
className == DataSpec::DNAMP1::CTweakSlideShow::DNAType() || className == DataSpec::DNAMP1::CTweakSlideShow::DNAType() ||
className == DataSpec::DNAMP1::CTweakPlayer::DNAType() || className == DataSpec::DNAMP1::CTweakPlayer::DNAType() ||
className == DataSpec::DNAMP1::CTweakCameraBob::DNAType() || className == DataSpec::DNAMP1::CTweakCameraBob::DNAType() ||
className == DataSpec::DNAMP1::CTweakGame::DNAType() || className == DataSpec::DNAMP1::CTweakGame::DNAType() ||
className == DataSpec::DNAMP1::CTweakTargeting::DNAType() || className == DataSpec::DNAMP1::CTweakTargeting<true>::DNAType() ||
className == DataSpec::DNAMP1::CTweakTargeting<false>::DNAType() ||
className == DataSpec::DNAMP1::CTweakAutoMapper::DNAType() || className == DataSpec::DNAMP1::CTweakAutoMapper::DNAType() ||
className == DataSpec::DNAMP1::CTweakGui::DNAType() || className == DataSpec::DNAMP1::CTweakGui::DNAType() ||
className == DataSpec::DNAMP1::CTweakPlayerControl::DNAType() || className == DataSpec::DNAMP1::CTweakPlayerControl::DNAType() ||
@ -834,8 +840,12 @@ struct SpecMP1 : SpecBase {
DNAFont::FONT<UniqueID32> font; DNAFont::FONT<UniqueID32> font;
font.read(reader); font.read(reader);
DNAFont::WriteFONT(font, out); DNAFont::WriteFONT(font, out);
} else if (classStr == DNAMP1::CTweakPlayerRes::DNAType()) { } else if (classStr == DNAMP1::CTweakPlayerRes<true>::DNAType()) {
DNAMP1::CTweakPlayerRes playerRes; DNAMP1::CTweakPlayerRes<true> playerRes;
playerRes.read(reader);
WriteTweak(playerRes, out);
} else if (classStr == DNAMP1::CTweakPlayerRes<false>::DNAType()) {
DNAMP1::CTweakPlayerRes<false> playerRes;
playerRes.read(reader); playerRes.read(reader);
WriteTweak(playerRes, out); WriteTweak(playerRes, out);
} else if (classStr == DNAMP1::CTweakGunRes::DNAType()) { } else if (classStr == DNAMP1::CTweakGunRes::DNAType()) {
@ -862,8 +872,12 @@ struct SpecMP1 : SpecBase {
DNAMP1::CTweakAutoMapper autoMapper; DNAMP1::CTweakAutoMapper autoMapper;
autoMapper.read(reader); autoMapper.read(reader);
WriteTweak(autoMapper, out); WriteTweak(autoMapper, out);
} else if (classStr == DNAMP1::CTweakTargeting::DNAType()) { } else if (classStr == DNAMP1::CTweakTargeting<true>::DNAType()) {
DNAMP1::CTweakTargeting targeting; DNAMP1::CTweakTargeting<false> targeting;
targeting.read(reader);
WriteTweak(targeting, out);
} else if (classStr == DNAMP1::CTweakTargeting<false>::DNAType()) {
DNAMP1::CTweakTargeting<false> targeting;
targeting.read(reader); targeting.read(reader);
WriteTweak(targeting, out); WriteTweak(targeting, out);
} else if (classStr == DNAMP1::CTweakGui::DNAType()) { } else if (classStr == DNAMP1::CTweakGui::DNAType()) {

View File

@ -1428,11 +1428,14 @@ void CStateManager::InformListeners(const zeus::CVector3f& pos, EListenNoiseType
void CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, const CDamageVulnerability& vuln, void CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, const CDamageVulnerability& vuln,
const zeus::CVector3f& pos, float dampen) { const zeus::CVector3f& pos, float dampen) {
if (vuln.GetVulnerability(info.GetWeaponMode(), false) == EVulnerability::Deflect) if (vuln.GetVulnerability(info.GetWeaponMode(), false) == EVulnerability::Deflect) {
return; return;
}
CHealthInfo* hInfo = actor.HealthInfo(*this); CHealthInfo* hInfo = actor.HealthInfo(*this);
if (!hInfo) if (hInfo == nullptr) {
return; return;
}
float dampedPower = (1.f - dampen) * info.GetKnockBackPower(); float dampedPower = (1.f - dampen) * info.GetKnockBackPower();
if (TCastToPtr<CPlayer> player = actor) { if (TCastToPtr<CPlayer> player = actor) {
@ -1446,30 +1449,34 @@ void CStateManager::ApplyKnockBack(CActor& actor, const CDamageInfo& info, const
if (TCastToPtr<CPhysicsActor> physActor = actor) { if (TCastToPtr<CPhysicsActor> physActor = actor) {
zeus::CVector3f kbVec = pos * (dampedPower - hInfo->GetKnockbackResistance()) * physActor->GetMass() * 1.5f; zeus::CVector3f kbVec = pos * (dampedPower - hInfo->GetKnockbackResistance()) * physActor->GetMass() * 1.5f;
if (physActor->GetMaterialList().HasMaterial(EMaterialTypes::Immovable) || if (physActor->GetMaterialList().HasMaterial(EMaterialTypes::Immovable) ||
!physActor->GetMaterialList().HasMaterial(EMaterialTypes::Grass)) !physActor->GetMaterialList().HasMaterial(EMaterialTypes::Solid)) {
return; return;
}
physActor->ApplyImpulseWR(kbVec, zeus::CAxisAngle()); physActor->ApplyImpulseWR(kbVec, zeus::CAxisAngle());
return; return;
} }
} }
} }
if (ai) if (ai) {
ai->KnockBack(pos, *this, info, dampen == 0.f ? EKnockBackType::Direct : EKnockBackType::Radius, false, ai->KnockBack(pos, *this, info, dampen == 0.f ? EKnockBackType::Direct : EKnockBackType::Radius, false,
dampedPower); dampedPower);
} }
}
void CStateManager::KnockBackPlayer(CPlayer& player, const zeus::CVector3f& pos, float power, float resistance) { void CStateManager::KnockBackPlayer(CPlayer& player, const zeus::CVector3f& pos, float power, float resistance) {
if (player.GetMaterialList().HasMaterial(EMaterialTypes::Immovable)) if (player.GetMaterialList().HasMaterial(EMaterialTypes::Immovable)) {
return; return;
}
float usePower; float usePower;
if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) { if (player.GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed) {
usePower = power * 1000.f; usePower = power * 1000.f;
CPlayer::ESurfaceRestraints surface = CPlayer::ESurfaceRestraints surface =
player.x2b0_outOfWaterTicks == 2 ? player.x2ac_surfaceRestraint : CPlayer::ESurfaceRestraints::Water; player.x2b0_outOfWaterTicks == 2 ? player.x2ac_surfaceRestraint : CPlayer::ESurfaceRestraints::Water;
if (surface != CPlayer::ESurfaceRestraints::Normal && player.GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit) if (surface != CPlayer::ESurfaceRestraints::Normal && player.GetOrbitState() == CPlayer::EPlayerOrbitState::NoOrbit) {
usePower /= 7.f; usePower /= 7.f;
}
} else { } else {
usePower = power * 500.f; usePower = power * 500.f;
} }
@ -1496,15 +1503,17 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c
bool bomb = false; bool bomb = false;
TCastToConstPtr<CWeapon> weapon = actor; TCastToConstPtr<CWeapon> weapon = actor;
if (weapon) if (weapon) {
bomb = True(weapon->GetAttribField() & (EProjectileAttrib::Bombs | EProjectileAttrib::PowerBombs)); bomb = True(weapon->GetAttribField() & (EProjectileAttrib::Bombs | EProjectileAttrib::PowerBombs));
}
rstl::reserved_vector<TUniqueId, 1024> nearList; rstl::reserved_vector<TUniqueId, 1024> nearList;
BuildNearList(nearList, aabb, filter, &actor); BuildNearList(nearList, aabb, filter, &actor);
for (TUniqueId id : nearList) { for (TUniqueId id : nearList) {
CEntity* ent = ObjectById(id); CEntity* ent = ObjectById(id);
if (!ent) if (ent == nullptr) {
continue; continue;
}
TCastToPtr<CPlayer> player = ent; TCastToPtr<CPlayer> player = ent;
if (bomb && player) { if (bomb && player) {
@ -1513,22 +1522,26 @@ void CStateManager::ApplyDamageToWorld(TUniqueId damager, const CActor& actor, c
MP1::CSamusHud::DisplayHudMemo(u"", CHUDMemoParms{0.f, true, true, true}); MP1::CSamusHud::DisplayHudMemo(u"", CHUDMemoParms{0.f, true, true, true});
player->UnFreeze(*this); player->UnFreeze(*this);
} else { } else {
if ((weapon->GetAttribField() & EProjectileAttrib::Bombs) == EProjectileAttrib::Bombs) if ((weapon->GetAttribField() & EProjectileAttrib::Bombs) == EProjectileAttrib::Bombs) {
player->BombJump(pos, *this); player->BombJump(pos, *this);
} }
}
} else if (ent->GetUniqueId() != damager) { } else if (ent->GetUniqueId() != damager) {
TestBombHittingWater(actor, pos, static_cast<CActor&>(*ent)); TestBombHittingWater(actor, pos, static_cast<CActor&>(*ent));
if (TestRayDamage(pos, static_cast<CActor&>(*ent), nearList)) if (TestRayDamage(pos, static_cast<CActor&>(*ent), nearList)) {
ApplyRadiusDamage(actor, pos, static_cast<CActor&>(*ent), info); ApplyRadiusDamage(actor, pos, static_cast<CActor&>(*ent), info);
} }
}
if (TCastToPtr<CWallCrawlerSwarm> swarm = ent) if (TCastToPtr<CWallCrawlerSwarm> swarm = ent) {
swarm->ApplyRadiusDamage(pos, info, *this); swarm->ApplyRadiusDamage(pos, info, *this);
}
if (TCastToPtr<CSnakeWeedSwarm> swarm = ent) if (TCastToPtr<CSnakeWeedSwarm> swarm = ent) {
swarm->ApplyRadiusDamage(pos, info, *this); swarm->ApplyRadiusDamage(pos, info, *this);
} }
} }
}
void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee, TUniqueId senderId, void CStateManager::ProcessRadiusDamage(const CActor& damager, CActor& damagee, TUniqueId senderId,
const CDamageInfo& info, const CMaterialFilter& filter) { const CDamageInfo& info, const CMaterialFilter& filter) {
@ -1555,28 +1568,29 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
((bounds = a2.GetTouchBounds()) && ((bounds = a2.GetTouchBounds()) &&
CCollidableSphere::Sphere_AABox_Bool(zeus::CSphere{pos, info.GetRadius()}, *bounds))) { CCollidableSphere::Sphere_AABox_Bool(zeus::CSphere{pos, info.GetRadius()}, *bounds))) {
float rad = info.GetRadius(); float rad = info.GetRadius();
if (rad > FLT_EPSILON) if (rad > FLT_EPSILON) {
rad = delta.magnitude() / rad; rad = delta.magnitude() / rad;
else } else {
rad = 0.f; rad = 0.f;
if (rad > 0.f) }
if (rad > 0.f) {
delta.normalize(); delta.normalize();
}
bool alive = false; bool alive = false;
if (CHealthInfo* hInfo = a2.HealthInfo(*this)) if (CHealthInfo* hInfo = a2.HealthInfo(*this)) {
if (hInfo->GetHP() > 0.f) if (hInfo->GetHP() > 0.f) {
alive = true; alive = true;
}
}
const CDamageVulnerability* vuln; const CDamageVulnerability* vuln = rad > 0.f ? a2.GetDamageVulnerability(pos, delta, info) : a2.GetDamageVulnerability();
if (rad > 0.f)
vuln = a2.GetDamageVulnerability(pos, delta, info);
else
vuln = a2.GetDamageVulnerability();
if (vuln->WeaponHurts(info.GetWeaponMode(), true)) { if (vuln->WeaponHurts(info.GetWeaponMode(), true)) {
float dam = info.GetRadiusDamage(*vuln); float dam = info.GetRadiusDamage(*vuln);
if (dam > 0.f) if (dam > 0.f) {
ApplyLocalDamage(pos, delta, a2, dam, info.GetWeaponMode()); ApplyLocalDamage(pos, delta, a2, dam, info.GetWeaponMode());
}
a2.SendScriptMsgs(EScriptObjectState::Damage, *this, EScriptObjectMessage::None); a2.SendScriptMsgs(EScriptObjectState::Damage, *this, EScriptObjectMessage::None);
SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::Damage); SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::Damage);
} else { } else {
@ -1584,10 +1598,11 @@ void CStateManager::ApplyRadiusDamage(const CActor& a1, const zeus::CVector3f& p
SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::InvulnDamage); SendScriptMsg(&a2, a1.GetUniqueId(), EScriptObjectMessage::InvulnDamage);
} }
if (alive && info.GetKnockBackPower() > 0.f) if (alive && info.GetKnockBackPower() > 0.f) {
ApplyKnockBack(a2, info, *vuln, (a2.GetTranslation() - a1.GetTranslation()).normalized(), rad); ApplyKnockBack(a2, info, *vuln, (a2.GetTranslation() - a1.GetTranslation()).normalized(), rad);
} }
} }
}
bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& damagee, bool CStateManager::TestRayDamage(const zeus::CVector3f& pos, const CActor& damagee,
const rstl::reserved_vector<TUniqueId, 1024>& nearList) const { const rstl::reserved_vector<TUniqueId, 1024>& nearList) const {

View File

@ -57,11 +57,9 @@ extern class CStateManager* g_StateManager;
#if USE_DOWNCAST_TWEAKS #if USE_DOWNCAST_TWEAKS
using ITweakGame = DataSpec::DNAMP1::CTweakGame; using ITweakGame = DataSpec::DNAMP1::CTweakGame;
using ITweakPlayer = DataSpec::DNAMP1::CTweakPlayer; using ITweakPlayer = DataSpec::DNAMP1::CTweakPlayer;
using ITweakPlayerRes = DataSpec::DNAMP1::CTweakPlayerRes;
using ITweakPlayerControl = DataSpec::DNAMP1::CTweakPlayerControl; using ITweakPlayerControl = DataSpec::DNAMP1::CTweakPlayerControl;
using ITweakPlayerGun = DataSpec::DNAMP1::CTweakPlayerGun; using ITweakPlayerGun = DataSpec::DNAMP1::CTweakPlayerGun;
using ITweakGunRes = DataSpec::DNAMP1::CTweakGunRes; using ITweakGunRes = DataSpec::DNAMP1::CTweakGunRes;
using ITweakTargeting = DataSpec::DNAMP1::CTweakTargeting;
using ITweakAutoMapper = DataSpec::DNAMP1::CTweakAutoMapper; using ITweakAutoMapper = DataSpec::DNAMP1::CTweakAutoMapper;
using ITweakGui = DataSpec::DNAMP1::CTweakGui; using ITweakGui = DataSpec::DNAMP1::CTweakGui;
using ITweakSlideShow = DataSpec::DNAMP1::CTweakSlideShow; using ITweakSlideShow = DataSpec::DNAMP1::CTweakSlideShow;
@ -71,11 +69,9 @@ using ITweakGuiColors = DataSpec::DNAMP1::CTweakGuiColors;
#else #else
using ITweakGame = DataSpec::ITweakGame; using ITweakGame = DataSpec::ITweakGame;
using ITweakPlayer = DataSpec::ITweakPlayer; using ITweakPlayer = DataSpec::ITweakPlayer;
using ITweakPlayerRes = DataSpec::ITweakPlayerRes;
using ITweakPlayerControl = DataSpec::ITweakPlayerControl; using ITweakPlayerControl = DataSpec::ITweakPlayerControl;
using ITweakPlayerGun = DataSpec::ITweakPlayerGun; using ITweakPlayerGun = DataSpec::ITweakPlayerGun;
using ITweakGunRes = DataSpec::ITweakGunRes; using ITweakGunRes = DataSpec::ITweakGunRes;
using ITweakTargeting = DataSpec::ITweakTargeting;
using ITweakAutoMapper = DataSpec::ITweakAutoMapper; using ITweakAutoMapper = DataSpec::ITweakAutoMapper;
using ITweakGui = DataSpec::ITweakGui; using ITweakGui = DataSpec::ITweakGui;
using ITweakSlideShow = DataSpec::ITweakSlideShow; using ITweakSlideShow = DataSpec::ITweakSlideShow;
@ -83,6 +79,8 @@ using ITweakParticle = DataSpec::ITweakParticle;
using ITweakBall = DataSpec::ITweakBall; using ITweakBall = DataSpec::ITweakBall;
using ITweakGuiColors = DataSpec::ITweakGuiColors; using ITweakGuiColors = DataSpec::ITweakGuiColors;
#endif #endif
using ITweakPlayerRes = DataSpec::ITweakPlayerRes;
using ITweakTargeting = DataSpec::ITweakTargeting;
extern ITweakGame* g_tweakGame; extern ITweakGame* g_tweakGame;
extern ITweakPlayer* g_tweakPlayer; extern ITweakPlayer* g_tweakPlayer;

View File

@ -6,6 +6,7 @@
#include <boo/boo.hpp> #include <boo/boo.hpp>
#include <boo/audiodev/IAudioVoiceEngine.hpp> #include <boo/audiodev/IAudioVoiceEngine.hpp>
#include <hecl/Runtime.hpp> #include <hecl/Runtime.hpp>
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
namespace hecl { namespace hecl {
class Console; class Console;
@ -13,6 +14,9 @@ class CVarManager;
} // namespace hecl } // namespace hecl
namespace urde { namespace urde {
using ERegion = DataSpec::ERegion;
using EGame = DataSpec::EGame;
class CStopwatch; class CStopwatch;
enum class EGameplayResult { None, Win, Lose, Playing }; enum class EGameplayResult { None, Win, Lose, Playing };
@ -40,5 +44,12 @@ public:
virtual size_t GetExpectedIdSize() const = 0; virtual size_t GetExpectedIdSize() const = 0;
virtual void WarmupShaders() = 0; virtual void WarmupShaders() = 0;
virtual hecl::Console* Console() const = 0; virtual hecl::Console* Console() const = 0;
virtual EGame GetGame() const =0;
virtual ERegion GetRegion() const =0;
virtual bool IsPAL() const = 0;
virtual bool IsJapanese() const = 0;
virtual bool IsUSA() const = 0;
virtual bool IsTrilogy() const = 0;
virtual std::string_view GetVersionString() const=0;
}; };
} // namespace urde } // namespace urde

View File

@ -63,8 +63,13 @@ void CTweaks::RegisterTweaks(hecl::CVarManager* cvarMgr) {
/* Targeting */ /* Targeting */
tag = g_ResFactory->GetResourceIdByName("Targeting"); tag = g_ResFactory->GetResourceIdByName("Targeting");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true); strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakTargeting = new DataSpec::DNAMP1::CTweakTargeting(*strm); if (g_Main->IsTrilogy() || g_Main->IsPAL() || g_Main->IsJapanese()) {
g_tweakTargeting = new DataSpec::DNAMP1::CTweakTargeting<true>(*strm);
g_tweakTargeting->initCVars(cvarMgr); g_tweakTargeting->initCVars(cvarMgr);
} else {
g_tweakTargeting = new DataSpec::DNAMP1::CTweakTargeting<false>(*strm);
g_tweakTargeting->initCVars(cvarMgr);
}
/* Game */ /* Game */
tag = g_ResFactory->GetResourceIdByName("Game"); tag = g_ResFactory->GetResourceIdByName("Game");
@ -121,7 +126,12 @@ void CTweaks::RegisterResourceTweaks(hecl::CVarManager* cvarMgr) {
tag = g_ResFactory->GetResourceIdByName("PlayerRes"); tag = g_ResFactory->GetResourceIdByName("PlayerRes");
strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true); strm.emplace(g_ResFactory->LoadResourceSync(*tag).release(), g_ResFactory->ResourceSize(*tag), true);
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes(*strm); if (g_Main->IsTrilogy() || g_Main->IsPAL() || g_Main->IsJapanese()) {
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes<true>(*strm);
} else {
g_tweakPlayerRes = new DataSpec::DNAMP1::CTweakPlayerRes<false>(*strm);
}
g_tweakPlayerRes->ResolveResources(*g_ResFactory); g_tweakPlayerRes->ResolveResources(*g_ResFactory);
g_tweakPlayerRes->initCVars(cvarMgr); g_tweakPlayerRes->initCVars(cvarMgr);
} }

View File

@ -37,7 +37,6 @@
#include "Runtime/GuiSys/CTextExecuteBuffer.hpp" #include "Runtime/GuiSys/CTextExecuteBuffer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakPlayer.hpp"
#include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp" #include "DataSpec/DNAMP1/Tweaks/CTweakGame.hpp"
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
#include "hecl/Console.hpp" #include "hecl/Console.hpp"
#include "hecl/CVarCommons.hpp" #include "hecl/CVarCommons.hpp"
@ -49,8 +48,6 @@ class IObjectStore;
namespace MP1 { namespace MP1 {
class CMain; class CMain;
using ERegion = DataSpec::ERegion;
using EGame = DataSpec::EGame;
class CGameGlobalObjects { class CGameGlobalObjects {
friend class CMain; friend class CMain;
@ -315,13 +312,13 @@ public:
void ListWorlds(hecl::Console*, const std::vector<std::string>&); void ListWorlds(hecl::Console*, const std::vector<std::string>&);
void Warp(hecl::Console*, const std::vector<std::string>&); void Warp(hecl::Console*, const std::vector<std::string>&);
hecl::Console* Console() const override { return m_console.get(); } hecl::Console* Console() const override { return m_console.get(); }
bool IsPAL() const { return m_version.region == ERegion::PAL; } bool IsPAL() const override { return m_version.region == ERegion::PAL; }
bool IsJapanese() const { return m_version.region == ERegion::NTSC_J; } bool IsJapanese() const override { return m_version.region == ERegion::NTSC_J; }
bool IsUSA() const { return m_version.region == ERegion::NTSC_U; } bool IsUSA() const override { return m_version.region == ERegion::NTSC_U; }
bool IsTrilogy() const { return m_version.isTrilogy; } bool IsTrilogy() const override { return m_version.isTrilogy; }
ERegion GetRegion() const { return m_version.region; } ERegion GetRegion() const override { return m_version.region; }
EGame GetGame() const { return m_version.game; } EGame GetGame() const override { return m_version.game; }
std::string_view GetVersionString() const { return m_version.version; } std::string_view GetVersionString() const override{ return m_version.version; }
int m_warpWorldIdx = -1; int m_warpWorldIdx = -1;
TAreaId m_warpAreaId = 0; TAreaId m_warpAreaId = 0;

View File

@ -149,6 +149,15 @@ bool CProjectileWeaponDataFactory::CreateWPSM(CWeaponDescription* desc, CInputSt
case SBIG('FOFF'): case SBIG('FOFF'):
desc->xb0_FOFF = CPF::GetRealElement(in); desc->xb0_FOFF = CPF::GetRealElement(in);
break; break;
case SBIG('SPS1'):
desc->x28_SPS1 = CPF::GetBool(in);
break;
case SBIG('SPS2'):
desc->x29_SPS2 = CPF::GetBool(in);
break;
case SBIG('FC60'):
desc->x29_FC60 = CPF::GetBool(in);
break;
default: { default: {
Log.report(logvisor::Fatal, FMT_STRING("Unknown WPSM class {} @{}"), clsId, in.position()); Log.report(logvisor::Fatal, FMT_STRING("Unknown WPSM class {} @{}"), clsId, in.position());
return false; return false;

View File

@ -54,5 +54,9 @@ public:
s32 xa8_PJFX = -1; s32 xa8_PJFX = -1;
std::unique_ptr<CRealElement> xac_RNGE; std::unique_ptr<CRealElement> xac_RNGE;
std::unique_ptr<CRealElement> xb0_FOFF; std::unique_ptr<CRealElement> xb0_FOFF;
// PAL/RS5
bool x28_SPS1 = false;
bool x29_SPS2 = false;
bool x29_FC60 = false;
}; };
} // namespace urde } // namespace urde

View File

@ -36,10 +36,12 @@ float CDamageInfo::GetDamage(const CDamageVulnerability& dVuln) const {
float CDamageInfo::GetRadiusDamage(const CDamageVulnerability& dVuln) const { float CDamageInfo::GetRadiusDamage(const CDamageVulnerability& dVuln) const {
EVulnerability vuln = dVuln.GetVulnerability(x0_weaponMode, false); EVulnerability vuln = dVuln.GetVulnerability(x0_weaponMode, false);
if (vuln == EVulnerability::Deflect) if (vuln == EVulnerability::Deflect) {
return 0.f; return 0.f;
else if (vuln == EVulnerability::Weak) }
if (vuln == EVulnerability::Weak) {
return 2.f * xc_radiusDamage; return 2.f * xc_radiusDamage;
}
return xc_radiusDamage; return xc_radiusDamage;
} }

View File

@ -240,36 +240,44 @@ bool CDamageVulnerability::WeaponHits(const CWeaponMode& mode, bool checkDirect)
} }
EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, bool ignoreDirect) const { EVulnerability CDamageVulnerability::GetVulnerability(const CWeaponMode& mode, bool ignoreDirect) const {
if (mode.GetType() == EWeaponType::None || mode.GetType() > EWeaponType::OrangePhazon) if (mode.GetType() == EWeaponType::None || mode.GetType() > EWeaponType::OrangePhazon) {
return EVulnerability::Deflect; return EVulnerability::Deflect;
}
if (mode.IsInstantKill()) if (mode.IsInstantKill()) {
return EVulnerability::Normal; return EVulnerability::Normal;
}
EVulnerability vuln = (&x0_power)[u32(mode.GetType())]; EVulnerability vuln = (&x0_power)[u32(mode.GetType())];
if (mode.IsCharged()) { if (mode.IsCharged()) {
if (mode.GetType() < EWeaponType::Bomb) if (mode.GetType() < EWeaponType::Bomb) {
vuln = (&x3c_chargedPower)[u32(mode.GetType())]; vuln = (&x3c_chargedPower)[u32(mode.GetType())];
else } else {
vuln = EVulnerability::Normal; vuln = EVulnerability::Normal;
} }
}
if (mode.IsComboed()) { if (mode.IsComboed()) {
if (mode.GetType() < EWeaponType::Bomb) if (mode.GetType() < EWeaponType::Bomb) {
vuln = (&x3c_chargedPower)[u32(mode.GetType())]; vuln = (&x3c_chargedPower)[u32(mode.GetType())];
else } else {
vuln = EVulnerability::Normal; vuln = EVulnerability::Normal;
} }
}
if (ignoreDirect) if (ignoreDirect) {
return vuln; return vuln;
}
if (vuln == EVulnerability::DirectWeak) if (vuln == EVulnerability::DirectWeak) {
return EVulnerability::Weak; return EVulnerability::Weak;
else if (vuln == EVulnerability::DirectNormal) }
if (vuln == EVulnerability::DirectNormal) {
return EVulnerability::Normal; return EVulnerability::Normal;
else if (vuln == EVulnerability::DirectImmune) }
if (vuln == EVulnerability::DirectImmune) {
return EVulnerability::Immune; return EVulnerability::Immune;
}
return vuln; return vuln;
} }

View File

@ -483,8 +483,9 @@ void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec,
switch (x4_activeParms.x0_animState) { switch (x4_activeParms.x0_animState) {
case EKnockBackAnimationState::Hurled: { case EKnockBackAnimationState::Hurled: {
float hurlVel = 5.f; float hurlVel = 5.f;
if (CHealthInfo* hInfo = parent.HealthInfo(mgr)) if (CHealthInfo* hInfo = parent.HealthInfo(mgr)) {
hurlVel += CalculateExtraHurlVelocity(mgr, magnitude, hInfo->GetKnockbackResistance()); hurlVel += CalculateExtraHurlVelocity(mgr, magnitude, hInfo->GetKnockbackResistance());
}
hurlVel = std::sqrt(parent.GetGravityConstant() * 0.5f * hurlVel); hurlVel = std::sqrt(parent.GetGravityConstant() * 0.5f * hurlVel);
zeus::CVector3f backUpVec = backVec + backVec.magnitude() * zeus::skUp; zeus::CVector3f backUpVec = backVec + backVec.magnitude() * zeus::skUp;
if (backUpVec.canBeNormalized()) { if (backUpVec.canBeNormalized()) {
@ -520,10 +521,11 @@ void CKnockBackController::ResetKnockBackImpulse(CPatterned& parent, const zeus:
if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack && if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack &&
x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) { x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) {
x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1]; x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1];
if (x60_impulseRemTime <= 0.f) if (x60_impulseRemTime <= 0.f) {
x5c_impulseMag = magnitude; x5c_impulseMag = magnitude;
else } else {
x5c_impulseMag += magnitude * (1.f - x60_impulseRemTime / ImpulseDurationTable[x20_impulseDurationIdx]); x5c_impulseMag += magnitude * (1.f - x60_impulseRemTime / ImpulseDurationTable[x20_impulseDurationIdx]);
}
x60_impulseRemTime = ImpulseDurationTable[x20_impulseDurationIdx]; x60_impulseRemTime = ImpulseDurationTable[x20_impulseDurationIdx];
} }
} }
@ -565,21 +567,25 @@ void CKnockBackController::SetAutoResetImpulse(bool b) {
void CKnockBackController::Update(float dt, CStateManager& mgr, CPatterned& parent) { void CKnockBackController::Update(float dt, CStateManager& mgr, CPatterned& parent) {
ApplyImpulse(dt, parent); ApplyImpulse(dt, parent);
x64_flinchRemTime -= dt; x64_flinchRemTime -= dt;
if (TickDeferredTimer(dt)) if (TickDeferredTimer(dt)) {
DoDeferredKnockBack(mgr, parent); DoDeferredKnockBack(mgr, parent);
if (x82_26_locomotionDuringElectrocution && parent.GetBodyController()->IsElectrocuting()) }
if (x82_26_locomotionDuringElectrocution && parent.GetBodyController()->IsElectrocuting()) {
parent.GetBodyController()->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::Locomotion)); parent.GetBodyController()->GetCommandMgr().DeliverCmd(CBodyStateCmd(EBodyStateCmd::Locomotion));
} }
}
EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageInfo& info, EWeaponType wType, EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageInfo& info, EWeaponType wType,
EKnockBackType type) { EKnockBackType type) {
int stacking = 0; int stacking = 0;
if (info.GetWeaponMode().IsCharged()) if (info.GetWeaponMode().IsCharged()) {
stacking = 1; stacking = 1;
else if (info.GetWeaponMode().IsComboed()) } else if (info.GetWeaponMode().IsComboed()) {
stacking = 2; stacking = 2;
if (wType > EWeaponType::Phazon) }
if (wType > EWeaponType::Phazon) {
return EKnockBackWeaponType::Invalid; return EKnockBackWeaponType::Invalid;
}
switch (wType) { switch (wType) {
case EWeaponType::Power: case EWeaponType::Power:
return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking : stacking + 1); return EKnockBackWeaponType(type != EKnockBackType::Direct ? stacking : stacking + 1);
@ -604,6 +610,8 @@ EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageI
void CKnockBackController::SelectDamageState(CPatterned& parent, const CDamageInfo& info, EWeaponType wType, void CKnockBackController::SelectDamageState(CPatterned& parent, const CDamageInfo& info, EWeaponType wType,
EKnockBackType type) { EKnockBackType type) {
x4_activeParms = KnockBackParms();
EKnockBackWeaponType weaponType = GetKnockBackWeaponType(info, wType, type); EKnockBackWeaponType weaponType = GetKnockBackWeaponType(info, wType, type);
if (weaponType != EKnockBackWeaponType::Invalid) { if (weaponType != EKnockBackWeaponType::Invalid) {
x4_activeParms = x4_activeParms =
@ -616,8 +624,9 @@ void CKnockBackController::KnockBack(const zeus::CVector3f& backVec, CStateManag
const CDamageInfo& info, EKnockBackType type, float magnitude) { const CDamageInfo& info, EKnockBackType type, float magnitude) {
if (!x82_25_inDeferredKnockBack) { if (!x82_25_inDeferredKnockBack) {
zeus::CVector3f vec(backVec.toVec2f()); zeus::CVector3f vec(backVec.toVec2f());
if (!vec.isMagnitudeSafe()) if (!vec.isMagnitudeSafe()) {
vec = -parent.GetTransform().basis[1]; vec = -parent.GetTransform().basis[1];
}
SelectDamageState(parent, info, info.GetWeaponMode().GetType(), type); SelectDamageState(parent, info, info.GetWeaponMode().GetType(), type);
DoKnockBackAnimation(vec, mgr, parent, magnitude); DoKnockBackAnimation(vec, mgr, parent, magnitude);
ResetKnockBackImpulse(parent, vec, 2.f); ResetKnockBackImpulse(parent, vec, 2.f);

View File

@ -497,10 +497,11 @@ void CPatterned::Death(CStateManager& mgr, const zeus::CVector3f& dir, EScriptOb
void CPatterned::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, const CDamageInfo& info, void CPatterned::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, const CDamageInfo& info,
EKnockBackType type, bool inDeferred, float magnitude) { EKnockBackType type, bool inDeferred, float magnitude) {
CHealthInfo* hInfo = HealthInfo(mgr); CHealthInfo* hInfo = HealthInfo(mgr);
if (!x401_27_phazingOut && !x401_28_burning && hInfo) { if (!x401_27_phazingOut && !x401_28_burning && hInfo != nullptr) {
x460_knockBackController.KnockBack(backVec, mgr, *this, info, type, magnitude); x460_knockBackController.KnockBack(backVec, mgr, *this, info, type, magnitude);
if (x450_bodyController->IsFrozen() && x460_knockBackController.GetActiveParms().xc_intoFreezeDur >= 0.f) if (x450_bodyController->IsFrozen() && x460_knockBackController.GetActiveParms().xc_intoFreezeDur >= 0.f) {
x450_bodyController->FrozenBreakout(); x450_bodyController->FrozenBreakout();
}
switch (x460_knockBackController.GetActiveParms().x4_animFollowup) { switch (x460_knockBackController.GetActiveParms().x4_animFollowup) {
case EKnockBackAnimationFollowUp::Freeze: case EKnockBackAnimationFollowUp::Freeze:
Freeze(mgr, zeus::skZero3f, zeus::CUnitVector3f(x34_transform.transposeRotate(backVec)), Freeze(mgr, zeus::skZero3f, zeus::CUnitVector3f(x34_transform.transposeRotate(backVec)),
@ -545,10 +546,11 @@ void CPatterned::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, c
break; break;
case EKnockBackAnimationFollowUp::IceDeath: case EKnockBackAnimationFollowUp::IceDeath:
Death(mgr, zeus::skZero3f, EScriptObjectState::DeathRattle); Death(mgr, zeus::skZero3f, EScriptObjectState::DeathRattle);
if (x54c_iceDeathExplosionParticle) if (x54c_iceDeathExplosionParticle) {
MassiveFrozenDeath(mgr); MassiveFrozenDeath(mgr);
else if (x450_bodyController->IsFrozen()) } else if (x450_bodyController->IsFrozen()) {
x450_bodyController->FrozenBreakout(); x450_bodyController->FrozenBreakout();
}
break; break;
default: default:
break; break;

View File

@ -835,7 +835,7 @@ void CWallCrawlerSwarm::Think(float dt, CStateManager& mgr) {
const zeus::CAABox aabb = BoxForPosition(r26, r27, r20, x374_boidRadius + 0.5f); const zeus::CAABox aabb = BoxForPosition(r26, r27, r20, x374_boidRadius + 0.5f);
CAreaCollisionCache ccache(aabb); CAreaCollisionCache ccache(aabb);
CGameCollision::BuildAreaCollisionCache(mgr, ccache); CGameCollision::BuildAreaCollisionCache(mgr, ccache);
while (boid) { while (boid != nullptr) {
r21 += 1; r21 += 1;
if (boid->GetActive()) { if (boid->GetActive()) {
if (x558_flavor == EFlavor::Scarab) { if (x558_flavor == EFlavor::Scarab) {
@ -1235,5 +1235,15 @@ zeus::CVector3f CWallCrawlerSwarm::GetAimPosition(const CStateManager&, float dt
return x108_boids[x42c_lockOnIdx].x30_velocity * dt + x124_lastOrbitPosition; return x108_boids[x42c_lockOnIdx].x30_velocity * dt + x124_lastOrbitPosition;
} }
void CWallCrawlerSwarm::ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& stateMgr) {
for (CBoid& boid : x108_boids) {
if (boid.GetActive() && (boid.GetTranslation() - pos).magSquared() < info.GetRadius() * info.GetRadius()) {
boid.x78_health -= info.GetRadiusDamage();
if (boid.x78_health <= 0.f) {
KillBoid(boid, stateMgr, 1.f, 0.1f);
}
}
}
}
} // namespace urde } // namespace urde

View File

@ -205,7 +205,7 @@ public:
zeus::CVector3f GetOrbitPosition(const CStateManager&) const override; zeus::CVector3f GetOrbitPosition(const CStateManager&) const override;
zeus::CVector3f GetAimPosition(const CStateManager&, float) const override; zeus::CVector3f GetAimPosition(const CStateManager&, float) const override;
const zeus::CVector3f& GetLastKilledOffset() const { return x130_lastKilledOffset; } const zeus::CVector3f& GetLastKilledOffset() const { return x130_lastKilledOffset; }
void ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& stateMgr) {} void ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& stateMgr);
const std::vector<CBoid>& GetBoids() const { return x108_boids; } const std::vector<CBoid>& GetBoids() const { return x108_boids; }
int GetCurrentLockOnId() const { return x42c_lockOnIdx; } int GetCurrentLockOnId() const { return x42c_lockOnIdx; }
bool GetLockOnLocationValid(int id) const { return id >= 0 && id < x108_boids.size() && x108_boids[id].GetActive(); } bool GetLockOnLocationValid(int id) const { return id >= 0 && id < x108_boids.size() && x108_boids[id].GetActive(); }