Leonhart

Joined: 25 Feb 2004 Posts: 383 Location: Philippines
|
Posted: Fri Nov 16, 2007 1:37 am Post subject: Pretty much like stealth? |
|
|
How do you:
create a script so that if you are (insert number of steps) away from an enemy, it automatically "detects" you, causing a battle? _________________ The man who smiles when things go wrong has thought of someone to blame it on.
- Robert Bloch |
|
TMC On the Verge of Insanity
Joined: 05 Apr 2003 Posts: 3240 Location: Matakana
|
Posted: Fri Nov 16, 2007 8:57 pm Post subject: |
|
|
well you have your standard distance script:
Code: | script, abs, n, begin
if (n << 0) then (return (n * -1)) else (return (n))
end
script, distance, x1, y1, x2, y2, begin
return (abs (x1 -- x2) + abs (y1 -- y2))
end |
And then you just have a loop in the background (or if the NPC isn't moving, an on footstep script instead) to check the distance:
Code: | plotscript, check range, begin
while (current map == ...) do (
if (distance (hero x, hero y, npc x (...), npc y (...)) <= ...) then (
fight formation (...)
)
wait
)
end
|
Fill in the dots with map number (note: this doesn't work well, see the FAQ), an npc reference/id, distance in tiles, and formation. You can have several of these. _________________ "It is so great it is insanely great." |
|