Implement CNewIntroBoss

This commit is contained in:
Phillip Stephens 2018-11-16 21:05:57 -08:00
parent cc4a895818
commit ea4848196a
37 changed files with 952 additions and 56 deletions

View File

@ -17,7 +17,7 @@ struct NewIntroBoss : IScriptObject
PatternedInfo patternedInfo;
ActorParameters actorParameters;
Value<float> unknown1;
Value<float> unknown2;
UniqueID32 weaponDesc;
DamageInfo damageInfo;
UniqueID32 particle1;
UniqueID32 particle2;
@ -58,6 +58,7 @@ struct NewIntroBoss : IScriptObject
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut,
std::vector<hecl::ProjectPath>& lazyOut) const
{
g_curSpec->flattenDependencies(weaponDesc, pathsOut);
g_curSpec->flattenDependencies(particle1, pathsOut);
g_curSpec->flattenDependencies(particle2, pathsOut);
g_curSpec->flattenDependencies(texture1, pathsOut);

View File

@ -256,6 +256,7 @@ public:
u16 GetDefaultAnimation() const { return x208_defaultAnim; }
TLockedToken<CMorphableSkinnedModel>& IceModel() { return xe4_iceModelData; }
const TLockedToken<CMorphableSkinnedModel>& GetIceModel() const { return xe4_iceModelData; }
void SetParticleLightIdx(s32 idx) { x21c_particleLightIdx = idx; }
};
}

View File

@ -0,0 +1,56 @@
#include "Character/CBoneTracking.hpp"
#include "Character/CBodyController.hpp"
#include "Character/CAnimData.hpp"
#include "Character/CHierarchyPoseBuilder.hpp"
#include "World/CPatterned.hpp"
#include "CStateManager.hpp"
#include "TCastTo.hpp"
namespace urde
{
CBoneTracking::CBoneTracking(const CAnimData& animData, std::string_view bone, float f1, float f2, bool b1)
: x14_segId(animData.GetCharLayoutInfo().GetSegIdFromString(bone)), x1c_(f1), x20_(f2), x36_24_active(false),
x36_25_(false), x36_26_(b1), x36_27_(b1), x36_28_(b1), x36_29_(b1)
{
}
void CBoneTracking::Update(float dt)
{
x18_time += dt;
}
void CBoneTracking::PreRender(const CStateManager& mgr, CAnimData& animData, const zeus::CTransform& xf,
const zeus::CVector3f& vec, const CBodyController& bodyController)
{
TCastToPtr <CPatterned> patterned = bodyController.GetOwner();
bool r31 = false;
if (bodyController.GetBodyStateInfo().ApplyHeadTracking() && patterned && patterned->ApplyBoneTracking())
r31 = true;
PreRender(mgr, animData, xf, vec, r31);
}
void CBoneTracking::PreRender(const CStateManager& mgr, CAnimData& animData, const zeus::CTransform& xf,
const zeus::CVector3f& vec, bool b)
{
}
void CBoneTracking::SetActive(bool)
{
x36_24_active = true;
}
void CBoneTracking::SetTarget(TUniqueId target)
{
x34_target = target;
}
void CBoneTracking::SetTargetPosition(const zeus::CVector3f& targetPos)
{
x24_targetPosition = targetPos;
}
}

View File

@ -90,6 +90,7 @@ set(CHARACTER_SOURCES
CBodyController.hpp CBodyController.cpp
CGroundMovement.hpp CGroundMovement.cpp
CSteeringBehaviors.hpp CSteeringBehaviors.cpp
CBodyStateInfo.hpp CBodyStateInfo.cpp)
CBodyStateInfo.hpp CBodyStateInfo.cpp
CBoneTracking.hpp CBoneTracking.cpp)
runtime_add_list(Character CHARACTER_SOURCES)

View File

@ -49,7 +49,7 @@ CParticleGenInfoGeneric::CParticleGenInfoGeneric(const SObjectTag& part, const s
if (lightId == -1)
x88_lightId = kInvalidUniqueId;
else
x88_lightId = _initializeLight(system, stateMgr, lightId, areaId);
x88_lightId = _initializeLight(system, stateMgr, areaId, lightId);
}
void CParticleGenInfoGeneric::AddToRenderer() { g_Renderer->AddParticleGen(*x84_system.get()); }

View File

@ -168,7 +168,10 @@ enum class EGenerateType
{
Invalid = -1,
Zero,
One
One,
Two,
Three,
Four
};
enum class ESlideType

View File

