Skip to content

Commit

Permalink
[MIRROR] Assorted Ballistics Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
l3lb0t authored and SuhEugene committed Nov 23, 2023
1 parent cbafaf9 commit 3fd2457
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
46 changes: 45 additions & 1 deletion code/modules/projectiles/guns/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
var/list/loaded = list() //stored ammo
var/starts_loaded = 1 //whether the gun starts loaded or not, can be overridden for guns crafted in-game
var/load_sound = 'sound/weapons/guns/interaction/bullet_insert.ogg'
var/recentload = 0 // artificially limits how fast a gun can be loaded

//For CYCLE_CASING guns
var/chamber_offset = 0 //how many empty chambers in the cylinder until you hit a round

//For MAGAZINE guns
var/magazine_type = null //the type of magazine that the gun comes preloaded with
Expand Down Expand Up @@ -133,7 +137,25 @@
if(istype(A, /obj/item/ammo_magazine))
. = TRUE
var/obj/item/ammo_magazine/AM = A
if(!(load_method & AM.mag_type) || ((istext(caliber) && caliber != AM.caliber) && (islist(caliber) && !is_type_in_list(AM.caliber, caliber))))
if (((istext(caliber) && caliber != AM.caliber) || (islist(caliber) && !is_type_in_list(AM.caliber, caliber))))
return //incompatible
else if (load_method == SINGLE_CASING && AM.mag_type == SPEEDLOADER && world.time >= recentload)
if (length(AM.stored_ammo))
var/C = AM.stored_ammo[1]
if (length(loaded) >= max_shells)
to_chat(user, SPAN_WARNING("[src] is full!"))
return
if (!user.unEquip(C, src))
return
loaded.Insert(1, C) //add to the head of the list
AM.stored_ammo -= C
user.visible_message("[user] inserts \a [C] into [src].", SPAN_NOTICE("You insert \a [C] into [src]."))
playsound(loc, load_sound, 50, 1)
recentload = world.time + 0.5 SECONDS
AM.update_icon()
update_icon()
return
else if (!(load_method & AM.mag_type))
return //incompatible

switch(AM.mag_type)
Expand Down Expand Up @@ -313,6 +335,8 @@
to_chat(user, "It has \a [ammo_magazine] loaded.")
if(user.skill_check(SKILL_WEAPONS, SKILL_TRAINED))
to_chat(user, "Has [getAmmo()] round\s remaining.")
if (user.skill_check(SKILL_WEAPONS, SKILL_EXPERIENCED))
to_chat(user, "[src.DrawChamber()]")

/obj/item/gun/projectile/proc/getAmmo()
var/bullets = 0
Expand All @@ -324,6 +348,26 @@
bullets += 1
return bullets

/obj/item/gun/projectile/proc/DrawChamber()
if (handle_casings == CYCLE_CASINGS)
var/chambers = list()
var/empty_chambers = 0
while (chamber_offset > empty_chambers)
chambers += "🌣"
empty_chambers ++
for (var/obj/item/ammo_casing/casing in loaded)
if (casing.BB)
chambers += ""
else
chambers += ""
while (max_shells > length(chambers))
chambers += "🌣"
empty_chambers ++
var/chamberlist = ""
for (var/chamber in chambers)
chamberlist += chamber
return chamberlist

/* Unneeded -- so far.
//in case the weapon has firemodes and can't unload using attack_hand()
/obj/item/gun/projectile/verb/unload_gun()
Expand Down
1 change: 0 additions & 1 deletion code/modules/projectiles/guns/projectile/revolver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
max_shells = 6
fire_delay = 12 //Revolvers are naturally slower-firing
ammo_type = /obj/item/ammo_casing/pistol/magnum
var/chamber_offset = 0 //how many empty chambers in the cylinder until you hit a round
mag_insert_sound = 'sound/weapons/guns/interaction/rev_magin.ogg'
mag_remove_sound = 'sound/weapons/guns/interaction/rev_magout.ogg'
accuracy = 2
Expand Down
21 changes: 20 additions & 1 deletion code/modules/projectiles/guns/projectile/shotgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,31 @@

return ..()

/obj/item/gun/projectile/shotgun/pump/DrawChamber()
var/chamberlist = ""
if (chambered)
if (chambered.BB)
chamberlist += "◉|"
else
chamberlist += "◎|"
else
chamberlist += "🌣|"
if (length(loaded) > 0)
var/obj/item/ammo_casing/casinglist = loaded
if (casinglist[1].BB)
chamberlist += ""
else
chamberlist += ""
else
chamberlist += "🌣"
return chamberlist

/obj/item/gun/projectile/shotgun/pump/empty
starts_loaded = FALSE

/obj/item/gun/projectile/shotgun/pump/sawn
name = "riot shotgun"
desc = "A mass-produced shotgun by Mars Security Industries. The rugged ZX-870 'Bulldog' is common throughout most frontier worlds. This one has had it's stock cut off..."
desc = "A mass-produced shotgun by Mars Security Industries. The rugged ZX-870 'Bulldog' is common throughout most frontier worlds. This one has had its stock cut off..."
icon = 'icons/obj/guns/shotguns.dmi'
icon_state = "rshotgun"
item_state = "rshotgun"
Expand Down
20 changes: 20 additions & 0 deletions code/modules/projectiles/guns/projectile/sniper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
to_chat(user, SPAN_NOTICE("You work the bolt open."))
else
to_chat(user, SPAN_NOTICE("You work the bolt closed."))
if (length(loaded))
chambered = loaded[1]
else
chambered = null
playsound(src.loc, 'sound/weapons/guns/interaction/rifle_boltforward.ogg', 50, 1)
bolt_open = 0
add_fingerprint(user)
Expand All @@ -77,6 +81,22 @@
return
..()

/obj/item/gun/projectile/heavysniper/getAmmo()
var/bullets = 0
if (loaded)
bullets += length(loaded)
if (ammo_magazine && ammo_magazine.stored_ammo)
bullets += length(ammo_magazine.stored_ammo)
return bullets

/obj/item/gun/projectile/heavysniper/DrawChamber()
if (chambered)
if (chambered.BB)
return ""
else
return ""
else
return "🌣"

/obj/item/gun/projectile/heavysniper/boltaction
name = "bolt action rifle"
Expand Down
3 changes: 1 addition & 2 deletions code/modules/projectiles/projectile/bullets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,12 @@
damage = 45
armor_penetration = 25
penetrating = 1
distance_falloff = 1.5
distance_falloff = 1

/obj/item/projectile/bullet/rifle/military
fire_sound = 'sound/weapons/gunshot/gunshot2.ogg'
damage = 40
armor_penetration = 35
distance_falloff = 1

/obj/item/projectile/bullet/rifle/shell
fire_sound = 'sound/weapons/gunshot/sniper.ogg'
Expand Down

0 comments on commit 3fd2457

Please sign in to comment.