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 32 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
5 changes: 4 additions & 1 deletion code/__DEFINES/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PROBABILITY CALCULATIONS ARE HERE

#define XENO_SLASH 80

#define XENO_DOOR_BUILDING_CHANCE 25
#define XENO_DOOR_BUILDING_CHANCE 40

#define PLASMA_RETREAT_PERCENTAGE 10
#define HEALTH_RETREAT_PERCENTAGE 20
Expand Down 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 @@ -27,7 +27,7 @@
return FALSE

processing_xeno.current_target = parent
processing_xeno.resting = FALSE
processing_xeno.set_resting(FALSE, FALSE, TRUE)
if(prob(5))
processing_xeno.emote("hiss")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides)
game_master.images -= behavior_image

QDEL_NULL(behavior_image)

for(var/assigned_xeno in currently_assigned)
UnregisterSignal(assigned_xeno, COMSIG_PARENT_QDELETING)
currently_assigned = null

. = ..()
Expand All @@ -45,12 +48,23 @@ GLOBAL_LIST_EMPTY(all_ai_behavior_overrides)
if(length(currently_assigned) >= max_assigned && !(checked_xeno in currently_assigned))
return FALSE

if(checked_xeno.stat != CONSCIOUS)
return FALSE

return TRUE

/// Processes what we want this behavior to do, return FALSE if we want to continue in the process_ai() proc or TRUE if we want to handle everything and have process_ai() return
/datum/component/ai_behavior_override/proc/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time)
SHOULD_NOT_SLEEP(TRUE)

RegisterSignal(processing_xeno, COMSIG_PARENT_QDELETING, PROC_REF(remove_from_queue), TRUE)
currently_assigned |= processing_xeno

return TRUE

/datum/component/ai_behavior_override/proc/remove_from_queue(mob/removed_xeno)
SIGNAL_HANDLER
if(currently_assigned)
currently_assigned -= removed_xeno

UnregisterSignal(removed_xeno, COMSIG_PARENT_QDELETING)
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
qdel(src)
return FALSE

var/area/current_area = get_area(location)
if(!current_area.is_resin_allowed)
for(var/client/game_master in GLOB.game_masters)
to_chat(game_master, SPAN_XENOBOLDNOTICE("This area doesn't allow xenos to build here"))

qdel(src)
return FALSE

if(distance > 10)
return FALSE

Expand All @@ -46,9 +54,8 @@

if(checked_xeno.get_plasma_percentage() < PLASMA_RETREAT_PERCENTAGE)
var/turf/xeno_loc = get_turf(checked_xeno)
if(xeno_loc.weeds && !checked_xeno.resting)
currently_assigned -= checked_xeno
checked_xeno.lay_down()
if(xeno_loc.weeds)
checked_xeno.set_resting(TRUE, FALSE, TRUE)

return FALSE

Expand All @@ -59,16 +66,21 @@
if(!.)
return

processing_xeno.resting = FALSE
processing_xeno.set_resting(FALSE, FALSE, TRUE)

var/turf/xeno_loc = get_turf(processing_xeno)
if(xeno_loc.density)
return FALSE // We shouldn't stand in a wall, let's act default

var/turf/parent_turf = get_turf(parent)
var/distance = get_dist(processing_xeno, parent)

var/list/turfs_around = xeno_loc.AdjacentTurfs()
if(turfs_around && distance < 1) // We are gonna be stuck after building at our loc, let's step away
return processing_xeno.move_to_next_turf(pick(turfs_around))

var/is_diagonal = (get_dir(processing_xeno, parent_turf) in diagonals)
if(is_diagonal || get_dist(processing_xeno, parent) > 1)
if(is_diagonal || distance > 1)
return processing_xeno.move_to_next_turf(parent_turf)

for(var/obj/structure/blocker in parent_turf.contents)
Expand All @@ -84,19 +96,23 @@
var/list/resin_types = processing_xeno.resin_build_order
processing_xeno.selected_resin = locate(/datum/resin_construction/resin_turf/wall) in resin_types

