Skip to content

Commit

Permalink
OK this time for sure
Browse files Browse the repository at this point in the history
  • Loading branch information
morrowwolf committed Oct 28, 2023
1 parent 089b8b6 commit 21a2468
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 19 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/dcs/signals/atom/mob/living/signals_xeno.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@
/// From /mob/living/carbon/xenomorph/proc/handle_crit()
#define COMSIG_XENO_HANDLE_CRIT "xeno_handle_crit"

/// From /datum/action/xeno_action/activable/pounce/use_ability()
#define COMSIG_XENO_USED_POUNCE "xeno_used_pounce"

/// From /mob/living/carbon/xenomorph/proc/handle_ai_shot()
#define COMSIG_XENO_HANDLE_AI_SHOT "xeno_handle_ai_shot"
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,8 @@

X.launch_towards(LM)

SEND_SIGNAL(owner, COMSIG_XENO_USED_POUNCE, A)

X.update_icons()

additional_effects_always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
if (istype(lurker_invis))
lurker_invis.invisibility_off()

var/datum/xeno_ai_movement/linger/lurking/AI = xeno.ai_movement_handler
if (AI && istype(AI))
AI.stop_lurking()

/datum/action/xeno_action/activable/pounce/lurker/additional_effects(mob/living/L)
var/mob/living/carbon/xenomorph/X = owner
if (!istype(X))
Expand Down
28 changes: 22 additions & 6 deletions code/modules/mob/living/carbon/xenomorph/ai/movement/lurking.dm
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

RegisterSignal(parent, COMSIG_XENO_HANDLE_AI_SHOT, PROC_REF(stop_lurking))
RegisterSignal(parent, COMSIG_XENO_HANDLE_CRIT, PROC_REF(stop_lurking))
RegisterSignal(parent, COMSIG_XENO_USED_POUNCE, PROC_REF(stop_lurking))

addtimer(CALLBACK(src, PROC_REF(check_annoyance)), AI_CHECK_ANNOYANCE_COOLDOWN, TIMER_UNIQUE|TIMER_LOOP|TIMER_DELETE_ME)

#undef AI_CHECK_ANNOYANCE_COOLDOWN
Expand Down Expand Up @@ -176,14 +178,14 @@
#undef LURKER_BAITS_BEFORE_AMBUSH

/datum/xeno_ai_movement/linger/lurking/proc/interact_random(mob/living/carbon/xenomorph/X)
for(var/obj/O in orange(1, X))
if(istype(O, /obj/structure/window_frame))
for(var/obj/potential_interaction in orange(1, X))
if(istype(potential_interaction, /obj/structure/window_frame))
continue
if(istype(O, /obj/structure/pipes))
if(istype(potential_interaction, /obj/structure/pipes))
continue
if(istype(O, /obj/structure/sign))
if(istype(potential_interaction, /obj/structure/sign))
continue
if(!O.xeno_ai_act(X))
if(!potential_interaction.xeno_ai_act(X))
continue
return TRUE
return FALSE
Expand All @@ -199,6 +201,8 @@
register_turf_signals()
ai_lurking = TRUE

RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(lurking_parent_moved))

var/datum/action/xeno_action/activable/pounce/lurker/LPA = get_xeno_action_by_type(lurking_xeno, /datum/action/xeno_action/activable/pounce/lurker)
if(LPA && istype(LPA))
LPA.knockdown = TRUE
Expand All @@ -215,13 +219,19 @@
unregister_turf_signals()
ai_lurking = FALSE

UnregisterSignal(parent, COMSIG_MOVABLE_MOVED)

INVOKE_ASYNC(lurking_xeno, TYPE_PROC_REF(/mob, stop_pulling))

/datum/xeno_ai_movement/linger/lurking/proc/register_turf_signals()
for(var/turf/open/cycled_open_turf in view(5, parent))
for(var/turf/open/cycled_open_turf in view(world.view, parent))
RegisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED, PROC_REF(set_target))
registered_turfs += cycled_open_turf

var/mob/living/carbon/human/possible_target = locate() in cycled_open_turf
if(possible_target)
parent.current_target = possible_target

/datum/xeno_ai_movement/linger/lurking/proc/unregister_turf_signals()
for(var/turf/open/cycled_open_turf in registered_turfs)
UnregisterSignal(cycled_open_turf, COMSIG_TURF_ENTERED)
Expand All @@ -235,3 +245,9 @@
return

lurking_xeno.current_target = entering_atom

/datum/xeno_ai_movement/linger/lurking/proc/lurking_parent_moved(atom/movable/moving_atom, atom/oldloc, direction, Forced)
SIGNAL_HANDLER

unregister_turf_signals()
register_turf_signals()
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ GLOBAL_LIST_INIT(ai_target_limbs, list(
return new /datum/xeno_ai_movement(src)

/mob/living/carbon/xenomorph/proc/handle_ai_shot(obj/projectile/P)
SEND_SIGNAL(src, COMSIG_XENO_HANDLE_AI_SHOT, P)

if(current_target || !P.firer)
return

SEND_SIGNAL(src, COMSIG_XENO_HANDLE_AI_SHOT, P)

var/distance = get_dist(src, P.firer)
if(distance > max_travel_distance)
return
Expand Down
6 changes: 0 additions & 6 deletions code/modules/mob/living/carbon/xenomorph/castes/Lurker.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,6 @@
/mob/living/carbon/xenomorph/lurker/init_movement_handler()
return new /datum/xeno_ai_movement/linger/lurking(src)

/mob/living/carbon/xenomorph/lurker/handle_ai_shot(obj/projectile/P)
if(prob(LURKING_IGNORE_SHOT_CHANCE))
return

. = ..()

/mob/living/carbon/xenomorph/lurker/ai_move_target(delta_time)
if(throwing)
return
Expand Down
3 changes: 2 additions & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,8 @@

bullet_message(P) //Message us about the bullet, since damage was inflicted.


if(mob_flags & AI_CONTROLLED)
handle_ai_shot(P)

if(SEND_SIGNAL(src, COMSIG_XENO_BULLET_ACT, damage_result, ammo_flags, P) & COMPONENT_CANCEL_BULLET_ACT)
return
Expand Down

0 comments on commit 21a2468

Please sign in to comment.