Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds a new salvager weapon: The Makeshift Laser Rifle #15856

Merged
merged 70 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
5304a2b
adds basic laser gun and heat system
unfunnyperson Sep 3, 2023
32ea09b
:waa:
unfunnyperson Sep 4, 2023
0e02a01
adds construction
unfunnyperson Sep 4, 2023
3c31ba2
wrong battery desc
unfunnyperson Sep 4, 2023
a66a1c7
breaks instead of exploding
unfunnyperson Sep 5, 2023
c0e63f5
uses big cells as ammo now
unfunnyperson Sep 8, 2023
c44a4af
what if it was FULL-AUTO???
unfunnyperson Sep 8, 2023
42b6038
increase heat drain, increase heat on fire
unfunnyperson Sep 8, 2023
d596b22
simplify construction
unfunnyperson Sep 9, 2023
48c590c
gah
unfunnyperson Sep 9, 2023
70e5993
small laser
unfunnyperson Sep 9, 2023
5fbfcf5
first sprite, use light tubes
unfunnyperson Sep 10, 2023
5dc37c3
select firerate and increase heat drain/gain
unfunnyperson Sep 10, 2023
e427ea4
scream
unfunnyperson Sep 10, 2023
6b85ea5
improved sprites
unfunnyperson Sep 12, 2023
ee94289
aaa
unfunnyperson Sep 12, 2023
efacbd2
what if there was an ITEM STATE!!
unfunnyperson Sep 13, 2023
6b811d4
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 14, 2023
e3af276
use construction component
unfunnyperson Sep 15, 2023
f9ccdcd
adds smoke particle when at high heat
unfunnyperson Sep 16, 2023
16a4371
back sprites
unfunnyperson Sep 16, 2023
98e80aa
final touches
unfunnyperson Sep 16, 2023
45851ce
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 16, 2023
d8a778e
TRUE/FALSE defines
unfunnyperson Sep 16, 2023
dc76439
updates
unfunnyperson Sep 17, 2023
496c774
aa
unfunnyperson Sep 17, 2023
658ef21
help messages
unfunnyperson Sep 17, 2023
a726e5b
change message
unfunnyperson Sep 17, 2023
592a10c
adjustment
unfunnyperson Sep 17, 2023
165da36
massively reduce wire req
unfunnyperson Sep 17, 2023
fc931ac
Replaces glass sheet step with lens step
unfunnyperson Sep 17, 2023
e811666
potato
unfunnyperson Sep 18, 2023
ba90eae
code improvements + minor sprite update
unfunnyperson Sep 18, 2023
f2c8d04
matsci lenses work
unfunnyperson Sep 19, 2023
b404b04
thing
unfunnyperson Sep 20, 2023
93eb774
increase very powerful laser cost
unfunnyperson Sep 20, 2023
cad42f5
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 20, 2023
3628b2a
fix
unfunnyperson Sep 20, 2023
4dd081b
heat decays slightly slower
unfunnyperson Sep 20, 2023
07ae5b4
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 23, 2023
e99dcb5
actually no that was fine
unfunnyperson Sep 23, 2023
f626fcd
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 23, 2023
5fffbe7
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 25, 2023
f9f07f9
salv lens is a subtype now + minor heat change
unfunnyperson Sep 26, 2023
9d3e6f7
fix stray pixel + minor burn sprite change
unfunnyperson Sep 27, 2023
822eeb4
material name adjustment
unfunnyperson Sep 27, 2023
8ca5530
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Sep 29, 2023
22dce0f
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Oct 2, 2023
2d53868
fix
unfunnyperson Oct 3, 2023
8fea52e
gah
unfunnyperson Oct 3, 2023
508e8e2
up base projectile cost, powerful laser changed
unfunnyperson Oct 4, 2023
6b3e2c6
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Oct 7, 2023
46de751
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Oct 8, 2023
9301845
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Oct 19, 2023
a7a94b9
fix
unfunnyperson Oct 19, 2023
cce801b
fix 2
unfunnyperson Oct 19, 2023
52db141
remove update_proj()
unfunnyperson Oct 25, 2023
f37ab74
remove construction + minor adjustments
unfunnyperson Oct 26, 2023
3f9d3c4
whoops
unfunnyperson Oct 26, 2023
38c9bde
whoops 2
unfunnyperson Oct 26, 2023
d5c3925
fix
unfunnyperson Oct 26, 2023
aa98b85
adjustments
unfunnyperson Oct 27, 2023
4856692
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Nov 11, 2023
31ec600
span change
unfunnyperson Nov 11, 2023
357b9e1
changes
unfunnyperson Dec 1, 2023
5e5a925
changes
unfunnyperson Dec 3, 2023
8a77a7b
colored lasers!!
unfunnyperson Dec 7, 2023
b6301f0
Merge branch 'master' into makeshift-laser-guns
unfunnyperson Dec 21, 2023
106659f
Merge remote-tracking branch 'upstream/master' into pr/unfunnyperson/…
Azrun Dec 22, 2023
a7a3511
Expanding possible usage...
Azrun Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/datums/components/power_cell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ TYPEINFO(/datum/component/power_cell)
RegisterSignal(parent, COMSIG_CELL_IS_CELL, PROC_REF(is_cell))
RegisterSignal(parent, COMSIG_ITEM_PROCESS, PROC_REF(process))

/datum/component/power_cell/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ATTACKBY)
UnregisterSignal(parent, COMSIG_CELL_CHARGE)
UnregisterSignal(parent, COMSIG_CELL_CAN_CHARGE)
UnregisterSignal(parent, COMSIG_CELL_USE)
UnregisterSignal(parent, COMSIG_CELL_CHECK_CHARGE)
UnregisterSignal(parent, COMSIG_CELL_IS_CELL)
UnregisterSignal(parent, COMSIG_ITEM_PROCESS)
. = ..()

/datum/component/power_cell/InheritComponent(datum/component/power_cell/C, i_am_original, max, start_charge, recharge, delay, rechargable)
if(C)
Expand Down
10 changes: 10 additions & 0 deletions code/modules/projectiles/laser.dm
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,13 @@ toxic - poisons
hit.delStatus("cornicened2")
else
hit.setStatus("cornicened")

/datum/projectile/laser/makeshift
cost = 1250
shot_sound = 'sound/weapons/laserlight.ogg'
icon_state = "laser_tiny"
damage = 20
/// lower bounds of heat added to the makeshift laser rifle this was fired from
var/heat_low = 10
/// higher bounds of heat added to the makeshift laser rifle this was fired from
var/heat_high = 12
267 changes: 267 additions & 0 deletions code/obj/item/gun/energy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1839,3 +1839,270 @@ TYPEINFO(/obj/item/gun/energy/wasp)
set_current_projectile(new/datum/projectile/energy_bolt/dazzler)
projectiles = list(current_projectile)
..()

// Makeshift Laser Rifle
#define HEAT_REMOVED_PER_PROCESS 30
#define FIRE_THRESHOLD 125
TYPEINFO(/obj/item/gun/energy/makeshift)
mats = 0

/obj/item/gun/energy/makeshift
name = "makeshift laser rifle"
icon = 'icons/obj/items/guns/energy64x32.dmi'
wear_image_icon = 'icons/mob/clothing/back.dmi'
icon_state = "makeshift-energy"
item_state = "makeshift_laser"
wear_state = "makeshift_laser"
c_flags = ONBACK
cell_type = null
can_swap_cell = FALSE
rechargeable = FALSE
force = 7
two_handed = TRUE
can_dual_wield = FALSE
desc = "A laser rifle cobbled together from various appliances, Prone to overheating."
muzzle_flash = "muzzle_flash_phaser"
charge_icon_state = "laser"
spread_angle = 10
shoot_delay = 5 DECI SECONDS
///What light source we use for the rifle
var/obj/item/light/tube/our_light
///What battery this gun uses
var/obj/item/cell/our_cell
///How much heat this weapon has after firing, the weapon breaks if this gets too high
var/heat = 0
///What step of repair are we on if we have broken? 0 = functional
var/heat_repair = 0

proc/attach_cell(var/obj/item/cell/C, mob/user)
if (user)
user.u_equip(C)
our_cell = C
our_cell.set_loc(src)
our_cell.AddComponent(/datum/component/power_cell, our_cell.maxcharge, our_cell.charge, our_cell.genrate, 0, FALSE)
SEND_SIGNAL(src, COMSIG_CELL_SWAP, our_cell)
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved

proc/attach_light(var/obj/item/light/tube/T, mob/user)
if (user)
user.u_equip(T)
our_light = T
our_light.set_loc(src)
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved

proc/do_explode()
explosion(src, get_turf(src), -1, -1, 1, 2)
qdel(src)

proc/finish_repairs(var/obj/item/cable_coil/C, /var/mob/user)
C.change_stack_amount(-10)
heat_repair = 0
playsound(src, 'sound/effects/pop.ogg', 50, TRUE)
src.icon_state = "makeshift-energy"
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved

