Skip to content

Commit

Permalink
Fix Select Equipment Presets (#5758)
Browse files Browse the repository at this point in the history
# About the pull request

<!--
 -->
This is literally a one-line fix to an apparently unnoticed bug
affecting multiple loadouts, particularly certain ERTs. Explanation
below.

Select Equipment now spawns in an ID before equipment.

# Explain why it's good for the game

<!--
-->
ID Locks check via the COMSIG_ITEM_ATTEMPTING_EQUIP signal when someone
tries to equip them, and searches for an equipped ID to lock with. If
there's none, it cancels the equip.

/obj/item/proc/mob_can_equip() sends out that signal as part of its
testing, and the usual mob equip_to_slot_or_del() proc used in most
presets ends up checking the item's mob_can_equip() before equipping.

IDs were generated AFTER equipment within
/datum/equipment_preset/proc/load_preset() in _select_equipment.dm. This
means every single item with an ID lock would be spawned in, the mob
would see if it could equip them, the item would return no, cancelling
the equip, and the item would be deleted.

Pre-equipped Spec loadouts were the most affected, losing all of their
armor and ID-locked sights. Most special ERT NVGs were affected as well,
being subtypes of the Sniper Spec's NVGs, and sharing the same
MOB_LOCK_ON_EQUIP flag.

**If there's a reason IDs were spawned in after, this might break
something, but I doubt it. Just went tracking once I noticed this bug,
and found this as the most effective solution.**

An alternative solution was to use the unsafe equip_to_slot() proc
instead.


# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl: Kaga
fix: Fixed a bug that broke ID-Lockable items in presets. Rejoice, PMC
Snipers, pre-equipped USCM Specs, UPP Commandos, and WY Deathsquads.
/:cl:
  • Loading branch information
Kaga-404 authored Feb 21, 2024
1 parent c2ed945 commit 2abcb7b
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/modules/gear_presets/_select_equipment.dm
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@
load_skills(new_human, mob_client) //skills are set before equipment because of skill restrictions on certain clothes.
load_languages(new_human, mob_client)
load_age(new_human, mob_client)
load_id(new_human, mob_client)
if(show_job_gear)
load_gear(new_human, mob_client)
load_id(new_human, mob_client)
load_status(new_human, mob_client)
load_vanity(new_human, mob_client)
load_traits(new_human, mob_client)
Expand Down
1 change: 0 additions & 1 deletion code/modules/gear_presets/clf.dm
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,6 @@
new_human.set_species(SYNTH_COLONY_GEN_ONE)

/datum/equipment_preset/clf/synth/load_gear(mob/living/carbon/human/new_human)
load_name(new_human)
var/obj/item/clothing/under/colonist/clf/CLF = new()
var/obj/item/clothing/accessory/storage/webbing/W = new()
CLF.attach_accessory(new_human, W)
Expand Down
1 change: 0 additions & 1 deletion code/modules/gear_presets/cmb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@
new_human.set_species(SYNTH_COLONY)

/datum/equipment_preset/cmb/synth/load_gear(mob/living/carbon/human/new_human)
load_name(new_human)
//backpack
new_human.equip_to_slot_or_del(new /obj/item/storage/backpack/security, WEAR_BACK)
new_human.equip_to_slot_or_del(new /obj/item/ammo_magazine/revolver/cmb/normalpoint, WEAR_IN_BACK)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/gear_presets/contractor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@
new_human.set_species(SYNTH_GEN_THREE)

/datum/equipment_preset/contractor/duty/synth/load_gear(mob/living/carbon/human/new_human)
load_name(new_human)
//back
new_human.equip_to_slot_or_del(new /obj/item/storage/backpack/marine/smartpack/black, WEAR_BACK)
new_human.equip_to_slot_or_del(new /obj/item/device/defibrillator, WEAR_IN_BACK) //1
Expand Down Expand Up @@ -782,7 +781,6 @@
new_human.set_species(SYNTH_GEN_THREE)

/datum/equipment_preset/contractor/covert/synth/load_gear(mob/living/carbon/human/new_human)
load_name(new_human)
//back
new_human.equip_to_slot_or_del(new /obj/item/storage/backpack/marine/smartpack/black, WEAR_BACK)
new_human.equip_to_slot_or_del(new /obj/item/device/defibrillator, WEAR_IN_BACK) //1
Expand Down
3 changes: 1 addition & 2 deletions code/modules/gear_presets/upp.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2599,7 +2599,7 @@
assignment = JOB_UPP_COMBAT_SYNTH
rank = JOB_UPP_COMBAT_SYNTH
paygrade = PAY_SHORT_SYN
idtype = /obj/item/card/id/gold
idtype = /obj/item/card/id/dogtag

/datum/equipment_preset/upp/synth/load_name(mob/living/carbon/human/new_human, randomise)
new_human.gender = pick(50;MALE,50;FEMALE)
Expand Down Expand Up @@ -2638,7 +2638,6 @@
new_human.set_species(SYNTH_GEN_THREE)

/datum/equipment_preset/upp/synth/load_gear(mob/living/carbon/human/new_human)
load_name(new_human)
//back
new_human.equip_to_slot_or_del(new /obj/item/storage/backpack/lightpack/upp, WEAR_BACK)
new_human.equip_to_slot_or_del(new /obj/item/device/defibrillator/compact, WEAR_IN_BACK) //1
Expand Down

0 comments on commit 2abcb7b

Please sign in to comment.