-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathenergy_katana.dm
126 lines (109 loc) · 4.34 KB
/
energy_katana.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* # Energy Katana
*
* The space ninja's katana.
*
* The katana that only space ninja spawns with. Comes with 30 force and throwforce, along with a signature special jaunting system.
* Upon clicking on a tile with the dash on, the user will teleport to that tile.
* The katana has 5 dashes stored at maximum, and upon using the dash, it will return 20 seconds after it was used.
* It also has a special feature where if it is tossed at a space ninja who owns it (determined by the ninja suit), the ninja will catch the katana instead of being hit by it.
*
*/
/obj/item/energy_katana
name = "energy katana"
desc = "A katana infused with strong energy."
icon = 'icons/obj/weapons/longsword.dmi'
icon_state = "energy_katana"
item_state = "energy_katana"
lefthand_file = 'icons/mob/inhands/weapons/swords_lefthand.dmi'
righthand_file = 'icons/mob/inhands/weapons/swords_righthand.dmi'
force = 30
throwforce = 30
armour_penetration = 50
w_class = WEIGHT_CLASS_NORMAL
hitsound = 'sound/weapons/bladeslice.ogg'
attack_verb = list("attacked", "slashed", "stabbed", "sliced", "torn", "ripped", "diced", "cut")
slot_flags = ITEM_SLOT_BACK|ITEM_SLOT_BELT
sharpness = SHARP_EDGED
max_integrity = 200
resistance_flags = LAVA_PROOF | FIRE_PROOF | ACID_PROOF
var/datum/effect_system/spark_spread/spark_system
var/datum/action/innate/dash/ninja/jaunt
var/dash_toggled = TRUE
/obj/item/energy_katana/Initialize(mapload)
. = ..()
jaunt = new(src)
spark_system = new /datum/effect_system/spark_spread()
spark_system.set_up(5, 0, src)
spark_system.attach(src)
AddComponent(/datum/component/blocking, block_force = 15, block_flags = WEAPON_BLOCK_FLAGS|PROJECTILE_ATTACK|REFLECTIVE_BLOCK)
/obj/item/energy_katana/attack_self(mob/user)
dash_toggled = !dash_toggled
to_chat(user, span_notice("You [dash_toggled ? "enable" : "disable"] the dash function on [src]."))
/obj/item/energy_katana/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
. = ..()
if(dash_toggled)
jaunt.Teleport(user, target)
if(proximity_flag && (isobj(target) || issilicon(target)))
spark_system.start()
playsound(user, "sparks", 50, 1)
playsound(user, 'sound/weapons/blade1.ogg', 50, 1)
target.emag_act(user)
/obj/item/energy_katana/pickup(mob/living/carbon/human/user)
. = ..()
if(!IS_SPACE_NINJA(user)) //stolen directly from the bloody bastard sword
if(user.electrocute_act(15, src, 1, user.held_index_to_hand(user.active_hand_index))) // you tried to grab it with this hand, so we'll shock it
to_chat(user, span_userdanger("[src] shocks you!"))
user.emote("scream")
user.dropItemToGround(src, TRUE)
user.Paralyze(50)
else
to_chat(user, span_warning("[src] attempts to shock you."))
jaunt.Grant(user, src)
user.update_icons()
playsound(src, 'sound/items/unsheath.ogg', 25, 1)
/obj/item/energy_katana/dropped(mob/user)
. = ..()
jaunt.Remove(user)
user.update_icons()
//If we hit the Ninja who owns this Katana, they catch it.
//Works for if the Ninja throws it or it throws itself or someone tries
//To throw it at the ninja
/obj/item/energy_katana/throw_impact(atom/hit_atom, datum/thrownthing/throwingdatum)
if(ishuman(hit_atom))
var/mob/living/carbon/human/H = hit_atom
if(istype(H.wear_suit, /obj/item/clothing/suit/space/space_ninja))
var/obj/item/clothing/suit/space/space_ninja/SN = H.wear_suit
if(SN.energyKatana == src)
returnToOwner(H, 0, 1)
return
..()
/obj/item/energy_katana/proc/returnToOwner(mob/living/carbon/human/user, doSpark = 1, caught = 0)
if(!istype(user))
return
forceMove(get_turf(user))
if(doSpark)
spark_system.start()
playsound(get_turf(src), "sparks", 50, 1)
var/msg = ""
if(user.put_in_hands(src))
msg = "Your Energy Katana teleports into your hand!"
else if(user.equip_to_slot_if_possible(src, ITEM_SLOT_BELT, 0, 1, 1))
msg = "Your Energy Katana teleports back to you, sheathing itself as it does so!</span>"
else
msg = "Your Energy Katana teleports to your location!"
if(caught)
if(loc == user)
msg = "You catch your Energy Katana!"
else
msg = "Your Energy Katana lands at your feet!"
if(msg)
to_chat(user, span_notice("[msg]"))
/obj/item/energy_katana/Destroy()
QDEL_NULL(spark_system)
return ..()
/datum/action/innate/dash/ninja //Holds a good amount of charges, but charges them slowly. Use them wisely.
current_charges = 5
max_charges = 5
charge_rate = 200
recharge_sound = null