Skip to content

Commit

Permalink
wooo so much stuff..
Browse files Browse the repository at this point in the history
  • Loading branch information
FalloutFalcon committed Feb 4, 2024
1 parent 0eee121 commit c52fb7f
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 175 deletions.
190 changes: 64 additions & 126 deletions code/modules/guncrafting/frame.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@
name = "gun frame"
desc = "a generic gun frame."
icon_state = "frame_olivaw"
//var/obj/item/gun/result = /obj/item/gun
var/list/preinstalledParts = list()
var/list/installedParts = list()
var/list/filtered_recipes = list()

// Currently installed grip
//var/obj/item/part/gun/modular/grip/InstalledGrip
// Which grips does the frame accept?
//var/list/validGrips = list(/obj/item/part/gun/modular/grip/wood, /obj/item/part/gun/modular/grip/black)

// Currently installed mechanism
//var/obj/item/part/gun/modular/grip/InstalledMechanism
// Which mechanism the frame accepts?
//var/list/validMechanisms = list(/obj/item/part/gun/modular/mechanism)

// Currently installed barrel
//var/obj/item/part/gun/modular/barrel/InstalledBarrel
// Which barrels does the frame accept?
//var/list/validBarrels = list(/obj/item/part/gun/modular/barrel)

gun_part_type = GUN_PART_FRAME


Expand Down Expand Up @@ -87,93 +71,30 @@
. = ..()
if(istype(I, /obj/item/part/gun))
handle_part(I, user)
/*
if(istype(I, /obj/item/part/gun/modular/grip))
if(InstalledGrip)
to_chat(user, span_warning("[src] already has a grip attached!"))
return
else
handle_grip(I, user)
if(istype(I, /obj/item/part/gun/modular/mechanism))
if(InstalledMechanism)
to_chat(user, span_warning("[src] already has a mechanism attached!"))
return
else
handle_mechanism(I, user)
if(istype(I, /obj/item/part/gun/modular/barrel))
if(InstalledBarrel)
to_chat(user, span_warning("[src] already has a barrel attached!"))
return
else
handle_barrel(I, user)
*/

if(I.tool_behaviour == TOOL_SCREWDRIVER)
var/list/possibles = contents.Copy()
var/obj/item/part/gun/toremove = input("Which part would you like to remove?","Removing parts") in possibles
if(!toremove)
return
if(I.use_tool(src, user, 40, volume=50))
eject_item(toremove, user)
/*
if(istype(toremove, /obj/item/part/gun/modular/grip))
InstalledGrip = null
else if(istype(toremove, /obj/item/part/gun/modular/barrel))
InstalledBarrel = FALSE
else if(istype(toremove, /obj/item/part/gun/modular/mechanism))
InstalledMechanism = FALSE
*/

return ..()
/*
/obj/item/part/gun/frame/proc/handle_grip(obj/item/I, mob/living/user)
if(I.type in validGrips)
if(insert_item(I, user))
InstalledGrip = I
to_chat(user, span_notice("You have attached the grip to \the [src]."))
return
else
to_chat(user, span_warning("This grip does not fit!"))
return
/obj/item/part/gun/frame/proc/handle_mechanism(obj/item/I, mob/living/user)
if(I.type in validMechanisms)
if(insert_item(I, user))
InstalledMechanism = I
to_chat(user, span_notice("You have attached the mechanism to \the [src]."))
return
else
to_chat(user, span_warning("This mechanism does not fit!"))
return
/obj/item/part/gun/frame/proc/handle_barrel(obj/item/I, mob/living/user)
if(I.type in validBarrels)
if(insert_item(I, user))
InstalledBarrel = I
to_chat(user, span_notice("You have attached the barrel to \the [src]."))
return
else
to_chat(user, span_warning("This barrel does not fit!"))
return
*/

/obj/item/part/gun/frame/proc/handle_part(obj/item/part/gun/I, mob/living/user)
for(var/datum/lathe_recipe/gun/recipe in filtered_recipes)
if(I.type in recipe.validParts)
//if(I.gun_part_type && !(I.gun_part_type & get_part_types()))
if(insert_item(I, user))
to_chat(user, span_notice("You have attached the part to \the [src]."))
installedParts += I
get_current_recipes()
return
if(I.gun_part_type && !(I.gun_part_type in get_part_types()))
if(insert_item(I, user))
to_chat(user, span_notice("You have attached the part to \the [src]."))
installedParts += I
get_current_recipes()
return
else
to_chat(user, span_warning("This part does not fit!"))
else
to_chat(user, span_warning("This part does not fit!"))
return
to_chat(user, span_warning("This type of part is already installed!"))
else
to_chat(user, span_warning("This part cannot be installed on this [src]!"))
return


