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

Refactor of ammo and it's children file to clean a bit BE code. #4886

Closed
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
62 changes: 61 additions & 1 deletion code/datums/ammo/ammo.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/datum/ammo
var/name = "generic bullet"
//Icon state when a human is permanently killed with it by execution/suicide.
/// Icon state when a human is permanently killed with it by execution/suicide.
var/headshot_state = null
var/icon = 'icons/obj/items/weapons/projectiles.dmi'
var/icon_state = "bullet"
Expand Down Expand Up @@ -244,3 +244,63 @@

var/datum/reagent/R = new flamer_reagent_type()
new /obj/flamer_fire(T, cause_data, R)

//battle execution code.
// handle battlefield execution check if BE can be executed
/datum/ammo/proc/handle_battlefield_execution(datum/ammo/firing_ammo, mob/living/hit_mob, obj/projectile/firing_projectile, mob/living/user, obj/item/weapon/gun/fired_from)
SIGNAL_HANDLER

if(!user || hit_mob == user || user.zone_selected != "head" || user.a_intent != INTENT_HARM || !ishuman_strict(hit_mob))
return

if(!skillcheck(user, SKILL_EXECUTION, SKILL_EXECUTION_TRAINED))
to_chat(user, SPAN_DANGER("You don't know how to execute someone correctly."))
return

var/mob/living/carbon/human/execution_target = hit_mob

if(execution_target.status_flags & PERMANENTLY_DEAD)
to_chat(user, SPAN_DANGER("[execution_target] has already been executed!"))
return

INVOKE_ASYNC(src, PROC_REF(attempt_battlefield_execution), src, execution_target, firing_projectile, user, fired_from)

return COMPONENT_CANCEL_AMMO_POINT_BLANK

/datum/ammo/proc/attempt_battlefield_execution(datum/ammo/firing_ammo, mob/living/carbon/human/execution_target, obj/projectile/firing_projectile, mob/living/user, obj/item/weapon/gun/fired_from)
user.affected_message(execution_target,
SPAN_HIGHDANGER("You aim \the [fired_from] at [execution_target]'s head!"),
SPAN_HIGHDANGER("[user] aims \the [fired_from] directly at your head!"),
SPAN_DANGER("[user] aims \the [fired_from] at [execution_target]'s head!"))

user.next_move += 1.1 SECONDS //PB has no click delay; readding it here to prevent people accidentally queuing up multiple executions.

if(!do_after(user, 1 SECONDS, INTERRUPT_ALL, BUSY_ICON_HOSTILE) || !user.Adjacent(execution_target))
fired_from.delete_bullet(firing_projectile, TRUE)
return

if(!(fired_from.flags_gun_features & GUN_SILENCED))
playsound(user, fired_from.fire_sound, fired_from.firesound_volume, FALSE)
else
playsound(user, fired_from.fire_sound, 25, FALSE)

shake_camera(user, 1, 2)

execution_target.apply_damage(damage * 3, BRUTE, "head", no_limb_loss = TRUE, permanent_kill = TRUE) //Apply gobs of damage and make sure they can't be revived later...
execution_target.apply_damage(200, OXY) //...fill out the rest of their health bar with oxyloss...
execution_target.death(create_cause_data("execution", user)) //...make certain they're properly dead...
shake_camera(execution_target, 3, 4)
execution_target.update_headshot_overlay(headshot_state) //...and add a gory headshot overlay.

execution_target.visible_message(SPAN_HIGHDANGER(uppertext("[execution_target] WAS EXECUTED!")), \
SPAN_HIGHDANGER("You WERE EXECUTED!"))

user.count_niche_stat(STATISTICS_NICHE_EXECUTION, 1, firing_projectile.weapon_cause_data?.cause_name)

var/area/execution_area = get_area(execution_target)

msg_admin_attack(FONT_SIZE_HUGE("[key_name(usr)] has battlefield executed [key_name(execution_target)] in [get_area(usr)] ([usr.loc.x],[usr.loc.y],[usr.loc.z])."), usr.loc.x, usr.loc.y, usr.loc.z)
log_attack("[key_name(usr)] battlefield executed [key_name(execution_target)] at [execution_area.name].")

if(flags_ammo_behavior & AMMO_EXPLOSIVE)
execution_target.gib()
59 changes: 0 additions & 59 deletions code/datums/ammo/bullet/bullet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,62 +20,3 @@
shrapnel_chance = SHRAPNEL_CHANCE_TIER_1
shrapnel_type = /obj/item/shard/shrapnel
shell_speed = AMMO_SPEED_TIER_4

/datum/ammo/bullet/proc/handle_battlefield_execution(datum/ammo/firing_ammo, mob/living/hit_mob, obj/projectile/firing_projectile, mob/living/user, obj/item/weapon/gun/fired_from)
SIGNAL_HANDLER

if(!user || hit_mob == user || user.zone_selected != "head" || user.a_intent != INTENT_HARM || !ishuman_strict(hit_mob))
return

if(!skillcheck(user, SKILL_EXECUTION, SKILL_EXECUTION_TRAINED))
to_chat(user, SPAN_DANGER("You don't know how to execute someone correctly."))
return

var/mob/living/carbon/human/execution_target = hit_mob

if(execution_target.status_flags & PERMANENTLY_DEAD)
to_chat(user, SPAN_DANGER("[execution_target] has already been executed!"))
return

