Skip to content

Commit

Permalink
Modular changes for batch 10/31
Browse files Browse the repository at this point in the history
Updates a couple paths, and rewrites a large chucnk of modsuit module
rendering, skipping the caching that TG does with their modsuit masking
because it wouldn't be worth how many variants we have
  • Loading branch information
FlufflesTheDog authored and Iajret committed Dec 6, 2024
1 parent 5418c71 commit 9878a27
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 125 deletions.
4 changes: 2 additions & 2 deletions code/modules/mod/mod_activation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@
part.heat_protection = NONE
part.cold_protection = NONE
part.alternate_worn_layer = part_datum.unsealed_layer
generate_suit_mask()
// generate_suit_mask() NOVA EDIT REMOVAL - why are you generating masks before you need them on suits that 80% of the time will not need them (also we're not currently caching)
wearer.update_clothing(part.slot_flags | slot_flags)
wearer.update_obscured_slots(part.visor_flags_inv)
if((part.clothing_flags & (MASKINTERNALS|HEADINTERNALS)) && wearer.invalid_internals())
Expand Down Expand Up @@ -303,7 +303,7 @@
update_speed()
update_charge_alert()
update_appearance(UPDATE_ICON_STATE)
generate_suit_mask()
// generate_suit_mask() NOVA EDIT REMOVAL - why are you generating masks before you need them on suits that 80% of the time will not need them (also we're not currently caching)
wearer.update_clothing(slot_flags)

/// Quickly deploys all the suit parts and if successful, seals them and turns on the suit. Intended mostly for outfits.
Expand Down
4 changes: 0 additions & 4 deletions code/modules/mod/modules/_module.dm
Original file line number Diff line number Diff line change
Expand Up @@ -348,16 +348,12 @@
var/used_overlay = get_current_overlay_state()
if (!used_overlay)
return
<<<<<<< HEAD
/* NOVA EDIT START - Making MODsuits mutant-compatible - ORIGINAL:
var/mutable_appearance/module_icon = mutable_appearance(overlay_icon_file, used_overlay, layer = standing.layer + 0.1)
=======
var/mutable_appearance/module_icon
if(mask_worn_overlay)
module_icon = mutable_appearance(get_module_icon_cache(used_overlay), layer = standing.layer + 0.1)
else
module_icon = mutable_appearance(overlay_icon_file, used_overlay, layer = standing.layer + 0.1)
>>>>>>> 7247928ec4... MODules don't create visual overlays when their required part isn't deployed (#87452)
if(!use_mod_colors)
module_icon.appearance_flags |= RESET_COLOR
Expand Down
149 changes: 45 additions & 104 deletions modular_nova/master_files/code/modules/mod/modules/_module.dm
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
/obj/item/mod/module
/// The suit's supports_variations_flags, currently only for the chestplate and the helmet parts of the MODsuit.
var/suit_supports_variations_flags = NONE
/// Does this module have a separate head sprite? Useful for muzzled sprites
var/has_head_sprite = FALSE
/// Is the module's visuals head-only when active? Useful for visors and such, to avoid multiplying the amount of overlay with empty images
var/head_only_when_active = FALSE
/// Is the module's visuals head-only when inactive? Useful for visors and such, to avoid multiplying the amount of overlay with empty images
var/head_only_when_inactive = FALSE
/// Which part of the modsuit this module is 'attached' to, for purposes of hiding them when retracting the part. Null means it won't get hidden.
var/datum/weakref/retracts_into

// we need to update mob overlays on deploy/retract in order for the hiding to work because this doesn't happen otherwise
/obj/item/mod/control/deploy(mob/user, obj/item/part)
. = ..()
if(wearer)
wearer.update_clothing(slot_flags)

/obj/item/mod/control/retract(mob/user, obj/item/part)
. = ..()
if(wearer)
wearer.update_clothing(slot_flags)

/obj/item/mod/module/on_uninstall(deleting = FALSE)
. = ..()
retracts_into = null

// SEE HERE: This is how you make any given module retract alongside a suit part.
// Set the retracts_into WEAKREF to mod.helmet, mod.chestplate, mod.boots, or mod.gauntlets as desired in the on_install proc just like shown below
/obj/item/mod/module/visor/on_install()
. = ..()
retracts_into = WEAKREF(mod.get_part_from_slot(ITEM_SLOT_HEAD) || mod.get_part_from_slot(ITEM_SLOT_MASK) || mod.get_part_from_slot(ITEM_SLOT_EYES)) // hide visor module when the helmet is retracted

/obj/item/mod/module/flashlight/on_install()
. = ..()
retracts_into = WEAKREF(mod.get_part_from_slot(ITEM_SLOT_HEAD) || mod.get_part_from_slot(ITEM_SLOT_MASK))

/obj/item/mod/module/welding/on_install()
. = ..()
retracts_into = WEAKREF(mod.get_part_from_slot(ITEM_SLOT_HEAD) || mod.get_part_from_slot(ITEM_SLOT_MASK) || mod.get_part_from_slot(ITEM_SLOT_EYES))


/**
* Proc that handles the mutable_appearances of the module on the MODsuits
*
Expand All @@ -48,73 +6,56 @@
* * module_icon_state - The name of the icon_state we'll be using for the module on the MODsuit.
*/
/obj/item/mod/module/proc/handle_module_icon(mutable_appearance/standing, module_icon_state)
if(!mod.wearer)
CRASH("Attempted to generate modsuit module icons with no wearer")
. = list()
var/is_new_vox = FALSE
var/is_old_vox = FALSE
if(mod.wearer)
if(is_module_hidden()) // retracted modules can hide parts that aren't usable when inactive
return
var/obj/item/clothing/suit/mod/chestplate = mod.get_part_from_slot(ITEM_SLOT_OCLOTHING)
var/obj/item/clothing/head/mod/helmet = mod.get_part_from_slot(ITEM_SLOT_HEAD)
if(chestplate && (chestplate.supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION) && (mod.wearer.bodyshape & BODYSHAPE_DIGITIGRADE))
suit_supports_variations_flags |= CLOTHING_DIGITIGRADE_VARIATION

if(helmet && (helmet.supports_variations_flags & CLOTHING_SNOUTED_VARIATION) && mod.wearer.bodyshape & BODYSHAPE_SNOUTED)
suit_supports_variations_flags |= CLOTHING_SNOUTED_VARIATION
is_new_vox = isvoxprimalis(mod.wearer)
is_old_vox = isvox(mod.wearer)
var/obj/item/clothing/suit/mod/chestplate = mod.get_part_from_slot(ITEM_SLOT_OCLOTHING)
var/obj/item/clothing/head/mod/helmet = mod.get_part_from_slot(ITEM_SLOT_HEAD)
var/suit_snouted = (helmet?.supports_variations_flags & CLOTHING_SNOUTED_VARIATION) && (mod.wearer.bodyshape & BODYSHAPE_SNOUTED) && (supports_variations_flags & CLOTHING_SNOUTED_VARIATION)
var/suit_digitigrade = (chestplate.supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION) && (mod.wearer.bodyshape & BODYSHAPE_DIGITIGRADE) && (supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION)

var/icon_to_use = 'icons/mob/clothing/modsuit/mod_modules.dmi'
var/icon_state_to_use = module_icon_state
if(is_new_vox || is_old_vox)
if(is_new_vox)
icon_to_use = worn_icon_better_vox
if(is_old_vox)
icon_to_use = worn_icon_vox
if(isvoxprimalis(mod.wearer))
icon_to_use = 'modular_nova/modules/better_vox/icons/clothing/mod_modules.dmi'
else if(isvox(mod.wearer))
icon_to_use = worn_icon_vox

if(suit_supports_variations_flags && (supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION))
else if(suit_snouted && (supports_variations_flags & CLOTHING_SNOUTED_VARIATION))
icon_to_use = 'modular_nova/master_files/icons/mob/clothing/modsuit/mod_modules_mutant.dmi'
icon_state_to_use = "[module_icon_state]_digi"

