ID:261942
 
mob/guard
icon='stuff.dmi'
icon_state="guard1"
density=1
hp = 1000
evil = 0
NPC = 1
New()
LookAround()
proc/LookAround()
if(istype(/mob/Player/M in view(10))
for(var/mob/Player/M in view(10))
if(M.evil = 1)
ai_walk_to()
Attack(M)
else
..()
There is an error somewhere in there. It says missing comma or right parent. BUT when I take what it tells me has the error out the coding on the line gets the error.for(var/mob/Player/M in view(10)) is the line that supposably has an error.
mob/proc/LookAround() //make this a mob/proc
for(var/mob/M in view(10,src)) //view of src, if there is no argument, it defaults to usr, which is not good all the time in procs.
if(M.evil) //If the mob is evil
ai_walk_to() //call the walk to proc
Attack(M) //call the attack proc
return //stop
else //else
return //stop
mob/guard
icon='stuff.dmi'
icon_state="guard1"
hp = 1000
evil = 0
NPC = 1
New()
..()
while(1) //infinate loop
LookAround() //call the proc
sleep(50) //wait 5 seconds before looking around again


I haven't done stuff with New() in a little while, so you may need a spawn. Hopefully someone will correct me if Im wrong, and sorry if I am.
Dragon warrior2662 wrote:
proc/LookAround()
if(istype(/mob/Player/M in view(10))
for(var/mob/Player/M in view(10))

There is an error somewhere in there. It says missing comma or right parent.

Right parenthesis. The terminology makes a difference.

BUT when I take what it tells me has the error out the coding on the line gets the error.for(var/mob/Player/M in view(10)) is the line that supposably has an error.

This kind of error, a missing parenthesis, usually occurs on the previous line, not on the line where it's reported. If you think about why, this makes perfect sense. The compiler is going along minding its business, looking for that last parenthesis or whatever to finish what it's working on, and it runs into something completely unexpected. "Hey wait a minute! Where's that last parenthesis?!"

It doesn't help that you have an indentation error in there too, but here's the real problem line:
if(istype(/mob/Player/M in view(10))
Notice you have 3 opening parentheses and 2 closing. But that's not the worst of it. You're using istype() completely wrong. It doesn't take an "in view()" clause at the end, and unless /mob/Player/M is a type path itself (and not /mob/Player, which you really meant), you'll get an error about the path not being found. Besides, the variable M hasn't even been defined yet. I think this is what you wanted:
if(locate(/mob/Player) in view(10, src))
Yep, you forgot to put src in view() too, because usr is the default and it's wrong here. You need to change the for() below this as well.

But the above line you don't even need. I'd leave it out completely anyway. The for() loop will do the same thing; if there isn't a mob to be found it will just skip past the loop.

Within that for() loop, your if() check on the evil var is also wrong, on two levels. You're using the = operator instead of ==, which will generate a compiler error. You're also testing against 1 instead of just using it as a true/false var as you no doubt intended. Just do if(M.evil) instead. And unless ai_walk_to() is just supposed to guess at a target, you probably need to tell it where to walk.

Then, you need to actually change your LookAround() to a loop, and make it spawn() out of New() or else you'll get some weird results. If you don't make it a loop, the guard will take one look around and then do nothing ever again. If you don't spawn() it out of New(), New() will never complete normally.

And "supposably" isn't a word. The word is "supposedly".

Lummox JR