proc/add_heat(var/heat_to_add, var/mob/user)
heat += heat_to_add
if (heat >= FIRE_THRESHOLD)
if (user)
boutput(user,SPAN_ALERT("[src] bursts into flame!"))
if (our_cell)
our_cell.use(our_cell.charge)
SEND_SIGNAL(src, COMSIG_CELL_USE, INFINITY)
elecflash(get_turf(src), 1, 3)
our_light.light_status = LIGHT_BURNED
our_light.update()
heat_repair = 1
src.icon_state = "makeshift-burnt-1"
heat += FIRE_THRESHOLD // spicy!
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved


emp_act()
if (our_cell)
src.visible_message(SPAN_ALERT("[src]'s cell violently overheats!"))
src.add_heat(FIRE_THRESHOLD)

New()
processing_items |= src
set_current_projectile(new/datum/projectile/laser/makeshift)
projectiles = list(current_projectile)
..()

Exited(Obj, newloc)
var/obj/item/cell/C = Obj
if (istype(C) && !QDELETED(C))
C.update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
var/datum/component/power_cell/comp = C.GetComponent(/datum/component/power_cell)
comp.UnregisterFromParent()
comp.RemoveComponent()
our_cell = null
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
. = ..()


process()
if (heat > 0)
if (heat > FIRE_THRESHOLD)
var/mob/living/victim = src.loc
if (istype(victim))
victim.changeStatus("burning", 7 SECONDS)
if (!ON_COOLDOWN(victim, "makeshift_burn", 5 SECONDS))
boutput(victim, SPAN_ALERT("You are set on fire due to the extreme temperature of [src]!"))
victim.emote("scream")
heat = max(0, heat - HEAT_REMOVED_PER_PROCESS)
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
return

canshoot(mob/user)
if (heat_repair != 0)
boutput(user,SPAN_ALERT("[src] will need repairs before being able to function!"))
return FALSE
if (!our_light)
boutput(user,SPAN_ALERT("[src] needs a light source to function!"))
return FALSE
else if (our_light.light_status != LIGHT_OK)
boutput(user,SPAN_ALERT("[src] has no reaction when you pull the trigger!"))
return FALSE
else
return ..()

attackby(obj/item/W, mob/user, params)
if (heat < FIRE_THRESHOLD)
if(heat_repair) // gun machine broke, we need to repair it
if (issnippingtool(W) && heat_repair == 1)
boutput(user,SPAN_NOTICE("You remove the burnt wiring from [src]."))
playsound(src, 'sound/items/Wirecutter.ogg', 50, TRUE)
heat_repair++
src.icon_state = "makeshift-burnt-2"
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
return
else if (istype(W, /obj/item/cable_coil) && heat_repair == 2)
if (W.amount >= 10)
SETUP_GENERIC_ACTIONBAR(user, src, 3 SECONDS, /obj/item/gun/energy/makeshift/proc/finish_repairs,\
list(W,user), W.icon, W.icon_state, SPAN_NOTICE("[user] replaces the burnt wiring within [src]."), null)
else
boutput(user,SPAN_NOTICE("You need at least 10 wire to repair the wiring."))
return
else if (iswrenchingtool(W) && our_cell)
var/obj/item/removed_cell = our_cell
SEND_SIGNAL(src, COMSIG_CELL_SWAP, null)
boutput(user,SPAN_NOTICE("You disconnect [our_cell] from [src]."))
playsound(src, 'sound/items/Ratchet.ogg', 50, TRUE)
user.put_in_hand_or_drop(removed_cell)
return
else if (istype(W, /obj/item/cell) && !our_cell)
user.u_equip(W)
boutput(user,SPAN_NOTICE("You attach [W] to [src]."))
attach_cell(W, user)
return
else if (issnippingtool(W) && our_light)
boutput(user,SPAN_NOTICE("You remove [our_light] from the barrel."))
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
playsound(src, 'sound/items/Wirecutter.ogg', 50, TRUE)
user.put_in_hand_or_drop(our_light)
our_light = null
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
return
else if (istype(W, /obj/item/light/tube) && !our_light)
boutput(user,SPAN_NOTICE("You place [W] inside of the barrel and redo the wiring."))
playsound(src, 'sound/effects/pop.ogg', 50, TRUE)
attach_light(W, user)
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
return
..()
else
boutput(user,SPAN_NOTICE("Attempting to work on [src] while its on fire might be a bad idea..."))
return

