ID:270894
 
Ok is it a good idea to use
        sleep(rand(Speed1,Speed2))
step_towards(src,src.target)
sleep(rand(Speed1,Speed2))
step_towards(src,src.target)
sleep(rand(Speed1,Speed2))
step_towards(src,src.target)
sleep(rand(Speed1,Speed2))
step_towards(src,src.target)

In a AI code? am juss wondering.
No. It's just a repeat. If you want it to go on for 4 times like this code does, you should do something like this:

for(var/i=1,i<=4,i++)
sleep(rand(Speed1,Speed2))
step_towards(src,src.target)


On the other hand, if you wish to continue the behavior indefinately as long as <code>src.target</code> is true, you should do something like this:

while(src&&src.target)
sleep(rand(Speed1,Speed2))
step_towards(src,src.target)


Also, note that <code>src.target</code> is unnessesary unless you have a temporary variable named "target".

mob
var/target
proc/MyProc_1()
target="The Enemy" //this is valid, and actually sets src.target
proc/MyProc_2()
var/target
target="The Enemy" //this is invalid: it doesn't set src.target, it sets the "target" variable above


You may want to ditch the <code>src.</code> if it's not such a temporary variable. It saves on typing, and we all know programmers are lazy.
In response to Android Data
Ok thx.
In response to Android Data
Question- why're you using this?
while(src&&src.target)


If src wasn't true then the proc wouldn't even be running at all.
In response to Elation
Elation wrote:
If src wasn't true then the proc wouldn't even be running at all.

Good point. It's just a habit of mine, I guess.