@ -69,13 +69,14 @@ void CCollisionActor::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, C
{
switch(msg)
{
case EScriptObjectMessage::ToggleActive:
case EScriptObjectMessage::Falling:
case EScriptObjectMessage::Registered:
case EScriptObjectMessage::Deleted:
case EScriptObjectMessage::InitializedInArea:
break;
case EScriptObjectMessage::Alert:
case EScriptObjectMessage::LandOnNotFloor:
case EScriptObjectMessage::Registered:
case EScriptObjectMessage::Touched:
case EScriptObjectMessage::Damage:
case EScriptObjectMessage::InvulnDamage:
{
CEntity* ent = mgr.ObjectById(x25c_owner);
if (ent)

View File

@ -52,6 +52,7 @@ CCollisionActorManager::CCollisionActorManager(CStateManager& mgr, TUniqueId own
}
mgr.AddObject(newAct);
x0_jointDescriptions.push_back(desc);
x0_jointDescriptions.back().SetCollisionActorId(newAct->GetUniqueId());
}
else
{
@ -134,6 +135,7 @@ void CCollisionActorManager::Destroy(CStateManager& mgr) const
void CCollisionActorManager::SetActive(CStateManager& mgr, bool active)
{
x12_active = active;
for (const CJointCollisionDescription& jDesc : x0_jointDescriptions)
{
if (TCastToPtr<CActor> act = mgr.ObjectById(jDesc.GetCollisionActorId()))
@ -142,7 +144,7 @@ void CCollisionActorManager::SetActive(CStateManager& mgr, bool active)
if (curActive != active)
act->SetActive(active);
if (!curActive)
if (active)
Update(0.f, mgr, EUpdateOptions::WorldSpace);
}
}

View File

@ -40,5 +40,6 @@ public:
static zeus::CTransform GetWRLocatorTransform(const CAnimData& animData, CSegId id,
const zeus::CTransform& worldXf,
const zeus::CTransform& localXf);
};
}

View File

@ -16,6 +16,7 @@ enum class ERumbleFxId
PlayerGrappleFire = 14,
PlayerLand = 15,
PlayerGrappleSwoosh = 17,
IntroBossProjectile = 19,
Twenty = 20,
TwentyOne = 21,
TwentyTwo = 22,

View File

@ -22,7 +22,7 @@ const SAdsrData RumbleFxTable[] =
{2.4f, 0.f, 0.01f, 0.125f, 0.25f, 0.5f, false, false}, // PlayerMissileFire
{0.84f, 0.f, 0.1f, 0.125f, 0.35f, 1.0f, false, false}, // PlayerGrappleFire
{2.4f, 0.f, 0.1f, 0.225f, 0.38f, 0.3f, false, false}, // PlayerLand
{0.48f, 0.f, 0.065f, 0.175f, 0.4f, 0.f, false, false},
{0.48f, 0.f, 0.065f, 0.175f, 0.4f, 0.f, false, false}, // IntroBossProjectile (??)
{0.3024f, 0.f, 0.1f, 1.345f, 0.f, 1.756f, false, false}, // PlayerGrappleSwoosh
{0.72f, 0.f, 0.01f, 0.01f, 0.6f, 0.1f, false, false},
{1.1904f, 0.f, 0.f, 0.125f, 0.683f, 0.5f, true, false},

View File

@ -1,6 +1,8 @@
#include <Runtime/World/CPatternedInfo.hpp>
#include "CFireFlea.hpp"
#include "CStateManager.hpp"
#include "CPlayerState.hpp"
#include "World/CWorld.hpp"
#include "TCastTo.hpp"
namespace urde::MP1
@ -63,11 +65,60 @@ void CFireFlea::CDeathCameraEffect::Think(float dt, CStateManager& mgr)
//endregion
s32 CFireFlea::sLightIdx = 0;
CFireFlea::CFireFlea(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, float)
CModelData&& mData, const CActorParameters& actParms, const CPatternedInfo& pInfo, float f1)
: CPatterned(ECharacter::FireFlea, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::NewFlyer, actParms, EKnockBackVariant::Small)
, x56c_(f1)
, xd8c_pathFind(nullptr, 2, pInfo.GetParticle1Frames(), 1.f, 1.f)
{
CMaterialFilter filter = GetMaterialFilter();
filter.ExcludeList().Add(EMaterialTypes::Character);
SetMaterialFilter(filter);
ModelData()->AnimationData()->SetParticleLightIdx(sLightIdx);
++sLightIdx;
}
void CFireFlea::Dead(CStateManager& mgr, EStateMsg msg, float dt)
{
if (msg != EStateMsg::Activate || mgr.GetPlayerState()->GetActiveVisor(mgr) != CPlayerState::EPlayerVisor::Thermal)
return;
mgr.AddObject(new CDeathCameraEffect(mgr.AllocateUniqueId(), GetAreaIdAlways(), ""sv));
}
bool CFireFlea::Delay(CStateManager&, float arg)
{
return x330_stateMachineState.GetTime() > 0.5f;
}
void CFireFlea::Accept(IVisitor& visitor)
{
visitor.Visit(this);
}
void CFireFlea::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
CPatterned::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Registered)
{
x450_bodyController->Activate(mgr);
}
else if (msg == EScriptObjectMessage::InitializedInArea)
{
xd8c_pathFind.SetArea(mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways())->GetPostConstructed()->x10bc_pathArea);
xe64_ = 50.f;
}
}
bool CFireFlea::InPosition(CStateManager& mgr, float dt)
{
if (x2dc_destObj == kInvalidUniqueId)
return false;
return (xd80_ - GetTranslation()).magnitude() < 25.f;
}
}

View File

@ -1,12 +1,13 @@
#pragma once
#include "World/CPatterned.hpp"
#include "World/CPathFindSearch.hpp"
namespace urde::MP1
{
class CFireFlea : public CPatterned
{
class CDeathCameraEffect : CEntity
class CDeathCameraEffect : public CEntity
{
u32 x34_ = 13;
u32 x38_ = 5;
@ -23,11 +24,27 @@ class CFireFlea : public CPatterned
void PreThink(float, CStateManager&);
void Think(float, CStateManager&);
};
float x568_ = 1.f;
float x56c_;
u32 x570_ = 0;
float xe64_;
zeus::CVector3f xd74_;
zeus::CVector3f xd80_;
CPathFindSearch xd8c_pathFind;
static s32 sLightIdx;
public:
DEFINE_PATTERNED(FireFlea)
CFireFlea(TUniqueId, std::string_view, const CEntityInfo&, const zeus::CTransform&, CModelData&&,
const CActorParameters&, const CPatternedInfo&, float);
void Accept(IVisitor&);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr);
void Dead(CStateManager&, EStateMsg msg, float dt);
bool Delay(CStateManager&, float arg);
bool InPosition(CStateManager& mgr, float dt);
CPathFindSearch* GetSearchPath() { return &xd8c_pathFind; }
};
}

View File

