From d12942238285f79988367b7922499fe80713ff2d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 10 May 2023 19:55:41 -0400 Subject: [PATCH] Bots can now see TERRAIN-based offroad / damage --- src/k_botsearch.c | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/k_botsearch.c b/src/k_botsearch.c index f619035e9..1dd3132b1 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -142,16 +142,33 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y) Return:- true if avoiding this sector special, false otherwise. --------------------------------------------------*/ -static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec) +static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec, const boolean flip) { - if (sec->damagetype != SD_NONE) - { - return true; - } + terrain_t *terrain = K_GetTerrainForFlatNum(flip ? sec->ceilingpic : sec->floorpic); - if (sec->offroad > 0) + if (terrain != NULL) { - return !K_BotCanTakeCut(player); + if (terrain->damageType != SD_NONE) + { + return true; + } + + if (terrain->offroad > 0) + { + return !K_BotCanTakeCut(player); + } + } + else + { + if (sec->damagetype != SD_NONE) + { + return true; + } + + if (sec->offroad > 0) + { + return !K_BotCanTakeCut(player); + } } return false; @@ -200,7 +217,7 @@ boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t if (!(rover->fofflags & FOF_BLOCKPLAYER)) { if ((top >= player->mo->z) && (bottom <= player->mo->z + player->mo->height) - && K_BotHatesThisSectorsSpecial(player, rover->master->frontsector)) + && K_BotHatesThisSectorsSpecial(player, rover->master->frontsector, flip)) { // Bad intangible sector at our height, so we DEFINITELY want to avoid return true; @@ -236,7 +253,7 @@ boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t return false; } - return K_BotHatesThisSectorsSpecial(player, bestsector); + return K_BotHatesThisSectorsSpecial(player, bestsector, flip); } /*--------------------------------------------------