#(laura) how do i make a citizens npc walk randomly using citizens api for bukkit(spigot)

43 messages · Page 1 of 1 (latest)

clever shuttle
#

i maked this but "Navigation" not exists

Navigation navigation = npc.getNavigator().getDefaultParameters();
navigation.avoidWater(true);
navigation.setRandomDirection(true);
navigation.setSpeed(0.5);
npc.getNavigator().setDefaultParameters(navigation);```
livid needleBOT
#

(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>

faint bluff
#

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")

clever shuttle
# faint bluff first, most of that appears to be completely random 0.o

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
faint bluff
clever shuttle
faint bluff
#

yes

clever shuttle
#

will it work on player npc?

clever shuttle
# faint bluff yes

that's why I made this code, for fear of not working in npc of type player lmao

faint bluff
clever shuttle
#

@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

fallow belfryBOT
faint bluff
#

^ just give it Sentinel trait, and set respawntime to -1

clever shuttle
#

i spawned he in a tree and he teleported

#

but he is walking

#

but i think if there is a hole the npc teleports

faint bluff
#

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

clever shuttle
faint bluff
#

er sorta

#

that sets a persistent tracker for after restarts

#

it's npc.getNavigator().getDefaultParameters().stuckAction(null); that disables it immediately

clever shuttle
#

on command i used /npc vulnerable

#

but on api how do i do this

faint bluff
novel saffronBOT
#
Thread Closing Reminder

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