#(JustinS) Check for movement?

106 messages · Page 1 of 1 (latest)

warm shadow
#

Im using the on walk event and - if <context.old_location.xyz> != <context.new_location.xyz> to check if the player is moving, though I find the above if statement to be wayyyy too sensitive. I've tried subtracting them, taking the absolute and then rounding but then it complains that context.old_location.xyz is not a valid decimal. Also tried just rounding both but same issue. Any alternatives/workarounds to this?

honest socketBOT
#

(JustinS) Check for movement?

honest socketBOT
#

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.

fast perch
#

!t distance

restive sparrowBOT
# fast perch !t distance
Cannot Specify Searched Tag

Multiple possible tags: <LocationTag.distance[<location>]>, <MaterialTag.distance>, <EntityTag.fall_distance>, <LocationTag.tree_distance>, <WorldTag.view_distance>, <server.view_distance>, <NPCTag.distance_margin>, <LocationTag.distance_squared[<location>]>, <LocationTag.distance[<location>].vertical>, <LocationTag.distance[<location>].horizontal>, <WorldTag.simulation_distance>, <NPCTag.path_distance_margin>, <WorldTag.no_tick_view_distance>, <LocationTag.points_between[<location>].distance[<#.#>]>, <WorldTag.border_warning_distance>, <LocationTag.distance[<location>].vertical.multiworld>, <LocationTag.distance[<location>].horizontal.multiworld>, <NPCTag.sentinel.guard_distance_minimum>.

fast perch
#

!t LocationTag.distance[<location>]

restive sparrowBOT
warm shadow
#

ahh genius

#

Ill give it a try

wise hollow
#

Do you want to check for every movement, or just when they walk to a different location?

#

That event fires very often

fast perch
#

I mean that's only 20 times a second * the amount of players

warm shadow
#

Im trying to allow players to heal themselves but only when they stand still

fast perch
#

!e player steps on block

restive sparrowBOT
# fast perch !e player steps on block
Group

Player

**WARNING**

This event may fire very rapidly.

Event Lines

player steps on block player steps on <material>

Triggers

when a player steps onto a specific block material.

Has Player

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

Context

<context.location> returns a LocationTag of the block the player is stepping on.
<context.previous_location> returns a LocationTag of where the player was before stepping onto the block.
<context.new_location> returns a LocationTag of where the player is now.

Has Known Location

True - this adds switches in:<area> + location_flagged:<flag name>.

Cancellable

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

warm shadow
#

Ill need the standing still component for multiple things in the future probably

#

they cant jump either

fast perch
#

pretty much the same but fires quite less often

wise hollow
#

!e jumps

restive sparrowBOT
warm shadow
#

I guess I have to add a seperate event for jumping then?

fast perch
#

You run a command, wait a few seconds, get healed if you didn't move ?

warm shadow
# fast perch how exactly

flag the player when theyre walking. The heal script is on a repeat 8 times (keeps adding a little bit of health) and when you move (it keeps checking the flag) it stops

fast perch
#

ah so being immobile naturally heals

warm shadow
#

if you run the heal command

#

yeah

#

it only goes on for 8 times

#

then theres a cooldown

#

Ill give this a try

fast perch
#

wait

#

now i don't understand

#

please explain what should happen step by step (overall mechanism you're aiming for)

warm shadow
#

Theres a special tool that allows the player to heal themselves but only when theyre standing still. When they right click it, it heals them for 8 seconds (every second it adds a little health). If they move, the healing process stops

fast perch
#

ok so the trigger is a right click event with a specific item in hand

#

use this as the trigger, not the player walking event

warm shadow
#

thats what Im doing

fast perch
#

ye but you don't have to flag the player and check for movement or whatever

#

keep the logic withing that right click event

warm shadow
#

Heres what I have rn:

player_movement_detection:
    type: world
    events:
       after player steps on block:
        - flag player walking:true
        - wait 0.2s
        - flag player walking:false
force_heal:
    type: task
    script:
        - ratelimit <player> 12s
        - itemcooldown diamond duration:12
        - cast slow <player> amplifier:1 duration:8s no_clear no_icon hide_particles
        - repeat <duration[8s].in_seconds> from:0:
            - if <player.flag[walking]>:
                - cast slow remove <player>
                - stop
            - define target <player.eye_location.ray_trace_target[ignore=<player>;range=8]||null>
            - if <[target]> != null && (<[target].is_player> || <[target].is_mob> || <[target].is_npc>):
                - define target <player>
            - heal <player> 1
            - narrate "healing target: <[target].name>"
            - wait 1s```
fast perch
#

for your information this is writing 8 with extra steps

warm shadow
#

yeah idk I saw that in a different post lol

fast perch
#

i like the extra readability tho

warm shadow
#

I thought it was weird

#

but it worked

#

I can just remove the inseconds part right? The s behind the 8 takes care of that

fast perch
#

literaly replace by - repeat 8 from:0:

warm shadow
#

yeah that works

#

yeah that too

fast perch
#

also don't need the from:0 if the loop index is never checked

#

but anyways, that's not really a logical approach

warm shadow
#

What isnt

#

everything?

fast perch
#

pseudo code (this is not a script you can copy)

on player right clicks with my item: 
  - define location player.location 
  - repeat 8: # because you said it must repeat 8 times
    
    # note that putting the `wait` first means they must be imobile for a second before getting the first healing
    # might want to put that to the end for an instant initial healing
    - wait 1s # add whatever delay you want between each healing
    - define new_location player.location
    - if location.distance[new_location] > 0.5: # or whichever threshold you feel is "imobile enough"
      - narrate "Don't move if you want to get healed"
      - stop
    - do things # at this point you know the user didn't move
warm shadow
#

hmm yeah thats pretty smart

fast perch
#

now if you want to ensure the player didn't jump, or didn't do some action you want to prohibit while healing, you could do something like this:

on player right clicks with my item: 
  - define location player.location 
+ - flag player is_healing
  - repeat 8: # because you said it must repeat 8 times 
    # note that putting the `wait` first means they must be imobile for a second before getting the first healing
    # might want to put that to the end for an instant initial healing
    - wait 1s # add whatever delay you want between each healing
    - define new_location player.location
+   - if !player.has_flag[is_healing]:
+     - narrate "You did something that stopped you from healing"
+     - stop
    - if location.distance[new_location] > 0.5: # or whichever threshold you feel is "imobile enough"
      - narrate "Don't move if you want to get healed"
      - stop
    - do things # at this point you know the user didn't move

# this or any other event you'd like to listen to
+ on player jumps flagged:is_healing:
+  - flag player is_healing:!
warm shadow
#

Ill change it to that, though I just found out about another (little) issue: whenever Im looking at a mob, it still thinks I want to heal myself. Whenever I look at another entity during the healing it should heal them instead. So somethings going wrong here? There's no errors. I changed the if to all the '!''s because that prevents me from putting more code in an if statement

            - define target <player.eye_location.ray_trace_target[ignore=<player>;range=8;raysize=0.15]||null>
            - if <[target]> == null || !<[target].is_player> || !<[target].is_mob> || !<[target].is_npc>:
                - define target <player>
            - heal <player> 1
            - narrate "healing target: <[target].name>"```
warm shadow
# fast perch now if you want to ensure the player didn't jump, or didn't do some action you w...

Hmm the playerloc variable isnt working?

[19:11:13 INFO]:  ERROR in script 'force_heal' in queue 'FORCE_HEAL_3405_ReferenceCourier' while executing command 'IF' in file '\scripts\Forcepowers.dsc' on line '92' with player 'JustinS_2006'!
                 Error Message: Tag <player.location.distance[playerLoc]> is invalid!
[19:11:13 INFO]: Additional Error Info: Unfilled or unrecognized sub-tag(s) 'distance[playerLoc]' for tag <player.location.distance[playerLoc]>!
[19:11:13 INFO]: Additional Error Info: The returned value from initial tag fragment 'player.location' was: 'l@300.50541147525314, 63, -616.2464319769457, -3.715579, 155.362732, world'.```
  • define playerLoc <player.location
  • if !<player.flag[healing]> || <player.location.distance[playerLoc]> > 0.5:
    ... ```
wise hollow
#

Can you

#

!haste

restive sparrowBOT
warm shadow
#

for 2 lines?

#

cmon

wise hollow
#

The formatting is weird

warm shadow
#

....

#

2 lines

#

alr

wise hollow
#

Because there are 2 things wrong

warm shadow
wise hollow
#

- define playerLoc <player.location this was wrongly pased, you're missing a > in your message

#

main reason I asked for a paste

#

also

#

<player.location.distance[playerLoc]>

#

playerLoc is just plain text

#

<[playerLoc]> is a definition that will return the value you defined

warm shadow
#

in the paste it shows that > at the end

wise hollow
#

so <player.location.distance[<[playerLoc]>]>

wise hollow
warm shadow
#

ah

#

Great, that doesnt throw an error anymore, thanks. Im still having the issue of it not healing the player if theyre not looking at another entity though

#

Should I make a seperate thread for that? I feel like this one already contains most context

#

[target].name should be my name

wise hollow
#

Couldn't you just use the player as a fallback?

warm shadow
#

wdym

wise hollow
#

!t if_null

restive sparrowBOT
# wise hollow !t if_null

If the object is null (or the tag errors), this will return the input object.
If the object isn't null, the input won't be parsed, and the original object will be returned.
For example, "<player.if_null[<npc>]>" will return the player if there is a player, and otherwise will return the NPC.
This functions as a fallback - meaning, if the tag up to this point errors, that error will be hidden.

Returns

ObjectTag

wise hollow
#

If your ray target is null, fallback to the player casting

#

eg. <player.eye_location.ray_trace_target[ignore=<player>;range=8;raysize=0.3]||<player>>

#

instead of <player.eye_location.ray_trace_target[ignore=<player>;range=8;raysize=0.3]||null>

warm shadow
#

aha

#

thats pretty smart

#

And it works. who wouldve guessed

#

thanks a lot for the help guys!

#

See you pretty soon

wind edgeBOT
#
Resolved

Thread closed as resolved.

#
Thread Reopened

Thread was manually reopened by @fast perch.