ID:150012
 
I edited a code to mkae this code:


atom/movable
var
HP = 10
Armor = 1
Def = 1

mob/elf
HP = 20

var
STR = 5

next_action_time
action_delay = 10
movement_probability = 50


New()
next_action_time = world.time + rand(10)
return ..()


base_EventCycle(world_time)
if (next_action_time <= world_time)
if (isDead())
return

TakeAction()

next_action_time = world_time + action_delay


Move()
if (isDead())
return 0

return ..()


proc/TakeAction()
if (client)
return

if (prob(movement_probability))
step_rand(src)
return



proc/TakeDamage(mob/attacker, potential_damage)
if (isDead())
view(src) << "[attacker] hits [src]'s dead body!"
return

var/defense_modifier = Armor + Def
potential_damage -= defense_modifier

if (potential_damage > 0)
HP -= potential_damage
view(src) << "[attacker] hit [src] for [potential_damage] points damage!"

if (isDead())
view(src) << "[attacker] killed [src]!"
Spawn()
return
else
view(src) << "[attacker]'s attack bounces harmlessly off [src]."

proc/Spawn()
usr.loc = locate(66,32,1)

proc/isDead()
if (HP <= 0)
return 1
return 0



TakeAction()
var/action_taken

for (var/mob/other_mob in oview(1, src))


Attack(other_mob)
action_taken = 1

for (var/mob/other_mob in oview(3, src))


view(src) << "[src] is going after [other_mob]!"
step_towards(src, other_mob)
action_taken = 1

if (action_taken)
return

..()

Now the elf attacks it self instead of attacking the user for some reason and when it dies it spawns at (20,20,1) instead of where i want it. Can someone help me with this?