@ -1,17 +1,35 @@
#include "CNewIntroBoss.hpp"
#include "MP1/World/CNewIntroBoss.hpp"
#include "Character/CCharLayoutInfo.hpp"
#include "Collision/CCollisionActor.hpp"
#include "Collision/CCollisionActorManager.hpp"
#include "Collision/CGameCollision.hpp"
#include "Collision/CJointCollisionDescription.hpp"
#include "Weapon/CPlasmaProjectile.hpp"
#include "World/CPlayer.hpp"
#include "CStateManager.hpp"
#include "TCastTo.hpp"
#include "CNewIntroBoss.hpp"
namespace urde::MP1
{
CNewIntroBoss::CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo,
u32, u32, u32, u32)
const CActorParameters& actParms, float f1, CAssetId projectile, const CDamageInfo& dInfo,
CAssetId part1, CAssetId part2, CAssetId tex1, CAssetId tex2)
: CPatterned(ECharacter::NewIntroBoss, uid, name, EFlavorType::Zero, info, xf, std::move(mData), pInfo,
EMovementType::Flyer, EColliderType::One, EBodyType::Restricted, actParms, EKnockBackVariant::Medium)
, x570_(f1)
, x574_boneTracking(*GetModelData()->GetAnimationData(), "Head_1"sv, zeus::degToRad(80.f), zeus::degToRad(180.f), false)
, x5ac_projectileInfo(projectile, dInfo)
, x5f0_(part1)
, x5f4_(part2)
, x5f8_(tex1)
, x5fc_(tex2)
{
const_cast<TToken<CWeaponDescription>*>(&x5ac_projectileInfo.Token())->Lock();
x574_boneTracking.SetActive(true);
}
void CNewIntroBoss::Accept(IVisitor &visitor)
@ -19,4 +37,492 @@ void CNewIntroBoss::Accept(IVisitor &visitor)
visitor.Visit(this);
}
struct SSphereJointDescription
{
const char* name;
float radius;
};
static const SSphereJointDescription skSphereJoints[] ={
{"Head_1", 1.5f},
{"Tail_1", 1.5f}
};
struct SOBBJointDescription
{
const char* from;
const char* to;
zeus::CVector3f bounds;
};
static const SOBBJointDescription skOBBJoints[] = {
{"Pelvis", "Spine_3", {4.f, 1.f, 4.f}},
{"Spine_3", "Tail_1", {2.f, 1.f, 2.f}},
{"Tail_1", "Tail_2", {1.f, 1.f, 1.f}},
{"Tail_2", "Tail_3", {1.f, 1.f, 1.f}},
{"Tail_3", "Tail_4", {1.f, 1.f, 1.f}},
{"R_shoulder_front", "R_elbow_front", {.5f, .5f, .5f}},
{"R_elbow_front", "R_wrist_front", {.5f, .5f, .5f}},
{"L_shoulder_front", "L_elbow_front", {.5f, .5f, .5f}},
{"L_elbow_front", "L_wrist_front", {.5f, .5f, .5f}},
{"R_shoulder_back", "R_elbow_back", {.5f, .5f, .5f}},
{"R_elbow_back", "R_wrist_back", {.5f, .5f, .5f}},
{"L_shoulder_back", "L_elbow_back", {.5f, .5f, .5f}},
{"L_elbow_back", "L_wrist_back", {.5f, .5f, .5f}},
};
void CNewIntroBoss::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
if (msg == EScriptObjectMessage::Registered)
{
RemoveMaterial(EMaterialTypes::Solid, mgr);
RemoveMaterial(EMaterialTypes::Target, mgr);
RemoveMaterial(EMaterialTypes::Orbit, mgr);
x450_bodyController->Activate(mgr);
if (x5d4_stage1Projectile == kInvalidUniqueId)
{
CBeamInfo stage1BeamInfo = CBeamInfo(3, x5f0_, x5f4_, x5f8_, x5fc_, 50, 1.f, 1.f, 1.5f, 20.f,
1.f, 4.f, 8.f, zeus::CColor::skYellow,
zeus::CColor(0.1098f, 0.5764f, 0.1592f), 150.f);
CBeamInfo stage2BeamInfo(3, x5f0_, x5f4_, x5f8_, x5fc_, 50, 1.f, 1.f, 2.f, 20.f, 1.f, 4.f, 8.f,
zeus::CColor::skYellow, zeus::CColor(0.1098f, 0.5764f, 0.1592f), 150.f);
x5d4_stage1Projectile = mgr.AllocateUniqueId();
x5d6_stage2Projectile = mgr.AllocateUniqueId();
x5d8_stage3Projectile = mgr.AllocateUniqueId();
CPlasmaProjectile* stage1Projectile = new CPlasmaProjectile(x5ac_projectileInfo.Token(), "IntroBoss_Beam"sv, EWeaponType::AI,
stage1BeamInfo, {}, EMaterialTypes::Character,
x5ac_projectileInfo.GetDamage(), x5d4_stage1Projectile,
GetAreaIdAlways(), GetUniqueId(), 8, true,
EProjectileAttrib::KeepInCinematic);
CPlasmaProjectile* stage2Projectile = new CPlasmaProjectile(x5ac_projectileInfo.Token(), "IntroBoss_Beam_Stage2"sv,
EWeaponType::AI, stage2BeamInfo, {}, EMaterialTypes::Character,
x5ac_projectileInfo.GetDamage(), x5d6_stage2Projectile,
GetAreaIdAlways(), GetUniqueId(), 8, true,
EProjectileAttrib::KeepInCinematic);
CPlasmaProjectile* stage3Projectile = new CPlasmaProjectile(x5ac_projectileInfo.Token(), "IntroBoss_Beam_Stage2"sv,
EWeaponType::AI, stage2BeamInfo, {}, EMaterialTypes::Character,
x5ac_projectileInfo.GetDamage(), x5d8_stage3Projectile,
GetAreaIdAlways(), GetUniqueId(), 8, true,
EProjectileAttrib::KeepInCinematic);
mgr.AddObject(stage1Projectile);
mgr.AddObject(stage2Projectile);
mgr.AddObject(stage3Projectile);
x676_curProjectile = x5d4_stage1Projectile;
}
std::vector<CJointCollisionDescription> jointCollisions;
jointCollisions.reserve(15);
const CAnimData* animData = GetModelData()->GetAnimationData();
for (const SSphereJointDescription& joint : skSphereJoints)
{
CSegId seg = animData->GetLocatorSegId(joint.name);
jointCollisions.push_back(
CJointCollisionDescription::SphereCollision(seg, joint.radius, joint.name, 0.001f));
}
for (const SOBBJointDescription& joint : skOBBJoints)
{
CSegId from = animData->GetLocatorSegId(joint.from);
CSegId to = animData->GetLocatorSegId(joint.to);
jointCollisions.push_back(
CJointCollisionDescription::OBBAutoSizeCollision(from, to, joint.bounds,
CJointCollisionDescription::EOrientationType::One,
joint.from, 0.001f));
}
x5ec_collisionManager.reset(
new CCollisionActorManager(mgr, GetUniqueId(), GetAreaIdAlways(), jointCollisions, GetActive()));
x640_initialHp = GetHealthInfo(mgr)->GetHP();
for (u32 i = 0; i < x5ec_collisionManager->GetNumCollisionActors(); ++i)
{
const CJointCollisionDescription& desc = x5ec_collisionManager->GetCollisionDescFromIndex(i);
TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(desc.GetCollisionActorId());
if (desc.GetName() == skSphereJoints[0].name)
{
x600_headActor = desc.GetCollisionActorId();
if (colAct)
{
CHealthInfo* thisHealthInfo = HealthInfo(mgr);
CHealthInfo* colHealthInfo = colAct->HealthInfo(mgr);
*colHealthInfo = *thisHealthInfo;
colAct->SetDamageVulnerability(*GetDamageVulnerability());
colAct->RemoveMaterial(EMaterialTypes::Orbit, mgr);
}
}
else if (desc.GetName() == skOBBJoints[0].from)
{
x602_pelvisActor = desc.GetCollisionActorId();
if (colAct)
{
CHealthInfo* thisHealthInfo = HealthInfo(mgr);
CHealthInfo* colHealthInfo = colAct->HealthInfo(mgr);
*colHealthInfo = *thisHealthInfo;
colAct->SetDamageVulnerability(CDamageVulnerability::NormalVulnerabilty());
colAct->AddMaterial(EMaterialTypes::Orbit, mgr);
MoveScannableObjectInfoToActor(colAct, mgr);
}
} else
colAct->RemoveMaterial(EMaterialTypes::Orbit, mgr);
}
}
else if (msg == EScriptObjectMessage::Deleted)
{
DeleteBeam(mgr);
x5ec_collisionManager->Destroy(mgr);
}
else if (msg == EScriptObjectMessage::Damage)
{
if (uid == x600_headActor || uid == x602_pelvisActor)
TakeDamage({}, 0.f);
}
bool active = GetActive();
CPatterned::AcceptScriptMsg(msg, uid, mgr);
if (active == GetActive())
return;
if (x5ec_collisionManager)
x5ec_collisionManager->SetActive(mgr, GetActive());
x63c_attackTime = 8.f;
}
pas::ELocomotionType CNewIntroBoss::GetLocoForHealth(const CStateManager& mgr) const
{
float hp = GetHealthInfo(mgr)->GetHP();
if (hp > .66f * x640_initialHp)
return pas::ELocomotionType::Relaxed;
else if (hp > .33f * x640_initialHp)
return pas::ELocomotionType::Lurk;
return pas::ELocomotionType::Combat;
}
void CNewIntroBoss::OnScanStateChanged(EScanState state, CStateManager& mgr)
{
CPatterned::OnScanStateChanged(state, mgr);
if (state != EScanState::Done)
return;
TCastToPtr<CCollisionActor> colAct = mgr.ObjectById(x600_headActor);
if (colAct)
colAct->AddMaterial(EMaterialTypes::Orbit, mgr);
colAct = mgr.ObjectById(x602_pelvisActor);
if (colAct)
colAct->RemoveMaterial(EMaterialTypes::Orbit, mgr);
}
void CNewIntroBoss::DeleteBeam(CStateManager& mgr)
{
if (x5d4_stage1Projectile != kInvalidUniqueId)
{
mgr.FreeScriptObject(x5d4_stage1Projectile);
x5d4_stage1Projectile = kInvalidUniqueId;
}
if (x5d6_stage2Projectile != kInvalidUniqueId)
{
mgr.FreeScriptObject(x5d6_stage2Projectile);
x5d6_stage2Projectile = kInvalidUniqueId;
}
if (x5d8_stage3Projectile != kInvalidUniqueId)
{
mgr.FreeScriptObject(x5d8_stage3Projectile);
x5d8_stage3Projectile = kInvalidUniqueId;
}
StopRumble(mgr);
}
void CNewIntroBoss::StopRumble(CStateManager& mgr)
{
if (x674_rumbleVoice == -1)
return;
mgr.GetRumbleManager().StopRumble(x674_rumbleVoice);
x674_rumbleVoice = -1;
}
void CNewIntroBoss::Think(float dt, CStateManager& mgr)
{
CPatterned::Think(dt, mgr);
if (x638_ < 0.2f)
x638_ += dt;
if (x400_25_alive)
{
x574_boneTracking.SetTargetPosition(x62c_targetPos + zeus::CVector3f{0.f, 0.f, 10.f});
x574_boneTracking.Update(dt);
}
if (x63c_attackTime > 0.f)
x63c_attackTime -= dt;
ModelData()->AnimationData()->PreRender();
if (x400_25_alive)
x574_boneTracking.PreRender(mgr, *ModelData()->AnimationData(), x34_transform, ModelData()->GetScale(),
*x450_bodyController);
x5ec_collisionManager->Update(dt, mgr, CCollisionActorManager::EUpdateOptions::ObjectSpace);
CPlasmaProjectile* curProjectile = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x676_curProjectile));
if (curProjectile && curProjectile->GetActive())
{
x628_ += dt;
zeus::CTransform xf = GetLctrTransform(x5dc_damageLocator);
if (x400_25_alive)
{
zeus::CQuaternion clampedQuat = zeus::CQuaternion::clampedRotateTo(
(x610_lookPos + (zeus::min(x628_ / 1.5f, 1.f) * (x61c_ - x610_lookPos))) - xf.origin,
xf.frontVector(), zeus::CRelAngle::FromDegrees(30.f));
curProjectile->UpdateFX(clampedQuat.toTransform() * xf.getRotation(), dt, mgr);
} else
curProjectile->UpdateFX(xf, dt, mgr);
}
TCastToPtr<CCollisionActor> headAct = mgr.ObjectById(x600_headActor);
TCastToPtr<CCollisionActor> pelvisAct = mgr.ObjectById(x602_pelvisActor);
if (headAct && pelvisAct)
{
CHealthInfo* pelvisHealth = pelvisAct->HealthInfo(mgr);
CHealthInfo* headHealth = headAct->HealthInfo(mgr);
if (headHealth->GetHP() < pelvisHealth->GetHP())
{
*HealthInfo(mgr) = *headHealth;
*pelvisAct->HealthInfo(mgr) = *headHealth;
}
else
{
*HealthInfo(mgr) = *pelvisHealth;
*headAct->HealthInfo(mgr) = *pelvisHealth;
}
}
if (HealthInfo(mgr)->GetHP() <= 0.f && x400_25_alive)
{
if (curProjectile)
curProjectile->ResetBeam(mgr, true);
x450_bodyController->SetPlaybackRate(1.f);
SetTransform(x644_);
StopRumble(mgr);
Death(mgr, GetTransform().frontVector(), EScriptObjectState::DeathRattle);
}
}
void CNewIntroBoss::DoUserAnimEvent(CStateManager& mgr, CInt32POINode& node, EUserEventType event, float dt)
{
if (event == EUserEventType::DamageOn)
{
x5dc_damageLocator = node.GetLocatorName();
zeus::CTransform xf = GetLctrTransform(x5dc_damageLocator);
zeus::CVector3f playerPos = PlayerPos(mgr);
x604_predictedPlayerPos = x610_lookPos = x62c_targetPos = playerPos;
x628_ = 0.f;
if (GetLocoForHealth(mgr) == pas::ELocomotionType::Combat)
x676_curProjectile = x5d8_stage3Projectile;
else if (GetLocoForHealth(mgr) == pas::ELocomotionType::Lurk)
x676_curProjectile = x5d6_stage2Projectile;
else
x676_curProjectile = x5d4_stage1Projectile;
if (CPlasmaProjectile* projectile = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x676_curProjectile)))
{
if (!projectile->GetActive())
{
projectile->Fire(zeus::lookAt(xf.origin, x610_lookPos), mgr, false);
if (x674_rumbleVoice == -1)
x674_rumbleVoice = mgr.GetRumbleManager().Rumble(mgr, ERumbleFxId::IntroBossProjectile, 1.f, ERumblePriority::Two);
}
}
}
else if (event == EUserEventType::DamageOff)
{
if (CPlasmaProjectile* projectile = static_cast<CPlasmaProjectile*>(mgr.ObjectById(x676_curProjectile)))
projectile->ResetBeam(mgr, false);
StopRumble(mgr);
x63c_attackTime = GetNextAttackTime(mgr);
SendScriptMsgs(EScriptObjectState::Attack, mgr, EScriptObjectMessage::None);
}
else
CActor::DoUserAnimEvent(mgr, node, event, dt);
}
void CNewIntroBoss::AddToRenderer(const zeus::CFrustum&, const CStateManager& mgr) const
{
EnsureRendered(mgr);
}
float CNewIntroBoss::GetNextAttackTime(CStateManager& mgr) const
{
float attackTime = 2.f * mgr.GetActiveRandom()->Float() + 6.f;
float hp = GetHealthInfo(mgr)->GetHP();
if (hp > .66 * x640_initialHp)
return attackTime;
else if (hp > .33 * x640_initialHp)
return attackTime - (0.4125f * attackTime);
return attackTime - (0.825f * attackTime);
}
zeus::CVector3f CNewIntroBoss::PlayerPos(const CStateManager& mgr) const
{
CRayCastResult result = CGameCollision::RayStaticIntersection(mgr, mgr.GetPlayer().GetTranslation() +
zeus::CVector3f{0.f, 0.f,
mgr.GetPlayer().GetEyeHeight() *
0.5f},
zeus::CVector3f::skDown, 30.f,
CMaterialFilter::MakeInclude(
{EMaterialTypes::Solid}));
if (result.IsValid())
return result.GetPoint() + zeus::CVector3f{0.f, 0.f, (mgr.GetPlayer().GetEyeHeight() * 0.5f) + 0.2f};
return mgr.GetPlayer().GetTranslation() + zeus::CVector3f{0.f, 0.f, (mgr.GetPlayer().GetEyeHeight() * 0.5f) + 0.2f};
}
bool CNewIntroBoss::ShouldTurn(CStateManager& mgr, float dt)
{
zeus::CVector3f playerVel = 1.f * mgr.GetPlayer().GetVelocity();
zeus::CVector3f playerPos = PlayerPos(mgr);
x604_predictedPlayerPos = playerPos + playerVel;
zeus::CVector2f diffPos = (x604_predictedPlayerPos - GetTranslation()).toVec2f();
return zeus::CVector2f::getAngleDiff(GetTransform().frontVector().toVec2f(), diffPos) > zeus::degToRad(1.f);
}
bool CNewIntroBoss::ShouldAttack(CStateManager& mgr, float dt)
{
if (x63c_attackTime > 0.f)
return false;
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Turn)
return false;
return !ShouldTurn(mgr, dt);
}
bool CNewIntroBoss::AIStage(CStateManager& mgr, float)
{
return x568_locomotion != GetLocoForHealth(mgr);
}
bool CNewIntroBoss::AnimOver(urde::CStateManager&, float)
{
return x56c_ == 3;
}
void CNewIntroBoss::Generate(CStateManager& mgr, EStateMsg msg, float dt)
{
if (msg == EStateMsg::Activate)
{
x56c_ = 0;
x568_locomotion = GetLocoForHealth(mgr);
SendScriptMsgs(EScriptObjectState::Entered, mgr, EScriptObjectMessage::None);
}
else if (msg == EStateMsg::Update)
{
if (x56c_ == 0)
{
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::Generate)
{
x56c_ = 2;
return;
}
x450_bodyController->GetCommandMgr().DeliverCmd(CBCGenerateCmd(GetGenerateForHealth(mgr)));
}
else if (x56c_ == 2)
{
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Generate)
{
x56c_ = 3;
SendScriptMsgs(EScriptObjectState::Exited, mgr, EScriptObjectMessage::None);
}
}
}
}
pas::EGenerateType CNewIntroBoss::GetGenerateForHealth(const CStateManager& mgr) const
{
return GetHealthInfo(mgr)->GetHP() > 0.33f * x640_initialHp ? pas::EGenerateType::Three : pas::EGenerateType::Four;
}
bool CNewIntroBoss::InAttackPosition(CStateManager& mgr, float dt)
{
return x330_stateMachineState.GetTime() > 0.25f && x678_ &&
x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::Turn &&
!ShouldTurn(mgr, dt);
}
void CNewIntroBoss::Attack(CStateManager& mgr, EStateMsg msg, float dt)
{
if (msg == EStateMsg::Activate)
x56c_ = 0;
else if (msg == EStateMsg::Update)
{
if (x56c_ == 0)
{
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() == pas::EAnimationState::ProjectileAttack)
x56c_ = 2;
else
{
x450_bodyController->GetCommandMgr().DeliverCmd(
CBCProjectileAttackCmd(pas::ESeverity::One, mgr.GetPlayer().GetTranslation(), false));
}
}
else if (x56c_ == 2)
{
if (x450_bodyController->GetBodyStateInfo().GetCurrentStateId() != pas::EAnimationState::ProjectileAttack)
{
x56c_ = 3;
x638_ = 0.f;
}
if (const CPlasmaProjectile* proj = static_cast<const CPlasmaProjectile*>(mgr.GetObjectById(
x676_curProjectile)))
{
if (!proj->GetActive())
x62c_targetPos = mgr.GetPlayer().GetTranslation();
}
}
}
else if (msg == EStateMsg::Deactivate)
{
if (GetLocoForHealth(mgr) == pas::ELocomotionType::Lurk || GetLocoForHealth(mgr) == pas::ELocomotionType::Combat)
x678_ ^= 1;
else
x678_ = false;
}
}
void CNewIntroBoss::Patrol(CStateManager& mgr, EStateMsg msg, float dt)
{
if (msg == EStateMsg::Activate || msg == EStateMsg::Update)
{
x450_bodyController->SetLocomotionType(x568_locomotion);
if (x638_ > 0.2f)
x62c_targetPos = PlayerPos(mgr);
else
x62c_targetPos = x610_lookPos + ((x638_ / 0.2f) * (PlayerPos(mgr) - x610_lookPos));
if (ShouldTurn(mgr, 0.f))
{
x450_bodyController->GetCommandMgr().DeliverCmd(CBCLocomotionCmd({},
(x604_predictedPlayerPos -
GetTranslation()).normalized(), 1.f));
}
}
}
}

