-
-
Notifications
You must be signed in to change notification settings - Fork 120
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
IjNebula
wants to merge
4
commits into
BurgerLUA:master
Choose a base branch
from
IjNebula:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
code/_core/obj/item/clothing/belt/bandoliers/_bandoliers.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/obj/item/clothing/belt/bandoliers | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
34
code/_core/obj/item/clothing/belt/bandoliers/musket_bag.dm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 bestored_shells
), and the path should be/obj/item/clothing/belt/bandolier