/WALK Command


Author: aufdemrand
Created: 2013-07-30T06:48:08-0400
Edited: 2013-07-30T06:48:22-0400
Denizen Version: 0.9.2+
Views: 26
Downloads: 948
Likes: 0


WGET
Description:
# +-----------------------------------
# | /WALK COMMAND --- Make NPCs walk!
# +-----------------------------------

# Just type /walk [start/stop/to] [blocks|...] [radius] [speed]
# For example: /walk to grass 20 115 would make the NPC walk to grass,
# within 20 blocks, at 115% speed.

# Typing /walk again will make them do the same thing!

# You can also set some NPC flags to alter behavior
# walk_filter -- the blocks that the NPC will path to
# walk_radius -- the number of blocks in radius to search
# walk_speed -- the speed of the walking_task
# walk_duration -- the amount of time between walks when using /walk start

# +-----------------------------------
# | /WALK COMMAND --- Make NPCs walk!
# +-----------------------------------
 
# Just type /walk [start/stop/to] [blocks|...] [radius] [speed]
# For example: /walk to grass 20 115 would make the NPC walk to grass,
# within 20 blocks, at 115% speed.
 
# Typing /walk again will make them do the same thing!
 
# You can also set some NPC flags to alter behavior
# walk_filter -- the blocks that the NPC will path to
# walk_radius -- the number of blocks in radius to search
# walk_speed  -- the speed of the walking_task
# walk_duration -- the amount of time between walks when using /walk start

Auf's Walk Command:
  type: world

  events:
    on walk command:
    - if !<player.is_op> queue clear
    - determine passively fulfilled
    - define NPC <player.selected_npc>

      # /walk start or /walk stop
    - if '<c.args.get[1]>' == start {
        - flag npc:%NPC% npc walk_toggle:true
        - queue clear
 
      } else if '<c.args.get[1]>' == stop {
        - flag npc:%NPC% npc walk_toggle:false
        - queue clear
 
      } else if '<c.args.get[1]>' == status {
        - narrate "<%NPC%.name>'s current walk status:"
        - narrate 'Currently wandering<&co> <%NPC%.flag[walk_toggle] || false>'
        - narrate 'Currently looking<&co> <%NPC%.flag[look_toggle] || false>'
        - narrate 'Wandering/Looking duration<&co> <%NPC%.flag[walk_duration] || 10s-25s>/<npc.flag[look_duration] || 1s-7s>'
        - narrate 'Wandering/Looking radius<&co> <%NPC%.flag[walk_radius] || 10>/<npc.flag[look_radius] || 8>'
        - narrate 'Wandering speed<&co> <%NPC%.flag[walk_speed] || 100>%'
        - narrate 'Number of wanders so far<&co> <%NPC%.flag[walk_counter] || 0>'
        - narrate 'Number of looks so far<&co> <%NPC%.flag[look_counter] || 0>'
        - queue clear
      }
 
      # /walk [filter] ([radius]) (speed)
    - if <c.args.get[1]> != null 
      flag npc:%NPC% npc "walk_filter:<c.args.get[1]>"
    - if <c.args.get[2]> != null
      flag npc:%NPC% npc "walk_radius:<c.args.get[2]>"
    - if <c.args.get[3]> != null
      flag npc:%NPC% npc "walk_speed:<c.args.get[3]>"
 
    # OK, walk.
    - run walking_task as:%NPC% instantly
 

    on npc completes navigation:
    - if <npc.flag[walk_toggle]> 
      run "auf's walking_loop" path:reloop

    on npc cancels navigation:
    - if <npc.flag[walk_toggle]> 
      run "auf's walking_loop" path:reloop

    on npc spawns:
    - if <npc.flag[walk_toggle]> 
      run "auf's walking_loop" path:reloop

    on npc flag walk_toggle changed:
    - if <npc.flag[walk_toggle]> == true
      run "auf's walking_loop" path:start
      else follow stop
 

Auf's Walking_task:
  type: task

  script:
  - ^define filter '<npc.flag[walk_filter] || grass|cobblestone|mycel|wool|stone|dirt>'
  - ^define radius '<npc.flag[walk_radius] || 10>'
  - ^define speed '<npc.flag[walk_speed] || 100>'
  - ^flag npc walk_counter:++
  - ^if <player> != null
    ^narrate "Walking <npc.name> to '<li@%filter%.ascslist>' within %radius% blocks at a speed of %speed%%."
  - ^define loc <npc.location.find.surface_blocks[%filter%].within[%radius%].random>
  - walkto auto_range location:%loc% 'speed:<m:%speed% / 100>'
 

Auf's Walking_loop:
  type: task
  
  start:
  - ^if '<npc.flag[walk_toggle] || false>' == false
    queue clear
  - ^run "auf's walking_task" as:<player.selected_npc> instantly

  reloop:
  - ^define dur '<npc.flag[walk_duration] || 10s-25s>'
  - wait %dur%
  - run "auf's walking_loop" path:start
 




Comments
No one has posted a comment! Post one below: