Jump to content
  • 1

How can i make npc's that stand still even when i attack it


Dagobah

Question

9 answers to this question

Recommended Posts

  • 0

oh i see, well i want to make a sandbox mechanic, my way to do it was to use npcs as blocks, that way i could summon and destroy elements anywhere, but to make them stand still i would be obligated to set every tile in the map as npc's avoids

 

i think i have to enter the source to change the call to attack the player if attacked or something like that, any suggestion?

Link to comment
Share on other sites

  • 0

ok i finally get it,

 

i justa have to enter the source and edit in this path: Intersect.Server/Entities/Npc

 

 

comment the call to void TryFindNewTarget and AssignTarget in line 665

 

and comment the movement in line 754 

 

this way no npc will follow the player even if is attacked by him 

                    if (tgt != null)
                    {
                        AssignTarget(tgt);
                    }
                    else
                    {
                         Check if attack on sight or have other npc's to target
                        TryFindNewTarget(timeMs);
                    }


                                        
                                        if (CanMove(dir) == -1 || CanMove(dir) == -4)
                                        {
                                            //check if NPC is snared or stunned
                                            statuses = Statuses.Values.ToArray();
                                            foreach (var status in statuses)
                                            {
                                                if (status.Type == StatusTypes.Stun ||
                                                    status.Type == StatusTypes.Snare ||
                                                    status.Type == StatusTypes.Sleep)
                                                {
                                                    return;
                                                }
                                            }

                                            Move((byte) dir, null);
                                        }
                                        else
                                        {
                                            mPathFinder.PathFailed(timeMs);
                                        }

 

 

Link to comment
Share on other sites

  • 0
1 hour ago, Dagobah said:

ok i finally get it,

 

i justa have to enter the source and edit in this path: Intersect.Server/Entities/Npc

 

 

comment the call to void TryFindNewTarget and AssignTarget in line 665

 

and comment the movement in line 754 

 

this way no npc will follow the player even if is attacked by him 


                    if (tgt != null)
                    {
                        AssignTarget(tgt);
                    }
                    else
                    {
                         Check if attack on sight or have other npc's to target
                        TryFindNewTarget(timeMs);
                    }



                                        
                                        if (CanMove(dir) == -1 || CanMove(dir) == -4)
                                        {
                                            //check if NPC is snared or stunned
                                            statuses = Statuses.Values.ToArray();
                                            foreach (var status in statuses)
                                            {
                                                if (status.Type == StatusTypes.Stun ||
                                                    status.Type == StatusTypes.Snare ||
                                                    status.Type == StatusTypes.Sleep)
                                                {
                                                    return;
                                                }
                                            }

                                            Move((byte) dir, null);
                                        }
                                        else
                                        {
                                            mPathFinder.PathFailed(timeMs);
                                        }

 

 

No npcs will be able to walk after that right? Maybe you should add an option to the editor to do so instead of blocking every NPC.

Link to comment
Share on other sites

  • 0
On 4/21/2020 at 1:20 PM, Shenmue said:

No npcs will be able to walk after that right? Maybe you should add an option to the editor to do so instead of blocking every NPC.

Yes that would happen and in the final i use an established option i use this condition: 

 

if (t.Despawnable && t.Base.Movement != (int)NpcMovement.StandStill) {

//calling movement and attack voids

 

}

 

that makes all the NPCs that are established as Stands Still in its movement will be totally immobile even if you attack them, and the NPCs that are established as turn randomly or move randomly will attack and move with normality.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...