mob
blue
icon = 'arcade2.dmi'
icon_state = "blue"
var/mob/Target
New()
..()
spawn(5)
src.Wander()
proc
Wander()
while(src)
sleep(5)
for(var/mob/M in oview()) // how far you want the enemy to target a player
src.Target = M
break
if(src.Target) .
walk_towards(src,Target,5)
else
walk_rand(src,5)
Problem description:
well i had more of a code but i thought i did something backwards so i undid it all and it wont let me redo -.- but im trying to make this mob target the usr if it touches the usr then usr paclife - 1 and if usr paclife = 0 then he gets send to usr loc = locate(/turf/begining) otherwise he gets sent to usr.loc = locate(/turf/pacman) and for he needs to not be able to walk through walls =\ if you can help thanks
So look up the oview() proc and check out the arguments and their default values; you've got usr abuse there, in fact.
Side notes:
--Why wait 5 ticks before launching the proc? I realize it is probably somewhat "for good measure", but it could potentially (sure, not too likely) cause more harm than good. But it won't blow up your game if you don't wait between things that don't loop.
--You should use the locate() proc instead of a one-iteration for() loop (one that has break at the end).
--Your proc can potentially set a new Target every iteration which could prevent the mob from ever reaching a current Target, etc. You'll probably want to add code to the beginning of it to handle what to do if there is already a Target, including checking if it is still valid (exists, and in sight...).