mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-27 18:41:59 +00:00
Reorganizes launcher source files
This commit is contained in:
262
code/modules/projectiles/guns/launcher/crossbow.dm
Normal file
262
code/modules/projectiles/guns/launcher/crossbow.dm
Normal file
@@ -0,0 +1,262 @@
|
||||
//AMMUNITION
|
||||
|
||||
/obj/item/weapon/arrow
|
||||
name = "bolt"
|
||||
desc = "It's got a tip for you - get the point?"
|
||||
icon = 'icons/obj/weapons.dmi'
|
||||
icon_state = "bolt"
|
||||
item_state = "bolt"
|
||||
throwforce = 8
|
||||
w_class = 3.0
|
||||
sharp = 1
|
||||
edge = 0
|
||||
|
||||
/obj/item/weapon/arrow/proc/removed() //Helper for metal rods falling apart.
|
||||
return
|
||||
|
||||
/obj/item/weapon/spike
|
||||
name = "alloy spike"
|
||||
desc = "It's about a foot of weird silver metal with a wicked point."
|
||||
sharp = 1
|
||||
edge = 0
|
||||
throwforce = 5
|
||||
w_class = 2
|
||||
icon = 'icons/obj/weapons.dmi'
|
||||
icon_state = "metal-rod"
|
||||
item_state = "bolt"
|
||||
|
||||
/obj/item/weapon/arrow/quill
|
||||
name = "vox quill"
|
||||
desc = "A wickedly barbed quill from some bizarre animal."
|
||||
icon = 'icons/obj/weapons.dmi'
|
||||
icon_state = "quill"
|
||||
item_state = "quill"
|
||||
throwforce = 5
|
||||
|
||||
/obj/item/weapon/arrow/rod
|
||||
name = "metal rod"
|
||||
desc = "Don't cry for me, Orithena."
|
||||
icon_state = "metal-rod"
|
||||
|
||||
/obj/item/weapon/arrow/rod/removed(mob/user)
|
||||
if(throwforce == 15) // The rod has been superheated - we don't want it to be useable when removed from the bow.
|
||||
user << "[src] shatters into a scattering of overstressed metal shards as it leaves the crossbow."
|
||||
var/obj/item/weapon/shard/shrapnel/S = new()
|
||||
S.loc = get_turf(src)
|
||||
src.Del()
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow
|
||||
name = "powered crossbow"
|
||||
desc = "A 2557AD twist on an old classic. Pick up that can."
|
||||
icon_state = "crossbow"
|
||||
item_state = "crossbow-solid"
|
||||
fire_sound = 'sound/weapons/punchmiss.ogg' // TODO: Decent THWOK noise.
|
||||
fire_sound_text = "a solid thunk"
|
||||
fire_delay = 25
|
||||
slot_flags = SLOT_BACK
|
||||
|
||||
var/obj/item/bolt
|
||||
var/tension = 0 // Current draw on the bow.
|
||||
var/max_tension = 5 // Highest possible tension.
|
||||
var/release_speed = 5 // Speed per unit of tension.
|
||||
var/obj/item/weapon/cell/cell = null // Used for firing superheated rods.
|
||||
var/current_user // Used to check if the crossbow has changed hands since being drawn.
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/update_release_force()
|
||||
release_force = tension*release_speed
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/consume_next_projectile(mob/user=null)
|
||||
if(tension <= 0)
|
||||
user << "\red \The [src] is not drawn back!"
|
||||
return null
|
||||
return bolt
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/handle_post_fire(mob/user, atom/target)
|
||||
bolt = null
|
||||
icon_state = "crossbow"
|
||||
tension = 0
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/attack_self(mob/living/user as mob)
|
||||
if(tension)
|
||||
if(bolt)
|
||||
user.visible_message("[user] relaxes the tension on [src]'s string and removes [bolt].","You relax the tension on [src]'s string and remove [bolt].")
|
||||
bolt.loc = get_turf(src)
|
||||
var/obj/item/weapon/arrow/A = bolt
|
||||
bolt = null
|
||||
A.removed(user)
|
||||
else
|
||||
user.visible_message("[user] relaxes the tension on [src]'s string.","You relax the tension on [src]'s string.")
|
||||
tension = 0
|
||||
icon_state = "crossbow"
|
||||
else
|
||||
draw(user)
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/proc/draw(var/mob/user as mob)
|
||||
|
||||
if(!bolt)
|
||||
user << "You don't have anything nocked to [src]."
|
||||
return
|
||||
|
||||
if(user.restrained())
|
||||
return
|
||||
|
||||
current_user = user
|
||||
user.visible_message("[user] begins to draw back the string of [src].","<span class='notice'>You begin to draw back the string of [src].</span>")
|
||||
tension = 1
|
||||
|
||||
while(bolt && tension && current_user == user)
|
||||
if(!do_after(user, 25)) //crossbow strings don't just magically pull back on their own.
|
||||
user.visible_message("[usr] stops drawing and relaxes the string of [src].","<span class='warning'>You stop drawing back and relax the string of [src].</span>")
|
||||
tension = 0
|
||||
icon_state = "crossbow"
|
||||
return
|
||||
|
||||
tension++
|
||||
icon_state = "crossbow-drawn"
|
||||
|
||||
if(tension >= max_tension)
|
||||
tension = max_tension
|
||||
usr << "[src] clunks as you draw the string to its maximum tension!"
|
||||
return
|
||||
|
||||
user.visible_message("[usr] draws back the string of [src]!","<span class='notice'>You continue drawing back the string of [src]!</span>")
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/proc/increase_tension(var/mob/user as mob)
|
||||
|
||||
if(!bolt || !tension || current_user != user) //Arrow has been fired, bow has been relaxed or user has changed.
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if(!bolt)
|
||||
if (istype(W,/obj/item/weapon/arrow))
|
||||
user.drop_item()
|
||||
bolt = W
|
||||
bolt.loc = src
|
||||
user.visible_message("[user] slides [bolt] into [src].","You slide [bolt] into [src].")
|
||||
icon_state = "crossbow-nocked"
|
||||
return
|
||||
else if(istype(W,/obj/item/stack/rods))
|
||||
var/obj/item/stack/rods/R = W
|
||||
if (R.use(1))
|
||||
bolt = new /obj/item/weapon/arrow/rod(src)
|
||||
bolt.fingerprintslast = src.fingerprintslast
|
||||
bolt.loc = src
|
||||
icon_state = "crossbow-nocked"
|
||||
user.visible_message("[user] jams [bolt] into [src].","You jam [bolt] into [src].")
|
||||
superheat_rod(user)
|
||||
return
|
||||
|
||||
if(istype(W, /obj/item/weapon/cell))
|
||||
if(!cell)
|
||||
user.drop_item()
|
||||
cell = W
|
||||
cell.loc = src
|
||||
user << "<span class='notice'>You jam [cell] into [src] and wire it to the firing coil.</span>"
|
||||
superheat_rod(user)
|
||||
else
|
||||
user << "<span class='notice'>[src] already has a cell installed.</span>"
|
||||
|
||||
else if(istype(W, /obj/item/weapon/screwdriver))
|
||||
if(cell)
|
||||
var/obj/item/C = cell
|
||||
C.loc = get_turf(user)
|
||||
user << "<span class='notice'>You jimmy [cell] out of [src] with [W].</span>"
|
||||
cell = null
|
||||
else
|
||||
user << "<span class='notice'>[src] doesn't have a cell installed.</span>"
|
||||
|
||||
else
|
||||
..()
|
||||
|
||||
/obj/item/weapon/gun/launcher/crossbow/proc/superheat_rod(var/mob/user)
|
||||
if(!user || !cell || !bolt) return
|
||||
if(cell.charge < 500) return
|
||||
if(bolt.throwforce >= 15) return
|
||||
if(!istype(bolt,/obj/item/weapon/arrow/rod)) return
|
||||
|
||||
user << "<span class='notice'>[bolt] plinks and crackles as it begins to glow red-hot.</span>"
|
||||
bolt.throwforce = 15
|
||||
bolt.icon_state = "metal-rod-superheated"
|
||||
cell.use(500)
|
||||
|
||||
|
||||
// Crossbow construction.
|
||||
/obj/item/weapon/crossbowframe
|
||||
name = "crossbow frame"
|
||||
desc = "A half-finished crossbow."
|
||||
icon_state = "crossbowframe0"
|
||||
item_state = "crossbow-solid"
|
||||
|
||||
var/buildstate = 0
|
||||
|
||||
/obj/item/weapon/crossbowframe/update_icon()
|
||||
icon_state = "crossbowframe[buildstate]"
|
||||
|
||||
/obj/item/weapon/crossbowframe/examine(mob/user)
|
||||
..(user)
|
||||
switch(buildstate)
|
||||
if(1) user << "It has a loose rod frame in place."
|
||||
if(2) user << "It has a steel backbone welded in place."
|
||||
if(3) user << "It has a steel backbone and a cell mount installed."
|
||||
if(4) user << "It has a steel backbone, plastic lath and a cell mount installed."
|
||||
if(5) user << "It has a steel cable loosely strung across the lath."
|
||||
|
||||
/obj/item/weapon/crossbowframe/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if(istype(W,/obj/item/stack/rods))
|
||||
if(buildstate == 0)
|
||||
var/obj/item/stack/rods/R = W
|
||||
if(R.use(3))
|
||||
user << "\blue You assemble a backbone of rods around the wooden stock."
|
||||
buildstate++
|
||||
update_icon()
|
||||
else
|
||||
user << "\blue You need at least three rods to complete this task."
|
||||
return
|
||||
else if(istype(W,/obj/item/weapon/weldingtool))
|
||||
if(buildstate == 1)
|
||||
var/obj/item/weapon/weldingtool/T = W
|
||||
if(T.remove_fuel(0,user))
|
||||
if(!src || !T.isOn()) return
|
||||
playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1)
|
||||
user << "\blue You weld the rods into place."
|
||||
buildstate++
|
||||
update_icon()
|
||||
return
|
||||
else if(istype(W,/obj/item/stack/cable_coil))
|
||||
var/obj/item/stack/cable_coil/C = W
|
||||
if(buildstate == 2)
|
||||
if(C.use(5))
|
||||
user << "\blue You wire a crude cell mount into the top of the crossbow."
|
||||
buildstate++
|
||||
update_icon()
|
||||
else
|
||||
user << "\blue You need at least five segments of cable coil to complete this task."
|
||||
return
|
||||
else if(buildstate == 4)
|
||||
if(C.use(5))
|
||||
user << "\blue You string a steel cable across the crossbow's lath."
|
||||
buildstate++
|
||||
update_icon()
|
||||
else
|
||||
user << "\blue You need at least five segments of cable coil to complete this task."
|
||||
return
|
||||
else if(istype(W,/obj/item/stack/sheet/mineral/plastic))
|
||||
if(buildstate == 3)
|
||||
var/obj/item/stack/sheet/mineral/plastic/P = W
|
||||
if(P.use(3))
|
||||
user << "\blue You assemble and install a heavy plastic lath onto the crossbow."
|
||||
buildstate++
|
||||
update_icon()
|
||||
else
|
||||
user << "\blue You need at least three plastic sheets to complete this task."
|
||||
return
|
||||
else if(istype(W,/obj/item/weapon/screwdriver))
|
||||
if(buildstate == 5)
|
||||
user << "\blue You secure the crossbow's various parts."
|
||||
new /obj/item/weapon/gun/launcher/crossbow(get_turf(src))
|
||||
del(src)
|
||||
return
|
||||
else
|
||||
..()
|
||||
204
code/modules/projectiles/guns/launcher/pneumatic.dm
Normal file
204
code/modules/projectiles/guns/launcher/pneumatic.dm
Normal file
@@ -0,0 +1,204 @@
|
||||
/obj/item/weapon/gun/launcher/pneumatic
|
||||
name = "pneumatic cannon"
|
||||
desc = "A large gas-powered cannon."
|
||||
icon = 'icons/obj/gun.dmi'
|
||||
icon_state = "pneumatic"
|
||||
item_state = "pneumatic"
|
||||
slot_flags = SLOT_BELT
|
||||
w_class = 5.0
|
||||
flags = CONDUCT
|
||||
fire_sound_text = "a loud whoosh of moving air"
|
||||
fire_delay = 50
|
||||
fire_sound = 'sound/weapons/tablehit1.ogg'
|
||||
|
||||
var/fire_pressure // Used in fire checks/pressure checks.
|
||||
var/max_w_class = 3 // Hopper intake size.
|
||||
var/max_combined_w_class = 20 // Total internal storage size.
|
||||
var/obj/item/weapon/tank/tank = null // Tank of gas for use in firing the cannon.
|
||||
var/obj/item/weapon/storage/tank_container // Something to hold the tank item so we don't accidentally fire it.
|
||||
var/pressure_setting = 10 // Percentage of the gas in the tank used to fire the projectile.
|
||||
var/possible_pressure_amounts = list(5,10,20,25,50) // Possible pressure settings.
|
||||
var/minimum_tank_pressure = 10 // Minimum pressure to fire the gun.
|
||||
var/force_divisor = 400 // Force equates to speed. Speed/5 equates to a damage multiplier for whoever you hit.
|
||||
// For reference, a fully pressurized oxy tank at 50% gas release firing a health
|
||||
// analyzer with a force_divisor of 10 hit with a damage multiplier of 3000+.
|
||||
/obj/item/weapon/gun/launcher/pneumatic/New()
|
||||
..()
|
||||
tank_container = new(src)
|
||||
tank_container.tag = "gas_tank_holder"
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/verb/set_pressure() //set amount of tank pressure.
|
||||
set name = "Set Valve Pressure"
|
||||
set category = "Object"
|
||||
set src in range(0)
|
||||
var/N = input("Percentage of tank used per shot:","[src]") as null|anything in possible_pressure_amounts
|
||||
if (N)
|
||||
pressure_setting = N
|
||||
usr << "You dial the pressure valve to [pressure_setting]%."
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/verb/eject_tank() //Remove the tank.
|
||||
set name = "Eject Tank"
|
||||
set category = "Object"
|
||||
set src in range(0)
|
||||
|
||||
if(tank)
|
||||
usr << "You twist the valve and pop the tank out of [src]."
|
||||
tank.loc = usr.loc
|
||||
tank = null
|
||||
icon_state = "pneumatic"
|
||||
item_state = "pneumatic"
|
||||
if (ismob(src.loc))
|
||||
var/mob/M = src.loc
|
||||
M.update_icons()
|
||||
else
|
||||
usr << "There's no tank in [src]."
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if(!tank && istype(W,/obj/item/weapon/tank))
|
||||
user.drop_item()
|
||||
tank = W
|
||||
tank.loc = src.tank_container
|
||||
user.visible_message("[user] jams [W] into [src]'s valve and twists it closed.","You jam [W] into [src]'s valve and twist it closed.")
|
||||
icon_state = "pneumatic-tank"
|
||||
item_state = "pneumatic-tank"
|
||||
user.update_icons()
|
||||
else if(W.w_class <= max_w_class)
|
||||
var/total_stored = 0
|
||||
for(var/obj/item/O in src.contents)
|
||||
total_stored += O.w_class
|
||||
if(total_stored + W.w_class <= max_combined_w_class)
|
||||
user.drop_item(W)
|
||||
W.loc = src
|
||||
user << "You shove [W] into the hopper."
|
||||
else
|
||||
user << "That won't fit into the hopper - it's full."
|
||||
return
|
||||
else
|
||||
user << "That won't fit into the hopper."
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/attack_self(mob/user as mob)
|
||||
if(contents.len > 0)
|
||||
var/obj/item/removing = contents[contents.len]
|
||||
removing.loc = get_turf(src)
|
||||
user.put_in_hands(removing)
|
||||
user << "You remove [removing] from the hopper."
|
||||
else
|
||||
user << "There is nothing to remove in \the [src]."
|
||||
return
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/consume_next_projectile(mob/user=null)
|
||||
if(!contents.len)
|
||||
return null
|
||||
if (!tank)
|
||||
user << "There is no gas tank in [src]!"
|
||||
return null
|
||||
|
||||
var/fire_pressure = (tank.air_contents.return_pressure()/100)*pressure_setting
|
||||
if(fire_pressure < minimum_tank_pressure)
|
||||
user << "There isn't enough gas in the tank to fire [src]."
|
||||
return null
|
||||
|
||||
return contents[1]
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/examine(mob/user)
|
||||
if(!..(user, 2))
|
||||
return
|
||||
user << "The valve is dialed to [pressure_setting]%."
|
||||
if(tank)
|
||||
user << "The tank dial reads [tank.air_contents.return_pressure()] kPa."
|
||||
else
|
||||
user << "Nothing is attached to the tank valve!"
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/update_release_force(obj/item/projectile)
|
||||
if(tank)
|
||||
release_force = ((fire_pressure*tank.volume)/projectile.w_class)/force_divisor //projectile speed.
|
||||
if(release_force > 80) release_force = 80 //damage cap.
|
||||
else
|
||||
release_force = 0
|
||||
|
||||
/obj/item/weapon/gun/launcher/pneumatic/handle_post_fire()
|
||||
if(tank)
|
||||
var/lost_gas_amount = tank.air_contents.total_moles*(pressure_setting/100)
|
||||
var/datum/gas_mixture/removed = tank.air_contents.remove(lost_gas_amount)
|
||||
|
||||
var/turf/T = get_turf(src.loc)
|
||||
if(T) T.assume_air(removed)
|
||||
..()
|
||||
|
||||
//Constructable pneumatic cannon.
|
||||
|
||||
/obj/item/weapon/cannonframe
|
||||
name = "pneumatic cannon frame"
|
||||
desc = "A half-finished pneumatic cannon."
|
||||
icon_state = "pneumatic0"
|
||||
item_state = "pneumatic"
|
||||
|
||||
var/buildstate = 0
|
||||
|
||||
/obj/item/weapon/cannonframe/update_icon()
|
||||
icon_state = "pneumatic[buildstate]"
|
||||
|
||||
/obj/item/weapon/cannonframe/examine(mob/user)
|
||||
..(user)
|
||||
switch(buildstate)
|
||||
if(1) user << "It has a pipe segment installed."
|
||||
if(2) user << "It has a pipe segment welded in place."
|
||||
if(3) user << "It has an outer chassis installed."
|
||||
if(4) user << "It has an outer chassis welded in place."
|
||||
if(5) user << "It has a transfer valve installed."
|
||||
|
||||
/obj/item/weapon/cannonframe/attackby(obj/item/W as obj, mob/user as mob)
|
||||
if(istype(W,/obj/item/pipe))
|
||||
if(buildstate == 0)
|
||||
user.drop_item()
|
||||
del(W)
|
||||
user << "\blue You secure the piping inside the frame."
|
||||
buildstate++
|
||||
update_icon()
|
||||
return
|
||||
else if(istype(W,/obj/item/stack/sheet/metal))
|
||||
if(buildstate == 2)
|
||||
var/obj/item/stack/sheet/metal/M = W
|
||||
if(M.use(5))
|
||||
user << "\blue You assemble a chassis around the cannon frame."
|
||||
buildstate++
|
||||
update_icon()
|
||||
else
|
||||
user << "\blue You need at least five metal sheets to complete this task."
|
||||
return
|
||||
else if(istype(W,/obj/item/device/transfer_valve))
|
||||
if(buildstate == 4)
|
||||
user.drop_item()
|
||||
del(W)
|
||||
user << "\blue You install the transfer valve and connect it to the piping."
|
||||
buildstate++
|
||||
update_icon()
|
||||
return
|
||||
else if(istype(W,/obj/item/weapon/weldingtool))
|
||||
if(buildstate == 1)
|
||||
var/obj/item/weapon/weldingtool/T = W
|
||||
if(T.remove_fuel(0,user))
|
||||
if(!src || !T.isOn()) return
|
||||
playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1)
|
||||
user << "\blue You weld the pipe into place."
|
||||
buildstate++
|
||||
update_icon()
|
||||
if(buildstate == 3)
|
||||
var/obj/item/weapon/weldingtool/T = W
|
||||
if(T.remove_fuel(0,user))
|
||||
if(!src || !T.isOn()) return
|
||||
playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1)
|
||||
user << "\blue You weld the metal chassis together."
|
||||
buildstate++
|
||||
update_icon()
|
||||
if(buildstate == 5)
|
||||
var/obj/item/weapon/weldingtool/T = W
|
||||
if(T.remove_fuel(0,user))
|
||||
if(!src || !T.isOn()) return
|
||||
playsound(src.loc, 'sound/items/Welder2.ogg', 100, 1)
|
||||
user << "\blue You weld the valve into place."
|
||||
new /obj/item/weapon/gun/launcher/pneumatic(get_turf(src))
|
||||
del(src)
|
||||
return
|
||||
else
|
||||
..()
|
||||
48
code/modules/projectiles/guns/launcher/rocket.dm
Normal file
48
code/modules/projectiles/guns/launcher/rocket.dm
Normal file
@@ -0,0 +1,48 @@
|
||||
/obj/item/weapon/gun/launcher/rocket
|
||||
name = "rocket launcher"
|
||||
desc = "MAGGOT."
|
||||
icon_state = "rocket"
|
||||
item_state = "rocket"
|
||||
w_class = 4.0
|
||||
throw_speed = 2
|
||||
throw_range = 10
|
||||
force = 5.0
|
||||
flags = CONDUCT | USEDELAY
|
||||
slot_flags = 0
|
||||
origin_tech = "combat=8;materials=5"
|
||||
fire_sound = 'sound/effects/bang.ogg'
|
||||
|
||||
release_force = 15
|
||||
throw_distance = 30
|
||||
var/max_rockets = 1
|
||||
var/list/rockets = new/list()
|
||||
|
||||
/obj/item/weapon/gun/launcher/rocket/examine(mob/user)
|
||||
if(!..(user, 2))
|
||||
return
|
||||
user << "\blue [rockets.len] / [max_rockets] rockets."
|
||||
|
||||
/obj/item/weapon/gun/launcher/rocket/attackby(obj/item/I as obj, mob/user as mob)
|
||||
if(istype(I, /obj/item/ammo_casing/rocket))
|
||||
if(rockets.len < max_rockets)
|
||||
user.drop_item()
|
||||
I.loc = src
|
||||
rockets += I
|
||||
user << "\blue You put the rocket in [src]."
|
||||
user << "\blue [rockets.len] / [max_rockets] rockets."
|
||||
else
|
||||
usr << "\red [src] cannot hold more rockets."
|
||||
|
||||
/obj/item/weapon/gun/launcher/rocket/consume_next_projectile()
|
||||
if(rockets.len)
|
||||
var/obj/item/ammo_casing/rocket/I = rockets[1]
|
||||
var/obj/item/missile/M = new (src)
|
||||
M.primed = 1
|
||||
rockets -= I
|
||||
return M
|
||||
return null
|
||||
|
||||
/obj/item/weapon/gun/launcher/rocket/handle_post_fire(mob/user, atom/target)
|
||||
message_admins("[key_name_admin(user)] fired a rocket from a rocket launcher ([src.name]) at [target].")
|
||||
log_game("[key_name_admin(user)] used a rocket launcher ([src.name]) at [target].")
|
||||
..()
|
||||
Reference in New Issue
Block a user