var/add_overlay = TRUE
if(has_head_sprite && ((active && head_only_when_active) || (!active && head_only_when_inactive)))
add_overlay = FALSE

if(add_overlay)
icon_to_use = overlay_icon_file
var/mutable_appearance/module_icon = mutable_appearance(icon_to_use, icon_state_to_use, layer = standing.layer + 0.1) // Just changed the raw icon path to icon_to_use and the used_overlay to icon_state_to_use
module_icon.appearance_flags |= RESET_COLOR
. += module_icon

if(has_head_sprite)
icon_state_to_use = "[module_icon_state]_head_muzzled"
else if(suit_digitigrade && (supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION))
icon_to_use = 'modular_nova/master_files/icons/mob/clothing/modsuit/mod_modules_mutant.dmi'
icon_state_to_use = "[module_icon_state]_head"

if(suit_supports_variations_flags && (supports_variations_flags & CLOTHING_SNOUTED_VARIATION))
icon_state_to_use = "[icon_state_to_use]_muzzled"

if(is_new_vox)
icon_to_use = 'modular_nova/modules/better_vox/icons/clothing/mod_modules.dmi'
icon_state_to_use = module_icon_state

var/mutable_appearance/additional_module_icon = mutable_appearance(icon_to_use, icon_state_to_use, layer = standing.layer + 0.1)
additional_module_icon.appearance_flags |= RESET_COLOR
. += additional_module_icon

/**
* Check whether or not the mod's overlay is hidden.
*
* Returns TRUE or FALSE based on whether the module is able to be hidden when the part it is attached to is retracted.
* By default, will return FALSE for every mod unless 'retracts_into' is set for that mod.
*
*/
/obj/item/mod/module/proc/is_module_hidden()
if(isnull(retracts_into))
return FALSE
if(allow_flags & MODULE_ALLOW_INACTIVE)
return FALSE

var/obj/item/clothing/attached_suit_part = retracts_into.resolve()
if(attached_suit_part && attached_suit_part.loc == mod)
return TRUE
icon_state_to_use = "[module_icon_state]_digi"

var/mutable_appearance/module_icon
if(mask_worn_overlay)
var/icon/mod_mask = icon(mod.generate_suit_mask())
mod_mask.Blend(icon(icon_to_use, icon_state_to_use), ICON_MULTIPLY)
module_icon = mutable_appearance(mod_mask, layer = standing.layer + 0.1)
else
module_icon = mutable_appearance(icon_to_use, icon_state_to_use, layer = standing.layer + 0.1)
module_icon.appearance_flags |= RESET_COLOR

. += module_icon

/obj/item/mod/control/generate_suit_mask()
var/list/parts = get_parts(all = TRUE)
var/icon/slot_mask = icon('icons/blanks/32x32.dmi', "nothing")
for(var/obj/item/part as anything in parts)
var/icon_to_use
if(isvoxprimalis(wearer) && part.worn_icon_better_vox)
icon_to_use = part.worn_icon_better_vox
else if(isvox(wearer) && part.worn_icon_vox)
icon_to_use = part.worn_icon_vox
else if (isteshari(wearer) && part.worn_icon_teshari)
icon_to_use = part.worn_icon_teshari
else if((wearer.bodyshape & BODYSHAPE_SNOUTED) && (part.supports_variations_flags & CLOTHING_SNOUTED_VARIATION))
icon_to_use = part.worn_icon_muzzled
else if((wearer.bodyshape & BODYSHAPE_DIGITIGRADE) && (part.supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION))
icon_to_use = part.worn_icon_digi
else
icon_to_use = 'icons/mob/clothing/modsuit/mod_clothing.dmi'
slot_mask.Blend(icon(icon_to_use, part.icon_state), ICON_OVERLAY)
slot_mask.Blend("#fff", ICON_ADD)
return slot_mask
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
/obj/item/mod/module/armor_booster
supports_variations_flags = CLOTHING_SNOUTED_VARIATION
has_head_sprite = TRUE
head_only_when_active = TRUE
head_only_when_inactive = TRUE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/obj/item/mod/module/hydraulic/on_suit_activation()
/obj/item/mod/module/hydraulic/on_part_activation()
. = ..()
ADD_TRAIT(mod.wearer, TRAIT_TRASHMAN, MOD_TRAIT)

