Skip to content

Commit

Permalink
Merge pull request TauCetiStation#2554 from volas/asteroid
Browse files Browse the repository at this point in the history
Asteroid
  • Loading branch information
volas authored Jul 4, 2018
2 parents 0c4cbac + 34d4bfe commit fd9eb23
Show file tree
Hide file tree
Showing 8 changed files with 152 additions and 9 deletions.
8 changes: 5 additions & 3 deletions code/datums/helper_datums/map_template.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
/datum/map_template/New(path = null, map = null, rename = null)
if(path)
mappath = path
if(mappath)
preload_size(mappath)
if(map)
mapfile = map
if(mappath)
preload_size(mappath)
else if(mapfile)
preload_size(mapfile)
if(rename)
name = rename

/datum/map_template/proc/preload_size(path)
loaded_stuff = maploader.load_map(file(path), 1, 1, 1, cropMap=FALSE, measureOnly=TRUE)
loaded_stuff = maploader.load_map(get_file(), 1, 1, 1, cropMap=FALSE, measureOnly=TRUE)
if(loaded_stuff && loaded_stuff.len)
var/list/bounds = loaded_stuff["bounds"]
if(bounds && bounds.len)
Expand Down
8 changes: 6 additions & 2 deletions code/game/turfs/turf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,12 @@
qdel(L)

//Creates a new turf
/turf/proc/ChangeTurf(path, force_lighting_update)
/turf/proc/ChangeTurf(path, force_lighting_update, list/arguments = list())
if (!path)
return
/*if(istype(src, path))
stack_trace("Warning: [src]([type]) changeTurf called for same turf!")
return*/

// Back all this data up, so we can set it after the turf replace.
// If you're wondering how this proc'll keep running since the turf should be "deleted":
Expand Down Expand Up @@ -211,7 +214,8 @@
if(S.zone)
S.zone.rebuild()

var/turf/W = new path(src)
arguments.Insert(0, src)
var/turf/W = new path(arglist(arguments))

W.has_resources = has_resources
W.resources = temp_res
Expand Down
1 change: 1 addition & 0 deletions code/modules/admin/admin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ var/global/BSACooldown = 0
<A href='?src=\ref[src];secretsfun=ionstorm'>Spawn an Ion Storm</A><BR>
<A href='?src=\ref[src];secretsfun=spacevines'>Spawn Space-Vines</A><BR>
<A href='?src=\ref[src];secretsfun=comms_blackout'>Trigger a communication blackout</A><BR>
<A href='?src=\ref[src];secretsfun=drop_asteroid'>Drop asteroid</A><BR>
<BR>
<B>Fun Secrets</B><BR>
<BR>
Expand Down
10 changes: 9 additions & 1 deletion code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,8 @@
return

else if(href_list["secretsfun"])
if(!check_rights(R_FUN)) return
if(!check_rights(R_FUN|R_EVENT))
return

var/ok = 0
switch(href_list["secretsfun"])
Expand Down Expand Up @@ -2332,6 +2333,13 @@
feedback_add_details("admin_secrets_fun_used","OO")
usr.client.only_one()
message_admins("[key_name_admin(usr)] has triggered a battle to the death (only one)")
if("drop_asteroid")
if(!check_rights(R_EVENT))
to_chat(usr, "<span class='warning'>You don't have permissions for this</span>")
return
feedback_inc("admin_secrets_fun_used",1)
feedback_add_details("admin_secrets_fun_used","ASTEROID")
usr.client.drop_asteroid()
if(usr)
log_admin("[key_name(usr)] used secret [href_list["secretsfun"]]")
if (ok)
Expand Down
114 changes: 114 additions & 0 deletions code/modules/admin/verbs/drop_asteroid.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/client/proc/drop_asteroid()
if(!check_rights(R_EVENT))
return

var/side_x = input(usr, "Please input the width for asteroid", "Width" , "") as num|null
var/side_y = input(usr, "Please input the height for asteroid", "Height" , "") as num|null

if(!side_x || !side_y)
return

var/turf/T = get_turf(usr)

message_admins("\blue [key_name_admin(usr)] creates the [side_x]x[side_y] asteroid on [T.x],[T.y],[T.z] [ADMIN_JMP(T)]")
log_admin("[key_name_admin(usr)] creates the [side_x]x[side_y] asteroid on [T.x],[T.y],[T.z]")

var/datum/map_template/asteroid = new(map = generate_asteroid_mapfile(side_x, side_y))


T = locate(T.x - round(asteroid.width/2), T.y - round(asteroid.height/2) , T.z)
var/list/bounds = list(T.x, T.y, T.z, T.x + asteroid.width + 1, T.y + asteroid.height + 1, T.z)

for(var/mob/M in player_list)
if(M.z == T.z)
M << sound('sound/effects/Explosion3.ogg')

//shake the station!
for(var/mob/living/carbon/C in mob_list)
if(C.z == T.z)
if(C.buckled)
shake_camera(C, 4, 1)
else
shake_camera(C, 10, 2)
C.Weaken(8)
C.throw_at(get_step(C,pick(1,2,4,8)),16,3)

