Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrer committed Dec 6, 2024
1 parent 0527e59 commit a3faf96
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 28 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/clothing_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@
#define MUZZLE_MUTE_MUFFLE 1 // Muffles everything you say "MHHPHHMMM!!!
#define MUZZLE_MUTE_ALL 2 // Completely mutes you.

/// Wrapper for adding clothing based traits
#define ADD_CLOTHING_TRAIT(mob, trait) ADD_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[UID(src)]")
/// Wrapper for removing clothing based traits
#define REMOVE_CLOTHING_TRAIT(mob, trait) REMOVE_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[UID(src)]")
34 changes: 34 additions & 0 deletions code/modules/clothing/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,40 @@

return TRUE

/**
* Inserts a trait (or multiple traits) into the clothing traits list
*
* If worn, then we will also give the wearer the trait as if equipped
*
* This is so you can add clothing traits without worrying about needing to equip or unequip them to gain effects
*/
/obj/item/clothing/proc/attach_clothing_traits(trait_or_traits)
if(!islist(trait_or_traits))
trait_or_traits = list(trait_or_traits)

LAZYOR(clothing_traits, trait_or_traits)
var/mob/wearer = loc
if(istype(wearer) && (wearer.get_slot_by_item(src) & slot_flags))
for(var/new_trait in trait_or_traits)
ADD_CLOTHING_TRAIT(wearer, new_trait)

/**
* Removes a trait (or multiple traits) from the clothing traits list
*
* If worn, then we will also remove the trait from the wearer as if unequipped
*
* This is so you can add clothing traits without worrying about needing to equip or unequip them to gain effects
*/
/obj/item/clothing/proc/detach_clothing_traits(trait_or_traits)
if(!islist(trait_or_traits))
trait_or_traits = list(trait_or_traits)

LAZYREMOVE(clothing_traits, trait_or_traits)
var/mob/wearer = loc
if(istype(wearer))
for(var/new_trait in trait_or_traits)
REMOVE_CLOTHING_TRAIT(wearer, new_trait)

/obj/item/clothing/proc/refit_for_species(target_species)
//Set icon
if(sprite_sheets && (target_species in sprite_sheets))
Expand Down
43 changes: 15 additions & 28 deletions code/modules/clothing/shoes/magboots.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
strip_delay = 7 SECONDS
put_on_delay = 7 SECONDS
resistance_flags = FIRE_PROOF
no_slip = FALSE

var/magboot_state = "magboots"
var/magpulse = FALSE
var/slowdown_active = 2
var/slowdown_passive = SHOES_SLOWDOWN
var/magpulse_name = "mag-pulse traction system"
///If a pair of magboots has different icons for being on or off
var/multiple_icons = TRUE
var/list/active_traits = list(TRAIT_NOSLIP)

/obj/item/clothing/shoes/magboots/water_act(volume, temperature, source, method)
. = ..()
Expand All @@ -24,48 +25,34 @@

/obj/item/clothing/shoes/magboots/equipped(mob/user, slot, initial)
. = ..()
if(slot != ITEM_SLOT_SHOES || !ishuman(user))
return
check_mag_pulse(user)
if(magpulse)
attach_clothing_traits(active_traits)

/obj/item/clothing/shoes/magboots/dropped(mob/user, silent)
. = ..()
if(!ishuman(user))
return
check_mag_pulse(user, removing = TRUE)
if(magpulse)
detach_clothing_traits(active_traits)

/obj/item/clothing/shoes/magboots/attack_self__legacy__attackchain(mob/user)
toggle_magpulse(user)
/obj/item/clothing/shoes/magboots/attack_self(mob/user, forced = FALSE)
toggle_magpulse(user, forced)

/obj/item/clothing/shoes/magboots/proc/toggle_magpulse(mob/user, no_message)
/obj/item/clothing/shoes/magboots/proc/toggle_magpulse(mob/user, forced)
magpulse = !magpulse
if(magpulse) //magpulse and no_slip will always be the same value unless VV happens
REMOVE_TRAIT(user, TRAIT_NOSLIP, UID())
slowdown = slowdown_passive
else
if(user.get_item_by_slot(ITEM_SLOT_SHOES) == src)
ADD_TRAIT(user, TRAIT_NOSLIP, UID())
attach_clothing_traits(active_traits)
slowdown = slowdown_active
magpulse = !magpulse
no_slip = !no_slip
else
detach_clothing_traits(active_traits)
slowdown = slowdown_passive
if(multiple_icons)
icon_state = "[magboot_state][magpulse]"
if(!no_message)
if(!forced)
to_chat(user, "You [magpulse ? "enable" : "disable"] the [magpulse_name].")
user.update_inv_shoes() //so our mob-overlays update
user.update_gravity(user.mob_has_gravity())
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtons()
check_mag_pulse(user, removing = (user.get_item_by_slot(ITEM_SLOT_SHOES) != src))

/obj/item/clothing/shoes/magboots/proc/check_mag_pulse(mob/user, removing = FALSE)
if(!user)
return
if(magpulse && !removing)
ADD_TRAIT(user, TRAIT_MAGPULSE, "magboots[UID()]")
return
if(HAS_TRAIT(user, TRAIT_MAGPULSE)) // User has trait and the magboots were turned off, remove trait
REMOVE_TRAIT(user, TRAIT_MAGPULSE, "magboots[UID()]")

/obj/item/clothing/shoes/magboots/examine(mob/user)
. = ..()
Expand Down

0 comments on commit a3faf96

Please sign in to comment.