View File

@ -1,24 +1,82 @@
#pragma once
#include "World/CPatterned.hpp"
#include "Character/CBoneTracking.hpp"
#include "Weapon/CProjectileInfo.hpp"
namespace urde
{
class CDamageInfo;
class CCollisionActorManager;
namespace MP1
{
class CNewIntroBoss : public CPatterned
{
pas::ELocomotionType x568_locomotion = pas::ELocomotionType::Relaxed;
u32 x56c_ = 0;
float x570_;
CBoneTracking x574_boneTracking;
CProjectileInfo x5ac_projectileInfo;
TUniqueId x5d4_stage1Projectile = kInvalidUniqueId;
TUniqueId x5d6_stage2Projectile = kInvalidUniqueId;
TUniqueId x5d8_stage3Projectile = kInvalidUniqueId;
std::string x5dc_damageLocator; // ???
std::unique_ptr<CCollisionActorManager> x5ec_collisionManager;
CAssetId x5f0_;
CAssetId x5f4_;
CAssetId x5f8_;
CAssetId x5fc_;
TUniqueId x600_headActor = kInvalidUniqueId;
TUniqueId x602_pelvisActor = kInvalidUniqueId;
zeus::CVector3f x604_predictedPlayerPos;
zeus::CVector3f x610_lookPos;
zeus::CVector3f x61c_;
float x628_ = 0.f;
zeus::CVector3f x62c_targetPos;
float x638_ = 0.2f;
float x63c_attackTime = 8.f;
float x640_initialHp = 0.f;
zeus::CTransform x644_;
s16 x674_rumbleVoice = -1;
TUniqueId x676_curProjectile = kInvalidUniqueId;
bool x678_ = false;
pas::ELocomotionType GetLocoForHealth(const CStateManager&) const;
pas::EGenerateType GetGenerateForHealth(const CStateManager&) const;
float GetNextAttackTime(CStateManager&) const;
zeus::CVector3f PlayerPos(const CStateManager&) const;
void DeleteBeam(CStateManager&);
void StopRumble(CStateManager&);
public:
DEFINE_PATTERNED(NewIntroBoss)
CNewIntroBoss(TUniqueId uid, std::string_view name, const CEntityInfo& info,
const zeus::CTransform& xf, CModelData&& mData, const CPatternedInfo& pInfo,
const CActorParameters& actParms, float, u32, const CDamageInfo& dInfo,
u32, u32, u32, u32);
const CActorParameters& actParms, float, CAssetId, const CDamageInfo& dInfo,
CAssetId, CAssetId, CAssetId, CAssetId);
void Accept(IVisitor &visitor);
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager&);
void Think(float dt, CStateManager& mgr);
void AddToRenderer(const zeus::CFrustum&, const CStateManager&) const;
void OnScanStateChanged(EScanState, CStateManager&);
CProjectileInfo* GetProjectileInfo() { return &x5ac_projectileInfo; }
zeus::CAABox GetSortingBounds(const CStateManager&) const
{
zeus::CAABox box = GetModelData()->GetBounds();
return zeus::CAABox({-0.5f, -0.5f, box.min.z}, {0.5f, 0.5f, box.max.z}).getTransformedAABox(x34_transform);
}
std::experimental::optional<zeus::CAABox> GetTouchBounds() const { return {}; }
void DoUserAnimEvent(CStateManager&, CInt32POINode&, EUserEventType, float dt);
void Generate(CStateManager&, EStateMsg, float);
void Attack(CStateManager&, EStateMsg, float);
void Patrol(CStateManager&, EStateMsg, float);
bool ShouldTurn(CStateManager&, float);
bool ShouldAttack(CStateManager&, float);
bool AIStage(CStateManager&, float);
bool AnimOver(CStateManager&, float);
bool InAttackPosition(CStateManager&, float);
};
}

