Skip to content

Commit

Permalink
Damage Effects and big mob improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Halonexus committed Dec 21, 2024
1 parent 0339de2 commit 5b73d45
Show file tree
Hide file tree
Showing 13 changed files with 139 additions and 51 deletions.
1 change: 1 addition & 0 deletions ModularTegustation/tegu_mobs/apocalypse_bird.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
occupied_tiles_left = 3
occupied_tiles_right = 3
occupied_tiles_up = 2
damage_effect_scale = 1.25
blood_volume = BLOOD_VOLUME_NORMAL
del_on_death = TRUE
death_message = "finally stops moving, falling to the ground."
Expand Down
3 changes: 3 additions & 0 deletions code/__HELPERS/game.dm
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@

return dist

/proc/get_dist_manhattan(atom/Loc1, atom/Loc2)
return abs(Loc1.x - Loc2.x) + abs(Loc1.y - Loc2.y)

/proc/circlerangeturfs(center=usr,radius=3)

var/turf/centerturf = get_turf(center)
Expand Down
5 changes: 4 additions & 1 deletion code/_onclick/click.dm
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,12 @@
if(CanReach(A,W))
if(W)
var/atom/target_thing = A
if((isturf(A) || iseffect(A)) && W.force > 10)
if(a_intent != INTENT_HARM && (isturf(A) || iseffect(A)) && W.force > 10)
var/turf/T = get_turf(A)
for(var/mob/living/L in T)
if(istype(L, /mob/living/simple_animal/projectile_blocker_dummy))
var/mob/living/simple_animal/projectile_blocker_dummy/pbd = L
L = pbd.parent
if(L.invisibility > see_invisible)
continue
if(L.stat != DEAD)
Expand Down
3 changes: 3 additions & 0 deletions code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@

for(var/turf/T in hit_turfs)
for(var/mob/M in T)
if(istype(M, /mob/living/simple_animal/projectile_blocker_dummy))
var/mob/living/simple_animal/projectile_blocker_dummy/pbd = M
M = pbd.parent
potential_targets |= M

potential_targets -= user
Expand Down
3 changes: 3 additions & 0 deletions code/_onclick/other_mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@
if(isturf(A) || iseffect(A))
var/turf/T = get_turf(A)
for(var/mob/living/L in T)
if(istype(L, /mob/living/simple_animal/projectile_blocker_dummy))
var/mob/living/simple_animal/projectile_blocker_dummy/pbd = L
L = pbd.parent
if(L.invisibility > see_invisible)
continue
if(L.stat != DEAD)
Expand Down
30 changes: 13 additions & 17 deletions code/modules/mob/living/carbon/human/damage_procs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@

//// Damage Effects
/mob/living/carbon/human/adjustRedLoss(amount, updating_health = TRUE, forced = FALSE)
if(stat != DEAD)
DamageEffect(amount, RED_DAMAGE)
. = ..()
//Failsafe
if(. && !forced)
if(. > 0)
new /obj/effect/temp_visual/damage_effect/red(get_turf(src))


/mob/living/carbon/human/adjustWhiteLoss(amount, updating_health = TRUE, forced = FALSE, white_healable = FALSE)
var/damage_amt = amount
if(sanity_lost && white_healable) // Heal sanity instead.
damage_amt *= -1
if(damage_amt > 0 && !forced)
new /obj/effect/temp_visual/damage_effect/white(get_turf(src))
if(stat != DEAD)
DamageEffect(damage_amt, WHITE_DAMAGE)
adjustSanityLoss(damage_amt, forced)
if(updating_health)
updatehealth()
Expand All @@ -27,29 +26,26 @@
var/damage_amt = amount
if(sanity_lost && white_healable) // Heal sanity instead.
damage_amt *= -1
if(amount > 0 && !forced)
new /obj/effect/temp_visual/damage_effect/black(get_turf(src))
if(stat != DEAD)
DamageEffect(amount, BLACK_DAMAGE)
adjustBruteLoss(amount, forced = forced)
adjustSanityLoss(damage_amt, forced = forced)
return damage_amt

/mob/living/carbon/human/adjustPaleLoss(amount, updating_health = TRUE, forced = FALSE)
if(stat != DEAD)
DamageEffect(amount, PALE_DAMAGE)
. = ..()
if(. && !forced)
if(. > 0)
new /obj/effect/temp_visual/damage_effect/pale(get_turf(src))

/mob/living/carbon/human/adjustToxLoss(amount, updating_health = TRUE, forced = FALSE)
if(stat != DEAD)
DamageEffect(amount, TOX)
. = ..()
if(. && !forced)
if(. > 0)
new /obj/effect/temp_visual/damage_effect/tox(get_turf(src))

/mob/living/carbon/human/adjustFireLoss(amount, updating_health = TRUE, forced = FALSE, required_status)
if(stat != DEAD)
DamageEffect(amount, BURN)
. = ..()
if(. && !forced)
if(. > 0)
new /obj/effect/temp_visual/damage_effect/burn(get_turf(src))

//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
offsets_pixel_y = list("south" = -8, "north" = -8, "west" = -8, "east" = -8)
transform = matrix(1.5, MATRIX_SCALE)
SetOccupiedTiles(1, 1, 1, 1)
damage_effect_scale = 1.2
startTeleport() //Let's Spaghettioodle out of here

/mob/living/simple_animal/hostile/abnormality/greed_king/proc/startTeleport()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,5 @@

/mob/living/simple_animal/hostile/abnormality/warden/bullet_act(obj/projectile/P)
visible_message(span_userdanger("[src] is unfazed by \the [P]!"))
new /obj/effect/temp_visual/healing/no_dam(get_turf(src))
P.Destroy()
1 change: 1 addition & 0 deletions code/modules/mob/living/simple_animal/animal_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@

if(temp_damage >= 0 && temp_damage <= force_threshold)
visible_message(span_warning("[src] looks unharmed!"))
DamageEffect(0, damagetype)
return FALSE

if(actuallydamage)
Expand Down
112 changes: 82 additions & 30 deletions code/modules/mob/living/simple_animal/hostile/hostile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
/// How willing a mob is to switch targets. More resistance means more aggro is required
var/target_switch_resistance

var/damage_effect_scale = 1

/mob/living/simple_animal/hostile/Initialize()
/*Update Speed overrides set speed and sets it
to the equivilent of move_to_delay. Basically
Expand Down Expand Up @@ -201,7 +203,6 @@
//register the attacker in our memory.
if(P.firer)
RegisterAggroValue(P.firer, P.damage, P.damage_type)
DamageEffect(P.damage, P.damage_type)
return ..()

/mob/living/simple_animal/hostile/attack_animal(mob/living/simple_animal/M, damage)
Expand Down Expand Up @@ -280,42 +281,93 @@
/*-------------------\
|Damage Visual Effect|
\-------------------*/

/mob/living/simple_animal/hostile/attack_threshold_check(damage, damagetype = BRUTE, armorcheck = MELEE, actuallydamage = TRUE)
//This used to also check actually damage but turns out melee weapons in item_attack.dm dont call actually damage.
if(stat != DEAD && (damagetype in list(RED_DAMAGE, WHITE_DAMAGE, BLACK_DAMAGE, PALE_DAMAGE)))
//To simplify things, if you bash a abnormality with a wrench it wont show any effect. --uhh it will though
DamageEffect(damagetype)
return ..()

/mob/living/simple_animal/hostile/proc/DamageEffect(damtype)
//Code stolen from attack_threshold_check() in animal_defense.dm
var/damage_modifier
if(islist(damage_coeff))
damage_modifier = damage_coeff[damtype]
else
damage_modifier = damage_coeff.getCoeff(damtype)

if(damage_modifier == 0)
//Visual Effect for immunity.
return new /obj/effect/temp_visual/healing/no_dam(get_turf(src))
if(damage_modifier < 0)
//Visual Effect for healing.
return new /obj/effect/temp_visual/healing(get_turf(src))

