Skip to content

Commit

Permalink
Updates Management for Abno Weights (#1677)
Browse files Browse the repository at this point in the history
  • Loading branch information
LanceSmites328 authored Dec 2, 2023
1 parent 5de099b commit 69d950e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 7 additions & 6 deletions code/controllers/subsystem/persistence.dm
Original file line number Diff line number Diff line change
Expand Up @@ -180,18 +180,19 @@ SUBSYSTEM_DEF(persistence)
pe_status = json_decode(json)

/datum/controller/subsystem/persistence/proc/LoadAbnoPicks()
abno_rates = typecacheof(/mob/living/simple_animal/hostile/abnormality, TRUE)
var/json = file2text(FILE_ABNO_PICKS)
if(!json)
var/json_file = file(FILE_ABNO_PICKS)
if(!fexists(json_file))
WARNING("Failed to load agent reputation. File likely corrupt.")
abno_rates = typecacheof(/mob/living/simple_animal/hostile/abnormality, TRUE)
WARNING("Failed to load Abno pick rates. File likely corrupt.")
else
abno_rates = json_decode(json)
//var/list/all_abnos = subtypesof(/mob/living/simple_animal/hostile/abnormality)
var/list/pick_rates = json_decode(json)
for(var/path in pick_rates)
abno_rates[text2path(path)] = pick_rates[path]
var/highest = max(abno_rates[ReturnHighestValue(abno_rates)] + 1, 2) // Ensures no 0 results
for(var/i in abno_rates)
var/mob/living/simple_animal/hostile/abnormality/abno = text2path(i)
var/mob/living/simple_animal/hostile/abnormality/abno = i
if(initial(abno.can_spawn))
SSabnormality_queue.possible_abnormalities[initial(abno.threat_level)] += abno
var/rate = (abno_rates[i] * -1) + highest
Expand Down Expand Up @@ -414,7 +415,7 @@ SUBSYSTEM_DEF(persistence)

/datum/controller/subsystem/persistence/proc/SaveAbnoPicks()
for(var/datum/abnormality/abno_ref in SSlobotomy_corp.all_abnormality_datums)
abno_rates["[abno_ref.abno_path]"] = text2num(abno_rates[abno_ref.abno_path]) + 1
abno_rates[abno_ref.abno_path] = text2num(abno_rates[abno_ref.abno_path]) + 1
fdel(FILE_ABNO_PICKS)
text2file(json_encode(abno_rates), FILE_ABNO_PICKS)

Expand Down
5 changes: 4 additions & 1 deletion code/game/gamemodes/management/management.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@
var/list/gamemode_abnos = list(ZAYIN_LEVEL = list(), TETH_LEVEL = list(), HE_LEVEL = list(), WAW_LEVEL = list(), ALEPH_LEVEL = list())

/datum/game_mode/management/post_setup()
var/list/all_abnos = subtypesof(/mob/living/simple_animal/hostile/abnormality)
var/list/all_abnos = SSpersistence.abno_rates
var/highest = max(all_abnos[ReturnHighestValue(all_abnos)] + 1, 2) // Ensures no 0 results
for(var/i in all_abnos)
var/mob/living/simple_animal/hostile/abnormality/abno = i
if(initial(abno.can_spawn) && (initial(abno.abnormality_origin) in abno_types))
gamemode_abnos[initial(abno.threat_level)] += abno
var/rate = (all_abnos[i] * -1) + highest
gamemode_abnos[initial(abno.threat_level)][abno] = rate

SSabnormality_queue.possible_abnormalities = list()
SSabnormality_queue.possible_abnormalities = gamemode_abnos
Expand Down

0 comments on commit 69d950e

Please sign in to comment.