Skip to content

Commit

Permalink
step 2. make it a backpack mount and take power
Browse files Browse the repository at this point in the history
  • Loading branch information
Thera-Pissed committed Jun 24, 2024
1 parent 85021fc commit 575c8d5
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 17 deletions.
3 changes: 3 additions & 0 deletions code/datums/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@
/datum/action/item_action/toggle_mister
name = "Toggle Mister"

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

/datum/action/item_action/activate_injector
name = "Activate Injector"

Expand Down
4 changes: 2 additions & 2 deletions code/datums/components/twohanded.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
dupe_mode = COMPONENT_DUPE_UNIQUE_PASSARGS // Only one of the component can exist on an item
var/wielded = FALSE /// Are we holding the two handed item properly
var/force_multiplier = 0 /// The multiplier applied to force when wielded, does not work with force_wielded, and force_unwielded
var/force_wielded = 0 /// The force of the item when weilded
var/force_unwielded = 0 /// The force of the item when unweilded
var/force_wielded = 0 /// The force of the item when wielded
var/force_unwielded = 0 /// The force of the item when unwielded
var/wieldsound = FALSE /// Play sound when wielded
var/unwieldsound = FALSE /// Play sound when unwielded
var/attacksound = FALSE /// Play sound on attack when wielded
Expand Down
6 changes: 3 additions & 3 deletions code/modules/cargo/packs/tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@

/datum/supply_pack/tools/anglegrinder
name = "Angle Grinder"
desc = "Contain one angle grinder, a tool used for quick structure deconstruction and salvaging"
cost = 1000
contains = list(/obj/item/anglegrinder)
desc = "Contains one angle grinder pack, a tool used for quick structure deconstruction and salvaging"
cost = 2000
contains = list(/obj/item/anglegrinderpack)
crate_name = "Angle Grinder"

/*
Expand Down
174 changes: 162 additions & 12 deletions code/modules/mining/equipment/angle_grinder.dm
Original file line number Diff line number Diff line change
@@ -1,43 +1,193 @@
/*
* Configure features by editing __DEFINES/anglegrinder.dm
*/
/obj/item/anglegrinderpack
name = "grinder pack"
desc = "Supplies the high voltage needed to run the attached grinder."
icon = 'icons/obj/mining.dmi'
item_state = "anglegrinderpack"
icon_state = "anglegrinderpack"
lefthand_file = 'icons/mob/inhands/equipment/backpack_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/backpack_righthand.dmi'
w_class = WEIGHT_CLASS_BULKY
slot_flags = ITEM_SLOT_BACK
slowdown = 1
actions_types = list(/datum/action/item_action/toggle_grinder)
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/obj/item/anglegrinder/grinder
var/obj/item/stock_parts/cell/cell
var/preload_cell_type = /obj/item/stock_parts/cell/high
var/power_cost = 5

/obj/item/anglegrinderpack/Initialize()
. = ..()
grinder = make_grinder()
if(preload_cell_type)
if(!ispath(preload_cell_type,/obj/item/stock_parts/cell))
log_mapping("[src] at [AREACOORD(src)] had an invalid preload_cell_type: [preload_cell_type].")
else
cell = new preload_cell_type(src)

/obj/item/anglegrinderpack/Destroy()
QDEL_NULL(grinder)
return ..()

/obj/item/anglegrinderpack/ui_action_click(mob/user)
toggle_grinder(user)

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

/obj/item/anglegrinderpack/proc/toggle_grinder(mob/living/user)
if(!istype(user))
return
if(user.get_item_by_slot(user.getBackSlot()) != src)
to_chat(user, "<span class='warning'>[src] must be worn properly to use!</span>")
return
if(user.incapacitated())
return
if(!cell || !cell.charge)
return

if(QDELETED(grinder))
grinder = make_grinder()
if(grinder in src)
//Detach the grinder into the user's hands
if(!user.put_in_hands(grinder))
to_chat(user, "<span class='warning'>You need a free hand to hold the grinder!</span>")
return
else
//Remove from their hands and put back "into" the pack
remove_grinder()

/obj/item/anglegrinderpack/verb/toggle_grinder_verb()
set name = "Toggle Angle Grinder"
set category = "Object"
toggle_grinder(usr)

/obj/item/anglegrinderpack/proc/make_grinder()
return new /obj/item/anglegrinder(src)

/obj/item/anglegrinderpack/equipped(mob/user, slot)
..()
if(slot != ITEM_SLOT_BACK)
remove_grinder()

/obj/item/anglegrinderpack/proc/remove_grinder()
if(!QDELETED(grinder))
if(ismob(grinder.loc))
var/mob/M = grinder.loc
M.temporarilyRemoveItemFromInventory(grinder, TRUE)
grinder.forceMove(src)

