Skip to content

Commit

Permalink
smartgun reloading
Browse files Browse the repository at this point in the history
  • Loading branch information
Zonespace27 committed Nov 4, 2024
1 parent 683880a commit 940113f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 25 deletions.
27 changes: 2 additions & 25 deletions code/modules/mob/living/carbon/human/ai/brain/ai_brain_guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

currently_reloading = TRUE
currently_busy = TRUE
currently_firing = FALSE

var/obj/item/ammo_magazine/mag = primary_ammo_search()
if(!mag)
Expand All @@ -52,31 +53,7 @@
currently_reloading = FALSE
currently_busy = FALSE
return //soz
unholster_primary()
ensure_primary_hand(primary_weapon)
primary_weapon.unwield(tied_human)
sleep(short_action_delay * action_delay_mult)
if(!(primary_weapon?.flags_gun_features & GUN_INTERNAL_MAG) && primary_weapon?.current_mag)
primary_weapon?.unload(tied_human, FALSE, TRUE, FALSE)
tied_human.swap_hand()
sleep(micro_action_delay * action_delay_mult)
equip_item_from_equipment_map(HUMAN_AI_AMMUNITION, mag)
sleep(short_action_delay * action_delay_mult)
if(istype(mag, /obj/item/ammo_magazine/handful))
for(var/i in 1 to mag.current_rounds)
primary_weapon?.attackby(mag, tied_human)
sleep(micro_action_delay * action_delay_mult)
if(!QDELETED(mag) && (mag.current_rounds > 0))
var/storage_slot = storage_has_room(mag)
if(storage_slot)
store_item(mag, storage_slot)
else
tied_human.drop_held_item(mag)
else
primary_weapon?.attackby(mag, tied_human)
sleep(short_action_delay * action_delay_mult)
tied_human.swap_hand()
primary_weapon?.wield(tied_human)
gun_data.do_reload(mag, tied_human, src)
#ifdef TESTING
to_chat(world, "[tied_human.name] reloaded [primary_weapon].")
#endif
Expand Down
48 changes: 48 additions & 0 deletions code/modules/mob/living/carbon/human/ai/firearm_appraisal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,33 @@ GLOBAL_LIST_INIT_TYPED(firearm_appraisals, /datum/firearm_appraisal, build_firea
firearm.flags_gun_features ^= GUN_TRIGGER_SAFETY
firearm.gun_safety_handle(user)

/datum/firearm_appraisal/proc/do_reload(obj/item/ammo_magazine/mag, mob/living/carbon/user, datum/human_ai_brain/AI)
AI.unholster_primary()
AI.ensure_primary_hand(AI.primary_weapon)
AI.primary_weapon.unwield(user)
sleep(AI.short_action_delay * AI.action_delay_mult)
if(!(AI.primary_weapon?.flags_gun_features & GUN_INTERNAL_MAG) && AI.primary_weapon?.current_mag)
AI.primary_weapon?.unload(user, FALSE, TRUE, FALSE)
user.swap_hand()
sleep(AI.micro_action_delay * AI.action_delay_mult)
AI.equip_item_from_equipment_map(HUMAN_AI_AMMUNITION, mag)
sleep(AI.short_action_delay * AI.action_delay_mult)
if(istype(mag, /obj/item/ammo_magazine/handful))
for(var/i in 1 to mag.current_rounds)
AI.primary_weapon?.attackby(mag, user)
sleep(AI.micro_action_delay * AI.action_delay_mult)
if(!QDELETED(mag) && (mag.current_rounds > 0))
var/storage_slot = AI.storage_has_room(mag)
if(storage_slot)
AI.store_item(mag, storage_slot)
else
user.drop_held_item(mag)
else
AI.primary_weapon?.attackby(mag, user)
sleep(AI.short_action_delay * AI.action_delay_mult)
user.swap_hand()
AI.primary_weapon?.wield(user)

/datum/firearm_appraisal/sniper
maximum_range = 30
burst_amount_max = 1
Expand All @@ -52,6 +79,27 @@ GLOBAL_LIST_INIT_TYPED(firearm_appraisals, /datum/firearm_appraisal, build_firea
/obj/item/weapon/gun/smartgun,
)

/datum/firearm_appraisal/smartgun/do_reload(obj/item/ammo_magazine/mag, mob/living/carbon/user, datum/human_ai_brain/AI)
AI.unholster_primary()
AI.ensure_primary_hand(AI.primary_weapon)
AI.primary_weapon.unwield(user)
user.swap_hand()
AI.primary_weapon.clicked(user, list("alt" = TRUE))
sleep(AI.short_action_delay * AI.action_delay_mult)
user.swap_hand()
if(!(AI.primary_weapon?.flags_gun_features & GUN_INTERNAL_MAG) && AI.primary_weapon?.current_mag)
AI.primary_weapon?.unload(user, FALSE, TRUE, FALSE)
user.swap_hand()
sleep(AI.micro_action_delay * AI.action_delay_mult)
AI.equip_item_from_equipment_map(HUMAN_AI_AMMUNITION, mag)
sleep(AI.short_action_delay * AI.action_delay_mult)
AI.primary_weapon?.attackby(mag, user)
sleep(AI.short_action_delay * AI.action_delay_mult)
AI.primary_weapon.clicked(user, list("alt" = TRUE))
sleep(AI.short_action_delay * AI.action_delay_mult)
user.swap_hand()
AI.primary_weapon?.wield(user)

/datum/firearm_appraisal/smg
burst_amount_max = 10
minimum_range = 1
Expand Down

0 comments on commit 940113f

Please sign in to comment.