Skip to content

Commit

Permalink
Merge pull request #2 from xDanilcusx/human-ai
Browse files Browse the repository at this point in the history
Merge issues
  • Loading branch information
Zonespace27 authored Sep 19, 2024
2 parents 54cc736 + 59d88ad commit 6927928
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
3 changes: 2 additions & 1 deletion code/__DEFINES/human_ai.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#define AI_ACTION_PICKUP_GUN /datum/ongoing_action/item_pickup/pickup_primary
#define AI_ACTION_COVER /datum/ongoing_action/take_cover
#define AI_ACTION_COVER_I /datum/ongoing_action/take_inside_cover
#define AI_ACTION_TROWBACK /datum/ongoing_action/throw_back_nade
#define AI_ACTION_THROWBACK /datum/ongoing_action/throw_back_nade
#define AI_ACTION_NADE /datum/ongoing_action/throw_grenade

/// Action is completed, delete this and move onto the next ongoing action
#define ONGOING_ACTION_COMPLETED "completed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
var/obj/item/ammo_magazine/mag = to_pickup
if(istype(brain.primary_weapon, mag.gun_type))
brain.tied_human.put_in_hands(to_pickup, TRUE)

brain.store_item(to_pickup, storage_spot, HUMAN_AI_AMMUNITION)
return ONGOING_ACTION_COMPLETED

Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/ai/brain/ai_brain.dm
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ GLOBAL_LIST_EMPTY(human_ai_brains)
tied_human.swap_hand()

/datum/human_ai_brain/proc/nade_throwback(list/things_around)
if(has_ongoing_action(AI_ACTION_TROWBACK))
if(has_ongoing_action(AI_ACTION_THROWBACK))
return

var/turf/place_to_throw
Expand Down Expand Up @@ -192,7 +192,7 @@ GLOBAL_LIST_EMPTY(human_ai_brains)
return

throw_back_nade:
ADD_ONGOING_ACTION(src, AI_ACTION_TROWBACK, throw_nade, place_to_throw)
ADD_ONGOING_ACTION(src, AI_ACTION_THROWBACK, throw_nade, place_to_throw)

/// Use ADD_ONGOING_ACTION() macro instead of calling this directly
/datum/human_ai_brain/proc/_add_ongoing_action(datum/ongoing_action/path, ...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,6 @@

if(primary_weapon.current_mag?.current_rounds <= 1 && !primary_weapon.in_chamber) // bullet removal comes after comsig is triggered
end_gun_fire()
return

if(!(current_target in viewers(world.view, tied_human)))
if(!in_cover)
ADD_ONGOING_ACTION(src, AI_ACTION_APPROACH_C, current_target, 0)
else if(overwatch_allowed)
establish_overwatch()
end_gun_fire()
if(gun_data?.disposable)
var/obj/item/gun = primary_weapon
set_primary_weapon(null)
Expand All @@ -221,7 +213,9 @@

if(get_dist(tied_human, current_target) > gun_data.maximum_range)
end_gun_fire()
if(overwatch_allowed)
if(!in_cover)
ADD_ONGOING_ACTION(src, AI_ACTION_APPROACH_C, current_target, 0)
else if(overwatch_allowed)
establish_overwatch()
else if(grenading_allowed)
throw_grenade_cover()
Expand Down Expand Up @@ -307,13 +301,13 @@
attack_target()

/datum/human_ai_brain/proc/throw_grenade_cover()
if(!target_floor || has_ongoing_action(/datum/ongoing_action/throw_grenade))
if(!target_floor || has_ongoing_action(AI_ACTION_NADE))
return

var/obj/item/explosive/grenade/nade = locate() in equipment_map[HUMAN_AI_GRENADES]
if(!nade)
return

ADD_ONGOING_ACTION(src, /datum/ongoing_action/throw_grenade, nade, target_floor)
ADD_ONGOING_ACTION(src, AI_ACTION_NADE, nade, target_floor)

#undef EXTRA_CHECK_DISTANCE_MULTIPLIER

0 comments on commit 6927928

Please sign in to comment.