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

Musket Bag + Premium Flintlock Ammo #709

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion burgerstation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,6 @@
#include "code\_core\obj\item\clothing\back\wings\angel.dm"
#include "code\_core\obj\item\clothing\back\wings\fairy.dm"
#include "code\_core\obj\item\clothing\belt\_belts.dm"
#include "code\_core\obj\item\clothing\belt\bandolier.dm"
#include "code\_core\obj\item\clothing\belt\belt_of_holding.dm"
#include "code\_core\obj\item\clothing\belt\brass.dm"
#include "code\_core\obj\item\clothing\belt\damage_deferal_shield.dm"
Expand All @@ -1333,6 +1332,9 @@
#include "code\_core\obj\item\clothing\belt\skull_codpiece.dm"
#include "code\_core\obj\item\clothing\belt\storage.dm"
#include "code\_core\obj\item\clothing\belt\white.dm"
#include "code\_core\obj\item\clothing\belt\bandoliers\_bandoliers.dm"
#include "code\_core\obj\item\clothing\belt\bandoliers\bandolier.dm"
#include "code\_core\obj\item\clothing\belt\bandoliers\musket_bag.dm"
#include "code\_core\obj\item\clothing\ears\_ears.dm"
#include "code\_core\obj\item\clothing\ears\headsets.dm"
#include "code\_core\obj\item\clothing\feet\_feet.dm"
Expand Down
9 changes: 8 additions & 1 deletion code/_core/datum/damagetype/ranged/bullet/flintlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
attack_damage_penetration = list(
BLUNT = 0
)
falloff = VIEW_RANGE*0.75
falloff = VIEW_RANGE*0.75

/damagetype/ranged/bullet/flintlock/premium
damage_mod = PREMIUM_MUL

attack_damage_penetration = list(
BLUNT = 5
)
1 change: 1 addition & 0 deletions code/_core/datum/loadout/pirate.dm
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
/obj/item/bullet_cartridge/flintlock{amount=3}
)


