Skip to content

Commit

Permalink
[MIRROR] Fixes some shielded component jank [MDB IGNORE] (#599)
Browse files Browse the repository at this point in the history
* Fixes some shielded component jank

* Update _suits.dm

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: MrMelbert <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
4 people authored Nov 13, 2023
1 parent 057b3a6 commit e2b3aac
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
8 changes: 7 additions & 1 deletion code/datums/components/shielded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

/datum/component/shielded
dupe_mode = COMPONENT_DUPE_UNIQUE
/// The person currently wearing us
var/mob/living/wearer
/// How many charges we can have max, and how many we start with
Expand Down Expand Up @@ -113,7 +114,7 @@
if((slot & ITEM_SLOT_HANDS) && !shield_inhand)
lost_wearer(source, user)
return
set_wearer(source, user)
set_wearer(user)

/// Either we've been dropped or our wearer has been QDEL'd. Either way, they're no longer our problem
/datum/component/shielded/proc/lost_wearer(datum/source, mob/user)
Expand All @@ -125,6 +126,11 @@
wearer = null

/datum/component/shielded/proc/set_wearer(mob/user)
if(wearer == user)
return
if(!isnull(wearer))
CRASH("[type] called set_wearer with [user] but [wearer] was already the wearer!")

wearer = user
RegisterSignal(wearer, COMSIG_ATOM_UPDATE_OVERLAYS, PROC_REF(on_update_overlays))
RegisterSignal(wearer, COMSIG_QDELETING, PROC_REF(lost_wearer))
Expand Down
11 changes: 9 additions & 2 deletions code/modules/antagonists/cult/cult_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,15 @@ Striking a noncultist, however, will tear their flesh."}
fire = 50
acid = 60

/obj/item/clothing/suit/hooded/cultrobes/cult_shield/setup_shielding()
AddComponent(/datum/component/shielded, recharge_start_delay = 0 SECONDS, shield_icon_file = 'icons/effects/cult/effects.dmi', shield_icon = "shield-cult", run_hit_callback = CALLBACK(src, PROC_REF(shield_damaged)))
/obj/item/clothing/suit/hooded/cultrobes/cult_shield/Initialize(mapload)
. = ..()
AddComponent( \
/datum/component/shielded, \
recharge_start_delay = 0 SECONDS, \
shield_icon_file = 'icons/effects/cult/effects.dmi', \
shield_icon = "shield-cult", \
run_hit_callback = CALLBACK(src, PROC_REF(shield_damaged)), \
)

/// A proc for callback when the shield breaks, since cult robes are stupid and have different effects
/obj/item/clothing/suit/hooded/cultrobes/cult_shield/proc/shield_damaged(mob/living/wearer, attack_text, new_current_charges)
Expand Down
16 changes: 11 additions & 5 deletions code/modules/capture_the_flag/ctf_equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,18 @@
var/lose_multiple_charges = TRUE
var/show_charge_as_alpha = TRUE

/obj/item/clothing/suit/armor/vest/ctf/equipped(mob/user, slot)
/obj/item/clothing/suit/armor/vest/ctf/Initialize(mapload)
. = ..()
if(!slot || slot & ITEM_SLOT_HANDS)
return
AddComponent(/datum/component/shielded, max_charges = max_charges, recharge_start_delay = recharge_start_delay, charge_increment_delay = charge_increment_delay, \
charge_recovery = charge_recovery, lose_multiple_charges = lose_multiple_charges, show_charge_as_alpha = show_charge_as_alpha, shield_icon = team_shield_icon)
AddComponent( \
/datum/component/shielded, \
max_charges = max_charges, \
recharge_start_delay = recharge_start_delay, \
charge_increment_delay = charge_increment_delay, \
charge_recovery = charge_recovery, \
lose_multiple_charges = lose_multiple_charges, \
show_charge_as_alpha = show_charge_as_alpha, \
shield_icon = team_shield_icon, \
)

// LIGHT SHIELDED VEST

Expand Down
18 changes: 1 addition & 17 deletions code/modules/clothing/suits/_suits.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
var/blood_overlay_type = "suit"
limb_integrity = 0 // disabled for most exo-suits

/obj/item/clothing/suit/Initialize(mapload)
. = ..()
setup_shielding()

/// SKYRAT EDIT CHANGE BEGIN - taurs and teshis
// /obj/item/clothing/suit/worn_overlays(mutable_appearance/standing, isinhands = FALSE) // ORIGINAL
/obj/item/clothing/suit/worn_overlays(mutable_appearance/standing, isinhands = FALSE, file2use = null, mutant_styles = NONE)
// SKYRAT EDIT CHANGE END
/obj/item/clothing/suit/worn_overlays(mutable_appearance/standing, isinhands = FALSE, file2use = null, mutant_styles = NONE) // SKYRAT EDIT CHANGE - TAURS AND TESHIS - ORIGINAL: /obj/item/clothing/suit/worn_overlays(mutable_appearance/standing, isinhands = FALSE)
. = ..()
if(isinhands)
return
Expand Down Expand Up @@ -58,12 +51,3 @@
if(ismob(loc))
var/mob/M = loc
M.update_worn_oversuit()

/**
* Wrapper proc to apply shielding through AddComponent().
* Called in /obj/item/clothing/Initialize().
* Override with an AddComponent(/datum/component/shielded, args) call containing the desired shield statistics.
* See /datum/component/shielded documentation for a description of the arguments
**/
/obj/item/clothing/suit/proc/setup_shielding()
return

0 comments on commit e2b3aac

Please sign in to comment.