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

Fix a non-working player check #725

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Fix a non-working player check #725

merged 2 commits into from
Jan 29, 2025

Conversation

thokkat
Copy link
Contributor

@thokkat thokkat commented Jan 20, 2025

As described in #722 we don't know if aiPolicy==Player in npc constructor which means best weapon equip has to be done later.

One of the addNpc functions already does this indirectly by calling restPositionToTA. The other one is never called for the player so weapon equip can be done here safely as well. This covers the case when marvin insert command is used which was the original motivation to do this in the constructor, see #653 (comment).

Regarding the mentioned summons, I modified the wolf spell to summon the hero instead. Weapon was equipped while script had only a createInvItem line.

Fixes #722

Copy link
Owner

@Try Try left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @thokkat and thanks for the fix - one of overrides of addNpc appears to be missing.

@@ -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();
npc->autoEquipWeapons();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another override for WorldObjects::addNpc(size_t npcInstance, std::string_view at) seem to be missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it out because this function calls restPositionToTA where it's already done. You want to have it added for consistency with other addNpc function?

Additionally I found thatB_RefreshAtInsert is called as well and added it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to have it added for consistency with other addNpc function?

Ideally, I think, we need to make it robust and leave no room for inconsistency. After giving more thought to it: maybe it's even better to add ProcessPolicy as a parameter to npc constructor. This will make any explicit/implicit use of isPlayer correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@thokkat thokkat force-pushed the fix-weaponAutoEquip branch from 7cb8c7f to 2387ef2 Compare January 25, 2025 17:54
fixes a non-working isPlayer check
@thokkat thokkat force-pushed the fix-weaponAutoEquip branch from 2387ef2 to 732807a Compare January 28, 2025 21:32
@Try Try merged commit 0fb0aa2 into Try:master Jan 29, 2025
1 check was pending
@Try
Copy link
Owner

Try commented Jan 29, 2025

Merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

isPlayer() in Npc::Npc constructor will always be false
2 participants