ID:147336
 
Ive been working on a guard code and ive been trying to make it so when the gaurd attacks the enemie that when the gaurd chases the enemie and kills it it returns to the old position were i put it in the map editor. If you can help me on this please post back.
err... could you please speak a little better english, for all of us, organize your thoughts into sections, thanks
In response to Chibi_Gohan123
Sorry about not being able to read it very well (I was in a hurry) but what I mean is this, I've created a code for a gaurd to enable it to chase an enemy and kill it. I want to be able to return the gaurd to its position were I put it on the map editor. I want to be able to return it to there so I don't have a gaurd on the other side of my town. If anyone would know how I could do this please reply. And if you don't get this it's actually really hard to explain, so just work with me.

Thanks, Caramonmajere
In response to Caramonmajere
sorta like mystic journy guards?
In response to Caramonmajere
Store the guard's loc in a special guard var when it is created (in the guard's New() proc). After the guard destroys the enemy, have it return to the loc stored in that var. You'll want some sort of advanced pathfinding to be certain that the guard can return properly if the enemy leads him or her on a convoluted path. The various built in walk() and step() procs are easily foiled by obstacles.
In response to Chibi_Gohan123
I've figured it out! I just made a return code like this,
mob
proc
Gaurd_Move()
usr.x = usr.loc_x
usr.y = usr.loc_y
usr.z = usr.loc_z

then for the gaurd I put this,
mob
NPC
Gaurd
icon='npc.dmi'
icon_state="gaurd"
hp=2000
maxhp=2000
New()
usr.loc_y = usr.y
usr.loc_x = usr.x
usr.loc_z = usr.z
then I added the code to make it attack the enemy. When I made it so after it kills the enemy I put the Gaurd_Move() proc there. Then when a gaurd looses track of the enemy I made it so it stays in that position for 2 seconds then returns. I made it stay for 2 seconds incase the enemy decides to come back :p . Thanks for your help though it gave me this great idea. I think I'm going to make a demo for this.....