View File

@ -32,4 +32,14 @@ void CSpacePirate::Accept(IVisitor &visitor)
visitor.Visit(this);
}
void CSpacePirate::Think(float dt, CStateManager& mgr)
{
if (!GetActive())
return;
if (!x450_bodyController->GetActive())
x450_bodyController->Activate(mgr);
CPatterned::Think(dt, mgr);
}
}

View File

@ -77,5 +77,6 @@ public:
const CActorParameters&, const CPatternedInfo&, CInputStream&, u32);
void Accept(IVisitor &visitor);
void Think(float dt, CStateManager&);
};
}

View File

@ -9,7 +9,7 @@ namespace urde
struct CBeamInfo
{
u32 x0_;
u32 x4_;
s32 x4_;
CAssetId x8_;
CAssetId xc_;
CAssetId x10_;
@ -27,25 +27,21 @@ struct CBeamInfo
zeus::CColor x40_;
CBeamInfo(CInputStream& in)
: x0_(in.readUint32Big())
, x4_(in.readUint32Big())
, x8_(in.readUint32Big())
, xc_(in.readUint32Big())
, x10_(in.readUint32Big())
, x14_(in.readUint32Big())
, x18_(in.readFloatBig())
, x1c_(in.readFloatBig())
, x20_(in.readFloatBig())
, x24_(in.readFloatBig())
, x28_(in.readFloatBig())
, x2c_(in.readFloatBig())
, x30_(in.readFloatBig())
, x34_(in.readFloatBig())
, x38_(in.readFloatBig())
, x3c_(zeus::CColor::ReadRGBABig(in))
, x40_(zeus::CColor::ReadRGBABig(in))
: x0_(in.readUint32Big()), x4_(in.readUint32Big()), x8_(in.readUint32Big()), xc_(in.readUint32Big()),
x10_(in.readUint32Big()), x14_(in.readUint32Big()), x18_(in.readFloatBig()), x1c_(in.readFloatBig()),
x20_(in.readFloatBig()), x24_(in.readFloatBig()), x28_(in.readFloatBig()), x2c_(in.readFloatBig()),
x30_(in.readFloatBig()), x34_(in.readFloatBig()), x38_(in.readFloatBig()),
x3c_(zeus::CColor::ReadRGBABig(in)), x40_(zeus::CColor::ReadRGBABig(in))
{
}
CBeamInfo(s32 w1, CAssetId w2, CAssetId w3, CAssetId w4, CAssetId w5, s32 w6, float f1, float f2, float f3,
float f4, float f5, float f6, float f7, const zeus::CColor& col1, const zeus::CColor& col2, float f8)
: x4_(w1), x8_(w2), xc_(w3), x10_(w4), x14_(w5), x18_(w6), x1c_(f1), x20_(f2), x24_(f3), x28_(f4), x2c_(f5),
x30_(f6), x34_(f7), x38_(f8), x3c_(col1), x40_(col2)
{
}
};
}

