Main
Projects
Art
Music
Scripting
LiveJournal
Forum
Links
NPC In Range
by James `SPAM Man' Paige

Checks whether the NPC is within the range of the hero.


include, plotscr.hsd

#-----------------------------------------------------------

define script(autonumber,NPC in range,3,0,0,0)

script,NPC in range,hero,NPC,range,begin

  variable(difference)

  # by default, the result is false
  return(false)

  # check vertically
  difference:=NPC Y(NPC) -- Hero Y(hero)
  if(difference<=range,and,difference>=range*-1) then(
    # yes, the NPC is in range vertically
    # now check horizontally
    difference:=NPC X(NPC) -- Hero X(hero)
    if(difference<=range,and,difference>=range*-1) then(
      return(true)
    )
  )

end

#-----------------------------------------------------------

Site layout (c)2000 Jennifer Raby. Used by permission.