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

Does item pickup have a victim (picking up items marked as theft) #717

Open
mmind opened this issue Jan 15, 2025 · 2 comments · May be fixed by #735
Open

Does item pickup have a victim (picking up items marked as theft) #717

mmind opened this issue Jan 15, 2025 · 2 comments · May be fixed by #735
Labels
bug Something isn't working

Comments

@mmind
Copy link
Contributor

mmind commented Jan 15, 2025

In Gothic 1 every time I pick up an item from the ground (i.e. a berry at the startpoint) while a Npc looks, he'll shout "Behind you!".

Tracking that down to b_assesstheft(), I can see:

    ai_quicklook(self, other);
    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
            if (...) {
    ...
                ai_pointatnpc(self, other);
                b_say(self, other, "$BEHINDYOU");

So the condition (hlp_isvaliditem(item) && (!hlp_isvalidnpc(victim)) should be true to indicated something picked up, but isn't, leading to the pickpocket branch.

I'm not yet sure what part is wrong though.

@mmind mmind added the bug Something isn't working label Jan 15, 2025
@mmind
Copy link
Contributor Author

mmind commented Jan 15, 2025

Interestingly Gothic 2 does if (hlp_isvalidnpc(other) && npc_isplayer(other)) and Gothic 1 also does similar things, like if ((hlp_isvalidnpc(other) && (!c_npcisdown(other))) && (!npc_isplayer(other)) , so the player is a valid Npc in both games in other places.

But I guess the player being the "victim" when picking up an item might be strange?

@mmind
Copy link
Contributor Author

mmind commented Jan 15, 2025

I guess the culprit might be living in Npc::takeItem, which does
owner.sendPassivePerc(*this,*this,*this,*it,PERC_ASSESSTHEFT);
marking the player as the victim of the theft. I guess victim might need to be optional?

@mmind mmind changed the title Behaviour difference hlp_isvaliditem() or hlp_isvalidnpc() Does theft have a victim Jan 15, 2025
@mmind mmind changed the title Does theft have a victim Does item pickup have a victim (picking up items marked as theft) Jan 15, 2025
mmind added a commit to mmind/OpenGothic that referenced this issue Jan 22, 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 Try#18, so do the same for the current default victim setting.

This fixes Try#717.
mmind added a commit to mmind/OpenGothic that referenced this issue Jan 29, 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 Try#18, so do the same for the current default victim setting.

This fixes Try#717.
mmind added a commit to mmind/OpenGothic that referenced this issue Jan 29, 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 Try#18, so do the same for the current default victim setting.

This fixes Try#717.
mmind added a commit to mmind/OpenGothic that referenced this issue 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 Try#18, so do the same for the current default victim setting.

This fixes Try#717.
@mmind mmind linked a pull request Jan 30, 2025 that will close this issue
mmind added a commit to mmind/OpenGothic that referenced this issue Feb 8, 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 Try#18, so do the same for the current default victim setting.

This fixes Try#717.
mmind added a commit to mmind/OpenGothic that referenced this issue Feb 8, 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 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
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant