Skip to content

Commit

Permalink
Myriad bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Oct 28, 2023
1 parent 89279ef commit 73297f0
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 72 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,5 @@ PROBABILITY CALCULATIONS ARE HERE
#define XENO_SPAWN_T2 (1<<1)
#define XENO_SPAWN_T3 (1<<2)

/// Special blockers for pathfinding or obstacle handling
#define XENO_AI_SPECIAL_BLOCKERS list(/obj/flamer_fire, /obj/vehicle/multitile)
5 changes: 1 addition & 4 deletions code/controllers/subsystem/pathfinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ SUBSYSTEM_DEF(xeno_pathfinding)
var/list/hash_path = list()
var/current_position = 1

/// Any special blockers we want to account for that do not normally block movement
var/list/special_blockers = list(/obj/flamer_fire)

/datum/controller/subsystem/xeno_pathfinding/stat_entry(msg)
msg = "P:[length(paths_to_calculate)]"
return ..()
Expand Down Expand Up @@ -133,7 +130,7 @@ SUBSYSTEM_DEF(xeno_pathfinding)
var/list/pass_back = list()

for(var/atom/checked_atom as anything in checking_turf)
for(var/special_block in special_blockers)
for(var/special_block in XENO_AI_SPECIAL_BLOCKERS)
if(istype(checked_atom, special_block))
pass_back += checked_atom

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
if(T == get_turf(X.current_target))
break


if(!X.move_to_next_turf(T))
X.current_target = null
return TRUE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
if(moving_xeno.throwing)
return

if(moving_xeno.current_target.is_mob_incapacitated())
// Always charge forward if sentries/APCs, no real reason to dodge and weave
var/incapacitated_check = TRUE
if(istype(moving_xeno.current_target, /mob))
var/mob/current_target_mob = moving_xeno.current_target
incapacitated_check = current_target_mob.is_mob_incapacitated()

if(incapacitated_check)
return ..()

check_for_travelling_turf_change(moving_xeno)
Expand Down
114 changes: 53 additions & 61 deletions code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/mob/living/carbon/xenomorph
// AI stuff
var/flags_ai = XENO_AI_NO_DESPAWN
var/mob/current_target
var/atom/movable/current_target

var/next_path_generation = 0
var/list/current_path
Expand Down Expand Up @@ -64,7 +64,12 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
current_path = null
return TRUE

if(QDELETED(current_target) || current_target.stat != CONSCIOUS || get_dist(current_target, src) > ai_range)
var/stat_check = FALSE
if(istype(current_target, /mob))
var/mob/current_target_mob = current_target
stat_check = (current_target_mob != CONSCIOUS)

if(QDELETED(current_target) || stat_check || get_dist(current_target, src) > ai_range)
current_target = get_target(ai_range)
if(QDELETED(src))
return TRUE
Expand Down Expand Up @@ -96,8 +101,19 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
if(XA.process_ai(src, delta_time) == PROCESS_KILL)
unregister_ai_action(XA)

if(get_dist(src, current_target) <= 1 && DT_PROB(XENO_SLASH, delta_time))
if(!current_target || !DT_PROB(XENO_SLASH, delta_time))
return

var/list/turf/turfs_to_dist_check = list(get_turf(current_target))

if(length(current_target.locs) > 1)
turfs_to_dist_check = get_multitile_turfs_to_check()

for(var/turf/checked_turf as anything in turfs_to_dist_check)
if(get_dist(src, checked_turf) > 1)
continue
INVOKE_ASYNC(src, PROC_REF(do_click), current_target, "", list())
return

/** Controls movement when idle. Called by process_ai */
/mob/living/carbon/xenomorph/proc/ai_move_idle(delta_time)
Expand Down Expand Up @@ -172,9 +188,9 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
if(!can_move_and_apply_move_delay())
return TRUE


var/turf/next_turf = current_path[current_path.len]
var/list/L = LinkBlocked(src, loc, next_turf, list(src, current_target), TRUE)
L += SSxeno_pathfinding.check_special_blockers(src, next_turf)
for(var/a in L)
var/atom/A = a
if(A.xeno_ai_obstacle(src, get_dir(loc, next_turf)) == INFINITY)
Expand Down Expand Up @@ -262,60 +278,36 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
SHOULD_CALL_PARENT(TRUE)
SSxeno_ai.remove_ai(src)

