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

Making smart holstering and trying to keybind a reload button [do NOT merge] #3229

Closed
wants to merge 3 commits into from
Closed
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
76 changes: 76 additions & 0 deletions code/modules/keybindings/keybind/combat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 13 additions & 3 deletions code/modules/keybindings/keybind/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
SA.quick_equip()


/*
/datum/keybinding/human/quick_equipbelt
hotkey_keys = list("ShiftE")
name = "quick_equipbelt"
Expand All @@ -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
12 changes: 11 additions & 1 deletion code/modules/mob/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
56 changes: 56 additions & 0 deletions code/modules/mob/living/carbon/human/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
62 changes: 0 additions & 62 deletions code/modules/projectiles/gun_keybinds.dm

This file was deleted.

Loading
Loading