View File

@ -46,5 +46,6 @@ public:
void CalculateRenderBounds();
virtual void ResetBeam(CStateManager&, bool);
virtual void UpdateFX(const zeus::CTransform&, float, CStateManager&);
virtual void Fire(const zeus::CTransform&, CStateManager&, bool) = 0;
};
}

View File

@ -25,4 +25,54 @@ zeus::CVector3f CBurstFire::GetDistanceCompensatedError(float, float) const
{
return {};
}
void CBurstFire::SetFirstBurst(bool)
{
}
bool CBurstFire::IsBurstSet() const
{
return false;
}
void CBurstFire::SetTimeToNextShot(float)
{
}
bool CBurstFire::ShouldFire() const
{
return false;
}
void CBurstFire::Start(CStateManager&)
{
}
void CBurstFire::GetError(float, float) const
{
}
float CBurstFire::GetMaxXError() const
{
return 0;
}
float CBurstFire::GetMaxZError() const
{
return 0;
}
void CBurstFire::GetError() const
{
}
void CBurstFire::SetFirstBurstIndex(s32)
{
}
}

View File

@ -21,6 +21,7 @@ struct SBurst
class CBurstFire
{
friend class CScriptGunTurret;
s32 x0_ = -1;
s32 x4_ = -1;
float x8_ = 0.f;
@ -37,11 +38,11 @@ public:
CBurstFire(SBurst**, s32);
void SetFirstBurst(bool);
void SetBurstType(s32);
void SetBurstType(s32 type) { x0_ = type; }
bool IsBurstSet() const;
void SetTimeToNextShot(float);
bool ShouldFire() const;
s32 GetBurstType() const;
s32 GetBurstType() const { return x0_; }
void Start(CStateManager&);
void Update(CStateManager&, float);
void Update();

View File

@ -126,7 +126,7 @@ static constexpr u64 kCheckMaterial = 0xE3FFFE;
void CEnergyProjectile::ResolveCollisionWithWorld(const CRayCastResult& res, CStateManager& mgr)
{
EWeaponCollisionResponseTypes crType = CCollisionResponseData::GetWorldCollisionResponseType(
CMaterialList::BitPosition(res.GetMaterial().GetValue() & 0xffffffff & kCheckMaterial));
CMaterialList::BitPosition((res.GetMaterial().GetValue() & 0xffffffff) & kCheckMaterial));
if ((xe8_projectileAttribs & (EProjectileAttrib::Wave | EProjectileAttrib::ComboShot)) !=
(EProjectileAttrib::Wave | EProjectileAttrib::ComboShot))
{

View File

@ -17,6 +17,7 @@ public:
void Accept(IVisitor& visitor);
void UpdateFx(const zeus::CTransform&, float, CStateManager&) {}
void Fire(const zeus::CTransform&, CStateManager&, bool) {}
};
}

