From 788ceb6acd94ac6030f46239e944641509db67fd Mon Sep 17 00:00:00 2001 From: Halonexus Date: Fri, 26 Apr 2024 23:36:54 +0300 Subject: [PATCH 1/5] Hostile AI changes squashed --- ModularTegustation/ego_weapons/melee/aleph.dm | 4 + .../ego_weapons/melee/subtype/shield.dm | 6 + .../tegu_mobs/lc13_corrosions.dm | 16 +- .../tegu_mobs/lc13_humanoids.dm | 8 +- .../tegu_mobs/lc13_outskirtdwellers.dm | 20 +- code/__DEFINES/combat.dm | 2 + .../community/aleph/crying_children.dm | 12 +- .../abnormality/aleph/censored.dm | 6 +- .../abnormality/aleph/melting_love.dm | 22 +- .../abnormality/aleph/mountain.dm | 8 +- .../abnormality/aleph/nobody_is.dm | 4 +- .../abnormality/aleph/seasons.dm | 4 +- .../abnormality/aleph/titania.dm | 4 +- .../abnormality/aleph/white_night.dm | 8 +- .../simple_animal/abnormality/he/KQE.dm | 2 +- .../abnormality/he/basilisoup.dm | 6 +- .../abnormality/he/better_memories.dm | 6 +- .../abnormality/he/blue_shepherd.dm | 6 +- .../simple_animal/abnormality/he/eris.dm | 6 +- .../abnormality/he/golden_false_apple.dm | 12 +- .../abnormality/he/headless_ichthys.dm | 6 +- .../simple_animal/abnormality/he/jangsan.dm | 4 +- .../simple_animal/abnormality/he/porccubus.dm | 6 +- .../simple_animal/abnormality/he/red_shoes.dm | 12 +- .../simple_animal/abnormality/he/scarecrow.dm | 6 +- .../abnormality/he/shock_centipede.dm | 4 +- .../abnormality/he/snow_queen.dm | 8 +- .../simple_animal/abnormality/he/woodsman.dm | 10 +- .../abnormality/teth/fairy_gentleman.dm | 8 +- .../abnormality/teth/fairy_long_legs.dm | 4 +- .../abnormality/teth/pale_horse.dm | 6 +- .../simple_animal/abnormality/teth/ppodae.dm | 8 +- .../abnormality/teth/punishing_bird.dm | 8 +- .../abnormality/teth/scorched_girl.dm | 14 +- .../abnormality/teth/simple_smile.dm | 6 +- .../abnormality/teth/so_that_no_cry.dm | 6 +- .../abnormality/waw/apex_predator.dm | 20 +- .../simple_animal/abnormality/waw/big_bird.dm | 6 +- .../simple_animal/abnormality/waw/big_wolf.dm | 6 +- .../abnormality/waw/clown_smiling.dm | 6 +- .../abnormality/waw/ebony_queen.dm | 8 +- .../abnormality/waw/hatred_queen.dm | 4 +- .../abnormality/waw/judgement_bird.dm | 6 +- .../abnormality/waw/naked_nest.dm | 10 +- .../abnormality/waw/nosferatu.dm | 12 +- .../abnormality/waw/queen_bee.dm | 6 +- .../abnormality/waw/screenwriter.dm | 6 +- .../simple_animal/abnormality/waw/sphinx.dm | 6 +- .../abnormality/waw/thunder_bird.dm | 6 +- .../simple_animal/abnormality/waw/warden.dm | 6 +- .../abnormality/waw/wrath_servant.dm | 20 +- .../simple_animal/abnormality/zayin/bald.dm | 6 +- .../abnormality/zayin/blubbering_toad.dm | 10 +- .../simple_animal/abnormality/zayin/bottle.dm | 4 +- .../abnormality/zayin/fairy_festival.dm | 6 +- .../abnormality/zayin/sleeping_beauty.dm | 4 +- .../living/simple_animal/animal_defense.dm | 3 +- .../distortion/legend/papa_bongy.dm | 18 +- .../living/simple_animal/hostile/hostile.dm | 271 ++++++++++++------ .../hostile/megafauna/megafauna.dm | 6 +- .../simple_animal/hostile/ordeal/amber.dm | 6 +- .../hostile/ordeal/brown/dawn.dm | 14 +- .../simple_animal/hostile/ordeal/crimson.dm | 10 +- .../simple_animal/hostile/ordeal/gold.dm | 0 .../simple_animal/hostile/ordeal/gold/dusk.dm | 10 +- .../simple_animal/hostile/ordeal/gold/noon.dm | 12 +- .../simple_animal/hostile/ordeal/green.dm | 12 +- .../hostile/ordeal/green/dawn.dm | 16 +- .../simple_animal/hostile/ordeal/indigo.dm | 18 +- .../hostile/ordeal/indigo/dawn.dm | 6 +- .../simple_animal/hostile/ordeal/white.dm | 16 +- code/modules/spells/ability_types/realized.dm | 8 +- code/modules/suppressions/extraction.dm | 4 +- 73 files changed, 497 insertions(+), 369 deletions(-) create mode 100644 code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm diff --git a/ModularTegustation/ego_weapons/melee/aleph.dm b/ModularTegustation/ego_weapons/melee/aleph.dm index 2230bb108c63..929b1e7797ae 100644 --- a/ModularTegustation/ego_weapons/melee/aleph.dm +++ b/ModularTegustation/ego_weapons/melee/aleph.dm @@ -750,6 +750,10 @@ attacking = TRUE //ALWAYS blocking ranged attacks +/obj/item/ego_weapon/shield/distortion/Initialize() + . = ..() + aggro_on_block *= 4 + /obj/item/ego_weapon/shield/distortion/EgoAttackInfo(mob/user) return span_notice("It deals [force * 4] red, white, black and pale damage combined.") diff --git a/ModularTegustation/ego_weapons/melee/subtype/shield.dm b/ModularTegustation/ego_weapons/melee/subtype/shield.dm index dfdd067204e3..5bb0b25cd73c 100644 --- a/ModularTegustation/ego_weapons/melee/subtype/shield.dm +++ b/ModularTegustation/ego_weapons/melee/subtype/shield.dm @@ -43,6 +43,7 @@ var/block_sound_volume = 50 var/projectile_timer var/parry_timer + var/aggro_on_block /obj/item/ego_weapon/shield/Initialize() . = ..() @@ -56,6 +57,7 @@ resistances_list += list("BLACK" = reductions[3]) if(reductions[4] != 0) resistances_list += list("PALE" = reductions[4]) + aggro_on_block = force * 3 //Allows the user to deflect projectiles for however long recovery time is set to on a hit /obj/item/ego_weapon/shield/melee_attack_chain(mob/user, atom/target, params) @@ -96,6 +98,10 @@ shield_user.physiology.black_mod *= max(0.001, (1 - ((reductions[3]) / 100))) shield_user.physiology.pale_mod *= max(0.001, (1 - ((reductions[4]) / 100))) RegisterSignal(user, COMSIG_MOB_APPLY_DAMGE, PROC_REF(AnnounceBlock)) + for(var/mob/living/simple_animal/hostile/H in hearers(3, user)) + if(H.stat != CONSCIOUS || H.AIStatus == AI_OFF || H.client) + continue + H.RegisterAggroValue(user, aggro_on_block, AGGRO_DAMAGE) if(QDELING(src)) DisableBlock(shield_user) else diff --git a/ModularTegustation/tegu_mobs/lc13_corrosions.dm b/ModularTegustation/tegu_mobs/lc13_corrosions.dm index d6a6636b523b..54e3ac3f92de 100644 --- a/ModularTegustation/tegu_mobs/lc13_corrosions.dm +++ b/ModularTegustation/tegu_mobs/lc13_corrosions.dm @@ -247,12 +247,12 @@ return FALSE ..() -/mob/living/simple_animal/hostile/ordeal/snake_corrosion/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/snake_corrosion/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE - ..() - if(isliving(target)) - var/mob/living/H = target + . = ..() + if(isliving(attacked_target)) + var/mob/living/H = attacked_target H.apply_venom(applied_venom) /mob/living/simple_animal/hostile/ordeal/snake_corrosion/OpenFire() @@ -409,16 +409,16 @@ return ..() -/mob/living/simple_animal/hostile/ordeal/dog_corrosion/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/dog_corrosion/AttackingTarget(atom/attacked_target) if(charging) return if(dash_cooldown <= world.time && !client && charge_ready) - PrepCharge(target) + PrepCharge(attacked_target) return . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.health < 0) H.gib() playsound(src, "sound/abnormalities/clouded_monk/eat.ogg", 75, 1) diff --git a/ModularTegustation/tegu_mobs/lc13_humanoids.dm b/ModularTegustation/tegu_mobs/lc13_humanoids.dm index ed9803ba75cd..cd76fc0b3c7a 100644 --- a/ModularTegustation/tegu_mobs/lc13_humanoids.dm +++ b/ModularTegustation/tegu_mobs/lc13_humanoids.dm @@ -120,12 +120,12 @@ Skittish, they prefer to move in groups and will run away if the enemies are in return FALSE return ..() -/mob/living/simple_animal/hostile/humanoid/rat/knife/AttackingTarget() +/mob/living/simple_animal/hostile/humanoid/rat/knife/AttackingTarget(atom/attacked_target) if(!can_act) return ..() if(dash_cooldown < world.time) - BackstreetsDash(target) + BackstreetsDash(attacked_target) return /mob/living/simple_animal/hostile/humanoid/rat/knife/OpenFire() @@ -653,8 +653,8 @@ Skittish, they prefer to move in groups and will run away if the enemies are in return . = ..() - if (istype(target, /mob/living)) - var/mob/living/L = target + if (istype(attacked_target, /mob/living)) + var/mob/living/L = attacked_target L.apply_lc_burn(burn_stacks) TripleDash() diff --git a/ModularTegustation/tegu_mobs/lc13_outskirtdwellers.dm b/ModularTegustation/tegu_mobs/lc13_outskirtdwellers.dm index 04f1089cb0a5..46ffbbf9c86c 100644 --- a/ModularTegustation/tegu_mobs/lc13_outskirtdwellers.dm +++ b/ModularTegustation/tegu_mobs/lc13_outskirtdwellers.dm @@ -52,10 +52,10 @@ if(maxHealth >= 250) . += span_notice("Drag yourself onto [src] in order to ride them.") -/mob/living/simple_animal/hostile/morsel/AttackingTarget() +/mob/living/simple_animal/hostile/morsel/AttackingTarget(atom/attacked_target) retreat_distance = 0 - if(is_type_in_typecache(target,wanted_objects)) //we eats - qdel(target) + if(is_type_in_typecache(attacked_target, wanted_objects)) //we eats + qdel(attacked_target) buffed = (buffed + 1) if(buffed >= 10) PustuleChurn() @@ -87,10 +87,10 @@ return return ..() -/mob/living/simple_animal/hostile/morsel/AttackingTarget() +/mob/living/simple_animal/hostile/morsel/AttackingTarget(atom/attacked_target) . = ..() if(.) - var/dir_to_target = get_dir(get_turf(src), get_turf(target)) + var/dir_to_target = get_dir(get_turf(src), get_turf(attacked_target)) animate(src, pixel_y = (base_pixel_y + 18), time = 2) addtimer(CALLBACK(src, PROC_REF(AnimateBack)), 2) for(var/i = 1 to 2) @@ -735,11 +735,11 @@ Mobs that mostly focus on dealing RED damage, they are all a bit more frail than return FALSE return ..() -/mob/living/simple_animal/hostile/lovetown/slumberer/AttackingTarget() +/mob/living/simple_animal/hostile/lovetown/slumberer/AttackingTarget(atom/attacked_target) if(countering) return if(grab_ready) - return OpenFire(target) + return OpenFire(attacked_target) return ..() /mob/living/simple_animal/hostile/lovetown/slumberer/OpenFire(target) @@ -1039,8 +1039,8 @@ Mobs that mostly focus on dealing RED damage, they are all a bit more frail than if(current_stage == 2) adjustBruteLoss(-40) //self damages at stage 2 - if(ishuman(target)) - if(Finisher(target)) + if(ishuman(attacked_target)) + if(Finisher(attacked_target)) return if(countering) @@ -1053,7 +1053,7 @@ Mobs that mostly focus on dealing RED damage, they are all a bit more frail than DisableCounter() return if(counter_ready) - return OpenFire(target) + return OpenFire(attacked_target) return AoeAttack() /mob/living/simple_animal/hostile/lovetown/abomination/OpenFire(target) diff --git a/code/__DEFINES/combat.dm b/code/__DEFINES/combat.dm index e53369331abd..d8f04672fd16 100644 --- a/code/__DEFINES/combat.dm +++ b/code/__DEFINES/combat.dm @@ -50,6 +50,8 @@ #define BLACK_DAMAGE "black" /// Deals brute damage in percents. #define PALE_DAMAGE "pale" +/// Fake damage used for hostile ai targetting +#define AGGRO_DAMAGE "aggro" //bitflag damage defines used for suicide_act #define BRUTELOSS (1<<0) diff --git a/code/modules/mob/living/simple_animal/abnormality/_auxiliary_modes/community/aleph/crying_children.dm b/code/modules/mob/living/simple_animal/abnormality/_auxiliary_modes/community/aleph/crying_children.dm index b5dc6bacd7ee..3042d17f8589 100644 --- a/code/modules/mob/living/simple_animal/abnormality/_auxiliary_modes/community/aleph/crying_children.dm +++ b/code/modules/mob/living/simple_animal/abnormality/_auxiliary_modes/community/aleph/crying_children.dm @@ -262,24 +262,24 @@ Combusting_Courage() return -/mob/living/simple_animal/hostile/abnormality/crying_children/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/crying_children/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE if(!client) if(desperate && (courage_cooldown <= world.time) && prob(30)) return Combusting_Courage() if(sorrow_cooldown <= world.time && prob(25)) - return Wounds_Of_Sorrow(target) + return Wounds_Of_Sorrow(attacked_target) if(prob(35)) - return Bygone_Illusion(target) + return Bygone_Illusion(attacked_target) // Distorted Illusion can_act = FALSE icon_state = "[icon_phase]_salvador" . = ..() - if(isliving(target)) - var/mob/living/L = target + if(isliving(attacked_target)) + var/mob/living/L = attacked_target L.apply_lc_burn(5*burn_mod) SLEEP_CHECK_DEATH(10) icon_state = "[icon_phase]_idle" @@ -508,7 +508,7 @@ if(!target) target = H if(target in view(1, src)) - AttackingTarget() + AttackingTarget(target) tagged = TRUE // Unseeing diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/censored.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/censored.dm index ab836b7f4e3a..48b82aa4f999 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/censored.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/censored.dm @@ -116,15 +116,15 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/censored/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/censored/AttackingTarget(atom/attacked_target) . = ..() if(!can_act) return - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.stat >= SOFT_CRIT || H.health < 0) return Convert(H) diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/melting_love.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/melting_love.dm index b1f37dff8aa2..4385c6ce5ccf 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/melting_love.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/melting_love.dm @@ -100,16 +100,16 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/melting_love/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/melting_love/AttackingTarget(atom/attacked_target) // Convert - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(H.stat == DEAD || H.health <= HEALTH_THRESHOLD_DEAD) return SlimeConvert(H) // Consume a slime. Cannot work on the big one, so the check is not istype() - if(target.type == /mob/living/simple_animal/hostile/slime) - var/mob/living/simple_animal/hostile/slime/S = target + if(attacked_target.type == /mob/living/simple_animal/hostile/slime) + var/mob/living/simple_animal/hostile/slime/S = attacked_target visible_message(span_warning("[src] consumes \the [S], restoring its own health.")) . = ..() // We do a normal attack without AOE and then consume the slime to restore HP adjustBruteLoss(-maxHealth * 0.2) @@ -117,9 +117,9 @@ return . // AOE attack - if(isliving(target) || ismecha(target)) - new /obj/effect/gibspawner/generic/silent/melty_slime(get_turf(target)) - for(var/turf/open/T in view(1, target)) + if(isliving(attacked_target) || ismecha(attacked_target)) + new /obj/effect/gibspawner/generic/silent/melty_slime(get_turf(attacked_target)) + for(var/turf/open/T in view(1, attacked_target)) var/obj/effect/temp_visual/small_smoke/halfsecond/S = new(T) S.color = "#FF0081" var/list/got_hit = list() @@ -326,10 +326,10 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/slime/AttackingTarget() +/mob/living/simple_animal/hostile/slime/AttackingTarget(atom/attacked_target) // Convert - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(H.stat == DEAD || H.health <= HEALTH_THRESHOLD_DEAD) return SlimeConvert(H) if(prob(statuschance)) diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/mountain.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/mountain.dm index 01ea0c958c0a..ae6194359a24 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/mountain.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/mountain.dm @@ -120,16 +120,16 @@ return TRUE return FALSE -/mob/living/simple_animal/hostile/abnormality/mountain/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/mountain/AttackingTarget(atom/attacked_target) if(finishing) return FALSE if(phase >= 2) if(prob(35) && OpenFire()) return . = ..() - if(. && isliving(target)) - var/mob/living/L = target - if(isliving(target) && (L.health < 0 || L.stat == DEAD)) + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target + if(isliving(attacked_target) && (L.health < 0 || L.stat == DEAD)) finishing = TRUE if(phase == 3) icon_state = "mosb_bite2" diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/nobody_is.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/nobody_is.dm index 44703d2803a0..8e967b5c9a37 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/nobody_is.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/nobody_is.dm @@ -625,8 +625,8 @@ for(var/i = 1 to 3) target_turf = get_step(target_turf, get_dir(get_turf(src), target_turf)) return WhipAttack(target_turf) - if(isliving(target)) - var/mob/living/L = target + if(isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.health <= 0) if(ishuman(L)) var/mob/living/carbon/human/H = L diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/seasons.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/seasons.dm index b71ac42ce4a1..58e3f6ce6d54 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/seasons.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/seasons.dm @@ -348,8 +348,8 @@ return ConeAttack(target) if((slam_cooldown <= world.time) && prob(35)) return Slam() - if(ishuman(target)) - if(Finisher(target)) + if(ishuman(attacked_target)) + if(Finisher(attacked_target)) return return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/titania.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/titania.dm index 27ac02599073..031ada2a568e 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/titania.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/titania.dm @@ -77,10 +77,10 @@ return ..() //Attacking code -/mob/living/simple_animal/hostile/abnormality/titania/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/titania/AttackingTarget(atom/attacked_target) if(fused) return FALSE - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target //Kills the weak immediately. if(get_user_level(H) < 4 && (ishuman(H))) say("I rid you of your pain, mere human.") diff --git a/code/modules/mob/living/simple_animal/abnormality/aleph/white_night.dm b/code/modules/mob/living/simple_animal/abnormality/aleph/white_night.dm index 0cbd36d1f7d0..eb7ece82cc32 100644 --- a/code/modules/mob/living/simple_animal/abnormality/aleph/white_night.dm +++ b/code/modules/mob/living/simple_animal/abnormality/aleph/white_night.dm @@ -310,16 +310,16 @@ GLOBAL_LIST_EMPTY(apostles) return FALSE return ..() -/mob/living/simple_animal/hostile/apostle/AttackingTarget() +/mob/living/simple_animal/hostile/apostle/AttackingTarget(atom/attacked_target) if(!can_act) return - if(isliving(target)) - var/mob/living/L = target + if(isliving(attacked_target)) + var/mob/living/L = attacked_target if(faction_check_mob(L)) return . = ..() - if(. && isliving(target)) + if(. && isliving(attacked_target)) if(!client && ranged && ranged_cooldown <= world.time) OpenFire() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/KQE.dm b/code/modules/mob/living/simple_animal/abnormality/he/KQE.dm index 8aa0d6923b9b..01200cdfbd8e 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/KQE.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/KQE.dm @@ -218,7 +218,7 @@ if(!can_act) return FALSE if ((grab_cooldown <= world.time) && prob(35) && (!client))//checks for client since you can still use the claw if you click nearby - var/turf/target_turf = get_turf(target) + var/turf/target_turf = get_turf(attacked_target) return ClawGrab(target_turf) return Whip_Attack() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/basilisoup.dm b/code/modules/mob/living/simple_animal/abnormality/he/basilisoup.dm index ce7db6feeaea..ffcab6d3f22a 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/basilisoup.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/basilisoup.dm @@ -159,11 +159,11 @@ density = TRUE mouse_opacity = MOUSE_OPACITY_ICON -/mob/living/simple_animal/hostile/abnormality/basilisoup/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/basilisoup/AttackingTarget(atom/attacked_target) if(!can_act) return - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(H.nutrition >= NUTRITION_LEVEL_FAT) playsound(get_turf(src), 'sound/abnormalities/bigbird/bite.ogg', 50, 1, 2) H.gib() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/better_memories.dm b/code/modules/mob/living/simple_animal/abnormality/he/better_memories.dm index f9975364db14..4da625147411 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/better_memories.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/better_memories.dm @@ -203,12 +203,12 @@ if(target_memory[the_target] <= 100) return FALSE -/mob/living/simple_animal/hostile/better_memories_minion/AttackingTarget() +/mob/living/simple_animal/hostile/better_memories_minion/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE if(!client) - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target /* Dont jab those standing still for their picture. Death is not our goal */ diff --git a/code/modules/mob/living/simple_animal/abnormality/he/blue_shepherd.dm b/code/modules/mob/living/simple_animal/abnormality/he/blue_shepherd.dm index 62fdef761037..c975fded23b4 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/blue_shepherd.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/blue_shepherd.dm @@ -205,12 +205,12 @@ hired = FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/blue_shepherd/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/blue_shepherd/AttackingTarget(atom/attacked_target) . = ..() if(client) switch(chosen_attack) if(1) - if(isliving(target)) + if(isliving(attacked_target)) slash_current-=1 return OpenFire() if(2) @@ -224,7 +224,7 @@ slashing = TRUE slash() if(awakened_buddy) - awakened_buddy.GiveTarget(target) + awakened_buddy.GiveTarget(attacked_target) /mob/living/simple_animal/hostile/abnormality/blue_shepherd/OpenFire() if(slash_current == 0) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/eris.dm b/code/modules/mob/living/simple_animal/abnormality/he/eris.dm index 7a5786db90ec..21b1487061c6 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/eris.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/eris.dm @@ -127,10 +127,10 @@ return FALSE /mob/living/simple_animal/hostile/abnormality/eris/AttackingTarget(atom/attacked_target) - if(ishuman(target)) - var/mob/living/H = target + if(ishuman(attacked_target)) + var/mob/living/H = attacked_target if(H.stat >= SOFT_CRIT) - Dine(target) + Dine(attacked_target) return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/golden_false_apple.dm b/code/modules/mob/living/simple_animal/abnormality/he/golden_false_apple.dm index 0c88973c76f9..c64e06360d4c 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/golden_false_apple.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/golden_false_apple.dm @@ -294,13 +294,13 @@ is_maggot = TRUE ChangeMoveToDelayBy(-1) -/mob/living/simple_animal/hostile/abnormality/golden_apple/AttackingTarget()//regular attacks or AOE. Determines the outcome for both players and the AI behavior +/mob/living/simple_animal/hostile/abnormality/golden_apple/AttackingTarget(atom/attacked_target)//regular attacks or AOE. Determines the outcome for both players and the AI behavior if(!can_act) return FALSE if(!is_maggot)//Is it still in the first form? Start building sheen pulses if(pulse_count < pulse_maximum) - if(isliving(target)) - var/mob/living/hit = target + if(isliving(attacked_target)) + var/mob/living/hit = attacked_target if((hit.stat == DEAD) ||!ishuman(hit))//if the target is dead or not human return ..() if(istype(target, /mob/living/carbon/human/species/pinocchio)) @@ -319,12 +319,12 @@ if(client && smash_cooldown < world.time)//playable behavior is nested under here switch(chosen_attack) if(1) - Smash(target) + Smash(attacked_target) if(2) - Smash(target, wide = FALSE) + Smash(attacked_target, wide = FALSE) return if(prob(50) && (smash_cooldown < world.time))//AI behavior goes here - Smash(target, wide = pick(TRUE, FALSE)) + Smash(attacked_target, wide = pick(TRUE, FALSE)) return return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/headless_ichthys.dm b/code/modules/mob/living/simple_animal/abnormality/he/headless_ichthys.dm index eae81b66db8f..8884cfb82e27 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/headless_ichthys.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/headless_ichthys.dm @@ -189,14 +189,14 @@ can_act = TRUE // Breach Stuff -/mob/living/simple_animal/hostile/abnormality/headless_ichthys/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/headless_ichthys/AttackingTarget(atom/attacked_target) if(!can_act) return if(jump_cooldown <= world.time && prob(10) && !client) - IchthysJump(target) + IchthysJump(attacked_target) return if(cannon_cooldown <= world.time && prob(5) && !client) - BloodCannon(target) + BloodCannon(attacked_target) return return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/jangsan.dm b/code/modules/mob/living/simple_animal/abnormality/he/jangsan.dm index c5d138cc532f..ca564b2af7ac 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/jangsan.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/jangsan.dm @@ -256,9 +256,9 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/jangsan/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/jangsan/AttackingTarget(atom/attacked_target) if(bite_cooldown < world.time) - KillCheck(target) + KillCheck(attacked_target) icon_state = icon_aggro return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/he/porccubus.dm b/code/modules/mob/living/simple_animal/abnormality/he/porccubus.dm index 74dbbe1ae7de..cff432a39da1 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/porccubus.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/porccubus.dm @@ -197,10 +197,10 @@ playsound(src, 'sound/abnormalities/porccubus/porccu_giggle.ogg', 10, FALSE, 4) // This thing is absurdly loud ranged_cooldown = world.time + ranged_cooldown_time -/mob/living/simple_animal/hostile/abnormality/porccubus/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/porccubus/AttackingTarget(atom/attacked_target) var/mob/living/carbon/human/H - if(ishuman(target)) - H = target + if(ishuman(attacked_target)) + H = attacked_target . = ..() if(.) if(!H) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/red_shoes.dm b/code/modules/mob/living/simple_animal/abnormality/he/red_shoes.dm index 6191e2e632fe..75cb8f4e67e1 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/red_shoes.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/red_shoes.dm @@ -223,11 +223,11 @@ if(S.stat != DEAD && !S.target && !S.client && faction_check_mob(S))//cannibalized from steel ordeals S.Goto(src,S.move_to_delay,1) -/mob/living/simple_animal/hostile/abnormality/red_shoes/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/red_shoes/AttackingTarget(atom/attacked_target) . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.stat >= SOFT_CRIT || H.health < 0) ChopFeet(H) @@ -392,11 +392,11 @@ move_to_delay = 3 var/steppy = 0 -/mob/living/simple_animal/hostile/red_shoe/AttackingTarget() +/mob/living/simple_animal/hostile/red_shoe/AttackingTarget(atom/attacked_target) . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.stat >= SOFT_CRIT || H.health < 0) ChopFeet(H) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/scarecrow.dm b/code/modules/mob/living/simple_animal/abnormality/he/scarecrow.dm index 8d2f0e0f9ce0..7f54df0e2df4 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/scarecrow.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/scarecrow.dm @@ -75,12 +75,12 @@ QDEL_IN(src, 10 SECONDS) ..() -/mob/living/simple_animal/hostile/abnormality/scarecrow/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/scarecrow/AttackingTarget(atom/attacked_target) . = ..() if(.) - if(!istype(target, /mob/living/carbon/human)) + if(!istype(attacked_target, /mob/living/carbon/human)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.health < 0 && stat != DEAD && !finishing && H.getorgan(/obj/item/organ/brain)) finishing = TRUE H.Stun(10 SECONDS) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/shock_centipede.dm b/code/modules/mob/living/simple_animal/abnormality/he/shock_centipede.dm index cfa44f83512d..8e3afad62958 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/shock_centipede.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/shock_centipede.dm @@ -234,13 +234,13 @@ AT.pixel_y += random_y return 0 -/mob/living/simple_animal/hostile/abnormality/shock_centipede/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/shock_centipede/AttackingTarget(atom/attacked_target) if (shield > 0 || !can_act) // dont attack if coiled or stunned return FALSE if(!client) TryCoil() if(tail_attack_cooldown < world.time) - var/turf/target_turf = get_turf(target) + var/turf/target_turf = get_turf(attacked_target) for(var/i = 1 to tailattack_range - 2) target_turf = get_step(target_turf, get_dir(get_turf(src), target_turf)) TailAttack(target_turf) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/snow_queen.dm b/code/modules/mob/living/simple_animal/abnormality/he/snow_queen.dm index 4cfbd50e6666..8e369030d8a1 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/snow_queen.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/snow_queen.dm @@ -204,14 +204,14 @@ return TRUE return ..() -/mob/living/simple_animal/hostile/abnormality/snow_queen/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/snow_queen/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE if(client) return ..() //Destroy them. They lost the duel. - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(H.stat == DEAD && (H == storybook_hero || H == frozen_employee)) H.dust(TRUE, FALSE) return FALSE @@ -224,7 +224,7 @@ can_act = TRUE return can_act = TRUE - Slash(target, wide = pick(TRUE, FALSE)) + Slash(attacked_target, wide = pick(TRUE, FALSE)) return //Dont do normal attacks if in the arena. if(!arena_attacks) diff --git a/code/modules/mob/living/simple_animal/abnormality/he/woodsman.dm b/code/modules/mob/living/simple_animal/abnormality/he/woodsman.dm index 10e34be7d468..f00412b1c2f8 100644 --- a/code/modules/mob/living/simple_animal/abnormality/he/woodsman.dm +++ b/code/modules/mob/living/simple_animal/abnormality/he/woodsman.dm @@ -129,8 +129,8 @@ /mob/living/simple_animal/hostile/abnormality/woodsman/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(H.stat == DEAD || (H.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(H, TRAIT_NODEATH)) || H.health <= -30) Heal(H) return ..() @@ -140,12 +140,12 @@ if(client) switch(chosen_attack) if(1) - Woodsman_Flurry(target) + Woodsman_Flurry(attacked_target) if(2) return ..() return ..() - if(isliving(target) && flurry_cooldown <= world.time && get_dist(src, target) <= 2 && prob(30)) - Woodsman_Flurry(target) + if(isliving(attacked_target) && flurry_cooldown <= world.time && get_dist(src, attacked_target) <= 2 && prob(30)) + Woodsman_Flurry(attacked_target) return ..() /mob/living/simple_animal/hostile/abnormality/woodsman/PickTarget(list/Targets) // We attack corpses first if there are any diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/fairy_gentleman.dm b/code/modules/mob/living/simple_animal/abnormality/teth/fairy_gentleman.dm index a7a2c437393f..85b7c69b5b43 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/fairy_gentleman.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/fairy_gentleman.dm @@ -131,16 +131,16 @@ is_flying_animal = TRUE ADD_TRAIT(src, TRAIT_MOVE_FLYING, INNATE_TRAIT) -/mob/living/simple_animal/hostile/abnormality/fairy_gentleman/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/fairy_gentleman/AttackingTarget(atom/attacked_target) if(!can_act) return melee_damage_type = WHITE_DAMAGE if(jump_cooldown <= world.time && prob(10) && !client) - FairyJump(target) + FairyJump(attacked_target) return - if(!ishuman(target)) + if(!ishuman(attacked_target)) return ..() - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target H.drunkenness += 5 to_chat(H, span_warning("Yuck, some of it got in your mouth!")) if(H.sanity_lost) diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/fairy_long_legs.dm b/code/modules/mob/living/simple_animal/abnormality/teth/fairy_long_legs.dm index ff119b9b0681..e8ec2b2f7284 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/fairy_long_legs.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/fairy_long_legs.dm @@ -157,10 +157,10 @@ icon_state = "fairy_longlegs" //Breach Stuff -/mob/living/simple_animal/hostile/abnormality/fairy_longlegs/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/fairy_longlegs/AttackingTarget(atom/attacked_target) if(finishing) return FALSE - if(!istype(target, /mob/living/carbon/human)) + if(!istype(attacked_target, /mob/living/carbon/human)) return ..() finishing = TRUE icon_state = "fairy_longlegs_healing" diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/pale_horse.dm b/code/modules/mob/living/simple_animal/abnormality/teth/pale_horse.dm index 2dd93448990a..b3ace720687e 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/pale_horse.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/pale_horse.dm @@ -136,11 +136,11 @@ for(var/turf/T in view(1, target_turf)) new /obj/effect/temp_visual/palefog(T) -/mob/living/simple_animal/hostile/abnormality/pale_horse/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/pale_horse/AttackingTarget(atom/attacked_target) . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return FALSE - var/mob/living/carbon/human/T = target + var/mob/living/carbon/human/T = attacked_target if(T.health > 0) var/datum/status_effect/mortis/M = T.has_status_effect(/datum/status_effect/mortis) if(!M) diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/ppodae.dm b/code/modules/mob/living/simple_animal/abnormality/teth/ppodae.dm index a72bb70aabe8..9aacdb8453c4 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/ppodae.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/ppodae.dm @@ -53,11 +53,11 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/ppodae/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/ppodae/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE - var/mob/living/carbon/L = target - if(iscarbon(target) && (L.health < 0 || L.stat == DEAD)) + var/mob/living/carbon/L = attacked_target + if(iscarbon(attacked_target) && (L.health < 0 || L.stat == DEAD)) if(HAS_TRAIT(L, TRAIT_NODISMEMBER)) return var/list/parts = list() @@ -72,7 +72,7 @@ bp.forceMove(get_turf(datum_reference.landmark)) // Teleports limb to containment QDEL_NULL(src) // Taken from eldritch_demons.dm - return Smash(target) + return Smash(attacked_target) //AoE attack taken from woodsman /mob/living/simple_animal/hostile/abnormality/ppodae/proc/Smash(target) diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/punishing_bird.dm b/code/modules/mob/living/simple_animal/abnormality/teth/punishing_bird.dm index e454d8b0bd30..07af10bc6f7d 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/punishing_bird.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/punishing_bird.dm @@ -166,8 +166,8 @@ var/mob/living/carbon/le_target = pick(potential_mobs) pecking_targets |= le_target -/mob/living/simple_animal/hostile/abnormality/punishing_bird/AttackingTarget() - if(ishuman(target) && bird_angry) +/mob/living/simple_animal/hostile/abnormality/punishing_bird/AttackingTarget(atom/attacked_target) + if(ishuman(attacked_target) && bird_angry) melee_damage_lower = angry_damage_human melee_damage_upper = angry_damage_human @@ -179,8 +179,8 @@ melee_damage_lower = 1 melee_damage_upper = 2 - if(isliving(target)) - var/mob/living/L = target + if(isliving(attacked_target)) + var/mob/living/L = attacked_target if(!(L in enemies) && obj_damage > 0) // The target didn't attack us and we've transformed to_chat(src, span_warning("You can't punish innocent people!")) return diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/scorched_girl.dm b/code/modules/mob/living/simple_animal/abnormality/teth/scorched_girl.dm index 6133ca1b59bd..c484b373ea5d 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/scorched_girl.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/scorched_girl.dm @@ -84,7 +84,7 @@ var/highestcount = 0 for(var/turf/T in GLOB.department_centers) var/targets_at_tile = 0 - for(var/mob/living/L in view(10, T)) + for(var/mob/living/L in ohearers(10, T)) if(!faction_check_mob(L) && L.stat != DEAD) targets_at_tile++ if(targets_at_tile > highestcount) @@ -104,7 +104,7 @@ return var/amount_inview = 0 - for(var/mob/living/carbon/human/H in view(7, src)) + for(var/mob/living/carbon/human/H in ohearers(7, src)) if(!faction_check_mob(H) && H.stat != DEAD) amount_inview += 1 if(prob(amount_inview*20)) @@ -122,7 +122,15 @@ return FALSE /mob/living/simple_animal/hostile/abnormality/scorched_girl/AttackingTarget(atom/attacked_target) - explode() + if(client) + explode() + return + var/amount_inview = 0 + for(var/mob/living/carbon/human/H in ohearers(7, src)) + if(!faction_check_mob(H) && H.stat != DEAD) + amount_inview += 1 + if(prob(amount_inview * 20)) + explode() return /mob/living/simple_animal/hostile/abnormality/scorched_girl/proc/explode() diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/simple_smile.dm b/code/modules/mob/living/simple_animal/abnormality/teth/simple_smile.dm index c7280ffdab6b..c609aabad6ee 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/simple_smile.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/simple_smile.dm @@ -64,10 +64,10 @@ -/mob/living/simple_animal/hostile/abnormality/smile/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/smile/AttackingTarget(atom/attacked_target) . = ..() - if(ishuman(target)) - var/mob/living/carbon/human/L = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/L = attacked_target L.Knockdown(20) var/obj/item/held = L.get_active_held_item() L.dropItemToGround(held) //Drop weapon diff --git a/code/modules/mob/living/simple_animal/abnormality/teth/so_that_no_cry.dm b/code/modules/mob/living/simple_animal/abnormality/teth/so_that_no_cry.dm index 0756e364f675..0eb585b6018c 100644 --- a/code/modules/mob/living/simple_animal/abnormality/teth/so_that_no_cry.dm +++ b/code/modules/mob/living/simple_animal/abnormality/teth/so_that_no_cry.dm @@ -193,12 +193,12 @@ can_act = TRUE //Talisman Stuff -/mob/living/simple_animal/hostile/abnormality/so_that_no_cry/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/so_that_no_cry/AttackingTarget(atom/attacked_target) if(!can_act) return - if(!ishuman(target)) + if(!ishuman(attacked_target)) return ..() - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target Apply_Talisman(H) return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/apex_predator.dm b/code/modules/mob/living/simple_animal/abnormality/waw/apex_predator.dm index 70ba22917f5a..f49b510ba790 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/apex_predator.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/apex_predator.dm @@ -115,7 +115,7 @@ Cloak() GiveTarget(user) -/mob/living/simple_animal/hostile/abnormality/apex_predator/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/apex_predator/AttackingTarget(atom/attacked_target) if(!can_act) return if(!revealed) @@ -126,23 +126,23 @@ Decloak() SLEEP_CHECK_DEATH(3) //Backstab - if(target in range(1, src)) - if(isliving(target)) - var/mob/living/V = target - visible_message(span_danger("The [src] rips out [target]'s guts!")) + if(attacked_target in range(1, src)) + if(isliving(attacked_target)) + var/mob/living/V = attacked_target + visible_message(span_danger("The [src] rips out [attacked_target]'s guts!")) new /obj/effect/gibspawner/generic(get_turf(V)) V.deal_damage(backstab_damage, RED_DAMAGE) //Backstab succeeds from any one of 3 tiles behind a mecha, backstab from directly behind gets boosted by mecha directional armor weakness - else if(ismecha(target)) - var/relative_angle = abs(dir2angle(target.dir) - dir2angle(get_dir(target, src))) + else if(ismecha(attacked_target)) + var/relative_angle = abs(dir2angle(attacked_target.dir) - dir2angle(get_dir(attacked_target, src))) relative_angle = relative_angle > 180 ? 360 - relative_angle : relative_angle if(relative_angle >= 135) - visible_message(span_danger("The [src] shreds [target]'s armor!")) - var/obj/vehicle/sealed/mecha/M = target + visible_message(span_danger("The [src] shreds [attacked_target]'s armor!")) + var/obj/vehicle/sealed/mecha/M = attacked_target M.take_damage(backstab_damage, RED_DAMAGE, attack_dir = get_dir(M, src)) new /obj/effect/temp_visual/kinetic_blast(get_turf(M)) else - visible_message(span_danger("The [src]'s attack misses [target]'s weakspots!")) + visible_message(span_danger("The [src]'s attack misses [attacked_target]'s weakspots!")) ..() else ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/big_bird.dm b/code/modules/mob/living/simple_animal/abnormality/waw/big_bird.dm index 6f591a11b3fc..194fa292f1d7 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/big_bird.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/big_bird.dm @@ -128,11 +128,11 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/big_bird/AttackingTarget() - if(ishuman(target)) +/mob/living/simple_animal/hostile/abnormality/big_bird/AttackingTarget(atom/attacked_target) + if(ishuman(attacked_target)) if(bite_cooldown > world.time) return FALSE - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target var/obj/item/bodypart/head/head = H.get_bodypart("head") if(QDELETED(head)) return diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/big_wolf.dm b/code/modules/mob/living/simple_animal/abnormality/waw/big_wolf.dm index 6011aa6aa321..f678dbc1adb1 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/big_wolf.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/big_wolf.dm @@ -369,9 +369,9 @@ cut_overlay(visual_overlay) can_act = TRUE -/mob/living/simple_animal/hostile/abnormality/big_wolf/AttackingTarget() - if(istype(target, /mob/living/simple_animal/hostile/abnormality/red_hood)) //Red takes triple damage from the wolf, becauser her resistances are high - var/mob/living/simple_animal/hostile/abnormality/red_hood/mercenary = target +/mob/living/simple_animal/hostile/abnormality/big_wolf/AttackingTarget(atom/attacked_target) + if(istype(attacked_target, /mob/living/simple_animal/hostile/abnormality/red_hood)) //Red takes triple damage from the wolf, becauser her resistances are high + var/mob/living/simple_animal/hostile/abnormality/red_hood/mercenary = attacked_target var/bonus_damage_dealt = 2 * (rand(melee_damage_lower,melee_damage_upper)) mercenary.deal_damage(bonus_damage_dealt, RED_DAMAGE) return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/clown_smiling.dm b/code/modules/mob/living/simple_animal/abnormality/waw/clown_smiling.dm index 8959e6a6eabe..9eb894acb704 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/clown_smiling.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/clown_smiling.dm @@ -109,12 +109,12 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/abnormality/clown/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/clown/AttackingTarget(atom/attacked_target) . = ..() if(.) - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/TH = target + var/mob/living/carbon/human/TH = attacked_target if(TH.health < 0) finishing = TRUE TH.Stun(4 SECONDS) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/ebony_queen.dm b/code/modules/mob/living/simple_animal/abnormality/waw/ebony_queen.dm index bc857687fa23..e79af2a806aa 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/ebony_queen.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/ebony_queen.dm @@ -205,15 +205,15 @@ OpenFire() return - if(target) // You'd think this should be "attacked_target" but no this shit still uses target I hate it. - if(ismecha(target)) + if(attacked_target) // You'd think this should be "attacked_target" but no this shit still uses target I hate it. + if(ismecha(attacked_target)) if(burst_cooldown <= world.time && prob(50)) thornBurst() else OpenFire() return - else if(isliving(target)) - var/mob/living/L = target + else if(isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(burst_cooldown <= world.time && prob(50)) thornBurst() diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/hatred_queen.dm b/code/modules/mob/living/simple_animal/abnormality/waw/hatred_queen.dm index d9308962749d..26589e5d4daa 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/hatred_queen.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/hatred_queen.dm @@ -233,8 +233,8 @@ wand.forceMove(get_turf(src)) //That way it will be behind her like in the game. return ..() -/mob/living/simple_animal/hostile/abnormality/hatred_queen/AttackingTarget() - return OpenFire(target) +/mob/living/simple_animal/hostile/abnormality/hatred_queen/AttackingTarget(atom/attacked_target) + return OpenFire(attacked_target) /mob/living/simple_animal/hostile/abnormality/hatred_queen/OpenFire() if(!can_act || IsContained()) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/judgement_bird.dm b/code/modules/mob/living/simple_animal/abnormality/waw/judgement_bird.dm index b70fbf6d434a..fed0cf1298f6 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/judgement_bird.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/judgement_bird.dm @@ -192,10 +192,10 @@ visible_message(span_danger("[src] taunts [A]!")) ranged_cooldown = world.time + ranged_cooldown_time -/mob/living/simple_animal/hostile/runawaybird/AttackingTarget() +/mob/living/simple_animal/hostile/runawaybird/AttackingTarget(atom/attacked_target) . = ..() - if(ishuman(target)) - var/mob/living/carbon/human/L = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/L = attacked_target L.Knockdown(20) var/obj/item/held = L.get_active_held_item() L.dropItemToGround(held) //Drop weapon diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/naked_nest.dm b/code/modules/mob/living/simple_animal/abnormality/waw/naked_nest.dm index 1af158cef9c4..95019daad398 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/naked_nest.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/naked_nest.dm @@ -187,14 +187,14 @@ origin_nest = home_naked_nest AddComponent(/datum/component/swarming) -/mob/living/simple_animal/hostile/naked_nest_serpent/AttackingTarget() - if(iscarbon(target)) - var/mob/living/carbon/human/C = target +/mob/living/simple_animal/hostile/naked_nest_serpent/AttackingTarget(atom/attacked_target) + if(iscarbon(attacked_target)) + var/mob/living/carbon/human/C = attacked_target if(C.stat != DEAD && !C.NAKED_NESTED && a_intent == "harm") EnterHost(C) return - if(istype(target, /mob/living/simple_animal/hostile/abnormality/naked_nest)) - var/mob/living/simple_animal/hostile/abnormality/naked_nest/nest = target + if(istype(attacked_target, /mob/living/simple_animal/hostile/abnormality/naked_nest)) + var/mob/living/simple_animal/hostile/abnormality/naked_nest/nest = attacked_target nest.RecoverSerpent(src) return ..() diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/nosferatu.dm b/code/modules/mob/living/simple_animal/abnormality/waw/nosferatu.dm index 0b385e53a876..f2acb88c7b3a 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/nosferatu.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/nosferatu.dm @@ -188,15 +188,15 @@ Banquet() return -/mob/living/simple_animal/hostile/abnormality/nosferatu/AttackingTarget() //Combo for double attacks - if(!ishuman(target)) +/mob/living/simple_animal/hostile/abnormality/nosferatu/AttackingTarget(atom/attacked_target) //Combo for double attacks + if(!ishuman(attacked_target)) return ..() - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(bloodlust <= 0) bloodlust = bloodlust_cooldown H.deal_damage(45, BLACK_DAMAGE) playsound(get_turf(src), 'sound/abnormalities/nosferatu/bat_attack.ogg', 50, 1) - to_chat(target, span_danger("The [src] attacks you savagely!")) + to_chat(attacked_target, span_danger("The [src] attacks you savagely!")) AdjustThirst(40) else bloodlust -= 1 @@ -267,8 +267,8 @@ retreat_distance = 3 minimum_distance = 1 -/mob/living/simple_animal/hostile/nosferatu_mob/AttackingTarget() //they spawn blood on hit - if(ishuman(target)) +/mob/living/simple_animal/hostile/nosferatu_mob/AttackingTarget(atom/attacked_target) //they spawn blood on hit + if(ishuman(attacked_target)) var/obj/effect/decal/cleanable/blood/B = locate() in get_turf(src) if(!B) B = new /obj/effect/decal/cleanable/blood(get_turf(src)) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/queen_bee.dm b/code/modules/mob/living/simple_animal/abnormality/waw/queen_bee.dm index 4f884519f9bf..3b8db2c436bd 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/queen_bee.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/queen_bee.dm @@ -135,11 +135,11 @@ alpha = 25 animate(src, alpha = 255, transform = init_transform, time = 5) -/mob/living/simple_animal/hostile/worker_bee/AttackingTarget() +/mob/living/simple_animal/hostile/worker_bee/AttackingTarget(atom/attacked_target) . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.health <= 0) var/turf/T = get_turf(H) visible_message(span_danger("[src] bites hard on \the [H] as another bee appears!")) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/screenwriter.dm b/code/modules/mob/living/simple_animal/abnormality/waw/screenwriter.dm index b5db3f472314..a69ac701449a 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/screenwriter.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/screenwriter.dm @@ -310,12 +310,12 @@ Defeating the murderer also surpresses the abnormality. if(LAZYLEN(priority)) return pick(priority) -/mob/living/simple_animal/hostile/actor/AttackingTarget() +/mob/living/simple_animal/hostile/actor/AttackingTarget(atom/attacked_target) . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(!H.sanity_lost) return diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/sphinx.dm b/code/modules/mob/living/simple_animal/abnormality/waw/sphinx.dm index c74b171ca215..2c8d0e9f6148 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/sphinx.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/sphinx.dm @@ -279,12 +279,12 @@ if(LAZYLEN(priority)) return pick(priority) -/mob/living/simple_animal/hostile/abnormality/sphinx/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/sphinx/AttackingTarget(atom/attacked_target) ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(!H.sanity_lost) return diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/thunder_bird.dm b/code/modules/mob/living/simple_animal/abnormality/waw/thunder_bird.dm index 4d2efc44baaf..2420c2d63c8b 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/thunder_bird.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/thunder_bird.dm @@ -369,13 +369,13 @@ var/mob/living/simple_animal/hostile/abnormality/thunder_bird/master //Zombie conversion from zombie kills -/mob/living/simple_animal/hostile/thunder_zombie/AttackingTarget() +/mob/living/simple_animal/hostile/thunder_zombie/AttackingTarget(atom/attacked_target) . = ..() if(!can_act) return - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.stat >= SOFT_CRIT || H.health < 0) Convert(H) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/warden.dm b/code/modules/mob/living/simple_animal/abnormality/waw/warden.dm index 52c6dcefe7a3..a38b22cdd280 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/warden.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/warden.dm @@ -78,14 +78,14 @@ |Soul Warden|: If you attack a corpse, you will dust it, heal and gain a stack of “Captured Soul”
\ For each stack of “Captured Soul”, you become faster, deal 10 less melee damage and take 50% more damage.") -/mob/living/simple_animal/hostile/abnormality/warden/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/warden/AttackingTarget(atom/attacked_target) . = ..() if(.) if(finishing) return FALSE - if(!istype(target, /mob/living/carbon/human)) + if(!istype(attacked_target, /mob/living/carbon/human)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.health < 0) diff --git a/code/modules/mob/living/simple_animal/abnormality/waw/wrath_servant.dm b/code/modules/mob/living/simple_animal/abnormality/waw/wrath_servant.dm index dd816cbd7cd0..84e0673761d5 100644 --- a/code/modules/mob/living/simple_animal/abnormality/waw/wrath_servant.dm +++ b/code/modules/mob/living/simple_animal/abnormality/waw/wrath_servant.dm @@ -257,18 +257,18 @@ return if(prob(5)) if(friendly) - new /obj/effect/gibspawner/generic/silent/wrath_acid(get_turf(target)) + new /obj/effect/gibspawner/generic/silent/wrath_acid(get_turf(attacked_target)) else - new /obj/effect/gibspawner/generic/silent/wrath_acid/bad(get_turf(target)) + new /obj/effect/gibspawner/generic/silent/wrath_acid/bad(get_turf(attacked_target)) . = ..() attack_sound = pick('sound/abnormalities/wrath_servant/small_smash1.ogg','sound/abnormalities/wrath_servant/small_smash2.ogg') - if(!isliving(target) || (get_dist(target, src) > 1)) + if(!isliving(attacked_target) || (get_dist(attacked_target, src) > 1)) return - var/mob/living/L = target + var/mob/living/L = attacked_target L.deal_damage(rand(10, 15), BLACK_DAMAGE) - if(!istype(target, /mob/living/simple_animal/hostile/azure_hermit)) + if(!istype(attacked_target, /mob/living/simple_animal/hostile/azure_hermit)) return - var/mob/living/simple_animal/hostile/azure_hermit/AZ = target + var/mob/living/simple_animal/hostile/azure_hermit/AZ = attacked_target if(AZ.health > 120) return PerformEnding(AZ) @@ -727,8 +727,8 @@ /mob/living/simple_animal/hostile/azure_hermit/AttackingTarget(atom/attacked_target) if(!can_act || (status_flags & GODMODE)) return - if(istype(target, /mob/living/simple_animal/hostile/abnormality/wrath_servant)) - var/mob/living/simple_animal/hostile/abnormality/wrath_servant/SW = target + if(istype(attacked_target, /mob/living/simple_animal/hostile/abnormality/wrath_servant)) + var/mob/living/simple_animal/hostile/abnormality/wrath_servant/SW = attacked_target if(SW.stunned) return if(SW.health > 400) @@ -757,8 +757,8 @@ SW.icon_state = "wrath_staff_stun" SW.desc = "A large red monster with white bandages hanging from it. Its flesh oozes a bubble acid. A wooden staff is impaled in its chest, it can't seem to move!" return - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target if(get_user_level(H) < 3) say("Pardon me.") var/turf/TT = get_turf(H) diff --git a/code/modules/mob/living/simple_animal/abnormality/zayin/bald.dm b/code/modules/mob/living/simple_animal/abnormality/zayin/bald.dm index 31ae2759046e..efe01e9addb5 100644 --- a/code/modules/mob/living/simple_animal/abnormality/zayin/bald.dm +++ b/code/modules/mob/living/simple_animal/abnormality/zayin/bald.dm @@ -117,10 +117,10 @@ if(HAS_TRAIT(not_bald, TRAIT_BALD)) . -= not_bald -/mob/living/simple_animal/hostile/abnormality/bald/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/bald/AttackingTarget(atom/attacked_target) . = ..() - if(ishuman(target)) - var/mob/living/carbon/human/H = target + if(ishuman(attacked_target)) + var/mob/living/carbon/human/H = attacked_target do_bald(H) /mob/living/simple_animal/hostile/abnormality/bald/Login() diff --git a/code/modules/mob/living/simple_animal/abnormality/zayin/blubbering_toad.dm b/code/modules/mob/living/simple_animal/abnormality/zayin/blubbering_toad.dm index 91b51986a08d..4d09f09118e2 100644 --- a/code/modules/mob/living/simple_animal/abnormality/zayin/blubbering_toad.dm +++ b/code/modules/mob/living/simple_animal/abnormality/zayin/blubbering_toad.dm @@ -229,14 +229,14 @@ update_icon_state() //prevents icons from getting stuck ..() -/mob/living/simple_animal/hostile/abnormality/blubbering_toad/AttackingTarget() - if(!ishuman(target)) +/mob/living/simple_animal/hostile/abnormality/blubbering_toad/AttackingTarget(atom/attacked_target) + if(!ishuman(attacked_target)) return - if(target != idiot) - LoseTarget(target) + if(attacked_target != idiot) + LoseTarget(attacked_target) return ..() - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.sanity_lost) //prevents hitting the same guy in an infinite loop melee_damage_type = BLACK_DAMAGE if(H.health < 0) diff --git a/code/modules/mob/living/simple_animal/abnormality/zayin/bottle.dm b/code/modules/mob/living/simple_animal/abnormality/zayin/bottle.dm index f35de3ec6a90..c8b1e2e26dc9 100644 --- a/code/modules/mob/living/simple_animal/abnormality/zayin/bottle.dm +++ b/code/modules/mob/living/simple_animal/abnormality/zayin/bottle.dm @@ -230,8 +230,8 @@ /mob/living/simple_animal/hostile/abnormality/bottle/AttackingTarget(atom/attacked_target) if(eating) return - if(isliving(target)) - var/mob/living/L = target + if(isliving(attacked_target)) + var/mob/living/L = attacked_target if(faction_check_mob(L)) L.visible_message(span_danger("[src] feeds [L]... [L] seems heartier!"), span_nicegreen("[src] feeds you, you feel heartier!")) L.adjustBruteLoss(-speak_damage/2) diff --git a/code/modules/mob/living/simple_animal/abnormality/zayin/fairy_festival.dm b/code/modules/mob/living/simple_animal/abnormality/zayin/fairy_festival.dm index 9b75c676af9a..8562c85400ce 100644 --- a/code/modules/mob/living/simple_animal/abnormality/zayin/fairy_festival.dm +++ b/code/modules/mob/living/simple_animal/abnormality/zayin/fairy_festival.dm @@ -164,15 +164,15 @@ AddComponent(/datum/component/swarming) summon_backup() -/mob/living/simple_animal/hostile/mini_fairy/AttackingTarget() +/mob/living/simple_animal/hostile/mini_fairy/AttackingTarget(atom/attacked_target) . = ..() var/friends = 0 for(var/mob/living/simple_animal/hostile/mini_fairy/fren in view(6, src)) friends++ if(friends < 3) summon_backup() - if(ishuman(target)) - var/mob/living/L = target + if(ishuman(attacked_target)) + var/mob/living/L = attacked_target if(L.health < 0 || L.stat == DEAD) var/mob/living/simple_animal/hostile/mini_fairy/MF = new(get_turf(L)) MF.faction = src.faction diff --git a/code/modules/mob/living/simple_animal/abnormality/zayin/sleeping_beauty.dm b/code/modules/mob/living/simple_animal/abnormality/zayin/sleeping_beauty.dm index 9c51a111228d..e4ae27ea2019 100644 --- a/code/modules/mob/living/simple_animal/abnormality/zayin/sleeping_beauty.dm +++ b/code/modules/mob/living/simple_animal/abnormality/zayin/sleeping_beauty.dm @@ -159,9 +159,9 @@ //pink midnight code -/mob/living/simple_animal/hostile/abnormality/sleeping/AttackingTarget() +/mob/living/simple_animal/hostile/abnormality/sleeping/AttackingTarget(atom/attacked_target) if(grab_cooldown < world.time) - buckle_mob(target) + buckle_mob(attacked_target) grab_cooldown = world.time + grab_cooldown_time return ..() diff --git a/code/modules/mob/living/simple_animal/animal_defense.dm b/code/modules/mob/living/simple_animal/animal_defense.dm index 0ba7958c5842..e5b0ff5f0541 100644 --- a/code/modules/mob/living/simple_animal/animal_defense.dm +++ b/code/modules/mob/living/simple_animal/animal_defense.dm @@ -107,10 +107,9 @@ if(.) L.amount_grown = min(L.amount_grown + damage, L.max_grown) -/mob/living/simple_animal/attack_animal(mob/living/simple_animal/M) +/mob/living/simple_animal/attack_animal(mob/living/simple_animal/M, damage) . = ..() if(.) - var/damage = rand(M.melee_damage_lower, M.melee_damage_upper) return attack_threshold_check(damage, M.melee_damage_type) /mob/living/simple_animal/attack_slime(mob/living/simple_animal/slime/M) diff --git a/code/modules/mob/living/simple_animal/distortion/legend/papa_bongy.dm b/code/modules/mob/living/simple_animal/distortion/legend/papa_bongy.dm index cdef95961439..83713bf5d8d6 100644 --- a/code/modules/mob/living/simple_animal/distortion/legend/papa_bongy.dm +++ b/code/modules/mob/living/simple_animal/distortion/legend/papa_bongy.dm @@ -125,14 +125,14 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/distortion/papa_bongy/AttackingTarget() - if(!can_act || !target) +/mob/living/simple_animal/hostile/distortion/papa_bongy/AttackingTarget(atom/attacked_target) + if(!can_act || !attacked_target) return FALSE - if(!isliving(target)) + if(!isliving(attacked_target)) return ..() - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(ishuman(H)) - if(istype(target.ai_controller, /datum/ai_controller/insane/murder/bongy)) + if(istype(H.ai_controller, /datum/ai_controller/insane/murder/bongy)) LoseTarget() return//need to test whether this is still needed H.add_movespeed_modifier(/datum/movespeed_modifier/bongy) @@ -141,7 +141,7 @@ BongyPanic(H) ..() can_act = FALSE - return DingAttack(target) + return DingAttack(attacked_target) /mob/living/simple_animal/hostile/distortion/papa_bongy/proc/DingAttack(target) var/turf/target_turf = get_turf(target) @@ -241,10 +241,10 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/bongy_hostile/AttackingTarget() - if(!target) +/mob/living/simple_animal/hostile/bongy_hostile/AttackingTarget(atom/attacked_target) + if(!attacked_target) return FALSE - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target ..() if(ishuman(H) && H.sanity_lost) BongyPanic(H) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index c00b2af3caa5..3172fee0d344 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -27,6 +27,10 @@ var/rapid_melee = 1 //Number of melee attacks between each npc pool tick. Spread evenly. var/melee_queue_distance = 4 //If target is close enough start preparing to hit them if we have rapid_melee enabled var/melee_reach = 1 // The range at which a mob can make melee attacks + var/attack_cooldown = 0 + var/attack_is_on_cooldown = FALSE + var/attack_timer_id = null + var/old_rapid_melee = 0 var/ranged_message = "fires" //Fluff text for ranged mobs var/ranged_cooldown = 0 //What the current cooldown on ranged attacks is, generally world.time + ranged_cooldown_time @@ -52,7 +56,7 @@ var/atom/targets_from = null //all range/attack/etc. calculations should be done from this atom, defaults to the mob itself, useful for Vehicles and such var/attack_all_objects = FALSE //if true, equivalent to having a wanted_objects list containing ALL objects. var/lose_patience_timer_id //id for a timer to call LoseTarget(), used to stop mobs fixating on a target they can't reach - var/lose_patience_timeout = 300 //30 seconds by default, so there's no major changes to AI behaviour, beyond actually bailing if stuck forever + var/lose_patience_timeout = 60 //6 seconds by default, so there's no major changes to AI behaviour, beyond actually bailing if stuck forever // Experimental Target Memory. Short term HATE. Things added to this list will have their accossiated values considered. var/list/target_memory = list() @@ -77,6 +81,9 @@ var/patrol_tries = 0 //max of 5 var/patrol_move_timer = null + /// How willing a mob is to switch targets. More resistance means more aggro is required + var/target_switch_resistance + /mob/living/simple_animal/hostile/Initialize() /*Update Speed overrides set speed and sets it to the equivilent of move_to_delay. Basically @@ -86,13 +93,23 @@ if(SSmaptype.maptype in SSmaptype.citymaps) vision_range = min(vision_range, 8) + if(attack_cooldown == 0) + attack_cooldown = SSnpcpool.wait / rapid_melee + old_rapid_melee = rapid_melee if(!targets_from) targets_from = src + target_switch_resistance = clamp(maxHealth * 0.15, 100, 600) wanted_objects = typecacheof(wanted_objects) /mob/living/simple_animal/hostile/Destroy() targets_from = null + if(attack_timer_id) + deltimer(attack_timer_id) + attack_timer_id = null + if(lose_patience_timer_id) + deltimer(lose_patience_timer_id) + lose_patience_timer_id = null return ..() /mob/living/simple_animal/hostile/Life() @@ -123,19 +140,21 @@ return FALSE //we look around for potential targets and make it a list for later use. var/list/possible_targets = ListTargets() - if(environment_smash) - EscapeConfinement() - if(AICanContinue(possible_targets)) + if(!attack_is_on_cooldown) + TryAttack() if(!QDELETED(target) && !targets_from.Adjacent(target)) DestroyPathToTarget() if(!MoveToTarget(possible_targets)) //if we lose our target if(AIShouldSleep(possible_targets)) // we try to acquire a new one + target_memory.Cut() toggle_ai(AI_IDLE) // otherwise we go idle return TRUE /mob/living/simple_animal/hostile/handle_automated_movement() . = ..() + if(environment_smash) + EscapeConfinement() if(dodging && target && in_melee && isturf(loc) && isturf(target.loc)) var/datum/cb = CALLBACK(src, PROC_REF(sidestep)) if(sidestep_per_cycle > 1) //For more than one just spread them equally - this could changed to some sensible distribution later @@ -148,19 +167,30 @@ /mob/living/simple_animal/hostile/attacked_by(obj/item/I, mob/living/user) if(stat == CONSCIOUS && AIStatus != AI_OFF && !client && user) if(!target) + if(AIStatus == AI_IDLE) + toggle_ai(AI_ON) FindTarget(list(user), 1) + var/add_aggro = 0 + var/add_damtype + if(I) + add_aggro = I.force + add_damtype = I.damtype + if(ishuman(user)) + var/mob/living/carbon/human/H = user + var/justice_mod = 1 + get_modified_attribute_level(H, JUSTICE_ATTRIBUTE) / 100 + add_aggro *= justice_mod + if(istype(I, /obj/item/ego_weapon/)) + var/obj/item/ego_weapon/EW = I + add_aggro *= EW.force_multiplier else - var/add_aggro = 0 - var/add_damtype - if(I) - add_aggro = I.force - add_damtype = I.damtype - else - add_aggro = user.melee_damage_upper - if(isanimal(user)) - var/mob/living/simple_animal/A = user - add_damtype = A.melee_damage_type - RegisterAggroValue(user, add_aggro, add_damtype) + //this code does not seem to ever get executed + add_aggro = user.melee_damage_upper + if(isanimal(user)) + var/mob/living/simple_animal/A = user + add_damtype = A.melee_damage_type + RegisterAggroValue(user, add_aggro, add_damtype) + if(target == user) + GainPatience() return ..() /mob/living/simple_animal/hostile/bullet_act(obj/projectile/P) @@ -170,19 +200,24 @@ FindTarget(list(P.firer), 1) else Goto(P.starting, move_to_delay, 3) - //If we have a target register the attacker in our memory. - else - if(P.firer) - RegisterAggroValue(P.firer, P.damage, P.damage_type) - //If the projectile had no firer then just list it as nobuddy - if(!P.firer) - if(target_memory["nobuddy"] > MAX_DAMAGE_SUFFERED) - FindTarget() - //If our damage value for that person exceeds this number then we consider targeting them. - if(target_memory[P.firer] > MAX_DAMAGE_SUFFERED) - FindTarget(list(P.firer), 1) + //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) + damage = rand(M.melee_damage_lower, M.melee_damage_upper) + . = ..() + if(. && stat == CONSCIOUS && AIStatus != AI_OFF && !client) + if(!target) + if(AIStatus == AI_IDLE) + toggle_ai(AI_ON) + FindTarget(list(M), TRUE) + RegisterAggroValue(M, damage, M.melee_damage_type) + if(target == M) + GainPatience() + /mob/living/simple_animal/hostile/Move(atom/newloc, dir , step_x , step_y) if(dodging && approaching_target && prob(dodge_prob) && moving_diagonally == 0 && isturf(loc) && isturf(newloc)) return dodge(newloc,dir) @@ -217,10 +252,9 @@ if(AIStatus != AI_ON && AIStatus != AI_OFF) toggle_ai(AI_ON) FindTarget() - else if(target != null && prob(40))//No more pulling a mob forever and having a second player attack it, it can switch targets now if it finds a more suitable one - FindTarget() /mob/living/simple_animal/hostile/death(gibbed) + target_memory.Cut() LoseTarget() ..(gibbed) @@ -245,20 +279,6 @@ add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/variable_hostile_speed_bonus, TRUE, amount, TRUE) addtimer(CALLBACK(src, TYPE_PROC_REF(/mob, add_or_update_variable_movespeed_modifier), /datum/movespeed_modifier/variable_hostile_speed_bonus, TRUE, -amount, TRUE), time) -/mob/living/simple_animal/hostile/attacked_by(obj/item/I, mob/living/user) - if(stat == CONSCIOUS && !target && AIStatus != AI_OFF && !client && user) - FindTarget(list(user), 1) - return ..() - -/mob/living/simple_animal/hostile/bullet_act(obj/projectile/P) - if(stat == CONSCIOUS && !target && AIStatus != AI_OFF && !client) - if(P.firer && get_dist(src, P.firer) <= aggro_vision_range) - FindTarget(list(P.firer), 1) - Goto(P.starting, move_to_delay, 3) - - . = ..() - DamageEffect(P.damage_type) - /*-------------------\ |Damage Visual Effect| \-------------------*/ @@ -335,17 +355,17 @@ //////////////HOSTILE MOB TARGETTING AND AGGRESSION//////////// -/mob/living/simple_animal/hostile/proc/ListTargets() //Step 1, find out what we can see +/mob/living/simple_animal/hostile/proc/ListTargets(max_range = vision_range) //Step 1, find out what we can see if(!search_objects) - . = hearers(vision_range, targets_from) - src //Remove self, so we don't suicide + . = hearers(max_range, targets_from) - src //Remove self, so we don't suicide var/static/hostile_machines = typecacheof(list(/obj/machinery/porta_turret, /obj/vehicle/sealed/mecha)) - for(var/HM in typecache_filter_list(range(vision_range, targets_from), hostile_machines)) - if(can_see(targets_from, HM, vision_range)) - . += HM + for(var/obj/O in oview(max_range, targets_from)) + if(is_type_in_typecache(O, hostile_machines)) + . += O else - . = oview(vision_range, targets_from) + . = oview(max_range, targets_from) /mob/living/simple_animal/hostile/proc/ListTargetsLazy(_Z) var/static/hostile_machines = typecacheof(list(/obj/machinery/porta_turret, /obj/vehicle/sealed/mecha)) @@ -382,9 +402,9 @@ /* Essentially is the middle part of FindTarget but returns only a list without giving a target.*/ -/mob/living/simple_animal/hostile/proc/PossibleThreats() +/mob/living/simple_animal/hostile/proc/PossibleThreats(max_range = vision_range) . = list() - for(var/pos_targ in ListTargets()) + for(var/pos_targ in ListTargets(max_range)) var/atom/A = pos_targ if(Found(A)) . = list(A) @@ -471,7 +491,7 @@ This may be changed in the future if we want to still value them to see if we even care about attacking. */ if(Targets.len == 1) - return pick(Targets) + return Targets[1] /* Form a list of our targets, value how much we hate them, and then pick the target who has the MOST hate. */ @@ -482,7 +502,7 @@ /* If we have a target do we continue fighting if asked to pick again? */ - if(target) + if(target && target != .) if(KeepTargetCondition(target, .)) return target @@ -497,21 +517,37 @@ // Adds entity to THE LIST OF GRUDGES which is reset upon gaining a new target. /mob/living/simple_animal/hostile/proc/RegisterAggroValue(atom/remembered_target, value, damage_type) - if(!remembered_target) - remembered_target = "nobody" - if(!target_memory[remembered_target]) + if(!remembered_target || !damage_type) + return FALSE + if(!isnum(target_memory[remembered_target])) target_memory += remembered_target - if(damage_type) + + //could potentially add aggro as a mob armor type to also apply aggro damage coeff + //also could potentially check for remembered_target's aggro modifiers here such as from armor or status effects + if(damage_type == AGGRO_DAMAGE) + if(istype(remembered_target, /mob/living/carbon/human)) + var/mob/living/carbon/human/H = remembered_target + var/aggro_stat_modifier = 1 + (get_attribute_level(H, FORTITUDE_ATTRIBUTE) + get_attribute_level(H, PRUDENCE_ATTRIBUTE)) / 200 + value *= aggro_stat_modifier + else value *= damage_coeff.getCoeff(damage_type) target_memory[remembered_target] += value + if(target && remembered_target != target && target_memory[remembered_target] > target_memory[target] + target_switch_resistance && CanAttack(remembered_target)) + GiveTarget(remembered_target) + target_memory[remembered_target] += value + return TRUE + /*-------------------\ |Standard Hate Levels| |--------------------/ |Living Adjacent = 80 -|Living Far = 30 +|Living Far = 10 |Other Adjacent = 0 -|Other Far = -50 +|Other Far = -70 +|Modifiers: +|Previous target -60 +|Damage dealt +0 to +25 \-------------------*/ /mob/living/simple_animal/hostile/proc/ValueTarget(atom/target_thing) if(!target_thing) @@ -519,13 +555,6 @@ //This is a safety net just in the case that no value is returned. . = 0 - //If your farther than 5 tiles from us you suffer the max 50 of hate penalty. - . -= clamp(get_dist(targets_from, target_thing) * 10,0,50) - - //This is in order to make mobs not instantly reaggro on mobs they lost patience on. - if(isnum(target_memory[target_thing])) - . -= (target_memory[target_thing] / 10) - /* This is in order to treat Mechas as living by instead considering their pilot for the hate value. */ if(ismecha(target_thing)) @@ -533,13 +562,27 @@ for(var/occupant in M.occupants) if(isliving(occupant) && CanAttack(occupant)) . += 80 - - if(isliving(target_thing)) + else if(isliving(target_thing)) //Minimum starting hate for anything living is 80. . += 80 + //If your farther than 7 tiles from us you suffer the max 70 of hate penalty. + var/distance = get_dist(targets_from, target_thing) - 1 + . -= clamp(10 * distance , 0, 70) + + //This is in order to make mobs not instantly reaggro on mobs they lost patience on. + if(target_thing == target) + . -= 60 + + //up to 25 points for damage taken from target_thing + if(target_memory[target_thing]) + var/fraction_hp_lost_to_thing = min(target_memory[target_thing] / maxHealth, 1) + . += fraction_hp_lost_to_thing * 25 + /mob/living/simple_animal/hostile/proc/GiveTarget(new_target) target = new_target + target_memory.Cut() + target_memory[target] = 0 LosePatience() if(target != null) GainPatience() @@ -547,8 +590,6 @@ return 1 /mob/living/simple_animal/hostile/proc/LoseTarget() - if(target_memory.len > 1) - target_memory.Cut() target = null approaching_target = FALSE in_melee = FALSE @@ -581,12 +622,66 @@ /mob/living/simple_animal/hostile/proc/CheckAndAttack() if(!target) return FALSE - var/in_range = melee_reach > 1 ? target.Adjacent(targets_from) || (get_dist(src, target) <= melee_reach && (target in view(src, melee_reach))) : target.Adjacent(targets_from) + var/in_range = melee_reach > 1 ? target.Adjacent(targets_from) || (get_dist(src, target) <= melee_reach && (target in view(melee_reach, src))) : target.Adjacent(targets_from) if(targets_from && isturf(targets_from.loc) && in_range && !incapacitated()) AttackingTarget() return TRUE return FALSE +/mob/living/simple_animal/hostile/Bumped(atom/movable/AM) + . = ..() + if(!client && AIStatus == AI_ON && !attack_is_on_cooldown && CanAttack(AM)) + TryAttack() + +/mob/living/simple_animal/hostile/Moved() + . = ..() + if(!client && AIStatus == AI_ON && target) + INVOKE_ASYNC(src, PROC_REF(MovedTryAttack)) + +/mob/living/simple_animal/hostile/proc/MovedTryAttack() + SLEEP_CHECK_DEATH(move_to_delay * 0.5) // half of move delay so that its in between moves + if(!client && AIStatus == AI_ON && target && !attack_is_on_cooldown) + TryAttack() + +/mob/living/simple_animal/hostile/proc/TryAttack(called_by_timer = FALSE) + if(called_by_timer) + attack_timer_id = null + if(QDELETED(src)) + return + if(client || stat != CONSCIOUS || AIStatus != AI_ON || incapacitated() || !targets_from || !isturf(targets_from.loc)) + attack_is_on_cooldown = FALSE + if(attack_timer_id) + deltimer(attack_timer_id) + attack_timer_id = null + return + var/atom/attacked_target + var/should_gain_patience = FALSE + if(target && (target.Adjacent(targets_from) || melee_reach > 1 && can_see(targets_from, target, melee_reach))) + //attack target + attacked_target = target + should_gain_patience = TRUE + else + in_melee = FALSE + var/list/targets_in_range = PossibleThreats(melee_reach) + if(targets_in_range.len > 0) + //attack random thing in the list + attacked_target = pick(targets_in_range) + else + attack_is_on_cooldown = FALSE + + if(attacked_target) + attack_is_on_cooldown = TRUE + if(attack_timer_id) + deltimer(attack_timer_id) + attack_timer_id = null + AttackingTarget(attacked_target) + if(QDELETED(src) || stat != CONSCIOUS) + return + if(should_gain_patience) + GainPatience() + if(!attack_timer_id) + attack_timer_id = addtimer(CALLBACK(src, PROC_REF(TryAttack), TRUE), attack_cooldown, TIMER_STOPPABLE) + // Called by automated_action and causes the AI to go idle if it returns false. This proc is pretty big. /mob/living/simple_animal/hostile/proc/MoveToTarget(list/possible_targets) stop_automated_movement = 1 @@ -641,13 +736,6 @@ //This is for attacking. if(target) - if(targets_from && isturf(targets_from.loc) && in_range) - //If they're next to us, attack - MeleeAction() - else - if(rapid_melee > 1 && target_distance <= melee_queue_distance) - MeleeAction(FALSE) - in_melee = FALSE //If we're just preparing to strike do not enter sidestep mode return TRUE return FALSE @@ -675,13 +763,17 @@ walk_to(src, target, minimum_distance, delay) /mob/living/simple_animal/hostile/proc/AttackingTarget(atom/attacked_target) - SEND_SIGNAL(src, COMSIG_HOSTILE_ATTACKINGTARGET, target) - in_melee = TRUE - if(ismob(target)) - changeNext_move(SSnpcpool.wait / rapid_melee) - // Wow! that's a really weird variable to base attack speed on! Yes. - // It's because mobs typically attack once per this duration, because the subsystem calls handle_automated_movement() which then calls the attacking procs. - return target.attack_animal(src) + if(!attacked_target) + attacked_target = target + if(old_rapid_melee != rapid_melee) + attack_cooldown = SSnpcpool.wait / rapid_melee + old_rapid_melee = rapid_melee + SEND_SIGNAL(src, COMSIG_HOSTILE_ATTACKINGTARGET, attacked_target) + if(attacked_target == target) + in_melee = TRUE + if(ismob(attacked_target) || isobj(attacked_target)) + changeNext_move(attack_cooldown) + return attacked_target.attack_animal(src) //////////////END HOSTILE MOB TARGETTING AND AGGRESSION//////////// @@ -868,12 +960,17 @@ /mob/living/simple_animal/hostile/proc/GainPatience() if(lose_patience_timeout) LosePatience() - lose_patience_timer_id = addtimer(CALLBACK(src, PROC_REF(LoseTarget)), lose_patience_timeout, TIMER_STOPPABLE) + lose_patience_timer_id = addtimer(CALLBACK(src, PROC_REF(TryChangeTarget)), lose_patience_timeout, TIMER_STOPPABLE) +/mob/living/simple_animal/hostile/proc/TryChangeTarget() + lose_patience_timer_id = null + if(!FindTarget()) + LoseTarget() /mob/living/simple_animal/hostile/proc/LosePatience() - deltimer(lose_patience_timer_id) - + if(lose_patience_timer_id) + deltimer(lose_patience_timer_id) + lose_patience_timer_id = null //These two procs handle losing and regaining search_objects when attacked by a mob /mob/living/simple_animal/hostile/proc/LoseSearchObjects() diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm index ea7f320a71c2..fa6c4ce79523 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/megafauna.dm @@ -117,12 +117,12 @@ else ..() -/mob/living/simple_animal/hostile/megafauna/AttackingTarget() +/mob/living/simple_animal/hostile/megafauna/AttackingTarget(atom/attacked_target) if(recovery_time >= world.time) return . = ..() - if(. && isliving(target)) - var/mob/living/L = target + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(!client && ranged && ranged_cooldown <= world.time) OpenFire() diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/amber.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/amber.dm index 0ad86cc3f495..1a2a3de686b4 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/amber.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/amber.dm @@ -79,10 +79,12 @@ if(. && target) //reset burrow cooldown whenever in combat burrow_cooldown = world.time + burrow_cooldown_time -/mob/living/simple_animal/hostile/ordeal/amber_bug/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/amber_bug/AttackingTarget(atom/attacked_target) + if(burrowing) + return . = ..() if(.) - var/dir_to_target = get_dir(get_turf(src), get_turf(target)) + var/dir_to_target = get_dir(get_turf(src), get_turf(attacked_target)) animate(src, pixel_y = (base_pixel_y + 18), time = 2) addtimer(CALLBACK(src, PROC_REF(AnimateBack)), 2) for(var/i = 1 to 2) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/brown/dawn.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/brown/dawn.dm index 5bbbc2cb0abb..cc4bd0f98d4e 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/brown/dawn.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/brown/dawn.dm @@ -184,10 +184,10 @@ guaranteed_butcher_results = list(/obj/item/food/meat/slab/human/mutant/plant = 1) stat_attack = DEAD -/mob/living/simple_animal/hostile/ordeal/sin_gluttony/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/sin_gluttony/AttackingTarget(atom/attacked_target) . = ..() - if(. && isliving(target) && SSmaptype.maptype != "limbus_labs") - var/mob/living/L = target + if(. && isliving(attacked_target) && SSmaptype.maptype != "limbus_labs") + var/mob/living/L = attacked_target if(L.stat != DEAD) if(L.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(L, TRAIT_NODEATH)) devour(L) @@ -299,16 +299,16 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/sin_pride/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/sin_pride/AttackingTarget(atom/attacked_target) if(charging) return if(dash_cooldown <= world.time && prob(10) && !client) - PrepCharge(target) + PrepCharge(attacked_target) return . = ..() - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.health < 0) if(SSmaptype.maptype != "limbus_labs") H.gib() diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/crimson.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/crimson.dm index 642d56829898..c326d7b8f587 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/crimson.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/crimson.dm @@ -36,9 +36,9 @@ return TRUE return FALSE -/mob/living/simple_animal/hostile/ordeal/crimson_clown/AttackingTarget() - if(istype(target, /obj/machinery/computer/abnormality)) - var/obj/machinery/computer/abnormality/CA = target +/mob/living/simple_animal/hostile/ordeal/crimson_clown/AttackingTarget(atom/attacked_target) + if(istype(attacked_target, /obj/machinery/computer/abnormality)) + var/obj/machinery/computer/abnormality/CA = attacked_target if(console_attack_counter < 12) console_attack_counter += 1 visible_message(span_warning("[src] hits [CA]'s buttons at random!")) @@ -382,10 +382,10 @@ L.apply_damage(700, RED_DAMAGE, null, L.run_armor_check(null, RED_DAMAGE)) gib() -/mob/living/simple_animal/hostile/ordeal/crimson_tent/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/crimson_tent/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE - return Bite(target) + return Bite(attacked_target) /mob/living/simple_animal/hostile/ordeal/crimson_tent/proc/Bite(target) if (get_dist(src, target) > 3) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/gold/dusk.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/gold/dusk.dm index 04a7b3ac732a..7f4147e430d6 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/gold/dusk.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/gold/dusk.dm @@ -191,19 +191,19 @@ recharge_cooldown = world.time + recharge_cooldown_time current_beam = Beam(A, icon_state="lightning[rand(1,12)]", time = 3 SECONDS) -/mob/living/simple_animal/hostile/ordeal/thunderbird_corrosion/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/thunderbird_corrosion/AttackingTarget(atom/attacked_target) . = ..() - if(!isliving(target)) + if(!isliving(attacked_target)) return - var/mob/living/L = target + var/mob/living/L = attacked_target if(charge_level) // We deal up to 20 more damage, 1 for every point of charge. L.deal_damage(charge_level, BLACK_DAMAGE) playsound(get_turf(src), 'sound/weapons/fixer/generic/energyfinisher1.ogg', 75, 1) to_chat(L,span_danger("The [src] unleashes its charge!")) AdjustCharge(-charge_level) - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target if(H.stat >= SOFT_CRIT || H.health < 0) Convert(H) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/gold/noon.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/gold/noon.dm index 9a6d8edb0774..85099a61d838 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/gold/noon.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/gold/noon.dm @@ -60,10 +60,10 @@ AreaAttack() return -/mob/living/simple_animal/hostile/ordeal/white_lake_corrosion/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/white_lake_corrosion/AttackingTarget(atom/attacked_target) if(!can_act) return FALSE - return Slash(target) + return Slash(attacked_target) /mob/living/simple_animal/hostile/ordeal/white_lake_corrosion/proc/Slash(target) if (get_dist(src, target) > 3) @@ -293,14 +293,14 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/silentgirl_corrosion/AttackingTarget() - if(!vengeful && (target != current_target)) +/mob/living/simple_animal/hostile/ordeal/silentgirl_corrosion/AttackingTarget(atom/attacked_target) + if(!vengeful && (attacked_target != current_target)) return FALSE . = ..() if(.) - if(!ishuman(target)) + if(!ishuman(attacked_target)) return - var/mob/living/carbon/human/TH = target + var/mob/living/carbon/human/TH = attacked_target if(TH.health < 0 || TH.sanity_lost) finishing = TRUE TH.Stun(4 SECONDS) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/green.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/green.dm index 213668d0706d..902563287382 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/green.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/green.dm @@ -38,6 +38,7 @@ /// Can't move/attack when it's TRUE var/reloading = FALSE + var/firing_time = 0 /// When at 12 - it will start "reloading" var/fire_count = 0 @@ -64,18 +65,23 @@ /mob/living/simple_animal/hostile/ordeal/green_bot_big/OpenFire(atom/A) if(reloading) return FALSE + firing_time = world.time fire_count += 1 if(fire_count >= 12) StartReloading() return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/green_bot_big/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/green_bot_big/AttackingTarget(atom/attacked_target) + if(reloading) + return FALSE + if(world.time < firing_time + 1.2 SECONDS) + return FALSE . = ..() if(.) - if(!istype(target, /mob/living)) + if(!istype(attacked_target, /mob/living)) return - var/turf/T = get_turf(target) + var/turf/T = get_turf(attacked_target) if(!T) return for(var/i = 1 to 4) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/green/dawn.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/green/dawn.dm index 82114dbd31ca..d7bc8f7de31d 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/green/dawn.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/green/dawn.dm @@ -47,14 +47,16 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/green_bot/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/green_bot/AttackingTarget(atom/attacked_target) + if(finishing) + return . = ..() if(.) - if(!istype(target, /mob/living/carbon/human)) + if(!istype(attacked_target, /mob/living/carbon/human)) return if(SSmaptype.maptype in SSmaptype.citymaps) return - var/mob/living/carbon/human/TH = target + var/mob/living/carbon/human/TH = attacked_target if(TH.health < 0) finishing = TRUE TH.Stun(4 SECONDS) @@ -103,12 +105,14 @@ melee_damage_lower = 14 melee_damage_upper = 16 -/mob/living/simple_animal/hostile/ordeal/green_bot/syringe/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/green_bot/syringe/AttackingTarget(atom/attacked_target) + if(finishing) + return . = ..() if(.) - if(!istype(target, /mob/living/carbon/human)) + if(!istype(attacked_target, /mob/living/carbon/human)) return - var/mob/living/carbon/human/H = target + var/mob/living/carbon/human/H = attacked_target H.add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) addtimer(CALLBACK(H, TYPE_PROC_REF(/mob, remove_movespeed_modifier), /datum/movespeed_modifier/grab_slowdown/aggressive), 4 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/indigo.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/indigo.dm index d4389faca882..62136ba226ee 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/indigo.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/indigo.dm @@ -38,10 +38,10 @@ . = ..() a_intent_change(INTENT_HELP) -/mob/living/simple_animal/hostile/ordeal/indigo_noon/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/indigo_noon/AttackingTarget(atom/attacked_target) . = ..() - if(. && isliving(target)) - var/mob/living/L = target + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(L.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(L, TRAIT_NODEATH)) devour(L) @@ -196,10 +196,10 @@ . = ..() a_intent_change(INTENT_HELP) //so that they dont get body blocked by their kin outside of combat -/mob/living/simple_animal/hostile/ordeal/indigo_dusk/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/indigo_dusk/AttackingTarget(atom/attacked_target) . = ..() - if(. && isliving(target)) - var/mob/living/L = target + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(L.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(L, TRAIT_NODEATH)) devour(L) @@ -361,10 +361,10 @@ patrol_reset() return FALSE -/mob/living/simple_animal/hostile/ordeal/indigo_midnight/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/indigo_midnight/AttackingTarget(atom/attacked_target) . = ..() - if(. && isliving(target)) - var/mob/living/L = target + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(L.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(L, TRAIT_NODEATH)) devour(L) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/indigo/dawn.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/indigo/dawn.dm index fb28ff044476..cec30ba012a8 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/indigo/dawn.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/indigo/dawn.dm @@ -23,10 +23,10 @@ blood_volume = BLOOD_VOLUME_NORMAL silk_results = list(/obj/item/stack/sheet/silk/indigo_simple = 1) -/mob/living/simple_animal/hostile/ordeal/indigo_dawn/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/indigo_dawn/AttackingTarget(atom/attacked_target) . = ..() - if(. && isliving(target)) - var/mob/living/L = target + if(. && isliving(attacked_target)) + var/mob/living/L = attacked_target if(L.stat != DEAD) if(L.health <= HEALTH_THRESHOLD_DEAD && HAS_TRAIT(L, TRAIT_NODEATH)) devour(L) diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/white.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/white.dm index 1bf75d26c79a..2bdaacdd96c5 100644 --- a/code/modules/mob/living/simple_animal/hostile/ordeal/white.dm +++ b/code/modules/mob/living/simple_animal/hostile/ordeal/white.dm @@ -59,12 +59,12 @@ current_pulse_range = max(6, current_pulse_range - min(round(amount * 0.1), 4)) // Being attacked will reduce the range temporarily return ..() -/mob/living/simple_animal/hostile/ordeal/black_fixer/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/black_fixer/AttackingTarget(atom/attacked_target) if(busy) return ..() if(hammer_cooldown < world.time) - HammerAttack(target) + HammerAttack(attacked_target) /mob/living/simple_animal/hostile/ordeal/black_fixer/OpenFire() if(busy) @@ -407,15 +407,15 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/red_fixer/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/red_fixer/AttackingTarget(atom/attacked_target) if(busy) return ..() if(multislash_cooldown < world.time) - MultiSlash(target) + MultiSlash(attacked_target) return if(prob(50) && beam_cooldown < world.time) - LaserBeam(target) + LaserBeam(attacked_target) return /mob/living/simple_animal/hostile/ordeal/red_fixer/OpenFire() @@ -565,14 +565,14 @@ return FALSE return ..() -/mob/living/simple_animal/hostile/ordeal/pale_fixer/AttackingTarget() +/mob/living/simple_animal/hostile/ordeal/pale_fixer/AttackingTarget(atom/attacked_target) if(!can_act) return if(prob(60) && multislash_cooldown < world.time) - MultiSlash(target) + MultiSlash(attacked_target) return if(prob(40) && tentacle_cooldown < world.time) - TentacleAttack(target) + TentacleAttack(attacked_target) return return ..() diff --git a/code/modules/spells/ability_types/realized.dm b/code/modules/spells/ability_types/realized.dm index 8a55f6f43fbe..693b857bba04 100644 --- a/code/modules/spells/ability_types/realized.dm +++ b/code/modules/spells/ability_types/realized.dm @@ -1106,10 +1106,10 @@ AddComponent(/datum/component/knockback, 1, FALSE, TRUE) QDEL_IN(src, (90 SECONDS)) -/mob/living/simple_animal/hostile/shrimp/friendly/AttackingTarget() +/mob/living/simple_animal/hostile/shrimp/friendly/AttackingTarget(atom/attacked_target) . = ..() if(.) - var/mob/living/L = target + var/mob/living/L = attacked_target if(L.health < 0 || L.stat == DEAD) L.gib() //Punch them so hard they explode /* Flesh Idol - Repentance */ @@ -1283,8 +1283,8 @@ AddComponent(/datum/component/swarming) QDEL_IN(src, (20 SECONDS)) -/mob/living/simple_animal/hostile/naked_nest_serpent_friend/AttackingTarget() - var/mob/living/L = target +/mob/living/simple_animal/hostile/naked_nest_serpent_friend/AttackingTarget(atom/attacked_target) + var/mob/living/L = attacked_target var/datum/status_effect/stacking/infestation/INF = L.has_status_effect(/datum/status_effect/stacking/infestation) if(!INF) INF = L.apply_status_effect(/datum/status_effect/stacking/infestation) diff --git a/code/modules/suppressions/extraction.dm b/code/modules/suppressions/extraction.dm index 355d3f976992..b2233c9a9d29 100644 --- a/code/modules/suppressions/extraction.dm +++ b/code/modules/suppressions/extraction.dm @@ -176,8 +176,8 @@ /* Combat */ -/mob/living/simple_animal/hostile/megafauna/arbiter/AttackingTarget() - return OpenFire(target) +/mob/living/simple_animal/hostile/megafauna/arbiter/AttackingTarget(atom/attacked_target) + return OpenFire(attacked_target) /mob/living/simple_animal/hostile/megafauna/arbiter/OpenFire(target) if(charging) From 0d1294d9e39c8a97ac14d535e4058e6c7da98f23 Mon Sep 17 00:00:00 2001 From: Halonexus Date: Mon, 16 Dec 2024 23:52:27 +0300 Subject: [PATCH 2/5] removed obsolete file --- code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm diff --git a/code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm b/code/modules/mob/living/simple_animal/hostile/ordeal/gold.dm deleted file mode 100644 index e69de29bb2d1..000000000000 From bcfae4b8a86aad5b09b69085ff6c6c97ee4734c8 Mon Sep 17 00:00:00 2001 From: Halonexus Date: Tue, 17 Dec 2024 02:41:54 +0300 Subject: [PATCH 3/5] Timer replacements Based on my experience with optimising effects timers are really bad for performance compared to sleeps. --- .../living/simple_animal/hostile/hostile.dm | 82 +++++++++---------- 1 file changed, 40 insertions(+), 42 deletions(-) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 3172fee0d344..86c84c8b0c94 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -24,13 +24,12 @@ var/list/emote_taunt = list() var/taunt_chance = 0 - var/rapid_melee = 1 //Number of melee attacks between each npc pool tick. Spread evenly. + var/rapid_melee = 1 //Number of melee attacks between each npc pool tick. Spread evenly. !!OBSOLETE!! It still works but use attack_cooldown instead. var/melee_queue_distance = 4 //If target is close enough start preparing to hit them if we have rapid_melee enabled var/melee_reach = 1 // The range at which a mob can make melee attacks - var/attack_cooldown = 0 + var/attack_cooldown = 0 //The time between attacks in deciseconds. If 0 at initialization then uses rapid_melee to calculate the initial value. var/attack_is_on_cooldown = FALSE - var/attack_timer_id = null - var/old_rapid_melee = 0 + var/old_rapid_melee = 0 //used for compatibility with old rapid_melee system to detect outside code changing the rapid_melee value and adjusts attack_cooldown accordingly var/ranged_message = "fires" //Fluff text for ranged mobs var/ranged_cooldown = 0 //What the current cooldown on ranged attacks is, generally world.time + ranged_cooldown_time @@ -55,7 +54,7 @@ var/attack_same = 0 //Set us to 1 to allow us to attack our own faction var/atom/targets_from = null //all range/attack/etc. calculations should be done from this atom, defaults to the mob itself, useful for Vehicles and such var/attack_all_objects = FALSE //if true, equivalent to having a wanted_objects list containing ALL objects. - var/lose_patience_timer_id //id for a timer to call LoseTarget(), used to stop mobs fixating on a target they can't reach + var/patience_last_interaction = 0 //instead of expensive timers checks whether enough time passed in Life() to try find a different target var/lose_patience_timeout = 60 //6 seconds by default, so there's no major changes to AI behaviour, beyond actually bailing if stuck forever // Experimental Target Memory. Short term HATE. Things added to this list will have their accossiated values considered. var/list/target_memory = list() @@ -104,19 +103,18 @@ /mob/living/simple_animal/hostile/Destroy() targets_from = null - if(attack_timer_id) - deltimer(attack_timer_id) - attack_timer_id = null - if(lose_patience_timer_id) - deltimer(lose_patience_timer_id) - lose_patience_timer_id = null return ..() /mob/living/simple_animal/hostile/Life() . = ..() if(!.) //dead walk(src, 0) //stops walking - if(!can_patrol || client) + return + if(client) + return + if(lose_patience_timeout && patience_last_interaction + lose_patience_timeout < world.time) + LosePatience() + if(!can_patrol) return if(target && length(patrol_path)) //if AI has acquired a target while on patrol, stop patrol patrol_reset() @@ -155,7 +153,7 @@ . = ..() if(environment_smash) EscapeConfinement() - if(dodging && target && in_melee && isturf(loc) && isturf(target.loc)) + if(dodging && !QDELETED(target) && in_melee && isturf(loc) && isturf(target.loc)) var/datum/cb = CALLBACK(src, PROC_REF(sidestep)) if(sidestep_per_cycle > 1) //For more than one just spread them equally - this could changed to some sensible distribution later var/sidestep_delay = SSnpcpool.wait / sidestep_per_cycle @@ -533,7 +531,7 @@ value *= damage_coeff.getCoeff(damage_type) target_memory[remembered_target] += value - if(target && remembered_target != target && target_memory[remembered_target] > target_memory[target] + target_switch_resistance && CanAttack(remembered_target)) + if(!QDELETED(target) && remembered_target != target && target_memory[remembered_target] > target_memory[target] + target_switch_resistance && CanAttack(remembered_target)) GiveTarget(remembered_target) target_memory[remembered_target] += value return TRUE @@ -583,7 +581,6 @@ target = new_target target_memory.Cut() target_memory[target] = 0 - LosePatience() if(target != null) GainPatience() Aggro() @@ -636,27 +633,25 @@ /mob/living/simple_animal/hostile/Moved() . = ..() if(!client && AIStatus == AI_ON && target) - INVOKE_ASYNC(src, PROC_REF(MovedTryAttack)) + MovedTryAttack() /mob/living/simple_animal/hostile/proc/MovedTryAttack() + set waitfor = FALSE SLEEP_CHECK_DEATH(move_to_delay * 0.5) // half of move delay so that its in between moves if(!client && AIStatus == AI_ON && target && !attack_is_on_cooldown) TryAttack() -/mob/living/simple_animal/hostile/proc/TryAttack(called_by_timer = FALSE) - if(called_by_timer) - attack_timer_id = null +/mob/living/simple_animal/hostile/proc/TryAttack() + //at this point it is assumed that an attack can be made regardless of cooldown state, + //cooldown checks are made before calling TryAttack or you might want to be able to attack without caring about cooldowns if(QDELETED(src)) return if(client || stat != CONSCIOUS || AIStatus != AI_ON || incapacitated() || !targets_from || !isturf(targets_from.loc)) attack_is_on_cooldown = FALSE - if(attack_timer_id) - deltimer(attack_timer_id) - attack_timer_id = null return var/atom/attacked_target var/should_gain_patience = FALSE - if(target && (target.Adjacent(targets_from) || melee_reach > 1 && can_see(targets_from, target, melee_reach))) + if(!QDELETED(target) && (target.Adjacent(targets_from) || melee_reach > 1 && can_see(targets_from, target, melee_reach - 1))) //attack target attacked_target = target should_gain_patience = TRUE @@ -666,23 +661,32 @@ if(targets_in_range.len > 0) //attack random thing in the list attacked_target = pick(targets_in_range) - else - attack_is_on_cooldown = FALSE if(attacked_target) attack_is_on_cooldown = TRUE - if(attack_timer_id) - deltimer(attack_timer_id) - attack_timer_id = null AttackingTarget(attacked_target) if(QDELETED(src) || stat != CONSCIOUS) return + ResetAttackCooldown(attack_cooldown) if(should_gain_patience) GainPatience() - if(!attack_timer_id) - attack_timer_id = addtimer(CALLBACK(src, PROC_REF(TryAttack), TRUE), attack_cooldown, TIMER_STOPPABLE) + else + attack_is_on_cooldown = FALSE + DelayedTryAttack(attack_cooldown) + +/mob/living/simple_animal/hostile/proc/ResetAttackCooldown(delay) + set waitfor = FALSE + SLEEP_CHECK_DEATH(delay) + attack_is_on_cooldown = FALSE + TryAttack() + +/mob/living/simple_animal/hostile/proc/DelayedTryAttack(delay) + set waitfor = FALSE + SLEEP_CHECK_DEATH(delay) + if(!attack_is_on_cooldown) + TryAttack() - // Called by automated_action and causes the AI to go idle if it returns false. This proc is pretty big. +// Called by automated_action and causes the AI to go idle if it returns false. This proc is pretty big. /mob/living/simple_animal/hostile/proc/MoveToTarget(list/possible_targets) stop_automated_movement = 1 /*Stop automated movement is only used for wander code. @@ -690,7 +694,7 @@ target and if we are currently moving towards a target and they suddenly or are currently something we dont attack.*/ - if(!target) + if(QDELETED(target)) if(approaching_target) /* Approaching target means we are currently moving menacingly towards something. Otherwise we are just moving and if we @@ -768,6 +772,8 @@ if(old_rapid_melee != rapid_melee) attack_cooldown = SSnpcpool.wait / rapid_melee old_rapid_melee = rapid_melee + //Enforcing minimum attack cooldown here cause i tried setting this to 0 and it was not fun for the server.(1 decisecond is basically rapid_melee 20) + attack_cooldown = max(attack_cooldown, 1) SEND_SIGNAL(src, COMSIG_HOSTILE_ATTACKINGTARGET, attacked_target) if(attacked_target == target) in_melee = TRUE @@ -958,20 +964,12 @@ more than lose_patience_timeout deciseconds, which probably means we're stuck */ /mob/living/simple_animal/hostile/proc/GainPatience() - if(lose_patience_timeout) - LosePatience() - lose_patience_timer_id = addtimer(CALLBACK(src, PROC_REF(TryChangeTarget)), lose_patience_timeout, TIMER_STOPPABLE) + patience_last_interaction = world.time -/mob/living/simple_animal/hostile/proc/TryChangeTarget() - lose_patience_timer_id = null +/mob/living/simple_animal/hostile/proc/LosePatience() if(!FindTarget()) LoseTarget() -/mob/living/simple_animal/hostile/proc/LosePatience() - if(lose_patience_timer_id) - deltimer(lose_patience_timer_id) - lose_patience_timer_id = null - //These two procs handle losing and regaining search_objects when attacked by a mob /mob/living/simple_animal/hostile/proc/LoseSearchObjects() search_objects = 0 From 4eb1ecbd3253f6a67682397fd3c676e55b194f1a Mon Sep 17 00:00:00 2001 From: Halonexus Date: Tue, 17 Dec 2024 14:40:15 +0300 Subject: [PATCH 4/5] Updated patience checks --- code/modules/mob/living/simple_animal/hostile/hostile.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 86c84c8b0c94..03bcab619e6f 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -112,7 +112,7 @@ return if(client) return - if(lose_patience_timeout && patience_last_interaction + lose_patience_timeout < world.time) + if(lose_patience_timeout && !QDELETED(target) && AIStatus == AI_ON && patience_last_interaction + lose_patience_timeout < world.time) LosePatience() if(!can_patrol) return From 79d7d0f8b0e77d63b65747576d1c789431567850 Mon Sep 17 00:00:00 2001 From: Halonexus Date: Tue, 17 Dec 2024 18:06:37 +0300 Subject: [PATCH 5/5] Smoother retargetting --- .../living/simple_animal/hostile/hostile.dm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 03bcab619e6f..01da7bfb9c10 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -695,15 +695,17 @@ target and they suddenly or are currently something we dont attack.*/ if(QDELETED(target)) - if(approaching_target) - /* Approaching target means we are currently moving menacingly - towards something. Otherwise we are just moving and if we - are investigating a location we dont want to be told to stand still. */ - LoseTarget() - return FALSE + if(!FindTarget(possible_targets, TRUE)) + if(approaching_target) + /* Approaching target means we are currently moving menacingly + towards something. Otherwise we are just moving and if we + are investigating a location we dont want to be told to stand still. */ + LoseTarget() + return FALSE if(!CanAttack(target)) - LoseTarget() - return FALSE + if(!FindTarget(possible_targets, TRUE)) + LoseTarget() + return FALSE // The target we currently have is in our view and we must decide if we move towards it more. if(target in possible_targets) var/turf/T = get_turf(src)