Skip to content

Commit

Permalink
set aiPolicy in npc constructor
Browse files Browse the repository at this point in the history
fixes a non-working isPlayer check
  • Loading branch information
thokkat committed Jan 28, 2025
1 parent 4f8828c commit 732807a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions game/world/objects/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<zenkit::INpc>();
Expand Down
2 changes: 1 addition & 1 deletion game/world/objects/npc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions game/world/world.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Npc>(*this,id,waypoint);
auto npc = std::make_unique<Npc>(*this,id,waypoint,Npc::ProcessPolicy::Player);
npcPlayer = wobj.insertPlayer(std::move(npc),waypoint);
npcPlayer->setProcessPolicy(Npc::ProcessPolicy::Player);
game.script()->setInstanceNPC("HERO",*npcPlayer);
}

Expand Down
2 changes: 2 additions & 0 deletions game/world/worldobjects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ 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();
if(owner.version().game==2)
owner.script().invokeRefreshAtInsert(*npc);

npcArr.emplace_back(npc);
return npc;
Expand Down

0 comments on commit 732807a

Please sign in to comment.