Skip to content

Commit

Permalink
Tool bit initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
PollardTheDragon committed Feb 11, 2025
1 parent 02ee3bc commit f291945
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 0 deletions.
31 changes: 31 additions & 0 deletions code/game/objects/items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons

var/tip_timer = 0

// Smithing vars
/// List of attached tool bits
var/list/attached_bits = list()
/// Maximum number of bits
var/max_bits = 1
/// Can this item equip bits?
var/can_have_bits = FALSE

///////////////////////////
// MARK: item hover FX
///////////////////////////
Expand Down Expand Up @@ -435,6 +443,29 @@ GLOBAL_DATUM_INIT(welding_sparks, /mutable_appearance, mutable_appearance('icons
user.transfer_fingerprints_to(src)
else
to_chat(user, "<span class='notice'>You don't have enough tape to do that!</span>")
else if(istype(I, /obj/item/smithed_item/tool_bit) && can_have_bits)
if(length(attached_bits) >= max_bits)
to_chat(user, "<span class='notice'>Your tool already has the maximum number of bits!</span>")
return
var/obj/item/smithed_item/tool_bit/bit = I
bit.forceMove(src)
attached_bits += bit
bit.on_attached(user, src)

/obj/item/AltClick(mob/user)
. = ..()
if(!attached_bits)
to_chat(user, "<span class='notice'>Your [src] has no tool bits to remove.</span>")
return
var/obj/item/smithed_item/tool_bit/old_bit
if(length(attached_bits) == 1)
old_bit = attached_bits[0]
else
attached_bits = tgui_input_list(user, "Select a tool bit", src, attached_bits)
if(!istype(old_bit, /obj/item/smithed_item/tool_bit))
return
old_bit.on_detached()
user.put_in_hands(old_bit)

/obj/item/proc/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
var/signal_result = (SEND_SIGNAL(src, COMSIG_ITEM_HIT_REACT, owner, hitby, damage, attack_type)) + prob(final_block_chance)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/crowbar.dm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
origin_tech = "engineering=1;combat=1"
attack_verb = list("attacked", "bashed", "battered", "bludgeoned", "whacked")
toolspeed = 1
can_have_bits = TRUE

armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 50, ACID = 30)
tool_behaviour = TOOL_CROWBAR
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/hammer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
origin_tech = "engineering=1;combat=1"
attack_verb = list("attacked", "hammered", "smashed", "bludgeoned", "whacked")
toolspeed = 1
can_have_bits = TRUE

armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 50, ACID = 30)
tool_behaviour = TOOL_HAMMER
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/multitool.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
materials = list(MAT_METAL = 300, MAT_GLASS = 140)
origin_tech = "magnets=1;engineering=2"
toolspeed = 1
can_have_bits = TRUE
tool_behaviour = TOOL_MULTITOOL
hitsound = 'sound/weapons/tap.ogg'
/// Reference to whatever machine is held in the buffer
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/screwdriver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
drop_sound = 'sound/items/handling/screwdriver_drop.ogg'
pickup_sound = 'sound/items/handling/screwdriver_pickup.ogg'
tool_behaviour = TOOL_SCREWDRIVER
can_have_bits = TRUE
var/random_color = TRUE //if the screwdriver uses random coloring

new_attack_chain = TRUE
Expand Down
8 changes: 8 additions & 0 deletions code/game/objects/items/tools/tool_behaviour.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
// but only if the delay between the beginning and the end is not too small
if(delay >= MIN_TOOL_SOUND_DELAY)
play_tool_sound(target, volume)

// If it has a bit, wear and tear
for(var/obj/item/smithed_item/tool_bit/bit in attached_bits)
bit.durability--
if(bit.durability == 0)
attached_bits -= bit
bit.break_bit()

return TRUE

// Called before use_tool if there is a delay, or by use_tool if there isn't.
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/welder.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
usesound = 'sound/items/welder.ogg'
drop_sound = 'sound/items/handling/weldingtool_drop.ogg'
pickup_sound = 'sound/items/handling/weldingtool_pickup.ogg'
can_have_bits = TRUE
var/maximum_fuel = 20
/// Set to FALSE if it doesn't need fuel, but serves equally well as a cost modifier.
var/requires_fuel = TRUE
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/wirecutters.dm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 50, ACID = 30)
tool_behaviour = TOOL_WIRECUTTER
var/random_color = TRUE
can_have_bits = TRUE

new_attack_chain = TRUE

Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/tools/wrench.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
toolspeed = 1
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 50, ACID = 30)
tool_behaviour = TOOL_WRENCH
can_have_bits = TRUE

new_attack_chain = TRUE

Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/weapons/RCD.dm
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 0, RAD = 0, FIRE = 100, ACID = 50)
resistance_flags = FIRE_PROOF
new_attack_chain = TRUE
can_have_bits = TRUE
/// No ammo warning
var/no_ammo_message = "<span class='warning'>The \'Low Ammo\' light on the device blinks yellow.</span>"
/// The spark system used to create sparks when the user interacts with the RCD.
Expand Down
5 changes: 5 additions & 0 deletions code/modules/crafting/smithed_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
attached_suit.siemens_coefficient += siemens_coeff
attached_suit.min_cold_protection_temperature += heat_insulation
attached_suit.max_heat_protection_temperature -= heat_insulation
attached_suit = null

/obj/item/smithed_item/insert/ballistic
name = "ballistic plate"
Expand Down Expand Up @@ -318,10 +319,13 @@
if(!istype(target))
return
attached_tool = target
attached_tool.w_class += size_mod
attached_tool.toolspeed = toolspeed * speed_mod

/obj/item/smithed_item/tool_bit/on_detached()
attached_tool.toolspeed = toolspeed / speed_mod
attached_tool.w_class -= size_mod
attached_tool = null

/obj/item/smithed_item/tool_bit/proc/break_bit()
on_detached()
Expand Down Expand Up @@ -407,6 +411,7 @@
var/obj/item/projectile/e_bullet = casing.projectile_type
e_bullet.damage = e_bullet.damage / damage_mult
e_bullet.speed = e_bullet.speed * laser_speed_mult
attached_gun = null

/obj/item/smithed_item/lense/proc/break_lense()
on_detached()
Expand Down
5 changes: 5 additions & 0 deletions code/modules/projectiles/guns/energy_guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@
/obj/item/gun/energy/process_fire(atom/target, mob/living/user, message = 1, params, zone_override, bonus_spread = 0)
if(!chambered && can_shoot())
process_chamber()
if(current_lense)
current_lense.durability--
if(current_lense.durability <= 0)
current_lense.break_lense()
current_lense = null
return ..()

/obj/item/gun/energy/proc/select_fire(mob/living/user)
Expand Down
9 changes: 9 additions & 0 deletions code/modules/surgery/tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
w_class = WEIGHT_CLASS_SMALL
origin_tech = "materials=1;biotech=1"
tool_behaviour = TOOL_RETRACTOR
can_have_bits = TRUE

/obj/item/retractor/Initialize(mapload)
. = ..()
Expand All @@ -33,6 +34,7 @@
origin_tech = "materials=1;biotech=1"
attack_verb = list("attacked", "pinched")
tool_behaviour = TOOL_HEMOSTAT
can_have_bits = TRUE

/obj/item/hemostat/Initialize(mapload)
. = ..()
Expand All @@ -56,6 +58,7 @@
origin_tech = "materials=1;biotech=1"
attack_verb = list("burnt")
tool_behaviour = TOOL_CAUTERY
can_have_bits = TRUE

/obj/item/cautery/attack__legacy__attackchain(mob/living/target, mob/living/user)
if(!cigarette_lighter_act(user, target))
Expand Down Expand Up @@ -103,6 +106,7 @@
origin_tech = "materials=1;biotech=1"
attack_verb = list("drilled")
tool_behaviour = TOOL_DRILL
can_have_bits = TRUE

/obj/item/surgicaldrill/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -140,6 +144,7 @@
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
hitsound = 'sound/weapons/bladeslice.ogg'
tool_behaviour = TOOL_SCALPEL
can_have_bits = TRUE

/obj/item/scalpel/Initialize(mapload)
. = ..()
Expand Down Expand Up @@ -242,6 +247,7 @@
origin_tech = "biotech=1;combat=1"
attack_verb = list("attacked", "slashed", "sawed", "cut")
tool_behaviour = TOOL_SAW
can_have_bits = TRUE

/obj/item/circular_saw/Initialize(mapload)
. = ..()
Expand All @@ -266,6 +272,7 @@
throwforce = 1.0
origin_tech = "materials=1;biotech=1"
tool_behaviour = TOOL_BONEGEL
can_have_bits = TRUE

/obj/item/bonegel/Initialize(mapload)
. = ..()
Expand All @@ -286,6 +293,7 @@
origin_tech = "materials=1;biotech=1"
w_class = WEIGHT_CLASS_SMALL
tool_behaviour = TOOL_FIXOVEIN
can_have_bits = TRUE

/obj/item/fix_o_vein/Initialize(mapload)
. = ..()
Expand All @@ -309,6 +317,7 @@
attack_verb = list("attacked", "hit", "bludgeoned")
origin_tech = "materials=1;biotech=1"
tool_behaviour = TOOL_BONESET
can_have_bits = TRUE

/obj/item/bonesetter/Initialize(mapload)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/modules/telesci/rcs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
throw_range = 5
toolspeed = 1
usesound = 'sound/weapons/flash.ogg'
can_have_bits = TRUE
/// Power cell (10000W)
var/obj/item/stock_parts/cell/high/rcell = null
/// Selected telepad
Expand Down

0 comments on commit f291945

Please sign in to comment.