ID:1447146
 
(See the best response by Kaiochao.)
Code:
        HuntAI(var/mob/Target)
while(Target)
step_towards(src, Target, 0)
if(bounds_dist(src, Target) == 0)
spawn(0) src.AttackAI(Target)
break
if(get_dist(src, Target) > 10)
Target = null
spawn(0) src.Sleep()
break
else sleep(30)

AttackAI(var/mob/Target)
var/Damage2Do = DamageCalc(src.Strength.Current, Target.Constitution.Current)
if(Damage2Do > 0)

/* This is MONSTER AI code. Since the monster is attacking a player (monsters only attack mobs with clients), you only
need to give the player experience. */


Target.Constitution.Experience.Value += (Damage2Do/Target.Level)
Target.Health.Value -= Damage2Do ; Target.DeathCheck(src)
spawn(30) src.HuntAI(Target)
return

else
Target << "You shrug off [src]'s attack."
spawn(30) src.HuntAI(Target)
return


Problem description:
The slimes attack so fast, I can't figure out where any delays could be put to slow their attack speed. I keep using sleep/spawn(30) to hopefully delay their attacks, but when they attack, they attack practically every tick.
Best response
You don't need to use sleep or spawn to delay events. If you're using a continuous loop that ticks frequently, all you need is a variable that says "we're not ready to perform this action until a certain time in the future," also known as a cooldown. Every tick of the AI loop, check if world.time has exceeded a "next_attack time" set when the action is performed as world.time + cooldown_time.
To add onto this, I'd like to ask: Is there a way to speed up animations? Ideally, I'd like "attack speed" to be defined as "how fast you attack" rather than "the delay between each attack". So as you gain attack speed, I want to somehow speed up the attack animation. Is this possible?
In response to Albro1
I didn't find anything on variable animation speed in a search, so you might want to make a feature request. It's worth a bit of discussion, too.
There'd have to be a way to control the delays of associated movie states at run-time.
Made a request.
In response to Lugia319
I imagine it would be simplest to just add a speed scale to flick().
I'd be fine with simply being able to go by multiples, like Scale() does. As long as I can be somewhat detailed with it (Being able to do like 1.08 would be ideal), I'm great.