diff --git a/code/modules/mining/lavaland/megafauna_loot.dm b/code/modules/mining/lavaland/megafauna_loot.dm index 7079b3bccc7..1c0f040d963 100644 --- a/code/modules/mining/lavaland/megafauna_loot.dm +++ b/code/modules/mining/lavaland/megafauna_loot.dm @@ -1022,7 +1022,7 @@ targeted_turfs += target_turf balloon_alert(user, "you aim at [target_turf]...") new /obj/effect/temp_visual/telegraphing/thunderbolt(target_turf) - addtimer(CALLBACK(src, .proc/throw_thunderbolt, target_turf, power_boosted, user), 1.5 SECONDS) + addtimer(CALLBACK(src, .proc/throw_thunderbolt, target_turf, power_boosted), 1.5 SECONDS) thunder_charges-- addtimer(CALLBACK(src, .proc/recharge), thunder_charge_time) log_game("[key_name(user)] fired the staff of storms at [AREACOORD(target_turf)].") @@ -1031,7 +1031,7 @@ thunder_charges = min(thunder_charges + 1, max_thunder_charges) playsound(src, 'sound/magic/charge.ogg', 10, TRUE, extrarange = SILENCED_SOUND_EXTRARANGE, falloff_distance = 0) -/obj/item/storm_staff/proc/throw_thunderbolt(turf/target, boosted, mob/user) +/obj/item/storm_staff/proc/throw_thunderbolt(turf/target, boosted) targeted_turfs -= target new /obj/effect/temp_visual/thunderbolt(target) var/list/affected_turfs = list(target) @@ -1046,12 +1046,6 @@ for(var/mob/living/hit_mob in turf) to_chat(hit_mob, span_userdanger("You've been struck by lightning!")) hit_mob.electrocute_act(15 * (isanimal(hit_mob) ? 3 : 1) * (turf == target ? 2 : 1) * (boosted ? 2 : 1), src, flags = SHOCK_TESLA|SHOCK_NOSTUN) - if(!ishostile(hit_mob)) - continue - - var/mob/living/simple_animal/hostile/hit_hostile = hit_mob - if(hit_hostile.stat == CONSCIOUS && !hit_hostile.target && hit_hostile.AIStatus != AI_OFF && !hit_hostile.client) //Mimicks what would happen on a melee attack - hit_hostile.FindTarget(list(user), 1) for(var/obj/hit_thing in turf) hit_thing.take_damage(20, BURN, ENERGY, FALSE) diff --git a/code/modules/mob/living/simple_animal/hostile/hostile.dm b/code/modules/mob/living/simple_animal/hostile/hostile.dm index 851ceb2b1b2..a38ba295507 100644 --- a/code/modules/mob/living/simple_animal/hostile/hostile.dm +++ b/code/modules/mob/living/simple_animal/hostile/hostile.dm @@ -119,13 +119,18 @@ /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) + FindTarget(list(user)) + return ..() + +/mob/living/simple_animal/hostile/electrocute_act(shock_damage, source, siemens_coeff, flags) + if(stat == CONSCIOUS && !target && AIStatus != AI_OFF && !client) + FindTarget(list(source)) 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) + FindTarget(list(P.firer)) Goto(P.starting, move_to_delay, 3) return ..() @@ -144,22 +149,27 @@ else . = oview(vision_range, target_from) -/mob/living/simple_animal/hostile/proc/FindTarget(list/possible_targets, HasTargetsList = 0)//Step 2, filter down possible targets to things we actually care about - . = list() - if(!HasTargetsList) - possible_targets = ListTargets() - for(var/pos_targ in possible_targets) - var/atom/A = pos_targ - if(Found(A))//Just in case people want to override targetting - . = list(A) - break - if(CanAttack(A))//Can we attack it? - . += A - continue - var/Target = PickTarget(.) - GiveTarget(Target) - return Target //We now have a target +/mob/living/simple_animal/hostile/proc/FindTarget(list/possible_targets)//Step 2, filter down possible targets to things we actually care about + var/list/all_potential_targets = list() + if(isnull(possible_targets)) + possible_targets = ListTargets() + + for(var/atom/pos_targ as anything in possible_targets) + if(Found(pos_targ)) //Just in case people want to override targetting + all_potential_targets = list(pos_targ) + break + + if(isitem(pos_targ) && ismob(pos_targ.loc)) //If source is from an item, check the holder of it. + if(CanAttack(pos_targ.loc)) + all_potential_targets += pos_targ.loc + else + if(CanAttack(pos_targ)) + all_potential_targets += pos_targ + + var/found_target = PickTarget(all_potential_targets) + GiveTarget(found_target) + return found_target //We now have a target /mob/living/simple_animal/hostile/proc/PossibleThreats() @@ -523,14 +533,14 @@ if(AI_ON) . = 1 if(AI_IDLE) - if(FindTarget(possible_targets, 1)) + if(FindTarget(possible_targets)) . = 1 toggle_ai(AI_ON) //Wake up for more than one Life() cycle. else . = 0 /mob/living/simple_animal/hostile/proc/AIShouldSleep(list/possible_targets) - return !FindTarget(possible_targets, 1) + return !FindTarget(possible_targets) //These two procs handle losing our target if we've failed to attack them for @@ -575,7 +585,7 @@ else tlist = ListTargets() - if(AIStatus == AI_IDLE && FindTarget(tlist, 1)) + if(AIStatus == AI_IDLE && FindTarget(tlist)) if(cheap_search) //Try again with full effort FindTarget() toggle_ai(AI_ON) diff --git a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm index dd550099053..8bf2c130532 100644 --- a/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm +++ b/code/modules/mob/living/simple_animal/hostile/megafauna/hierophant.dm @@ -710,7 +710,7 @@ Difficulty: Hard if(H.stat == CONSCIOUS && !H.target && H.AIStatus != AI_OFF && !H.client) if(!QDELETED(caster)) if(get_dist(H, caster) <= H.aggro_vision_range) - H.FindTarget(list(caster), 1) + H.FindTarget(list(caster)) else H.Goto(get_turf(caster), H.move_to_delay, 3) if(monster_damage_boost && (ismegafauna(L) || istype(L, /mob/living/simple_animal/hostile/asteroid)))