Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isPlayer() in Npc::Npc constructor will always be false #722

Open
mmind opened this issue Jan 20, 2025 · 1 comment · May be fixed by #725
Open

isPlayer() in Npc::Npc constructor will always be false #722

mmind opened this issue Jan 20, 2025 · 1 comment · May be fixed by #725
Labels
bug Something isn't working

Comments

@mmind
Copy link
Contributor

mmind commented Jan 20, 2025

The Npc constructor does

  // vanilla behavior: equip best weapon and set non-zero damage type
  if(!isPlayer())
    invent.autoEquipWeapons(*this);

with

bool Npc::isPlayer() const {
  return aiPolicy==Npc::ProcessPolicy::Player;
  }

But npc->setProcessPolicy(...) is only set after the constructor has finished, see

void World::createPlayer(std::string_view cls) {
...
  npcPlayer = wobj.insertPlayer(std::move(npc),waypoint);
  npcPlayer->setProcessPolicy(Npc::ProcessPolicy::Player);
...
  }

So right now all Npcs will not be recognized as player, but this works, because the player has an empty inventory at the beginning of the main games.

@mmind mmind added the bug Something isn't working label Jan 20, 2025
@thokkat thokkat linked a pull request Jan 20, 2025 that will close this issue
@thokkat
Copy link
Contributor

thokkat commented Jan 20, 2025

Good find. I proposed a fix in #725.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants