mob
Enemy
var
health=100
attack_power=10
target=null
move_delay=10
attack_delay=10
canhit=TRUE
//If we need to find a target, find one
proc/FindTarget()
var/got_target=FALSE
if(src.target != null && src.target in view(8))
got_target=TRUE
Goto_Target()
else
target=null
if(!got_target)
for(var/mob/player/Player in view(3))
target = Player
got_target=TRUE
break
sleep(10)
FindTarget()
//After we find a target, we call this to make the mob go to the target
proc/Goto_Target()
step_to(src, target)
//Hit Stuff
if(canhit && src.target in get_step(src, get_dir(src, src.target)))
world << "[src] attacks [src.target]"
AI_Hit_Cooldown()
sleep(move_delay)
FindTarget()
proc/AI_Hit_Cooldown()
canhit=FALSE
spawn(attack_delay)
canhit=TRUE
//When an enemy is created
New()
FindTarget()
//Mobs below + their stats
Blob
icon='Icons/Enemies/Blob.dmi'
//Blob stats
attack_power=3
So right now, I have that.. I think it could be better optimized in techniques I don't know yet. I think it's actually pretty important in case i have a lot of mobs.. I'm just curious on better ways of creating AI targeting + movement.
instead.