INVOKE_ASYNC(src, PROC_REF(attempt_battlefield_execution), src, execution_target, firing_projectile, user, fired_from)

return COMPONENT_CANCEL_AMMO_POINT_BLANK

/datum/ammo/bullet/proc/attempt_battlefield_execution(datum/ammo/firing_ammo, mob/living/carbon/human/execution_target, obj/projectile/firing_projectile, mob/living/user, obj/item/weapon/gun/fired_from)
user.affected_message(execution_target,
SPAN_HIGHDANGER("You aim \the [fired_from] at [execution_target]'s head!"),
SPAN_HIGHDANGER("[user] aims \the [fired_from] directly at your head!"),
SPAN_DANGER("[user] aims \the [fired_from] at [execution_target]'s head!"))

user.next_move += 1.1 SECONDS //PB has no click delay; readding it here to prevent people accidentally queuing up multiple executions.

if(!do_after(user, 1 SECONDS, INTERRUPT_ALL, BUSY_ICON_HOSTILE) || !user.Adjacent(execution_target))
fired_from.delete_bullet(firing_projectile, TRUE)
return

if(!(fired_from.flags_gun_features & GUN_SILENCED))
playsound(user, fired_from.fire_sound, fired_from.firesound_volume, FALSE)
else
playsound(user, fired_from.fire_sound, 25, FALSE)

shake_camera(user, 1, 2)

execution_target.apply_damage(damage * 3, BRUTE, "head", no_limb_loss = TRUE, permanent_kill = TRUE) //Apply gobs of damage and make sure they can't be revived later...
execution_target.apply_damage(200, OXY) //...fill out the rest of their health bar with oxyloss...
execution_target.death(create_cause_data("execution", user)) //...make certain they're properly dead...
shake_camera(execution_target, 3, 4)
execution_target.update_headshot_overlay(headshot_state) //...and add a gory headshot overlay.

execution_target.visible_message(SPAN_HIGHDANGER(uppertext("[execution_target] WAS EXECUTED!")), \
SPAN_HIGHDANGER("You WERE EXECUTED!"))

user.count_niche_stat(STATISTICS_NICHE_EXECUTION, 1, firing_projectile.weapon_cause_data?.cause_name)

var/area/execution_area = get_area(execution_target)

msg_admin_attack(FONT_SIZE_HUGE("[key_name(usr)] has battlefield executed [key_name(execution_target)] in [get_area(usr)] ([usr.loc.x],[usr.loc.y],[usr.loc.z])."), usr.loc.x, usr.loc.y, usr.loc.z)
log_attack("[key_name(usr)] battlefield executed [key_name(execution_target)] at [execution_area.name].")

if(flags_ammo_behavior & AMMO_EXPLOSIVE)
execution_target.gib()

4 changes: 0 additions & 4 deletions code/datums/ammo/bullet/pistol.dm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
// Used by M1911, Deagle and KT-42
/datum/ammo/bullet/pistol/heavy
name = "heavy pistol bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM
accuracy = -HIT_ACCURACY_TIER_3
accuracy_var_low = PROJECTILE_VARIANCE_TIER_6
damage = 55
Expand Down Expand Up @@ -167,8 +166,6 @@

/datum/ammo/bullet/pistol/highpower
name = "high-powered pistol bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM
Huffie56 marked this conversation as resolved.
Show resolved Hide resolved

accuracy = HIT_ACCURACY_TIER_3
damage = 36
penetration = ARMOR_PENETRATION_TIER_5
Expand All @@ -177,7 +174,6 @@
// Used by VP78 and Auto 9
/datum/ammo/bullet/pistol/squash
name = "squash-head pistol bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM
debilitate = list(0,0,0,0,0,0,0,2)

accuracy = HIT_ACCURACY_TIER_4
Expand Down
7 changes: 0 additions & 7 deletions code/datums/ammo/bullet/revolver.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
/datum/ammo/bullet/revolver
name = "revolver bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM

damage = 55
penetration = ARMOR_PENETRATION_TIER_1
accuracy = HIT_ACCURACY_TIER_1
Expand Down Expand Up @@ -74,7 +73,6 @@

/datum/ammo/bullet/revolver/upp
name = "heavy revolver bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM
penetration = ARMOR_PENETRATION_TIER_4
damage = 70

Expand Down Expand Up @@ -102,7 +100,6 @@
/datum/ammo/bullet/revolver/upp/shrapnel_bits
name = "small shrapnel"
icon_state = "shrapnelshot_bit"

max_range = 6
damage = 30
penetration = ARMOR_PENETRATION_TIER_4
Expand All @@ -113,22 +110,18 @@
/datum/ammo/bullet/revolver/small
name = "small revolver bullet"
headshot_state = HEADSHOT_OVERLAY_LIGHT

damage = 45

penetration = ARMOR_PENETRATION_TIER_3

/datum/ammo/bullet/revolver/small/hollowpoint
name = "small hollowpoint revolver bullet"
headshot_state = HEADSHOT_OVERLAY_MEDIUM

damage = 75 // way too strong because it's hard to make a good balance between HP and normal with this system, but the damage falloff is really strong
penetration = 0
damage_falloff = DAMAGE_FALLOFF_TIER_6

/datum/ammo/bullet/revolver/mateba
name = ".454 heavy revolver bullet"

damage = 60
damage_var_low = PROJECTILE_VARIANCE_TIER_8
damage_var_high = PROJECTILE_VARIANCE_TIER_6
Expand Down
Loading