Scripts:Cancel movement

Jump to: navigation, search

You can halt an NPC or hero in their tracks by telling them to walk 0 tiles. Doing so in two directions cancels all movement (if you walk a hero both south and east at once it will move diagonally!), but it also changes the direction of the NPC/hero, so that needs to be considered too.

The following scripts take an NPC ID, an NPC reference, or a hero caterpillar slot (0-3) as argument.

script, cancel npc movement, npc, begin
  variable (dir)
  dir := npc direction (npc)
  walk npc (npc, south, 0)
  walk npc (npc, east, 0)
  set npc direction (npc, dir)
script, cancel hero movement, hero, begin
  variable (dir)
  dir := hero direction (hero)
  walk hero (hero, south, 0)
  walk hero (hero, east, 0)
  set hero direction (hero, dir)

After halting an NPC or hero it might be in-between two tiles. This will cause problems. See Scripts:Realign hero or NPC for a script to fix this.