mob
Enemy
New()
set background = 1
..()
AggroCheck()
proc
AggroCheck()
do
world << "<font color=red>Starting for loop to search mobs nearby.</font>"
for(var/mob/Player/M in oview(src.aggrorange))
world << "<font color=red>Mob [M] found!</font>"
if(M.Playerflag==1)
world << "<font color=red>Mob's Playerflag is [M.Playerflag]</font>"
src.target=M.name
world << "<font color=red>[src]'s target is [src.target]!</font>"
src.combatflag=1
src.aggroName.len++
src.aggroList.len++
src.aggroName[1]+=M.name
src.aggroList[1]+=0
world << "<font color=red>aggroName(1) = [src.aggroName[1]] - aggroList(1) - [src.aggroList[1]]</font>"
break
sleep(10)
while(src.currenthp>0&&src.combatflag==0)
verb
Set_Combat_Flag(mob/M in oview())
set category="Debug"
if(M.combatflag==1)
M.combatflag=0
M.target=null
src.Playerflag=1
else M.combatflag=1
world << "<font color=red>[M]'s combat flag is set to [M.combatflag].</font>"
if(istype(M, /mob/Enemy/))
M:AggroCheck()
Problem description:
So I'm having an issue with this little snippet of code. What's supposed to happen here, is that the mobs start looping through the mob's defined aggro range, and look for a mob with a Playerflag set to 1, indicating that it's a player mob. I know I could do this by just checking the client, but that's irrelevant.
Once the mob finds a player in range, it sets that player to their internal target var, and stops looping. The lists are just threat lists, one for the name of the player on the threat list, and the other for the threat value. All of the world statements found in this code are simple debug statements so I know what's going on.
Now, the problem I'm having, is that the mob will perform the loop, once it finds a mob, it sets the target, stops looping, adds the player's name to their threat list, and sets an amount (0). It also sets the mob's combat flag to 1, so that the loop does not start up again. Everything works like it's supposed to!...until I use the debug verb to reset the mob's flag to 0. The loop starts up, but it is unable to find a player. It just continues to loop through without finding a player in range, even when one is standing next to it.
If I need to go into detail more, or post more information, please do not hesitate to ask. Thank you in advance for any help.