#(clouddino) How to toggle NPC following player

116 messages · Page 1 of 1 (latest)

wicked gorge
#

I've taken a bit of a break from this so have forgotten how to do this is all, thank you!

(also, how would i limit the range of the NPC walking? So that it stays in a set area)

grim minnowBOT
#

(clouddino) How to toggle NPC following player

grim minnowBOT
#

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.

fading timber
#

!guide script editor

fading timber
#

Your script editor does not seem to work

#

should probably set this up first

wicked gorge
#

I dont really plan on using this much after this small NPC for a practice range, is it possible to do without this?

#

the other settings in it have been working fine

empty oriole
#

It takes like 10 minutes to set up, and then you have it forever - I'd just do it real quick, as the error checking, syntax highlighting documentation, etc. are very useful

wicked gorge
#

Alright ive done that, but it isnt highlighting any issues with the line that i need help with

fading timber
#

does it do highlighting and shows colors?

wicked gorge
#

yeah it does

fading timber
#

nice that means the file extension of your script file is correct

wicked gorge
#

right so what do i do now to fix the following setting

fading timber
#

let me review it real quick

wicked gorge
fading timber
#

!paste

mental kettleBOT
wicked gorge
fading timber
#

so you want to make the npc follow the player, but only in a specific area and make the npc go to its spawn point if the player leaves it

wicked gorge
#

right now theres settings so that players can customise how the NPC interacts with them for aim training

#

i just want them to be able to click something and the npc will be toggled to follow them

#

then a seperate thing that isnt toggleable to limit where the npc walks

fading timber
#

yeah so I'd probably use

#

!c follow

mental kettleBOT
# fading timber !c follow
Group

entity

Syntax

