ID:261762
 
Why is this going through an infintate loop?
mob/player/verb/Attack() for(var/mob/monster/M in oview(1,usr)) if(istype(M,/mob/monster/Giant_Rat)) if(M.dead==0) Attack(M,usr)

Also why isnt my monster attacking the player or going after it when its with in 5 spaces.

mob/monster icon='Monsters.dmi' density=1 New() ..() GetDist(src) proc/GetDist(var/mob/monster/M) for(var/mob/player/P in oview(5,src)) if(P.dead!=1) if(P in oview(1)) Attack(P,M) else step_towards(M,P) spawn(10) GetDist(M) break
Green Lime wrote:
Why is this going through an infintate loop?
mob/player/verb/Attack()
for(var/mob/monster/M in oview(1,usr))
if(istype(M,/mob/monster/Giant_Rat))
if(M.dead==0)
Attack(M,usr)

Because Attack() is calling itself over and over again.
That should be if(!M.dead) anyway.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Green Lime wrote:
Why is this going through an infintate loop?
mob/player/verb/Attack()
> for(var/mob/monster/M in oview(1,usr))
> if(istype(M,/mob/monster/Giant_Rat))
> if(M.dead==0)
> Attack(M,usr)

Because Attack() is calling itself over and over again.
That should be if(!M.dead) anyway.

Lummox JR

Hmm O.o Im not stuiped Im just confussed. Why is it looping over and over again?
In response to Green Lime
Green Lime wrote:
Lummox JR wrote:
Green Lime wrote:
Why is this going through an infintate loop?
mob/player/verb/Attack()
> > for(var/mob/monster/M in oview(1,usr))
> > if(istype(M,/mob/monster/Giant_Rat))
> > if(M.dead==0)
> > Attack(M,usr)

Because Attack() is calling itself over and over again.
That should be if(!M.dead) anyway.

Lummox JR

Hmm O.o Im not stuiped Im just confussed. Why is it looping over and over again?

Well I put this at the bigining of my proc/Attack(var/mob/victum,var/mob/attacker) proc. <code>world << "ATTACK [victum], [attacker]."</code> and it doesnt output any thing. Making me think that its not even opening the Attack() proc doesnt even get to it I dont think it cant. I think it has to do with some strange For() bug.

The only thing I can come up with is its a bug in the Byond system or a virii of some kinds has caused a bug in my byond.
In response to Green Lime
You're naming the verb, and the proc the same thing, that makes one override the other. You could name your verb something else and use "set name" to make it "Attack".
In response to Nadrew
Nadrew wrote:
You're naming the verb, and the proc the same thing, that makes one override the other. You could name your verb something else and use "set name" to make it "Attack".

*claps for Nadrew* Bravo Nadrew you have my respect. :)
In response to Green Lime
Green Lime wrote:
The only thing I can come up with is its a bug in the Byond system or a virii of some kinds has caused a bug in my byond.

It always amuses me when people jump to conclusions like that. =) If your code has a problem, it's probably your fault (sounds a bit harsh, but it's true =) ). Be really, really certain that it can't possibly be anything else than a BYOND bug before saying it is. And a virus that caused a problem like that would have to be either very lucky (freak chance caused by slight data corruption in EXACTLY the right places and in EXACTLY the right way), or specifically targeted at BYOND. And I doubt there are any of the latter. =)