View File

@ -791,4 +791,16 @@ void CActor::SetMuted(bool muted)
xe5_26_muted = muted;
RemoveEmitter();
}
void CActor::MoveScannableObjectInfoToActor(CActor* act, CStateManager& mgr)
{
if (!act)
return;
if (act->GetScannableObjectInfo() != GetScannableObjectInfo())
act->x98_scanObjectInfo = x98_scanObjectInfo;
act->AddMaterial(EMaterialTypes::Scannable, mgr);
RemoveMaterial(EMaterialTypes::Scannable, mgr);
}
}

View File

@ -201,6 +201,7 @@ public:
bool GetPointGeneratorParticles() const { return xe5_31_pointGeneratorParticles; }
void SetPointGeneratorParticles(bool s) { xe5_31_pointGeneratorParticles = s; }
CSimpleShadow* Shadow() { return x94_simpleShadow.get(); }
void MoveScannableObjectInfoToActor(CActor*, CStateManager&);
};
}

View File

@ -31,6 +31,8 @@ void CAmbientAI::Accept(IVisitor& visitor)
void CAmbientAI::Think(float dt, CStateManager& mgr)
{
return;
if (!GetActive())
return;
@ -114,6 +116,8 @@ void CAmbientAI::Think(float dt, CStateManager& mgr)
void CAmbientAI::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
return;
switch(msg)
{
case EScriptObjectMessage::Reset:

View File

@ -10,6 +10,7 @@ CEntity::CEntity(TUniqueId uniqueId, const CEntityInfo& info, bool active, std::
x20_conns(info.GetConnectionList())
{
x30_24_active = active;
x30_27_inUse = x4_areaId != kInvalidAreaId;
}
void CEntity::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr)

View File

@ -1183,7 +1183,8 @@ void CGameArea::PostConstructArea()
{
athena::io::MemoryReader r(secIt->first, secIt->second);
CAssetId pathId = r.readUint32Big();
x12c_postConstructed->x10ac_path = g_SimplePool->GetObj(SObjectTag{FOURCC('PATH'), pathId});
x12c_postConstructed->x10ac_pathToken = g_SimplePool->GetObj(SObjectTag{FOURCC('PATH'), pathId});
x12c_postConstructed->x10bc_pathArea = x12c_postConstructed->x10ac_pathToken.GetObj();
++secIt;
}

View File

@ -219,9 +219,9 @@ public:
TUniqueId x4_uid = kInvalidUniqueId;
} xa8_pvsEntityMap[1024];
u32 x10a8_pvsVersion = 0;
TLockedToken<CPFArea> x10ac_path;
TLockedToken<CPFArea> x10ac_pathToken;
// bool x10b8_ = 0; optional flag for CToken
u32 x10bc_ = 0;
CPFArea* x10bc_pathArea = nullptr;
std::unique_ptr<CAreaObjectList> x10c0_areaObjs;
std::unique_ptr<CAreaFog> x10c4_areaFog;
const u8* x10c8_sclyBuf = nullptr;

View File

@ -107,7 +107,7 @@ private:
u32 x70_ = 0;
u32 x74_ = 0;
pas::ESeverity x7c_severity = pas::ESeverity::One;
std::bitset<4> x80_availableStates;
std::bitset<5> x80_availableStates;
union
{
struct
@ -157,6 +157,7 @@ public:
void SetX82_24(bool b) { x82_24_ = b; }
const KnockBackParms& GetActiveParms() const { return x4_activeParms; }
EKnockBackVariant GetVariant() const { return x0_variant; }
float GetFlinchRemTime() const { return x64_flinchRemTime; }
};
}

View File

@ -47,6 +47,7 @@ public:
bool SegmentOver(const zeus::CVector3f& p1) const;
void GetSplinePoint(zeus::CVector3f& pOut, const zeus::CVector3f& p1) const;
void GetSplinePointWithLookahead(zeus::CVector3f& pOut, const zeus::CVector3f& p1, float lookahead) const;
void SetArea(CPFArea* area) { x0_area = area; }
};
}

View File

@ -1790,4 +1790,12 @@ void CPatterned::PhazeOut(CStateManager& mgr)
x450_bodyController->SetPlaybackRate(0.f);
x64_modelData->AnimationData()->GetParticleDB().SetUpdatesEnabled(false);
}
bool CPatterned::ApplyBoneTracking() const
{
if (x400_25_alive)
return x460_knockBackController.GetFlinchRemTime() <= 0.f;
return false;
}
}

View File

@ -331,6 +331,8 @@ public:
zeus::CTransform GetLctrTransform(std::string_view name) const;
zeus::CTransform GetLctrTransform(CSegId id) const;
bool ApplyBoneTracking() const;
void DeathDelete(CStateManager& mgr);
void Death(CStateManager& mgr, const zeus::CVector3f& direction, EScriptObjectState state);
void KnockBack(const zeus::CVector3f&, CStateManager&, const CDamageInfo& info,

View File

@ -64,6 +64,7 @@ public:
float GetHalfExtent() const { return xc4_halfExtent; }
float GetHeight() const { return xc8_height; }
u32 GetParticle1Frames() const { return x10c_particle1Frames; }
};
}

View File