GLOBAL_LIST_EMPTY_TYPED(xeno_ai_spawns, /obj/effect/landmark/xeno_ai)
/obj/effect/landmark/xeno_ai
name = "Xeno AI Spawn"
var/list/spawned_xenos
var/remaining_spawns = 5

var/spawn_radius = 5
var/list/spawnable_turfs

/obj/effect/landmark/xeno_ai/Initialize(mapload, ...)
. = ..()
spawned_xenos = list()

GLOB.xeno_ai_spawns += src
spawnable_turfs = list()
for(var/i in RANGE_TURFS(spawn_radius, src))
var/turf/T = i
if(T == get_turf(src))
spawnable_turfs += T
continue

if(T.density)
continue

var/failed = FALSE
for(var/a in T)
var/atom/A = a
if(A.density)
failed = TRUE
break

if(failed)
continue

for(var/t in getline(T, src))
var/turf/line = t
if(line.density)
failed = TRUE
break

if(failed)
continue

spawnable_turfs += T

/obj/effect/landmark/xeno_ai/proc/reduce_remaining_spawns(mob/living/carbon/xenomorph/X)
SIGNAL_HANDLER
remaining_spawns--

/obj/effect/landmark/xeno_ai/proc/handle_xeno_delete(mob/living/carbon/xenomorph/X)
SIGNAL_HANDLER
spawned_xenos -= X

/obj/effect/landmark/xeno_ai/Destroy()
spawnable_turfs = null
GLOB.xeno_ai_spawns -= src
return ..()
/mob/living/carbon/xenomorph/proc/get_multitile_turfs_to_check()
var/angle = get_angle(current_target, src)
var/turf/base_turf = current_target.locs[1]

switch(angle)
if(315 to 360, 0 to 45) //northerly
var/max_y_value = base_turf.y + (round(current_target.bound_height / 32) - 1)
var/list/turf/max_y_turfs = list()
for(var/turf/cycled_turf as anything in current_target.locs)
if(cycled_turf.y == max_y_value)
max_y_turfs += cycled_turf
return max_y_turfs
if(45 to 135) //easterly
var/max_x_value = base_turf.x + (round(current_target.bound_width / 32) - 1)
var/list/turf/max_x_turfs = list()
for(var/turf/cycled_turf as anything in current_target.locs)
if(cycled_turf.x == max_x_value)
max_x_turfs += cycled_turf
return max_x_turfs
if(135 to 225) //southerly
var/min_y_value = base_turf.y
var/list/turf/min_y_turfs = list()
for(var/turf/cycled_turf as anything in current_target.locs)
if(cycled_turf.y == min_y_value)
min_y_turfs += cycled_turf
return min_y_turfs
if(225 to 315) //westerly
var/min_x_value = base_turf.x
var/list/turf/min_x_turfs = list()
for(var/turf/cycled_turf as anything in current_target.locs)
if(cycled_turf.x == min_x_value)
min_x_turfs += cycled_turf
return min_x_turfs
7 changes: 6 additions & 1 deletion code/modules/mob/living/carbon/xenomorph/castes/Runner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@
if(get_dist(current_target, src) > 1)
return

if(!current_target.is_mob_incapacitated())
if(!istype(current_target, /mob))
return

var/mob/current_target_mob = current_target

if(!current_target_mob.is_mob_incapacitated())
return

if(isxeno(current_target.pulledby))
Expand Down
2 changes: 0 additions & 2 deletions code/modules/vehicles/apc/apc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ GLOBAL_LIST_EMPTY(command_apc_list)

vehicle_flags = VEHICLE_CLASS_LIGHT

mob_size_required_to_hit = MOB_SIZE_XENO

dmg_multipliers = list(
"all" = 1,
"acid" = 1.6,
Expand Down
2 changes: 0 additions & 2 deletions code/modules/vehicles/van/van.dm
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@

door_locked = FALSE

mob_size_required_to_hit = MOB_SIZE_XENO

var/overdrive_next = 0
var/overdrive_cooldown = 15 SECONDS
var/overdrive_duration = 3 SECONDS
Expand Down

0 comments on commit 73297f0

Please sign in to comment.