mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-26 06:29:23 +01:00
[MIRROR] limb disabled refactor (#757)
* limb disabled refactor (#53374) Fixes #53219 Nukes is_disabled() Turns several variable value changes into events. bodypart_disabled turned into a boolean value. BODYPART_DISABLED_WOUND turned into TRAIT_DISABLED_BY_WOUND. Not the cleanest thing out there, but it works. Cleans some code and reduces number of updates, as only the extremities have a disabled effect. * limb disabled refactor Co-authored-by: Rohesie <rohesie@gmail.com>
This commit is contained in:
@@ -104,13 +104,13 @@
|
||||
..()
|
||||
for(var/X in paralysis_traits)
|
||||
ADD_TRAIT(owner, X, "trauma_paralysis")
|
||||
owner.update_disabled_bodyparts()
|
||||
|
||||
|
||||
/datum/brain_trauma/severe/paralysis/on_lose()
|
||||
..()
|
||||
for(var/X in paralysis_traits)
|
||||
REMOVE_TRAIT(owner, X, "trauma_paralysis")
|
||||
owner.update_disabled_bodyparts()
|
||||
|
||||
|
||||
/datum/brain_trauma/severe/paralysis/paraplegic
|
||||
random_gain = FALSE
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
QDEL_NULL(attached_surgery)
|
||||
if(limb?.wounds && (src in limb.wounds)) // destroy can call remove_wound() and remove_wound() calls qdel, so we check to make sure there's anything to remove first
|
||||
remove_wound()
|
||||
limb = null
|
||||
set_limb(null)
|
||||
victim = null
|
||||
return ..()
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
return
|
||||
|
||||
victim = L.owner
|
||||
limb = L
|
||||
set_limb(L)
|
||||
LAZYADD(victim.all_wounds, src)
|
||||
LAZYADD(limb.wounds, src)
|
||||
limb.update_wounds()
|
||||
@@ -192,13 +192,45 @@
|
||||
already_scarred = TRUE
|
||||
remove_wound(replaced=TRUE)
|
||||
new_wound.apply_wound(limb, old_wound = src, smited = smited)
|
||||
. = new_wound
|
||||
qdel(src)
|
||||
return new_wound
|
||||
|
||||
/// The immediate negative effects faced as a result of the wound
|
||||
/datum/wound/proc/wound_injury(datum/wound/old_wound = null)
|
||||
return
|
||||
|
||||
|
||||
/// Proc called to change the variable `limb` and react to the event.
|
||||
/datum/wound/proc/set_limb(new_value)
|
||||
if(limb == new_value)
|
||||
return FALSE //Limb can either be a reference to something or `null`. Returning the number variable makes it clear no change was made.
|
||||
. = limb
|
||||
limb = new_value
|
||||
if(. && disabling)
|
||||
var/obj/item/bodypart/old_limb = .
|
||||
REMOVE_TRAIT(old_limb, TRAIT_PARALYSIS, src)
|
||||
REMOVE_TRAIT(old_limb, TRAIT_DISABLED_BY_WOUND, src)
|
||||
if(limb)
|
||||
if(disabling)
|
||||
ADD_TRAIT(limb, TRAIT_PARALYSIS, src)
|
||||
ADD_TRAIT(limb, TRAIT_DISABLED_BY_WOUND, src)
|
||||
|
||||
|
||||
/// Proc called to change the variable `disabling` and react to the event.
|
||||
/datum/wound/proc/set_disabling(new_value)
|
||||
if(disabling == new_value)
|
||||
return
|
||||
. = disabling
|
||||
disabling = new_value
|
||||
if(disabling)
|
||||
if(!. && limb) //Gained disabling.
|
||||
ADD_TRAIT(limb, TRAIT_PARALYSIS, src)
|
||||
ADD_TRAIT(limb, TRAIT_DISABLED_BY_WOUND, src)
|
||||
else if(. && limb) //Lost disabling.
|
||||
REMOVE_TRAIT(limb, TRAIT_PARALYSIS, src)
|
||||
REMOVE_TRAIT(limb, TRAIT_DISABLED_BY_WOUND, src)
|
||||
|
||||
|
||||
/// Additional beneficial effects when the wound is gained, in case you want to give a temporary boost to allow the victim to try an escape or last stand
|
||||
/datum/wound/proc/second_wind()
|
||||
switch(severity)
|
||||
|
||||
@@ -177,7 +177,7 @@
|
||||
interaction_efficiency_penalty = interaction_efficiency_penalty
|
||||
|
||||
if(initial(disabling))
|
||||
disabling = !limb.current_gauze
|
||||
set_disabling(!limb.current_gauze)
|
||||
|
||||
limb.update_wounds()
|
||||
|
||||
|
||||
@@ -82,19 +82,19 @@
|
||||
if(WOUND_INFECTION_SEVERE to WOUND_INFECTION_CRITICAL)
|
||||
if(!disabling && prob(2))
|
||||
to_chat(victim, "<span class='warning'><b>Your [limb.name] completely locks up, as you struggle for control against the infection!</b></span>")
|
||||
disabling = TRUE
|
||||
set_disabling(TRUE)
|
||||
else if(disabling && prob(8))
|
||||
to_chat(victim, "<span class='notice'>You regain sensation in your [limb.name], but it's still in terrible shape!</span>")
|
||||
disabling = FALSE
|
||||
set_disabling(FALSE)
|
||||
else if(prob(20))
|
||||
victim.adjustToxLoss(0.5)
|
||||
if(WOUND_INFECTION_CRITICAL to WOUND_INFECTION_SEPTIC)
|
||||
if(!disabling && prob(3))
|
||||
to_chat(victim, "<span class='warning'><b>You suddenly lose all sensation of the festering infection in your [limb.name]!</b></span>")
|
||||
disabling = TRUE
|
||||
set_disabling(TRUE)
|
||||
else if(disabling && prob(3))
|
||||
to_chat(victim, "<span class='notice'>You can barely feel your [limb.name] again, and you have to strain to retain motor control!</span>")
|
||||
disabling = FALSE
|
||||
set_disabling(FALSE)
|
||||
else if(prob(1))
|
||||
to_chat(victim, "<span class='warning'>You contemplate life without your [limb.name]...</span>")
|
||||
victim.adjustToxLoss(0.75)
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
victim.visible_message(msg, "<span class='userdanger'>Your [dismembered_part.name] [occur_text]!</span>")
|
||||
|
||||
limb = dismembered_part
|
||||
set_limb(dismembered_part)
|
||||
severity = WOUND_SEVERITY_LOSS
|
||||
second_wind()
|
||||
log_wound(victim, src)
|
||||
|
||||
Reference in New Issue
Block a user