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

Companions don't adjust their walking speed #10

Closed
AmProsius opened this issue Dec 30, 2020 · 3 comments · Fixed by #76
Closed

Companions don't adjust their walking speed #10

AmProsius opened this issue Dec 30, 2020 · 3 comments · Fixed by #76
Labels
impl: hook script func This issue requires hooking script functions. impl: replace func call This issue requires replacing function calls in the scripts. provided fix This issue has a fix provided in the comments. type: session fix The fix for this issues is persistent across a session. validation: validated This issue is still present even with Systempack/Union.
Milestone

Comments

@AmProsius
Copy link
Owner

AmProsius commented Dec 30, 2020

Describe the bug
Followers still run if the player walks.

Expected behavior
Followers adjust their walking speed according to the player. However, the player must be in sight of the follower if the player starts running after walking.

@AmProsius AmProsius added this to To Do in v1.0.0 Dec 30, 2020
@AmProsius AmProsius changed the title Companions don't adjust their walking speed. Companions don't adjust their walking speed Dec 30, 2020
@AmProsius AmProsius removed ai labels Jan 1, 2021
@catalinstoian
Copy link

catalinstoian commented Jan 9, 2021

func int ZS_FollowPC_Loop()
{
PrintDebugNpc (PD_TA_LOOP, "ZS_FollowPC_Loop");
PrintGlobals (PD_MST_DETAIL);
//-------- SC-Meister folgen ! --------
if (Npc_GetDistToNpc(self,hero) > HAI_DIST_FOLLOWPC)
{
if !C_BodyStateContains(self, BS_SWIM)
{
AI_SetWalkmode (self, NPC_RUN);
};
AI_GotoNpc (self, hero);
}
else
{
B_SmartTurnToNpc(self, hero);
};
AI_Wait (self, 1);
return LOOP_CONTINUE;
};

changed to

func int ZS_FollowPC_Loop()
{
    PrintDebugNpc       (PD_TA_LOOP,    "ZS_FollowPC_Loop");
    PrintGlobals        (PD_MST_DETAIL);

    //-------- SC-Meister folgen ! --------
    if C_BodyStateContains(hero, BS_WALK) // wenn SC geht, gehe ich auch
    {
        AI_SetWalkmode  (self, NPC_WALK);
    }
    else if !C_BodyStateContains(self, BS_SWIM) // nur NPC_RUN wenn NPC nicht schwimmt und SC nicht geht
    {
        AI_SetWalkmode  (self, NPC_RUN);
    };
    if (Npc_GetDistToNpc(self,hero) > HAI_DIST_FOLLOWPC)
    {
        AI_GotoNpc      (self,  hero);
    }
    else
    {
        B_SmartTurnToNpc(self,  hero);
    };

    AI_Wait             (self,  1);
    return              LOOP_CONTINUE;
};

@szapp szapp added the type: session fix The fix for this issues is persistent across a session. label Jan 18, 2021
@szapp szapp self-assigned this Jan 24, 2021
@szapp
Copy link
Collaborator

szapp commented Jan 24, 2021

The code does not fix the issue for me:

  • Hero runs: NPC runs
  • Hero walks: NPC walks (as soon as they come close to the hero)
  • Hero resumes running: NPC keeps walking and does not revert to running.

The reason for this is, that the state loop (ZS_FollowPC_Loop) is only called when all running AI-commands are completed. So until the NPC reaches the hero (from the command AI_GotoNpc(self, hero);, the function is not called. If the NPC is walking, but the hero starts running again, the functions is never called again (because the NPC cannot reach the player in walking speed) and the walk mode cannot be updated. I do not see an easy fix for this issue.

@szapp szapp removed their assignment Jan 24, 2021
szapp added a commit that referenced this issue Jan 24, 2021
@szapp
Copy link
Collaborator

szapp commented Jan 24, 2021

I fixed it here #76. With the use of B_FollowPC_AssessSC it works - provided the NPC sees the player. That means: If the player walks around a corner and then starts running, the NPC will remain walking until seeing the player again.

v1.0.0 automation moved this from To Do to Done Jan 24, 2021
AmProsius added a commit that referenced this issue Jan 24, 2021
#10: Adjust walk mode in follow state
@AmProsius AmProsius added this to the v1.0.0 milestone Feb 13, 2021
@AmProsius AmProsius added provided fix This issue has a fix provided in the comments. validation: validated This issue is still present even with Systempack/Union. labels Mar 13, 2021
szapp added a commit that referenced this issue Mar 13, 2021
No longer the external is hooked but its call intercepted
@szapp szapp added this to Replace calls in Fix templates Mar 15, 2021
@szapp szapp added impl: hook script func This issue requires hooking script functions. impl: replace func call This issue requires replacing function calls in the scripts. labels Mar 16, 2021
@szapp szapp moved this from Replace function calls to NPC state in Fix templates Mar 16, 2021
@szapp szapp moved this from Modify NPC state to Some NPC Test? (Todo adjust name) in Fix templates Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impl: hook script func This issue requires hooking script functions. impl: replace func call This issue requires replacing function calls in the scripts. provided fix This issue has a fix provided in the comments. type: session fix The fix for this issues is persistent across a session. validation: validated This issue is still present even with Systempack/Union.
Projects
Fix templates
NPC manual test (TODO rename)
v1.0.0
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants