#include "python_runtime.h" #include "python_gameplay_modules.h" #include "eter_net/PythonNetworkStream.h" #include "eter_net/NetworkActorManager.h" #include "eter_render/RaceData.h" #include "eter_render/CRenderTarget.h" #include "eter_effect/FlyingManager.h" #include "eter_render/MapObjectManager.h" #include "test_rundir.h" #include #include #include #include #include #include #include using namespace ava2; namespace fs=std::filesystem; static uint32_t motionRandom=0,motionRandomCalls=0; static uint32_t RandomMotion() {++motionRandomCalls;return motionRandom;} static uint32_t motionClock=1000; static uint32_t Clock() {return motionClock;} static uint32_t shakeRandomCalls=0; static uint32_t ShakeRandom() {static const uint32_t values[]={0,3,1,4,0,5};return values[(shakeRandomCalls++)%6];} static void require(bool ok,const char* why) {if(!ok) throw std::runtime_error(why);} int main(int argc,char** argv) { if(argc!=2) return 2; const auto previous=fs::current_path(); if(!ava2_test::EnterTestRunDir()) return ava2_test::kSkip; const auto stdlib=fs::absolute(argv[1]); const auto model=fs::absolute("ymir work/pc/warrior/warrior_assasin1.gr2"); const auto gateModel=fs::absolute("ymir work/zone/a/building/a1-middledam-01.gr2"); const auto gateAttribute=fs::absolute("ymir work/zone/a/building/a1-middledam-01.mdatr"); const auto animation=fs::absolute("ymir work/pc/warrior/general/wait.gr2"); const std::array variantAnimations={animation,fs::absolute("ymir work/pc/warrior/general/walk.gr2"),fs::absolute("ymir work/pc/warrior/general/run.gr2")}; if(!fs::exists(model) || !fs::exists(animation) || !fs::exists(variantAnimations[1]) || !fs::exists(variantAnimations[2])) return ava2_test::kSkip; const auto root=fs::temp_directory_path()/("ava2-motion-"+std::to_string(std::chrono::steady_clock::now().time_since_epoch().count())); try { fs::create_directories(root);fs::current_path(root); auto* race=RaceManager::Instance().CreateRace(1);race->RegisterMotionMode(1); for(uint16_t index=1;index<=RaceData::NAME_JOY;++index) { const auto path=root/(std::to_string(index)+".msa"); std::ofstream(path)<<"ScriptType MotionData\nMotionFileName \""<RegisterMotion(1,index,path.string(),100),"synthetic motion registration"); } std::ofstream(root/"skillgate.txt")<<"type active\nname Gate\niconfilename icon.dds\nneedspformula 1\nmotionindex 1\n"; std::weak_ptr preview; { PythonRuntime python(stdlib,root);auto& net=PythonNetworkStream::Instance();auto& actors=NetworkActorManager::Instance(); preview=CRenderTargetManager::Instance().CreateRenderTarget(12345); actors.Clear();net.SetPhase(PHASE_GAME);net.SetMainActorVID(10); SNetworkActorData main{};main.m_dwVID=10;main.m_dwRace=1;main.m_bType=6; SNetworkActorData target=main;target.m_dwVID=20;target.m_stName="MotionTarget"; actors.AppendActor(main);actors.AppendActor(target); auto actor=actors.GetActorInstance(10);auto victim=actors.GetActorInstance(20); require(actor && victim && actor->SetModel(model.string()) && victim->SetModel(model.string()),"GR2 motion fixture"); actor->SetHP(1000);victim->SetHP(1000);actor->SetPosition(0,0,0);victim->SetPosition(100,0,0); require(actor->SetLoopMotionIndex(RaceData::NAME_WAIT),"wait motion fixture"); python.execute("import player,net\nclass W:\n def __init__(self): self.fail=0\n def OnFishingFailure(self): self.fail+=1\nw=W()\nnet.SetPhaseWindow(net.PHASE_WINDOW_GAME,w)\nplayer.SetGameWindow(w)\n"); python.execute("import skill\nskill.RegisterSkill(220,'skillgate.txt')\n");SetPlayerSkill(30,220);SetPlayerSkillLevel(220,0,1);SetPlayerStatusPoint(7,100); require(actor->InterceptMotionIndex(RaceData::NAME_SKILL,false) && actor->CanUseSkill(),"cancel-enabled current skill fixture"); net.ClearSendQueue();ClickSkillSlot(30);require(net.GetSendQueue().empty(),"ClickSkillSlot bypassed original second IsUsingSkill gate"); require(actor->SetLoopMotionIndex(RaceData::NAME_WAIT),"restore wait after skill gate"); auto motion=[&](uint32_t index) {require(uint32_t(actor->GetCurrentMotion())==index,"incorrect current motion");}; auto next=[&]() {actor->Update(actor->GetMotionDuration()+0.01f);}; auto fishing=[&](uint8_t subtype,uint32_t vid=10,uint8_t dir=0) { const uint8_t packet[]={89,subtype,uint8_t(vid),uint8_t(vid>>8),uint8_t(vid>>16),uint8_t(vid>>24),dir}; net.PushRecvData(packet,sizeof(packet));net.ProcessRecvData(); }; fishing(2);next();motion(RaceData::NAME_WAIT); // React ignored outside WAIT/REACT fishing motions. fishing(0,10,18);require(actor->GetYaw()==90,"fishing direction is not BYTE*5"); require(!actor->IsFishing(),"queued throw treated as fishing");next();motion(RaceData::NAME_FISHING_THROW); require(!actor->IsFishing(),"throw treated as fishing"); fishing(1);next();motion(RaceData::NAME_FISHING_WAIT);require(actor->IsFishing(),"wait not fishing"); fishing(2);next();motion(RaceData::NAME_FISHING_REACT);require(actor->IsFishing(),"react not fishing"); next();motion(RaceData::NAME_FISHING_WAIT); fishing(1);motion(RaceData::NAME_FISHING_STOP);require(!actor->IsFishing(),"stop remains fishing");next();motion(RaceData::NAME_WAIT); fishing(0);next();next();motion(RaceData::NAME_FISHING_WAIT); fishing(3);motion(RaceData::NAME_FISHING_CATCH);next();motion(RaceData::NAME_WAIT); fishing(4);motion(RaceData::NAME_FISHING_FAIL);python.execute("assert w.fail==1\n");next();motion(RaceData::NAME_WAIT); fishing(4,20);python.execute("assert w.fail==1\n"); // Remote failure does not call local UI. fishing(0,999);motion(RaceData::NAME_WAIT); uint8_t dig[]={134,10,0,0,0,20,0,0,0,3}; net.PushRecvData(dig,5);net.ProcessRecvData();next();motion(RaceData::NAME_WAIT); net.PushRecvData(dig+5,5);net.ProcessRecvData();require(std::abs(actor->GetYaw()-90)<0.001f,"dig target facing"); for(int count=0;count<3;++count) {next();motion(RaceData::NAME_DIG);} next();motion(RaceData::NAME_WAIT); // Exactly the received count, no extra repetition. for(uint32_t start:{uint32_t(RaceData::NAME_KISS_START),uint32_t(RaceData::NAME_FRENCH_KISS_START)}) { for(uint32_t job=0;job<4;++job) { require(actor->InterceptMotionIndex(start+job,false),"kiss motion fixture"); python.execute("assert player.IsActingEmotion()==1\n"); next();python.execute("assert player.IsActingEmotion()==0\n"); } } for(uint32_t index:{uint32_t(RaceData::NAME_CLAP),uint32_t(RaceData::NAME_DANCE_1),uint32_t(RaceData::NAME_DIG),uint32_t(RaceData::NAME_SLAP_HIT_START)}) { require(actor->InterceptMotionIndex(index,false),"nonkiss fixture");python.execute("assert player.IsActingEmotion()==0\n"); } // Original dual-emotion scheduler: 500ms delay, 100-unit approach, high/low roles. auto* secondRace=RaceManager::Instance().CreateRace(2);secondRace->RegisterMotionMode(1); for(uint16_t index=1;index<=RaceData::NAME_JOY;++index)require(secondRace->RegisterMotion(1,index,(root/(std::to_string(index)+".msa")).string(),100),"second job motions"); require(victim->SetRace(2) && victim->SetModel(model.string()),"second job model"); actors.GetActorData(20)->m_dwRace=2; actor->SetLoopMotionIndex(RaceData::NAME_WAIT);victim->SetLoopMotionIndex(RaceData::NAME_WAIT); actor->SetPosition(0,0,0);victim->SetPosition(500,0,0);actor->SetSpeed(100); actors.SetTimeSourceForTest(Clock);motionClock=1000; net.ServerCommand("kiss 10 20");require(actors.IsEmotionProcessing(),"main emotion processing not started"); require(!actors.BeginDualEmotion(10,20,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START),"overlapping pair accepted"); SetPlayerJoystick(true,1,0);float yaw=0;require(!GetPlayerMovementYaw(0,yaw),"movement input not blocked during approach"); actor->SetMoveTarget(999,999);require(!actor->HasMoveTarget(),"click movement bypassed emotion lock"); actor->MoveInDirection(90,1);require(actor->GetX()==0,"direct movement bypassed lock"); SNetworkMoveActorData move{};move.m_dwVID=10;move.m_dwFunc=0;move.m_lPosX=700;move.m_lPosY=0; actors.MoveActor(move);motionClock=1499;actors.Update(0); require(actor->GetX()==0 && victim->GetX()==500,"emotion started before deadline/network move escaped lock"); motionClock=1500;actors.Update(0);require(actor->GetX()==0 && actor->GetCurrentMotion()==MotionType::Run,"approach not started at deadline"); actors.Update(1);require(actor->GetX()==100 && actors.IsEmotionProcessing(),"approach teleported or unlocked early"); for(int step=0;step<3;++step)actors.Update(1); require(actor->GetX()==400 && victim->GetX()==500 && !actors.IsEmotionProcessing(),"dual spacing/completion"); require(uint32_t(actor->GetCurrentMotion())==RaceData::NAME_KISS_START+2 && uint32_t(victim->GetCurrentMotion())==RaceData::NAME_KISS_START+1,"dual job selection"); require(std::abs(actor->GetYaw()-90)<0.001f && std::abs(victim->GetYaw()-270)<0.001f,"dual mutual facing"); require(!GetPlayerMovementYaw(0,yaw),"movement unlocked during kiss playback"); actors.Update(actor->GetMotionDuration()+0.01f);actors.Update(0); require(actor->GetCurrentMotion()==MotionType::Wait && GetPlayerMovementYaw(0,yaw),"emotion input did not recover"); // Stop packets resume after playback instead of getting discarded. require(actors.GetActorData(10)->m_lDstX==700,"deferred movement was discarded"); SetPlayerJoystick(false,0,0); actor->SetPosition(400,0,0);victim->SetPosition(500,0,0);motionClock=2000; net.ServerCommand("slap 10 20");motionClock=2500;actors.Update(0); require(uint32_t(actor->GetCurrentMotion())==RaceData::NAME_SLAP_HIT_START+2 && uint32_t(victim->GetCurrentMotion())==RaceData::NAME_SLAP_HURT_START+1,"MAKELONG slap roles reversed"); actors.Update(actor->GetMotionDuration()+0.01f); // Clock rollover and coincident positions must remain finite. actor->SetPosition(0,0,0);victim->SetPosition(0,0,0);motionClock=0xffffff00; net.ServerCommand("french_kiss 10 20");motionClock+=499;actors.Update(0);require(actors.IsEmotionProcessing(),"rollover deadline early"); ++motionClock;actors.Update(0);require(!actors.IsEmotionProcessing() && std::isfinite(actor->GetX()) && std::isfinite(actor->GetZ()),"coincident pair/rollover invalid"); actors.Update(actor->GetMotionDuration()+0.01f);motionClock=3000; net.ServerCommand("kiss 10 20");actors.RemoveActor(20); require(!actors.IsEmotionProcessing() && !actor->IsEmotionMovementLocked(),"deleted target left input locked"); require(!actors.BeginDualEmotion(10,10,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START),"self pair accepted"); SNetworkActorData third=main;third.m_dwVID=30;third.m_dwRace=2; actors.AppendActor(third);auto thirdActor=actors.GetActorInstance(30); require(thirdActor->SetModel(model.string()),"main target model");thirdActor->SetPosition(500,0,0); net.SetMainActorVID(30);motionClock=3500; require(actors.BeginDualEmotion(10,30,RaceData::NAME_KISS_START,RaceData::NAME_KISS_START) && actors.IsEmotionProcessing(),"target main not locked"); actors.RemoveActor(10); require(!actors.IsEmotionProcessing() && !thirdActor->IsEmotionMovementLocked(),"source removal left main target locked"); actors.SetTimeSourceForTest(nullptr); // AVA2 GetRandomMotionKey: cumulative BYTE percentages, never normalized. auto* variants=RaceManager::Instance().CreateRace(779);variants->RegisterMotionMode(1); std::array durations{}; for(int index=0;index<3;++index) { auto parsed=gr2::File::load_path(variantAnimations[index].string(),nullptr); require(parsed && !parsed->file_info().animations.empty(),"original variant GR2");durations[index]=parsed->file_info().animations[0].duration; const auto path=root/("variant"+std::to_string(index)+".msa"); std::ofstream(path)<<"ScriptType MotionData\nMotionFileName \""<RegisterMotion(1,RaceData::NAME_WAIT,path.string(),index==0?15:index==1?25:60),"variant registration"); } require(variants->RegisterMotion(1,RaceData::NAME_DAMAGE,(root/"1.msa").string(),100),"speed motion registration"); ActorInstance weighted;require(weighted.SetRace(779) && weighted.SetModel(model.string()),"weighted motion model"); weighted.SetMotionRandomSourceForTest(RandomMotion); auto checkVariant=[&](unsigned expected) { require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"weighted loop"); require(weighted.GetCurrentRaceMotionData() && weighted.GetCurrentRaceMotionData()->motionDuration==float(expected+1),"events bound to wrong variant"); require(weighted.GetCurrentRaceMotionData()->motionFileName==variantAnimations[expected].string(),"variant metadata path"); require(std::abs(weighted.GetMotionDuration()-std::max(0.1f,durations[expected]))<0.0001f,"GR2 differs from bound event variant"); }; for(motionRandom=0;motionRandom<100;++motionRandom)checkVariant(motionRandom<15?0:motionRandom<40?1:2); variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,0,0);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,1,20);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,2,0); motionRandom=19;checkVariant(1);motionRandom=20;checkVariant(0);motionRandom=99;checkVariant(0); // Uncovered probability falls back to sub-index 0. variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,0,80);variants->SetMotionRandomWeight(1,RaceData::NAME_WAIT,1,80); motionRandom=79;checkVariant(0);motionRandom=80;checkVariant(1);motionRandom=99;checkVariant(1); // Mode resolution and variant selection happen once when a queued motion binds. weighted.SetLoopMotionIndex(RaceData::NAME_WAIT,2);weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"explicit loop speed ignored"); auto calls=motionRandomCalls;require(weighted.PushMotionIndex(RaceData::NAME_DAMAGE,false,0.5f),"queued speed motion"); require(motionRandomCalls==calls,"queued motion sampled before activation"); weighted.Update(weighted.GetMotionDuration()/2+0.01f);require(weighted.GetCurrentMotion()==MotionType::Damage,"queued motion not activated"); weighted.Update(0.1f);require(std::abs(weighted.GetAnimTime()-0.05f)<0.0001f,"queued speed lost"); require(weighted.PushMotionIndex(RaceData::NAME_WAIT,true,2),"queued loop speed"); weighted.Update(weighted.GetMotionDuration()/0.5f+0.01f);require(motionRandomCalls==calls+1,"queued loop did not sample exactly once"); weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"queued loop speed lost"); const auto before=weighted.GetAnimTime();require(!weighted.InterceptMotionIndex(RaceData::NAME_DAMAGE,false,0) && weighted.GetAnimTime()==before,"invalid speed changed state"); require(weighted.InterceptMotionIndex(RaceData::NAME_DAMAGE,false,2),"explicit intercept speed");weighted.Update(0.01f); require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"intercept speed ignored"); for(int cancel=0;cancel<2;++cancel) { const auto path=root/("skillcancel"+std::to_string(cancel)+".msa"); std::ofstream(path)<<"MotionFileName \""<RegisterMotion(1,RaceData::NAME_SKILL+cancel,path.string(),100),"cancel skill motion registration"); require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+cancel,false),"cancel skill motion bind"); require(weighted.CanUseSkill()==bool(cancel),"LoopCancelEnable not used for skill permission"); } weighted.Stun();require(!weighted.CanUseSkill(),"stunned cancellable skill accepted");weighted.Revive(); require(weighted.CanUseSkill(),"revived cancellable skill locked"); // Real GR2 loop playback consumes queued actor/position flight targets, // then restores the original primary; no inspection-only queue assertion. const auto flightLoop=root/"flightloop.msa"; std::ofstream(flightLoop)<<"MotionFileName \""<RegisterMotion(1,RaceData::NAME_SKILL+5,flightLoop.string(),100),"flight loop motion registration"); SNetworkActorData flightVictim=third;flightVictim.m_dwVID=31;actors.AppendActor(flightVictim); weighted.ClearFlyTarget();weighted.SetFlyTarget(30);weighted.AddFlyTarget(31);weighted.AddFlyTarget(123,45,678); require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false,uint32_t(270),1),"flight loop bind"); weighted.Update(0.11f);require(weighted.GetFlyTargetVID()==31,"first queued flight not consumed"); weighted.Update(0.11f);float flightPosition[3]; require(weighted.GetFlyTargetVID()==0 && weighted.GetFlyTargetPosition(flightPosition) && flightPosition[0]==123 && flightPosition[1]==45 && flightPosition[2]==678,"position flight queue/order"); weighted.Update(weighted.GetMotionDuration()+0.01f);require(weighted.GetFlyTargetVID()==30,"flight primary not restored"); weighted.ClearFlyTarget();require(!weighted.HasFlyTarget(),"flight clear retained backup");actors.RemoveActor(31); require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"shoot damage wait fixture"); const int hpBeforeShoot=weighted.GetHP();weighted.OnShootDamage(); require(weighted.GetCurrentMotion()==MotionType::Damage && weighted.GetHP()==hpBeforeShoot,"shoot damage motion/HP mismatch"); weighted.Update(weighted.GetMotionDuration()+0.01f);require(weighted.GetCurrentMotion()==MotionType::Wait,"shoot damage did not queue wait"); require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false),"shoot locked skill fixture"); weighted.OnShootDamage();require(uint32_t(weighted.GetCurrentMotion())==RaceData::NAME_SKILL+5,"shoot damage interrupted locked skill"); require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+1,false),"shoot cancellable skill fixture"); weighted.OnShootDamage();require(weighted.GetCurrentMotion()==MotionType::Damage,"shoot reaction ignored cancel-enabled skill"); weighted.Stun();weighted.OnShootDamage();require(weighted.IsDead(),"shoot damage on stunned actor did not die");weighted.Revive(); // MSA FLY event -> live object tracking -> actor damage reaction and skill callback. const auto flightScript=root/"tracking.msf",flightMotion=root/"tracking.msa"; std::ofstream(flightScript)<<"InitialVelocity 1000\nRange 10000\nBombRange 5\nHomingFlag 1\nHomingMaxAngle 181\n"; std::ofstream(flightMotion)<<"MotionFileName \""<RegisterMotion(1,RaceData::NAME_SKILL+6,flightMotion.string(),100),"tracking motion registration"); SNetworkActorData liveFlightTarget=main;liveFlightTarget.m_dwVID=31;actors.AppendActor(liveFlightTarget); auto liveTarget=actors.GetActorInstance(31);require(liveTarget->SetModel(model.string()) && liveTarget->SetLoopMotionIndex(RaceData::NAME_WAIT),"tracking target model"); liveTarget->SetPosition(100,0,0);weighted.SetPosition(0,0,0);weighted.SetFlyTarget(31); unsigned shots=0,explosions=0;weighted.SetFlyEventHandler({{},[&](uint32_t skill){require(skill==270,"shoot skill identity");++shots;},[&](uint32_t skill){require(skill==270,"hit skill identity");++explosions;}}); auto& flying=FlyingManager::Instance();flying.DeleteAllInstances(); require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+6,false,uint32_t(270),1),"tracking FLY bind"); weighted.Update(0.04f);require(shots==1 && flying.GetActiveInstanceCount()==1,"MSA FLY did not spawn"); liveTarget->SetPosition(200,0,0);flying.Update(0.3f,0.3f); require(explosions==1 && flying.GetActiveInstanceCount()==0 && liveTarget->GetCurrentMotion()==MotionType::Damage,"FLY live target/reaction/callback chain"); flying.Update(0.3f,0.6f);require(explosions==1,"FLY hit callback repeated"); // Source primary CG51, like extra CG53, carries graphic Y (negative game Y). auto* primaryRace=RaceManager::Instance().GetRaceDataPointer(1); require(primaryRace->RegisterMotion(1,RaceData::NAME_SKILL+10,flightMotion.string(),100) && primaryRace->SetMotionRandomWeight(1,RaceData::NAME_SKILL+10,0,0),"primary packet FLY fixture"); auto sender=actors.GetActorInstance(30);require(sender->SetRace(1) && sender->SetModel(model.string()) && sender->SetLoopMotionIndex(RaceData::NAME_WAIT),"primary packet actor fixture"); liveTarget->SetPosition(200,0,50);ProcessPlayerAttack(0,0,false);sender->SetFlyTarget(31);net.ClearSendQueue(); require(sender->InterceptMotionIndex(RaceData::NAME_SKILL+10,false),"primary packet FLY bind"); require(net.GetSendQueue()==std::vector({51,31,0,0,0,200,0,0,0,206,255,255,255}),"primary fly target graphic Y wire sign"); weighted.ClearFlyEventHandler();weighted.ClearFlyTarget();actors.RemoveActor(31); // Real model OBB proxy: endpoint hits, altitude, yaw and manager background callback. fs::copy_file(model,root/"obstacle.gr2"); MapObjectManager obstacles;require(obstacles.AddObject("obstacle.gr2",500,50,0,30),"flight obstacle model"); const auto& obstacle=obstacles.GetObjects().front();require(obstacle.has_collision,"model collision proxy absent"); const auto& box=obstacle.obb; const float center[3]={box.centerX,box.centerY,box.centerZ}; const float obstacleStart[3]={center[0]-5000,center[1],center[2]},after[3]={center[0]+5000,center[1],center[2]}; const float aboveBox[3]={center[0],center[1]+box.halfExtents[1]+10,center[2]}; require(obstacles.CheckFlyingCollision(obstacleStart,center) && !obstacles.CheckFlyingCollision(aboveBox,aboveBox),"real OBB endpoint/height check"); require(obstacles.CheckMovementCollision(obstacleStart,center,1),"movement passed through a solid box"); require(!obstacles.CheckMovementCollision(aboveBox,aboveBox,1),"overhead movement blocked by flattened box"); const float belowBox[3]={center[0],center[1]-box.halfExtents[1]-40,center[2]}; require(!obstacles.CheckMovementCollision(belowBox,belowBox,30),"movement below a box blocked by its footprint"); ActorInstance overheadWalker;overheadWalker.SetPosition(center[0]-100,center[1]+box.halfExtents[1]+50,center[2]);overheadWalker.SetSpeed(100); overheadWalker.MoveInDirection(90,1,nullptr,&obstacles); require(std::abs(overheadWalker.GetX()-center[0])<0.01f,"actor could not walk above an object footprint"); if(fs::exists(gateModel) && fs::exists(gateAttribute)) { fs::copy_file(gateModel,root/"gate.gr2");fs::copy_file(gateAttribute,root/"gate.mdatr"); MapObjectManager gates; require(gates.AddObject("gate.gr2",66907.429688f,19664.039063f,72199.484375f,30),"reported town gate fixture"); const auto& gate=gates.GetObjects().front(); require(gate.has_authored_planes && gate.collision_planes.size()==6,"town gate authored collision planes missing"); const float entrance[3]={66041.5f,19725.5f,71337.5f},advance[3]={66048.5f,19725.5f,71348.9f}; require(gates.CheckCollision(advance[0],advance[2],30),"reported gate no longer reproduces old solid footprint"); require(!gates.CheckMovementCollision(entrance,advance,30),"authored planes still seal reported gate opening"); ActorInstance gateWalker;gateWalker.SetPosition(entrance[0],entrance[1]-30,entrance[2]);gateWalker.SetSpeed(100); gateWalker.MoveInDirection(31.55f,0.15f,nullptr,&gates); require(std::hypot(gateWalker.GetX()-entrance[0],gateWalker.GetZ()-entrance[2])>14,"actor still stuck at reported gate opening"); gateWalker.SetPosition(entrance[0],entrance[1]-30,entrance[2]); for(int step=0;step<200;++step)gateWalker.MoveInDirection(31.55f,0.1f,nullptr,&gates); require(std::hypot(gateWalker.GetX()-entrance[0],gateWalker.GetZ()-entrance[2])>1999,"actor blocked while crossing entire gate opening"); for(const auto& plane:gate.collision_planes) { float nearWall[3],intoWall[3]; for(int k=0;k<3;++k){nearWall[k]=plane.center[k]+plane.normal[k]*40;intoWall[k]=plane.center[k]+plane.normal[k]*20;} require(gates.CheckMovementCollision(nearWall,intoWall,30),"authored gate wall lost collision"); require(!plane.Intersects(intoWall,nearWall,30,true),"authored plane prevents escaping overlap"); } std::cout<<"Reported town gate opening and all 6 walls verified\n"; } { // A real empty attribute file intentionally disables dummy collisions; // a truncated attribute must retain the existing solid fallback. const char emptyAttribute[22]="AttributeData"; std::ofstream(root/"obstacle.mdatr",std::ios::binary).write(emptyAttribute,22); MapObjectManager emptyObstacles;require(emptyObstacles.AddObject("obstacle.gr2",500,50,0,30),"empty attribute fixture"); require(emptyObstacles.GetObjects().front().has_authored_planes && !emptyObstacles.CheckMovementCollision(obstacleStart,center,30),"empty authored attribute replaced by solid dummy"); std::ofstream(root/"obstacle.mdatr",std::ios::binary).write(emptyAttribute,18); MapObjectManager brokenObstacles;require(brokenObstacles.AddObject("obstacle.gr2",500,50,0,30),"broken attribute fixture"); require(!brokenObstacles.GetObjects().front().has_authored_planes && brokenObstacles.CheckMovementCollision(obstacleStart,center,30),"truncated attribute removed solid collision"); fs::remove(root/"obstacle.mdatr"); } require(!obstacles.CheckFlyingCollision(obstacleStart,after),"OBB changed to continuous sweep instead of source endpoints"); auto collisionData=std::make_shared();collisionData->initial_velocity=100;collisionData->range=10000;collisionData->hit_on_background=true; FlyingInstance obstacleFlight(collisionData,center,after);unsigned obstacleHits=0;FlyCollisionCallbacks collisionCallbacks; collisionCallbacks.onBackground=[&]{++obstacleHits;};obstacleFlight.SetCollisionCallbacks(collisionCallbacks); require(!obstacleFlight.Update(0,0,nullptr,&obstacles) && obstacleHits==1,"real model background dispatch"); // Source shake changes the graphic matrix only; sample once per Actor.Update. weighted.SetPosition(0,0,0);weighted.SetShakeSourcesForTest(Clock,ShakeRandom);motionClock=1000;shakeRandomCalls=0; require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT),"shake wait fixture");weighted.OnShootDamage(); motionClock=1100;weighted.Update(0.01f);auto shaken=weighted.BuildDrawCommands(); require(!shaken.empty() && std::abs(shaken.front().world[12]-3)<0.001f && std::abs(shaken.front().world[13]-5)<0.001f && std::abs(shaken.front().world[14]-4)<0.001f,"source shake axes/amplitude/inclusive deadline"); require(weighted.GetX()==0 && weighted.GetY()==0 && weighted.GetZ()==0 && shakeRandomCalls==6,"shake moved logical position/wrong RNG count"); weighted.BuildDrawCommands();require(shakeRandomCalls==6,"draw sampled shake a second time"); motionClock=1101;weighted.Update(0.01f);auto unshaken=weighted.BuildDrawCommands(); require(!unshaken.empty() && unshaken.front().world[12]==0 && unshaken.front().world[13]==0 && unshaken.front().world[14]==0 && shakeRandomCalls==6,"expired shake not cleared"); motionClock=1200;require(weighted.InterceptMotionIndex(RaceData::NAME_SKILL+5,false),"shake locked skill fixture");weighted.OnShootDamage();weighted.Update(0.01f); require(uint32_t(weighted.GetCurrentMotion())==RaceData::NAME_SKILL+5 && shakeRandomCalls==12,"locked skill did not shake"); motionClock=1301;weighted.Update(0.01f);weighted.Stun();weighted.OnShootDamage();weighted.Update(0.01f); require(weighted.IsDead() && shakeRandomCalls==12,"stunned death started shake");weighted.Revive();weighted.SetShakeSourcesForTest(nullptr,nullptr); // AVA2 IsPoly includes TYPE_PC with a non-player race, as well as TYPE_POLY. weighted.SetActorType(6);require(weighted.IsPolymorph(),"PC monster race not polymorph"); weighted.SetMotionMode(2);require(weighted.GetMotionMode()==1,"polymorph mode not GENERAL"); const auto beforePolyCalls=motionRandomCalls; require(weighted.InterceptMotionIndex(RaceData::NAME_WAIT,false,2),"poly intercept"); require(motionRandomCalls==beforePolyCalls && weighted.GetCurrentRaceMotionData()->motionDuration==1,"poly intercept randomized instead of base key"); weighted.Update(0.1f); require(std::abs(weighted.GetAnimTime()-weighted.GetMotionDuration()*0.2f/1.1f)<0.0001f,"poly 1.1-second scaling missing"); require(weighted.InterceptMotionIndex(RaceData::NAME_WAIT,true),"poly loop intercept"); weighted.Update(0.1f); require(std::abs(weighted.GetAnimTime()-weighted.GetMotionDuration()*0.1f/1.1f)<0.0001f,"poly loop intercept normalization missing"); require(weighted.SetLoopMotionIndex(RaceData::NAME_WAIT,2),"poly ordinary loop"); require(motionRandomCalls==beforePolyCalls+1,"ordinary poly loop incorrectly bypassed random selection"); weighted.Update(0.01f);require(std::abs(weighted.GetAnimTime()-0.02f)<0.0001f,"ordinary poly loop incorrectly normalized"); weighted.SetActorType(0);require(!weighted.IsPolymorph(),"ordinary monster classified as poly"); weighted.SetActorType(7);require(weighted.IsPolymorph(),"TYPE_POLY missing"); require(weighted.SetRace(1),"normal PC classification fixture"); weighted.SetActorType(6);require(!weighted.IsPolymorph(),"normal PC classified as poly"); weighted.SetActorType(7);require(weighted.IsPolymorph(),"explicit poly depends on race"); auto* walkRace=RaceManager::Instance().CreateRace(780);walkRace->RegisterMotionMode(1); require(walkRace->RegisterMotion(1,RaceData::NAME_WAIT,(root/"1.msa").string(),100) && walkRace->RegisterMotion(1,RaceData::NAME_RUN,(root/"1.msa").string(),100),"walking speed race"); SNetworkActorData walker{};walker.m_dwVID=40;walker.m_dwRace=780;walker.m_bType=6;walker.m_dwMovSpd=150;walker.m_dwAtkSpd=175; actors.AppendActor(walker);auto walking=actors.GetActorInstance(40); require(walking->IsPolymorph(),"network PC monster type not propagated"); actors.SetSash(40,123); require(actors.GetActorData(40)->m_dwSash==0,"polymorph PC accepted sash"); require(walking->GetAttackSpeed()==1.75f,"creation attack speed not normalized"); require(walking->SetModel(model.string()) && walking->PlayMotion(MotionType::Run,true),"walking model"); walking->Update(0.1f);require(std::abs(walking->GetAnimTime()-0.15f)<0.0001f,"packet move speed not applied to animation"); SNetworkUpdateActorData speedUpdate{};speedUpdate.m_dwVID=40;speedUpdate.m_dwMovSpd=200; actors.UpdateActor(speedUpdate);require(walking->GetAnimTime()==0,"speed change did not restart move loop"); walking->Update(0.1f);require(std::abs(walking->GetAnimTime()-0.2f)<0.0001f,"live walking speed update ignored"); speedUpdate.m_dwMovSpd=0;actors.UpdateActor(speedUpdate);walking->Update(0.1f); require(walking->GetMoveAnimationSpeed()==0 && walking->GetAnimTime()==0,"zero packet speed not frozen"); SNetworkMoveActorData stoppedMove{};stoppedMove.m_dwVID=40;stoppedMove.m_dwFunc=1;stoppedMove.m_lPosX=500; actors.MoveActor(stoppedMove);actors.Update(0.1f);require(walking->GetX()==0,"zero speed fell back to invented movement"); speedUpdate.m_dwMovSpd=1101;actors.UpdateActor(speedUpdate);require(walking->GetMoveAnimationSpeed()==0,"original overflow-to-zero rule lost"); for(uint32_t speed : {0u,1u,100u,175u,1100u,1101u,0xffffffffu}) { speedUpdate.m_dwAtkSpd=speed;actors.UpdateActor(speedUpdate); require(walking->GetAttackSpeed()==(speed<=1100?float(speed)/100:0),"updated attack speed boundary"); walker.m_dwVID=41;walker.m_dwAtkSpd=speed;walker.m_dwMountVnum=780;actors.AppendActor(walker); require(actors.GetActorInstance(41)->GetAttackSpeed()==walking->GetAttackSpeed(),"creation/update attack speed disagree"); auto* mounted=actors.GetActorData(41); require(mounted && mounted->m_pMountInstance && mounted->m_pMountInstance->GetAttackSpeed()==walking->GetAttackSpeed(),"mount creation attack speed disagree"); auto mountUpdate=speedUpdate;mountUpdate.m_dwVID=41;mountUpdate.m_dwMountVnum=780;mountUpdate.m_dwAtkSpd=200; actors.UpdateActor(mountUpdate); require(mounted->m_pMountInstance && mounted->m_pMountInstance->GetAttackSpeed()==2,"mount update attack speed ignored"); actors.RemoveActor(41); } python.execute("player.SetGameWindow(0)\nnet.ClearPhaseWindow(net.PHASE_WINDOW_GAME,w)\n"); actors.Clear();net.ResetConnection(); } require(preview.expired(),"preview singleton retained runtime-owned resources after shutdown"); require(CRenderTargetManager::Instance().GetFreeIndex(12345,12345)==12345,"preview index not released on shutdown"); fs::current_path(previous);fs::remove_all(root); std::cout<<"AVA2 emotion queries, fishing transitions and digging queues passed\n";return 0; } catch(const std::exception& error) { fs::current_path(previous);fs::remove_all(root);std::cerr<