ID:162591
 
hello,

DM says the code is fine but the game will not start if i have a (con)my ai on the map otherwise the game runs fine
i think the loop is bad but i tried everything

mob

var
mob/target
proc
attackloop(var/mob/M)
while(target && target ==M)
if(target in oview(src, 1))
attackurst(target)
sleep(3)
attackurst(var/mob/victim)
src<<sound('rifle_fire.wav')
if(prob(50))
src<<"You get hit by conscript for 5 damage!"
src.hp -= 5
if(usr.hp <= 0)
src<<"your dead"
else
src<<"The conscript has missed you!"


getTarget(var/mob/M)
if(M != src)
target = M
spawn() attackloop(M)

soviet
New()
..()
spawn() AILoop()
proc
AILoop()
while(!client)
if(!target)
getTarget(locate(/mob/player/) in oview(5,src))
else
if(target in oview(5,src))
step_towards (src, target)
else
target = null
sleep (3)
con
icon = 'soviet.dmi'
icon_state = "con"
hp = 30

                while(!client)
if(!target)
getTarget(locate(/mob/player/) in oview(5,src))


There needs to be a sleep somewhere within this branch (in fact, the sleep() you already have should just be moved so it always executes). Otherwise, your AI is just searching for a target as often as it can, which means if it can't find a target, it's going to just lock up the game with this loop.

Your attackurst proc is also messed up. src is the mob attacking. victim is the mob being attacked. usr is completely invalid.
In response to Garthor (#1)
thx at least it dont lock up ..now...

how do i play the sound for victim here? or tell him he was hit or not?

why if i attack the ai(con) he dies with 1 hp worth of dmg i set his hp to 30?

In response to Kylemark (#2)
I already told you what your problem was. Go fix it.