mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-15 12:11:45 +00:00
* Componentizes/Elementalizes Pride Struck Hammer Behavior + Carp'Sie Plushie Behavior (#60728) Title, please say hello to the element "chemical_transfer" and the component "faction_granter" Componentized behavior is easier for admins to make events out of, more modular for code maintainability, lowers the possibility of future copy and paste, set me up with my wife, and more One of the things I personally like the most about it is the ability for each behavior to properly be described on examine, which I loooooove! Also, these should be fantasy affixes after the freeze is done Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com> * Componentizes/Elementalizes Pride Struck Hammer Behavior + Carp'Sie Plushie Behavior Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@ users.noreply.github.com>
56 lines
2.1 KiB
Plaintext
56 lines
2.1 KiB
Plaintext
|
|
/**
|
|
* ## faction granter component!
|
|
*
|
|
* component attached to items, lets them be used in hand once to add yourself to a certain faction
|
|
* one good example is the chaplain plushie that grants you the carp faction, making you friendly with them.
|
|
*/
|
|
/datum/component/faction_granter
|
|
dupe_mode = COMPONENT_DUPE_ALLOWED
|
|
///whichever faction the parent adds upon using in hand
|
|
var/faction_to_grant
|
|
///whether you need to be holy to get the faction.
|
|
var/holy_role_required
|
|
///message given when granting the faction.
|
|
var/grant_message
|
|
///boolean on whether it has been used
|
|
var/used = FALSE
|
|
|
|
/datum/component/faction_granter/Initialize(faction_to_grant, holy_role_required = NONE, grant_message)
|
|
if(!isitem(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
if(!grant_message) //Yes we could do this in the init call with default args, but it scares people
|
|
grant_message = "You have become friends with [faction_to_grant]"
|
|
src.faction_to_grant = faction_to_grant
|
|
src.holy_role_required = holy_role_required
|
|
src.grant_message = grant_message
|
|
|
|
/datum/component/faction_granter/RegisterWithParent()
|
|
RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, .proc/on_self_attack)
|
|
RegisterSignal(parent, COMSIG_PARENT_EXAMINE, .proc/on_examine)
|
|
|
|
/datum/component/faction_granter/UnregisterFromParent()
|
|
UnregisterSignal(parent, list(COMSIG_ITEM_ATTACK_SELF, COMSIG_PARENT_EXAMINE))
|
|
|
|
///signal called on parent being examined
|
|
/datum/component/faction_granter/proc/on_examine(datum/source, mob/user, list/examine_list)
|
|
SIGNAL_HANDLER
|
|
if(used)
|
|
examine_list += span_notice("[parent]'s favor granting power has been used up.")
|
|
else
|
|
examine_list += span_notice("Using [parent] in your hand will grant you favor with [faction_to_grant]\s")
|
|
|
|
///signal called on parent being interacted with in hand
|
|
/datum/component/faction_granter/proc/on_self_attack(atom/source, mob/user)
|
|
SIGNAL_HANDLER
|
|
if(used)
|
|
to_chat(user, span_warning("The power of [parent] has been used up!"))
|
|
return
|
|
if(user.mind?.holy_role >= holy_role_required)
|
|
to_chat(user, span_warning("You are not holy enough to invoke the power of [parent]!"))
|
|
return
|
|
|
|
to_chat(user, grant_message)
|
|
user.faction |= faction_to_grant
|
|
used = TRUE
|