proc/RandomBattle(mob/M,var/Place,var/Envir)
M.Oldloc = M.loc
M.OldX = M.x
M.OldY = M.y
M.OldZ = M.z
var/mob/M2 = null
var/mob/M3 = null
var/mob/M4 = null
M.End = 0
if(M.Party.len > 1)
switch(M.Party.len)
if(2)
M2 = M.Party[2]
M2.Oldloc = M.loc
M2.End = 0
M2.OldX = M.x
M2.OldY = M.y
M2.OldZ = M.z
if(3)
M2 = M.Party[2]
M2.Oldloc = M.loc
M2.End = 0
M3 = M.Party[3]
M3.Oldloc = M.loc
M3.End = 0
M2.OldX = M.x
M2.OldY = M.y
M2.OldZ = M.z
M3.OldX = M.x
M3.OldY = M.y
M3.OldZ = M.z
if(4)
M2 = M.Party[2]
M2.Oldloc = M.loc
M2.End = 0
M3 = M.Party[3]
M3.Oldloc = M.loc
M3.End = 0
M4 = M.Party[4]
M4.Oldloc = M.loc
M4.End = 0
M2.OldX = M.x
M2.OldY = M.y
M2.OldZ = M.z
M3.OldX = M.x
M3.OldY = M.y
M3.OldZ = M.z
M4.OldX = M.x
M4.OldY = M.y
M4.OldZ = M.z
var/mob/Mon1 = null
var/mob/Mon2 = null
var/mob/Mon3 = null
var/mob/Mon4 = null
var/mob/Mon5 = null
var/mob/Mon6 = null
var/mob/Mon7 = null
var/mob/Mon8 = null
var/mob/Mon9 = null
M << sound(M.BattleMusic(),1)
if(M.Dead) M.icon_state = "Dead"
else M.icon_state = "Stance"
if(M2)
M2 << M2.BattleMusic()
if(M2.Dead) M2.icon_state = "Dead"
else M2.icon_state = "Stance"
if(M3)
M3 << M3.BattleMusic()
if(M3.Dead) M3.icon_state = "Dead"
else M3.icon_state = "Stance"
if(M4)
M4 << M4.BattleMusic()
if(M4.Dead) M4.icon_state = "Dead"
else M4.icon_state = "Stance"
var/swapmap/battlemap = SwapMaps_CreateFromTemplate(Envir)
var/turf/T = locate(2,12,battlemap.z1)
var/turf/T2 = locate(2,10,battlemap.z1)
var/turf/T3 = locate(2,8,battlemap.z1)
var/turf/T4 = locate(2,6,battlemap.z1)
var/turf/T5 = locate(2,4,battlemap.z1)
var/mob/O = locate(7,7,battlemap.z1)
M.client.eye = O
M.dir = EAST
if(M2)
M2.dir = EAST
M2.client.eye = O
if(M3)
M3.dir = EAST
M3.client.eye = O
if(M4)//4 Players
M4.dir = EAST
M4.client.eye = O
M.loc = get_step(T, SOUTH)
M2.loc = get_step(T2, SOUTH)
M3.loc = get_step(T3, SOUTH)
M4.loc = get_step(T4, SOUTH)
walk(M2,0)
walk(M3,0)
walk(M4,0)
M.Update_Bars("On")
M.Stat_Bonus()
M2.Update_Bars("On")
M2.Stat_Bonus()
M3.Update_Bars("On")
M3.Stat_Bonus()
M4.Update_Bars("On")
M4.Stat_Bonus()
else//3 Players
M.loc = get_step(T, SOUTH)
M2.loc = get_step(T3, SOUTH)
M3.loc = get_step(T5, SOUTH)
walk(M2,0)
walk(M3,0)
M.Update_Bars("On")
M.Stat_Bonus()
M2.Update_Bars("On")
M2.Stat_Bonus()
M3.Update_Bars("On")
M3.Stat_Bonus()
else//2 Players
M.loc = get_step(T2, SOUTH)
M2.loc = get_step(T4, SOUTH)
walk(M2,0)
M.Update_Bars("On")
M.Stat_Bonus()
M2.Update_Bars("On")
M2.Stat_Bonus()
else//1 Player
M.loc = get_step(T3, SOUTH)
M.Update_Bars("On")
M.Stat_Bonus()
switch(Place)
if("The Door")
if(prob(20))
Mon1 = new/mob/Green_Slime(locate(12,9,battlemap.z1))
Mon1.name = "Green Slime 1"
Mon2 = new/mob/Green_Slime(locate(12,7,battlemap.z1))
Mon2.name = "Green Slime 2"
Mon3 = new/mob/Green_Slime(locate(12,5,battlemap.z1))
Mon3.name = "Green Slime 3"
else
Mon1 = new/mob/Green_Slime(locate(12,10,battlemap.z1))
Mon1.name = "Green Slime 1"
Mon2 = new/mob/Green_Slime(locate(12,8,battlemap.z1))
Mon2.name = "Green Slime 2"
Mon3 = new/mob/Green_Slime(locate(12,6,battlemap.z1))
Mon3.name = "Green Slime 3"
Mon4 = new/mob/Green_Slime(locate(12,4,battlemap.z1))
Mon4.name = "Green Slime 4"
var/list/Order = Speedlist(M,M2,M3,M4,Mon1,Mon2,Mon3,Mon4,Mon5,Mon6,Mon7,Mon8,Mon9)
Battle(Order,battlemap)
Problem description:
I'm using swapmaps for a turn-based battle system. Recently, I've had a strange error that was not around before. Instead of creating multiple maps, something just decides "Well, I'm sick of creating new maps. Here, just use this first one."
In other words, the battles are no longer in different areas and they're all overlapping.
Not entirely sure if that snippet is what's causing the problem.
And yes, I'm aware that there are much more efficient ways of writing most of this, but as of now I'm not worried about that. I'm quite capable of fixing it, so don't bother yourself with it, okay? =P
In the Battle() proc I delete the map after everyone's been taken off of it and all the NPC mobs deleted.
var/turf/T = locate(2,12,battlemap.z1)
var/turf/T2 = locate(2,10,battlemap.z1)
var/turf/T3 = locate(2,8,battlemap.z1)
var/turf/T4 = locate(2,6,battlemap.z1)
var/turf/T5 = locate(2,4,battlemap.z1)
var/mob/O = locate(7,7,battlemap.z1)
Take a closer look at that. You are placing everything at the same x and y location, but using the battlemaps z location. The Swap Map library doesn't create every new map on a new z level, it might create multiple maps with the same z level.
Chances are you've assumed it does create each new map on a new z level.
To fix the problem you basically want to add in the battlemaps x and y locations too.
var/turf/T = locate(battlemap.x1+2,battlemap.y1+12,battlemap.z1)
var/turf/T2 = locate(battlemap.x1+2,battlemap.y1+10,battlemap.z1)
var/turf/T3 = locate(battlemap.x1+2,battlemap.y1+8,battlemap.z1)
var/turf/T4 = locate(battlemap.x1+2,battlemap.y1+6,battlemap.z1)
var/turf/T5 = locate(battlemap.x1+2,battlemap.y1+4,battlemap.z1)
var/mob/O = locate(battlemap.x1+7,battlemap.y1+7,battlemap.z1)
Something along the lines of that will fix the problem. You'd obviously also do something similar to that whenever placing other things on the battlemap, such as monsters and so on.