Skip to content

Commit

Permalink
now in ai_behavior_override!
Browse files Browse the repository at this point in the history
  • Loading branch information
xDanilcusx committed Oct 30, 2023
1 parent 97ecab1 commit 9ec8e2d
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 44 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/flags.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
/// Returned in PostTransfer to prevent transfer, similar to `COMPONENT_INCOMPATIBLE`
#define COMPONENT_NOTRANSFER 2

/// Returned in case we want to qdel our ai_behavior_override on /check_behavior_validity()
#define OVERRIDE_BEHAVIOR_QDEL 2

/// Return value to cancel attaching
#define ELEMENT_INCOMPATIBLE 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,47 +1,58 @@

/datum/component/ai_behavior_override/kidnap
// behavior_icon_state = "capture order"

/datum/component/ai_behavior_override/kidnap/Initialize(...)
. = ..()

if(!istype(parent, /mob))
if(!istype(parent, /mob) || isxeno(parent))
return COMPONENT_INCOMPATIBLE

/datum/component/ai_behavior_override/kidnap/check_behavior_validity(mob/living/carbon/xenomorph/checked_xeno, distance)
. = ..()

if(distance > 10) // Probably want checks like if(!target) and not already pulling someone and such
var/stat = parent?:stat
var/mob/pulledby = parent?:pulledby

if(stat == DEAD)
return OVERRIDE_BEHAVIOR_QDEL

if(HAS_TRAIT(parent, TRAIT_NESTED))
return OVERRIDE_BEHAVIOR_QDEL

if(distance > 10)
return FALSE

if(stat == CONSCIOUS)
return FALSE

if(isxeno(pulledby) && pulledby != checked_xeno)
return FALSE

return TRUE

/datum/component/ai_behavior_override/kidnap/process_override_behavior(mob/living/carbon/xenomorph/processing_xeno, delta_time)
. = ..()

/*
if(get_active_hand())
swap_hand()
if(stat_check && GLOB.xeno_kidnapping)
if(pulling)
if(ai_move_hive(delta_time))
return TRUE
if(isxeno(current_target.pulledby) || HAS_TRAIT(current_target, TRAIT_NESTED))
current_target = null
ai_move_idle(delta_time)
return TRUE
processing_xeno.current_target = parent
processing_xeno.resting = FALSE

if(get_dist(current_target, src) <= 1)
INVOKE_ASYNC(src, PROC_REF(start_pulling), current_target)
face_atom(current_target)
swap_hand()
if(processing_xeno.get_active_hand())
processing_xeno.swap_hand()

ai_move_target(delta_time)
var/datum/xeno_ai_movement/AI = processing_xeno.ai_movement_handler
if(processing_xeno.pulling == parent)
AI.ai_move_hive(delta_time)
return TRUE

return FALSE
*/
var/atom/movable/target = processing_xeno.current_target
if(get_dist(processing_xeno, target) <= 1)
INVOKE_ASYNC(processing_xeno, TYPE_PROC_REF(/mob, start_pulling), target)
processing_xeno.face_atom(target)
processing_xeno.swap_hand()

processing_xeno.ai_move_target(delta_time)
return TRUE

/*
This is where we do our target setting and such, instead of moving in here:.
Expand Down
2 changes: 0 additions & 2 deletions code/modules/admin/admin_verbs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ var/list/roundstart_mod_verbs = list(
add_verb(src, /client/proc/cmd_mentor_say)
add_verb(src, /datum/admins/proc/imaginary_friend)
if(CLIENT_HAS_RIGHTS(src, R_BUILDMODE))
add_verb(src, /client/proc/toggle_xeno_kidnapping)
add_verb(src, /client/proc/togglebuildmodeself)
add_verb(src, /client/proc/toggle_game_master)
add_verb(src, /client/proc/toggle_join_xeno)
Expand Down Expand Up @@ -357,7 +356,6 @@ var/list/roundstart_mod_verbs = list(
/client/proc/remove_admin_verbs()
remove_verb(src, list(
admin_verbs_default,
/client/proc/toggle_xeno_kidnapping,
/client/proc/togglebuildmodeself,
/client/proc/toggle_game_master,
/client/proc/toggle_join_xeno,
Expand Down
5 changes: 5 additions & 0 deletions code/modules/admin/game_master/hive_landmark.dm
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/obj/effect/landmark/ai_hive
name = "Hive Landmark"
var/hive_radius = 7

/obj/effect/landmark/ai_hive/New()
. = ..()

new /obj/effect/alien/weeds/node(loc)
13 changes: 0 additions & 13 deletions code/modules/admin/game_master/toggle_xeno_kidnapping.dm

This file was deleted.

1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/xenomorph/XenoProcs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@
for(var/obj/structure/bed/nest/preexisting_nest in get_turf(host_to_nest))
if(preexisting_nest.dir == dir_to_nest)
to_chat(src, SPAN_XENONOTICE("There is already a host nested here!"))
step_to(host_to_nest, src)
return

var/obj/structure/bed/nest/applicable_nest = new(get_turf(host_to_nest))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@
if(!potential_weeded_wall)
continue

var/xeno_to_potential_nest_distance = get_dist(capping_xeno, potential_nest)
if(xeno_to_potential_nest_distance > shortest_distance)
var/hive_to_potential_nest_distance = get_dist(hive_landmark, potential_nest)
if(hive_to_potential_nest_distance > shortest_distance)
continue

nest_turf = potential_nest
weeded_wall = potential_weeded_wall
shortest_distance = xeno_to_potential_nest_distance
shortest_distance = hive_to_potential_nest_distance

if(!nest_turf)
return
Expand Down
12 changes: 9 additions & 3 deletions code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
var/mob/current_target_mob = current_target
stat_check = (current_target_mob.stat != CONSCIOUS)

if(QDELETED(current_target) || (stat_check && !GLOB.xeno_kidnapping) || get_dist(current_target, src) > ai_range)
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 @@ -222,7 +222,13 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
var/datum/component/ai_behavior_override/closest_valid_override
for(var/datum/component/ai_behavior_override/cycled_override in GLOB.all_ai_behavior_overrides)
var/distance = get_dist(src, cycled_override.parent)
if(cycled_override.check_behavior_validity(src, distance) && distance < shortest_distance)
var/validity = cycled_override.check_behavior_validity(src, distance)

if(validity == OVERRIDE_BEHAVIOR_QDEL)
qdel(cycled_override)
continue

if(validity && distance < shortest_distance)
shortest_distance = distance
closest_valid_override = cycled_override

Expand Down Expand Up @@ -324,7 +330,7 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
if(FACTION_XENOMORPH in checked_human.faction_group)
return FALSE

if(checked_human.stat != CONSCIOUS && !GLOB.xeno_kidnapping)
if(checked_human.stat != CONSCIOUS)
return FALSE

return TRUE
Expand Down
1 change: 0 additions & 1 deletion colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,6 @@
#include "code\modules\admin\game_master\game_master_submenu.dm"
#include "code\modules\admin\game_master\hive_landmark.dm"
#include "code\modules\admin\game_master\toggle_join_xeno.dm"
#include "code\modules\admin\game_master\toggle_xeno_kidnapping.dm"
#include "code\modules\admin\game_master\game_master_submenu\vents.dm"
#include "code\modules\admin\medal_panel\medals_panel.dm"
#include "code\modules\admin\medal_panel\medals_panel_tgui.dm"
Expand Down

0 comments on commit 9ec8e2d

Please sign in to comment.