/
chainsaw.dm
83 lines (70 loc) · 2.75 KB
/
chainsaw.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// CHAINSAW
/obj/item/chainsaw
name = "chainsaw"
desc = "A versatile power tool. Useful for limbing trees and delimbing humans."
icon_state = "chainsaw_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
var/force_on = 24
w_class = WEIGHT_CLASS_HUGE
throwforce = 13
throw_speed = 2
throw_range = 4
custom_materials = list(/datum/material/iron=13000)
attack_verb = list("sawed", "torn", "cut", "chopped", "diced")
hitsound = "swing_hit"
sharpness = IS_SHARP
actions_types = list(/datum/action/item_action/startchainsaw)
tool_behaviour = TOOL_SAW
toolspeed = 0.5
var/on = FALSE
var/wielded = FALSE // track wielded status on item
/obj/item/chainsaw/Initialize()
. = ..()
RegisterSignal(src, COMSIG_TWOHANDED_WIELD, PROC_REF(on_wield))
RegisterSignal(src, COMSIG_TWOHANDED_UNWIELD, PROC_REF(on_unwield))
/obj/item/chainsaw/ComponentInitialize()
. = ..()
AddComponent(/datum/component/butchering, 30, 100, 0, 'sound/weapons/chainsawhit.ogg', TRUE)
AddComponent(/datum/component/two_handed, require_twohands=TRUE)
/// triggered on wield of two handed item
/obj/item/chainsaw/proc/on_wield(obj/item/source, mob/user)
SIGNAL_HANDLER
wielded = TRUE
/// triggered on unwield of two handed item
/obj/item/chainsaw/proc/on_unwield(obj/item/source, mob/user)
SIGNAL_HANDLER
wielded = FALSE
/obj/item/chainsaw/attack_self(mob/user)
on = !on
to_chat(user, "As you pull the starting cord dangling from [src], [on ? "it begins to whirr." : "the chain stops moving."]")
force = on ? force_on : initial(force)
throwforce = on ? force_on : initial(force)
icon_state = "chainsaw_[on ? "on" : "off"]"
var/datum/component/butchering/butchering = src.GetComponent(/datum/component/butchering)
butchering.butchering_enabled = on
if(on)
hitsound = 'sound/weapons/chainsawhit.ogg'
else
hitsound = "swing_hit"
if(src == user.get_active_held_item()) //update inhands
user.update_inv_hands()
for(var/X in actions)
var/datum/action/A = X
A.UpdateButtonIcon()
/obj/item/chainsaw/get_dismemberment_chance()
if(wielded)
. = ..()
/obj/item/chainsaw/doomslayer
name = "THE GREAT COMMUNICATOR"
desc = "<span class='warning'>VRRRRRRR!!!</span>"
armour_penetration = 100
force_on = 30
/obj/item/chainsaw/doomslayer/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK)
if(attack_type == PROJECTILE_ATTACK)
owner.visible_message("<span class='danger'>Ranged attacks just make [owner] angrier!</span>")
playsound(src, pick('sound/weapons/bulletflyby.ogg', 'sound/weapons/bulletflyby2.ogg', 'sound/weapons/bulletflyby3.ogg'), 75, TRUE)
return 1
return 0