Files
Bubberstation/code/modules/assembly/bomb.dm
Bloop 1bfee08d54 Fixes greyscale colors not updating when changing their colors via VV, and fixes some issues with accessories (#77806)
## About The Pull Request

Fixes https://github.com/Skyrat-SS13/Skyrat-tg/issues/23214

This fixes a few bugs and cleans up code a bit:

1) Greyscale colors that were changed via the VV modify greyscale menu
will now update the mob's worn clothing accordingly. It wasn't doing
this before. Accessories in particular needed a bit of extra work to
update in this way because it wasn't coded with this case in mind.

2) Accessories will call `equipped()` and `dropped()` when they get
added/removed. This will fix issues like item flags being incorrectly
set, action bars not being added, etc.

3) Accessories will now be returned by `get_all_gear()`. This will
probably fix a few issues I'm not aware of.

## Why It's Good For The Game

<details><summary>Works</summary>


![dreamseeker_xijzQB0ALa](https://github.com/tgstation/tgstation/assets/13398309/eccb35d5-e1ea-4e2c-9906-f5b8c2187d24)

</details>

<details><summary>get_all_gear()</summary>


![dreamseeker_WsG0Uu2tIe](https://github.com/tgstation/tgstation/assets/13398309/d5c272d4-1990-454c-b48f-4da7b6a5f859)

</details>

<details><summary>get_equipped_items()</summary>


![dreamseeker_qe4hMngAO3](https://github.com/tgstation/tgstation/assets/13398309/06469b93-2a58-49db-be7f-c748576bf481)

</details>


<details><summary>item_flags get set now, hopefully preventing future
issues related to that</summary>


![image](https://github.com/tgstation/tgstation/assets/13398309/29a0e25a-a88f-4547-99f8-888da6b85e4d)

</details>

## Changelog

🆑
fix: greyscale colors will now update on the mob when modifying them via
the VV menu
/🆑

---------

Co-authored-by: Ghom <42542238+Ghommie@users.noreply.github.com>
2023-08-26 20:47:59 +02:00

156 lines
4.6 KiB
Plaintext

/obj/item/onetankbomb
name = "bomb"
icon = 'icons/obj/canisters.dmi'
inhand_icon_state = "assembly"
lefthand_file = 'icons/mob/inhands/items/devices_lefthand.dmi'
righthand_file = 'icons/mob/inhands/items/devices_righthand.dmi'
throwforce = 5
w_class = WEIGHT_CLASS_NORMAL
throw_speed = 2
throw_range = 4
flags_1 = CONDUCT_1
var/status = FALSE //0 - not readied //1 - bomb finished with welder
var/obj/item/assembly_holder/bombassembly = null //The first part of the bomb is an assembly holder, holding an igniter+some device
var/obj/item/tank/bombtank = null //the second part of the bomb is a plasma tank
/obj/item/onetankbomb/Destroy()
bombassembly = null
bombtank = null
return ..()
/obj/item/onetankbomb/IsSpecialAssembly()
return TRUE
/obj/item/onetankbomb/examine(mob/user)
return bombtank.examine(user)
/obj/item/onetankbomb/update_icon(updates)
icon = bombtank?.icon || initial(icon)
return ..()
/obj/item/onetankbomb/update_icon_state()
icon_state = bombtank?.icon_state || initial(icon_state)
return ..()
/obj/item/onetankbomb/update_overlays()
. = ..()
if(bombassembly)
. += bombassembly.icon_state
. += bombassembly.overlays
. += "bomb_assembly"
/obj/item/onetankbomb/wrench_act(mob/living/user, obj/item/I)
..()
to_chat(user, span_notice("You disassemble [src]!"))
if(bombassembly)
bombassembly.forceMove(drop_location())
bombassembly.master = null
bombassembly = null
if(bombtank)
bombtank.forceMove(drop_location())
bombtank.master = null
bombtank = null
qdel(src)
return TRUE
/obj/item/onetankbomb/welder_act(mob/living/user, obj/item/I)
..()
. = FALSE
if(status)
to_chat(user, span_warning("[bombtank] already has a pressure hole!"))
return
if(!I.tool_start_check(user, amount=1))
return
if(I.use_tool(src, user, 0, volume=40))
status = TRUE
var/datum/gas_mixture/bomb_mix = bombtank.return_air()
log_bomber(user, "welded a single tank bomb,", src, "| Temp: [bomb_mix.temperature]")
to_chat(user, span_notice("A pressure hole has been bored to [bombtank] valve. \The [bombtank] can now be ignited."))
add_fingerprint(user)
return TRUE
/obj/item/onetankbomb/attack_self(mob/user) //pressing the bomb accesses its assembly
bombassembly.attack_self(user, TRUE)
add_fingerprint(user)
return
/obj/item/onetankbomb/receive_signal() //This is mainly called by the sensor through sense() to the holder, and from the holder to here.
audible_message(span_warning("[icon2html(src, hearers(src))] *beep* *beep* *beep*"))
playsound(src, 'sound/machines/triple_beep.ogg', ASSEMBLY_BEEP_VOLUME, TRUE)
sleep(1 SECONDS)
if(QDELETED(src))
return
if(status)
bombtank.ignite() //if its not a dud, boom (or not boom if you made shitty mix) the ignite proc is below, in this file
else
bombtank.release()
/obj/item/onetankbomb/on_found(mob/finder) //for mousetraps
if(bombassembly)
bombassembly.on_found(finder)
/obj/item/onetankbomb/attack_hand(mob/user, list/modifiers) //also for mousetraps
. = ..()
if(.)
return
if(bombassembly)
bombassembly.attack_hand()
/obj/item/onetankbomb/Move()
. = ..()
if(bombassembly)
bombassembly.setDir(dir)
bombassembly.Move()
/obj/item/onetankbomb/dropped()
. = ..()
if(bombassembly)
bombassembly.dropped()
// ---------- Procs below are for tanks that are used exclusively in 1-tank bombs ----------
//Bomb assembly proc. This turns assembly+tank into a bomb
/obj/item/tank/proc/bomb_assemble(obj/item/assembly_holder/assembly, mob/living/user)
//Check if either part of the assembly has an igniter, but if both parts are igniters, then fuck it
var/igniter_count = 0
for(var/obj/item/assembly/attached_assembly as anything in assembly.assemblies)
if(isigniter(attached_assembly))
igniter_count += 1
if(LAZYLEN(assembly.assemblies) == igniter_count)
return
if((src in user.get_equipped_items(include_pockets = TRUE, include_accessories = TRUE)) && !user.canUnEquip(src))
to_chat(user, span_warning("[src] is stuck to you!"))
return
if(!user.canUnEquip(assembly))
to_chat(user, span_warning("[assembly] is stuck to your hand!"))
return
var/obj/item/onetankbomb/bomb = new
user.transferItemToLoc(src, bomb)
user.transferItemToLoc(assembly, bomb)
bomb.bombassembly = assembly //Tell the bomb about its assembly part
assembly.master = bomb //Tell the assembly about its new owner
assembly.on_attach()
bomb.bombtank = src //Same for tank
master = bomb
forceMove(bomb)
bomb.update_appearance()
user.put_in_hands(bomb) //Equips the bomb if possible, or puts it on the floor.
to_chat(user, span_notice("You attach [assembly] to [src]."))
return
/obj/item/onetankbomb/return_analyzable_air()
if(bombtank)
return bombtank.return_analyzable_air()
else
return null