/mob/living/proc/DamageEffect(damage, damtype)
if(damage > 0)
switch(damtype)
if(RED_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/red(get_turf(src))
if(WHITE_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/white(get_turf(src))
if(BLACK_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/black(get_turf(src))
if(PALE_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/pale(get_turf(src))
if(BURN)
return new /obj/effect/temp_visual/damage_effect/burn(get_turf(src))
if(TOX)
return new /obj/effect/temp_visual/damage_effect/tox(get_turf(src))
else
return null

/mob/living/simple_animal/hostile/DamageEffect(damage, damtype)
var/obj/effect/dam_effect = null
if(!damage)
dam_effect = new /obj/effect/temp_visual/healing/no_dam(get_turf(src))
if(damage_effect_scale != 1)
dam_effect.transform *= damage_effect_scale
return dam_effect
if(damage < 0)
dam_effect = new /obj/effect/temp_visual/healing(get_turf(src))
if(damage_effect_scale != 1)
dam_effect.transform *= damage_effect_scale
return dam_effect
switch(damtype)
if(RED_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/red(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/red(get_turf(src))
if(WHITE_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/white(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/white(get_turf(src))
if(BLACK_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/black(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/black(get_turf(src))
if(PALE_DAMAGE)
return new /obj/effect/temp_visual/damage_effect/pale(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/pale(get_turf(src))
if(BURN)
return new /obj/effect/temp_visual/damage_effect/burn(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/burn(get_turf(src))
if(TOX)
return new /obj/effect/temp_visual/damage_effect/tox(get_turf(src))
dam_effect = new /obj/effect/temp_visual/damage_effect/tox(get_turf(src))
else
return null
if(damage_effect_scale != 1)
dam_effect.transform *= damage_effect_scale
if(length(projectile_blockers) > 0)
dam_effect.pixel_x += rand(-occupied_tiles_left_current * 32, occupied_tiles_right_current * 32)
dam_effect.pixel_y += rand(-occupied_tiles_down_current * 32, occupied_tiles_up_current * 32)
return dam_effect

/mob/living/simple_animal/hostile/adjustRedLoss(amount, updating_health, forced)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., RED_DAMAGE)

/mob/living/simple_animal/hostile/adjustWhiteLoss(amount, updating_health, forced, white_healable)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., WHITE_DAMAGE)

/mob/living/simple_animal/hostile/adjustBlackLoss(amount, updating_health, forced, white_healable)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., BLACK_DAMAGE)

/mob/living/simple_animal/hostile/adjustPaleLoss(amount, updating_health, forced)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., PALE_DAMAGE)

/mob/living/simple_animal/hostile/adjustFireLoss(amount, updating_health, forced)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., BURN)

/mob/living/simple_animal/hostile/adjustToxLoss(amount, updating_health, forced)
var/was_alive = stat != DEAD
. = ..()
if(was_alive)
DamageEffect(., TOX)

/*Used in LC13 abnormality calculations.
Moved here so we can use it for all hostiles.
Expand Down
21 changes: 21 additions & 0 deletions code/modules/mob/living/simple_animal/hostile/ordeal/amber.dm
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
should_projectile_blockers_change_orientation = TRUE
occupied_tiles_up = 1
offsets_pixel_x = list("south" = -16, "north" = -16, "west" = 0, "east" = -32)
offsets_pixel_y = list("south" = 9, "north" = -20, "west" = 0, "east" = 0)

/// This cooldown responds for both the burrowing and spawning in the dawns
var/burrow_cooldown
Expand Down Expand Up @@ -226,10 +227,25 @@

/mob/living/simple_animal/hostile/ordeal/amber_dusk/Initialize()
. = ..()
setDir(WEST)
soundloop = new(list(src), TRUE)
if(LAZYLEN(butcher_results))
addtimer(CALLBACK(src, PROC_REF(BurrowOut), get_turf(src)))

/mob/living/simple_animal/hostile/ordeal/amber_dusk/OnDirChange(atom/thing, dir, newdir)
. = ..()
if(stat == DEAD)
return
var/static/matrix/add_vertical_transform = matrix(0.8, 1.4, MATRIX_SCALE)
var/static/south_north = SOUTH | NORTH
var/static/east_west = EAST | WEST
var/combined = dir | newdir
if((combined & south_north) && (combined & east_west))
if(newdir & south_north)
transform = add_vertical_transform
else
transform = matrix()

/mob/living/simple_animal/hostile/ordeal/amber_dusk/Destroy()
QDEL_NULL(soundloop)
for(var/mob/living/simple_animal/hostile/ordeal/amber_bug/spawned/bug as anything in spawned_mobs)
Expand All @@ -249,6 +265,8 @@
if(LAZYLEN(butcher_results))
alpha = 255
offsets_pixel_x = list("south" = -16, "north" = -16, "west" = -16, "east" = -16)
offsets_pixel_y = list("south" = 0, "north" = 0, "west" = 0, "east" = 0)
transform = matrix()
soundloop.stop()
for(var/mob/living/simple_animal/hostile/ordeal/amber_bug/bug in spawned_mobs)
bug.can_burrow_solo = TRUE
Expand All @@ -257,6 +275,8 @@
/mob/living/simple_animal/hostile/ordeal/amber_dusk/revive(full_heal, admin_revive)
. = ..()
offsets_pixel_x = list("south" = -16, "north" = -16, "west" = 0, "east" = -32)
offsets_pixel_y = list("south" = 9, "north" = -20, "west" = 0, "east" = 0)
density = TRUE

/mob/living/simple_animal/hostile/ordeal/amber_dusk/proc/AttemptBirth()
var/max_spawn = clamp(length(GLOB.clients) * 2, 4, 8)
Expand Down Expand Up @@ -368,6 +388,7 @@
occupied_tiles_up = 2
offsets_pixel_x = list("south" = -96, "north" = -96, "west" = -96, "east" = -96)
offsets_pixel_y = list("south" = -16, "north" = -16, "west" = -16, "east" = -16)
damage_effect_scale = 1.25

blood_volume = BLOOD_VOLUME_NORMAL
death_sound = 'sound/effects/ordeals/amber/midnight_dead.ogg'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
guaranteed_butcher_results = list(/obj/item/food/meat/slab/robot = 16)
death_sound = 'sound/effects/ordeals/green/midnight_dead.ogg'
offsets_pixel_x = list("south" = -96, "north" = -96, "west" = -96, "east" = -96)
damage_effect_scale = 1.25

var/laser_cooldown
var/laser_cooldown_time = 20 SECONDS
Expand Down
8 changes: 5 additions & 3 deletions code/modules/mob/living/simple_animal/projectile_blocker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
return TRUE
if(!isturf(parent.loc))
return TRUE
if(parent.CanPassThroughBlocker(mover, target))
if(parent.CanPassThroughBlocker(mover, target, get_turf(src)))
return TRUE
return parent.CanPass(mover, target)

Expand Down Expand Up @@ -126,10 +126,12 @@
moveToNullspace()

///For letting some mobs walk through the blockers
/mob/living/simple_animal/proc/CanPassThroughBlocker(atom/movable/mover, turf/target)
/mob/living/simple_animal/proc/CanPassThroughBlocker(atom/movable/mover, turf/start, turf/destination)
return FALSE

/mob/living/simple_animal/hostile/CanPassThroughBlocker(atom/movable/mover, turf/target)
/mob/living/simple_animal/hostile/CanPassThroughBlocker(atom/movable/mover, turf/start, turf/destination)
if(isliving(mover) && faction_check_mob(mover))
return TRUE
if(isliving(mover) && get_dist_manhattan(get_turf(src), destination) > get_dist_manhattan(get_turf(src), start))
return TRUE
return FALSE

0 comments on commit 5b73d45

Please sign in to comment.