ID:149997
 
I wanted to code aggressive mobiles into my game, this is my current code.
mob/npc/enemy

New()
world << "(Debug) I here!"
AggyCheck()
return ..()

mob/npc/enemy/proc
AggyCheck()
var/mob/pc/M
if(aggressive == 1)
world << "(Debug) Aggy is run"
spawn while(1)
sleep(10)
if(M in oview(1))
if(M:enemy == null)
Fight(M)

I also have my alley cat mob with his aggressive set to one (duh). I get neither of my debug messages when I run the game though, what's wrong?
Polatrite wrote:
I wanted to code aggressive mobiles into my game, this is my current code.
mob/npc/enemy

New()
world << "(Debug) I here!"
AggyCheck()
return ..()

I also have my alley cat mob with his aggressive set to one (duh). I get neither of my debug messages when I run the game though, what's wrong?

I don't know if it will help, but you might want to try moving the call to ..() to an earlier part of New(). My guess is that what's happening here is, something's going wrong in AggyCheck() because the first time it's called, mob.loc==null--which won't happen if you move up ..() to the beginning of New(). If AggyCheck() crashes, it probably does so before the player is even technically logged into the game. (The world output messages you put in are being displayed before the login, I think.)

Another debugging idea is to run AggyCheck() after a spawn(10) or so, so you can see the debug messages.

Lummox JR
Most likely the mob is created, and the debug messages go out to the world before your client is connected. You have to either try it on a mob created during run-time, or spawn the debug message with a delay.
In response to Lummox JR
Alright, I can see my (spam) of debug messages, but only for the New() proc, not AggyCheck(), I did move the ..() call to the beginning, and spawned the debug and Aggy 2 seconds. So what could be wrong in AggyCheck? Here it is again.
mob/npc/enemy/proc
AggyCheck()
var/mob/pc/M
if(aggressive == 1)
world << "(Debug) Aggy is run"
spawn while(1)
sleep(10)
if(M in oview(1))
if(M:enemy == null)
Fight(M)
In response to Polatrite
Polatrite wrote:
Alright, I can see my (spam) of debug messages, but only for the New() proc, not AggyCheck(), I did move the ..() call to the beginning, and spawned the debug and Aggy 2 seconds. So what could be wrong in AggyCheck?

I would suggest two changes: First, put in another debug message before the if() statement; that should appear if the proc is called. Second, change if(aggressive==1) to just if(aggressive), which should work as long as it's non-zero. Odds are the var is set correctly and all that, but there's no point making this check as narrow as possible.

Lummox JR