From f09a0944dc1d2302778b0296465d19f9a4015e6f Mon Sep 17 00:00:00 2001 From: Morrow Date: Thu, 2 Nov 2023 14:01:10 -0400 Subject: [PATCH] Initial --- code/__DEFINES/xeno.dm | 1 + code/__DEFINES/xeno_ai.dm | 1 + .../mob/living/carbon/xenomorph/ai/xeno_ai.dm | 3 +- .../living/carbon/xenomorph/attack_alien.dm | 44 +++---- .../carbon/xenomorph/xeno_ai_interaction.dm | 116 +++++++++++------- 5 files changed, 93 insertions(+), 72 deletions(-) diff --git a/code/__DEFINES/xeno.dm b/code/__DEFINES/xeno.dm index a0a4c927d3..935f58f69c 100644 --- a/code/__DEFINES/xeno.dm +++ b/code/__DEFINES/xeno.dm @@ -36,6 +36,7 @@ #define XENO_HITS_TO_DESTROY_WINDOW_FRAME 3 #define XENO_HITS_TO_DESTROY_R_WINDOW_FRAME 5 #define XENO_HITS_TO_DESTROY_BOLTED_DOOR 10 +#define XENO_HITS_TO_DESTROY_DOOR 10 #define XENO_HITS_TO_DESTROY_WELDED_DOOR 15 #define XENO_HITS_TO_EXPOSE_WIRES_MIN 3 #define XENO_HITS_TO_EXPOSE_WIRES_MAX 4 diff --git a/code/__DEFINES/xeno_ai.dm b/code/__DEFINES/xeno_ai.dm index 9bea986461..dc4be8dbcc 100644 --- a/code/__DEFINES/xeno_ai.dm +++ b/code/__DEFINES/xeno_ai.dm @@ -5,6 +5,7 @@ #define DISTANCE_PENALTY 1 #define ASTAR_COST_FUNCTION(n) (abs(n.x - target.x)+abs(n.y - target.y)) +#define OPEN_TURF_PENALTY 1 #define DOOR_PENALTY 3 #define OBJECT_PENALTY 20 #define HUMAN_PENALTY 4 diff --git a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm index 08684b2cd9..c300c8a48e 100644 --- a/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm +++ b/code/modules/mob/living/carbon/xenomorph/ai/xeno_ai.dm @@ -143,7 +143,8 @@ GLOBAL_LIST_INIT(ai_target_limbs, list( // Called whenever an obstacle is encountered but xeno_ai_obstacle returned something else than infinite // and now it is considered a valid path. /atom/proc/xeno_ai_act(mob/living/carbon/xenomorph/X) - return + X.do_click(src, "", list()) + return TRUE /mob/living/carbon/xenomorph/proc/can_move_and_apply_move_delay() // Unable to move, try next time. diff --git a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm index e3dfccbf88..c833c051ea 100644 --- a/code/modules/mob/living/carbon/xenomorph/attack_alien.dm +++ b/code/modules/mob/living/carbon/xenomorph/attack_alien.dm @@ -517,46 +517,42 @@ //Prying open doors /obj/structure/machinery/door/airlock/attack_alien(mob/living/carbon/xenomorph/M) var/turf/cur_loc = M.loc - if(isElectrified()) - if(shock(M, 100)) - return XENO_NO_DELAY_ACTION + + . = XENO_NO_DELAY_ACTION + + if(M.claw_type >= CLAW_TYPE_SHARP) + M.animation_attack_on(src) + playsound(src, 'sound/effects/metalhit.ogg', 25, 1) + take_damage(damage_cap / XENO_HITS_TO_DESTROY_DOOR) + . = XENO_ATTACK_ACTION + + if(isElectrified() && shock(M, 100)) + return if(!density) to_chat(M, SPAN_WARNING("[src] is already open!")) - return XENO_NO_DELAY_ACTION + return if(heavy) to_chat(M, SPAN_WARNING("[src] is too heavy to open.")) - return XENO_NO_DELAY_ACTION + return if(welded) - if(M.claw_type >= CLAW_TYPE_SHARP) - M.animation_attack_on(src) - playsound(src, 'sound/effects/metalhit.ogg', 25, 1) - take_damage(damage_cap / XENO_HITS_TO_DESTROY_WELDED_DOOR) - return XENO_ATTACK_ACTION - else - to_chat(M, SPAN_WARNING("[src] is welded shut.")) - return XENO_NO_DELAY_ACTION + to_chat(M, SPAN_WARNING("[src] is welded shut.")) + return if(locked) - if(M.claw_type >= CLAW_TYPE_SHARP) - M.animation_attack_on(src) - playsound(src, 'sound/effects/metalhit.ogg', 25, 1) - take_damage(HEALTH_DOOR / XENO_HITS_TO_DESTROY_BOLTED_DOOR) - return XENO_ATTACK_ACTION - else - to_chat(M, SPAN_WARNING("[src] is bolted down tight.")) - return XENO_NO_DELAY_ACTION + to_chat(M, SPAN_WARNING("[src] is bolted down tight.")) + return if(!istype(cur_loc)) - return XENO_NO_DELAY_ACTION //Some basic logic here + return //Some basic logic here if(M.action_busy) - return XENO_NO_DELAY_ACTION + return if(M.lying) - return XENO_NO_DELAY_ACTION + return var/delay diff --git a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm index 9d0eb37c1b..6d35b6a101 100644 --- a/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm +++ b/code/modules/mob/living/carbon/xenomorph/xeno_ai_interaction.dm @@ -15,24 +15,50 @@ At bare minimum, make sure the relevant checks from parent types gets copied in */// - Morrow +// OBJECTS +/obj/structure/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + + if(!density) + return 0 + + if(unslashable && !climbable) + return + + return OBJECT_PENALTY + +/obj/structure/xeno_ai_act(mob/living/carbon/xenomorph/X) + if(unslashable) + if(!X.action_busy) + do_climb(X) + return + + return ..() // MINERAL DOOR /obj/structure/mineral_door/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) return DOOR_PENALTY -/obj/structure/mineral_door/xeno_ai_act(mob/living/carbon/xenomorph/X) - X.do_click(src, "", list()) - return TRUE - /obj/structure/mineral_door/resin/xeno_ai_obstacle(mob/living/carbon/xenomorph/xeno, direction, turf/target) if(xeno.hivenumber != hivenumber) return ..() return 0 /obj/structure/mineral_door/resin/xeno_ai_act(mob/living/carbon/xenomorph/acting_xeno) - acting_xeno.a_intent = INTENT_HELP + if(xeno.hivenumber == hivenumber) + acting_xeno.a_intent = INTENT_HELP . = ..() +/// Platforms +/obj/structure/platform/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + + return DOOR_PENALTY + // Poddoors/shutters /obj/structure/machinery/door/poddoor/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) . = ..() @@ -61,60 +87,34 @@ At bare minimum, make sure the relevant checks from parent types gets copied in return DOOR_PENALTY -/obj/structure/machinery/door/xeno_ai_act(mob/living/carbon/xenomorph/X) - X.do_click(src, "", list()) - return TRUE - -// OBJECTS -/obj/structure/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) - . = ..() - if(!.) - return - - if(!density) - return 0 - - if(unslashable && !climbable) - return - - return OBJECT_PENALTY - -/obj/structure/xeno_ai_act(mob/living/carbon/xenomorph/X) - if(unslashable) - if(!X.action_busy) - do_climb(X) - return - X.do_click(src, "", list()) - return TRUE - - // HUMANS /mob/living/carbon/human/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) if(status_flags & GODMODE) return ..() + return HUMAN_PENALTY /mob/living/carbon/human/xeno_ai_act(mob/living/carbon/xenomorph/X) if(status_flags & GODMODE) - return ..() - X.do_click(src, "", list()) - return TRUE + return + + . = ..() // VEHICLES /obj/vehicle/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) - return VEHICLE_PENALTY + . = ..() + if(!.) + return -/obj/vehicle/xeno_ai_act(mob/living/carbon/xenomorph/X) - X.do_click(src, "", list()) - return TRUE + return VEHICLE_PENALTY // SENTRY /obj/structure/machinery/defenses/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) - return VEHICLE_PENALTY + . = ..() + if(!.) + return -/obj/structure/machinery/defenses/xeno_ai_act(mob/living/carbon/xenomorph/X) - X.do_click(src, "", list()) - return TRUE + return VEHICLE_PENALTY // WINDOW FRAME /obj/structure/window_frame/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) @@ -127,8 +127,19 @@ At bare minimum, make sure the relevant checks from parent types gets copied in if(!X.action_busy) do_climb(X) +/obj/structure/barricade/handrail/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + + return DOOR_PENALTY + // Avoid barricades if possible. /obj/structure/barricade/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + return BARRICADE_PENALTY // FIRE @@ -138,7 +149,18 @@ At bare minimum, make sure the relevant checks from parent types gets copied in return FIRE_PENALTY -// HOLES -/obj/effect/acid_hole/xeno_ai_act(mob/living/carbon/xenomorph/X) - X.do_click(src, "", list()) - return TRUE +/// Open turfs, sometimes open turfs are passed back as obstacles due to platforms and such, generally it's fast so very slight penalty mainly for handling subtypes properly +/turf/open/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + + return OPEN_TURF_PENALTY + +/// Space, do NOT path into space. +/turf/open/space/xeno_ai_obstacle(mob/living/carbon/xenomorph/X, direction, turf/target) + . = ..() + if(!.) + return + + return INFINITY