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

Don't set victim when picking up an item from the floor #735

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmind
Copy link
Contributor

@mmind mmind commented Jan 30, 2025

At least the Gothic 1 script assesses theft differently depending on whether a victim is set or not.

if (npc_canseenpc(self, other)) {
        printdebugnpc(pd_zs_check, "...NSC kann den Dieb sehen!");
        if (hlp_isvaliditem(item) && (!hlp_isvalidnpc(victim))) {
            printdebugnpc(pd_zs_check, "...Item wurde aufgehoben!"); // Item picked up
            ...
        }
        else {
            printdebugnpc(pd_zs_check, "...Taschendiebstahl!"); //pickpocket
            ...
        }

This causes NPC around an item to tell the player that something is getting stolen right now and also indicates that victim is not always set in the perception process.

So adapt the sent passivePerc accordingly to not transmit the player as victim when picking up items.

GameScript::invokeState() already removed the default setting of other=npc for the !other case in commit 3fc5c39 ("damage from faling") as part of the fix for #18, so do the same for the current default victim setting.

This fixes #717.

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, @mmind !

Path looks good to me, but need to be updated due to #736

void World::sendPassivePerc(Npc &self, Npc &other, Npc &victum, int32_t perc) {
wobj.sendPassivePerc(self,other,victum,nullptr,perc);
wobj.sendPassivePerc(self,other,&victum,nullptr,perc);
Copy link
Owner

Choose a reason for hiding this comment

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

Since original assumption about victim cannot be null is now know to be not valid, we also need to update code that call to his function, such as:

// Interactive::implTick
npc.world().sendPassivePerc(npc,npc,npc,PERC_ASSESSUSEMOB);


Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully I caught all of them now.

One interesting decision I had a hard time with, was wether or not to have the World::sendPassivePerc() variants.
Before the victim change, there were two sendPassivePerc variants, hiding the the possible item nullptr from users.

I've gone now with introducing similar variants for victim and victimless variants, but this already increases variants to 4.

The other option would be of course to just add the nullptr when calling World::sentPassivePerc(). I'll defer that to your preference :-) .

At least the Gothic 1 script assesses theft differently depending on whether
a victim is set or not.

if (npc_canseenpc(self, other)) {
        printdebugnpc(pd_zs_check, "...NSC kann den Dieb sehen!");
        if (hlp_isvaliditem(item) && (!hlp_isvalidnpc(victim))) {
            printdebugnpc(pd_zs_check, "...Item wurde aufgehoben!"); // Item picked up
            ...
        }
        else {
            printdebugnpc(pd_zs_check, "...Taschendiebstahl!"); //pickpocket
            ...
        }

This causes NPC around an item to tell the player that something is getting
stolen right now and also indicates that victim is not always set in the
perception process.

So adapt the sent passivePerc accordingly to not transmit the player as victim
when picking up items.

GameScript::invokeState() already removed the default setting of other=npc
for the !other case in commit 3fc5c39 ("damage from faling") as part
of the fix for Try#18, so do the same for the current default victim setting.

This fixes Try#717.
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.

Does item pickup have a victim (picking up items marked as theft)
2 participants