var/list/targetAtoms = list()
for(var/L in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
for(var/A in L)
targetAtoms += A

for(var/atom/movable/M in targetAtoms)
if(istype(M, /obj/machinery/atmospherics/) || istype(M,/obj/structure/cable/))
qdel(M)
else if(ishuman(M))
var/mob/living/carbon/human/H = M
if(prob(5))
H.gib()
else
M.ex_act(pick(1,3))

asteroid.load(T)

sleep(max(side_x*side_y/100, 10))
//fix for basetypes coped from old turfs in mapload
for(var/turf/T2 in block(locate(bounds[MAP_MINX], bounds[MAP_MINY], bounds[MAP_MINZ]),
locate(bounds[MAP_MAXX], bounds[MAP_MAXY], bounds[MAP_MAXZ])))
if(istype(T, /turf/simulated/floor/plating/airless/asteroid/) || istype(T, /turf/simulated/mineral/))
T2.basetype = /turf/simulated/floor/plating/airless/asteroid

#define SPACETURF "a"
#define FLOORTURF "b"
#define CAVETURF "c"
#define RESCAVETURF "d"
#define MOBTURF "e"
#define ARTTURF "f"

/proc/generate_asteroid_mapfile(size_x, size_y)
var/map = "\
\"[SPACETURF]\" = (/turf/space,/area/space)\n\
\"[FLOORTURF]\" = (/turf/simulated/floor/plating/airless/asteroid,/area/mine/unexplored)\n\
\"[CAVETURF]\" = (/turf/simulated/mineral/random/caves,/area/mine/unexplored)\n\
\"[RESCAVETURF]\" = (/turf/simulated/mineral/random/high_chance,/area/mine/unexplored)\n\
\"[MOBTURF]\" = (/mob/living/simple_animal/hostile/asteroid/goliath,/turf/simulated/floor/plating/airless/asteroid,/area/mine/unexplored)\n\
\"[ARTTURF]\" = (/obj/machinery/artifact,/turf/simulated/floor/plating/airless/asteroid,/area/mine/unexplored)\n\
(1,1,1) = {\""

var/side_x = round(size_x / 10)//10% space from side
var/side_y = round(size_y / 10)
var/corner_rad = sqrt(side_x**2+side_y**2)

for(var/i = 1 to size_x)
map += "\n"
for(var/j = 1 to size_y)
var/xy = sqrt(min(size_x - i, i)**2 + min(size_y - j, j)**2)

//corners
if(xy<=corner_rad)
map += SPACETURF
//center
else if (i < size_x/2+side_x && i > size_x/2-side_x && j < size_y/2+side_y && j > size_y/2-side_y)
if(prob(10))
map += ARTTURF
else
map += prob(80) ? FLOORTURF : MOBTURF
//sides
else if (min(size_x - i, i) <= side_x || min(size_y - j, j) <= side_y)
map += prob(40) ? FLOORTURF : CAVETURF
else
if(prob(5))
map += FLOORTURF
else
map += prob(40) ? RESCAVETURF : CAVETURF

map += "\n\"}"

return map

#undef SPACETURF
#undef FLOORTURF
#undef CAVETURF
#undef RESCAVETURF
#undef MOBTURF
#undef ARTTURF
19 changes: 16 additions & 3 deletions code/modules/mining/mine_turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@
var/turf/simulated/mineral/random/target_turf = get_step(src, trydir)
if(istype(target_turf, /turf/simulated/mineral/random/caves))
if(prob(2))
new/turf/simulated/floor/plating/airless/asteroid/cave(src)
if(ticker.current_state > GAME_STATE_SETTING_UP)
ChangeTurf(/turf/simulated/floor/plating/airless/asteroid/cave)
else
new/turf/simulated/floor/plating/airless/asteroid/cave(src)

//Not even going to touch this pile of spaghetti
/turf/simulated/mineral/attackby(obj/item/weapon/W, mob/user)
Expand Down Expand Up @@ -409,6 +412,8 @@
if(7)
new/obj/item/stack/sheet/mineral/uranium(src, rand(5,25))

//this fucking caves works very badly with afterinit mapload (and with atominit generally)
//todo: move cavespread from atominit for side trigger?
/turf/simulated/mineral/random
name = "Mineral deposit"
icon_state = "rock"
Expand Down Expand Up @@ -525,7 +530,11 @@
if(istype(tunnel))
// Small chance to have forks in our tunnel; otherwise dig our tunnel.
if(i > 3 && prob(20))
new src.type(tunnel, rand(10, 15), 0, dir)
if(ticker.current_state > GAME_STATE_SETTING_UP)
var/list/arguments = list(tunnel, rand(10, 15), 0, dir)
ChangeTurf(src.type, arguments)
else
new src.type(tunnel, rand(10, 15), 0, dir)
else
SpawnFloor(tunnel)
else //if(!istype(tunnel, src.parent)) // We hit space/normal/wall, stop our tunnel.
Expand All @@ -547,7 +556,11 @@
return

SpawnMonster(T)
var/turf/t = new basetype(T)
var/turf/t
if(ticker.current_state > GAME_STATE_SETTING_UP)
t = new basetype(T)
else
t = T.ChangeTurf(basetype)
spawn(2)
t.fullUpdateMineralOverlays()

Expand Down
Binary file added sound/effects/Explosion3.ogg
Binary file not shown.
1 change: 1 addition & 0 deletions taucetistation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,7 @@
#include "code\modules\admin\verbs\debug.dm"
#include "code\modules\admin\verbs\diagnostics.dm"
#include "code\modules\admin\verbs\dice.dm"
#include "code\modules\admin\verbs\drop_asteroid.dm"
#include "code\modules\admin\verbs\epileptic_anomaly.dm"
#include "code\modules\admin\verbs\fps.dm"
#include "code\modules\admin\verbs\getlogs.dm"
Expand Down

0 comments on commit fd9eb23

Please sign in to comment.