- Moved bot related variables from player_t into a new FBot class.

This commit is contained in:
ChillyDoom 2014-10-13 18:40:25 +01:00
commit 83d84eaae9
20 changed files with 325 additions and 344 deletions

View file

@ -141,7 +141,7 @@ void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
angle_t an;
int m;
static bool inc[MAXPLAYERS];
AActor *enemy = actor->player->enemy;
AActor *enemy = actor->player->Bot.enemy;
if (!enemy || !(enemy->flags & MF_SHOOTABLE) || enemy->health <= 0)
return;
@ -149,20 +149,20 @@ void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
if (actor->player->ReadyWeapon == NULL)
return;
if (actor->player->damagecount > actor->player->skill.isp)
if (actor->player->damagecount > actor->player->Bot.skill.isp)
{
actor->player->first_shot = true;
actor->player->Bot.first_shot = true;
return;
}
//Reaction skill thing.
if (actor->player->first_shot &&
if (actor->player->Bot.first_shot &&
!(actor->player->ReadyWeapon->WeaponFlags & WIF_BOT_REACTION_SKILL_THING))
{
actor->player->t_react = (100-actor->player->skill.reaction+1)/((pr_botdofire()%3)+3);
actor->player->Bot.t_react = (100-actor->player->Bot.skill.reaction+1)/((pr_botdofire()%3)+3);
}
actor->player->first_shot = false;
if (actor->player->t_react)
actor->player->Bot.first_shot = false;
if (actor->player->Bot.t_react)
return;
//MAKEME: Decrease the rocket suicides even more.
@ -199,8 +199,8 @@ void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
else if (actor->player->ReadyWeapon->WeaponFlags & WIF_BOT_BFG)
{
//MAKEME: This should be smarter.
if ((pr_botdofire()%200)<=actor->player->skill.reaction)
if(Check_LOS(actor, actor->player->enemy, SHOOTFOV))
if ((pr_botdofire()%200)<=actor->player->Bot.skill.reaction)
if(Check_LOS(actor, actor->player->Bot.enemy, SHOOTFOV))
no_fire = false;
}
else if (actor->player->ReadyWeapon->ProjectileType != NULL)
@ -211,11 +211,11 @@ void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
an = FireRox (actor, enemy, cmd);
if(an)
{
actor->player->angle = an;
actor->player->Bot.angle = an;
//have to be somewhat precise. to avoid suicide.
if (abs (actor->player->angle - actor->angle) < 12*ANGLE_1)
if (abs (actor->player->Bot.angle - actor->angle) < 12*ANGLE_1)
{
actor->player->t_rocket = 9;
actor->player->Bot.t_rocket = 9;
no_fire = false;
}
}
@ -225,14 +225,14 @@ shootmissile:
dist = P_AproxDistance (actor->x - enemy->x, actor->y - enemy->y);
m = dist / GetDefaultByType (actor->player->ReadyWeapon->ProjectileType)->Speed;
SetBodyAt (enemy->x + enemy->velx*m*2, enemy->y + enemy->vely*m*2, enemy->z, 1);
actor->player->angle = R_PointToAngle2 (actor->x, actor->y, body1->x, body1->y);
actor->player->Bot.angle = R_PointToAngle2 (actor->x, actor->y, body1->x, body1->y);
if (Check_LOS (actor, enemy, SHOOTFOV))
no_fire = false;
}
else
{
//Other weapons, mostly instant hit stuff.
actor->player->angle = R_PointToAngle2 (actor->x, actor->y, enemy->x, enemy->y);
actor->player->Bot.angle = R_PointToAngle2 (actor->x, actor->y, enemy->x, enemy->y);
aiming_penalty = 0;
if (enemy->flags & MF_SHADOW)
aiming_penalty += (pr_botdofire()%25)+10;
@ -240,7 +240,7 @@ shootmissile:
aiming_penalty += pr_botdofire()%40;//Dark
if (actor->player->damagecount)
aiming_penalty += actor->player->damagecount; //Blood in face makes it hard to aim
aiming_value = actor->player->skill.aiming - aiming_penalty;
aiming_value = actor->player->Bot.skill.aiming - aiming_penalty;
if (aiming_value <= 0)
aiming_value = 1;
m = ((SHOOTFOV/2)-(aiming_value*SHOOTFOV/200)); //Higher skill is more accurate
@ -250,12 +250,12 @@ shootmissile:
if (m)
{
if (inc[actor->player - players])
actor->player->angle += m;
actor->player->Bot.angle += m;
else
actor->player->angle -= m;
actor->player->Bot.angle -= m;
}
if (abs (actor->player->angle - actor->angle) < 4*ANGLE_1)
if (abs (actor->player->Bot.angle - actor->angle) < 4*ANGLE_1)
{
inc[actor->player - players] = !inc[actor->player - players];
}
@ -285,20 +285,20 @@ AActor *FCajunMaster::Choose_Mate (AActor *bot)
bool p_leader[MAXPLAYERS];
//is mate alive?
if (bot->player->mate)
if (bot->player->Bot.mate)
{
if (bot->player->mate->health <= 0)
bot->player->mate = NULL;
if (bot->player->Bot.mate->health <= 0)
bot->player->Bot.mate = NULL;
else
bot->player->last_mate = bot->player->mate;
bot->player->Bot.last_mate = bot->player->Bot.mate;
}
if (bot->player->mate) //Still is..
return bot->player->mate;
if (bot->player->Bot.mate) //Still is..
return bot->player->Bot.mate;
//Check old_mates status.
if (bot->player->last_mate)
if (bot->player->last_mate->health <= 0)
bot->player->last_mate = NULL;
if (bot->player->Bot.last_mate)
if (bot->player->Bot.last_mate->health <= 0)
bot->player->Bot.last_mate = NULL;
for (count = 0; count < MAXPLAYERS; count++)
{
@ -307,8 +307,8 @@ AActor *FCajunMaster::Choose_Mate (AActor *bot)
p_leader[count] = false;
for (count2 = 0; count2 < MAXPLAYERS; count2++)
{
if (players[count].isbot
&& players[count2].mate == players[count].mo)
if (players[count].Bot.isbot
&& players[count2].Bot.mate == players[count].mo)
{
p_leader[count] = true;
break;
@ -386,11 +386,11 @@ AActor *FCajunMaster::Find_enemy (AActor *bot)
}
//Note: It's hard to ambush a bot who is not alone
if (bot->player->allround || bot->player->mate)
if (bot->player->Bot.allround || bot->player->Bot.mate)
vangle = ANGLE_MAX;
else
vangle = ENEMY_SCAN_FOV;
bot->player->allround = false;
bot->player->Bot.allround = false;
target = NULL;
closest_dist = FIXED_MAX;