@ -170,6 +170,8 @@ CScriptGunTurret::CScriptGunTurret(TUniqueId uid, std::string_view name, ETurret
if (comp == ETurretComponent::Base && HasModelData() && GetModelData()->HasAnimData())
ModelData()->EnableLooping(true);
const_cast<TToken<CWeaponDescription>*>(&x37c_projectileInfo.Token())->Lock();
}
void CScriptGunTurret::Accept(IVisitor& visitor)
@ -409,9 +411,13 @@ void CScriptGunTurret::sub80217408(CStateManager&)
}
void CScriptGunTurret::sub802172b8(CStateManager&)
void CScriptGunTurret::sub802172b8(CStateManager& mgr)
{
auto pair = ModelData()->AnimationData()->GetCharacterInfo().GetPASDatabase().FindBestAnimation(CPASAnimParmData(23),
*mgr.GetActiveRandom(),
-1);
if (pair.first > 0.f)
ModelData()->AnimationData()->AddAdditiveAnimation(pair.second, 1.f, false, true);
}
void CScriptGunTurret::AddToRenderer(const zeus::CFrustum& frustum, const CStateManager& mgr)
@ -967,14 +973,72 @@ void CScriptGunTurret::sub80217f5c(float dt, CStateManager& mgr)
}
}
void CScriptGunTurret::sub80216288(float)
void CScriptGunTurret::sub80216288(float dt)
{
x510_ += dt;
float angleDiff2D = zeus::CVector2f::getAngleDiff(x514_.toVec2f(), GetTransform().frontVector().toVec2f());
if (x560_30_ && angleDiff2D < zeus::degToRad(20.f) && (x520_ == 9 || x520_ == 10))
{
if (!x560_25_)
CSfxManager::AddEmitter(x2d4_data.x82_, GetTranslation(), zeus::CVector3f::skUp, false, false, 127,
GetAreaIdAlways());
x560_30_ = false;
}
if (x510_ >= 0.5f && !x560_25_)
{
if (x520_ == 9 || x520_ == 10 || x520_ == 12)
{
bool res = sub80217c24(dt);
if (!res && !x50c_)
x50c_ = CSfxManager::AddEmitter(x2d4_data.x7c_, GetTranslation(), zeus::CVector3f::skUp, false, true,
127, GetAreaIdAlways());
else if (res && x50c_)
{
CSfxManager::RemoveEmitter(x50c_);
x50c_.reset();
x510_ = 0.f;
}
if (x50c_)
{
float bendScale = dt * x2d4_data.x28_;
CSfxManager::PitchBend(x50c_,
std::max(1.f, 8192.f * (bendScale > 0.f ? angleDiff2D / bendScale : 0.f)) +
8192);
}
}
}
else if (x560_25_ && x50c_)
{
CSfxManager::RemoveEmitter(x50c_);
x50c_.reset();
}
x514_ = GetTransform().frontVector();
}
void CScriptGunTurret::sub80217124(CStateManager&)
void CScriptGunTurret::sub80217124(CStateManager& mgr)
{
if (x520_ == 10)
{
if (x55c_ != -1)
return;
auto pair = ModelData()->AnimationData()->GetCharacterInfo().GetPASDatabase().FindBestAnimation(
CPASAnimParmData(24, CPASAnimParm::FromEnum(2)), *mgr.GetActiveRandom(), -1);
if (pair.first > 0.f)
{
x55c_ = pair.second;
ModelData()->AnimationData()->AddAdditiveAnimation(pair.second, 1.f, true, false);
}
}
else if (x55c_ != -1)
{
ModelData()->AnimationData()->DelAdditiveAnimation(x55c_);
x55c_ = -1;
}
}
void CScriptGunTurret::sub80218830(float dt, CStateManager& mgr)
@ -1010,9 +1074,43 @@ void CScriptGunTurret::sub80218830(float dt, CStateManager& mgr)
}
}
void CScriptGunTurret::sub80216594(CStateManager&)
void CScriptGunTurret::sub80216594(CStateManager& mgr)
{
if (x560_27_)
{
u32 r0 = 1;
if (mgr.GetPlayer().GetMorphballTransitionState() != CPlayer::EPlayerMorphBallState::Morphed)
{
zeus::CVector3f frontVec = GetTransform().frontVector();
zeus::CVector3f plFrontVec = mgr.GetPlayer().GetTransform().frontVector();
float dot = frontVec.dot(plFrontVec);
if (dot > 0.f)
r0 = 0;
}
bool r29 = r0 != 0;
u32 r3 = mgr.GetActiveRandom()->Range(0, 3);
r3 += 2;
if (r3 > 2 && x2d4_data.x98_ < 3)
r0 = 0;
else if (r3 > 5 || r3 > 3)
r0 = 2;
else
r0 = 1;
x3a4_burstFire.SetBurstType(r0 + r29);
}
else
{
u32 r3 = x2d4_data.x90_ - 2;
x3a4_burstFire.SetBurstType(r3);
x3a4_burstFire.xc_ = x2d4_data.x94_;
}
x3a4_burstFire.Start(mgr);
x560_26_ = false;
x560_27_ = true;
}
bool CScriptGunTurret::sub80217950(CStateManager& mgr)
@ -1023,5 +1121,10 @@ bool CScriptGunTurret::sub80217950(CStateManager& mgr)
return false;
}
bool CScriptGunTurret::sub80217c24(float)
{
return zeus::CVector2f::getAngleDiff(x514_.toVec2f(), GetTransform().frontVector().toVec2f()) < zeus::degToRad(20.f);
}
}

View File

@ -1,5 +1,7 @@
#pragma once
#include <Runtime/Weapon/CBurstFire.hpp>
#include "CPhysicsActor.hpp"
#include "CDamageInfo.hpp"
#include "CDamageVulnerability.hpp"
@ -118,7 +120,7 @@ private:
float x4f8_ = 0.f;
zeus::CVector3f x4fc_;
u8 x508_gunSDKSeg = 0xFF;
CSfxHandle x50c_ = 0;
CSfxHandle x50c_;
float x510_ = 0.f;
zeus::CVector3f x514_;
s32 x520_ = -1;
@ -190,7 +192,7 @@ public:
void sub80218830(float, CStateManager&);
void sub80216594(CStateManager&);
bool sub80217950(CStateManager&);
bool sub80217c24(float);
};
}

View File

@ -832,14 +832,14 @@ CEntity* ScriptLoader::LoadNewIntroBoss(CStateManager& mgr, CInputStream& in, in
CActorParameters actParms = LoadActorParameters(in);
float f1 = in.readFloatBig();
u32 w1 = in.readUint32Big();
CAssetId w1(in);
CDamageInfo dInfo(in);
u32 w2 = in.readUint32Big();
u32 w3 = in.readUint32Big();
u32 w4 = in.readUint32Big();
u32 w5 = in.readUint32Big();
CAssetId w2(in);
CAssetId w3(in);
CAssetId w4(in);
CAssetId w5(in);
const CAnimationParameters& aParms = pInfo.GetAnimationParameters();
FourCC animType = g_ResFactory->GetResourceTypeById(aParms.GetACSFile());