Accurate minefield.

This commit is contained in:
Ghommie
2020-04-01 05:19:29 +02:00
parent 04c8cb09a4
commit 73c52c0c6e
@@ -159,6 +159,8 @@
if(CHECK_BITFIELD(obj_flags, EMAGGED) && !exploding_hell)
exploding_hell = TRUE
explode_EVERYTHING()
if(QDELETED(src))
return
if(mine_sound)
switch(rand(1,3)) //Play every time a mine is hit
if(1)
@@ -367,10 +369,10 @@
var/row_limit = rows-1
var/column_limit = columns-1
var/mine_limit_v2 = mine_limit
if(rows > 11)
row_limit = 10
if(columns > 11)
column_limit = 10
if(rows > 21)
row_limit = 20
if(columns > 21)
column_limit = 20
if(mine_limit > (rows*columns) * 0.25)
mine_limit_v2 = 24
message_admins("[key_name_admin(user)] failed an emagged Minesweeper arcade and has unleashed an explosion armageddon of size [row_limit],[column_limit] around [ADMIN_LOOKUPFLW(user.loc)]!")
@@ -378,16 +380,27 @@
explosion(loc, 2, 5, 10, 15) //Thought you could survive by putting as few mines as possible, huh??
else
explosion(loc, 1, 3, rand(1,5), rand(1,10))
var/num_explosions = 0
for(var/y69 in y-row_limit to y+row_limit) //Create a shitton of explosions in irl turfs if we lose, it will probably kill us
for(var/x69 in x-column_limit to x+column_limit)
if(prob(mine_limit_v2)) //Probability of explosion happening, according to how many mines were on the board... up to a limit
var/turf/target = locate(y69,x69,z)
var/list/targets = list()
var/cur_y = y - round(row_limit * 0.5, 1)
var/start_x = x - round(column_limit * 0.5, 1)
for(var/row in table) //translate the mines locations into actual turf coordinates.
if(!locate(cur_y, start_x, z))
continue
var/cur_x = start_x
for(var/column in row)
var/coord_value = table[row][column]
if(coord_value == 10 || coord_value == 0) //there is a mine in here.
var/turf/target = locate(cur_y, cur_x, z)
if(!target)
continue
addtimer(CALLBACK(GLOBAL_PROC, /proc/explosion, target, 0, rand(1,2),rand(1,5),rand(3,10), FALSE), 10 * ++num_explosions)
if(num_explosions == mine_limit_v2)
return
targets += target
cur_x++
cur_y++
var/num_explosions = 0
for(var/T in shuffle(targets)) //Create a shitton of explosions in irl turfs if we lose, it will probably kill us
addtimer(CALLBACK(GLOBAL_PROC, /proc/explosion, T, 0, rand(1,2),rand(1,5),rand(3,10), FALSE), 15 * ++num_explosions)
if(num_explosions == mine_limit_v2)
return
#undef MINESWEEPERIMG
#undef MINESWEEPER_GAME_MAIN_MENU