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
@@ -39,7 +39,7 @@ void TestParse() {
|
||||
assert(Near(a.motionDuration, 1.0f));
|
||||
assert(a.isComboMotion && Near(a.inputStartTime, 1.0f) && Near(a.nextComboTime, 1.0f) && Near(a.inputEndTime, 0.602564f));
|
||||
assert(a.isAttackingMotion && a.motionType == RaceMotionData::MOTION_TYPE_NORMAL);
|
||||
assert(a.attackType == 2 && a.hitLimitCount == 0); // AttackType missing: ATTACK_TYPE_SPLASH
|
||||
assert(a.attackType == 0 && a.hitLimitCount == 0); // AttackType missing: ATTACK_TYPE_SPLASH (0)
|
||||
assert(Near(a.invisibleTime, 0.5f));
|
||||
assert(a.hitData.size() == 1 && a.hitData[0].boneName == "equip_right_hand");
|
||||
assert(Near(a.hitData[0].attackStartTime, 0.456410f) && a.hitData[0].hitPositions.size() == 2);
|
||||
@@ -219,10 +219,59 @@ void TestHitDetection(const char* model) {
|
||||
}
|
||||
}
|
||||
|
||||
void TestMotionEvents() {
|
||||
// LoopData + MotionEventData (sound, special attacking with collision spheres, show/hide).
|
||||
const char* skillMsa =
|
||||
"ScriptType MotionData\n"
|
||||
"MotionFileName \"d:/ymir work/pc/warrior/skill/palbang.gr2\"\n"
|
||||
"MotionDuration 2.0\n"
|
||||
"Group LoopData\n{\n MotionLoopCount 3\n LoopStartTime 0.5\n LoopEndTime 1.25\n}\n"
|
||||
"Group MotionEventData\n{\n MotionEventDataCount 4\n"
|
||||
" Group Event00\n {\n MotionEventType 5\n StartingTime 0.1\n"
|
||||
" SoundFileName \"sound/pc/warrior/palbang.wav\"\n }\n"
|
||||
" Group Event01\n {\n MotionEventType 4\n StartingTime 0.6\n"
|
||||
" DuringTime 0.3\n EnableHitProcess 1\n AttackType 1\n HittingType 3\n"
|
||||
" StiffenTime 0.1\n InvisibleTime 0.2\n ExternalForce 4.0\n HitLimitCount 5\n"
|
||||
" CollisionType 0\n SphereDataCount 1\n"
|
||||
" Group SphereData00\n {\n Radius 150.0\n Position 0.0 -120.0 80.0\n }\n }\n"
|
||||
" Group Event02\n {\n MotionEventType 8\n StartingTime 0.7\n }\n"
|
||||
" Group Event03\n {\n MotionEventType 7\n StartingTime 1.0\n }\n"
|
||||
"}\n";
|
||||
RaceMotionData m;
|
||||
assert(ava2::ParseRaceMotionData(skillMsa, &m));
|
||||
assert(m.isLoopMotion && m.loopCount == 3 && Near(m.loopStartTime, 0.5f) && Near(m.loopEndTime, 1.25f));
|
||||
assert(m.events.size() == 4 && m.hasSplashEvent);
|
||||
assert(m.events[0].type == RaceMotionData::MOTION_EVENT_TYPE_SOUND && m.events[0].frame == 6);
|
||||
assert(m.events[0].fileName == "sound/pc/warrior/palbang.wav");
|
||||
const auto& splash = m.events[1];
|
||||
assert(splash.type == RaceMotionData::MOTION_EVENT_TYPE_SPECIAL_ATTACKING && splash.frame == 36);
|
||||
assert(Near(splash.durationTime, 0.3f) && splash.attackType == 1 && splash.hittingType == 3 && splash.hitLimitCount == 5);
|
||||
assert(splash.spheres.size() == 1 && Near(splash.spheres[0].radius, 150.0f) && Near(splash.spheres[0].position[1], -120.0f));
|
||||
assert(m.events[2].type == RaceMotionData::MOTION_EVENT_TYPE_CHARACTER_HIDE && m.events[3].type == RaceMotionData::MOTION_EVENT_TYPE_CHARACTER_SHOW);
|
||||
|
||||
// An unknown event type fails the whole .msa, like "Strange Event Type".
|
||||
const char* badMsa =
|
||||
"MotionFileName \"x.gr2\"\nMotionDuration 1.0\n"
|
||||
"Group MotionEventData\n{\n MotionEventDataCount 1\n"
|
||||
" Group Event00\n {\n MotionEventType 3\n StartingTime 0.1\n }\n}\n";
|
||||
RaceMotionData bad;
|
||||
assert(!ava2::ParseRaceMotionData(badMsa, &bad));
|
||||
|
||||
// Per-motion .mss sound script.
|
||||
std::vector<RaceMotionData::SoundInstance> sounds;
|
||||
assert(ava2::ParseSoundScriptData(
|
||||
"ScriptType CharacterSoundData\nSoundDataCount 2\n"
|
||||
"SoundData00 0.726000 \"sound/common/walk_dirt_n.wav\"\n"
|
||||
"SoundData01 0.100000 \"sound/common/walk_dirt_1.wav\"\n", &sounds));
|
||||
assert(sounds.size() == 2 && sounds[0].fileName == "sound/common/walk_dirt_n.wav" && sounds[0].frame == 43);
|
||||
assert(!ava2::ParseSoundScriptData("SoundDataCount 1\nSoundData00 0.5\n", &sounds) && sounds.size() == 2);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
TestParse();
|
||||
TestMotionEvents();
|
||||
std::cout << "msa parsing ok\n";
|
||||
if (argc < 2) return 0;
|
||||
if (!ava2_test::EnterTestRunDir()) return ava2_test::kSkip;
|
||||
|
||||
Reference in New Issue
Block a user