Port .msa motion events, .mss sounds and skill motions
ParseRaceMotionData now reads LoopData, MotionEventData and the per-motion .mss sound script. ActorInstance runs the events each 1/60 s frame: effects, sounds, splash attacks, fly shots, show/hide and warp. Player skill and guild-skill motions are registered. ClickSkillSlot and remote FUNC_SKILL states play the skill motions, and fly targets are synced with the server (audit P1 #4). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
31c74cec28
commit
f6dfcfc337
@@ -421,6 +421,14 @@ bool ActorInstance::PlayMotion(MotionType type, bool loop) {
|
||||
}
|
||||
|
||||
void ActorInstance::OnMotionBound(uint32_t type) {
|
||||
// __SetMotion: a hidden actor shows again; the motion node restarts at frame 0.
|
||||
m_isHiding = false;
|
||||
m_curFrame = 0;
|
||||
m_frameCount = uint32_t(m_motionDuration * 60.0f);
|
||||
m_curSkill = m_pendingSkill;
|
||||
const int skillLoopCount = m_pendingLoopCount;
|
||||
m_pendingSkill = 0;
|
||||
m_pendingLoopCount = 0;
|
||||
// ActorInstanceMotion.cpp __BindMotionData: the race motion data of the new motion.
|
||||
m_curRaceMotion = nullptr;
|
||||
uint16_t keyMode;
|
||||
@@ -428,6 +436,11 @@ void ActorInstance::OnMotionBound(uint32_t type) {
|
||||
const auto* entries = m_raceData->GetMotions(keyMode, type);
|
||||
if (entries && !entries->empty()) m_curRaceMotion = GetRaceMotionData(entries->front().fileName);
|
||||
}
|
||||
// SetMotionLoopCount(__GetLoopCount()) for once motions; NEW_UseSkill sets the skill's count.
|
||||
m_loopCount = (!m_loopMotion && m_curRaceMotion) ? m_curRaceMotion->loopCount : 0;
|
||||
if (skillLoopCount > 0) m_loopCount = skillLoopCount;
|
||||
// InterceptMotion: the fly event handler picks its target for WARP / FLY / EFFECT_TO_TARGET motions.
|
||||
if (m_flyEventHandler.onSetFlyTarget && IsNeedFlyTargetMotion()) m_flyEventHandler.onSetFlyTarget();
|
||||
if (!m_curRaceMotion) {
|
||||
m_comboIndex = 0;
|
||||
m_motionSpeed = 1.0f;
|
||||
@@ -458,7 +471,10 @@ float ActorInstance::GetDefendingRadius() const {
|
||||
}
|
||||
|
||||
bool ActorInstance::CanCheckAttacking() const {
|
||||
if (!m_curRaceMotion || !m_curRaceMotion->isAttackingMotion || IsMotionFinished()) return false;
|
||||
// isAttacking: isNormalAttacking || isComboAttacking || IsSplashAttacking.
|
||||
if (!m_curRaceMotion || IsMotionFinished()) return false;
|
||||
if (m_curRaceMotion->hasSplashEvent) return true;
|
||||
if (!m_curRaceMotion->isAttackingMotion) return false;
|
||||
return m_curRaceMotion->motionType == RaceMotionData::MOTION_TYPE_NORMAL ||
|
||||
m_curRaceMotion->motionType == RaceMotionData::MOTION_TYPE_COMBO;
|
||||
}
|
||||
@@ -642,6 +658,15 @@ bool ActorInstance::InterceptMotionIndex(uint32_t index, bool loop) {
|
||||
return PlayMotionIndex(index, loop);
|
||||
}
|
||||
|
||||
bool ActorInstance::InterceptMotionIndex(uint32_t index, bool loop, uint32_t skill, int loopCount) {
|
||||
m_pendingSkill = skill;
|
||||
m_pendingLoopCount = loopCount;
|
||||
const bool played = InterceptMotionIndex(index, loop);
|
||||
m_pendingSkill = 0;
|
||||
m_pendingLoopCount = 0;
|
||||
return played;
|
||||
}
|
||||
|
||||
bool ActorInstance::PushMotionIndex(uint32_t index, bool loop) {
|
||||
uint16_t keyMode;
|
||||
if (!m_raceData || !m_raceData->GetMotionKey(uint16_t(m_motionMode), uint16_t(index), &keyMode)) return false;
|
||||
@@ -781,6 +806,16 @@ void ActorInstance::Update(float dt, const TerrainHeightSource* terrain, const M
|
||||
m_animTime += dt * m_motionSpeed;
|
||||
m_localTime += dt;
|
||||
m_lodLocalTime += dt; // CGrannyModelInstance::UpdateLocalTime
|
||||
// MotionProcess: __MotionEventProcess, then CurrentMotionProcess (loop data).
|
||||
m_eventTerrain = terrain;
|
||||
MotionEventProcess();
|
||||
m_eventTerrain = nullptr;
|
||||
const bool looped = CurrentMotionLoopProcess();
|
||||
if (!looped && m_animTime >= m_motionDuration && m_backupFlyTarget.valid) {
|
||||
m_flyTarget = m_backupFlyTarget;
|
||||
m_backupFlyTarget = FlyTarget();
|
||||
}
|
||||
UpdateAttachedEffects();
|
||||
if (!m_motionQueue.empty() && m_animTime >= m_motionDuration) {
|
||||
// ReservingMotionProcess: the next pushed motion takes over when the current one ends.
|
||||
const auto next = m_motionQueue.front();
|
||||
@@ -908,7 +943,7 @@ bool ActorInstance::IsTargetInAttackRange(const ActorInstance& target, float max
|
||||
}
|
||||
|
||||
std::vector<Render3DDraw> ActorInstance::BuildDrawCommands(const float* worldOverride) {
|
||||
if (!m_model) return {};
|
||||
if (!m_model || m_isHiding) return {}; // __HideEvent: alpha 0
|
||||
float world[16];
|
||||
MakeTransformMatrix(m_yaw, m_posX, m_posY + m_modelYOffset * m_scale, m_posZ, m_scale, world);
|
||||
auto draws = DrawModel()->BuildDrawCommands(PoseTime(), worldOverride ? worldOverride : world);
|
||||
@@ -1063,22 +1098,11 @@ bool ActorInstance::HitTestScreen(float clickX, float clickY, const Gr2SceneRend
|
||||
}
|
||||
|
||||
bool ActorInstance::GetBoneWorldTransform(const std::string& boneName, float* outWorld16) const {
|
||||
if (!m_model || !outWorld16) return false;
|
||||
if (!outWorld16) return false;
|
||||
float localBone[16];
|
||||
// A bone the LOD skeleton dropped is still read from PART_MAIN.
|
||||
if (!DrawModel()->GetBoneWorldTransform(boneName, localBone, PoseTime()) &&
|
||||
(DrawModel() == m_model.get() || !m_model->GetBoneWorldTransform(boneName, localBone, PoseTime()))) {
|
||||
return false;
|
||||
}
|
||||
// Bone poses are still Granny Z-up, just like the mesh vertices. Convert
|
||||
// before composing with the engine world matrix (SDK R_GRANNY_TO_ENGINE).
|
||||
for (int row=0;row<4;++row) {
|
||||
const float y=localBone[row*4+1], z=localBone[row*4+2];
|
||||
localBone[row*4+1]=z;
|
||||
localBone[row*4+2]=-y;
|
||||
}
|
||||
if (!GetBoneLocalMatrix(boneName, localBone)) return false;
|
||||
float actorWorld[16];
|
||||
MakeTransformMatrix(m_yaw, m_posX, m_posY + m_modelYOffset * m_scale, m_posZ, m_scale, actorWorld);
|
||||
GetWorldMatrix(actorWorld);
|
||||
|
||||
for (int r = 0; r < 4; ++r) {
|
||||
for (int c = 0; c < 4; ++c) {
|
||||
|
||||
Reference in New Issue
Block a user