Skip to content

Commit

Permalink
revives gear_packs by bjarl because theyre just better
Browse files Browse the repository at this point in the history
  • Loading branch information
Thera-Pissed committed Jun 24, 2024
1 parent e6bd316 commit d9329ad
Show file tree
Hide file tree
Showing 19 changed files with 362 additions and 201 deletions.
4 changes: 2 additions & 2 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@
/datum/action/item_action/toggle_mister
name = "Toggle Mister"

/datum/action/item_action/toggle_grinder
name = "Toggle Grinder"
/datum/action/item_action/toggle_attachment
name = "Toggle Attachment"

/datum/action/item_action/activate_injector
name = "Activate Injector"
Expand Down
3 changes: 3 additions & 0 deletions code/game/machinery/constructable_frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
qdel(src)

/obj/structure/frame/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if(I.use_tool(src, user, 3 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart \the [src].</span>", "<span class='notice'>You cut apart \the [src].</span>")
deconstruct()
Expand Down
8 changes: 4 additions & 4 deletions code/game/machinery/deployable.dm
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
return ..()

/obj/structure/barricade/wooden/deconstruct_act(mob/living/user, obj/item/I)
if(I.use_tool(src, user, 3 SECONDS, volume=0))
deconstruct()
. = ..()
if (I.use_tool(src, user, 1 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart the railing.</span>")
if(!I.tool_start_check(user, amount=0))
return FALSE
if (I.use_tool(src, user, 2 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart [src].</span>")
deconstruct()
return TRUE

Expand Down
3 changes: 3 additions & 0 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1244,6 +1244,9 @@
INVOKE_ASYNC(src, (density ? PROC_REF(open) : PROC_REF(close)), 2)

/obj/machinery/door/airlock/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
var/decon_time = 5 SECONDS
if(welded)
decon_time += 5 SECONDS
Expand Down
285 changes: 285 additions & 0 deletions code/game/objects/items/gear_packs.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
/obj/item/gear_pack
name = "gear pack"
desc = "A large backpack that usually holds things"
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "waterbackpack"
item_state = "waterbackpack"
lefthand_file = 'icons/mob/inhands/equipment/backpack_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/backpack_righthand.dmi'
w_class = WEIGHT_CLASS_HUGE
slot_flags = ITEM_SLOT_BACK
item_flags = SLOWS_WHILE_IN_HAND
max_integrity = 300
slowdown = 1
drag_slowdown = 1
actions_types = list(/datum/action/item_action/toggle_attachment)
max_integrity = 200
armor = list("melee" = 0, "bullet" = 0, "laser" = 0, "energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 100, "acid" = 30)
resistance_flags = FIRE_PROOF
var/on = FALSE
var/obj/item/stock_parts/cell/cell
var/preload_cell_type = /obj/item/stock_parts/cell/high
var/powered = FALSE
var/activate_sound = "sparks"
var/obj/item/attachment/attachment_type = /obj/item/attachment
var/obj/item/attachment/attachment

/obj/item/gear_pack/get_cell()
return cell

/obj/item/gear_pack/Initialize()
. = ..()
drag_slowdown = slowdown
attachment = new attachment_type(src)
cell = new(src)
update_power()
return

/obj/item/gear_pack/examine(mob/user)
. = ..()
. += "<span class='notice'>It is [ on ? "currently" : "not"] active.</span>"
if(cell)
. += "<span class = 'notice'>A small readout reports [PERCENT(cell.charge / cell.maxcharge)]% charge."

/obj/item/gear_pack/fire_act(exposed_temperature, exposed_volume)
. = ..()
if(attachment?.loc == src)
attachment.fire_act(exposed_temperature, exposed_volume)

/obj/item/gear_pack/extinguish()
. = ..()
if(attachment?.loc == src)
attachment.extinguish()

/obj/item/gear_pack/proc/update_power()
if(!QDELETED(cell))
if(QDELETED(attachment) || cell.charge < attachment.usecost)
powered = FALSE
else
powered = TRUE
else
powered = FALSE
update_icon()

/obj/item/gear_pack/update_overlays()
. = ..()

if(powered)
. += "[initial(icon_state)]-powered"
if(!QDELETED(cell))
var/ratio = cell.charge / cell.maxcharge
ratio = CEILING(ratio*4, 1) * 25
. += "[initial(icon_state)]-charge[ratio]"
if(!cell)
. += "[initial(icon_state)]-nocell"
if(!on)
. += "[initial(icon_state)]-attachment"

/obj/item/gear_pack/CheckParts(list/parts_list)
..()
cell = locate(/obj/item/stock_parts/cell) in contents
update_power()

/obj/item/gear_pack/ui_action_click()
toggle_attachment()

//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/gear_pack/attack_hand(mob/user)
if(loc == user)
if(slot_flags == ITEM_SLOT_BACK)
if(user.get_item_by_slot(ITEM_SLOT_BACK) == src)
ui_action_click()
else
to_chat(user, "<span class='warning'>Put the [src] on your back first!</span>")

else if(slot_flags == ITEM_SLOT_BELT)
if(user.get_item_by_slot(ITEM_SLOT_BELT) == src)
ui_action_click()
else
to_chat(user, "<span class='warning'>Strap the [src]'s belt on first!</span>")
return
return ..()

/obj/item/gear_pack/MouseDrop(obj/over_object)
. = ..()
if(ismob(loc))
var/mob/M = loc
if(!M.incapacitated() && istype(over_object, /atom/movable/screen/inventory/hand))
var/atom/movable/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)

/obj/item/gear_pack/attackby(obj/item/W, mob/user, params)
if(W == attachment)
toggle_attachment()
else if(istype(W, /obj/item/stock_parts/cell))
var/obj/item/stock_parts/cell/C = W
if(cell)
to_chat(user, "<span class='warning'>[src] already has a cell!</span>")
else
if(C.maxcharge < attachment.usecost)
to_chat(user, "<span class='notice'>[src] requires a higher capacity cell.</span>")
return
if(!user.transferItemToLoc(W, src))
return
cell = W
to_chat(user, "<span class='notice'>You install a cell in [src].</span>")
update_power()

else if(W.tool_behaviour == TOOL_SCREWDRIVER)
if(cell)
cell.update_icon()
cell.forceMove(get_turf(src))
cell = null
to_chat(user, "<span class='notice'>You remove the cell from [src].</span>")
update_power()
else
return ..()

/obj/item/gear_pack/emp_act(severity)
. = ..()
if(cell && !(. & EMP_PROTECT_CONTENTS))
deductcharge(1000 / severity)
if(. & EMP_PROTECT_SELF)
return
update_power()

/obj/item/gear_pack/proc/toggle_attachment()
set name = "Toggle Attachment"
set category = "Object"
on = !on

var/mob/living/carbon/user = usr
if(on)
//Detach the attachment into the user's hands
playsound(src, 'sound/items/handling/multitool_pickup.ogg', 100)
if(!usr.put_in_hands(attachment))
on = FALSE
to_chat(user, "<span class='warning'>You need a free hand to hold the [attachment]!</span>")
update_power()
return
else
//Remove from their hands and back onto the gear pack
remove_attachment(user)

update_power()
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()


/obj/item/gear_pack/equipped(mob/user, slot)
..()
if((slot_flags == ITEM_SLOT_BACK && slot != ITEM_SLOT_BACK) || (slot_flags == ITEM_SLOT_BELT && slot != ITEM_SLOT_BELT))
remove_attachment(user)
update_power()

/obj/item/gear_pack/item_action_slot_check(slot, mob/user)
if(slot == user.getBackSlot())
return 1

/obj/item/gear_pack/proc/remove_attachment(mob/user)
if(ismob(attachment.loc))
var/mob/M = attachment.loc
M.dropItemToGround(attachment, TRUE)
return

/obj/item/gear_pack/Destroy()
if(on)
var/M = get(attachment, /mob)
remove_attachment(M)
QDEL_NULL(attachment)
QDEL_NULL(cell)
return ..()

/obj/item/gear_pack/proc/deductcharge(chrgdeductamt)
if(cell)
if(cell.charge < (attachment.usecost+chrgdeductamt))
powered = FALSE
update_power()
if(cell.use(chrgdeductamt))
update_power()
return TRUE
else
return FALSE

/obj/item/attachment

name = "attachment"
desc = "The Attachment."
icon = 'icons/obj/hydroponics/equipment.dmi'
icon_state = "mister"
item_state = "mister"
lefthand_file = 'icons/mob/inhands/equipment/mister_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/mister_righthand.dmi'

force = 0
throwforce = 6
w_class = WEIGHT_CLASS_BULKY
resistance_flags = INDESTRUCTIBLE
base_icon_state = "mister"

var/req_pack = TRUE
var/usecost = 1000
var/obj/item/gear_pack/pack

/obj/item/attachment/Initialize()
. = ..()
ADD_TRAIT(src, TRAIT_NO_STORAGE_INSERT, GENERIC_ITEM_TRAIT)
if (!loc || !istype(loc, /obj/item/gear_pack))
return INITIALIZE_HINT_QDEL
if(!req_pack)
return
pack = loc
update_icon()

/obj/item/attachment/Destroy()
pack = null
return ..()

/obj/item/attachment/equipped(mob/user, slot)
. = ..()
if(!req_pack)
return
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(check_range))

/obj/item/attachment/Moved()
. = ..()
check_range()


/obj/item/attachment/fire_act(exposed_temperature, exposed_volume)
. = ..()
if((req_pack && pack) && loc != pack)
pack.fire_act(exposed_temperature, exposed_volume)

/obj/item/attachment/proc/check_range()
SIGNAL_HANDLER

if(!req_pack ||!pack)
return
if(!in_range(src,pack))
var/mob/living/L = loc
if(istype(L))
to_chat(L, "<span class='warning'>[pack]'s [src] overextends and comes out of your hands!</span>")
else
visible_message("<span class='notice'>[src] snaps back into [pack].</span>")
snap_back()

/obj/item/attachment/dropped(mob/user)
. = ..()
if(!req_pack)
return ..()
if(user)
UnregisterSignal(user, COMSIG_MOVABLE_MOVED)
if(user != loc)
to_chat(user, "<span class='notice'>[src] snap back into the main unit.</span>")
snap_back()
return

/obj/item/attachment/proc/snap_back()
if(!pack)
return
playsound()
pack.on = FALSE
forceMove(pack)
pack.update_power()
3 changes: 3 additions & 0 deletions code/game/objects/structures/door_assembly.dm
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@
qdel(src)

/obj/structure/door_assembly/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if (I.use_tool(src, user, 3 SECONDS, volume=100))
to_chat(user, "<span class='warning'>You slice [src] apart.</span>")
deconstruct(FALSE)
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/structures/girders.dm
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@
return ..()

/obj/structure/girder/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if(I.use_tool(src, user, 3 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart \the [src].</span>", "<span class='notice'>You cut apart \the [src].</span>")
deconstruct()
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/structures/grille.dm
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@
..()

/obj/structure/grille/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if (I.use_tool(src, user, 1 SECONDS, volume=100))
to_chat(user, "<span class='warning'>You slice [src] apart.</span>")
deconstruct(FALSE)
Expand Down
5 changes: 4 additions & 1 deletion code/game/objects/structures/lattice.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@
var/turf/T = get_turf(src)
return T.attackby(C, user) //hand this off to the turf instead (for building plating, catwalks, etc)

/obj/structure/frame/deconstruct_act(mob/living/user, obj/item/I)
/obj/structure/lattice/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if(I.use_tool(src, user, 1 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart \the [src].</span>", "<span class='notice'>You cut apart \the [src].</span>")
deconstruct()
Expand Down
3 changes: 3 additions & 0 deletions code/game/objects/structures/railings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
return TRUE

/obj/structure/railing/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if (I.use_tool(src, user, 3 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut apart the railing.</span>")
deconstruct()
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/structures/tables_racks.dm
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@

/obj/structure/table/deconstruct_act(mob/living/user, obj/item/I)
. = ..()
if(!I.tool_start_check(user, amount=0))
return FALSE
if (I.use_tool(src, user, 1 SECONDS, volume=0))
to_chat(user, "<span class='warning'>You cut [src] into sheets.</span>")
deconstruct(wrench_disassembly = TRUE)
Expand Down
Loading

0 comments on commit d9329ad

Please sign in to comment.