//Finds all recipes that match the current parts
Expand All @@ -193,31 +114,40 @@
if(!(installed_part.type in recipe.validParts))
return FALSE
return TRUE
///obj/item/part/gun/frame/attack_self(obj/item/I, mob/user)

/*
if(!InstalledGrip)
to_chat(user, span_warning("\the [src] does not have a grip!"))
return
if(!InstalledMechanism)
to_chat(user, span_warning("\the [src] does not have a mechanism!"))
/obj/item/part/gun/frame/attack_self(mob/user)
var/list/choose_options = list()
var/list/option_results = list()
for(var/datum/lathe_recipe/gun/recipe in filtered_recipes)
var/obj/recipe_result = recipe.result
var/list/parts_for_craft = list()
for(var/obj/item/part/gun/part as anything in recipe.validParts)
var/part_type = initial(part.gun_part_type)
var/list/installed_types = get_part_types()
if(!(part_type in installed_types))
parts_for_craft += " \a [initial(part.name)]"
if(length(parts_for_craft) != 0)
to_chat(user, span_warning("Parts needed for a [initial(recipe_result.name)]:"))
for(var/part in parts_for_craft)
to_chat(user, span_warning(part))
else
to_chat(user, span_notice("You can craft a [initial(recipe_result.name)] with the parts installed."))
choose_options += list("Craft [initial(recipe_result.name)]" = image(icon = initial(recipe_result.icon), icon_state = initial(recipe_result.icon_state)))
option_results["Craft [initial(recipe_result.name)]"] = recipe_result
if(length(choose_options) == 0)
to_chat(user, span_warning("No recipes can be crafted with the parts installed."))
return
if(!InstalledBarrel)
to_chat(user, span_warning("\the [src] does not have a barrel!"))
var/picked_option = show_radial_menu(user, src, choose_options, radius = 38, require_near = TRUE)
if(!picked_option)
return
*/
/*
var/turf/T = get_turf(src)
var/obj/item/gun/newGun = new result(T, 0)
var/obj/item/gun/ballistic/pickedGun = option_results[picked_option]
var/obj/item/gun/newGun = new pickedGun(T, TRUE)
newGun.frame = src
src.forceMove(newGun)
return
*/

/obj/item/part/gun/frame/proc/can_be_installed()

/obj/item/part/gun/frame/proc/get_part_types()
var/part_types = NONE
var/list/part_types = list()
part_types |= gun_part_type
for(var/obj/item/part/gun/part in installedParts)
part_types |= part.gun_part_type
Expand All @@ -226,35 +156,37 @@
/obj/item/part/gun/frame/examine(user, distance)
. = ..()
if(.)
for (var/obj/item/part/gun/part in installedParts)
for(var/obj/item/part/gun/part in installedParts)
. += "<span class='notice'>[src] has \a [part] [icon2html(part, user)] installed.</span>"
for(var/datum/lathe_recipe/gun/recipe in filtered_recipes)
for(var/obj/part as anything in recipe.validParts)
. += "<span class='notice'>[src] could hold \a [initial(part.name)].</span>"
. += "<span class='notice'>[src] could hold \a [get_part_types()].</span>"

var/obj/recipe_result = recipe.result
var/list/parts_for_craft = list()
for(var/obj/item/part/gun/part as anything in recipe.validParts)
var/part_type = initial(part.gun_part_type)
var/list/installed_types = get_part_types()
if(!(part_type in installed_types))
parts_for_craft += " \a [initial(part.name)]"
if(length(parts_for_craft) != 0)
. += "<span class='notice'>Parts needed for a [initial(recipe_result.name)]:</span>"
for(var/part in parts_for_craft)
. += part
else
. += "<span class='notice'>You can craft a [initial(recipe_result.name)] with the parts installed.</span>"
/*
if(InstalledGrip)
. += "<span class='notice'>\the [src] has \a [InstalledGrip] installed.</span>"
else
. += "<span class='notice'>\the [src] does not have a grip installed.</span>"
if(InstalledMechanism)
. += "<span class='notice'>\the [src] has \a [InstalledMechanism] installed.</span>"
else
. += "<span class='notice'>\the [src] does not have a mechanism installed.</span>"
if(InstalledBarrel)
. += "<span class='notice'>\the [src] has \a [InstalledBarrel] installed.</span>"
else
. += "<span class='notice'>\the [src] does not have a barrel installed.</span>"
var/part_type_message = ""
for(var/part_type in get_part_types())
part_type_message += "\a [part_type], "
if(part_type_message)
. += "<span class='notice'>[src] has " + part_type_message + ".</span>"
*/

/obj/item/part/gun/frame/winchester
name = "winchester gun frame"
icon_state = "frame_shotgun"
preinstalledParts = list(
/obj/item/part/gun/modular/grip/wood,
/obj/item/part/gun/modular/mechanism/shotgun,
/obj/item/part/gun/modular/barrel/shotgun
/obj/item/part/gun/modular/mechanism/rifle,
/obj/item/part/gun/modular/barrel/rifle
)

/obj/item/part/gun/frame/winchester/mk1
Expand All @@ -264,12 +196,18 @@
name = "m1911 gun frame"
preinstalledParts = list(
/obj/item/part/gun/modular/grip/wood,
/obj/item/part/gun/modular/mechanism,
/obj/item/part/gun/modular/barrel
/obj/item/part/gun/modular/mechanism/pistol,
/obj/item/part/gun/modular/barrel/pistol
)

/obj/item/part/gun/frame/commander
name = "commander gun frame"

/obj/item/part/gun/frame/boltaction
name = "bolt action gun frame"

/obj/item/part/gun/frame/revolver

/obj/item/part/gun/frame/tec9

/obj/item/part/gun/frame/shotgun
23 changes: 23 additions & 0 deletions code/modules/guncrafting/guncrafting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,26 @@
icon = 'icons/obj/guncrafting.dmi'
icon_state = "work_piece"
max_amount = 10

/obj/item/storage/box/parts
name = "gunmakers box"
desc = "A set of tools and parts to assemble your first weapon"

/obj/item/storage/box/parts/PopulateContents()
new /obj/item/tool/hammer(src)
new /obj/item/tool/file(src)
new /obj/item/tool/saw(src)
new /obj/item/part/gun/frame/winchester(src)
new /obj/item/part/gun/modular/grip/wood(src)
new /obj/item/part/gun/modular/mechanism/shotgun(src)
new /obj/item/part/gun/modular/barrel/shotgun(src)
new /obj/item/part/gun/frame/winchester(src)
new /obj/item/part/gun/modular/grip/wood(src)
new /obj/item/part/gun/modular/mechanism/shotgun(src)
new /obj/item/part/gun/modular/barrel/shotgun(src)
new /obj/item/part/gun/frame(src)
new /obj/item/part/gun/frame/m1911(src)
new /obj/item/part/gun/modular/grip/wood(src)
new /obj/item/part/gun/modular/mechanism(src)
new /obj/item/part/gun/modular/barrel(src)

14 changes: 13 additions & 1 deletion code/modules/guncrafting/part.dm
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@

/obj/item/part/gun/modular/mechanism/shotgun
name = "generic shotgun mechanism"
desc = "All the bits that makes the bullet go bang."
icon_state = "mechanism_shotgun"

/obj/item/part/gun/modular/mechanism/rifle

/obj/item/part/gun/modular/mechanism/revolver
name = "generic revolver mechanism"

/obj/item/part/gun/modular/mechanism/pistol

/obj/item/part/gun/modular/barrel
name = "generic barrel"
desc = "A gun barrel, which keeps the bullet going in the right direction."
Expand All @@ -48,3 +54,9 @@
name = "generic shotgun barrel"
desc = "A gun barrel, which keeps the bullet going in the right direction."
icon_state = "barrel_30"

/obj/item/part/gun/modular/barrel/rifle

/obj/item/part/gun/modular/barrel/revolver

/obj/item/part/gun/modular/barrel/pistol
Loading

0 comments on commit c52fb7f

Please sign in to comment.