/loadout/pirate/crew/magic
spawning_items = list(
/obj/item/clothing/pants/brown,
Expand Down
4 changes: 2 additions & 2 deletions code/_core/obj/item/bullet/_bullet_cartridge.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@
var/obj/item/attachment/undermount/gun/AG = G.attachment_undermount
G = AG.stored_gun

if(G.bullet_time > 0)
PROGRESS_BAR(caller,G,G.bullet_time,/obj/item/weapon/ranged/bullet/proc/accept_bullet,caller,src)
if(G.bullet_time && G.bullet_time[src.type] > 0)
PROGRESS_BAR(caller,G,G.bullet_time[src.type],/obj/item/weapon/ranged/bullet/proc/accept_bullet,caller,src)
PROGRESS_BAR_CONDITIONS(caller,src,src::can_load_bullet_into(),caller,G)
else
G.accept_bullet(caller,src)
Expand Down
10 changes: 9 additions & 1 deletion code/_core/obj/item/bullet/flintlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@
size = 0.1
value = 1 //Dummy value.

caseless = TRUE
caseless = TRUE

/obj/item/bullet_cartridge/flintlock/premium
name = "\improper premium .62 powder charge and iron ball"
desc = "Wow, look at how technology's advancing."
desc = "It's really just another iron ball and powder charge, but they're wrapped in paper so it's a tiny bit easier to load."
icon = 'icons/obj/item/bullet/flintlock_premium.dmi'

damage_type_bullet = /damagetype/ranged/bullet/flintlock/premium
147 changes: 147 additions & 0 deletions code/_core/obj/item/clothing/belt/bandoliers/_bandoliers.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/obj/item/clothing/belt/bandoliers
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know how I missed this, but this should be tweaked so it's compatible with already existing instances of bandoliers. Existing code is below.

https://github.com/BurgerLUA/burgerstation/blob/1adcd75865837c6f5f43fe7d06b24055a42ede10/code/_core/obj/item/clothing/belt/bandolier.dm

Variable names that get saved/loaded should be the same, and the type paths should be the same. This is so that people don't lose their ammo when loading a character before the PR gets merged.

The only thing that needs to be changed is stored_bullets (should be stored_shells), and the path should be /obj/item/clothing/belt/bandolier

var/list/stored_bullets = list()

var/bullet_count = 0 //How many bullets are in the belt in total.
var/max_bullets = 100 //The maximum number of bullets the belt can hold. Duh.

var/next_regen = 0 //How long until it can be restocked again
var/can_be_restocked = FALSE //Ensures the restocker won't show errors if someone uses a bandolier that's not meant to be restocked.

var/bullet_type = /obj/item/bullet_cartridge //The one specific kind of bullet that this belt can hold. I should probably make it a list so you can add more storable bullets but oh well.
var/bullet_type_premium = /obj/item/bullet_cartridge //Only for ammo restocking purposes, don't need to worry about this if it can't be restocked. Otherwise, make sure it's set to the premium version of the bullet your belt can hold

var/num_overlays = 0 //The number of overlays the belt sprite has, so it can update at an equal interval and also won't try adding overlays to belts that have none

/obj/item/clothing/belt/bandoliers/proc/update_bullet_count()
bullet_count = 0
for(var/k in stored_bullets)
var/v = stored_bullets[k]
bullet_count += v

/obj/item/clothing/belt/bandoliers/save_item_data(var/mob/living/advanced/player/P,var/save_inventory = TRUE,var/died=FALSE,var/loadout=FALSE)
RUN_PARENT_SAFE
.["stored_bullets"] = list()
for(var/k in stored_bullets)
var/v = stored_bullets[k]
.["stored_bullets"][k] = v

/obj/item/clothing/belt/bandoliers/load_item_data_pre(var/mob/living/advanced/player/P,var/list/object_data,var/loadout=FALSE)
RUN_PARENT_SAFE
for(var/k in object_data["stored_bullets"])
var/v = object_data["stored_bullets"][k]
stored_bullets[text2path_safe(k)] = v

/obj/item/clothing/belt/bandoliers/Finalize()
. = ..()
update_bullet_count()
update_sprite()

/obj/item/clothing/belt/bandoliers/update_icon()
. = ..()
icon_state_worn = initial(icon_state_worn)
if(num_overlays == 0)
if(bullet_count)
icon_state_worn = "[icon_state_worn]_filled"
icon_state = "full"
else
icon_state = "inventory"
else
if(bullet_count > 0)
icon_state_worn = "[icon_state_worn]_filled"

/obj/item/clothing/belt/bandoliers/update_overlays()
. = ..()
if(num_overlays > 0)
var/step = max_bullets/num_overlays
if(bullet_count)
var/image/I = new/image(icon,"bullet_[CEILING(bullet_count/step,1)]")
add_overlay(I)

/obj/item/clothing/belt/bandoliers/clicked_on_by_object(var/mob/caller,var/atom/object,location,control,params)

if(istype(object,bullet_type))
INTERACT_CHECK
INTERACT_CHECK_OBJECT
INTERACT_DELAY(2)

var/obj/item/bullet_cartridge/C = object

if(caller.attack_flags & CONTROL_MOD_DISARM)
if(!stored_bullets[C.type])
caller.to_chat(span("warning","There are no charges of that type left in \the [src.name]!"))
return TRUE
var/amount_added = C.add_item_count(1)
if(amount_added)
stored_bullets[C.type] -= amount_added
bullet_count -= amount_added
caller.to_chat(span("notice","You add a charge to your hand. There are [stored_bullets[C.type]] charges of that type left."))
if(stored_bullets[C.type] <= 0)
stored_bullets -= C.type
update_sprite()
else
var/amount_added = -C.add_item_count(-min(C.amount,max(0,max_bullets - bullet_count)))
if(amount_added)
if(!stored_bullets[C.type])
stored_bullets[C.type] = amount_added
else
stored_bullets[C.type] += amount_added
update_bullet_count()
if(bullet_count > max_bullets) //Failsafe in case someone somehow adds more bullets to the bandolier than the bandolier can hold
C.add_item_count(bullet_count - max_bullets)
stored_bullets[C.type] -= (bullet_count - max_bullets)
update_bullet_count()
update_sprite()
return TRUE

if(istype(object,/obj/item/bullet_cartridge)&&!istype(object,stored_bullets))
INTERACT_CHECK
INTERACT_CHECK_OBJECT
INTERACT_DELAY(2)
caller.to_chat(span("warning","This type of bullet won't fit into the [src.name]!"))
return TRUE

if(istype(object,/obj/hud/inventory))
INTERACT_CHECK
INTERACT_CHECK_OBJECT
INTERACT_DELAY(2)

if(!length(stored_bullets))
caller.to_chat(span("warning","There are no bullets left!"))
return TRUE

var/obj/hud/inventory/I = object
var/obj/item/bullet_cartridge/C = pickweight(stored_bullets)
C = new C(get_turf(src))
var/amount_to_grab = 1
if(caller.attack_flags & CONTROL_MOD_DISARM)
amount_to_grab = min(stored_bullets[C.type],C.amount_max)
C.amount = amount_to_grab
stored_bullets[C.type] -= amount_to_grab
update_bullet_count()
caller.to_chat(span("notice","You take [amount_to_grab] bullet\s from \the [src.name]. There are [stored_bullets[C.type]] bullets of that type left."))
if(stored_bullets[C.type] <= 0)
stored_bullets -= C.type
INITIALIZE(C)
FINALIZE(C)
I.add_object(C)
update_sprite()
return TRUE

. = ..()

// /obj/item/clothing/belt/bandoliers/proc/take_bullet(var/mob/caller,var/obj/hud/inventory/I)//This proc is for the AI to be able to use bullets from the bag (DOES NOT WORK, kept it here in case someone wanted to try and figure that out)
// if(!length(stored_bullets))
// caller.to_chat(span("warning","There are no charges left!"))
// return FALSE
// var/obj/item/bullet_cartridge/C = pickweight(stored_bullets)
// C = new C(get_turf(src))
// C.amount = 1
// stored_bullets[C.type] -= 1
// caller.to_chat(span("notice","You take 1 charge from \the [src.name]. There are [stored_bullets[C.type]] charges left."))
// if(stored_bullets[C.type] <= 0)
// stored_bullets -= C.type
// INITIALIZE(C)
// FINALIZE(C)
// I.add_object(C)
// update_sprite()
// return TRUE
47 changes: 47 additions & 0 deletions code/_core/obj/item/clothing/belt/bandoliers/bandolier.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/obj/item/clothing/belt/bandoliers/bandolier
name = "error bandolier"
desc = "For the aspiring sweeper."
desc_extended = "A not-so-fancy bandolier meant to hold a number of shotgun shells. ALT+Click to grab additional shells while already holding a shell."

icon = 'icons/obj/item/clothing/belts/bandolier_12.dmi'
worn_layer = LAYER_MOB_CLOTHING_COAT_OVER
dyeable = TRUE


value = 0
size = SIZE_3

stored_bullets = list()

bullet_count = 0
max_bullets = 0
bullet_type = /obj/item/bullet_cartridge

num_overlays = 5

/obj/item/clothing/belt/bandoliers/get_base_value()
return max_bullets*3

/obj/item/clothing/belt/bandoliers/bandolier/shotgun_12
name = "12 gauge shotgun bandolier"
desc_extended = "A not-so-fancy bandolier meant to hold up to 100 12 gauge shotgun shells. ALT+Click to grab a handful of shells, or click to take one."
icon = 'icons/obj/item/clothing/belts/bandolier_12.dmi'
max_bullets = 100
bullet_type = /obj/item/bullet_cartridge/shotgun_12
value = 1 //Dummy value.

/obj/item/clothing/belt/bandoliers/bandolier/shotgun_20
name = "20 gauge shotgun bandolier"
desc_extended = "A dyed bandolier meant to hold up to 120 20 gauge shotgun shells. ALT+Click to grab a handful of shells, or click to take one."
icon = 'icons/obj/item/clothing/belts/bandolier_20.dmi'
max_bullets = 120
bullet_type = /obj/item/bullet_cartridge/shotgun_20
value = 1 //Dummy value.

/obj/item/clothing/belt/bandoliers/bandolier/shotgun_23
name = "23x75mmR shotgun bandolier"
desc_extended = "A surplus bandolier meant to hold up to 80 23x75mmR shotgun shells. ALT+Click to grab a handful of shells, or click to take one."
icon = 'icons/obj/item/clothing/belts/bandolier_23.dmi'
max_bullets = 80
bullet_type = /obj/item/bullet_cartridge/shotgun_23
value = 1 //Dummy value.
34 changes: 34 additions & 0 deletions code/_core/obj/item/clothing/belt/bandoliers/musket_bag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/obj/item/clothing/belt/bandoliers/musket_bag
name = "musket bag"
desc = "It's called a POWDER HORN, okay?"
desc_extended = "A nerdy bag and nerdy horn for nerds that need to hold more ammo for flintlocks (You know who you are). ALT+Click to grab additional charges while already holding a charge. Holds up to 80 charges"

icon = 'icons/obj/item/clothing/belts/musket_bag.dmi'
worn_layer = LAYER_MOB_CLOTHING_COAT_OVER
dyeable = FALSE


value = 0
size = SIZE_3

stored_bullets = list()

bullet_count = 0
max_bullets = 80
bullet_type = /obj/item/bullet_cartridge/flintlock
bullet_type_premium = /obj/item/bullet_cartridge/flintlock/premium

next_regen = 0 //Ammo restocking functionality woo!
can_be_restocked = TRUE

num_overlays = 0

/obj/item/clothing/belt/bandoliers/musket_bag/get_base_value()
return max_bullets*3

/obj/item/clothing/belt/bandoliers/musket_bag/basic/Generate()
stored_bullets[/obj/item/bullet_cartridge/flintlock] = rand(20,30)
bullet_count = stored_bullets[/obj/item/bullet_cartridge/flintlock]

/obj/item/clothing/belt/bandoliers/musket_bag/premium/Generate()
stored_bullets[/obj/item/bullet_cartridge/flintlock/premium] = rand(20,30)
2 changes: 1 addition & 1 deletion code/_core/obj/item/weapon/ranged/bullet/_bullet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

use_iff_tag = TRUE

var/bullet_time = 0 //Not slow-mo, but how long it takes to insert a bullet into the gun.
var/list/bullet_time //If there's some special bullets that take longer or shorter to load. Look at the flintlock or musket for examples

var/sound_pitch = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@

heat_max = 0.1

bullet_time = SECONDS_TO_DECISECONDS(2)
bullet_time = list(
/obj/item/bullet_cartridge/flintlock = SECONDS_TO_DECISECONDS(2),
/obj/item/bullet_cartridge/flintlock/premium = SECONDS_TO_DECISECONDS(1)
)

open = TRUE
can_shoot_while_open = TRUE
Expand Down
5 changes: 4 additions & 1 deletion code/_core/obj/item/weapon/ranged/bullet/revolver/musket.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@

heat_max = 0.1

bullet_time = SECONDS_TO_DECISECONDS(3)
bullet_time = list(
/obj/item/bullet_cartridge/flintlock = SECONDS_TO_DECISECONDS(3),
/obj/item/bullet_cartridge/flintlock/premium = SECONDS_TO_DECISECONDS(2)
)

open = TRUE
can_shoot_while_open = TRUE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
//Union
/obj/item/clothing/overwear/coat/union,
/obj/item/clothing/head/hat/union,
/obj/item/clothing/belt/bandoliers/musket_bag,

//Xeno
/obj/item/clothing/overwear/armor/xeno,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

//Belts and pockets
/obj/item/clothing/belt/storage/colored/brown,
/obj/item/clothing/belt/bandolier/shotgun_12,
/obj/item/clothing/belt/bandoliers/bandolier/shotgun_12,
/obj/item/storage/pouch/single/brown,
/obj/item/storage/pouch/double/brown,
/obj/item/storage/pouch/triple/brown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

//Belt and pockets.
/obj/item/clothing/belt/storage/colored/brown,
/obj/item/clothing/belt/bandolier/shotgun_12,
/obj/item/clothing/belt/bandoliers/bandolier/shotgun_12,
/obj/item/storage/pouch/single/brown,
/obj/item/storage/pouch/double/brown,
/obj/item/storage/pouch/triple/brown,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

//Belt and pockets.
/obj/item/clothing/belt/storage/colored/black,
/obj/item/clothing/belt/bandolier/shotgun_12,
/obj/item/clothing/belt/bandoliers/bandolier/shotgun_12,
/obj/item/storage/pouch/single/black,
/obj/item/storage/pouch/double/black,
/obj/item/storage/pouch/triple/black,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/obj/item/pinpointer/crew/revolutionary,
/obj/item/announcement/rev,
/obj/item/clothing/back/storage/backpack/explorer,
/obj/item/clothing/belt/bandolier/shotgun_23,
/obj/item/clothing/belt/bandoliers/bandolier/shotgun_23,
//obj/item/clothing/overwear/armor/plate_carrier/black,
//obj/item/armor_plate/super,
//obj/item/armor_plate/ultra,
Expand Down
Loading