tl;dr version: with just a sniper scope, spawn area is 228x126
Relevant pieces of code(if my files are correct) seems to be
Code:
public static int sWidth = 1920;
public static int sHeight = 1080;
private static int spawnRangeX = (int) ((double) (NPC.sWidth / 16) * 0.7);
private static int spawnRangeY = (int) ((double) (NPC.sHeight / 16) * 0.7);
public static int safeRangeX = (int) ((double) (NPC.sWidth / 16) * 0.52);
public static int safeRangeY = (int) ((double) (NPC.sHeight / 16) * 0.52);
Code:
if (Main.player[plr].inventory[Main.player[plr].selectedItem].type == 1254 || Main.player[plr].inventory[Main.player[plr].selectedItem].type == 1299 || Main.player[plr].scope)
{
float num3 = 1.5f;
if (Main.player[plr].inventory[Main.player[plr].selectedItem].type == 1254 && Main.player[plr].scope)
num3 = 1.25f;
else if (Main.player[plr].inventory[Main.player[plr].selectedItem].type == 1254)
num3 = 1.5f;
else if (Main.player[plr].inventory[Main.player[plr].selectedItem].type == 1299)
num3 = 1.5f;
else if (Main.player[plr].scope)
num3 = 2f;
NPC.spawnRangeX += (int) ((double) (NPC.sWidth / 16) * 0.5 / (double) num3);
NPC.spawnRangeY += (int) ((double) (NPC.sHeight / 16) * 0.5 / (double) num3);
NPC.safeRangeX += (int) ((double) (NPC.sWidth / 16) * 0.5 / (double) num3);
NPC.safeRangeY += (int) ((double) (NPC.sHeight / 16) * 0.5 / (double) num3);
}
item id 1254 is sniper rifle, 1299 is binoculars
Scope is rifle or sniper scope, but only if selected weapon uses bullets as ammo, or candy corn, or oddly enough gel. Who knew flamethrower was a precision weapon?
Spawn area goes from -spawnRange to +spawnRange.
With just a sniper scope spawn area is extended by 30 blocks horizontally in both directions, and by 16 blocks vertically in both directions.
(84+30)*2=228
(47+16)*2=126
So, with just a sniper scope, spawn area is 228x126
Afaik it's counted from the top left block the player character sprite occupies.
Hope that helps and I didn't mess up anything
P.S. Afaik casting to integer drops non integer part, aka rounds down
P.P.S. Didn't test in-game
edit: I guess spawn area is technically 1 less on the right and bottom sides, because random function used works that way, so it's technically (player position - spawn range) to (player position + spawn range - 1). But I don't recall at which position mobs are spawned, so maybe their width height accounts for that? Kind of minor but figured I'd edit it in anyway.