Merge pull request #759 from CHOMPStationBot/upstream-merge-9207

[MIRROR] [MIRROR] Phoron bore utility improvements
This commit is contained in:
Razgriz
2020-10-28 20:21:26 -07:00
committed by GitHub
11 changed files with 179 additions and 92 deletions

View File

@@ -1,27 +1,24 @@
/obj/item/weapon/gun/magnetic/matfed
name = "portable phoron bore"
desc = "A large man-portable tunnel bore, using phorogenic plasma blasts. Point away from user."
description_fluff = "An aging Grayson Manufactories mining tool used for rapidly digging through rock. Mass production was discontinued when many of the devices were stolen and used to break into a high security facility by Boiling Point drones."
description_antag = "This device is exceptional at breaking down walls, though it is incredibly loud when doing so."
description_info = "The projectile of this tool will travel six tiles before dissipating, excavating mineral walls as it does so. It can be reloaded with phoron sheets."
icon_state = "bore"
item_state = "bore"
wielded_item_state = "bore-wielded"
one_handed_penalty = 5
projectile_type = /obj/item/projectile/bullet/magnetic/bore
gun_unreliable = 0
power_cost = 750
load_type = /obj/item/stack/material
load_type = list(/obj/item/stack/material, /obj/item/weapon/ore)
var/mat_storage = 0 // How much material is stored inside? Input in multiples of 2000 as per auto/protolathe.
var/max_mat_storage = 8000 // How much material can be stored inside?
var/mat_cost = 500 // How much material is used per-shot?
var/ammo_material = MAT_PHORON
var/ammo_material
var/obj/item/weapon/stock_parts/manipulator/manipulator // Installed manipulator. Mostly for Phoron Bore, higher rating == less mats consumed upon firing. Set to a path to spawn with one of that type.
var/loading = FALSE
/obj/item/weapon/gun/magnetic/matfed/Initialize()
. = ..()
if(ispath(manipulator))
manipulator = new manipulator(src)
if(manipulator)
mat_cost = initial(mat_cost) / (2*manipulator.rating)
/obj/item/weapon/gun/magnetic/matfed/Destroy()
QDEL_NULL(manipulator)
. = ..()
/obj/item/weapon/gun/magnetic/matfed/examine(mob/user)
. = ..()
var/ammotext = show_ammo()
@@ -46,6 +43,7 @@
overlays = overlays_to_add
..()
/obj/item/weapon/gun/magnetic/matfed/attack_hand(var/mob/user) // It doesn't keep a loaded item inside.
if(user.get_inactive_hand() == src)
var/obj/item/removing
@@ -55,7 +53,6 @@
cell = null
if(removing)
removing.forceMove(get_turf(src))
user.put_in_hands(removing)
user.visible_message("<span class='notice'>\The [user] removes \the [removing] from \the [src].</span>")
playsound(src, 'sound/machines/click.ogg', 10, 1)
@@ -77,91 +74,170 @@
/obj/item/weapon/gun/magnetic/matfed/attackby(var/obj/item/thing, var/mob/user)
if(removable_components)
if(istype(thing, /obj/item/weapon/cell))
if(cell)
to_chat(user, "<span class='warning'>\The [src] already has \a [cell] installed.</span>")
return
cell = thing
user.drop_from_inventory(cell)
cell.forceMove(src)
playsound(src, 'sound/machines/click.ogg', 10, 1)
user.visible_message("<span class='notice'>\The [user] slots \the [cell] into \the [src].</span>")
update_icon()
return
if(thing.is_crowbar())
if(!manipulator)
to_chat(user, "<span class='warning'>\The [src] has no manipulator installed.</span>")
return
manipulator.forceMove(get_turf(src))
user.put_in_hands(manipulator)
user.visible_message("<span class='notice'>\The [user] levers \the [manipulator] from \the [src].</span>")
playsound(src, 'sound/items/Crowbar.ogg', 50, 1)
playsound(src, thing.usesound, 50, 1)
mat_cost = initial(mat_cost)
manipulator = null
update_icon()
return
if(thing.is_screwdriver())
if(!capacitor)
to_chat(user, "<span class='warning'>\The [src] has no capacitor installed.</span>")
return
capacitor.forceMove(get_turf(src))
user.put_in_hands(capacitor)
user.visible_message("<span class='notice'>\The [user] unscrews \the [capacitor] from \the [src].</span>")
playsound(src, 'sound/items/Screwdriver.ogg', 50, 1)
capacitor = null
update_icon()
return
if(istype(thing, /obj/item/weapon/stock_parts/capacitor))
if(capacitor)
to_chat(user, "<span class='warning'>\The [src] already has \a [capacitor] installed.</span>")
return
capacitor = thing
user.drop_from_inventory(capacitor)
capacitor.forceMove(src)
playsound(src, 'sound/machines/click.ogg', 10, 1)
power_per_tick = (power_cost*0.15) * capacitor.rating
user.visible_message("<span class='notice'>\The [user] slots \the [capacitor] into \the [src].</span>")
update_icon()
return
if(istype(thing, /obj/item/weapon/stock_parts/manipulator))
if(manipulator)
to_chat(user, "<span class='warning'>\The [src] already has \a [manipulator] installed.</span>")
return
manipulator = thing
user.drop_from_inventory(manipulator)
manipulator.forceMove(src)
user.drop_from_inventory(manipulator, src)
playsound(src, 'sound/machines/click.ogg', 10,1)
mat_cost = initial(mat_cost) % (2*manipulator.rating)
mat_cost = initial(mat_cost) / (2*manipulator.rating)
user.visible_message("<span class='notice'>\The [user] slots \the [manipulator] into \the [src].</span>")
update_icon()
return
if(istype(thing, load_type))
loading = TRUE
if(is_type_in_list(thing, load_type))
var/obj/item/stack/material/M = thing
if(!M.material || M.material.name != ammo_material)
return
if(istype(M)) //stack
if(!M.material || M.material.name != ammo_material || loading)
return
if(mat_storage + 2000 > max_mat_storage)
to_chat(user, "<span class='warning'>\The [src] cannot hold more [ammo_material].</span>")
return
if(mat_storage + SHEET_MATERIAL_AMOUNT > max_mat_storage)
to_chat(user, "<span class='warning'>\The [src] cannot hold more [ammo_material].</span>")
return
var/can_hold_val = 0
while(can_hold_val < round(max_mat_storage / 2000))
if(mat_storage + 2000 <= max_mat_storage && do_after(user,1.5 SECONDS))
var/can_hold_val = 0
loading = TRUE
while(mat_storage + SHEET_MATERIAL_AMOUNT <= max_mat_storage && do_after(user,1.5 SECONDS))
can_hold_val ++
mat_storage += 2000
mat_storage += SHEET_MATERIAL_AMOUNT
playsound(src, 'sound/effects/phasein.ogg', 15, 1)
else
loading = FALSE
break
M.use(can_hold_val)
M.use(can_hold_val)
loading = FALSE
else //ore
if(M.material != ammo_material)
return
if(mat_storage + (SHEET_MATERIAL_AMOUNT/2*0.8) > max_mat_storage)
to_chat(user, "<span class='warning'>\The [src] cannot hold more [ammo_material].</span>")
return
qdel(M)
mat_storage += (SHEET_MATERIAL_AMOUNT/2*0.8) //two plasma ores needed per sheet, some inefficiency for not using refined product
user.visible_message("<span class='notice'>\The [user] loads \the [src] with \the [M].</span>")
playsound(src, 'sound/weapons/flipblade.ogg', 50, 1)
update_icon()
return
. = ..()
#define GEN_STARTING -1
#define GEN_OFF 0
#define GEN_IDLE 1
#define GEN_ACTIVE 2
/obj/item/weapon/gun/magnetic/matfed/phoronbore
name = "portable phoron bore"
desc = "A large man-portable tunnel bore, using phorogenic plasma blasts. Point away from user."
description_fluff = "An aging Grayson Manufactories mining tool used for rapidly digging through rock. Mass production was discontinued when many of the devices were stolen and used to break into a high security facility by Boiling Point drones."
description_antag = "This device is exceptional at breaking down walls, though it is incredibly loud when doing so."
description_info = "The projectile of this tool will travel six tiles before dissipating, excavating mineral walls as it does so. It can be reloaded with phoron sheets or ore, and has a togglable generator that can recharge the power cell using stored phoron."
icon_state = "bore"
item_state = "bore"
wielded_item_state = "bore-wielded"
one_handed_penalty = 5
projectile_type = /obj/item/projectile/bullet/magnetic/bore
gun_unreliable = 0
power_cost = 100
ammo_material = MAT_PHORON
action_button_name = "Toggle internal generator"
var/generator_state = GEN_OFF
var/datum/looping_sound/small_motor/soundloop
var/time_started //to keep the soundloop from being "stopped" too soon and playing indefinitely
/obj/item/weapon/gun/magnetic/matfed/phoronbore/Initialize()
. = ..()
soundloop = new(list(src), 0)
/obj/item/weapon/gun/magnetic/matfed/phoronbore/Destroy()
QDEL_NULL(soundloop)
. = ..()
/obj/item/weapon/gun/magnetic/matfed/phoronbore/ui_action_click()
toggle_generator(usr)
/obj/item/weapon/gun/magnetic/matfed/phoronbore/process()
if(generator_state && !mat_storage)
audible_message(SPAN_NOTICE("\The [src] goes quiet."),SPAN_NOTICE("A motor noise cuts out."))
soundloop.stop()
generator_state = GEN_OFF
else if(generator_state > GEN_OFF)
if(generator_state == GEN_IDLE && (cell?.percent() < 80 || (!cell && capacitor && capacitor.charge/capacitor.max_charge < 0.8)))
generator_state = GEN_ACTIVE
else if(generator_state == GEN_ACTIVE && (!cell || cell.fully_charged()) && (!capacitor || capacitor.charge == capacitor.max_charge))
generator_state = GEN_IDLE
soundloop.speed = generator_state
generator_generate()
if(capacitor)
if(cell)
if(capacitor.charge < capacitor.max_charge && cell.checked_use(power_per_tick))
capacitor.charge(power_per_tick)
else if(!generator_state)
capacitor.use(capacitor.charge * 0.05)
update_state()
/obj/item/weapon/gun/magnetic/matfed/phoronbore/proc/generator_generate()
var/fuel_used = generator_state == GEN_IDLE ? 5 : 25
var/power_made = fuel_used * 800 * CELLRATE //20kW when active, same power as a pacman on setting one, but less efficient because compact and portable
if(cell)
cell.give(power_made)
else if(capacitor)
capacitor.charge(power_made)
mat_storage = max(mat_storage - fuel_used, 0)
var/turf/T = get_turf(src)
if(T)
T.assume_gas("carbon_dioxide", fuel_used * 0.01, T0C+200)
/obj/item/weapon/gun/magnetic/matfed/phoronbore/proc/toggle_generator(mob/living/user)
if(!generator_state && !mat_storage)
to_chat(user, SPAN_NOTICE("\The [src] has no fuel!"))
return
else if(!generator_state)
generator_state = GEN_STARTING
var/pull = (!cell || cell.charge < 100) ? rand(1,4) : 0
while(pull)
playsound(src, 'sound/items/small_motor/motor_pull_attempt.ogg', 100)
if(!do_after(user, 2 SECONDS, src))
generator_state = GEN_OFF
return
pull--
soundloop.start()
time_started = world.time
cell?.use(100)
audible_message(SPAN_NOTICE("\The [src] starts chugging."),SPAN_NOTICE("A motor noise starts up."))
generator_state = GEN_IDLE
else if(generator_state > GEN_OFF && time_started + 3 SECONDS < world.time)
soundloop.stop()
audible_message(SPAN_NOTICE("\The [src] goes quiet."),SPAN_NOTICE("A motor noise cuts out."))
generator_state = GEN_OFF
/obj/item/weapon/gun/magnetic/matfed/phoronbore/loaded
cell = /obj/item/weapon/cell/apc
capacitor = /obj/item/weapon/stock_parts/capacitor

View File

@@ -17,7 +17,6 @@
var/obj/item/weapon/cell/cell // Currently installed powercell.
var/obj/item/weapon/stock_parts/capacitor/capacitor // Installed capacitor. Higher rating == faster charge between shots. Set to a path to spawn with one of that type.
var/obj/item/weapon/stock_parts/manipulator/manipulator // Installed manipulator. Mostly for Phoron Bore, higher rating == less mats consumed upon firing. Set to a path to spawn with one of that type.
var/removable_components = TRUE // Whether or not the gun can be dismantled.
var/gun_unreliable = 15 // Percentage chance of detonating in your hands.
@@ -38,16 +37,14 @@
if(ispath(capacitor))
capacitor = new capacitor(src)
capacitor.charge = capacitor.max_charge
if(ispath(manipulator))
manipulator = new manipulator(src)
if(ispath(loaded))
loaded = new loaded(src)
START_PROCESSING(SSobj, src)
if(capacitor)
power_per_tick = (power_cost*0.15) * capacitor.rating
update_icon()
/obj/item/weapon/gun/magnetic/Destroy()
@@ -55,7 +52,6 @@
QDEL_NULL(cell)
QDEL_NULL(loaded)
QDEL_NULL(capacitor)
QDEL_NULL(manipulator)
. = ..()
/obj/item/weapon/gun/magnetic/get_cell()
@@ -68,7 +64,7 @@
capacitor.charge(power_per_tick)
else
capacitor.use(capacitor.charge * 0.05)
update_state() // May update icon, only if things changed.
/obj/item/weapon/gun/magnetic/proc/update_state()
@@ -80,7 +76,7 @@
newstate |= ICON_CELL
if(capacitor)
newstate |= ICON_CAP
// Functional state
if(!cell || !capacitor)
newstate |= ICON_BAD
@@ -88,7 +84,7 @@
newstate |= ICON_CHARGE
else
newstate |= ICON_READY
// Ammo indicator
if(loaded)
newstate |= ICON_LOADED
@@ -99,7 +95,7 @@
needs_update = TRUE
state = newstate
if(needs_update)
update_icon()
@@ -153,8 +149,7 @@
to_chat(user, "<span class='warning'>\The [src] already has \a [cell] installed.</span>")
return
cell = thing
user.drop_from_inventory(cell)
cell.forceMove(src)
user.drop_from_inventory(cell, src)
playsound(src, 'sound/machines/click.ogg', 10, 1)
user.visible_message("<span class='notice'>\The [user] slots \the [cell] into \the [src].</span>")
update_icon()
@@ -164,10 +159,9 @@
if(!capacitor)
to_chat(user, "<span class='warning'>\The [src] has no capacitor installed.</span>")
return
capacitor.forceMove(get_turf(src))
user.put_in_hands(capacitor)
user.visible_message("<span class='notice'>\The [user] unscrews \the [capacitor] from \the [src].</span>")
playsound(src, 'sound/items/Screwdriver.ogg', 50, 1)
playsound(src, thing.usesound, 50, 1)
capacitor = null
update_icon()
return
@@ -177,8 +171,7 @@
to_chat(user, "<span class='warning'>\The [src] already has \a [capacitor] installed.</span>")
return
capacitor = thing
user.drop_from_inventory(capacitor)
capacitor.forceMove(src)
user.drop_from_inventory(capacitor, src)
playsound(src, 'sound/machines/click.ogg', 10, 1)
power_per_tick = (power_cost*0.15) * capacitor.rating
user.visible_message("<span class='notice'>\The [user] slots \the [capacitor] into \the [src].</span>")

View File

@@ -162,6 +162,9 @@
irradiate = 20
range = 6
/obj/item/projectile/bullet/magnetic/bore/get_structure_damage()
return damage * 3 //made for boring holes
/obj/item/projectile/bullet/magnetic/bore/Bump(atom/A, forced=0)
if(istype(A, /turf/simulated/mineral))
var/turf/simulated/mineral/MI = A
@@ -171,7 +174,6 @@
return 0
else if(istype(A, /turf/simulated/wall) || istype(A, /turf/simulated/shuttle/wall)) // Cause a loud, but relatively minor explosion on the wall it hits.
explosion(A, -1, -1, 1, 3)
qdel(src)
return 1
return ..()
else
..()