From 1fcfdd5bae133b8fe3793a94faddec01aac1f780 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 30 Apr 2020 14:15:10 -0400 Subject: [PATCH] Bot hints Thing type 2004, adds a map-defined point for bots to gravitate towards or away from. Angle: Changes radius, defaults to a 32 radius (or 64x64 area) without. Ambush: When off, makes bots steer towards. When on, makes bots steer away. Parameter: Changes how much the bot steers away/towards this point. If 0, defaults to 2. (also, made bots ignore strong offroad if they could take a shortcut) --- src/dehacked.c | 2 ++ src/info.c | 27 +++++++++++++++++++++++++++ src/info.h | 2 ++ src/k_bot.c | 37 ++++++++++++++++++++++++------------- src/p_mobj.c | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 88 insertions(+), 13 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 8507a1b03..e8749931b 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -7901,6 +7901,8 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_WAYPOINT_RISER", "MT_WAYPOINT_ANCHOR", + "MT_BOTHINT", + "MT_RANDOMAUDIENCE", "MT_FLAYM", diff --git a/src/info.c b/src/info.c index 7bed0a78d..110704493 100644 --- a/src/info.c +++ b/src/info.c @@ -16582,6 +16582,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_BOTHINT + 2004, // doomednum + S_INVISIBLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 100, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 1*FRACUNIT, // radius + 2*FRACUNIT, // height + 0, // display offset + 100, // mass + 0, // damage + sfx_None, // activesound + MF_NOCLIP|MF_NOGRAVITY|MF_SCENERY, // flags + S_NULL // raisestate + }, + { // MT_RANDOMAUDIENCE 1488, // doomednum S_RANDOMAUDIENCE, // spawnstate diff --git a/src/info.h b/src/info.h index f86fed973..d5b5ecf2c 100644 --- a/src/info.h +++ b/src/info.h @@ -4832,6 +4832,8 @@ typedef enum mobj_type MT_WAYPOINT_RISER, MT_WAYPOINT_ANCHOR, + MT_BOTHINT, + MT_RANDOMAUDIENCE, MT_FLAYM, diff --git a/src/k_bot.c b/src/k_bot.c index 9ad78bb7d..de12885ad 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -209,24 +209,19 @@ static fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, return P_AproxDistance(cx - px, cy - py); } -mobj_t *botmo = NULL; -fixed_t distancetocheck = 0; - -fixed_t closestlinedist = INT32_MAX; - -INT16 badsteerglobal = 0; - -static boolean K_BotHatesThisSector(sector_t *sec) +static boolean K_BotHatesThisSector(player_t *player, sector_t *sec) { switch (GETSECSPECIAL(sec->special, 1)) { case 1: // Damage - //case 2: case 3: // Offroad (let's let them lawnmower) - case 4: // Offroad (Strong) case 5: // Spikes case 6: case 7: // Death Pit case 8: // Instant Kill return true; + //case 2: case 3: // Offroad (let's let them lawnmower) + case 4: // Offroad (Strong) + if (!K_BotCanTakeCut(player)) + return true; default: break; } @@ -234,6 +229,13 @@ static boolean K_BotHatesThisSector(sector_t *sec) return false; } +mobj_t *botmo = NULL; +fixed_t distancetocheck = 0; + +fixed_t closestlinedist = INT32_MAX; + +INT16 badsteerglobal = 0; + static inline boolean K_FindBlockingWalls(line_t *line) { // Condensed version of PIT_CheckLine @@ -300,18 +302,18 @@ static inline boolean K_FindBlockingWalls(line_t *line) goto blocked; } - if (!K_BotHatesThisSector(botmo->subsector->sector)) + if (!K_BotHatesThisSector(botmo->player, botmo->subsector->sector)) { // Treat damage sectors like walls if (lineside) { - if (K_BotHatesThisSector(line->frontsector)) + if (K_BotHatesThisSector(botmo->player, line->frontsector)) goto blocked; } else { - if (K_BotHatesThisSector(line->backsector)) + if (K_BotHatesThisSector(botmo->player, line->backsector)) goto blocked; } } @@ -700,6 +702,15 @@ static boolean K_BotSteerObjects(mobj_t *thing) } } break; + case MT_BOTHINT: + if (thing->extravalue1 == 0) + { + K_SteerFromObject(botmo, thing, fulldist, xdist, false, thing->extravalue2 * (KART_FULLTURN + dodge)); + } + { + K_SteerFromObject(botmo, thing, fulldist, xdist, true, thing->extravalue2 * (KART_FULLTURN + attack)); + } + break; default: if (thing->flags & (MF_SOLID|MF_ENEMY|MF_BOSS|MF_PAIN|MF_MISSILE|MF_FIRE)) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 4ec66ac9c..b9af1b91f 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -12691,6 +12691,39 @@ ML_NOCLIMB : Direction not controllable P_SetTarget(&waypointcap, mobj); break; } + case MT_BOTHINT: + { + // Change size + if (mthing->angle > 0) + { + mobj->radius = mthing->angle * FRACUNIT; + } + else + { + mobj->radius = 32 * mapobjectscale; + } + + // Steer away instead of towards + if (mthing->options & MTF_AMBUSH) + { + mobj->extravalue1 = 0; + } + else + { + mobj->extravalue1 = 1; + } + + // Steering amount + if (mthing->extrainfo == 0) + { + mobj->extravalue2 = 2; + } + else + { + mobj->extravalue2 = mthing->extrainfo; + } + break; + } // SRB2Kart case MT_BALLOON: mobj->color = (1 + (mthing->angle % (MAXSKINCOLORS-1)));