Files
fulpstation/code/modules/projectiles/guns/ballistic/laser_gatling.dm
Trevor Serpas bee0b5b2c3 Afterattack() Signal (#38606)
* adds signal and modifies each call of afterattack to call it's inherited proc

* uses new macro for sendsignal()

* map fuck

* skip precommithooks

* combine and negate 2 ifs
2018-07-07 02:00:25 -04:00

148 lines
4.1 KiB
Plaintext

//The ammo/gun is stored in a back slot item
/obj/item/minigunpack
name = "backpack power source"
desc = "The massive external power source for the laser gatling gun."
icon = 'icons/obj/guns/minigun.dmi'
icon_state = "holstered"
item_state = "backpack"
lefthand_file = 'icons/mob/inhands/equipment/backpack_lefthand.dmi'
righthand_file = 'icons/mob/inhands/equipment/backpack_righthand.dmi'
slot_flags = ITEM_SLOT_BACK
w_class = WEIGHT_CLASS_HUGE
var/obj/item/gun/ballistic/minigun/gun
var/armed = 0 //whether the gun is attached, 0 is attached, 1 is the gun is wielded.
var/overheat = 0
var/overheat_max = 40
var/heat_diffusion = 1
/obj/item/minigunpack/Initialize()
. = ..()
gun = new(src)
START_PROCESSING(SSobj, src)
/obj/item/minigunpack/Destroy()
STOP_PROCESSING(SSobj, src)
return ..()
/obj/item/minigunpack/process()
overheat = max(0, overheat - heat_diffusion)
//ATTACK HAND IGNORING PARENT RETURN VALUE
/obj/item/minigunpack/attack_hand(var/mob/living/carbon/user)
if(src.loc == user)
if(!armed)
if(user.get_item_by_slot(SLOT_BACK) == src)
armed = 1
if(!user.put_in_hands(gun))
armed = 0
to_chat(user, "<span class='warning'>You need a free hand to hold the gun!</span>")
return
update_icon()
user.update_inv_back()
else
to_chat(user, "<span class='warning'>You are already holding the gun!</span>")
else
..()
/obj/item/minigunpack/attackby(obj/item/W, mob/user, params)
if(W == gun) //Don't need armed check, because if you have the gun assume its armed.
user.dropItemToGround(gun, TRUE)
else
..()
/obj/item/minigunpack/dropped(mob/user)
if(armed)
user.dropItemToGround(gun, TRUE)
/obj/item/minigunpack/MouseDrop(atom/over_object)
. = ..()
if(armed)
return
if(iscarbon(usr))
var/mob/M = usr
if(!over_object)
return
if(!M.incapacitated())
if(istype(over_object, /obj/screen/inventory/hand))
var/obj/screen/inventory/hand/H = over_object
M.putItemFromInventoryInHandIfPossible(src, H.held_index)
/obj/item/minigunpack/update_icon()
if(armed)
icon_state = "notholstered"
else
icon_state = "holstered"
/obj/item/minigunpack/proc/attach_gun(var/mob/user)
if(!gun)
gun = new(src)
gun.forceMove(src)
armed = 0
if(user)
to_chat(user, "<span class='notice'>You attach the [gun.name] to the [name].</span>")
else
src.visible_message("<span class='warning'>The [gun.name] snaps back onto the [name]!</span>")
update_icon()
user.update_inv_back()
/obj/item/gun/ballistic/minigun
name = "laser gatling gun"
desc = "An advanced laser cannon with an incredible rate of fire. Requires a bulky backpack power source to use."
icon = 'icons/obj/guns/minigun.dmi'
icon_state = "minigun_spin"
item_state = "minigun"
flags_1 = CONDUCT_1
slowdown = 1
slot_flags = null
w_class = WEIGHT_CLASS_HUGE
materials = list()
burst_size = 3
automatic = 0
fire_delay = 1
weapon_weight = WEAPON_HEAVY
fire_sound = 'sound/weapons/laser.ogg'
mag_type = /obj/item/ammo_box/magazine/internal/minigun
casing_ejector = FALSE
item_flags = NEEDS_PERMIT | SLOWS_WHILE_IN_HAND
var/obj/item/minigunpack/ammo_pack
/obj/item/gun/ballistic/minigun/Initialize()
if(istype(loc, /obj/item/minigunpack)) //We should spawn inside an ammo pack so let's use that one.
ammo_pack = loc
else
return INITIALIZE_HINT_QDEL //No pack, no gun
return ..()
/obj/item/gun/ballistic/minigun/attack_self(mob/living/user)
return
/obj/item/gun/ballistic/minigun/dropped(mob/user)
if(ammo_pack)
ammo_pack.attach_gun(user)
else
qdel(src)
/obj/item/gun/ballistic/minigun/process_fire(atom/target, mob/living/user, message = TRUE, params = null, zone_override = "", bonus_spread = 0)
if(ammo_pack)
if(ammo_pack.overheat < ammo_pack.overheat_max)
ammo_pack.overheat += burst_size
..()
else
to_chat(user, "The gun's heat sensor locked the trigger to prevent lens damage.")
/obj/item/gun/ballistic/minigun/afterattack(atom/target, mob/living/user, flag, params)
if(!ammo_pack || ammo_pack.loc != user)
to_chat(user, "You need the backpack power source to fire the gun!")
. = ..()
/obj/item/gun/ballistic/minigun/dropped(mob/living/user)
ammo_pack.attach_gun(user)