-
Notifications
You must be signed in to change notification settings - Fork 86
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
Add some vanilla behavior for npcs #653
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
game/game/gamescript.cpp
Outdated
@@ -1128,6 +1128,14 @@ void GameScript::invokePickLock(Npc& npc, int bSuccess, int bBrokenOpen) { | |||
vm.call_function<void>(fn, bSuccess, bBrokenOpen); | |||
} | |||
|
|||
void GameScript::invokeRefreshAtInsert(Npc& npc) { | |||
auto fn = vm.find_symbol_by_name("B_RefreshAtInsert"); | |||
if(fn==nullptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be good idea to cache function in GameScript
, similar to ItKE_lockpick
, as there will be burst of this calls after "sleep".
I've tested path today: it seems we missing a case, when |
game/world/objects/npc.cpp
Outdated
@@ -169,7 +169,9 @@ Npc::Npc(World &owner, size_t instance, std::string_view waypoint) | |||
owner.script().initializeInstanceNpc(hnpc, instance); | |||
hnpc->wp = std::string(waypoint); | |||
|
|||
// vanilla forces non-zero damage type | |||
// vanilla behavior: equip best weapon and set non-zero damage type | |||
if(!isMonster() && !isPlayer()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more question: isMonster
is truly relevant? For wolfs/snappers should not mater; but maybe relevant for skeletons
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes best weapon autoequip works for skeletons and from what I tested it seems to only work for skeletons. Other monsters just have the weapon in their inventory.
For like a wolf weapon inserted with CreateInvItem
is equipped and visible in OpenGothic, that's why I excluded monsters in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some thinking it's maybe best to prevent weapon equipping for monsters somewhere in the equip function directly in case someone adds a EquipItem
call in script.
Skeleton is detected based on guild in vanilla. Changing the guild of a golem to skeleton resulted in a draw/remove weapon stall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it not directly related to isMonster
would be nice to at least understand how it intended to work.
I've done some testing with marvin - guild by itself seem to be irrelevant. Maybe it's related to npc
having some builtin bones, such as ZS_SWORD
/ZS_RIGHTHAND
?
Can you test what will happen if you assign GIL_SHEEP
to skeleton or "Ske_Body" to sheep, while having weapon in inventory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPD:
Tested by editing Nikolas guild: as GIL_SKELETON
or GIL_SHEEP
he still equips best weapon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GIL_SHEEP to skeleton
Nothing.
"Ske_Body" to sheep
Nothing but if Mdl_SetVisual (self, "HumanS.mds")
with Sheep_Body sword is visible.
For default sheep both Npc_HasEquippedWeapon
and Npc_HasEquippedMeleeWeapon
return true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GIL_SHEEP to skeleton
Nothing.
You mean nothing changed, or skeleton does not equip weapons any more?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing changed.
I've decide to file another ticket for monster/non-monster topic; |
If a npc comes into visibility range:
Best weapons are automatically equipped. For ranged weapons ammo has to be in inventory. From testing turns out this is checked in
equipBestRangedWeapon
. Bartok can be used as test npc.Script function
B_RefreshAtInsert
that restores health is called in G2.Additionally clean up some leftover of 1hp npc handling and setting the damage type to 2 if its default was 0. Needed for the hero in G1. Tested as behaving the same in G2 for some monsters and humans by setting their damage type to 0 in script.
Closes #354