/obj/item/anglegrinderpack/attack_hand(mob/user)
if (user.get_item_by_slot(user.getBackSlot()) == src)
toggle_grinder(user)
else
return ..()

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

/obj/item/anglegrinderpack/attackby(obj/item/W, mob/user, params)
if(W == grinder)
remove_grinder()
return 1
else
return ..()

/obj/item/anglegrinderpack/dropped(mob/user)
..()
remove_grinder()

/obj/item/anglegrinderpack/proc/consume_charge(cost = power_cost)
if(cell.charge >= cost)
cell.charge -= cost
return TRUE
else
cell.charge = 0
remove_grinder()
return FALSE

/obj/item/anglegrinderpack/attackby(obj/item/I, mob/living/user, params)
if(I.tool_behaviour == TOOL_SCREWDRIVER)
cell.update_appearance()
cell.forceMove(get_turf(src))
cell = null
to_chat(user, "<span class='notice'>You remove the cell from [src].</span>")
return
if(istype(I, /obj/item/stock_parts/cell))
var/obj/item/stock_parts/cell/newcell = I
if(cell)
to_chat(user, "<span class='warning'>[src] already has a cell!</span>")
return
else
if(newcell.maxcharge < power_cost)
to_chat(user, "<span class='notice'>[src] requires a higher capacity cell.</span>")
return
if(!user.transferItemToLoc(I, src))
return
cell = I
to_chat(user, "<span class='notice'>You install [cell] in [src].</span>")
return

/obj/item/anglegrinderpack/examine(mob/user)
. = ..()
if(!cell)
. += "<spawn class='notice'>The cell is missing!</span>"
else
. += "<span class='notice'>[src] is [round(cell.percent())]% charged.</span>"

/obj/item/anglegrinder
name = "angle grinder"
desc = "A powerful salvage tool used to cut apart walls and airlocks. A peeling hazard sticker recommends ear and eye protection."
desc = "A powerful salvage tool used to cut apart walls and airlocks. A hazard sticker recommends ear and eye protection."
icon = 'icons/obj/mining.dmi'
icon_state = "anglegrinder_off"
lefthand_file = 'icons/mob/inhands/weapons/chainsaw_lefthand.dmi'
righthand_file = 'icons/mob/inhands/weapons/chainsaw_righthand.dmi'
flags_1 = CONDUCT_1
force = 13
w_class = WEIGHT_CLASS_HUGE
slot_flags = ITEM_SLOT_BACK
slowdown = 1
throwforce = 13
throw_speed = 2
throw_range = 4
custom_materials = list(/datum/material/iron=13000)
item_flags = ABSTRACT
attack_verb = list("sliced", "torn", "cut", "chopped", "diced")
hitsound = 'sound/weapons/anglegrinder.ogg'
usesound = 'sound/weapons/anglegrinder.ogg'
sharpness = IS_SHARP
tool_behaviour = null // is set to TOOL_DECONSTRUCT once weildedk
tool_behaviour = null // is set to TOOL_DECONSTRUCT once wielded
toolspeed = 1
var/wielded = FALSE // track wielded status on item
var/obj/item/anglegrinderpack/pack

// Trick to make the deconstruction that need a lit welder work. (bypassing fuel test)
/obj/item/anglegrinder/tool_use_check(mob/living/user, amount)
return TRUE
if(pack.consume_charge())
return TRUE
else
to_chat(user, "<span class='warning'>You need more charge to complete this task!</span>")
return FALSE

/obj/item/anglegrinder/use(used)
return TRUE

/obj/item/anglegrinder/Initialize()
. = ..()
pack = loc
if(!istype(pack))
return INITIALIZE_HINT_QDEL
RegisterSignal(src, COMSIG_TWOHANDED_WIELD, PROC_REF(on_wield))
RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, PROC_REF(on_unwield))

/obj/item/anglegrinder/doMove(atom/destination)
if(destination && (destination != pack.loc || !ismob(destination)))
if (loc != pack)
to_chat(pack.loc, "<span class='notice'>[src] snaps back onto [pack].</span>")
destination = pack
..()

/obj/item/anglegrinder/ComponentInitialize()
. = ..()
AddComponent(/datum/component/butchering, 30, 100, 0, 'sound/weapons/anglegrinder.ogg', TRUE)
Expand Down
Binary file modified icons/mob/clothing/back.dmi
Binary file not shown.
Binary file modified icons/obj/mining.dmi
Binary file not shown.
Binary file modified sound/weapons/anglegrinder.ogg
Binary file not shown.

0 comments on commit 575c8d5

Please sign in to comment.