follow (followers:<entity>|...) (stop/target:<entity>) (lead:<#.#>) (max:<#.#>) (speed:<#.#>) (allow_wander) (no_teleport)

Short Description

Causes a list of entities to follow a target.

Description

Causes a list of entities to follow a target.

Specify the list of followers or just one. If no follower is specified, will use the linked NPC.

Specify either the target to follow, or 'stop'. If no target is specified, will use the linked player.

Use 'speed' to set the movement speed multiplier.
Use 'lead' to set how far away the follower will remain from the target (ie, it won't try to get closer than the 'lead' distance).
Use 'max' to set the maximum distance between the follower and the tar...

fading timber
#

to make the npc follow a player

#

and then make a noted area (the area the npc can wander in)

wicked gorge
#

yeah i think thats what im attempting to use but im a bit slow

fading timber
#

and when the player leaves that area, reset the npc

#

!e player enters/exits

mental kettleBOT
fading timber
#

!e entity enters/exit

mental kettleBOT
#
Possible Confusion

Did you mean to search for entity enters|exits area?

wicked gorge
#

would it be possible to make them freeroam instead?

mental kettleBOT
# fading timber !e entity enters/exit
Group

Entity

**WARNING**

cancelling this event will have different results depending on the cause. Teleporting the entity away 1 tick later might be safer.

Event Lines

<entity> enters|exits <area>

Triggers

when an entity enters or exits a noted area (cuboid, ellipsoid, or polygon). On Spigot servers, only fires for players. Paper is required for other mob types.

Has Player

When the entity is a player. - this adds switches flagged:<flag name> + permission:<node>, in addition to the <player> link.

Context

<context.area> returns the area object that was entered or exited.
<context.cause> returns the cause of the event. Can be: WALK, WORLD_CHANGE, JOIN, QUIT, TELEPORT, VEHICLE.
<context.to> returns the location the entity moved to (might not be available in exit events).
<context.from> returns the location the entity moved from (when available, depending on cause).
<context.entity> returns the entity that entered/exited an area.

Cancellable

True - this adds <context.cancelled> and determines cancelled + cancelled:false.

wicked gorge
#

and then just players can walk up and interact with them

fading timber
wicked gorge
#

alright thank you

fading timber
#

!m wander

mental kettleBOT
# fading timber !m wander
Cannot Specify Searched Mechanism

Multiple possible mechanisms: NPCTag.wander_delay, NPCTag.wander_xrange, NPCTag.wander_yrange, NPCTag.worldguard_wander_region.

#
Possible Confusion

Did you mean to search for command weather?

wicked gorge
#

i have the wander stuff sorted and have made it toggleable, i just need to stop them from walking out of our little practice range and into like water

fading timber
#

!m waypoint_provider

mental kettleBOT
fading timber
# mental kettle

need to set it to wander ^ and then you can choose the range with the mechanisms above ^

wicked gorge
#

oh cool

fading timber
#

or restrict it by a worldguard region

#

!m npc.worldguard_wander_region

mental kettleBOT
# fading timber !m npc.worldguard_wander_region

If the NPC's waypoint provider is set to wander (!mechanism NPCTag.waypoint_provider),
sets the current WorldGuard region that wandering is restricted to.
Provide no input to remove the region restriction.

Required Plugins or Platforms

Depenizen, WorldGuard

Object

NPCTag

Input

WorldGuardRegionTag

Tags

<NPCTag.worldguard_wander_region> If the NPC's waypoint provider is set to wander (<@link tag NPCT...

wicked gorge
#

yeah deadass i cant understand how to use the follow tool

fading timber
mental kettleBOT
#
Info: debug

If you need help with a script issue, one of the most powerful tools Denizen has to offer is full debug output. This is displaying in your console whenever scripts are running until you turn debug off. To share a debug log quickly and easily with helpers, simply run the command /denizen debug -r in-game to begin recording, then run through the part of the script you need help with, then run the command /denizen submit. This will give you a link to a paste of the debug log, which you can then copy/paste back to us!

fading timber
#

if you provide both I can check for errors

wicked gorge
#
#

is this good?

#

i appreciate it a lot thank you

fading timber
#

oh it looks the same as before

wicked gorge
#

oh

#

i think i broke something

#

and then i reset it back to what it was before

#

since it wasnt working anyway

fading timber
#

can you elaborate a little bit more about how your script should work

#

like the whole idea

#

be as precise as possible please

wicked gorge
#

when you right click the npc it brings up a gui like this

#

and when you click the item it will make the NPC follow you

#

or toggle it

fading timber
#

what will it do? is it guarding the player, is this a specific npc only or can every player have an npc following them

wicked gorge
#

it will be a practice dummy for combat

#

they will be free roaming

#

like 5 of them

#

and then a player can walk up to the NPC and it will follow them if they toggle it on

#

until they either leave the area or if they toggle it off

fading timber
#

okay so you don't need to do instancing npcs

wicked gorge
#

i want them to have the option of it being roaming or if its following them is all

#

since it isnt vanilla pvp its using a seperate plugin

fading timber
#

should they always roam if they have nothing todo?

#

e.g. not following a player

wicked gorge
#

they should be stood still

#

then a player can come up to them and toggle a setting

fading timber
#

ah okay, well you have to set it up then

#

do you know how mechanisms work?

wicked gorge
#

i do not

fading timber
#

!guide mechanism

mental kettleBOT
fading timber
#

it's fairly simple, but you need the npc object available inside the inventory

#

can you show me the inventory part please?

fading timber
#

yea but in script form

wicked gorge
fading timber
#

oh holy

wicked gorge
#

😂

fading timber
mental kettleBOT
# fading timber !ds https://paste.denizenscript.com/View/135762
Script Check Results
Script Warnings

On line 7: This line appears to contain raw object notation. There is almost always a better way to write a line than using raw object notation. Consider the relevant object constructor tags.

Minor Warnings

On line 5: Data lines should not be quoted. You can use '<empty>' to make an empty line, or '<&dq>' to make a raw double-quote symbol, or '<&sq>' to make a raw single-quote.

Other Script Information

On line : (Statistics) Total structural lines: 2
On line : (Statistics) Total live code lines: 1
On line : (Statistics) Total comment lines: 0
On line : (Statistics) Total blank lines: 0

fading timber
#

you can remove each i@ there

#

do you have the interact script for me too

#

what i would do is instancing the inventory script and pass the npc data onto the relevant items

wicked gorge
#

heres just hte full thing

fading timber
mental kettleBOT
# fading timber !ds https://paste.denizenscript.com/View/135764
Script Check Results
Encountered Critical Errors

On line 20: Script section is empty (add contents, or remove the section).

Script Warnings

On line 21: Line purpose unknown, no identifier (missing a : or a -?).
On line 13: This line appears to contain raw object notation. There is almost always a better way to write a line than using raw object notation. Consider the relevant object constructor tags.
On line 28, 36, 40, 44: Inappropriate usage of the 'execute' command. Execute is for external plugin interop, and should never be used for vanilla commands. Use the relevant Denizen script command or mechanism instead.

Minor Warnings

On line 23: Stray space after end of line (possible copy/paste mixup. Enable View->Render Whitespace in VS Code).
On line 5: Data lines should not be quoted. You can use '<empty>' to make an empty line, or '<&dq>' to make a raw double-quote symbol, or '<&sq>' to make a raw single-quote.

Other Script Information

On line : (Statistics) Total structural lines: 16
On line : (Statistics) Total live code lines: 23
On line : (Statistics) Total comment lines: 0
On line : (Statistics) Total blank lines: 6

Shortened Lines

There are 3 lines that were merged into other lines.

fading timber
#

need to fix that ^

fading timber
#
- define inventory <inventory[strafe_menu_inventory]>
- inventory flag destination:<[inventory]> slot:1 npcData:<npc>
- inventory open destination:<[inventory]>

then you can use it in the click event, e.g instead of execute as_server "npc wander --id 6" you could use execute as_server "npc wander --id <context.item.flag[npcData].id>

#

or use the mechanism that makes the npc wander - adjust <context.item.flag[npcData]> waypoint_provider:wander

#

npcData holds the NPCObject that you can use in any command that takes an NPCTag

#

have to go to sleep now but I hope it helps

wicked gorge
#

yeah thank you so much

grim gardenBOT
#
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.)

#

@wicked gorge