mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -26,17 +26,17 @@
|
||||
max_z = max(z, max_z)
|
||||
return max_z
|
||||
|
||||
/proc/get_area(O)
|
||||
var/turf/loc = get_turf(O)
|
||||
if(loc)
|
||||
var/area/res = loc.loc
|
||||
.= res
|
||||
/proc/get_area(atom/A)
|
||||
if(isarea(A))
|
||||
return A
|
||||
var/turf/T = get_turf(A)
|
||||
return T ? T.loc : null
|
||||
|
||||
/proc/get_area_name(N) //get area by its name
|
||||
for(var/area/A in all_areas)
|
||||
if(A.name == N)
|
||||
return A
|
||||
return 0
|
||||
/proc/get_area_name(atom/X, format_text = FALSE)
|
||||
var/area/A = isarea(X) ? X : get_area(X)
|
||||
if(!A)
|
||||
return null
|
||||
return format_text ? format_text(A.name) : A.name
|
||||
|
||||
/proc/get_area_master(const/O)
|
||||
var/area/A = get_area(O)
|
||||
@@ -605,3 +605,8 @@ datum/projectile_data
|
||||
|
||||
/proc/SecondsToTicks(var/seconds)
|
||||
return seconds * 10
|
||||
|
||||
/proc/window_flash(var/client_or_usr)
|
||||
if (!client_or_usr)
|
||||
return
|
||||
winset(client_or_usr, "mainwindow", "flash=5")
|
||||
@@ -106,11 +106,12 @@ var/global/list/global_egg_types = list(
|
||||
"Tajaran" = TAJARAN_EGG,
|
||||
"Akula" = AKULA_EGG,
|
||||
"Skrell" = SKRELL_EGG,
|
||||
"Nevrean" = NEVREAN_EGG,
|
||||
"Sergal" = SERGAL_EGG,
|
||||
"Human" = HUMAN_EGG,
|
||||
"Slime" = SLIME_EGG,
|
||||
"Egg" = EGG_EGG,
|
||||
"Xenochimera" = XENOCHIMERA_EGG,
|
||||
"Xenochimera" = XENOCHIMERA_EGG,
|
||||
"Xenomorph" = XENOMORPH_EGG)
|
||||
|
||||
var/global/list/tf_egg_types = list(
|
||||
@@ -119,10 +120,11 @@ var/global/list/tf_egg_types = list(
|
||||
"Akula" = /obj/structure/closet/secure_closet/egg/shark,
|
||||
"Skrell" = /obj/structure/closet/secure_closet/egg/skrell,
|
||||
"Sergal" = /obj/structure/closet/secure_closet/egg/sergal,
|
||||
"Nevrean" = /obj/structure/closet/secure_closet/egg/nevrean,
|
||||
"Human" = /obj/structure/closet/secure_closet/egg/human,
|
||||
"Slime" = /obj/structure/closet/secure_closet/egg/slime,
|
||||
"Egg" = /obj/structure/closet/secure_closet/egg,
|
||||
"Xenochimera" = /obj/structure/closet/secure_closet/egg/scree,
|
||||
"Xenochimera" = /obj/structure/closet/secure_closet/egg/scree,
|
||||
"Xenomorph" = /obj/structure/closet/secure_closet/egg/xenomorph)
|
||||
|
||||
var/global/list/edible_trash = list(/obj/item/trash,
|
||||
|
||||
@@ -240,6 +240,17 @@ proc/listclearnulls(list/list)
|
||||
for(var/i in L)
|
||||
. |= i
|
||||
|
||||
//same, but returns nothing and acts on list in place (also handles associated values properly)
|
||||
/proc/uniqueList_inplace(list/L)
|
||||
var/temp = L.Copy()
|
||||
L.len = 0
|
||||
for(var/key in temp)
|
||||
if (isnum(key))
|
||||
L |= key
|
||||
else
|
||||
L[key] = temp[key]
|
||||
|
||||
|
||||
//Mergesort: divides up the list into halves to begin the sort
|
||||
/proc/sortKey(var/list/client/L, var/order = 1)
|
||||
if(isnull(L) || L.len < 2)
|
||||
|
||||
@@ -64,6 +64,11 @@ var/next_station_date_change = 1 DAY
|
||||
var/time_portion = time2text(world.timeofday, "hh:mm:ss")
|
||||
return "[date_portion]T[time_portion]"
|
||||
|
||||
/proc/gameTimestamp(format = "hh:mm:ss", wtime=null)
|
||||
if(!wtime)
|
||||
wtime = world.time
|
||||
return time2text(wtime - GLOB.timezoneOffset, format)
|
||||
|
||||
/* Returns 1 if it is the selected month and day */
|
||||
proc/isDay(var/month, var/day)
|
||||
if(isnum(month) && isnum(day))
|
||||
@@ -137,4 +142,101 @@ var/round_start_time = 0
|
||||
i *= 2
|
||||
while (TICK_USAGE > min(TICK_LIMIT_TO_RUN, GLOB.CURRENT_TICKLIMIT))
|
||||
|
||||
#undef DELTA_CALC
|
||||
#undef DELTA_CALC
|
||||
|
||||
|
||||
//Takes a value of time in deciseconds.
|
||||
//Returns a text value of that number in hours, minutes, or seconds.
|
||||
/proc/DisplayTimeText(time_value, truncate = FALSE)
|
||||
var/second = (time_value)*0.1
|
||||
var/second_adjusted = null
|
||||
var/second_rounded = FALSE
|
||||
var/minute = null
|
||||
var/hour = null
|
||||
var/day = null
|
||||
|
||||
if(!second)
|
||||
return "0 seconds"
|
||||
if(second >= 60)
|
||||
minute = FLOOR(second/60, 1)
|
||||
second = round(second - (minute*60), 0.1)
|
||||
second_rounded = TRUE
|
||||
if(second) //check if we still have seconds remaining to format, or if everything went into minute.
|
||||
second_adjusted = round(second) //used to prevent '1 seconds' being shown
|
||||
if(day || hour || minute)
|
||||
if(second_adjusted == 1 && second >= 1)
|
||||
second = " and 1 second"
|
||||
else if(second > 1)
|
||||
second = " and [second_adjusted] seconds"
|
||||
else //shows a fraction if seconds is < 1
|
||||
if(second_rounded) //no sense rounding again if it's already done
|
||||
second = " and [second] seconds"
|
||||
else
|
||||
second = " and [round(second, 0.1)] seconds"
|
||||
else
|
||||
if(second_adjusted == 1 && second >= 1)
|
||||
second = "[truncate ? "second" : "1 second"]"
|
||||
else if(second > 1)
|
||||
second = "[second_adjusted] seconds"
|
||||
else
|
||||
if(second_rounded)
|
||||
second = "[second] seconds"
|
||||
else
|
||||
second = "[round(second, 0.1)] seconds"
|
||||
else
|
||||
second = null
|
||||
|
||||
if(!minute)
|
||||
return "[second]"
|
||||
if(minute >= 60)
|
||||
hour = FLOOR(minute/60, 1)
|
||||
minute = (minute - (hour*60))
|
||||
if(minute) //alot simpler from here since you don't have to worry about fractions
|
||||
if(minute != 1)
|
||||
if((day || hour) && second)
|
||||
minute = ", [minute] minutes"
|
||||
else if((day || hour) && !second)
|
||||
minute = " and [minute] minutes"
|
||||
else
|
||||
minute = "[minute] minutes"
|
||||
else
|
||||
if((day || hour) && second)
|
||||
minute = ", 1 minute"
|
||||
else if((day || hour) && !second)
|
||||
minute = " and 1 minute"
|
||||
else
|
||||
minute = "[truncate ? "minute" : "1 minute"]"
|
||||
else
|
||||
minute = null
|
||||
|
||||
if(!hour)
|
||||
return "[minute][second]"
|
||||
if(hour >= 24)
|
||||
day = FLOOR(hour/24, 1)
|
||||
hour = (hour - (day*24))
|
||||
if(hour)
|
||||
if(hour != 1)
|
||||
if(day && (minute || second))
|
||||
hour = ", [hour] hours"
|
||||
else if(day && (!minute || !second))
|
||||
hour = " and [hour] hours"
|
||||
else
|
||||
hour = "[hour] hours"
|
||||
else
|
||||
if(day && (minute || second))
|
||||
hour = ", 1 hour"
|
||||
else if(day && (!minute || !second))
|
||||
hour = " and 1 hour"
|
||||
else
|
||||
hour = "[truncate ? "hour" : "1 hour"]"
|
||||
else
|
||||
hour = null
|
||||
|
||||
if(!day)
|
||||
return "[hour][minute][second]"
|
||||
if(day > 1)
|
||||
day = "[day] days"
|
||||
else
|
||||
day = "[truncate ? "day" : "1 day"]"
|
||||
|
||||
return "[day][hour][minute][second]"
|
||||
@@ -522,6 +522,14 @@ Turf and target are seperate in case you want to teleport some distance from a t
|
||||
return "[round((powerused * 0.000001),0.001)] MW"
|
||||
return "[round((powerused * 0.000000001),0.0001)] GW"
|
||||
|
||||
/proc/get_mob_by_ckey(key)
|
||||
if(!key)
|
||||
return
|
||||
var/list/mobs = sortmobs()
|
||||
for(var/mob/M in mobs)
|
||||
if(M.ckey == key)
|
||||
return M
|
||||
|
||||
//Forces a variable to be posative
|
||||
/proc/modulus(var/M)
|
||||
if(M >= 0)
|
||||
|
||||
Reference in New Issue
Block a user