[MIRROR] Adds admin quirk command, also fixes and unifies quirk helpers (#5195)

* Add admin quirk command, fix and unify quirk helpers (#43553)
This commit is contained in:
1fbff5f83b23d39d38b1dfcb4cac8d9b
2019-04-24 06:01:19 +02:00
committed by Gary Lafortune
parent 218b4c6eae
commit 32e46f2f9e
4 changed files with 50 additions and 13 deletions

View File

@@ -31,4 +31,8 @@ PROCESSING_SUBSYSTEM_DEF(quirks)
/datum/controller/subsystem/processing/quirks/proc/AssignQuirks(mob/living/user, client/cli, spawn_effects)
for(var/V in cli.prefs.all_quirks)
user.add_quirk(V, spawn_effects)
var/datum/quirk/Q = quirks[V]
if(Q)
user.add_quirk(Q, spawn_effects)
else
stack_trace("Invalid quirk \"[V]\" in client [cli.ckey] preferences")

View File

@@ -1389,3 +1389,30 @@
var/mob/living/carbon/human/H = locate(href_list["copyoutfit"]) in GLOB.carbon_list
if(istype(H))
H.copy_outfit()
else if(href_list["modquirks"])
if(!check_rights(R_SPAWN))
return
var/mob/living/carbon/human/H = locate(href_list["modquirks"]) in GLOB.mob_list
if(!istype(H))
to_chat(usr, "This can only be done to instances of type /mob/living/carbon/human")
return
var/list/options = list("Clear"="Clear")
for(var/x in subtypesof(/datum/quirk))
var/datum/quirk/T = x
var/qname = initial(T.name)
options[H.has_quirk(T) ? "[qname] (Remove)" : "[qname] (Add)"] = T
var/result = input(usr, "Choose quirk to add/remove","Quirk Mod") as null|anything in options
if(result)
if(result == "Clear")
for(var/datum/quirk/q in H.roundstart_quirks)
H.remove_quirk(q.type)
else
var/T = options[result]
if(H.has_quirk(T))
H.remove_quirk(T)
else
H.add_quirk(T,TRUE)

View File

@@ -839,6 +839,7 @@
.["Make slime"] = "?_src_=vars;[HrefToken()];makeslime=[REF(src)]"
.["Toggle Purrbation"] = "?_src_=vars;[HrefToken()];purrbation=[REF(src)]"
.["Copy outfit"] = "?_src_=vars;[HrefToken()];copyoutfit=[REF(src)]"
.["Add/Remove Quirks"] = "?_src_=vars;[HrefToken()];modquirks=[REF(src)]"
.["Make Cluwne"] = "?_src_=vars;[HrefToken()];cluwneing=[REF(src)]" // yogs -- make cluwne
/mob/living/carbon/human/MouseDrop_T(mob/living/target, mob/living/user)

View File

@@ -375,23 +375,28 @@
return TRUE
/////////////////////////////////// DISABILITIES ////////////////////////////////////
/mob/living/proc/add_quirk(quirk, spawn_effects) //separate proc due to the way these ones are handled
if(has_trait(quirk))
/mob/living/proc/add_quirk(quirktype, spawn_effects) //separate proc due to the way these ones are handled
if(has_trait(quirktype))
return
if(!SSquirks || !SSquirks.quirks[quirk])
var/datum/quirk/T = quirktype
var/qname = initial(T.name)
if(!SSquirks || !SSquirks.quirks[qname])
return
var/datum/quirk/T = SSquirks.quirks[quirk]
new T (src, spawn_effects)
new quirktype (src, spawn_effects)
return TRUE
/mob/living/proc/remove_quirk(quirk)
var/datum/quirk/T = roundstart_quirks[quirk]
if(T)
qdel(T)
return TRUE
/mob/living/proc/remove_quirk(quirktype)
for(var/datum/quirk/Q in roundstart_quirks)
if(Q.type == quirktype)
qdel(Q)
return TRUE
return FALSE
/mob/living/proc/has_quirk(quirk)
return roundstart_quirks[quirk]
/mob/living/proc/has_quirk(quirktype)
for(var/datum/quirk/Q in roundstart_quirks)
if(Q.type == quirktype)
return TRUE
return FALSE
/////////////////////////////////// TRAIT PROCS ////////////////////////////////////