diff --git a/code/modules/keybindings/keybind/combat.dm b/code/modules/keybindings/keybind/combat.dm index c4b44b5283b..9a62af182f5 100644 --- a/code/modules/keybindings/keybind/combat.dm +++ b/code/modules/keybindings/keybind/combat.dm @@ -48,3 +48,79 @@ var/mob/living/L = user.mob L.keybind_parry() return TRUE + +//-->Gun safety toggle hotkey +/datum/keybinding/living/gunsafety + hotkey_keys = list(",") + name = "gunsafety" + full_name = "Gun Safety Toggle" + category = CATEGORY_COMBAT + description = "Toggle your weapon's safety." + +/datum/keybinding/living/gunsafety/down(client/user) + var/mob/living/carbon/C = user.mob + var/obj/item/gun/firearm + + for(var/obj/item/gun/F in C.held_items) + firearm = F + break + if(!istype(firearm)) + return FALSE + . = ..() + firearm.ui_action_click(usr, "safety") + return TRUE + +//-->Gun scope toggle hotkey +/datum/keybinding/living/gunscope + hotkey_keys = list(".") + name = "gunscope" + full_name = "Gun Scope Toggle" + category = CATEGORY_COMBAT + description = "Use your gun's scope." + +/datum/keybinding/living/gunscope/down(client/user) + var/mob/living/carbon/C = user.mob + var/obj/item/gun/firearm + + for(var/obj/item/gun/F in C.held_items) + firearm = F + break + if(!istype(firearm)) + return FALSE + . = ..() + firearm.ui_action_click(usr, "scope") + return TRUE + +//-->Gun switch firing mode hotkey +/datum/keybinding/living/gunmode + hotkey_keys = list("/") + name = "gunmode" + full_name = "Gun Firing Mode" + category = CATEGORY_COMBAT + description = "Switch your weapon's firing mode." + +/datum/keybinding/living/gunmode/down(client/user) + var/mob/living/carbon/C = user.mob + var/obj/item/gun/firearm + + for(var/obj/item/gun/F in C.held_items) + firearm = F + break + if(!istype(firearm)) + return FALSE + . = ..() + firearm.ui_action_click(usr, "fire mode") + return TRUE + +//-->Reloading your gun with a simple button +/datum/keybinding/living/gunreload + hotkey_keys = list("ShiftR") + name = "gunreload" + full_name = "Quick weapon reload" + category = CATEGORY_COMBAT + description = "Reload your weapon with a button." + +/datum/keybinding/living/gunreload/down(client/user) + var/mob/living/carbon/C = user.mob + C.smart_gunreload() + return TRUE diff --git a/code/modules/keybindings/keybind/human.dm b/code/modules/keybindings/keybind/human.dm index 13c55680f9e..6541b601d2a 100644 --- a/code/modules/keybindings/keybind/human.dm +++ b/code/modules/keybindings/keybind/human.dm @@ -24,7 +24,6 @@ SA.quick_equip() -/* /datum/keybinding/human/quick_equipbelt hotkey_keys = list("ShiftE") name = "quick_equipbelt" @@ -39,11 +38,22 @@ /datum/keybinding/human/bag_equip hotkey_keys = list("ShiftB") name = "bag_equip" - full_name = "Bag equip" + full_name = "Quick bag equip" description = "Put held thing in backpack or take out most recent thing from backpack" /datum/keybinding/human/bag_equip/down(client/user) var/mob/living/carbon/human/H = user.mob H.smart_equipbag() return TRUE -*/ + +//-->We are now going to gunsling +// /datum/keybinding/human/holster_equip +// hotkey_keys = list("ShiftR") +// name = "holster_equip" +// full_name = "Quick holster equip" +// description = "Holster or unholster your gun or ammo clips." + +// /datum/keybinding/human/holster_equip/down(client/user) +// var/mob/living/carbon/human/H = user.mob +// H.smart_equipholster() +// return TRUE diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 2ca15e6ca3e..36dbf7a7f21 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -454,8 +454,18 @@ set hidden = 1 var/obj/item/I = get_active_held_item() - if (I) + if(I) I.equip_to_best_slot(src) + // else + // var/obj/item/storage = get_item_by_slot(SLOT_S_STORE) + // if(!storage.contents.len) //not a storage item + // if(get_active_held_item()) + // storage.attack_hand(src) + // else if(!get_active_held_item()) + // storage = get_item_by_slot(SLOT_BELT) + // if(!SEND_SIGNAL(storage, COMSIG_CONTAINS_STORAGE)) //not a storage item + // if(get_active_held_item()) + // storage.attack_hand(src) //used in code for items usable by both carbon and drones, this gives the proper back slot for each mob.(defibrillator, backpack watertank, ...) /mob/proc/getBackSlot() diff --git a/code/modules/mob/living/carbon/human/inventory.dm b/code/modules/mob/living/carbon/human/inventory.dm index ed101a0819f..4dc409f5fdc 100644 --- a/code/modules/mob/living/carbon/human/inventory.dm +++ b/code/modules/mob/living/carbon/human/inventory.dm @@ -355,3 +355,59 @@ return stored.attack_hand(src) // take out thing from belt return + +/* +/mob/living/carbon/human/proc/smart_equipholster() //put held thing in holster, take out weapons or ammo with a priority. + if(incapacitated()) + return + + var/obj/item/thing = get_active_held_item() + var/obj/item/equipped_neck = get_item_by_slot(SLOT_NECK) + + if(!equipped_neck) + if(!thing) + to_chat(src, span_warning("You have no holster to take something out of!")) + return + if(equip_to_slot_if_possible(thing, INV_SLOTBIT_NECK)) + update_inv_hands() + return + if(!SEND_SIGNAL(equipped_neck, COMSIG_CONTAINS_STORAGE)) //not a storage item + if(!thing) + equipped_neck.attack_hand(src) + else + to_chat(src, span_warning("You can't fit anything in your holster!")) + return + if(thing) //put thing in holster + if(!SEND_SIGNAL(equipped_neck, COMSIG_TRY_STORAGE_INSERT, thing, src)) + to_chat(src, span_warning("This item is too big to fit the holster!")) + return + if(!equipped_neck.contents.len) //nothing to take out + to_chat(src, span_warning("You can't fit anything in your holster!")) + return + + var/obj/item/gun/firearm = null + var/obj/item/ammo_box/speed_loader + + for(var/obj/item/gun/F in equipped_neck.contents) //First thing, we want to obviously prioritize the unholstering of the gun. + firearm = F + break + for(var/obj/item/ammo_box/S in equipped_neck.contents) //We surely have to find at least the first speedloader, otherwise the following for doesn't know what to do + speed_loader = S + break + for(var/obj/item/ammo_box/S in equipped_neck.contents) //Code didn't find a gun? Let's check if there are clips or speedloaders with ammo in it. + if(S.stored_ammo.len >= speed_loader.stored_ammo.len) + speed_loader = S + + var/obj/item/stored = equipped_neck.contents[equipped_neck.contents.len] + if(firearm && !firearm.on_found(src)) //return the firearm first + firearm.attack_hand(src) + return + else if(speed_loader && !speed_loader.on_found(src)) //if there's no firearm, return the fullest speedloader + speed_loader.attack_hand(src) + return + else if(stored && !stored.on_found(src)) //if none of the above is in the holster, return whatever was inside + stored.attack_hand(src) + return + else + return +*/ diff --git a/code/modules/projectiles/gun_keybinds.dm b/code/modules/projectiles/gun_keybinds.dm deleted file mode 100644 index ced2dfd525b..00000000000 --- a/code/modules/projectiles/gun_keybinds.dm +++ /dev/null @@ -1,62 +0,0 @@ -//-->Gun safety toggle hotkey -/datum/keybinding/living/gunsafety - hotkey_keys = list(",") - name = "gunsafety" - full_name = "Gun Safety Toggle" - category = CATEGORY_COMBAT - description = "Toggle your weapon's safety." - -/datum/keybinding/living/gunsafety/down(client/user) - var/mob/living/carbon/C = user.mob - var/obj/item/gun/firearm - - for(var/obj/item/gun/F in C.held_items) - firearm = F - break - if(!istype(firearm)) - return FALSE - . = ..() - firearm.ui_action_click(usr, "safety") - return TRUE - -//-->Gun scope toggle hotkey -/datum/keybinding/living/gunscope - hotkey_keys = list(".") - name = "gunscope" - full_name = "Gun Scope Toggle" - category = CATEGORY_COMBAT - description = "Use your gun's scope." - -/datum/keybinding/living/gunscope/down(client/user) - var/mob/living/carbon/C = user.mob - var/obj/item/gun/firearm - - for(var/obj/item/gun/F in C.held_items) - firearm = F - break - if(!istype(firearm)) - return FALSE - . = ..() - firearm.ui_action_click(usr, "scope") - return TRUE - -//-->Gun switch firing mode hotkey -/datum/keybinding/living/gunmode - hotkey_keys = list("/") - name = "gunmode" - full_name = "Gun Firing Mode" - category = CATEGORY_COMBAT - description = "Switch your weapon's firing mode." - -/datum/keybinding/living/gunmode/down(client/user) - var/mob/living/carbon/C = user.mob - var/obj/item/gun/firearm - - for(var/obj/item/gun/F in C.held_items) - firearm = F - break - if(!istype(firearm)) - return FALSE - . = ..() - firearm.ui_action_click(usr, "fire mode") - return TRUE diff --git a/code/modules/projectiles/gun_reload.dm b/code/modules/projectiles/gun_reload.dm new file mode 100644 index 00000000000..491a1e41748 --- /dev/null +++ b/code/modules/projectiles/gun_reload.dm @@ -0,0 +1,188 @@ +//-->Proc that allows reloading with a simple button +//we want a proc that unholsters your weapon from: suit storage, belt, shoulder holster. (in this order and if your hand is empty) +/mob/living/carbon/proc/smart_gunreload() + if(incapacitated()) + return + + var/obj/item/equipped_belt = get_item_by_slot(SLOT_BELT) + var/obj/item/equipped_back = get_item_by_slot(SLOT_BACK) + var/obj/item/gun/firearm_a = held_items[1] + var/obj/item/gun/firearm_b = held_items[2] + var/obj/item/ammo_box/clip + + // for(var/obj/item/gun/F in held_items) + // firearm_a = F + // break + + if((firearm_a && !firearm_b) || (!firearm_a && firearm_b)) + for(var/obj/item/ammo_box/C in equipped_belt.contents) //We surely have to find at least the first speedloader, otherwise the following for doesn't know what to do + clip = C + break + for(var/obj/item/ammo_box/C in equipped_belt.contents) //Code didn't find a gun? Let's check if there are clips or speedloaders with ammo in it. + if(C.stored_ammo.len >= clip.stored_ammo.len) + clip = C + + if(firearm_a) + if(clip && !clip.on_found(src)) //if there's no firearm, return the fullest speedloader + firearm_a.attackby(clip, src) + SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, GLOB.smart_gunreload_previous_magazine, src) + GLOB.smart_gunreload_previous_magazine = null + return + if(firearm_b) + if(clip && !clip.on_found(src)) //if there's no firearm, return the fullest speedloader + firearm_b.attackby(clip, src) + SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, GLOB.smart_gunreload_previous_magazine, src) + GLOB.smart_gunreload_previous_magazine = null + return + + //let's allow player to akimbo reload guns + if(firearm_a && firearm_b) + for(var/obj/item/ammo_box/C in equipped_belt.contents) //We surely have to find at least the first speedloader, otherwise the following for doesn't know what to do + clip = C + break + for(var/obj/item/ammo_box/C in equipped_belt.contents) //Code didn't find a gun? Let's check if there are clips or speedloaders with ammo in it. + if(C.stored_ammo.len >= clip.stored_ammo.len) + clip = C + + if(clip && !clip.on_found(src)) //if there's no firearm, return the fullest speedloader + firearm_a.attackby(clip, src) + SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, GLOB.smart_gunreload_previous_magazine, src) + GLOB.smart_gunreload_previous_magazine = null + + for(var/obj/item/ammo_box/C in equipped_belt.contents) //We surely have to find at least the first speedloader, otherwise the following for doesn't know what to do + clip = C + break + for(var/obj/item/ammo_box/C in equipped_belt.contents) //Code didn't find a gun? Let's check if there are clips or speedloaders with ammo in it. + if(C.stored_ammo.len >= clip.stored_ammo.len) + clip = C + + if(clip && !clip.on_found(src)) //if there's no firearm, return the fullest speedloader + firearm_b.attackby(clip, src) + SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, GLOB.smart_gunreload_previous_magazine, src) + GLOB.smart_gunreload_previous_magazine = null + return + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* + var/obj/item/thing = get_active_held_item() + var/obj/item/equipped_suit = get_item_by_slot(SLOT_S_STORE) + var/obj/item/equipped_belt = get_item_by_slot(SLOT_BELT) + var/obj/item/equipped_neck = get_item_by_slot(SLOT_NECK) + + if(!equipped_suit) + if(!thing) + to_chat(src, span_warning("You have no suit armor storage to take something out of!")) + return + if(thing.equip_to_best_slot(src)) + update_inv_hands() + return + else if(!equipped_belt) + if(!thing) + to_chat(src, span_warning("You have no belt storage to take something out of!")) + return + if(equip_to_slot_if_possible(thing, INV_SLOTBIT_BELT)) + update_inv_hands() + return + else if(!equipped_neck) + if(!thing) + to_chat(src, span_warning("You have no holster to take something out of!")) + return + if(equip_to_slot_if_possible(thing, INV_SLOTBIT_NECK)) + update_inv_hands() + return + + + if(!SEND_SIGNAL(equipped_suit, COMSIG_CONTAINS_STORAGE)) //not a storage item + if(!thing) + equipped_suit.attack_hand(src) + else + to_chat(src, span_warning("You can't fit anything in your suit storage!")) + return + else if(!SEND_SIGNAL(equipped_belt, COMSIG_CONTAINS_STORAGE)) //not a storage item + if(!thing) + equipped_belt.attack_hand(src) + else + to_chat(src, span_warning("You can't fit anything in your belt storage!")) + return + else if(!SEND_SIGNAL(equipped_neck, COMSIG_CONTAINS_STORAGE)) //not a storage item + if(!thing) + equipped_neck.attack_hand(src) + else + to_chat(src, span_warning("You can't fit anything in your holster!")) + return + + + if(thing) //put thing in storage + if(!SEND_SIGNAL(equipped_suit, COMSIG_TRY_STORAGE_INSERT, thing, src)) + to_chat(src, span_warning("This item is too big to fit the suit armor storage!")) + else if(!SEND_SIGNAL(equipped_belt, COMSIG_TRY_STORAGE_INSERT, thing, src)) + to_chat(src, span_warning("This item is too big to fit the belt storage!")) + else if(!SEND_SIGNAL(equipped_neck, COMSIG_TRY_STORAGE_INSERT, thing, src)) + to_chat(src, span_warning("This item is too big to fit the holster!")) + return + + + if(!equipped_suit.contents.len) //nothing to take out from suit storage + to_chat(src, span_warning("You can't fit anything in your armor storage!")) + return + else if(!equipped_belt.contents.len) //nothing to take out from belt + to_chat(src, span_warning("You can't fit anything in your belt storage!")) + return + else if(!equipped_neck.contents.len) //nothing to take out from holster + to_chat(src, span_warning("You can't fit anything in your holster!")) + return + + var/obj/item/gun/firearm = null + var/obj/item/ammo_box/clip + + for(var/obj/item/gun/F in equipped_neck.contents) //First thing, we want to obviously prioritize the unholstering of the gun. + firearm = F + break + for(var/obj/item/ammo_box/C in equipped_neck.contents) //We surely have to find at least the first speedloader, otherwise the following for doesn't know what to do + clip = C + break + for(var/obj/item/ammo_box/C in equipped_neck.contents) //Code didn't find a gun? Let's check if there are clips or speedloaders with ammo in it. + if(C.stored_ammo.len >= clip.stored_ammo.len) + clip = C + + var/obj/item/stored = equipped_neck.contents[equipped_neck.contents.len] + if(firearm && !firearm.on_found(src)) //return the firearm first + firearm.attack_hand(src) + return + else if(clip && !clip.on_found(src)) //if there's no firearm, return the fullest speedloader + clip.attack_hand(src) + return + else if(stored && !stored.on_found(src)) //if none of the above is in the holster, return whatever was inside + stored.attack_hand(src) + return + else + return +*/ diff --git a/code/modules/projectiles/guns/ballistic.dm b/code/modules/projectiles/guns/ballistic.dm index 89657a588d5..c9d501bbf8a 100644 --- a/code/modules/projectiles/guns/ballistic.dm +++ b/code/modules/projectiles/guns/ballistic.dm @@ -1,4 +1,5 @@ GLOBAL_LIST_EMPTY(gun_accepted_magazines) +GLOBAL_VAR_INIT(smart_gunreload_previous_magazine, 0) /obj/item/gun/ballistic desc = "Now comes in flavors like GUN. Uses 10mm ammo, for some reason." @@ -132,6 +133,7 @@ GLOBAL_LIST_EMPTY(gun_accepted_magazines) var/obj/item/ammo_box/oldmag if(istype(magazine)) oldmag = magazine + GLOB.smart_gunreload_previous_magazine = oldmag eject_magazine(user, en_bloc, !en_bloc, TRUE) //stop ejecting perfectly good shells! if(user.transferItemToLoc(new_mag, src)) magazine = new_mag diff --git a/code/modules/projectiles/guns/ballistic/pistol.dm b/code/modules/projectiles/guns/ballistic/pistol.dm index d61df49483d..a7ae8772c4a 100644 --- a/code/modules/projectiles/guns/ballistic/pistol.dm +++ b/code/modules/projectiles/guns/ballistic/pistol.dm @@ -742,7 +742,7 @@ item_state = "deagle" init_mag_type = /obj/item/ammo_box/magazine/m44/automag mag_type = /obj/item/ammo_box/magazine/m44/automag - weapon_class = WEAPON_CLASS_NORMAL + weapon_class = WEAPON_CLASS_SMALL weapon_weight = GUN_ONE_HAND_ONLY damage_multiplier = GUN_EXTRA_DAMAGE_T1 init_firemodes = list( diff --git a/code/modules/projectiles/guns/energy/plasmaf13.dm b/code/modules/projectiles/guns/energy/plasmaf13.dm index 2f3e10e52b8..0387d8ab914 100644 --- a/code/modules/projectiles/guns/energy/plasmaf13.dm +++ b/code/modules/projectiles/guns/energy/plasmaf13.dm @@ -91,7 +91,7 @@ ammo_type = list(/obj/item/ammo_casing/energy/plasma/pistol/glock) equipsound = 'sound/f13weapons/equipsounds/pistolplasequip.ogg' cell_type = /obj/item/stock_parts/cell/ammo/ec - weapon_class = WEAPON_CLASS_NORMAL + weapon_class = WEAPON_CLASS_SMALL weapon_weight = GUN_ONE_HAND_ONLY init_firemodes = list( /datum/firemode/semi_auto/slow @@ -104,7 +104,7 @@ desc = "This Glock 86 plasma pistol has had its magnetic housing chamber realigned to reduce the drain on its energy cell. Its efficiency has doubled, allowing it to fire more shots before the battery is expended." ammo_type = list(/obj/item/ammo_casing/energy/plasma/pistol/glock/extended) cell_type = /obj/item/stock_parts/cell/ammo/ec - weapon_class = WEAPON_CLASS_NORMAL + weapon_class = WEAPON_CLASS_SMALL weapon_weight = GUN_ONE_HAND_ONLY //Plasma Rifle diff --git a/fortune13.dme b/fortune13.dme index 0d1b22f5b58..511b42d3078 100644 --- a/fortune13.dme +++ b/fortune13.dme @@ -3211,7 +3211,7 @@ #include "code\modules\procedural_mapping\mapGenerators\syndicate.dm" #include "code\modules\projectiles\ammo_casing_gun_sound_properties.dm" #include "code\modules\projectiles\gun.dm" -#include "code\modules\projectiles\gun_keybinds.dm" +#include "code\modules\projectiles\gun_reload.dm" #include "code\modules\projectiles\pins.dm" #include "code\modules\projectiles\projectile.dm" #include "code\modules\projectiles\ammunition\_ammunition.dm"