ID:148528
 
Hi im coding a code for my demo and was wandoring How do i get him to stay still couse i got then From a demo and im trying to get it to work for a Stay still guard thank you for reading

mob/guards
var/mob/monster/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(1))
step_towards(src,P)
else
step_rand(src)
for(P in view(src))
break
sleep(10)
spawn(40)
Wander()

Bump(mob/M)
if (istype(M,/mob/monster))
Attack(M)

proc/Attack(mob/M)
var/damage = rand(1,str)
if(usr.str - M.defense > 0)
M.HP -= usr.str - M.defense
view(src) << "[src] Attacks [M] For ([damage])!"
M.DeathCheck()
else M << "[src] Bounces off you!", usr << "You Bounce off [M]"
Guard
icon = 'guards.dmi'
icon_state = "guard"
str = 100
HP = 200
maxHP = 200
defense = 100
gold = 2000
exp = 100
Just delete the whole else section where it sas to step randomly. That will do it. You don't need the else if you want them to stand still.
Since Attack() is a proc, not a verb, usr is out of place there; get rid of it.

Lummox JR
Just a few hints:
> for(P in view(src))
> break


What is that supposed to do? Makes no sense to me... A for statement should always include a bit more that just break.... let's go through this:

We enter the for, and look for a player in view. Ah ha! There's one, let's continue. Next command: break. Terminate the for loop. The point of that? (To slow the CPU?) Use sleep() if you need to pause for a couple secs.

Also, it is kinda nice (Plus you won't get yelled at) if you place your code between DM tags. Example:

<dm>HI!</dm>
produces:
HI!


-<font color='#ffff00'>Nova</font>