From 2fae0d653dc5ea01a769cebf7d3a5765a76e2c08 Mon Sep 17 00:00:00 2001 From: Sypsoti Date: Sun, 10 Apr 2022 23:00:02 -0500 Subject: [PATCH] several improvements: WIP --- code/modules/ai/ai_holder_combat_unseen.dm | 4 +- .../ai/ai_holder_subtypes/xeno_alien_ai.dm | 37 +++++++++++ code/modules/ai/ai_holder_targeting.dm | 8 +++ .../simple_mob/subtypes/animal/space/alien.dm | 65 ++++++++++++++++++- polaris.dme | 1 + 5 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 code/modules/ai/ai_holder_subtypes/xeno_alien_ai.dm diff --git a/code/modules/ai/ai_holder_combat_unseen.dm b/code/modules/ai/ai_holder_combat_unseen.dm index 6f6fbac567..2ba7b4b13a 100644 --- a/code/modules/ai/ai_holder_combat_unseen.dm +++ b/code/modules/ai/ai_holder_combat_unseen.dm @@ -4,7 +4,7 @@ /datum/ai_holder/proc/engage_unseen_enemy() ai_log("engage_unseen_enemy() : Entering.", AI_LOG_TRACE) // Also handled in strategic updates but handling it here allows for more fine resolution timeouts - if((lose_target_time+lose_target_timeout) >= world.time) + if((lose_target_time+lose_target_timeout) <= world.time) return remove_target() // Lets do some last things before giving up. if(conserve_ammo || !holder.ICheckRangedAttack(target_last_seen_turf)) @@ -12,7 +12,7 @@ // Go to where you last saw the enemy. return give_destination(target_last_seen_turf, 1, TRUE) // Sets stance as well // We last saw them next to us, so do a blind attack on that tile. - else if(melee_on_tile(target_last_seen_turf) != ATTACK_SUCCESSFUL && intelligence_level >= AI_NORMAL) + else if((melee_on_tile(target_last_seen_turf) != ATTACK_SUCCESSFUL) && (intelligence_level >= AI_NORMAL)) var/obj/O = find_escape_route() if(istype(O)) return give_destination(get_turf(O), 0, TRUE) diff --git a/code/modules/ai/ai_holder_subtypes/xeno_alien_ai.dm b/code/modules/ai/ai_holder_subtypes/xeno_alien_ai.dm new file mode 100644 index 0000000000..6a96574371 --- /dev/null +++ b/code/modules/ai/ai_holder_subtypes/xeno_alien_ai.dm @@ -0,0 +1,37 @@ +/* +/// For Skathari +/// In its own file to easily expand upon. Mob found in alien.dm +*/ + +/datum/ai_holder/simple_mob/xeno_alien /// Basic + hostile = TRUE + retaliate = TRUE + cooperative = TRUE + returns_home = FALSE + can_flee = FALSE + speak_chance = 0 + wander = TRUE + base_wander_delay = 4 + +/datum/ai_holder/simple_mob/xeno_alien/post_melee_attack(atom/A) + if(holder.Adjacent(A)) + holder.IMove(get_step(holder, pick(alldirs))) + holder.face_atom(A) + +/datum/ai_holder/simple_mob/xeno_alien/ranged /// Drones + pointblank = TRUE + ignore_incapacitated = TRUE /// We're squishier and our tox hits hard. Focus on who's up. + var/run_if_this_close = 4 + var/max_distance = 6 + +/datum/ai_holder/simple_mob/xeno_alien/ranged/on_engagement(atom/A) + if(get_dist(holder, A) < run_if_this_close) + holder.IMove(get_step_away(holder, A, run_if_this_close)) + holder.face_atom(A) + else if(get_dist(holder, A) > max_distance) + holder.IMove(get_step_towards(holder, A)) + holder.face_atom(A) + +/datum/ai_holder/simple_mob/xeno_alien/empress /// Big mama + ignore_incapacitated = TRUE /// Focus on better threats. + intelligence_level = AI_SMART /// She's got the brains \ No newline at end of file diff --git a/code/modules/ai/ai_holder_targeting.dm b/code/modules/ai/ai_holder_targeting.dm index f23c70cb5b..ca52c8b7e0 100644 --- a/code/modules/ai/ai_holder_targeting.dm +++ b/code/modules/ai/ai_holder_targeting.dm @@ -4,6 +4,7 @@ var/hostile = FALSE // Do we try to hurt others? var/retaliate = FALSE // Attacks whatever struck it first. Mobs will still attack back if this is false but hostile is true. var/mauling = FALSE // Attacks unconscious mobs + var/ignore_incapacitated = FALSE // If it's interested in attacking targets that are STUNNED. var/handle_corpse = FALSE // Allows AI to acknowledge corpses (e.g. nurse spiders) var/atom/movable/target = null // The thing (mob or object) we're trying to kill. @@ -129,6 +130,9 @@ return TRUE else return FALSE + if(L.incapacitated(INCAPACITATION_STUNNED)) // Are they stunned and do we care? + if(ignore_incapacitated) + return FALSE if(holder.IIsAlly(L)) return FALSE return TRUE @@ -161,6 +165,10 @@ /datum/ai_holder/proc/lose_target() ai_log("lose_target() : Entering.", AI_LOG_TRACE) if(target) + ai_log("lose_target() : Had a target, checking if still valid.", AI_LOG_DEBUG) + if(!can_attack(target, FALSE)) /// If it's not valid to chase, don't keep looking. + remove_target() + return find_target() ai_log("lose_target() : Had a target, setting to null and LTT.", AI_LOG_DEBUG) target = null lose_target_time = world.time diff --git a/code/modules/mob/living/simple_mob/subtypes/animal/space/alien.dm b/code/modules/mob/living/simple_mob/subtypes/animal/space/alien.dm index d37b88b7e4..901009bccd 100644 --- a/code/modules/mob/living/simple_mob/subtypes/animal/space/alien.dm +++ b/code/modules/mob/living/simple_mob/subtypes/animal/space/alien.dm @@ -21,13 +21,68 @@ turn_sound = "skathari_chitter" harm_intent_damage = 5 melee_damage_lower = 25 - melee_damage_upper = 25 + melee_damage_upper = 35 attack_armor_pen = 15 attack_sharp = TRUE attack_edge = TRUE attacktext = list("slashed") attack_sound = 'sound/weapons/bladeslice.ogg' + ai_holder_type = /datum/ai_holder/simple_mob/xeno_alien /// Found in xeno_alien_ai.dm + + special_attack_min_range = 3 + special_attack_max_range = 7 + var/special_attack_distance = 1 /// Special cases for drone subtype that doesn't want to get close. + special_attack_cooldown = 5 SECONDS +/mob/living/simple_mob/animal/space/alien/do_special_attack(atom/A) + /// Copied MOSTLY from bluespace slime's do_special_attack + if(!A) + to_chat(src, span("warning", "There's nothing to teleport to.")) + return FALSE + + var/list/nearby_things = range(special_attack_distance, A) + var/list/valid_turfs = list() + + // Check tile density and distance. + for(var/turf/potential_turf in nearby_things) + var/valid_turf = TRUE + if(potential_turf.density) + continue + for(var/atom/movable/AM in potential_turf) + if(AM.density) + valid_turf = FALSE + if(get_dist(potential_turf, A) != special_attack_distance) /// We want to maintain an acceptable distance. + valid_turf = FALSE + if(!can_see(src, potential_turf, 7)) /// We don't want to teleport out of sight! + valid_turf = FALSE + if(valid_turf) + valid_turfs.Add(potential_turf) + + var/turf/T = get_turf(src) + var/turf/target_turf = pick(valid_turfs) + + if(!target_turf) + to_chat(src, span("warning", "There wasn't an unoccupied spot to teleport to.")) + return FALSE + + var/datum/effect_system/spark_spread/s1 = new /datum/effect_system/spark_spread + s1.set_up(5, 1, T) + var/datum/effect_system/spark_spread/s2 = new /datum/effect_system/spark_spread + s2.set_up(5, 1, target_turf) + + + T.visible_message(span("notice", "\The [src] vanishes!")) + s1.start() + + forceMove(target_turf) + playsound(target_turf, 'sound/effects/phasein.ogg', 50, 1) + to_chat(src, span("notice", "You teleport to \the [target_turf].")) + + target_turf.visible_message(span("warning", "\The [src] appears!")) + s2.start() + + if(Adjacent(A)) + attack_target(A) /mob/living/simple_mob/animal/space/alien/death() var/turf/center = get_turf(src) @@ -51,10 +106,14 @@ icon_living = "aliend_running" icon_dead = "aliend_l" icon_rest = "aliend_sleep" + maxHealth = 80 health = 80 melee_damage_lower = 15 - melee_damage_upper = 15 + melee_damage_upper = 20 projectiletype = /obj/item/projectile/energy/skathari + ai_holder_type = /datum/ai_holder/simple_mob/xeno_alien/ranged + special_attack_min_range = 1 /// We want to move away quickly! + special_attack_distance = 5 /// Puts us right in the middle of our acceptable range. /mob/living/simple_mob/animal/space/alien/queen/empress/mother @@ -77,6 +136,8 @@ icon_expected_width = 96 icon_expected_height = 96 + special_attack_distance = 3 /// Will encourage mix of ranged and melee attacks. + /decl/mob_organ_names/skathari hit_zones = list("carapace", "abdomen", "left forelegs", "right forelegs", "left hind legs", "right hind legs", "head") diff --git a/polaris.dme b/polaris.dme index b91b88c255..d217d81ad0 100644 --- a/polaris.dme +++ b/polaris.dme @@ -1443,6 +1443,7 @@ #include "code\modules\ai\say_list.dm" #include "code\modules\ai\ai_holder_subtypes\simple_mob_ai.dm" #include "code\modules\ai\ai_holder_subtypes\slime_xenobio_ai.dm" +#include "code\modules\ai\ai_holder_subtypes\xeno_alien_ai.dm" #include "code\modules\alarm\alarm.dm" #include "code\modules\alarm\alarm_handler.dm" #include "code\modules\alarm\atmosphere_alarm.dm"