Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Hive Wars #93

Merged
merged 37 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
9079ffb
rival hives will fight to the death now
xDanilcusx Jan 7, 2024
e1aa576
Merge branch 'PvE-CMSS13:master' into XvX
xDanilcusx Jan 7, 2024
f614cc0
human -> carbon crusher's charge refactor
xDanilcusx Jan 7, 2024
e7c3862
Merge branch 'PvE-CMSS13:master' into XvX
xDanilcusx Jan 16, 2024
d11551d
issues being fixed
xDanilcusx Jan 16, 2024
b96cc26
lil checks refactor
xDanilcusx Jan 16, 2024
9c508d9
ouch wrong expression
xDanilcusx Jan 16, 2024
0442c12
IS_SAME_HIVENUMBER check implementation
xDanilcusx Jan 16, 2024
f0001b7
ai_move_idle refactor
xDanilcusx Jan 16, 2024
88c6ed4
nahh that's better
xDanilcusx Jan 16, 2024
fdc4e92
benos hate crit xenos
xDanilcusx Jan 21, 2024
c18c41a
Try that
morrowwolf Jan 22, 2024
8577f99
Merge branch 'PvE-CMSS13:master' into XvX
xDanilcusx Jan 22, 2024
7e8e469
making crusher lil dumber this time
xDanilcusx Jan 22, 2024
3257b25
Merge branch 'master' into XvX
xDanilcusx Jan 23, 2024
98607ba
null.moving fix
xDanilcusx Jan 23, 2024
662a63e
check_mob_target OOP refactor?
xDanilcusx Jan 23, 2024
eb0e383
Update xeno_ai_interaction.dm
xDanilcusx Jan 24, 2024
b330771
Stops xenos from nibbling friendlies
xDanilcusx Jan 24, 2024
2a1a5ee
Making use of IS_SAME_HIVENUMBER
xDanilcusx Jan 24, 2024
a78f52b
override behavior fixes
xDanilcusx Jan 25, 2024
ad847d0
resting -> set_resting()
xDanilcusx Jan 25, 2024
6af53f2
clearing override behavior queue
xDanilcusx Jan 25, 2024
4624562
Allow LZ weeding by default
xDanilcusx Jan 25, 2024
02738c2
remove_from_queue() and qdel signals
xDanilcusx Jan 25, 2024
78129a8
made xeno AI respect mobs alpha
xDanilcusx Jan 26, 2024
980fa38
more visible comment titles
xDanilcusx Jan 26, 2024
30feffa
making use of IS_SAME_HIVENUMBER again
xDanilcusx Jan 26, 2024
4bb7eb2
capture behavior will seek for mob on parent turf now
xDanilcusx Jan 26, 2024
1a3acec
APC is no longer a valid target while it has allies in it
xDanilcusx Jan 28, 2024
23e9cb9
abit smarter checks for ally vehicle targeting
xDanilcusx Jan 28, 2024
3814a83
stop fucking us up queen
xDanilcusx Jan 29, 2024
1ee7b0d
a few changes
xDanilcusx Feb 6, 2024
b7bb30f
i'm pretty sure that's it, that's the last changes
xDanilcusx Feb 6, 2024
25a08a1
oops forgot to put exclamation mark
xDanilcusx Feb 7, 2024
bcf7d1b
also this should return TRUE to stop retargeting on attack override
xDanilcusx Feb 7, 2024
14093ce
Merge branch 'master' into XvX
xDanilcusx Feb 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions code/__DEFINES/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,6 @@ PROBABILITY CALCULATIONS ARE HERE

/// Special blockers for pathfinding or obstacle handling
#define XENO_AI_SPECIAL_BLOCKERS list(/obj/flamer_fire, /obj/vehicle/multitile, /turf/open/space)

// Friend-or-foe universal check
#define IS_SAME_HIVENUMBER(A,B) (A.hivenumber == B.hivenumber)
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,29 @@

var/list/possible_charge_dirs = list()

for(var/mob/living/carbon/human/base_checked_human as anything in GLOB.alive_human_list)
var/distance_between_base_human_and_xeno = get_dist(processing_xeno, base_checked_human)
for(var/mob/living/carbon/base_checked_carbon as anything in GLOB.alive_mob_list)
var/distance_between_base_carbon_and_xeno = get_dist(processing_xeno, base_checked_carbon)

if(distance_between_base_human_and_xeno > MAXIMUM_TARGET_DISTANCE)
if(distance_between_base_carbon_and_xeno > MAXIMUM_TARGET_DISTANCE)
continue

if(distance_between_base_human_and_xeno < MINIMUM_CHARGE_DISTANCE)
if(distance_between_base_carbon_and_xeno < MINIMUM_CHARGE_DISTANCE)
continue

if(!processing_xeno.check_mob_target(base_checked_human))
if(!base_checked_carbon.check_mob_target(processing_xeno))
continue

