Skip to content

Commit

Permalink
handfuls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pariah919 committed Feb 16, 2022
1 parent f7484ff commit 3fb5571
Show file tree
Hide file tree
Showing 9 changed files with 163 additions and 2 deletions.
1 change: 1 addition & 0 deletions baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -2748,6 +2748,7 @@
#include "code\modules\projectiles\secure.dm"
#include "code\modules\projectiles\ammunition\boxes.dm"
#include "code\modules\projectiles\ammunition\bullets.dm"
#include "code\modules\projectiles\ammunition\handfuls.dm"
#include "code\modules\projectiles\ammunition\magnetic.dm"
#include "code\modules\projectiles\guns\energy.dm"
#include "code\modules\projectiles\guns\launcher.dm"
Expand Down
1 change: 1 addition & 0 deletions code/__defines/guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#define SINGLE_CASING 1 //The gun only accepts ammo_casings. ammo_magazines should never have this as their mag_type.
#define SPEEDLOADER 2 //Transfers casings from the mag to the gun when used.
#define MAGAZINE 4 //The magazine item itself goes inside the gun
#define SINGLE_LOAD 5 //You have to load it one casing at a time from a stack.


#define GUN_BULK_RIFLE 5
Expand Down
1 change: 1 addition & 0 deletions code/modules/boh_misc/munitions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
desc = "A high-power bullet casing."
caliber = CALIBER_PISTOL_MAGNUM_LARGE
projectile_type = /obj/item/projectile/bullet/pistol/large
ammo_stack = /obj/item/ammo_magazine/handful/magnum_handful/two

//projectile
/obj/item/projectile/bullet/pistol/large
Expand Down
9 changes: 9 additions & 0 deletions code/modules/projectiles/ammunition.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
var/obj/item/projectile/BB = null //The loaded bullet - make it so that the projectiles are created only when needed?
var/spent_icon = "pistolcasing-spent"
var/fall_sounds = list('sound/weapons/guns/casingfall1.ogg','sound/weapons/guns/casingfall2.ogg','sound/weapons/guns/casingfall3.ogg')
var/ammo_stack = null //Put the path of the ammo stack you'd like to create here. It creates an ammo stack when you combine two of the same ammo type.

/obj/item/ammo_casing/Initialize()
if(ispath(projectile_type))
Expand Down Expand Up @@ -60,6 +61,14 @@
LAZYDISTINCTADD(A.gunshot_residue, caliber)

/obj/item/ammo_casing/attackby(obj/item/weapon/W as obj, mob/user as mob)
if(istype(W, /obj/item/ammo_casing)) // merges it into handfuls.
if(src.type == W.type)
var/obj/item/ammo_casing/A = W
if(A.BB && src.BB && ammo_stack)
var/obj/item/ammo_magazine/handful/H = new ammo_stack(src.loc)
H.update_icon()
qdel(src)
qdel(A)
if(isScrewdriver(W))
if(!BB)
to_chat(user, "<span class='notice'>There is no bullet in the casing to inscribe anything into.</span>")
Expand Down
1 change: 1 addition & 0 deletions code/modules/projectiles/ammunition/bullets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
desc = "A shotshell."
icon_state = "gshell"
spent_icon = "gshell-spent"
ammo_stack = /obj/item/ammo_magazine/handful/shotgun/shotgun_handful/two
projectile_type = /obj/item/projectile/bullet/pellet/shotgun
matter = list(MATERIAL_STEEL = 360)

Expand Down
135 changes: 135 additions & 0 deletions code/modules/projectiles/ammunition/handfuls.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Handfuls, basically ammo boxes that single load and delete on hitting 0. //
// They're spawned from ammo boxes with handfuls in them. //

// Handfuls themselves, ported over from IS12, mostly. //

/obj/item/ammo_magazine/handful
name = "handful"
desc = "If you see this something fucked something up."
mag_type = SINGLE_LOAD
max_ammo = 6
multiple_sprites = 1

/obj/item/ammo_magazine/handful/New()
..()
update_icon()

/obj/item/ammo_magazine/handful/update_icon()
if(!stored_ammo.len)//There's no more ammo here, so delete the handful.
qdel(src)
return
icon_state = "[initial(icon_state)]-[stored_ammo.len]"//If there is ammo then we take our initial icon_state and add the ammount of ammo in the stack to it.

/obj/item/ammo_magazine/handful/attack_self(mob/user)//We want to override the normal attack self with makes us "empty" our "clip".
return

// Ammo boxes themselves. //

/obj/item/ammo_box
name = "\improper box of ammo"
desc = "You get bullets out of this."
icon = 'icons/obj/ammo.dmi'
icon_state = "rbox"
w_class = ITEM_SIZE_SMALL //So you can put it in your pocket.
var/handful_type = null
var/list/stored_handfuls = list()
var/max_stacks = 4
var/handful_verb = "handful"

/obj/item/ammo_box/Initialize()
. = ..()
for(var/i in 1 to max_stacks)
stored_handfuls += new handful_type(src)
update_icon()

/obj/item/ammo_box/examine(mob/user)
. = ..()
if(stored_handfuls.len)
to_chat(user, "It has [stored_handfuls.len] [handful_verb]s left.")
else
to_chat(user, "It is empty.")


