step_towards(src,src.Attacker)
sleep(5)
In my battle, I have this
M.Attacker="[usr]"
But for some reason.. They go straight down.. and don't follow you.. Why?
ID:140450
Jan 2 2010, 7:46 pm
|
|
In my AI, I have this line of code:
step_towards(src,src.Attacker) In my battle, I have this M.Attacker="[usr]" But for some reason.. They go straight down.. and don't follow you.. Why? |
Jan 2 2010, 8:38 pm
|
|
You're attempting to step towards a string. This is obviously nonsensical.
|
In response to Jp
|
|
What do I do then?
|
In response to Xyphon101
|
|
Pass step_towards a reference to the thing you want to step towards, rather than a string.
|
You need to set M.Attacker to an actual reference to the object. So, instead of Attacker = "[usr]", you need Attacker = usr. The first is a string that is (more or less) just usr's name. The second is an actual reference to the mob.
Also, for safety's sake, you should declare the Attacker variable as tmp (var/tmp/mob/Attacker), as otherwise if a monster were saved, it would save the player along with it (in order to save the value of the variable, it has to save the mob it's pointing to as well). This causes issues. So, any variable that will store a reference to some other object should generally be declared as tmp unless you REALLY want it saved (like, if you're sure the player is going to have it in their contents, as in a variable pointing to the weapon a player has equipped). |