diff --git a/game/game/gamescript.cpp b/game/game/gamescript.cpp index 70154b14..21db2cc7 100644 --- a/game/game/gamescript.cpp +++ b/game/game/gamescript.cpp @@ -1163,7 +1163,7 @@ void GameScript::invokePickLock(Npc& npc, int bSuccess, int bBrokenOpen) { } void GameScript::invokeRefreshAtInsert(Npc& npc) { - if(B_RefreshAtInsert==nullptr) + if(B_RefreshAtInsert==nullptr || owner.version().game!=2) return; ScopeVar self(*vm.global_self(), npc.handlePtr()); vm.call_function(B_RefreshAtInsert); diff --git a/game/world/objects/npc.cpp b/game/world/objects/npc.cpp index 3089cd8f..cf90ce37 100644 --- a/game/world/objects/npc.cpp +++ b/game/world/objects/npc.cpp @@ -156,8 +156,8 @@ struct Npc::TransformBack { }; -Npc::Npc(World &owner, size_t instance, std::string_view waypoint) - :owner(owner),mvAlgo(*this) { +Npc::Npc(World &owner, size_t instance, std::string_view waypoint, ProcessPolicy aiPolicy) + :owner(owner),aiPolicy(aiPolicy),mvAlgo(*this) { outputPipe = owner.script().openAiOuput(); hnpc = std::make_shared(); @@ -490,9 +490,7 @@ bool Npc::resetPositionToTA() { invent.autoEquipWeapons(*this); } - if(g2) - owner.script().invokeRefreshAtInsert(*this); - + owner.script().invokeRefreshAtInsert(*this); return true; } diff --git a/game/world/objects/npc.h b/game/world/objects/npc.h index 636fdd66..b5578240 100644 --- a/game/world/objects/npc.h +++ b/game/world/objects/npc.h @@ -74,7 +74,7 @@ class Npc final { using Anim = AnimationSolver::Anim; - Npc(World &owner, size_t instance, std::string_view waypoint); + Npc(World &owner, size_t instance, std::string_view waypoint, ProcessPolicy aiPolicy = AiNormal); Npc(const Npc&)=delete; ~Npc(); diff --git a/game/world/world.cpp b/game/world/world.cpp index 0080a4e4..8a94c5aa 100644 --- a/game/world/world.cpp +++ b/game/world/world.cpp @@ -130,9 +130,8 @@ void World::createPlayer(std::string_view cls) { if(id==size_t(-1)) return; std::string_view waypoint = wmatrix->startPoint().name; - auto npc = std::make_unique(*this,id,waypoint); - npcPlayer = wobj.insertPlayer(std::move(npc),waypoint); - npcPlayer->setProcessPolicy(Npc::ProcessPolicy::Player); + auto npc = std::make_unique(*this, id, waypoint, Npc::ProcessPolicy::Player); + npcPlayer = wobj.insertPlayer(std::move(npc), waypoint); game.script()->setInstanceNPC("HERO",*npcPlayer); } diff --git a/game/world/worldobjects.cpp b/game/world/worldobjects.cpp index ec966da2..6ce3ab5c 100644 --- a/game/world/worldobjects.cpp +++ b/game/world/worldobjects.cpp @@ -322,6 +322,7 @@ Npc* WorldObjects::addNpc(size_t npcInstance, const Vec3& pos) { Npc* npc = new Npc(owner,npcInstance,pstr); npc->setPosition (pos.x,pos.y,pos.z); npc->updateTransform(); + owner.script().invokeRefreshAtInsert(*npc); npcArr.emplace_back(npc); return npc;