Merge remote-tracking branch 'origin/master' into perlin-genny

This commit is contained in:
LetterN
2021-03-20 20:36:56 +08:00
267 changed files with 109865 additions and 107683 deletions
@@ -425,6 +425,7 @@ Example config:
var/list/min_pop = Get(/datum/config_entry/keyed_list/min_pop)
var/list/max_pop = Get(/datum/config_entry/keyed_list/max_pop)
var/list/repeated_mode_adjust = Get(/datum/config_entry/number_list/repeated_mode_adjust)
var/desired_chaos_level = 9 - SSpersistence.get_recent_chaos()
for(var/T in gamemode_cache)
var/datum/game_mode/M = new T()
if(!(M.config_tag in modes))
@@ -449,6 +450,17 @@ Example config:
adjustment += repeated_mode_adjust[recent_round]
recent_round = SSpersistence.saved_modes.Find(M.config_tag,recent_round+1,0)
final_weight *= max(0,((100-adjustment)/100))
if(Get(/datum/config_entry/flag/weigh_by_recent_chaos))
var/chaos_level = M.get_chaos()
var/exponent = Get(/datum/config_entry/number/chaos_exponent)
var/delta = chaos_level - desired_chaos_level
if(desired_chaos_level > 5)
delta = abs(min(delta, 0))
else if(desired_chaos_level < 5)
delta = max(delta, 0)
else
delta = abs(delta)
final_weight /= (delta + 1) ** exponent
runnable_modes[M] = final_weight
return runnable_modes
@@ -7,6 +7,13 @@
/datum/config_entry/keyed_list/probability/ValidateListEntry(key_name)
return key_name in config.modes
/datum/config_entry/keyed_list/chaos_level
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
/datum/config_entry/keyed_list/chaos_level/ValidateListEntry(key_name)
return key_name in config.modes
/datum/config_entry/keyed_list/max_pop
key_mode = KEY_MODE_TEXT
value_mode = VALUE_MODE_NUM
@@ -596,3 +603,8 @@
/// Dirtyness multiplier for making turfs dirty
/datum/config_entry/number/turf_dirty_multiplier
config_entry_value = 1
/datum/config_entry/flag/weigh_by_recent_chaos
/datum/config_entry/number/chaos_exponent
config_entry_value = 1
@@ -3,6 +3,7 @@
*/
/datum/controller/subsystem/persistence
var/list/saved_modes = list(1,2,3)
var/list/saved_chaos = list(5,5,5)
var/list/saved_dynamic_rules = list(list(),list(),list())
var/list/saved_storytellers = list("foo","bar","baz")
var/list/average_dynamic_threat = 50
@@ -20,6 +21,7 @@
/datum/controller/subsystem/persistence/LoadServerPersistence()
. = ..()
LoadRecentModes()
LoadRecentChaos()
LoadRecentStorytellers()
LoadRecentRulesets()
LoadRecentMaps()
@@ -33,6 +35,14 @@
file_data["data"] = saved_modes
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))
saved_chaos[3] = saved_chaos[2]
saved_chaos[2] = saved_chaos[1]
saved_chaos[1] = SSticker.mode.get_chaos()
json_file = file("data/RecentChaos.json")
file_data = list()
file_data["data"] = saved_chaos
fdel(json_file)
WRITE_FILE(json_file, json_encode(file_data))
/datum/controller/subsystem/persistence/proc/CollectStoryteller(var/datum/game_mode/dynamic/mode)
saved_storytellers.len = 3
@@ -76,6 +86,15 @@
return
saved_modes = json["data"]
/datum/controller/subsystem/persistence/proc/LoadRecentChaos()
var/json_file = file("data/RecentChaos.json")
if(!fexists(json_file))
return
var/list/json = json_decode(file2text(json_file))
if(!json)
return
saved_chaos = json["data"]
/datum/controller/subsystem/persistence/proc/LoadRecentRulesets()
var/json_file = file("data/RecentRulesets.json")
if(!fexists(json_file))
@@ -105,3 +124,9 @@
if(!json)
return
saved_maps = json["maps"]
/datum/controller/subsystem/persistence/proc/get_recent_chaos()
var/sum = 0
for(var/n in saved_chaos)
sum += n
return sum/length(saved_chaos)
@@ -47,5 +47,5 @@ SUBSYSTEM_DEF(processing)
* If you override this do not call parent, as it will return PROCESS_KILL. This is done to prevent objects that dont override process() from staying in the processing list
*/
/datum/proc/process(delta_time)
set waitfor = FALSE
// SHOULD_NOT_SLEEP(TRUE)
return PROCESS_KILL
@@ -70,3 +70,8 @@ PROCESSING_SUBSYSTEM_DEF(weather)
A = W
break
return A
/datum/controller/subsystem/processing/weather/proc/get_weather_by_type(datum/weather/weather_datum_type)
for(var/V in processing)
if(istype(V,weather_datum_type))
return V
+44 -13
View File
@@ -1,32 +1,63 @@
#define OCCLUSION_DISTANCE 20
/datum/sun
var/azimuth = 0 // clockwise, top-down rotation from 0 (north) to 359
var/power_mod = 1 // how much power this sun is outputting relative to standard
/datum/sun/vv_edit_var(var_name, var_value)
. = ..()
if(var_name == NAMEOF(src, azimuth))
SSsun.complete_movement()
/atom/proc/check_obscured(datum/sun/sun, distance = OCCLUSION_DISTANCE)
var/target_x = round(sin(sun.azimuth), 0.01)
var/target_y = round(cos(sun.azimuth), 0.01)
var/x_hit = x
var/y_hit = y
var/turf/hit
for(var/run in 1 to distance)
x_hit += target_x
y_hit += target_y
hit = locate(round(x_hit, 1), round(y_hit, 1), z)
if(hit.opacity)
return TRUE
if(hit.x == 1 || hit.x == world.maxx || hit.y == 1 || hit.y == world.maxy) //edge of the map
break
return FALSE
SUBSYSTEM_DEF(sun)
name = "Sun"
wait = 1 MINUTES
flags = SS_NO_TICK_CHECK
var/azimuth = 0 ///clockwise, top-down rotation from 0 (north) to 359
var/list/datum/sun/suns = list()
var/datum/sun/primary_sun
var/azimuth_mod = 1 ///multiplier against base_rotation
var/base_rotation = 6 ///base rotation in degrees per fire
/datum/controller/subsystem/sun/Initialize(start_timeofday)
azimuth = rand(0, 359)
primary_sun = new
suns += primary_sun
primary_sun.azimuth = rand(0, 359)
azimuth_mod = round(rand(50, 200)/100, 0.01) // 50% - 200% of standard rotation
if(prob(50))
azimuth_mod *= -1
return ..()
/datum/controller/subsystem/sun/fire(resumed = FALSE)
azimuth += azimuth_mod * base_rotation
azimuth = round(azimuth, 0.01)
if(azimuth >= 360)
azimuth -= 360
if(azimuth < 0)
azimuth += 360
for(var/S in suns)
var/datum/sun/sun = S
sun.azimuth += azimuth_mod * base_rotation
sun.azimuth = round(sun.azimuth, 0.01)
if(sun.azimuth >= 360)
sun.azimuth -= 360
if(sun.azimuth < 0)
sun.azimuth += 360
complete_movement()
/datum/controller/subsystem/sun/proc/complete_movement()
SEND_SIGNAL(src, COMSIG_SUN_MOVED, azimuth)
SEND_SIGNAL(src, COMSIG_SUN_MOVED, primary_sun, suns)
/datum/controller/subsystem/sun/vv_edit_var(var_name, var_value)
. = ..()
if(var_name == NAMEOF(src, azimuth))
complete_movement()
#undef OCCLUSION_DISTANCE