Skip to content

Commit

Permalink
Improve modsuit code (#976)
Browse files Browse the repository at this point in the history
* i cant spell

* ports

* re-add digi support

* fix

* fix
  • Loading branch information
Kapu1178 authored Jun 10, 2024
1 parent 17761ca commit 6040eeb
Show file tree
Hide file tree
Showing 32 changed files with 1,204 additions and 683 deletions.
8 changes: 8 additions & 0 deletions code/__DEFINES/dcs/signals/signals_mod.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
//MODsuit signals
/// Called when a module is selected to be the active one from on_select(obj/item/mod/module/module)
#define COMSIG_MOD_MODULE_SELECTED "mod_module_selected"
/// Called when a MOD user deploys one or more of its parts.
#define COMSIG_MOD_DEPLOYED "mod_deployed"
/// Called when a MOD user retracts one or more of its parts.
#define COMSIG_MOD_RETRACTED "mod_retracted"
/// Called when a MOD deploys a part.
#define COMSIG_MOD_PART_DEPLOYED "mod_part_deployed"
/// Called when a MOD retracts a part.
#define COMSIG_MOD_PART_RETRACTED "mod_part_retracted"
/// Called when a MOD activation is called from toggle_activate(mob/user)
#define COMSIG_MOD_ACTIVATE "mod_activate"
/// Cancels the suit's activation
Expand Down
19 changes: 13 additions & 6 deletions code/__DEFINES/mod.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@
#define MODULE_ACTIVE 3

//Defines used by the theme for clothing flags and similar
#define CONTROL_LAYER "control_layer"
#define HELMET_FLAGS "helmet_flags"
#define CHESTPLATE_FLAGS "chestplate_flags"
#define GAUNTLETS_FLAGS "gauntlets_flags"
#define BOOTS_FLAGS "boots_flags"

#define UNSEALED_LAYER "unsealed_layer"
#define SEALED_LAYER "sealed_layer"
#define UNSEALED_CLOTHING "unsealed_clothing"
#define SEALED_CLOTHING "sealed_clothing"
#define UNSEALED_INVISIBILITY "unsealed_invisibility"
#define SEALED_INVISIBILITY "sealed_invisibility"
#define UNSEALED_COVER "unsealed_cover"
#define SEALED_COVER "sealed_cover"
#define CAN_OVERSLOT "can_overslot"
#define UNSEALED_MESSAGE "unsealed_message"
#define SEALED_MESSAGE "sealed_message"

//Defines used to override MOD clothing's icon and worn icon files in the skin.
#define MOD_ICON_OVERRIDE "mod_icon_override"
Expand All @@ -42,6 +39,16 @@
#define MODLINK_FREQ_CHARLIE "CHRL"
#define MODLINK_FREQ_CENTCOM "CC"

//Default text for different messages for the user.
#define HELMET_UNSEAL_MESSAGE "hisses open"
#define HELMET_SEAL_MESSAGE "hisses closed"
#define CHESTPLATE_UNSEAL_MESSAGE "releases your chest"
#define CHESTPLATE_SEAL_MESSAGE "cinches tightly around your chest"
#define GAUNTLET_UNSEAL_MESSAGE "become loose around your fingers"
#define GAUNTLET_SEAL_MESSAGE "tighten around your fingers and wrists"
#define BOOT_UNSEAL_MESSAGE "relax their grip on your legs"
#define BOOT_SEAL_MESSAGE "seal around your feet"

/// Global list of all /datum/mod_theme
GLOBAL_LIST_EMPTY(mod_themes)
/// Global list of all ids associated to a /datum/mod_link instance
Expand Down
43 changes: 43 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,49 @@ GLOBAL_LIST_EMPTY(species_list)
else
return zone

///Returns a list of strings for a given slot flag.
/proc/parse_slot_flags(slot_flags)
var/list/slot_strings = list()
if(slot_flags & ITEM_SLOT_BACK)
slot_strings += "back"
if(slot_flags & ITEM_SLOT_MASK)
slot_strings += "mask"
if(slot_flags & ITEM_SLOT_NECK)
slot_strings += "neck"
if(slot_flags & ITEM_SLOT_HANDCUFFED)
slot_strings += "handcuff"
if(slot_flags & ITEM_SLOT_LEGCUFFED)
slot_strings += "legcuff"
if(slot_flags & ITEM_SLOT_BELT)
slot_strings += "belt"
if(slot_flags & ITEM_SLOT_ID)
slot_strings += "id"
if(slot_flags & ITEM_SLOT_EARS)
slot_strings += "ear"
if(slot_flags & ITEM_SLOT_EYES)
slot_strings += "glasses"
if(slot_flags & ITEM_SLOT_GLOVES)
slot_strings += "glove"
if(slot_flags & ITEM_SLOT_HEAD)
slot_strings += "head"
if(slot_flags & ITEM_SLOT_FEET)
slot_strings += "shoe"
if(slot_flags & ITEM_SLOT_OCLOTHING)
slot_strings += "oversuit"
if(slot_flags & ITEM_SLOT_ICLOTHING)
slot_strings += "undersuit"
if(slot_flags & ITEM_SLOT_SUITSTORE)
slot_strings += "suit storage"
if(slot_flags & (ITEM_SLOT_LPOCKET|ITEM_SLOT_RPOCKET))
slot_strings += "pocket"
if(slot_flags & ITEM_SLOT_HANDS)
slot_strings += "hand"
if(slot_flags & ITEM_SLOT_DEX_STORAGE)
slot_strings += "dextrous storage"
if(slot_flags & ITEM_SLOT_BACKPACK)
slot_strings += "backpack"
return slot_strings

///Returns the direction that the initiator and the target are facing
/proc/check_target_facings(mob/living/initiator, mob/living/target)
/*This can be used to add additional effects on interactions between mobs depending on how the mobs are facing each other, such as adding a crit damage to blows to the back of a guy's head.
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/human_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ There are several things that need to be remembered:
if((dna.species.bodytype & BODYTYPE_DIGITIGRADE) && (worn_item.supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION))
var/obj/item/bodypart/leg/leg = src.get_bodypart(BODY_ZONE_L_LEG)
if(leg.limb_id == leg.digitigrade_id)//Snowflakey and bad. But it makes it look consistent.
icon_file = shoes.worn_icon_digitigrade || DIGITIGRADE_SHOES_FILE //PARIAH EDIT
icon_file = shoes.worn_icon_digitigrade || DIGITIGRADE_SHOES_FILE

if(dna.species.bodytype & BODYTYPE_TESHARI)
if(worn_item.supports_variations_flags & CLOTHING_TESHARI_VARIATION)
Expand Down Expand Up @@ -566,7 +566,7 @@ There are several things that need to be remembered:
//More currently unused digitigrade handling
if(dna.species.bodytype & BODYTYPE_DIGITIGRADE)
if(worn_item.supports_variations_flags & CLOTHING_DIGITIGRADE_VARIATION)
icon_file = wear_suit.worn_icon_digitigrade || DIGITIGRADE_SUIT_FILE //PARIAH EDIT
icon_file = wear_suit.worn_icon_digitigrade || DIGITIGRADE_SUIT_FILE

//PARIAH EDIT END
if(dna.species.bodytype & BODYTYPE_TESHARI)
Expand Down
83 changes: 37 additions & 46 deletions code/modules/mod/adding_new_mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Currently crew MODsuits should be lightly armored in combat relevant stats.
for operating at lower power levels, keeping people sane. As consequence, the capacity \
of the suit has decreased, not being able to fit many modules at all."
default_skin = "psychological"
armor = list(MELEE = 10, BULLET = 5, LASER = 5, ENERGY = 5, BOMB = 0, BIO = 100, FIRE = 10, ACID = 75, WOUND = 5)
armor_type = /datum/armor/modtheme_psychological
complexity_max = DEFAULT_MAX_COMPLEXITY - 7
charge_drain = DEFAULT_CHARGE_DRAIN * 0.5
```
Expand Down Expand Up @@ -79,19 +79,18 @@ So, now that we have our theme, we want to add a skin to it (or another theme of
for operating at lower power levels, keeping people sane. As consequence, the capacity \
of the suit has decreased, not being able to fit many modules at all."
default_skin = "psychological"
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 100, FIRE = 10, ACID = 75, WOUND = 5)
armor_type = /datum/armor/modtheme_psychological
complexity_max = DEFAULT_MAX_COMPLEXITY - 7
charge_drain = DEFAULT_CHARGE_DRAIN * 0.5
skins = list(
variants = list(
"psychological" = list(
HELMET_LAYER = null,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
),
CHESTPLATE_FLAGS = list(
/obj/item/clothing/suit/mod = list(
),
GAUNTLETS_FLAGS = list(
/obj/item/clothing/gloves/mod = list(
),
BOOTS_FLAGS = list(
/obj/item/clothing/shoes/mod = list(
),
),
)
Expand All @@ -101,8 +100,7 @@ We now have a psychological skin, this will apply the psychological icons to eve
For example, if our helmet's icon covers the full head (like the research skin), we want to do something like this.

```dm
HELMET_LAYER = null,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_CLOTHING = SNUG_FIT|THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE|BLOCK_GAS_SMOKE_EFFECT,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR|HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT,
Expand All @@ -113,8 +111,8 @@ For example, if our helmet's icon covers the full head (like the research skin),
Otherwise, with an open helmet that becomes closed (like the engineering skin), we'd do this.

```dm
HELMET_LAYER = NECK_LAYER,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_LAYER = NECK_LAYER
UNSEALED_CLOTHING = SNUG_FIT,
SEALED_CLOTHING = THICKMATERIAL|STOPSPRESSUREDAMAGE,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR,
Expand All @@ -134,50 +132,49 @@ There are specific cases of helmets that semi-cover the head, like the cosmohonk
for operating at lower power levels, keeping people sane. As consequence, the capacity \
of the suit has decreased, not being able to fit many modules at all."
default_skin = "psychological"
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 100, FIRE = 10, ACID = 75, WOUND = 5)
armor_type = /datum/armor/modtheme_psychological
complexity_max = DEFAULT_MAX_COMPLEXITY - 7
charge_drain = DEFAULT_CHARGE_DRAIN * 0.5
skins = list(
variants = list(
"psychological" = list(
HELMET_LAYER = NECK_LAYER,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_LAYER = NECK_LAYER
UNSEALED_CLOTHING = SNUG_FIT,
SEALED_CLOTHING = THICKMATERIAL|STOPSPRESSUREDAMAGE,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR,
SEALED_INVISIBILITY = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT,
SEALED_COVER = HEADCOVERSMOUTH|HEADCOVERSEYES|PEPPERPROOF,
),
CHESTPLATE_FLAGS = list(
/obj/item/clothing/suit/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
SEALED_INVISIBILITY = HIDEJUMPSUIT,
),
GAUNTLETS_FLAGS = list(
/obj/item/clothing/gloves/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
BOOTS_FLAGS = list(
/obj/item/clothing/shoes/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
"psychotherapeutic" = list(
HELMET_LAYER = null,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_CLOTHING = SNUG_FIT|THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR|HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT,
UNSEALED_COVER = HEADCOVERSMOUTH|HEADCOVERSEYES|PEPPERPROOF,
),
CHESTPLATE_FLAGS = list(
/obj/item/clothing/suit/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
SEALED_INVISIBILITY = HIDEJUMPSUIT,
),
GAUNTLETS_FLAGS = list(
/obj/item/clothing/gloves/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
BOOTS_FLAGS = list(
/obj/item/clothing/shoes/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
Expand Down Expand Up @@ -207,7 +204,7 @@ As we want this effect to be on demand, we probably want this to be an usable mo
- Usable: You can use these for a one time effect.
- Active: You can only have one selected at a time. It gives you a special click effect.

As we have an usable module, we want to set a cooldown time. All modules are also incompatible with themselves, have a specific power cost and complexity varying on how powerful they are, so let's update our definition, and also add a new variable for how much brain damage we'll heal.
As we have an usable module, we want to set a cooldown time. All modules are also incompatible with themselves, have a specific power cost and complexity varying on how powerful they are, and are equippable to certain slots, so let's update our definition, and also add a new variable for how much brain damage we'll heal.

```dm
/obj/item/mod/module/neuron_healer
Expand All @@ -217,35 +214,30 @@ As we have an usable module, we want to set a cooldown time. All modules are als
icon_state = "neuron_healer"
module_type = MODULE_USABLE
complexity = 3
use_power_cost = DEFAULT_CHARGE_DRAIN
use_energy_cost = DEFAULT_CHARGE_DRAIN
incompatible_modules = list(/obj/item/mod/module/neuron_healer)
cooldown_time = 15 SECONDS
required_slot = list(ITEM_SLOT_HEAD)
var/brain_damage_healed = 25
```

Now, we want to override the on_use proc for our new effect. We want to make sure the use checks passed from parent. You can read about most procs and variables by reading [this](modules/_module.dm)
Now, we want to override the on_use proc for our new effect. You can read about most procs and variables by reading [this](modules/_module.dm)

```dm
/obj/item/mod/module/neuron_healer/on_use()
. = ..()
if(!.)
return
```

After this, we want to put our special code, a basic effect of healing all mobs nearby for their brain damage and creating a beam to them.

```dm
/obj/item/mod/module/neuron_healer/on_use()
. = ..()
if(!.)
return
for(var/mob/living/carbon/carbon_mob in range(5, src))
if(carbon_mob == mod.wearer)
continue
carbon_mob.adjustOrganLoss(ORGAN_SLOT_BRAIN, -brain_damage_healed)
mod.wearer.Beam(carbon_mob, icon_state = "plasmabeam", time = 1.5 SECONDS)
playsound(src, 'sound/effects/magic.ogg', 100, TRUE)
drain_power(use_power_cost)
drain_power(use_energy_cost)
```

We now have a basic module, we can add it to the techwebs to make it printable ingame, and we can add an inbuilt, advanced version of it for our psychological suit. We'll give it more healing power, no complexity and make it unremovable.
Expand All @@ -268,51 +260,50 @@ Now we want to add it to the psychological theme, which is very simple, finishin
for operating at lower power levels, keeping people sane. As consequence, the capacity \
of the suit has decreased, not being able to fit many modules at all."
default_skin = "psychological"
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, BIO = 100, FIRE = 10, ACID = 75, WOUND = 5)
armor_type = /datum/armor/modtheme_psychological
complexity_max = DEFAULT_MAX_COMPLEXITY - 7
charge_drain = DEFAULT_CHARGE_DRAIN * 0.5
inbuilt_modules = list(/obj/item/mod/module/neuron_healer/advanced)
skins = list(
variants = list(
"psychological" = list(
HELMET_LAYER = NECK_LAYER,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_LAYER = NECK_LAYER
UNSEALED_CLOTHING = SNUG_FIT,
SEALED_CLOTHING = THICKMATERIAL|STOPSPRESSUREDAMAGE,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR,
SEALED_INVISIBILITY = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT,
SEALED_COVER = HEADCOVERSMOUTH|HEADCOVERSEYES|PEPPERPROOF,
),
CHESTPLATE_FLAGS = list(
/obj/item/clothing/suit/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
SEALED_INVISIBILITY = HIDEJUMPSUIT,
),
GAUNTLETS_FLAGS = list(
/obj/item/clothing/gloves/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
BOOTS_FLAGS = list(
/obj/item/clothing/shoes/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
"psychotherapeutic" = list(
HELMET_LAYER = null,
HELMET_FLAGS = list(
/obj/item/clothing/head/mod = list(
UNSEALED_CLOTHING = SNUG_FIT|THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
UNSEALED_INVISIBILITY = HIDEFACIALHAIR|HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDESNOUT,
UNSEALED_COVER = HEADCOVERSMOUTH|HEADCOVERSEYES|PEPPERPROOF,
),
CHESTPLATE_FLAGS = list(
/obj/item/clothing/suit/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
SEALED_INVISIBILITY = HIDEJUMPSUIT,
),
GAUNTLETS_FLAGS = list(
/obj/item/clothing/gloves/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
BOOTS_FLAGS = list(
/obj/item/clothing/shoes/mod = list(
UNSEALED_CLOTHING = THICKMATERIAL,
SEALED_CLOTHING = STOPSPRESSUREDAMAGE,
),
Expand Down
Loading

0 comments on commit 6040eeb

Please sign in to comment.