diff --git a/code/modules/projectiles/guns/energy/laser.dm b/code/modules/projectiles/guns/energy/laser.dm index db6b0884926..b854b855ab3 100644 --- a/code/modules/projectiles/guns/energy/laser.dm +++ b/code/modules/projectiles/guns/energy/laser.dm @@ -157,6 +157,108 @@ charge_cost = 480 //to compensate a bit for self-recharging cell_type = /obj/item/weapon/cell/device/weapon/recharge/captain battery_lock = 1 + var/remainingshots = 0 //you may get a limited number of shots regardless of the charge + var/failurechance = 0 //chance per shot of something going awry + +/obj/item/weapon/gun/energy/captain/Initialize() + //it's an antique and it's been sitting in a case, unmaintained, for who the hell knows how long - who knows what'll happen when you pull it out? + ..() + //first, we decide, does it have a different type of beam? 75% of just being a 40-damage laser, 15% of being less or 0, 10% of being better + projectile_type = pick(prob(1);/obj/item/projectile/beam/pulse, + prob(2);/obj/item/projectile/beam/heavylaser/cannon, + prob(2);/obj/item/projectile/beam/heavylaser, + prob(5);/obj/item/projectile/beam/sniper, + prob(45);/obj/item/projectile/beam, + prob(10);/obj/item/projectile/beam/cyan, + prob(10);/obj/item/projectile/beam/eluger, + prob(10);/obj/item/projectile/beam/imperial, + prob(10);/obj/item/projectile/beam/weaklaser, + prob(5);/obj/item/projectile/beam/practice) + //now, decide whether it has a shot limit and if so how many + if(prob(50)) + remainingshots = rand(1,40) + if(prob(50)) + failurechance = rand(1,5) + + //finally, update the description so it has a tell if it's gonna burn out on you + if(remainingshots || failurechance) + desc = "A rare weapon, produced by the Lunar Arms Company around 2105 - one of humanity's first wholly extra-terrestrial weapon designs. It's been reasonably well-preserved." + +/obj/item/weapon/gun/energy/captain/special_check(var/mob/user) + if(remainingshots) + remainingshots -= 1 + if(!remainingshots) //you've shot your load, sonny + burnout(user) + return 0 + else if(prob(failurechance)) + malfunction(user) + return 0 + return ..() + +/obj/item/weapon/gun/energy/captain/proc/burnout(var/mob/user) + //your gun is now rendered useless + projectile_type = /obj/item/projectile/beam/practice //just in case you somehow manage to get it to fire again, its beam type is set to one that sucks + power_supply.charge = 0 + power_supply.maxcharge = 1 //just to avoid div/0 runtimes + desc = "A rare weapon, produced by the Lunar Arms Company around 2105 - one of humanity's first wholly extra-terrestrial weapon designs. It looks to have completely burned out." + user.visible_message("\The [src] erupts in a shower of sparks!", "\the [src] bursts into a shower of sparks!") + var/turf/T = get_turf(src) + var/datum/effect/effect/system/spark_spread/sparks = new /datum/effect/effect/system/spark_spread() + sparks.set_up(2, 1, T) + sparks.start() + update_icon() + +/obj/item/weapon/gun/energy/captain/proc/malfunction(var/mob/user) + var/screwup = rand(1,10) + switch(screwup) + if(1 to 5) //50% of just draining the battery and making future malfunctions more likely + power_supply.charge = 0 + var/turf/T = get_turf(src) + var/datum/effect/effect/system/spark_spread/sparks = new /datum/effect/effect/system/spark_spread() + sparks.set_up(2, 1, T) + sparks.start() + update_icon() + user.visible_message("\The [src] shorts out!", "\the [src] shorts out!") + failurechance += rand(1,5) + return + if(6 to 7) //20% chance of weakening the beam type, possibly to uselessness + var/obj/item/projectile/beam/B = new projectile_type + switch(B.damage) + if(0) + return //can't weaken it any further + if(1 to 15) //weaklaser becomes practice + projectile_type = /obj/item/projectile/beam/practice + if(16 to 40) //regular becomes weaklaser + projectile_type = /obj/item/projectile/beam/weaklaser + if(41 to 50) //sniper becomes regular + projectile_type = /obj/item/projectile/beam + if(51 to 60) //heavy becomes sniper + projectile_type = /obj/item/projectile/beam/sniper + if(61 to 80) //cannon becomes heavy + projectile_type = /obj/item/projectile/beam/heavylaser + if(81 to 100) //pulse becomes cannon + projectile_type = /obj/item/projectile/beam/heavylaser/cannon + user.visible_message("\The [src] dims slightly!", "\the [src] dims slightly!") + return + if(8) //10% chance of reducing the number of shots you have left, or giving you a limit if there isn't one + if(!remainingshots) + remainingshots = rand(1,40) + else + remainingshots = min(1, round(remainingshots/2)) + user.visible_message("\The [src] lets out a faint pop.", "\the [src] lets out a faint pop.") + if(9) //10% chance of permanently reducing the cell's max charge + power_supply.maxcharge = power_supply.maxcharge/2 + power_supply.charge = min(power_supply.charge, power_supply.maxcharge) + user.visible_message("\The [src] sparks,letting off a puff of smoke!", "\the [src] sparks,letting off a puff of smoke!") + var/turf/T = get_turf(src) + var/datum/effect/effect/system/spark_spread/sparks = new /datum/effect/effect/system/spark_spread() + sparks.set_up(2, 1, T) + sparks.start() + update_icon() + if(10) //10% chance of just straight-up breaking on the spot + burnout(user) + return + /* * Laser Cannon