Skip to content

Commit

Permalink
Blob damage now uses a shared take_damage() proc on /atom.
Browse files Browse the repository at this point in the history
  • Loading branch information
MistakeNot4892 committed Oct 9, 2023
1 parent 2c43f25 commit 8ace93d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 39 deletions.
5 changes: 5 additions & 0 deletions code/game/atom_damage.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/atom/proc/take_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0, var/used_weapon = null, var/armor_pen, var/silent = FALSE, var/override_droplimb)
return FALSE

/atom/proc/heal_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0)
return
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/grenades/flashbang.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

for(var/obj/effect/blob/B in objs) //Blob damage here
var/damage = round(30/(get_dist(B,T)+1))
B.take_blob_damage(damage)
B.take_damage(damage, /decl/damage_handler/brute)

new /obj/effect/sparks(loc)
new /obj/effect/effect/smoke/illumination(loc, 5, 30, 1, "#ffffff")
Expand Down
82 changes: 47 additions & 35 deletions code/modules/blob/blob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@
var/maxHealth = 30
var/health
var/regen_rate = 5
var/brute_resist = 4.3
var/fire_resist = 0.8
var/laser_resist = 2 // Special resist for laser based weapons - Emitters or handheld energy weaponry. Damage is divided by this and THEN by fire_resist.

// TODO: make blobs use either damage handlers or an armour extension (or both?).
var/list/blob_damage_resistance = list(
ARMOR_BULLET = 4.3,
ARMOR_BOMB = 4.3,
ARMOR_MELEE = 4.3,
ARMOR_LASER = 2,
ARMOR_ENERGY = 0.8
)
var/static/list/blob_damage_immunity = list(
ARMOR_RAD,
ARMOR_BIO
)

var/expandType = /obj/effect/blob
var/secondary_core_growth_chance = 5 //% chance to grow a secondary blob core instead of whatever was suposed to grown. Secondary cores are considerably weaker, but still nasty.
var/damage_min = 15
Expand All @@ -43,7 +54,7 @@

/obj/effect/blob/explosion_act(var/severity)
SHOULD_CALL_PARENT(FALSE)
take_blob_damage(rand(140 - (severity * 40), 140 - (severity * 20)) / brute_resist)
take_damage(rand(140 - (severity * 40), 140 - (severity * 20)), /decl/damage_handler/brute)

/obj/effect/blob/on_update_icon()
if(health > maxHealth / 2)
Expand All @@ -57,7 +68,19 @@
return
attempt_attack(global.alldirs)

/obj/effect/blob/proc/take_blob_damage(var/damage)
/obj/effect/blob/take_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0, var/used_weapon = null, var/armor_pen, var/silent = FALSE, var/override_droplimb)

var/decl/damage_handler/damage_type_data = GET_DECL(damage_type)
var/armor_key = damage_type_data?.get_armor_key(damage_flags)
if(armor_key in blob_damage_immunity)
return FALSE

if(armor_key in blob_damage_resistance)
damage = round(damage / blob_damage_resistance[armor_key])

if(damage <= 0)
return FALSE

health -= damage
if(health < 0)
playsound(loc, 'sound/effects/splat.ogg', 50, 1)
Expand Down Expand Up @@ -150,17 +173,6 @@
continue
attack_living(victim)

/obj/effect/blob/bullet_act(var/obj/item/projectile/Proj)
if(!Proj)
return

switch(Proj.damage_type)
if(/decl/damage_handler/brute)
take_blob_damage(Proj.damage / brute_resist)
if(/decl/damage_handler/burn)
take_blob_damage((Proj.damage / laser_resist) / fire_resist)
return 0

/obj/effect/blob/attackby(var/obj/item/W, var/mob/user)
user.setClickCooldown(DEFAULT_ATTACK_COOLDOWN)
user.do_attack_animation(src)
Expand All @@ -179,17 +191,9 @@
to_chat(user, SPAN_WARNING("\The [src] has already been pruned."))
return

