From 39daad8d212c77cc52ce9660d17a35f20bb00280 Mon Sep 17 00:00:00 2001 From: Xhuis Date: Wed, 14 Oct 2015 17:31:58 -0400 Subject: [PATCH] Pneumatic cannon optimization --- .../objects/items/weapons/pneumaticCannon.dm | 45 ++++++++++++++----- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/code/game/objects/items/weapons/pneumaticCannon.dm b/code/game/objects/items/weapons/pneumaticCannon.dm index eb7652cb0a0..48219fcd7b4 100644 --- a/code/game/objects/items/weapons/pneumaticCannon.dm +++ b/code/game/objects/items/weapons/pneumaticCannon.dm @@ -37,6 +37,9 @@ return updateTank(W, 0, user) return + if(W.type == type) + user << "You're fairly certain that putting a pneumatic cannon inside another pneumatic cannon would cause a spacetime disruption." + return if(istype(W, /obj/item/weapon/wrench)) switch(pressureSetting) if(1) @@ -70,9 +73,22 @@ return -/obj/item/weapon/pneumatic_cannon/afterattack(atom/target as mob|obj|turf, mob/living/carbon/human/user as mob|obj, flag, params) - if(user.a_intent == "harm" || !ishuman(user)) +/obj/item/weapon/pneumatic_cannon/afterattack(atom/target, mob/living/carbon/human/user, flag, params) + if(istype(target, /obj/item/weapon/storage)) //So you can store it in backpacks return ..() + if(istype(target, /obj/structure/closet)) //So you can store it in closets + return ..() + if(istype(target, /obj/structure/rack)) //So you can store it on racks + return ..() + if(!istype(user)) + return ..() + Fire(user, target) + + +/obj/item/weapon/pneumatic_cannon/proc/Fire(var/mob/living/carbon/human/user, var/turf/target_turf) + if(!istype(user) && !target_turf) + return + var/discharge = 0 if(is_in_gang(user, "Sleeping Carp")) user << "Use of ranged weaponry would bring dishonor to the clan." return @@ -85,20 +101,29 @@ if(tank && !tank.air_contents.remove(gasPerThrow * pressureSetting)) user << "\The [src] lets out a weak hiss and doesn't react!" return - user.visible_message("[user] fires \the [src]!", \ - "You fire \the [src]!") - add_logs(user, target, "fired at", src) - playsound(src.loc, 'sound/weapons/sonic_jackhammer.ogg', (50 * pressureSetting), 1) + if(user.disabilities & CLUMSY && prob(25)) + user.visible_message("[user] loses their grip on [src], causing it to go off!", \ + "[src] slips out of your hands and goes off!") + user.drop_item() + if(prob(10)) + target_turf = get_turf(user) + else + for(var/turf/T in range(3,src)) + if(prob(25)) + target_turf = T + discharge = 1 + if(!discharge) + user.visible_message("[user] fires \the [src]!", \ + "You fire \the [src]!") + add_logs(user, target_turf, "fired at", src) + playsound(src.loc, 'sound/weapons/sonic_jackhammer.ogg', 50, 1) for(var/obj/item/ITD in loadedItems) //Item To Discharge spawn(0) loadedItems.Remove(ITD) loadedWeightClass -= ITD.w_class ITD.throw_speed = pressureSetting * 2 ITD.loc = get_turf(src) - ITD.throw_at(target, pressureSetting * 5, pressureSetting * 2,user) - if(pressureSetting >= 3) - user << "\The [src]'s recoil knocks you down!" - user.Weaken(2) + ITD.throw_at(target_turf, pressureSetting * 5, pressureSetting * 2,user) /obj/item/weapon/pneumatic_cannon/ghetto //Obtainable by improvised methods; more gas per use, less capacity, but smaller