Paste #5368: Untitled Paste

Date: 2014/06/18 08:05:34 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


'PathfindWalkPath':
#
# Does sanety checks and then chooses a target and walks to it.
# Sets <npc.flag[Pathfind.Status]> when thinking and walking.
# Use on npc flag change event as needed.
#
# Sets <npc.flag[Pathfind.Status]> to Lost when there is no destination.
# Sets <npc.flag[Pathfind.Status]> to Arriving when walking to destination.
# Sets <npc.flag[Pathfind.Status]> to Walking after s@PathfindChooseTarget
#   successfully completes.
# Use on npc flag change event as needed.
#
  type: task
  script:
    - ^if !<npc.is_spawned> queue clear
    - flag npc Pathfind.Status:Thinking
    - inject s@PathfindLoadData instantly
    - ^if <def[destination].is[==].to[null]> {
      - flag npc Pathfind.Status:Lost
      - queue <npc.name>_PathfindWalkPath_Queue clear
      }
    - ^if <def[destinationDistance].as_int.is[OR_LESS].than[%maxPathFindRadius%]> {
      - flag npc Pathfind.Status:Arriving
      - walkto <def[destination]> speed:<def[pathWalkSpeed]>
      - queue clear
      }
    - inject s@PathfindChooseTarget instantly
    - flag npc Pathfind.Status:Walking
    - walkto <def[pathTarget]> speed:<def[pathWalkSpeed]> radius:<def[pathWalkRadius]>