ID:261537
 
I started making my own random combat code today, and I'm having ONE LITTLE problem that's driving me insane! Here's the code,

area
battleturf
icon = 'Turfs2.dmi'
icon_state = "Grass"
var/dice = "1d6"
Entered(mob/M as mob)
var/h = roll(dice)
if(h == 2)
M.oldx = M.x
M.oldy = M.y
M.oldz = M.z
usr << "BATTLE!"
M << "Click on the monster to start!"
M.loc = locate("Fight")

else if(h == 3)
M.oldx = M.x
M.oldy = M.y
M.oldz = M.z
usr << "BATTLE!"
M << "Click on the monster to start!"
M.loc = locate("Fight2")

So when a mob enters the battleturf area, it rolls a die, and if it rolls a 2 or a 3, they go to a battle area. But the problem I'm having is, if a mob enters the battleturf and they don't fight a monster on their first step, that mob can walk on other battleturf areas without fighting at all. But when they step on something that doesn't have a battlearea, they can fight again by stepping on the battleturf. I think the problem is using the Entered(). And when a person walks on a battleturf tile, and walks on other one from that tile, it doesn't consider it as entering a new one, since it was already on one. I know I made this sound confusing, so if you don't understand the problem. I'll try to make it more clear. Thanks for the help anyone.
Anyone? I still haven't figured this out!
In response to Philipe The Bard
Battleturf should be a turf, not an area. An area you only enter (it should be Enter() instead of Entered(), probably, or you get into fights by running into walls) if you're outside it and you move into it. A turf you enter every time you move.