var/damage = 0
switch(W.damtype)
if(/decl/damage_handler/burn)
damage = (W.force / fire_resist)
if(IS_WELDER(W))
playsound(loc, 'sound/items/Welder.ogg', 100, 1)
if(/decl/damage_handler/brute)
damage = (W.force / brute_resist)

take_blob_damage(damage)
return
take_damage(damage, W.damtype)

Check failure on line 194 in code/modules/blob/blob.dm

View workflow job for this annotation

GitHub Actions / DreamChecker

undefined var: "damage"
if(IS_WELDER(W) && W.damtype == /decl/damage_handler/burn)
playsound(loc, 'sound/items/Welder.ogg', 100, 1)

/obj/effect/blob/core
name = "master nucleus"
Expand Down Expand Up @@ -219,28 +223,36 @@ regen() will cover update_icon() for this proc
/obj/effect/blob/core/proc/process_core_health()
switch(get_health_percent())
if(75 to INFINITY)
brute_resist = 3.5
fire_resist = 2
blob_damage_resistance[ARMOR_BULLET] = 3.5
blob_damage_resistance[ARMOR_MELEE] = 3.5
blob_damage_resistance[ARMOR_BOMB] = 3.5
blob_damage_resistance[ARMOR_ENERGY] = 2
attack_freq = 5
regen_rate = 2
times_to_pulse = 4
if(reported_low_damage)
report_shield_status("high")
if(50 to 74)
brute_resist = 2.5
fire_resist = 1.5
blob_damage_resistance[ARMOR_BULLET] = 2.5
blob_damage_resistance[ARMOR_MELEE] = 2.5
blob_damage_resistance[ARMOR_BOMB] = 2.5
blob_damage_resistance[ARMOR_ENERGY] = 1.5
attack_freq = 4
regen_rate = 3
times_to_pulse = 3
if(34 to 49)
brute_resist = 1
fire_resist = 0.8
blob_damage_resistance[ARMOR_BULLET] = 1
blob_damage_resistance[ARMOR_MELEE] = 1
blob_damage_resistance[ARMOR_BOMB] = 1
blob_damage_resistance[ARMOR_ENERGY] = 0.8
attack_freq = 3
regen_rate = 4
times_to_pulse = 2
if(-INFINITY to 33)
brute_resist = 0.5
fire_resist = 0.3
blob_damage_resistance[ARMOR_BULLET] = 0.5
blob_damage_resistance[ARMOR_MELEE] = 0.5
blob_damage_resistance[ARMOR_BOMB] = 0.5
blob_damage_resistance[ARMOR_ENERGY] = 0.3
regen_rate = 5
times_to_pulse = 1
if(!reported_low_damage)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_damage.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
return my_species.total_health - health
return 0

/mob/living/proc/heal_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0)
/mob/living/heal_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0)
if(damage < 0)
return take_damage(abs(damage), damage_type, def_zone, damage_flags)
return resolve_damage_handler(damage_type)?.heal_mob_damage(src, damage)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/mob_grabs.dm
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// Casting stubs for grabs, check /mob/living for full definition.
/mob/proc/take_damage(var/damage, var/damage_type = /decl/damage_handler/brute, var/def_zone = null, var/damage_flags = 0, var/used_weapon = null, var/armor_pen, var/silent = FALSE, var/override_droplimb)
return FALSE
/mob/proc/get_blocked_ratio(def_zone, damage_type, damage_flags, armor_pen, damage)
return
/mob/proc/standard_weapon_hit_effects(obj/item/I, mob/living/user, var/effective_force, var/hit_zone)
Expand Down
1 change: 1 addition & 0 deletions nebula.dme
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@
#include "code\datums\wires\vending.dm"
#include "code\datums\wires\wire_description.dm"
#include "code\datums\wires\wires.dm"
#include "code\game\atom_damage.dm"
#include "code\game\atoms.dm"
#include "code\game\atoms_fluids.dm"
#include "code\game\atoms_init.dm"
Expand Down

0 comments on commit 8ace93d

Please sign in to comment.