/obj/item/mod/module/hydraulic/on_suit_deactivation(deleting = FALSE)
/obj/item/mod/module/hydraulic/on_part_deactivation(deleting = FALSE)
. = ..()
REMOVE_TRAIT(mod.wearer, TRAIT_TRASHMAN, MOD_TRAIT)

Expand All @@ -23,12 +23,12 @@
speed_added = mod.slowdown_active // so when you hit full ash accretion, slowdown cancels out
RegisterSignal(mod, COMSIG_SPEED_POTION_APPLIED, PROC_REF(update_added_speed))

/obj/item/mod/module/ash_accretion/on_suit_activation()
/obj/item/mod/module/ash_accretion/on_part_activation()
. = ..()
protection_enabled = TRUE
RegisterSignals(mod, list(COMSIG_MOD_DEPLOYED, COMSIG_MOD_RETRACTED), PROC_REF(on_mod_toggle))

/obj/item/mod/module/ash_accretion/on_suit_deactivation(deleting)
/obj/item/mod/module/ash_accretion/on_part_deactivation(deleting)
. = ..()
protection_enabled = FALSE
UnregisterSignal(mod, list(COMSIG_MOD_DEPLOYED, COMSIG_MOD_RETRACTED))
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions modular_nova/modules/contractor/code/items/modsuit/modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
icon_state = "magnet"
icon = 'modular_nova/modules/contractor/icons/modsuit_modules.dmi'

/obj/item/mod/module/springlock/contractor/on_suit_activation() // This module is actually *not* a death trap
/obj/item/mod/module/springlock/contractor/on_part_activation() // This module is actually *not* a death trap
return

/obj/item/mod/module/springlock/contractor/on_suit_deactivation(deleting = FALSE)
/obj/item/mod/module/springlock/contractor/on_part_deactivation(deleting = FALSE)
return

/// This exists for the adminbus contractor modsuit. Do not use otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@
"nuzzle",
)
squeak_override = list(
'sound/effects/can/can_open1.ogg' = 1,
'sound/effects/can/can_open2.ogg' = 1,
'sound/effects/can/can_open3.ogg' = 1,
'sound/items/can/can_open1.ogg' = 1,
'sound/items/can/can_open2.ogg' = 1,
'sound/items/can/can_open3.ogg' = 1,
)
///the list that is chosen from depending on gaming skill
var/static/list/skill_response = list(
Expand Down Expand Up @@ -374,7 +374,7 @@
skill_level = (max(6, skill_level))
say(skill_response[skill_level])
if(skill_level == 7)
playsound(src_turf, 'sound/effects/can/can_pop.ogg', 80, TRUE)
playsound(src_turf, 'sound/items/can/can_pop.ogg', 80, TRUE)
new /obj/effect/abstract/liquid_turf/pwr_gamr(src_turf)
playsound(src_turf, 'sound/effects/bubbles/bubbles.ogg', 50, TRUE)
qdel(src)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
update_external_organs_modsuit_status(is_sealed && active)
wearer.update_body_parts(TRUE)

/obj/item/mod/control/finish_activation(is_on)
/obj/item/mod/control/control_activation(is_on)
. = ..()
update_external_organs_modsuit_status(is_on)
wearer.update_body_parts(TRUE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ DEFINE_BITFIELD(turret_flags, list(
if (mag.ammo_count())
if(!claptrap_moment)
balloon_alert_to_viewers("loading cartridge...")
chambered = WEAKREF(mag.get_round(keep = FALSE))
chambered = WEAKREF(mag.get_round())
var/obj/item/ammo_casing/casing = chambered?.resolve()
if(isnull(casing))
chambered = null
Expand Down

0 comments on commit 9878a27

Please sign in to comment.