Skip to content

Commit

Permalink
Add one-click for event roles. (#27855)
Browse files Browse the repository at this point in the history
* Add one-click for event roles.

* Apply suggestions from code review

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Review fix.

* Update code/modules/admin/verbs/one_click_antag.dm

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Update code/modules/admin/verbs/one_click_antag.dm

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

* Update code/modules/admin/verbs/one_click_antag.dm

Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>

---------

Signed-off-by: Charlie Nolan <funnyman3595@gmail.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 21, 2025
1 parent b89794e commit 02a591a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/modules/admin/topic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
if(href_list["makeAntag"])
switch(href_list["makeAntag"])
if("1")
log_admin("[key_name(usr)] has spawned a traitor.")
log_admin("[key_name(usr)] has spawned traitors.")
if(!makeTraitors())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("2")
Expand Down Expand Up @@ -71,6 +71,10 @@
log_admin("[key_name(usr)] has spawned mindflayers.")
if(!makeMindflayers())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")
if("9")
log_admin("[key_name(usr)] has spawned event characters.")
if(!makeEventCharacters())
to_chat(usr, "<span class='warning'>Unfortunately there weren't enough candidates available.</span>")

else if(href_list["dbsearchckey"] || href_list["dbsearchadmin"] || href_list["dbsearchip"] || href_list["dbsearchcid"] || href_list["dbsearchbantype"])
var/adminckey = href_list["dbsearchadmin"]
Expand Down
59 changes: 59 additions & 0 deletions code/modules/admin/verbs/one_click_antag.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<a href='byond://?src=[UID()];makeAntag=6'>Make Vampires</a><br>
<a href='byond://?src=[UID()];makeAntag=7'>Make Abductor Team (Requires Ghosts)</a><br>
<a href='byond://?src=[UID()];makeAntag=8'>Make Mindflayers</a><br>
<a href='byond://?src=[UID()];makeAntag=9'>Make Event Characters</a><br>
"}
usr << browse(dat, "window=oneclickantag;size=400x400")
return
Expand Down Expand Up @@ -311,6 +312,64 @@
qdel(temp)
return TRUE

/datum/admins/proc/makeEventCharacters()
var/list/mob/living/carbon/human/candidates = list()
var/mob/living/carbon/human/H = null

var/antnum = input(owner, "How many event characters you want to create? Enter 0 to cancel","Amount:", 0) as num
if(!antnum || antnum <= 0)
return FALSE

var/datum/game_mode/traitor/temp = new()
var/no_mindshields = input(owner, "Avoid mindshielded characters?") in list("Yes", "No", "Cancel")
if(no_mindshields == "Cancel")
qdel(temp)
return FALSE
else if(no_mindshields == "Yes")
temp.restricted_jobs += temp.protected_jobs

var/respect_traitor = input(owner, "Require traitor willingness?") in list("Yes", "No", "Cancel")
var/role = null
if(respect_traitor == "Cancel")
qdel(temp)
return FALSE
else if(respect_traitor == "Yes")
role = ROLE_TRAITOR

var/give_objective = input(owner, "Give them a shared custom objective?") in list("Yes", "No", "Cancel")
var/objective = null
if(give_objective == "Cancel")
qdel(temp)
return FALSE
else if(give_objective == "Yes")
objective = sanitize(copytext_char(input("Custom objective:", "Objective", "") as text|null, 1, MAX_MESSAGE_LEN))
if(!length(objective))
qdel(temp)
return FALSE

log_admin("[key_name(owner)] tried making [antnum] event characters with One-Click-Antag")
message_admins("[key_name_admin(owner)] tried making [antnum] event characters with One-Click-Antag")

for(var/mob/living/carbon/human/applicant in GLOB.player_list)
if(CandCheck(role, applicant, temp))
candidates += applicant
qdel(temp)

if(length(candidates))
var/num_event_chars = min(length(candidates), antnum)

for(var/i in 1 to num_event_chars)
H = pick(candidates)
if(!isnull(objective))
var/datum/objective/O = new()
O.explanation_text = objective
O.needs_target = FALSE
H.mind.add_mind_objective(O)
H.mind.add_antag_datum(/datum/antagonist/eventmisc)
candidates.Remove(H)
return TRUE
return FALSE

/datum/admins/proc/makeThunderdomeTeams() // Not strictly an antag, but this seemed to be the best place to put it.
var/max_thunderdome_players = 10
var/team_to_assign_to = "Green"
Expand Down

0 comments on commit 02a591a

Please sign in to comment.