https://rpg.hamsterrepublic.com/ohrrpgc ... upon_it%3F
Code: Select all
plotscript, vigilant guards activate, begin
variable (this map)
this map := current map
while (this map == current map) do, begin
vigilant guard (0) #change '0' to the correct NPC ID
#vigilant guard (1) #repeat as desired
wait (1)
end
end
script, vigilant guard, NPC ID, begin
variable (guard)
guard := NPC reference (NPC ID)
variable (x1, x2, y1, y2, dir, dist, start chasing)
x1 := NPC X (guard)
x2 := hero X (me)
y1 := NPC Y (guard)
y2 := hero Y (me)
dir := NPC direction (guard)
dist := x2 -- x1
if (y1 == y2) then (
if (dir == right && dist <= 8 && dist >= 0) then (start chasing := true)
if (dir == left && dist >= -8 && dist <= 0) then (start chasing := true)
)
dist := y2 -- y1
if (x1 == x2) then (
if (dir == down && dist <= 8 && dist >= 0) then (start chasing := true)
if (dir == up && dist >= -8 && dist <= 0) then (start chasing := true)
)
if (start chasing) then (
wait for NPC (NPC ID)
Alter NPC (NPC ID, NPCstat:move type, NPCmovetype:chaseyoupathfinding) #you can change the NPCmovetype to suite your needs
Alter NPC (NPC ID, NPCstat:move speed, 5)
)
end
I should also mention that I am using a script that only allows NPCs to move when the player moves (roguelike-ish movement).
Any help appreciated!
Cheers.