var/secondary_count = 0
var/secondary_x_sum = 0
var/secondary_y_sum = 0

for(var/mob/living/carbon/human/secondary_checked_human in range(FLOCK_SCAN_RADIUS, base_checked_human))
if(!processing_xeno.check_mob_target(secondary_checked_human))
for(var/mob/living/carbon/secondary_checked_carbon in range(FLOCK_SCAN_RADIUS, base_checked_carbon))
if(!secondary_checked_carbon.check_mob_target(processing_xeno))
continue

secondary_count++
secondary_x_sum += secondary_checked_human.x
secondary_y_sum += secondary_checked_human.y
secondary_x_sum += secondary_checked_carbon.x
secondary_y_sum += secondary_checked_carbon.y

if(secondary_count < MIN_TARGETS_TO_CHARGE)
continue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
woyer.flick_attack_overlay(carbone, "disarm")
carbone.throw_atom(throw_turf, fling_distance, SPEED_VERY_FAST, woyer, TRUE)

COOLDOWN_RESET(woyer, forced_retarget_cooldown)
apply_cooldown()
return ..()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@
if(idle_xeno.throwing)
return

if(next_home_search < world.time && (!home_turf || !home_turf.weeds || get_dist(home_turf, idle_xeno) > max_distance_from_home))
if(next_home_search < world.time && (!home_turf || !home_turf.weeds || !IS_SAME_HIVENUMBER(idle_xeno, home_turf.weeds) || get_dist(home_turf, idle_xeno) > max_distance_from_home))
var/turf/T = get_turf(idle_xeno.loc)
next_home_search = world.time + home_search_delay
if(T.weeds)
var/obj/effect/alien/weeds/current_weeds = T.weeds
if(current_weeds && IS_SAME_HIVENUMBER(idle_xeno, current_weeds))
home_turf = T
else
var/shortest_distance = INFINITY
for(var/i in RANGE_TURFS(home_locate_range, T))
var/turf/potential_home = i
if(potential_home.weeds && !potential_home.density && get_dist(idle_xeno, potential_home) < shortest_distance)
var/obj/effect/alien/weeds/potential_weeds = potential_home.weeds
if(potential_weeds && IS_SAME_HIVENUMBER(idle_xeno, potential_weeds) && !potential_home.density && get_dist(idle_xeno, potential_home) < shortest_distance)
home_turf = potential_home
shortest_distance = get_dist(idle_xeno, potential_home)
if(idle_xeno.resting)
idle_xeno.lay_down()

if(!home_turf)
return
Expand Down
6 changes: 4 additions & 2 deletions code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@
if(checked_turf in blacklisted_turfs)
return FALSE

if(checked_turf.weeds)
var/obj/effect/alien/weeds/checked_weeds = checked_turf.weeds
if(checked_weeds && checked_weeds.hivenumber == parent.hivenumber)
return FALSE

if(checked_turf.is_weedable() < FULLY_WEEDABLE)
return FALSE

if(locate(/obj/effect/alien/weeds/node) in range(3, checked_turf))
var/obj/effect/alien/weeds/found_weeds = locate(/obj/effect/alien/weeds/node) in range(3, checked_turf)
if(found_weeds && found_weeds.hivenumber == parent.hivenumber)
return FALSE

if(checked_turf.density)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
registered_turfs += cycled_open_turf

var/mob/living/carbon/human/possible_target = locate() in cycled_open_turf
if(possible_target && (!parent.current_target || get_dist(parent, possible_target) < get_dist(parent, parent.current_target)) && parent.check_mob_target(possible_target))
if(possible_target && (!parent.current_target || get_dist(parent, possible_target) < get_dist(parent, parent.current_target)) && possible_target.check_mob_target(parent))
parent.current_target = possible_target

/datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals()
Expand All @@ -286,7 +286,7 @@
return

var/mob/living/carbon/human/possible_target = entering_atom
if(!parent.current_target || get_dist(parent, possible_target) < get_dist(parent, parent.current_target) && parent.check_mob_target(possible_target))
if(!parent.current_target || get_dist(parent, possible_target) < get_dist(parent, parent.current_target) && possible_target.check_mob_target(parent))
parent.current_target = possible_target

/datum/xeno_ai_movement/linger/lurking/proc/lurking_parent_moved(atom/movable/moving_atom, atom/oldloc, direction, Forced)
Expand Down
47 changes: 27 additions & 20 deletions code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/// The actual cooldown declaration for forceful retargeting, reference forced_retarget_time for time in between checks
COOLDOWN_DECLARE(forced_retarget_cooldown)

/// Amount of times no path found has occured
var/no_path_found_amount = 0

/// The time interval between calculating new paths if we cannot find a path
var/no_path_found_period = (2.5 SECONDS)

