CitizensDev / Citizens2

Citizens - the premier plugin and API for creating server-side NPCs in Minecraft.
https://citizensnpcs.co
Open Software License 3.0
564 stars 294 forks source link

New finder over-explores when unable to find a path to target entity #2730

Open hkkongou opened 2 years ago

hkkongou commented 2 years ago

/version output

[18:17:38 INFO]: Checking version, please wait...
[18:17:39 INFO]: This server is running Paper version git-Paper-151 (MC: 1.18.1) (Implementing API version 1.18.1-R0.1-SNAPSHOT) (Git: 6663747)
You are 1 version(s) behind
Download the new version at: https://papermc.io/downloads
Previous version: git-Paper-407 (MC: 1.17.1)

/version Citizens output

[18:17:40 INFO]: Citizens version 2.0.29-SNAPSHOT (build 2448)
[18:17:40 INFO]: Website: http://www.citizensnpcs.co
[18:17:40 INFO]: Author: fullwall
[18:17:42 INFO]: [serveritem][give] Ha

Log file

https://paste.denizenscript.com/View/92230

config.yml

https://paste.denizenscript.com/View/92232

saves.yml

https://paste.denizenscript.com/View/92231

Profiler report

https://spark.lucko.me/rDZZKEsi3p

Description

using finder 1 is causing npc moving so strangely, so i used finder 2, but when i use finder 2, it have very serious lag spikes, you can see in the spark profiler.

fullwall commented 2 years ago

Can you show a picture of the path?

hkkongou commented 2 years ago

Can you show a picture of the path?

the old one is like red and new one is like yellow image

attached 2 video

use-new-finder: false https://youtu.be/4_oxggWT-A0

use-new-finder: true https://youtu.be/4R2j_gL0-J8

the reason why i try to use new finder is because old finder move very abnormal, so i use new, but new is laggy

fullwall commented 2 years ago

Hm looks like you're flying and using NPC targeting which may account for some lag.

hkkongou commented 2 years ago

Hm looks like you're flying and using NPC targeting which may account for some lag.

i am actually using sentinel guard

in the video ,indeed i was flying, but is the same when i walk on the ground, it just doesn't walk diagonally. (i have player tested , they can't fly)

mcmonkey4eva commented 2 years ago

There are several config options in plugins/Citizens/config.yml that might help with pathfinding performance, notably:


npc:
  pathfinding:
    new-finder:
      iterations-per-tick: 5000
    maximum-new-pathfinder-iterations: 10000

tweaking those iteration counts to be lower counts to be lower can generally help with new finder performance.

Also, as you're using Sentinel, the Sentinel config option:

    # Whether to use Sentinel's entity chase pathfinder.
    # If set to 'false', will use the Citizens built-in one instead.
    workaround entity chase pathfinder: true

May be relevant. false might potentially have better performance, at the cost of the NPC being less effective at reaching and hitting the target.

hkkongou commented 2 years ago

There are several config options in plugins/Citizens/config.yml that might help with pathfinding performance, notably:

npc:
  pathfinding:
    new-finder:
      iterations-per-tick: 5000
    maximum-new-pathfinder-iterations: 10000

tweaking those iteration counts to be lower counts to be lower can generally help with new finder performance.

Also, as you're using Sentinel, the Sentinel config option:

    # Whether to use Sentinel's entity chase pathfinder.
    # If set to 'false', will use the Citizens built-in one instead.
    workaround entity chase pathfinder: true

May be relevant. false might potentially have better performance, at the cost of the NPC being less effective at reaching and hitting the target.

thank you, i just tuned down those two citizen config and for the sentinel one is default false

i will see for some moment , thank you

hkkongou commented 2 years ago

There are several config options in plugins/Citizens/config.yml that might help with pathfinding performance, notably:

npc:
  pathfinding:
    new-finder:
      iterations-per-tick: 5000
    maximum-new-pathfinder-iterations: 10000

tweaking those iteration counts to be lower counts to be lower can generally help with new finder performance.

Also, as you're using Sentinel, the Sentinel config option:

    # Whether to use Sentinel's entity chase pathfinder.
    # If set to 'false', will use the Citizens built-in one instead.
    workaround entity chase pathfinder: true

May be relevant. false might potentially have better performance, at the cost of the NPC being less effective at reaching and hitting the target.

hello i just changed to new finder with the settings you provided, however there are still lag spikes, previously can cause a 1000-2000ms spike from spark tickmonitor and now can do a 500-700 spike, which is still, not good as compare with old finder, which have no spikes at anytime, what should i do?

https://spark.lucko.me/ujwlSQYGsT

hkkongou commented 2 years ago

image

https://spark.lucko.me/1WJUePvOfE

my tps just dropped to 1 with 30players , spark checked, is citizen lag

fullwall commented 2 years ago

I believe it's because the sentinel is unable to find a path to the player. There are mitigation strategies I need to implement for this; I have not done it yet.