Before I get into things, I am currently coding for a game that's been around for ages, so I'm working with very old code. Likewise, I am probably less experienced at programming than a novice, so please bare with me. I am, more or less, an oldbie who was given permission to edit the source and host said game.
Now onto the issue we're having. For years, this game has had sprite overlapping issues, and now that I'm at the helm, I want to try and get to the bottom of it. The game uses .pngs for enemy mobs (this is a turn-based RPG for the record.) Smaller sprites seem to overlap when larger sprites are being displayed on screen. I believe this is the code for enemy mob placement.
Code:
var/totwidth = mmm.pixwidth
for (var/mob/NPC/enemys/m2 in mmm.group)
totwidth += m2.pixwidth
var/startwidth = totwidth/2
startwidth = round(startwidth/32-0.5)*-1
mmm.loc = locate(m.x+startwidth,m.y+2,m.z)
var/nextstartloc
var/nextoffsetpix
if (mmm.pixwidth<32)
nextstartloc = startwidth
nextoffsetpix = mmm.pixwidth
else if (mmm.pixwidth<64)
nextstartloc = startwidth+1
nextoffsetpix = mmm.pixwidth-32
else if (mmm.pixwidth<96)
nextstartloc = startwidth+2
nextoffsetpix = mmm.pixwidth-64
else if (mmm.pixwidth<128)
nextstartloc = startwidth+3
nextoffsetpix = mmm.pixwidth-96
else
nextstartloc = startwidth+4
nextoffsetpix = mmm.pixwidth-128
for (var/mob/NPC/enemys/m2 in mmm.group)
m2.loc = locate(m.x+nextstartloc,m.y+2,m.z)
m2.pixel_x = nextoffsetpix
if (m2.pixwidth<32)
nextoffsetpix = nextoffsetpix+m2.pixwidth
else if (m2.pixwidth<64)
nextoffsetpix = nextoffsetpix+m2.pixwidth-32
nextstartloc+=1
else if (m2.pixwidth<96)
nextoffsetpix = nextoffsetpix+m2.pixwidth-64
nextstartloc+=2
else if (m2.pixwidth<128)
nextoffsetpix = nextoffsetpix+m2.pixwidth-96
nextstartloc+=3
else
nextoffsetpix = nextoffsetpix+m2.pixwidth-128
nextstartloc+=4
while (nextoffsetpix>32)
nextoffsetpix -= 32
nextstartloc += 1
If anyone has any advice on what to change, it would very much be appreciated!
The older sources use the tiled map format, which is what caused the bug for me.
If it doesn't work, feel free to comment back, I'll try to help out where I can.