ID:142470
 
(Byond Version is 418.984)
Code:
               Enemy_Two  //PURE AGRESSIVE TYPE PLAYER/MONSTER ONLY
icon='Test Monster.dmi'
icon_state = "2"
density = 1
luminosity = 2
HP = 10
MaxHP = 10
MeleeChance = 100
KillRate = 10
AttackRange = 1
Attack_List = list("Normal","Side to Side","Half Rotation","Full Rotation","Pause")
MoveRate = 1
RunChance = 0
SpellChance = 0
Charging = 0
Spell_Picked = 0
Element_Resistance = list("Fire" = 0, "Ice" = 0,"Thunder" = 0, "Aero" = 0, \
"Venom" = 0, "Drain" = 0, "Earth" = 0)
Behavoir() //Pure melee Behavoir
..()
for(var/mob/Base/M in view(1)) // goes on up until view(6), can attack either the Player or Other enemies.
world << 1
if(prob(MeleeChance))
Attack(M, AttackRange, Attack_List, src)//Range - 1
return
else
if(prob(RunChance))
walk_away(M, src, MoveRate, 0)
return
else return
world << "Called return"
return

client/Move()
// . = ..()
// if(.)
var/mob/Base/PC/M = usr
if(M.InDungeon)
if(M.Stamina_Step == M.Stamina_Reduc_Rate)
M.Stamina -= 1 //LATER ADD REMOVAL FROM DUNGEON
else M.Stamina_Step += 1
M.Apply_Effects(M, M.Effect_List)
else //Normal
..()
for(var/mob/Base/Enemy/E in Enemy_List)
E.Behavoir()


Problem description:
This is a single-player game. :p
The Behavoir() is called whenever the Player is in a dungeon.
But within the Dungeon, where ever I am, the monster always says I'm within a range of 1 and calls the Attack proc, (the Attack() is normal because it's MeleeChance is 100%) It could be on a different Z-level altogether and still return a range of 1. The Enemies are loaded into a var/list for easy access.
Before I had changed the coding, I had the monsters loaded into a list that the Player held, this bug happened, so I moved the list to a world thing. An idea I have of the cause would be that since I've coated every Z-level in an area/Darkness (for luminosity darkness) it would show the player as close by somehow, but thats quite far-fetched.

If anyone has any ideas, I'll gladly listen.

Don't use usr in procs. view(1) is the same with view(1,usr).
Use view(1,src)
In response to Jemai1
Ah. I've changed it to src, but the problem still persists.
In response to Mechanios
</dm>var/mob/Base/M in view(1,src)</dm>
I don't think it's you who's in the enemy's range.
The "Enemy" has a type of /mob/Base so the enemy itself is in the view() list. Use oview() instead of view().

OR

Don't let it attack it's own types.
                    Behavoir() //Pure melee Behavoir
..()
for(var/mob/Base/M in view(1,src)) // goes on up until view(6), can attack either the Player or Other enemies.
if(M.type != src.type) //Type Check
world << 1
if(prob(MeleeChance))
Attack(M, AttackRange, Attack_List, src)//Range - 1
return
else
if(prob(RunChance))
walk_away(M, src, MoveRate, 0)
return
else return
world << "Called return"
return

Note: return stops the execution of the current proc.
In response to Jemai1
Brilliant! I never thought of checking what it's attacking. but, thank you. The monsters are going to attack each, pending killrate because that's how they 'evolve' per say.

I'll remember that view includes the src itself (given the situation.) Thanks again.
In response to Mechanios
No problem.