-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Adds a subtle ghost poll [MDB IGNORE] (#24503) (#220)
* Adds a subtle ghost poll (#79105) ## About The Pull Request This makes a new ghost poll system which doesn't give TGUI popups - instead, users are prompted to follow the POI and one of the orbiters is chosen. The old system remains in place, so you can still prompt if you want to. This gives two things: 1. A deadchat notification: ![image](https://github.com/tgstation/tgstation/assets/42397676/073fcfff-b1ed-47c3-bae0-4abf9c599144) 2. A screen alert: ![image](https://github.com/tgstation/tgstation/assets/42397676/92a4e566-614a-43ca-8680-3cb4ff86ced9) ## Why It's Good For The Game As stated in #76507, popups are pretty annoying. This is halfway between a screen alert with no time limit and an event with more important pings. This is better because: 1. Less popup fatigue 2. You can SEE how many you're competing with 4. DRY ## Changelog :cl: add: Adds a subtle ghost poll. This pings in dead chat and gives a screen alert, but no TGUI popup. Orbit the point of interest to be selected for the role. refactor: A number of ghost spawns now feature this alert. Write an issue report if anything breaks. /:cl: --------- * Adds a subtle ghost poll --------- Co-authored-by: SkyratBot <[email protected]> Co-authored-by: Jeremiah <[email protected]> Co-authored-by: MrMelbert <51863163+MrMelbert@ users.noreply.github.com>
- Loading branch information
1 parent
3c0919e
commit 5309234
Showing
11 changed files
with
262 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/** | ||
* A replacement for the standard poll_ghost_candidate. | ||
* Use this to subtly ask players to join - it picks from orbiters. | ||
* Please use named arguments for this. | ||
* | ||
* @params ignore_key - Required so it doesn't spam | ||
* @params job_bans - You can insert a list or single items here. | ||
* @params cb - Invokes this proc and appends the poll winner as the last argument, mob/dead/observer/ghost | ||
* @params title - Optional. Useful if the role name does not match the parent. | ||
* | ||
* @usage | ||
* ``` | ||
* var/datum/callback/cb = CALLBACK(src, PROC_REF(do_stuff), arg1, arg2) | ||
* AddComponent(/datum/component/orbit_poll, \ | ||
* ignore_key = POLL_IGNORE_EXAMPLE, \ | ||
* job_bans = ROLE_EXAMPLE or list(ROLE_EXAMPLE, ROLE_EXAMPLE2), \ | ||
* title = "Use this if you want something other than the parent name", \ | ||
* to_call = cb, \ | ||
* ) | ||
*/ | ||
/datum/component/orbit_poll | ||
/// Prevent players with this ban from being selected | ||
var/list/job_bans = list() | ||
/// Title of the role to announce after it's done | ||
var/title | ||
/// Proc to invoke whenever the poll is complete | ||
var/datum/callback/to_call | ||
|
||
/datum/component/orbit_poll/Initialize( \ | ||
ignore_key, \ | ||
list/job_bans, \ | ||
datum/callback/to_call, \ | ||
title, \ | ||
header = "Ghost Poll", \ | ||
custom_message, \ | ||
timeout = 20 SECONDS \ | ||
) | ||
. = ..() | ||
if (!isatom(parent)) | ||
return COMPONENT_INCOMPATIBLE | ||
|
||
var/atom/owner = parent | ||
|
||
src.job_bans |= job_bans | ||
src.title = title || owner.name | ||
src.to_call = to_call | ||
|
||
var/message = custom_message || "[capitalize(src.title)] is looking for volunteers" | ||
|
||
notify_ghosts("[message]. An orbiter will be chosen in [DisplayTimeText(timeout)].\n", \ | ||
action = NOTIFY_ORBIT, \ | ||
enter_link = "<a href='?src=[REF(src)];ignore=[ignore_key]'>(Ignore)</a>", \ | ||
flashwindow = FALSE, \ | ||
header = "Volunteers requested", \ | ||
ignore_key = ignore_key, \ | ||
source = parent \ | ||
) | ||
|
||
addtimer(CALLBACK(src, PROC_REF(end_poll)), timeout, TIMER_UNIQUE|TIMER_OVERRIDE|TIMER_STOPPABLE|TIMER_DELETE_ME) | ||
|
||
/datum/component/orbit_poll/Topic(href, list/href_list) | ||
if(!href_list["ignore"]) | ||
return | ||
|
||
var/mob/user = usr | ||
|
||
var/ignore_key = href_list["ignore"] | ||
if(tgui_alert(user, "Ignore further [title] alerts?", "Ignore Alert", list("Yes", "No"), 20 SECONDS, TRUE) != "Yes") | ||
return | ||
|
||
GLOB.poll_ignore[ignore_key] |= user.ckey | ||
|
||
/// Concludes the poll, picking one of the orbiters | ||
/datum/component/orbit_poll/proc/end_poll() | ||
if(QDELETED(parent)) | ||
return | ||
|
||
var/list/candidates = list() | ||
var/atom/owner = parent | ||
|
||
var/datum/component/orbiter/orbiter_comp = owner.GetComponent(/datum/component/orbiter) | ||
if(isnull(orbiter_comp)) | ||
phone_home() | ||
return | ||
|
||
for(var/mob/dead/observer/ghost as anything in orbiter_comp.orbiter_list) | ||
if(QDELETED(ghost) || isnull(ghost.client)) | ||
continue | ||
if(is_banned_from(ghost.ckey, job_bans)) | ||
continue | ||
|
||
candidates += ghost | ||
|
||
if(!length(candidates)) | ||
phone_home() | ||
return | ||
|
||
var/mob/dead/observer/chosen = pick(candidates) | ||
|
||
if(chosen) | ||
deadchat_broadcast("[key_name(chosen, include_name = FALSE)] was selected for the role ([title]).", "Ghost Poll: ", parent) | ||
|
||
phone_home(chosen) | ||
|
||
/// Make sure to call your parents my dude | ||
/datum/component/orbit_poll/proc/phone_home(mob/dead/observer/chosen) | ||
to_call.Invoke(chosen) | ||
qdel(src) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.