Files
Bubberstation/code/modules/ninja/energy_katana.dm
phil235 d3ee910211 Makes effect system code more OOP.
obj/effect/effect is now renamed obj/effect/particle_effect for better usability.
datum/effect/system and /datum/effect/effect/system are now both /datum/effect_system.
Fixes a bug where wall mounted igniters (and other spark producing objects) didn't produce sparks sometimes.
Moved explosion_particles.dm into the effect_system folder, because it has effect_systems code.
2015-10-21 23:28:29 +02:00

75 lines
2.1 KiB
Plaintext

/obj/item/weapon/katana/energy
name = "energy katana"
desc = "A katana infused with strong energy."
icon_state = "energy_katana"
item_state = "energy_katana"
force = 40
throwforce = 20
armour_penetration = 15
var/datum/effect_system/spark_spread/spark_system
/obj/item/weapon/katana/energy/afterattack(atom/target, mob/user, proximity_flag, click_parameters)
if(!user || !target)
return
if(proximity_flag)
if(isobj(target) || issilicon(target))
spark_system.start()
playsound(user, "sparks", 50, 1)
playsound(user, 'sound/weapons/blade1.ogg', 50, 1)
target.emag_act(user)
//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/weapon/katana/energy/throw_impact(atom/hit_atom)
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/weapon/katana/energy/proc/returnToOwner(mob/living/carbon/human/user, doSpark = 1, caught = 0)
if(!istype(user))
return
loc = get_turf(src)
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, slot_belt, 0, 1, 1))
msg = "Your Energy Katana teleports back to you, sheathing itself as it does so!</span>"
else
loc = get_turf(user)
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)
user << "<span class='notice'>[msg]</span>"
/obj/item/weapon/katana/energy/New()
..()
spark_system = new /datum/effect_system/spark_spread()
spark_system.set_up(5, 0, src)
spark_system.attach(src)
/obj/item/weapon/katana/energy/Destroy()
qdel(spark_system)
spark_system = null
return ..()