#(laura) how do i make a citizens npc walk randomly using citizens api for bukkit(spigot)
43 messages · Page 1 of 1 (latest)
(laura) how do i make a citizens npc walk randomly using citizens api for bukkit(spigot)
Hi I'm AutoThreadBot! Don't mind me, I'll just be adding the helper team to this thread so they can see it. A human will get to you soon.
You can block this bot if you don't want to see these messages, I won't mind.
<@&525394568410038282>
first, most of that appears to be completely random 0.o
you can't develop code by doing random things
Second, the way to do that in-game would be /wp provider wander, so the way to do that in API code is just, whatever that command executes
which as you can see is getOrAddTrait(Waypoints.class).setWaypointProvider("wander")
i make that code:
// Get the current location of the NPC
Location currentLocation = npc.getEntity().getLocation();
// Generate a random location within a certain radius
Location newLocation = currentLocation.add(Math.random() * 10 - 5, 0, Math.random() * 10 - 5);
// Teleport the NPC to the new location
Navigator nav = npc.getNavigator();
nav.setTarget(newLocation);
}, 0L, 20L);```
and it works, i will soon add to the npc to "stop" and wait some time to start again walk
You.... can technically do that too if you want, though that will have side effects and bugs (eg if the NPC respawns, walks out of loaded chunk range, Citizens reloads for any reason, ...)
Using the wander provider would probably be easier because it already accounts for every edge case
that alone will make him walk randomly like a villager?
yes
will it work on player npc?
that's why I made this code, for fear of not working in npc of type player lmao
yes
@faint bluff so how do i make the npc get damageable? and how do i remove it after he dies
sorry for the english lmao
!readme sentinel
Sentinel can be found on GitHub at: https://github.com/mcmonkeyprojects/Sentinel
^ just give it Sentinel trait, and set respawntime to -1
uhhhhh i tested the wander waypoint provider and for some reason the npc is teleporting
i spawned he in a tree and he teleported
but he is walking
but i think if there is a hole the npc teleports
The way to fix that in-game is /wp disableteleport (refer to prior demonstration of how to convert in-game commands to API)
When you disable teleports it means the NPC may sometimes get temporarily stuck in a place, but depending on your setup that might be preferred
should this stop to teleporting the npc? on api
er sorta
that sets a persistent tracker for after restarts
it's npc.getNavigator().getDefaultParameters().stuckAction(null); that disables it immediately
one more question, how do i make the npc vulnerable?
on command i used /npc vulnerable
but on api how do i do this
if you use Sentinel, just add the Sentinel trait and that part is automated
Has your issue been resolved, or your question been answered?
If so, please use the </resolved:1028673926114594866> command to close your thread.
Or </invalid:1028673926898909185> if it's not possible to resolve.
If not yet resolved, please reply below to tell us what you still need.
(Note that if there is no reply for a few days, this thread will eventually close itself.)
@clever shuttle