diff --git a/code/__HELPERS/roundend.dm b/code/__HELPERS/roundend.dm index ee575f686f..5c6856d3f6 100644 --- a/code/__HELPERS/roundend.dm +++ b/code/__HELPERS/roundend.dm @@ -162,6 +162,11 @@ if(LAZYLEN(GLOB.round_end_notifiees)) send2irc("Notice", "[GLOB.round_end_notifiees.Join(", ")] the round has ended.") + for(var/I in round_end_events) + var/datum/callback/cb = I + cb.InvokeAsync() + LAZYCLEARLIST(round_end_events) + for(var/client/C in GLOB.clients) if(!C.credits) C.RollCredits() diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index 03a1325923..4ab8332303 100755 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -61,6 +61,7 @@ SUBSYSTEM_DEF(ticker) var/round_start_time = 0 var/list/round_start_events + var/list/round_end_events var/mode_result = "undefined" var/end_state = "undefined" @@ -336,12 +337,20 @@ SUBSYSTEM_DEF(ticker) send2irc("Server", "Round [GLOB.round_id ? "#[GLOB.round_id]:" : "of"] [hide_mode ? "secret":"[mode.name]"] has started[allmins.len ? ".":" with no active admins online!"]") setup_done = TRUE +//These callbacks will fire after roundstart key transfer /datum/controller/subsystem/ticker/proc/OnRoundstart(datum/callback/cb) if(!HasRoundStarted()) LAZYADD(round_start_events, cb) else cb.InvokeAsync() +//These callbacks will fire before roundend report +/datum/controller/subsystem/ticker/proc/OnRoundend(datum/callback/cb) + if(current_state >= GAME_STATE_FINISHED) + cb.InvokeAsync() + else + LAZYADD(round_end_events, cb) + /datum/controller/subsystem/ticker/proc/station_explosion_detonation(atom/bomb) if(bomb) //BOOM var/turf/epi = bomb.loc diff --git a/code/modules/antagonists/greentext/greentext.dm b/code/modules/antagonists/greentext/greentext.dm new file mode 100644 index 0000000000..469eeb9882 --- /dev/null +++ b/code/modules/antagonists/greentext/greentext.dm @@ -0,0 +1,19 @@ +/datum/antagonist/greentext + name = "winner" + show_in_antagpanel = FALSE + show_name_in_check_antagonists = TRUE //Not that it will be there for long + +/datum/antagonist/greentext/proc/forge_objectives() + var/datum/objective/O = new /datum/objective("Succeed") + O.completed = TRUE //YES! + O.owner = owner + objectives += O + owner.objectives += objectives + +/datum/antagonist/greentext/on_gain() + forge_objectives() + . = ..() + +/datum/antagonist/greentext/on_removal() + owner.objectives -= objectives + . = ..() \ No newline at end of file diff --git a/code/modules/events/wizard/greentext.dm b/code/modules/events/wizard/greentext.dm index 156ecea2ec..fb944d9230 100644 --- a/code/modules/events/wizard/greentext.dm +++ b/code/modules/events/wizard/greentext.dm @@ -28,12 +28,15 @@ var/mob/living/last_holder var/mob/living/new_holder var/list/color_altered_mobs = list() + var/datum/callback/roundend_callback resistance_flags = FIRE_PROOF | ACID_PROOF var/quiet = FALSE -/obj/item/greentext/New() - ..() +/obj/item/greentext/Initialize(mapload) + . = ..() GLOB.poi_list |= src + roundend_callback = CALLBACK(src,.proc/check_winner) + SSticker.OnRoundend(roundend_callback) /obj/item/greentext/equipped(mob/living/user as mob) to_chat(user, "So long as you leave this place with greentext in hand you know will be happy...") @@ -57,20 +60,19 @@ STOP_PROCESSING(SSobj, src) ..() -/obj/item/greentext/process() - if(new_holder && is_centcom_level(new_holder.z))//you're winner! +/obj/item/greentext/proc/check_winner() + if(!new_holder) + return + + if(is_centcom_level(new_holder.z))//you're winner! to_chat(new_holder, "At last it feels like victory is assured!") - new_holder.mind.special_role = "winner" - var/datum/objective/O = new /datum/objective("Succeed") - O.completed = 1 //YES! - O.owner = new_holder.mind - new_holder.mind.objectives += O - new_holder.mind.add_antag_datum(/datum/antagonist/auto_custom) + new_holder.mind.add_antag_datum(/datum/antagonist/greentext) new_holder.log_message("Won with greentext!!!", INDIVIDUAL_ATTACK_LOG) color_altered_mobs -= new_holder resistance_flags |= ON_FIRE qdel(src) +/obj/item/greentext/process() if(last_holder && last_holder != new_holder) //Somehow it was swiped without ever getting dropped to_chat(last_holder, "A sudden wave of failure washes over you...") last_holder.add_atom_colour("#FF0000", ADMIN_COLOUR_PRIORITY) @@ -80,7 +82,7 @@ if(!(resistance_flags & ON_FIRE) && !force) return QDEL_HINT_LETMELIVE - . = ..() + SSticker.round_end_events -= roundend_callback GLOB.poi_list.Remove(src) for(var/i in GLOB.player_list) var/mob/M = i @@ -93,6 +95,7 @@ // can't skip the mob check as it also does the decolouring if(!quiet) to_chat(M, message) + . = ..() /obj/item/greentext/quiet quiet = TRUE diff --git a/tgstation.dme b/tgstation.dme index 6425c301e1..168364be19 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -1210,6 +1210,7 @@ #include "code\modules\antagonists\devil\true_devil\_true_devil.dm" #include "code\modules\antagonists\devil\true_devil\inventory.dm" #include "code\modules\antagonists\ert\ert.dm" +#include "code\modules\antagonists\greentext\greentext.dm" #include "code\modules\antagonists\highlander\highlander.dm" #include "code\modules\antagonists\monkey\monkey.dm" #include "code\modules\antagonists\morph\morph.dm"