2006-02-24 04:48:15 +00:00
|
|
|
/********************************
|
|
|
|
* B_Think.c *
|
|
|
|
* Description: *
|
|
|
|
* Functions for the different *
|
|
|
|
* states that the bot *
|
|
|
|
* uses. These functions are *
|
|
|
|
* the main AI *
|
|
|
|
* *
|
|
|
|
*********************************/
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "b_bot.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "stats.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "statnums.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "d_net.h"
|
|
|
|
#include "d_event.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_botmove ("BotMove");
|
|
|
|
|
|
|
|
//This function is called each tic for each bot,
|
|
|
|
//so this is what the bot does.
|
2008-03-28 00:38:17 +00:00
|
|
|
void FCajunMaster::Think (AActor *actor, ticcmd_t *cmd)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
memset (cmd, 0, sizeof(*cmd));
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (actor->player->Bot.enemy && actor->player->Bot.enemy->health <= 0)
|
|
|
|
actor->player->Bot.enemy = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (actor->health > 0) //Still alive
|
|
|
|
{
|
|
|
|
if (teamplay || !deathmatch)
|
2014-10-13 17:40:25 +00:00
|
|
|
actor->player->Bot.mate = Choose_Mate (actor);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
angle_t oldyaw = actor->angle;
|
|
|
|
int oldpitch = actor->pitch;
|
|
|
|
|
|
|
|
Set_enemy (actor);
|
|
|
|
ThinkForMove (actor, cmd);
|
|
|
|
TurnToAng (actor);
|
|
|
|
|
|
|
|
cmd->ucmd.yaw = (short)((actor->angle - oldyaw) >> 16) / ticdup;
|
|
|
|
cmd->ucmd.pitch = (short)((oldpitch - actor->pitch) >> 16);
|
|
|
|
if (cmd->ucmd.pitch == -32768)
|
|
|
|
cmd->ucmd.pitch = -32767;
|
|
|
|
cmd->ucmd.pitch /= ticdup;
|
|
|
|
actor->angle = oldyaw + (cmd->ucmd.yaw << 16) * ticdup;
|
|
|
|
actor->pitch = oldpitch - (cmd->ucmd.pitch << 16) * ticdup;
|
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (actor->player->Bot.t_active) actor->player->Bot.t_active--;
|
|
|
|
if (actor->player->Bot.t_strafe) actor->player->Bot.t_strafe--;
|
|
|
|
if (actor->player->Bot.t_react) actor->player->Bot.t_react--;
|
|
|
|
if (actor->player->Bot.t_fight) actor->player->Bot.t_fight--;
|
|
|
|
if (actor->player->Bot.t_rocket) actor->player->Bot.t_rocket--;
|
|
|
|
if (actor->player->Bot.t_roam) actor->player->Bot.t_roam--;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//Respawn ticker
|
2014-10-13 17:40:25 +00:00
|
|
|
if (actor->player->Bot.t_respawn)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
actor->player->Bot.t_respawn--;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (actor->health <= 0)
|
|
|
|
{ // Time to respawn
|
|
|
|
cmd->ucmd.buttons |= BT_USE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//how the bot moves.
|
|
|
|
//MAIN movement function.
|
2008-03-28 00:38:17 +00:00
|
|
|
void FCajunMaster::ThinkForMove (AActor *actor, ticcmd_t *cmd)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *b;
|
|
|
|
fixed_t dist;
|
|
|
|
bool stuck;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
b = actor->player;
|
2014-10-13 17:40:25 +00:00
|
|
|
if (!b->Bot.isbot)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
stuck = false;
|
2014-10-13 17:40:25 +00:00
|
|
|
dist = b->Bot.dest ? P_AproxDistance(actor->x-b->Bot.dest->x, actor->y-b->Bot.dest->y) : 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.missile &&
|
|
|
|
((!b->Bot.missile->velx || !b->Bot.missile->vely) || !Check_LOS(actor, b->Bot.missile, SHOOTFOV*3/2)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.sleft = !b->Bot.sleft;
|
|
|
|
b->Bot.missile = NULL; //Probably ended its travel.
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (actor->pitch > 0)
|
|
|
|
actor->pitch -= 80;
|
|
|
|
else if (actor->pitch <= -60)
|
|
|
|
actor->pitch += 80;
|
|
|
|
|
|
|
|
//HOW TO MOVE:
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.missile && (P_AproxDistance(actor->x-b->Bot.missile->x, actor->y-b->Bot.missile->y)<AVOID_DIST)) //try avoid missile got from P_Mobj.c thinking part.
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
Pitch (actor, b->Bot.missile);
|
|
|
|
actor->player->Bot.angle = R_PointToAngle2(actor->x, actor->y, b->Bot.missile->x, b->Bot.missile->y);
|
|
|
|
cmd->ucmd.sidemove = b->Bot.sleft ? -SIDERUN : SIDERUN;
|
2006-02-24 04:48:15 +00:00
|
|
|
cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best.
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if ((P_AproxDistance(actor->x-b->Bot.oldx, actor->y-b->Bot.oldy)<50000)
|
|
|
|
&& b->Bot.t_strafe<=0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.t_strafe = 5;
|
|
|
|
b->Bot.sleft = !b->Bot.sleft;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//If able to see enemy while avoiding missile, still fire at enemy.
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.enemy && Check_LOS (actor, b->Bot.enemy, SHOOTFOV))
|
2006-02-24 04:48:15 +00:00
|
|
|
Dofire (actor, cmd); //Order bot to fire current weapon
|
|
|
|
}
|
2014-10-13 17:40:25 +00:00
|
|
|
else if (b->Bot.enemy && P_CheckSight (actor, b->Bot.enemy, 0)) //Fight!
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
Pitch (actor, b->Bot.enemy);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//Check if it's more important to get an item than fight.
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.dest && (b->Bot.dest->flags&MF_SPECIAL)) //Must be an item, that is close enough.
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
#define is(x) b->Bot.dest->IsKindOf (PClass::FindClass (#x))
|
2006-02-24 04:48:15 +00:00
|
|
|
if (
|
|
|
|
(
|
2014-10-13 17:40:25 +00:00
|
|
|
(actor->health < b->Bot.skill.isp &&
|
2006-02-24 04:48:15 +00:00
|
|
|
(is (Medikit) ||
|
|
|
|
is (Stimpack) ||
|
|
|
|
is (Soulsphere) ||
|
|
|
|
is (Megasphere) ||
|
|
|
|
is (CrystalVial)
|
|
|
|
)
|
|
|
|
) || (
|
|
|
|
is (Invulnerability) ||
|
|
|
|
is (Invisibility) ||
|
|
|
|
is (Megasphere)
|
|
|
|
) ||
|
|
|
|
dist < (GETINCOMBAT/4) ||
|
|
|
|
(b->ReadyWeapon == NULL || b->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON)
|
|
|
|
)
|
|
|
|
&& (dist < GETINCOMBAT || (b->ReadyWeapon == NULL || b->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
2014-10-13 17:40:25 +00:00
|
|
|
&& Reachable (actor, b->Bot.dest))
|
2006-02-24 04:48:15 +00:00
|
|
|
#undef is
|
|
|
|
{
|
|
|
|
goto roam; //Pick it up, no matter the situation. All bonuses are nice close up.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = NULL; //To let bot turn right
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (b->ReadyWeapon != NULL && !(b->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
|
|
|
actor->flags &= ~MF_DROPOFF; //Don't jump off any ledges when fighting.
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (!(b->Bot.enemy->flags3 & MF3_ISMONSTER))
|
|
|
|
b->Bot.t_fight = AFTERTICS;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.t_strafe <= 0 &&
|
|
|
|
(P_AproxDistance(actor->x-b->Bot.oldx, actor->y-b->Bot.oldy)<50000
|
2006-02-24 04:48:15 +00:00
|
|
|
|| ((pr_botmove()%30)==10))
|
|
|
|
)
|
|
|
|
{
|
|
|
|
stuck = true;
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.t_strafe = 5;
|
|
|
|
b->Bot.sleft = !b->Bot.sleft;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.angle = R_PointToAngle2(actor->x, actor->y, b->Bot.enemy->x, b->Bot.enemy->y);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (b->ReadyWeapon == NULL ||
|
2014-10-13 17:40:25 +00:00
|
|
|
P_AproxDistance(actor->x-b->Bot.enemy->x, actor->y-b->Bot.enemy->y) >
|
2006-02-24 04:48:15 +00:00
|
|
|
b->ReadyWeapon->MoveCombatDist)
|
|
|
|
{
|
|
|
|
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)
|
2014-10-13 17:40:25 +00:00
|
|
|
cmd->ucmd.forwardmove = (b->Bot.enemy->flags3 & MF3_ISMONSTER) ? FORWARDWALK : FORWARDRUN;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (!stuck) //Too close, so move away.
|
|
|
|
{
|
|
|
|
// If a monster, use lower speed (just for cooler apperance while strafing down doomed monster)
|
2014-10-13 17:40:25 +00:00
|
|
|
cmd->ucmd.forwardmove = (b->Bot.enemy->flags3 & MF3_ISMONSTER) ? -FORWARDWALK : -FORWARDRUN;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Strafing.
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.enemy->flags3 & MF3_ISMONSTER) //It's just a monster so take it down cool.
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
cmd->ucmd.sidemove = b->Bot.sleft ? -SIDEWALK : SIDEWALK;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
cmd->ucmd.sidemove = b->Bot.sleft ? -SIDERUN : SIDERUN;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
Dofire (actor, cmd); //Order bot to fire current weapon
|
|
|
|
}
|
2014-10-13 17:40:25 +00:00
|
|
|
else if (b->Bot.mate && !b->Bot.enemy && (!b->Bot.dest || b->Bot.dest==b->Bot.mate)) //Follow mate move.
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t matedist;
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
Pitch (actor, b->Bot.mate);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (!Reachable (actor, b->Bot.mate))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.mate == b->Bot.dest && pr_botmove.Random() < 32)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // [RH] If the mate is the dest, pick a new dest sometimes
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
goto roam;
|
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
actor->player->Bot.angle = R_PointToAngle2(actor->x, actor->y, b->Bot.mate->x, b->Bot.mate->y);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
matedist = P_AproxDistance(actor->x - b->Bot.mate->x, actor->y - b->Bot.mate->y);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (matedist > (FRIEND_DIST*2))
|
|
|
|
cmd->ucmd.forwardmove = FORWARDRUN;
|
|
|
|
else if (matedist > FRIEND_DIST)
|
|
|
|
cmd->ucmd.forwardmove = FORWARDWALK; //Walk, when starting to get close.
|
|
|
|
else if (matedist < FRIEND_DIST-(FRIEND_DIST/3)) //Got too close, so move away.
|
|
|
|
cmd->ucmd.forwardmove = -FORWARDWALK;
|
|
|
|
}
|
|
|
|
else //Roam after something.
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.first_shot = true;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
/////
|
|
|
|
roam:
|
|
|
|
/////
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.enemy && Check_LOS (actor, b->Bot.enemy, SHOOTFOV*3/2)) //If able to see enemy while avoiding missile , still fire at it.
|
2006-02-24 04:48:15 +00:00
|
|
|
Dofire (actor, cmd); //Order bot to fire current weapon
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.dest && !(b->Bot.dest->flags&MF_SPECIAL) && b->Bot.dest->health < 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ //Roaming after something dead.
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.dest == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.t_fight && b->Bot.enemy) //Enemy/bot has jumped around corner. So what to do?
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.enemy->player)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
if (((b->Bot.enemy->player->ReadyWeapon != NULL && b->Bot.enemy->player->ReadyWeapon->WeaponFlags & WIF_BOT_EXPLOSIVE) ||
|
|
|
|
(pr_botmove()%100)>b->Bot.skill.isp) && b->ReadyWeapon != NULL && !(b->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON))
|
|
|
|
b->Bot.dest = b->Bot.enemy;//Dont let enemy kill the bot by supressive fire. So charge enemy.
|
2006-02-24 04:48:15 +00:00
|
|
|
else //hide while b->t_fight, but keep view at enemy.
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.angle = R_PointToAngle2(actor->x, actor->y, b->Bot.enemy->x, b->Bot.enemy->y);
|
2006-02-24 04:48:15 +00:00
|
|
|
} //Just a monster, so kill it.
|
|
|
|
else
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = b->Bot.enemy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//VerifFavoritWeapon(actor->player); //Dont know why here.., but it must be here, i know the reason, but not why at this spot, uh.
|
|
|
|
}
|
|
|
|
else //Choose a distant target. to get things going.
|
|
|
|
{
|
|
|
|
r = pr_botmove();
|
|
|
|
if (r < 128)
|
|
|
|
{
|
|
|
|
TThinkerIterator<AInventory> it (STAT_INVENTORY, firstthing);
|
|
|
|
AInventory *item = it.Next();
|
|
|
|
|
|
|
|
if (item != NULL || (item = it.Next()) != NULL)
|
|
|
|
{
|
|
|
|
r &= 63; // Only scan up to 64 entries at a time
|
|
|
|
while (r)
|
|
|
|
{
|
|
|
|
--r;
|
|
|
|
item = it.Next();
|
|
|
|
}
|
|
|
|
if (item == NULL)
|
|
|
|
{
|
|
|
|
item = it.Next();
|
|
|
|
}
|
|
|
|
firstthing = item;
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = item;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-13 17:40:25 +00:00
|
|
|
else if (b->Bot.mate && (r < 179 || P_CheckSight(actor, b->Bot.mate)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = b->Bot.mate;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if ((playeringame[(r&(MAXPLAYERS-1))]) && players[(r&(MAXPLAYERS-1))].mo->health > 0)
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.dest = players[(r&(MAXPLAYERS-1))].mo;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.dest)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.t_roam = MAXROAM;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.dest)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ //Bot has a target so roam after it.
|
|
|
|
Roam (actor, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
} //End of movement main part.
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (!b->Bot.t_roam && b->Bot.dest)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.prev = b->Bot.dest;
|
|
|
|
b->Bot.dest = NULL;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if (b->Bot.t_fight<(AFTERTICS/2))
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->flags |= MF_DROPOFF;
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.oldx = actor->x;
|
|
|
|
b->Bot.oldy = actor->y;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//BOT_WhatToGet
|
|
|
|
//
|
|
|
|
//Determines if the bot will roam after an item or not.
|
2008-03-28 00:38:17 +00:00
|
|
|
void FCajunMaster::WhatToGet (AActor *actor, AActor *item)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
player_t *b = actor->player;
|
|
|
|
|
|
|
|
if (b == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
#define typeis(x) item->IsKindOf (PClass::FindClass (#x))
|
2006-02-24 04:48:15 +00:00
|
|
|
if ((item->renderflags & RF_INVISIBLE) //Under respawn and away.
|
2014-10-13 17:40:25 +00:00
|
|
|
|| item == b->Bot.prev)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int weapgiveammo = (alwaysapplydmflags || deathmatch) && !(dmflags & DF_WEAPONS_STAY);
|
|
|
|
|
2008-03-28 00:38:17 +00:00
|
|
|
//if(pos && !bglobal.thingvis[pos->id][item->id]) continue;
|
2006-02-24 04:48:15 +00:00
|
|
|
// if (item->IsKindOf (RUNTIME_CLASS(AArtifact)))
|
|
|
|
// return; // don't know how to use artifacts
|
|
|
|
if (item->IsKindOf (RUNTIME_CLASS(AWeapon)))
|
2006-06-17 20:29:41 +00:00
|
|
|
{
|
2006-02-24 04:48:15 +00:00
|
|
|
// FIXME
|
|
|
|
AWeapon *heldWeapon;
|
|
|
|
|
|
|
|
heldWeapon = static_cast<AWeapon *> (b->mo->FindInventory (item->GetClass()));
|
|
|
|
if (heldWeapon != NULL)
|
|
|
|
{
|
|
|
|
if (!weapgiveammo)
|
|
|
|
return;
|
|
|
|
if ((heldWeapon->Ammo1 == NULL || heldWeapon->Ammo1->Amount >= heldWeapon->Ammo1->MaxAmount) &&
|
|
|
|
(heldWeapon->Ammo2 == NULL || heldWeapon->Ammo2->Amount >= heldWeapon->Ammo2->MaxAmount))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (item->IsKindOf (RUNTIME_CLASS(AAmmo)))
|
|
|
|
{
|
|
|
|
AAmmo *ammo = static_cast<AAmmo *> (item);
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *parent = ammo->GetParentAmmo ();
|
2006-02-24 04:48:15 +00:00
|
|
|
AInventory *holdingammo = b->mo->FindInventory (parent);
|
|
|
|
|
|
|
|
if (holdingammo != NULL && holdingammo->Amount >= holdingammo->MaxAmount)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((typeis (Megasphere) || typeis (Soulsphere) || typeis (HealthBonus)) && actor->health >= deh.MaxSoulsphere)
|
|
|
|
return;
|
2006-04-20 14:21:27 +00:00
|
|
|
else if (item->IsKindOf (RUNTIME_CLASS(AHealth)) && actor->health >= deh.MaxHealth /*MAXHEALTH*/)
|
2006-02-24 04:48:15 +00:00
|
|
|
return;
|
|
|
|
|
2014-10-13 17:40:25 +00:00
|
|
|
if ((b->Bot.dest == NULL ||
|
|
|
|
!(b->Bot.dest->flags & MF_SPECIAL)/* ||
|
2006-02-24 04:48:15 +00:00
|
|
|
!Reachable (actor, b->dest)*/)/* &&
|
|
|
|
Reachable (actor, item)*/) // Calling Reachable slows this down tremendously
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
b->Bot.prev = b->Bot.dest;
|
|
|
|
b->Bot.dest = item;
|
|
|
|
b->Bot.t_roam = MAXROAM;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-28 00:38:17 +00:00
|
|
|
void FCajunMaster::Set_enemy (AActor *actor)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *oldenemy;
|
2014-10-13 17:40:25 +00:00
|
|
|
AActor **enemy = &actor->player->Bot.enemy;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (*enemy
|
|
|
|
&& (*enemy)->health > 0
|
|
|
|
&& P_CheckSight (actor, *enemy))
|
|
|
|
{
|
|
|
|
oldenemy = *enemy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldenemy = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// [RH] Don't even bother looking for a different enemy if this is not deathmatch
|
|
|
|
// and we already have an existing enemy.
|
|
|
|
if (deathmatch || !*enemy)
|
|
|
|
{
|
2014-10-13 17:40:25 +00:00
|
|
|
actor->player->Bot.allround = !!*enemy;
|
2006-02-24 04:48:15 +00:00
|
|
|
*enemy = NULL;
|
|
|
|
*enemy = Find_enemy(actor);
|
|
|
|
if (!*enemy)
|
|
|
|
*enemy = oldenemy; //Try go for last (it will be NULL if there wasn't anyone)
|
|
|
|
}
|
|
|
|
//Verify that that enemy is really something alive that bot can kill.
|
2007-12-28 11:17:52 +00:00
|
|
|
if (*enemy && (((*enemy)->health < 0 || !((*enemy)->flags&MF_SHOOTABLE)) || actor->IsFriend(*enemy)))
|
2006-02-24 04:48:15 +00:00
|
|
|
*enemy = NULL;
|
|
|
|
}
|