diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 467e64af79..4565dbc25f 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -49,6 +49,8 @@ var/zoomdevicename = null //name used for message when binoculars/scope is used var/zoom = 0 //1 if item is actively being used to zoom. For scoped guns and binoculars. + var/embed_chance = -1 //-1 makes it calculate embed chance, 0 won't embed, and 100 will always embed + var/icon_override = null //Used to override hardcoded clothing dmis in human clothing proc. //** These specify item/icon overrides for _slots_ @@ -75,6 +77,14 @@ // Works similarly to worn sprite_sheets, except the alternate sprites are used when the clothing/refit_for_species() proc is called. var/list/sprite_sheets_obj = list() +/obj/item/New() + if(embed_chance == -1) + if(sharp) + embed_chance = force/w_class + else + embed_chance = force/(w_class*3) + ..() + /obj/item/equipped() ..() var/mob/living/M = loc diff --git a/code/game/objects/items/weapons/melee/energy.dm b/code/game/objects/items/weapons/melee/energy.dm index 2b2a2ee8b4..b3e3bb4e80 100644 --- a/code/game/objects/items/weapons/melee/energy.dm +++ b/code/game/objects/items/weapons/melee/energy.dm @@ -3,6 +3,7 @@ var/active_force var/active_throwforce var/active_w_class + var/active_embed_chance = 0 //In the off chance one of these is supposed to embed, you can just tweak this var sharp = 0 edge = 0 armor_penetration = 50 @@ -12,10 +13,10 @@ var/lcolor = "#0099FF" /obj/item/weapon/melee/energy/proc/activate(mob/living/user) - anchored = 1 if(active) return active = 1 + embed_chance = active_embed_chance force = active_force throwforce = active_throwforce sharp = 1 @@ -25,11 +26,11 @@ set_light(lrange, lpower, lcolor) /obj/item/weapon/melee/energy/proc/deactivate(mob/living/user) - anchored = 0 if(!active) return playsound(user, 'sound/weapons/saberoff.ogg', 50, 1) active = 0 + embed_chance = initial(embed_chance) force = initial(force) throwforce = initial(throwforce) sharp = initial(sharp) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 5ba80237ad..db59f6bc83 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -15,23 +15,25 @@ //Apply weapon damage var/weapon_sharp = is_sharp(I) var/weapon_edge = has_edge(I) + var/hit_embed_chance = I.embed_chance if(prob(getarmor(hit_zone, "melee"))) //melee armour provides a chance to turn sharp/edge weapon attacks into blunt ones weapon_sharp = 0 weapon_edge = 0 + hit_embed_chance = I.force/(I.w_class*3) apply_damage(effective_force, I.damtype, hit_zone, blocked, sharp=weapon_sharp, edge=weapon_edge, used_weapon=I) //Melee weapon embedded object code. - if (I && I.damtype == BRUTE && !I.anchored && !is_robot_module(I)) + if (I && I.damtype == BRUTE && !I.anchored && !is_robot_module(I) && I.embed_chance > 0) var/damage = effective_force if (blocked) damage *= (100 - blocked)/100 + hit_embed_chance *= (100 - blocked)/100 //blunt objects should really not be embedding in things unless a huge amount of force is involved - var/embed_chance = weapon_sharp? damage/I.w_class : damage/(I.w_class*3) var/embed_threshold = weapon_sharp? 5*I.w_class : 15*I.w_class - if(damage > embed_threshold && prob(embed_chance)) + if(damage > embed_threshold && prob(hit_embed_chance)) src.embed(I, hit_zone) return 1 diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index 2adb24665b..691861fba9 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -27,12 +27,14 @@ emp_act //Shrapnel if(P.can_embed()) var/armor = getarmor_organ(organ, "bullet") - if(prob(20 + max(P.damage - armor, -10))) - var/obj/item/weapon/material/shard/shrapnel/SP = new() - SP.name = (P.name != "shrapnel")? "[P.name] shrapnel" : "shrapnel" - SP.desc = "[SP.desc] It looks like it was fired from [P.shot_from]." - SP.loc = organ - organ.embed(SP) + if(!prob(armor/2)) //Even if the armor doesn't stop the bullet from hurting you, it might stop it from embedding. + var/hit_embed_chance = P.embed_chance + (P.damage - armor) //More damage equals more chance to embed + if(prob(max(hit_embed_chance, 0))) + var/obj/item/weapon/material/shard/shrapnel/SP = new() + SP.name = (P.name != "shrapnel")? "[P.name] shrapnel" : "shrapnel" + SP.desc = "[SP.desc] It looks like it was fired from [P.shot_from]." + SP.loc = organ + organ.embed(SP) return (..(P , def_zone)) diff --git a/code/modules/projectiles/guns/projectile/dartgun.dm b/code/modules/projectiles/guns/projectile/dartgun.dm index 79ca041ed5..8c64b297d1 100644 --- a/code/modules/projectiles/guns/projectile/dartgun.dm +++ b/code/modules/projectiles/guns/projectile/dartgun.dm @@ -2,8 +2,6 @@ name = "dart" icon_state = "dart" damage = 5 - sharp = 1 - embed = 1 //the dart is shot fast enough to pierce space suits, so I guess splintering inside the target can be a thing. Should be rare due to low damage. var/reagent_amount = 15 kill_count = 15 //shorter range diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index 81149cf2cb..484c1e0163 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -53,9 +53,10 @@ var/eyeblur = 0 var/drowsy = 0 var/agony = 0 - var/embed = 0 // whether or not the projectile can embed itself in the mob var/reflected = 0 // This should be set to 1 if reflected by any means, to prevent infinite reflections. + embed_chance = 0 //Base chance for a projectile to embed + var/hitscan = 0 // whether the projectile should be hitscan var/step_delay = 1 // the delay between iterations if not a hitscan projectile @@ -86,7 +87,7 @@ //Checks if the projectile is eligible for embedding. Not that it necessarily will. /obj/item/projectile/proc/can_embed() //embed must be enabled and damage type must be brute - if(!embed || damage_type != BRUTE) + if(embed_chance == 0 || damage_type != BRUTE) return 0 return 1 diff --git a/code/modules/projectiles/projectile/bullets.dm b/code/modules/projectiles/projectile/bullets.dm index 835a097267..f713f1cf1f 100644 --- a/code/modules/projectiles/projectile/bullets.dm +++ b/code/modules/projectiles/projectile/bullets.dm @@ -5,7 +5,7 @@ damage_type = BRUTE nodamage = 0 check_armour = "bullet" - embed = 1 + embed_chance = 20 //Modified in the actual embed process, but this should keep embed chance about the same sharp = 1 var/mob_passthrough_check = 0 @@ -140,7 +140,7 @@ name = "rubber bullet" damage = 5 agony = 40 - embed = 0 + embed_chance = 0 sharp = 0 check_armour = "melee" @@ -155,7 +155,7 @@ name = "beanbag" damage = 20 agony = 60 - embed = 0 + embed_chance = 0 sharp = 0 check_armour = "melee" @@ -172,7 +172,7 @@ /obj/item/projectile/bullet/shotgun/ion name = "ion slug" damage = 15 - embed = 0 + embed_chance = 0 sharp = 0 check_armour = "melee" @@ -224,7 +224,7 @@ /obj/item/projectile/bullet/burstbullet name = "exploding bullet" damage = 20 - embed = 0 + embed_chance = 0 edge = 1 /obj/item/projectile/bullet/gyro/on_hit(var/atom/target, var/blocked = 0) @@ -235,7 +235,7 @@ /obj/item/projectile/bullet/blank invisibility = 101 damage = 1 - embed = 0 + embed_chance = 0 /* Practice */ @@ -255,7 +255,7 @@ damage_type = HALLOSS damage = 0 nodamage = 1 - embed = 0 + embed_chance = 0 sharp = 0 /obj/item/projectile/bullet/pistol/cap/process() diff --git a/code/modules/projectiles/projectile/special.dm b/code/modules/projectiles/projectile/special.dm index 8ce0360c10..7ce94948fc 100644 --- a/code/modules/projectiles/projectile/special.dm +++ b/code/modules/projectiles/projectile/special.dm @@ -152,7 +152,7 @@ name = "bullet" icon_state = "bullet" damage = 1 // stop trying to murderbone with a fake gun dumbass!!! - embed = 0 // nope + embed_chance = 0 // nope nodamage = 1 damage_type = HALLOSS muzzle_type = /obj/effect/projectile/bullet/muzzle diff --git a/html/changelogs/Anewbe - Embed.yml b/html/changelogs/Anewbe - Embed.yml new file mode 100644 index 0000000000..f877242b9b --- /dev/null +++ b/html/changelogs/Anewbe - Embed.yml @@ -0,0 +1,37 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Anewbe + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Bullet armor has a higher chance of preventing an embed." + - tweak: "The actual system by which embed works has been changed. The overall effect should be negligible."