get_desc()
. = ..()
if (!heat_repair)
if (!our_cell)
. += SPAN_ALERT("<b> [src] is lacking a power source!</b>")
if (!our_light)
. += SPAN_ALERT("<b> [src] is lacking a light source!</b>")
else if(our_light.light_status != LIGHT_OK)
. += SPAN_ALERT("<b> [src]'s light source is nonfunctional!</b>")
else
. += SPAN_ALERT("<b> [src] is broken and requires repairs!</b>")

get_help_message(dist, mob/user)
switch(src.heat_repair)
if(0)
if(!our_cell)
. += "You can use a large energy cell on [src] to attach it to the gun."
else
. += "You can use a <b>wrench</b> to remove [src]'s energy cell."
if(!our_light)
. += "You can use a light tube on [src] to insert it into the gun."
else
. += "You can use <b>wirecutters</b> to remove [src]'s light tube."
if(1)
. = "You can use <b>wirecutters</b> to remove the burnt wiring."
if(2)
. = "You can add 10 wire to replace the wiring."

attack_self(mob/user)
var/I = tgui_input_number(user, "Input a firerate (In deciseconds)", "Timer Adjustment", shoot_delay, 10, 2)
if (!I || BOUNDS_DIST(src, user) > 0)
return
shoot_delay = I
boutput(user, SPAN_NOTICE("You adjust [src] to fire every [I / 10] seconds."))

update_icon()
if (our_cell)
var/image/overlay_image
if (istype(our_cell, /obj/item/cell/artifact))
var/obj/item/cell/artifact/C = our_cell
var/datum/artifact/powercell/AS = C.artifact
var/datum/artifact_origin/AO = AS.artitype
overlay_image = SafeGetOverlayImage("gun_cell", 'icons/obj/items/guns/energy64x32.dmi', "makeshift-[AO.name]")
else
overlay_image = SafeGetOverlayImage("gun_cell", 'icons/obj/items/guns/energy64x32.dmi', "makeshift-[our_cell.icon_state]")
src.UpdateOverlays(overlay_image, "gun_cell")
else
src.UpdateOverlays(null, "gun_cell")

if (our_light)
var/image/overlay_image = SafeGetOverlayImage("gun_light", 'icons/obj/items/guns/energy64x32.dmi', "makeshift-light")
src.UpdateOverlays(overlay_image, "gun_light")
else
src.UpdateOverlays(null, "gun_light")

if (heat > FIRE_THRESHOLD)
var/image/overlay_image = SafeGetOverlayImage("gun_smoke", 'icons/obj/items/guns/energy64x32.dmi', "makeshift-burn")
src.UpdateOverlays(overlay_image, "gun_smoke")
else if (heat > 70)
var/image/overlay_image = SafeGetOverlayImage("gun_smoke", 'icons/obj/items/guns/energy64x32.dmi', "makeshift-smoke")
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
src.UpdateOverlays(overlay_image, "gun_smoke")
else
src.UpdateOverlays(null, "gun_smoke")
..()

shoot(turf/target, turf/start, mob/user, POX, POY, is_dual_wield, atom/called_target = null)
if (canshoot(user))
if (our_light.rigged) // bad idea
src.visible_message(SPAN_ALERT("[src]'s light tube violently explodes!"))
do_explode()
return
var/datum/projectile/laser/makeshift/possible_laser
if (istype(possible_laser))
src.add_heat(rand(possible_laser.heat_low, possible_laser.heat_high), user)
else // allow varedit shenanigans
src.add_heat(rand(15,20), user)
update_icon()
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
our_cell.use(current_projectile.cost)
return ..(target, start, user)

/obj/item/gun/energy/makeshift/spawnable // for testing purposes

New()
..()
var/obj/item/cell/supercell/charged/C = new /obj/item/cell/supercell/charged
C.update_icon() // fix visual bug
unfunnyperson marked this conversation as resolved.
Show resolved Hide resolved
src.attach_cell(C)
var/obj/item/light/tube/T = new /obj/item/light/tube
src.attach_light(T)

#undef HEAT_REMOVED_PER_PROCESS
#undef FIRE_THRESHOLD
Binary file modified icons/mob/clothing/back.dmi
Binary file not shown.
Binary file modified icons/mob/inhand/hand_guns.dmi
Binary file not shown.
Binary file modified icons/obj/items/guns/energy64x32.dmi
Binary file not shown.
Binary file modified icons/obj/projectiles.dmi
Binary file not shown.