diff --git a/code/datums/elements/move_force_on_death.dm b/code/datums/elements/move_force_on_death.dm new file mode 100644 index 00000000000..af2560d000c --- /dev/null +++ b/code/datums/elements/move_force_on_death.dm @@ -0,0 +1,49 @@ +/** + * Element to change a mob's move forces on death and reset them on living + */ +/datum/element/change_force_on_death + element_flags = ELEMENT_BESPOKE + argument_hash_start_idx = 2 + ///Our move force + var/move_force + /// our resist move force + var/move_resist + /// how much we resist pulling + var/pull_force + +/datum/element/change_force_on_death/Attach(datum/target, move_force, move_resist, pull_force) + . = ..() + + if(!isliving(target)) + return ELEMENT_INCOMPATIBLE + + RegisterSignal(target, COMSIG_LIVING_DEATH, PROC_REF(on_death)) + RegisterSignal(target, COMSIG_LIVING_REVIVE, PROC_REF(on_revive)) + + if(!isnull(move_force)) + src.move_force = move_force + if(!isnull(move_resist)) + src.move_resist = move_resist + if(!isnull(pull_force)) + src.pull_force = pull_force + +/datum/element/change_force_on_death/Detach(datum/target) + . = ..() + UnregisterSignal(target, list(COMSIG_LIVING_DEATH, COMSIG_LIVING_REVIVE)) + +/datum/element/change_force_on_death/proc/on_death(mob/living/source) + SIGNAL_HANDLER + + if(!isnull(move_force)) + source.move_force = move_force + if(!isnull(move_resist)) + source.move_resist = move_resist + if(!isnull(pull_force)) + source.pull_force = pull_force + +/datum/element/change_force_on_death/proc/on_revive(mob/living/source) + SIGNAL_HANDLER + + source.move_force = initial(source.move_force) + source.move_resist = initial(source.move_resist) + source.pull_force = initial(source.pull_force) diff --git a/code/modules/mob/living/basic/lavaland/goliath/goliath.dm b/code/modules/mob/living/basic/lavaland/goliath/goliath.dm index b99e254853e..f5556cb15cd 100644 --- a/code/modules/mob/living/basic/lavaland/goliath/goliath.dm +++ b/code/modules/mob/living/basic/lavaland/goliath/goliath.dm @@ -55,6 +55,13 @@ AddElement(/datum/element/ai_retaliate) AddElement(/datum/element/footstep, FOOTSTEP_MOB_HEAVY) AddElement(/datum/element/basic_eating, heal_amt = 10, food_types = goliath_foods) + AddElement(\ + /datum/element/change_force_on_death,\ + move_force = MOVE_FORCE_DEFAULT,\ + move_resist = MOVE_RESIST_DEFAULT,\ + pull_force = PULL_FORCE_DEFAULT,\ + ) + AddComponent(/datum/component/ai_target_timer) AddComponent(/datum/component/basic_mob_attack_telegraph) AddComponentFrom(INNATE_TRAIT, /datum/component/shovel_hands) @@ -92,20 +99,6 @@ if (saddled) . += span_info("Someone appears to have attached a saddle to this one.") -/mob/living/basic/mining/goliath/revive(full_heal_flags, excess_healing, force_grab_ghost) - . = ..() - if (!.) - return - move_force = initial(move_force) - move_resist = initial(move_resist) - pull_force = initial(pull_force) - -/mob/living/basic/mining/goliath/death(gibbed) - move_force = MOVE_FORCE_DEFAULT - move_resist = MOVE_RESIST_DEFAULT - pull_force = PULL_FORCE_DEFAULT - return ..() - // Goliaths can summon tentacles more frequently as they take damage, scary. /mob/living/basic/mining/goliath/apply_damage(damage, damagetype, def_zone, blocked, forced, spread_damage, wound_bonus, bare_wound_bonus, sharpness, attack_direction, attacking_item) . = ..() diff --git a/code/modules/mob/living/basic/lavaland/mook/mook.dm b/code/modules/mob/living/basic/lavaland/mook/mook.dm index da833437715..d36973cff03 100644 --- a/code/modules/mob/living/basic/lavaland/mook/mook.dm +++ b/code/modules/mob/living/basic/lavaland/mook/mook.dm @@ -12,16 +12,14 @@ maxHealth = 150 faction = list(FACTION_MINING, FACTION_NEUTRAL) health = 150 - move_resist = MOVE_FORCE_OVERPOWERING + move_resist = MOVE_FORCE_VERY_STRONG melee_damage_lower = 8 melee_damage_upper = 8 - pass_flags_self = LETPASSTHROW attack_sound = 'sound/weapons/rapierhit.ogg' attack_vis_effect = ATTACK_EFFECT_SLASH death_sound = 'sound/voice/mook_death.ogg' ai_controller = /datum/ai_controller/basic_controller/mook/support speed = 5 - pixel_x = -16 base_pixel_x = -16 pixel_y = -16 @@ -49,6 +47,10 @@ /mob/living/basic/mining/mook/Initialize(mapload) . = ..() + AddElement(\ + /datum/element/change_force_on_death,\ + move_resist = MOVE_RESIST_DEFAULT,\ + ) AddComponent(/datum/component/ai_retaliate_advanced, CALLBACK(src, PROC_REF(attack_intruder))) var/datum/action/cooldown/mob_cooldown/mook_ability/mook_jump/jump = new(src) jump.Grant(src) @@ -154,6 +156,9 @@ /mob/living/basic/mining/mook/CanAllowThrough(atom/movable/mover, border_dir) . = ..() + if(.) + return TRUE + if(!istype(mover, /mob/living/basic/mining/mook)) return FALSE diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm index b13dba948d0..1aadefd4153 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/drake.dm @@ -92,6 +92,7 @@ RegisterSignal(src, COMSIG_MOB_ABILITY_FINISHED, PROC_REF(finished_attack)) RegisterSignal(src, COMSIG_SWOOP_INVULNERABILITY_STARTED, PROC_REF(swoop_invulnerability_started)) RegisterSignal(src, COMSIG_LAVA_ARENA_FAILED, PROC_REF(on_arena_fail)) + AddElement(/datum/element/change_force_on_death, move_force = MOVE_FORCE_DEFAULT) /mob/living/simple_animal/hostile/megafauna/dragon/Destroy() QDEL_NULL(fire_cone) @@ -100,16 +101,6 @@ QDEL_NULL(lava_swoop) return ..() -/mob/living/simple_animal/hostile/megafauna/dragon/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE) - . = ..() - if(!.) - return - pull_force = MOVE_FORCE_OVERPOWERING - -/mob/living/simple_animal/hostile/megafauna/dragon/death(gibbed) - move_force = MOVE_FORCE_DEFAULT - return ..() - /mob/living/simple_animal/hostile/megafauna/dragon/OpenFire() if(swooping) return diff --git a/code/modules/mob/living/simple_animal/hostile/mining_mobs/polarbear.dm b/code/modules/mob/living/simple_animal/hostile/mining_mobs/polarbear.dm index d70a8f9eaa2..0b163124a8e 100644 --- a/code/modules/mob/living/simple_animal/hostile/mining_mobs/polarbear.dm +++ b/code/modules/mob/living/simple_animal/hostile/mining_mobs/polarbear.dm @@ -36,6 +36,15 @@ /// Message for when the polar bear starts to attack faster var/aggressive_message_said = FALSE +/mob/living/simple_animal/hostile/asteroid/polarbear/Initialize(mapload) + . = ..() + AddElement(\ + /datum/element/change_force_on_death,\ + move_force = MOVE_FORCE_DEFAULT,\ + move_resist = MOVE_RESIST_DEFAULT,\ + pull_force = PULL_FORCE_DEFAULT,\ + ) + /mob/living/simple_animal/hostile/asteroid/polarbear/adjustHealth(amount, updating_health = TRUE, forced = FALSE) . = ..() if(health > maxHealth*0.5) @@ -52,20 +61,6 @@ return aggressive_message_said = FALSE -/mob/living/simple_animal/hostile/asteroid/polarbear/death(gibbed) - move_force = MOVE_FORCE_DEFAULT - move_resist = MOVE_RESIST_DEFAULT - pull_force = PULL_FORCE_DEFAULT - return ..() - -/mob/living/simple_animal/hostile/asteroid/polarbear/revive(full_heal_flags = NONE, excess_healing = 0, force_grab_ghost = FALSE) - . = ..() - if(!.) - return - move_force = initial(move_force) - move_resist = initial(move_resist) - pull_force = initial(pull_force) - /mob/living/simple_animal/hostile/asteroid/polarbear/lesser name = "magic polar bear" desc = "It seems sentient somehow." diff --git a/tgstation.dme b/tgstation.dme index 442d0cd7b46..7ae40a14220 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1451,6 +1451,7 @@ #include "code\datums\elements\mirage_border.dm" #include "code\datums\elements\mob_grabber.dm" #include "code\datums\elements\mob_killed_tally.dm" +#include "code\datums\elements\move_force_on_death.dm" #include "code\datums\elements\movement_turf_changer.dm" #include "code\datums\elements\movetype_handler.dm" #include "code\datums\elements\nerfed_pulling.dm"