/obj/item/ammo_box/attack_hand(var/mob/living/carbon/human/user)
if(!istype(user))
..()
return
if((src != user.r_store) && (src != user.l_store) && (src != user.belt) && (src != user.get_inactive_hand()))
..()//If it's not in any of these slots then just return normally.
return
if(!stored_handfuls.len)//If there's no more handfuls then don't divide by 0 please.
return
var/obj/item/ammo_magazine/handful/A = src.stored_handfuls[1]//If it is in one of these slots though put it in our hand.
if(A)
stored_handfuls.Cut(1, 2)
user.put_in_hands(A)
user.visible_message("[user] takes [A] out.")
update_icon()

/obj/item/ammo_box/attackby(obj/item/C, mob/user)
if(!istype(C, handful_type))
to_chat(user, "\The [src] does not accept this [handful_verb].")
return
if(stored_handfuls.len == max_stacks)
to_chat(user, "There's too many [handful_verb]s in there already.")
return
user.remove_from_mob(C)
C.forceMove(src)
stored_handfuls.Add(C)
user.visible_message("[user] adds [C] to the box.")
update_icon()


/obj/item/ammo_box/MouseDrop(var/obj/over_object)
if (!over_object || !(ishuman(usr) || issmall(usr)))
return

if (!(src.loc == usr))
return

if (usr.incapacitated(INCAPACITATION_STUNNED|INCAPACITATION_RESTRAINED|INCAPACITATION_KNOCKOUT))
return

if (!usr.unEquip(src))
return

switch(over_object.name)
if("r_hand")
usr.put_in_r_hand(src)
if("l_hand")
usr.put_in_l_hand(src)

src.add_fingerprint(usr)

// Shotgun shell box //

/obj/item/ammo_box/shotgun
name = "\improper shells box"
icon_state = "shotgun_box"
desc = "A box holidng a neat pile of 12 gauge shells. You get them out of here."
handful_type = /obj/item/ammo_magazine/handful/shotgun/shotgun_handful


/obj/item/ammo_magazine/handful/shotgun/shotgun_handful
name = "\improper handful of shells"
desc = "A handful of shotgun shells for a shotgun."
max_ammo = 6
icon_state = "gshell_handful"
caliber = CALIBER_SHOTGUN
ammo_type = /obj/item/ammo_casing/shotgun/pellet

/obj/item/ammo_magazine/handful/shotgun/shotgun_handful/two // This exists because you're technically making a new item when making handfuls. Not combining ammos.
initial_ammo = 2

// .454.

/obj/item/ammo_magazine/handful/magnum_handful
name = "\improper handful of high caliber revolver rounds"
desc = "A handful of shotgun shells for a high caliber revolver. .454."
max_ammo = 6
icon_state = "handful_magnum"
caliber = CALIBER_PISTOL_MAGNUM_LARGE
ammo_type = /obj/item/ammo_casing/pistol/magnum/large

/obj/item/ammo_magazine/handful/magnum_handful/two // This exists because you're technically making a new item when making handfuls. Not combining ammos.
initial_ammo = 2
15 changes: 14 additions & 1 deletion code/modules/projectiles/guns/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

var/caliber = CALIBER_PISTOL //determines which casings will fit
var/handle_casings = EJECT_CASINGS //determines how spent casings should be handled
var/load_method = SINGLE_CASING|SPEEDLOADER //1 = Single shells, 2 = box or quick loader, 3 = magazine
var/load_method = SINGLE_CASING|SPEEDLOADER|SINGLE_LOAD //1 = Single shells, 2 = box or quick loader, 3 = magazine
var/obj/item/ammo_casing/chambered = null

//For SINGLE_CASING or SPEEDLOADER guns
Expand Down Expand Up @@ -142,6 +142,19 @@
ammo_magazine = AM
user.visible_message("[user] inserts [AM] into [src].", "<span class='notice'>You insert [AM] into [src].</span>")
playsound(loc, mag_insert_sound, 50, 1)

if(SINGLE_LOAD)
if(loaded.len >= max_shells)
to_chat(user, "<span class='warning'>[src] is full!</span>")
return
var/obj/item/ammo_casing/C = AM.stored_ammo[1]
if(C)
C.loc = src
loaded.Insert(1, C) //add to the head of the list
AM.stored_ammo.Cut(1, 2)
playsound(loc, mag_insert_sound, 50, 1)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)//So we can't speed click these.

if(SPEEDLOADER)
if(loaded.len >= max_shells)
to_chat(user, "<span class='warning'>[src] is full!</span>")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/guns/projectile/shotgun.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
slot_flags = SLOT_BACK
caliber = CALIBER_SHOTGUN
origin_tech = list(TECH_COMBAT = 4, TECH_MATERIAL = 2)
load_method = SINGLE_CASING
load_method = SINGLE_CASING|SINGLE_LOAD
ammo_type = /obj/item/ammo_casing/shotgun/beanbag
handle_casings = HOLD_CASINGS
one_hand_penalty = 8
Expand Down
Binary file modified icons/obj/ammo.dmi
Binary file not shown.

0 comments on commit 3fb5571

Please sign in to comment.