Expand Down Expand Up @@ -74,7 +77,8 @@
var/stat_check = FALSE
if(istype(current_target, /mob))
var/mob/current_target_mob = current_target
stat_check = (current_target_mob.stat != CONSCIOUS)
var/enemy_stat = current_target_mob.stat
stat_check = isxeno(current_target_mob) ? (enemy_stat == DEAD) : (enemy_stat != CONSCIOUS)
xDanilcusx marked this conversation as resolved.
Show resolved Hide resolved

if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range || COOLDOWN_FINISHED(src, forced_retarget_cooldown))
current_target = get_target(ai_range)
Expand Down Expand Up @@ -168,10 +172,15 @@
return FALSE

if(no_path_found)
COOLDOWN_START(src, no_path_found_cooldown, no_path_found_period)

if(no_path_found_amount > 0)
COOLDOWN_START(src, no_path_found_cooldown, no_path_found_period)
no_path_found = FALSE
no_path_found_amount++
return FALSE

no_path_found_amount = 0

if((!current_path || (next_path_generation < world.time && current_target_turf != T)) && COOLDOWN_FINISHED(src, no_path_found_cooldown))
if(!XENO_CALCULATING_PATH(src) || current_target_turf != T)
SSxeno_pathfinding.calculate_path(src, T, max_range, src, CALLBACK(src, PROC_REF(set_path)), list(src, current_target))
Expand Down Expand Up @@ -242,24 +251,28 @@
var/list/viable_targets = list()
var/atom/movable/closest_target
var/smallest_distance = INFINITY
for(var/mob/living/carbon/human/potential_alive_human_target as anything in GLOB.alive_human_list)
if(z != potential_alive_human_target.z)

for(var/mob/living/carbon/potential_target as anything in GLOB.alive_mob_list)
if(!iscarbon(potential_target))
continue

if(z != potential_target.z)
continue

if(!check_mob_target(potential_alive_human_target))
if(!potential_target.check_mob_target(src))
continue

var/distance = get_dist(src, potential_alive_human_target)
var/distance = get_dist(src, potential_target)

if(distance > ai_range)
continue

viable_targets += potential_alive_human_target
viable_targets += potential_target

if(smallest_distance <= distance)
continue

closest_target = potential_alive_human_target
closest_target = potential_target
smallest_distance = distance

for(var/obj/vehicle/multitile/potential_vehicle_target as anything in GLOB.all_multi_vehicles)
Expand All @@ -275,8 +288,8 @@
var/skip_vehicle = TRUE

var/list/interior_living_mobs = potential_vehicle_target.interior.get_passengers()
for(var/mob/living/carbon/human/human_mob in interior_living_mobs)
if(!check_mob_target(human_mob))
for(var/mob/living/carbon/carbon_mob in interior_living_mobs)
if(!carbon_mob.check_mob_target(src))
continue

skip_vehicle = FALSE
Expand Down Expand Up @@ -322,17 +335,11 @@

#undef EXTRA_CHECK_DISTANCE_MULTIPLIER

/mob/living/carbon/xenomorph/proc/check_mob_target(mob/living/carbon/human/checked_human)
if(checked_human.species.flags & IS_SYNTHETIC)
return FALSE

if(HAS_TRAIT(checked_human, TRAIT_NESTED))
return FALSE

if(can_not_harm(checked_human))
return FALSE
/mob/living/carbon/proc/check_mob_target(mob/living/carbon/xenomorph/ai_xeno)
if(stat == DEAD)
return FALSE // We leave dead bodies alone

if(checked_human.stat != CONSCIOUS)
if(ai_xeno.can_not_harm(src))
return FALSE

return TRUE
Expand Down
29 changes: 29 additions & 0 deletions code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,43 @@ At bare minimum, make sure the relevant checks from parent types gets copied in

. = ..()

/mob/living/carbon/human/check_mob_target(mob/living/carbon/xenomorph/ai_xeno)
. = ..()
if(!.)
return FALSE

if(stat == UNCONSCIOUS)
return FALSE // We also leave crit people be

if(species.flags & IS_SYNTHETIC)
return FALSE

if(HAS_TRAIT(src, TRAIT_NESTED))
return FALSE

return TRUE

// XENOS
/mob/living/carbon/xenomorph/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target)
. = ..()
if(!.)
return

if(X.hivenumber != hivenumber)
return HUMAN_PENALTY

return XENO_PENALTY

/mob/living/carbon/xenomorph/check_mob_target(mob/living/carbon/xenomorph/ai_xeno)
. = ..()
if(!.)
return FALSE

if(ai_xeno.hivenumber == hivenumber)
return FALSE

return TRUE

// VEHICLES
/obj/vehicle/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ note dizziness decrements automatically in the mob's Life() proc.

// facing verbs
/mob/proc/canface()
if(client.moving) return 0
if(client && client.moving) return 0
if(stat==2) return 0
if(anchored) return 0
if(monkeyizing) return 0
Expand Down