Files
Yogstation/code/game/objects/items/weapons/grenades/plastic.dm
2017-05-02 14:28:55 -03:00

166 lines
5.6 KiB
Plaintext

/obj/item/weapon/grenade/plastic
name = "plastic explosive"
desc = "Used to put holes in specific areas without too much extra hole."
icon_state = "plastic-explosive0"
item_state = "plastic-explosive"
flags = NOBLUDGEON
det_time = 10
display_timer = 0
var/atom/target = null
var/mutable_appearance/plastic_overlay
var/obj/item/device/assembly_holder/nadeassembly = null
var/assemblyattacher
var/directional = FALSE
var/aim_dir = NORTH
var/boom_sizes = list(0, 0, 3)
/obj/item/weapon/grenade/plastic/New()
plastic_overlay = mutable_appearance(icon, "[item_state]2")
..()
/obj/item/weapon/grenade/plastic/Destroy()
qdel(nadeassembly)
nadeassembly = null
target = null
..()
/obj/item/weapon/grenade/plastic/attackby(obj/item/I, mob/user, params)
if(!nadeassembly && istype(I, /obj/item/device/assembly_holder))
var/obj/item/device/assembly_holder/A = I
if(!user.transferItemToLoc(I, src))
return ..()
nadeassembly = A
A.master = src
assemblyattacher = user.ckey
to_chat(user, "<span class='notice'>You add [A] to the [name].</span>")
playsound(src, 'sound/weapons/tap.ogg', 20, 1)
update_icon()
return
if(nadeassembly && istype(I, /obj/item/weapon/wirecutters))
playsound(src, I.usesound, 20, 1)
nadeassembly.forceMove(get_turf(src))
nadeassembly.master = null
nadeassembly = null
update_icon()
return
..()
/obj/item/weapon/grenade/plastic/prime()
var/turf/location
if(target)
if(!QDELETED(target))
location = get_turf(target)
target.cut_overlay(plastic_overlay, TRUE)
else
location = get_turf(src)
if(location)
if(directional && target && target.density)
var/turf/T = get_step(location, aim_dir)
explosion(get_step(T, aim_dir), boom_sizes[1], boom_sizes[2], boom_sizes[3])
else
explosion(location, boom_sizes[1], boom_sizes[2], boom_sizes[3])
location.ex_act(2, target)
if(istype(target, /mob))
var/mob/M = target
M.gib()
qdel(src)
//assembly stuff
/obj/item/weapon/grenade/plastic/receive_signal()
prime()
/obj/item/weapon/grenade/plastic/Crossed(atom/movable/AM)
if(nadeassembly)
nadeassembly.Crossed(AM)
/obj/item/weapon/grenade/plastic/on_found(mob/finder)
if(nadeassembly)
nadeassembly.on_found(finder)
/obj/item/weapon/grenade/plastic/attack_self(mob/user)
if(nadeassembly)
nadeassembly.attack_self(user)
return
var/newtime = input(usr, "Please set the timer.", "Timer", 10) as num
if(user.get_active_held_item() == src)
newtime = Clamp(newtime, 10, 60000)
det_time = newtime
to_chat(user, "Timer set for [det_time] seconds.")
/obj/item/weapon/grenade/plastic/afterattack(atom/movable/AM, mob/user, flag)
aim_dir = get_dir(user,AM)
if(!flag)
return
if(ismob(AM))
return
to_chat(user, "<span class='notice'>You start planting the [src]. The timer is set to [det_time]...</span>")
if(do_after(user, 50, target = AM))
if(!user.temporarilyRemoveItemFromInventory(src))
return
src.target = AM
forceMove(null) //Yep
if(istype(AM, /obj/item)) //your crappy throwing star can't fly so good with a giant brick of c4 on it.
var/obj/item/I = AM
I.throw_speed = max(1, (I.throw_speed - 3))
I.throw_range = max(1, (I.throw_range - 3))
I.embed_chance = 0
message_admins("[ADMIN_LOOKUPFLW(user)] planted [name] on [target.name] at [ADMIN_COORDJMP(target)] with [det_time] second fuse",0,1)
log_game("[key_name(user)] planted [name] on [target.name] at [COORD(src)] with [det_time] second fuse")
target.add_overlay(plastic_overlay, 1)
if(!nadeassembly)
to_chat(user, "<span class='notice'>You plant the bomb. Timer counting down from [det_time].</span>")
addtimer(CALLBACK(src, .proc/prime), det_time*10)
else
qdel(src) //How?
/obj/item/weapon/grenade/plastic/suicide_act(mob/user)
message_admins("[ADMIN_LOOKUPFLW(user)] suicided with [src] at [ADMIN_COORDJMP(user)]",0,1)
log_game("[key_name(user)] suicided with [src] at [COORD(user)]")
user.visible_message("<span class='suicide'>[user] activates the [src] and holds it above [user.p_their()] head! It looks like [user.p_theyre()] going out with a bang!</span>")
var/message_say = "FOR NO RAISIN!"
if(user.mind)
if(user.mind.special_role)
var/role = lowertext(user.mind.special_role)
if(role == "traitor" || role == "syndicate")
message_say = "FOR THE SYNDICATE!"
else if(role == "changeling")
message_say = "FOR THE HIVE!"
else if(role == "cultist")
message_say = "FOR NAR-SIE!"
else if(role == "revolutionary" || role == "head revolutionary")
message_say = "VIVA LA REVOLUTION!"
user.say(message_say)
explosion(user,0,2,0) //Cheap explosion imitation because putting prime() here causes runtimes
user.gib(1, 1)
qdel(src)
/obj/item/weapon/grenade/plastic/update_icon()
if(nadeassembly)
icon_state = "[item_state]1"
else
icon_state = "[item_state]0"
//////////////////////////
///// The Explosives /////
//////////////////////////
/obj/item/weapon/grenade/plastic/c4
name = "C4"
desc = "Used to put holes in specific areas without too much extra hole. A saboteur's favorite."
// X4 is an upgraded directional variant of c4 which is relatively safe to be standing next to. And much less safe to be standing on the other side of.
// C4 is intended to be used for infiltration, and destroying tech. X4 is intended to be used for heavy breaching and tight spaces.
// Intended to replace C4 for nukeops, and to be a randomdrop in surplus/random traitor purchases.
/obj/item/weapon/grenade/plastic/x4
name = "X4"
desc = "A shaped high-explosive breaching charge. Designed to ensure user safety and wall nonsafety."
icon_state = "plasticx40"
item_state = "plasticx4"
directional = TRUE
boom_sizes = list(0, 2, 5)