var/wall_nearby
var/wall_nearby = FALSE
var/blocked_turfs = 0
for(var/turf/blocked_turf in orange(1, parent_turf) - parent_turf.AdjacentTurfs())
blocked_turfs++

if(get_dir(blocked_turf, parent_turf) in diagonals)
continue

if(blocked_turf.density)
wall_nearby = TRUE

blocked_turfs++
var/obj/effect/alien/weeds/turf_weeds = blocked_turf.weeds
if(turf_weeds && turf_weeds.secreting)
wall_nearby = TRUE // Something is being constructed nearby, let's bet this is a new resin wall

if(blocked_turfs)
if(prob(XENO_DOOR_BUILDING_CHANCE) || (wall_nearby && blocked_turfs == 2))
if(wall_nearby)
if(prob(XENO_DOOR_BUILDING_CHANCE) || (wall_nearby && blocked_turfs > 1))
processing_xeno.selected_resin = locate(/datum/resin_construction/resin_obj/door) in resin_types

var/datum/action/xeno_action/activable/secrete_resin/build_action = locate() in processing_xeno.actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
/datum/component/ai_behavior_override/capture/Initialize(...)
. = ..()

if(!istype(parent, /mob))
return COMPONENT_INCOMPATIBLE
if(!ishuman(parent))
var/mob/living/new_parent = locate() in get_turf(parent)
if(new_parent)
new_parent.AddComponent(/datum/component/ai_behavior_override/capture)

if(isxeno(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/ai_behavior_override/capture/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance)
Expand All @@ -20,10 +21,10 @@

var/mob/parent_mob = parent

var/stat = parent_mob.stat
var/captee_stat = parent_mob.stat
var/mob/pulledby = parent_mob.pulledby

if(stat == DEAD)
if(captee_stat == DEAD)
qdel(src)
return FALSE

Expand All @@ -41,7 +42,7 @@
if(distance > 10)
return FALSE

if(stat == CONSCIOUS)
if(captee_stat == CONSCIOUS)
return FALSE

if(isxeno(pulledby) && pulledby != checked_xeno)
Expand All @@ -55,7 +56,7 @@
return

processing_xeno.current_target = parent
processing_xeno.resting = FALSE
processing_xeno.set_resting(FALSE, FALSE, TRUE)

if(processing_xeno.get_active_hand())
processing_xeno.swap_hand()
Expand Down
4 changes: 4 additions & 0 deletions code/game/gamemodes/colonialmarines/ai/colonialmarines_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

. = ..()

/datum/game_mode/colonialmarines/ai/post_setup()
set_lz_resin_allowed(TRUE)
xDanilcusx marked this conversation as resolved.
Show resolved Hide resolved
return ..()

/datum/game_mode/colonialmarines/ai/announce_bioscans()
return

Expand Down
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,25 +25,27 @@
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)

idle_xeno.set_resting(FALSE, FALSE, TRUE)
if(!home_turf)
return

if(idle_xeno.move_to_next_turf(home_turf, home_locate_range))
if(get_dist(home_turf, idle_xeno) <= 0 && !idle_xeno.resting)
idle_xeno.lay_down()
if(get_dist(home_turf, idle_xeno) <= 0)
idle_xeno.set_resting(TRUE, FALSE, TRUE)
else
home_turf = null

Expand Down
11 changes: 6 additions & 5 deletions code/modules/mob/living/carbon/xenomorph/ai/movement/drone.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@
home_turf = potential_home

if(!home_turf)
if(!idle_xeno.resting)
idle_xeno.lay_down()
idle_xeno.set_resting(TRUE, FALSE, TRUE)
return

idle_xeno.resting = FALSE
idle_xeno.set_resting(FALSE, FALSE, TRUE)

if(home_turf == last_home_turf)
blacklisted_turfs += home_turf
Expand All @@ -79,13 +78,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 && IS_SAME_HIVENUMBER(checked_weeds, parent))
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 && IS_SAME_HIVENUMBER(found_weeds, parent))
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
Loading
Loading