Anyway, the problem is simple, I'm using the Swap Map library to make maps for a turn based battle system. I can use it to create the map and place everything that is needed on said map, but the problem is the map is always stuck in the exact same place. Meaning if two players enter seperate battles they will both be able to see the others battling.
Here is the only code that should be relevant to the problem.
mob/proc
InitiateBattle(var/mob/M, var/list/Monsters, var/intcombat=1, var/mob/CC)
if(!M)
return
var/swapmap/Batt=null
M.BattleLoc=M.loc
M.Battle=1
if(intcombat)
CC=M
M.CalledBattle=1
Batt=new("[M.key]",17,13,1)
M.battlemap="[M.key]"
var/xx=1
var/yy=1
for(xx=1, xx<=17, xx+=1)
for(yy=1, yy<=13, yy+=1)
var/turf/Battle/C=new(locate(xx,yy,Batt.z1))
C.icon_state="[xx-1],[yy-1]"
if(!intcombat)
Batt=SwapMaps_Find(CC.battlemap)
var/list/PartyList=list(M)
if(intcombat && M.Party.len>1)
for(var/mob/P in M.Party)
if(P!=M)
if(get_dist(P,M)<17)
PartyList.Add(P)
P.InitiateBattle(P,Monsters,0,M)
P.BattleSide=1
M.loc=locate(17-(M.BattlePos*2),M.PartyNum+1,Batt.z1)
M.dir=WEST
if(M.client) M.client.eye=locate(1,1,Batt.z1)
var/mpos=1
if(intcombat)
if(Monsters.len<=2) mpos=2
for(var/mob/E in Monsters)
E.loc=locate((E.BattlePos*2)-1,(mpos*2)-1,Batt.z1)
E.BattleSide=2
E.dir=EAST
mpos+=1
E.BattleGroup.Insert(1,Monsters)
E.BattleGroup.Insert(E.BattleGroup.len,PartyList)
M.BattleGroup.Insert(1,PartyList)
M.BattleGroup.Insert(M.BattleGroup.len,Monsters)
for(var/mob/MM in M.BattleGroup)
MM.BattleOrder=100-MM.agi
if(intcombat) BattleCalcTurn(M.BattleGroup)
Since my coding sucks and is sloppy I'll explain more or less what it does.
M is (or should be) you.
Monsters is a list of monsters in the fight.
intcombat is whether you initiated the battle or not
CC is the person who initiated the battle.
battlemap stores the id of the map and CalledBattle identifies the player as the one who initiated the fight (these are passed on to another player if there is one in the fight and the player with them logs out of the game, battlemap is also used to find and delete the map once the battle ends).
Then it goes more or less, if you initiated the combat set a few variables that only you need to initiate, then make a new map (Batt) with your key as an id. Then place turf on the map.
Then it goes on to figure out if you're in a party and who is in the party, and if they are close enough then bring them into the fight too.
Then place every player on the map. (If you didn't initiate the battle then find the map with the same id as the person who did initiate it's battlemap var and then place yourself on that map, otherwise just place yourself on the map)
And finally if you initiated the battle place the enemies on the map and decide whose turn it is.
That is all you'd need to know about the code and how it should work. But yeah, the maps that are created using the Swap Map library are always in the same place and overlap if more than one player is in battle.
So... Anyone know why this is happening and how to fix it?