allow bots scoping & headshot

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6478 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lucas GAUTHERON
2011-05-30 17:09:34 +00:00
parent 8beb8979a7
commit 958c8e91d8
5 changed files with 30 additions and 12 deletions
+2 -4
View File
@@ -21,10 +21,10 @@ weaponinfo_s WeaponInfoTable[MAX_WEAPONS] =
// ---- Type : -- minDD -- maxDD -- minFD -- maxFD -- mA
{ TYPE_MELEE, 0.0f, 5.0f, 0.0f, 3.5f, 0 }, // KNIFE
{ TYPE_NORMAL, 3.5f, 15.0f, 3.0f, 60.0f, 6 }, // PISTOL
{ TYPE_SNIPER, 20.0f, 80.0f, 3.0f, 180.0f, 2 }, // CARBINE // min and max FD just guesstimates for now
{ TYPE_SNIPER, 15.0f, 80.0f, 3.0f, 180.0f, 2 }, // CARBINE // min and max FD just guesstimates for now
{ TYPE_SHOTGUN, 0.0f, 15.0f, 0.0f, 50.0f, 3 }, // SHOTGUN
{ TYPE_AUTO, 0.0f, 25.0f, 3.0f, 60.0f, 10 }, // SUBGUN
{ TYPE_SNIPER, 15.0f, 125.0f, 3.0f, 200.0f, 3 }, // SNIPER
{ TYPE_SNIPER, 10.0f, 125.0f, 3.0f, 200.0f, 3 }, // SNIPER
{ TYPE_AUTO, 20.0f, 80.0f, 3.0f, 150.0f, 6 }, // ASSAULT
{ TYPE_AUTO, 0.0f, 0.0f, 3.0f, 0.0f, 6 }, // CPISTOL
{ TYPE_GRENADE, 5.0f, 30.0f, 3.0f, 50.0f, 1 }, // GRENADE
@@ -50,8 +50,6 @@ bool CACBot::ChoosePreferredWeapon()
if (!m_pMyEnt->mag[i] && WeaponInfoTable[i].eWeaponType != TYPE_MELEE)
{
continue;
// If no ammo for this weapon, skip it
if(!m_pMyEnt->ammo[i]) continue;
}
else
{
+1 -1
View File
@@ -220,7 +220,7 @@ float CBot::ChangeAngle(float speed, float ideal, float current)
speed = diff; // just need to turn a little bit (less than max)
// check if the bot is already facing the idealpitch direction...
if (diff <= 1.0f)
if (diff <= 0.5f)
return ideal;
if ((current >= 180) && (ideal >= 180))
+1
View File
@@ -247,6 +247,7 @@ public:
bool FindEnemy(void);
void CheckReload(void);
void CheckWeaponSwitch(void); // 2011jan17:ft: fix non-shooting bots
void CheckScope(void);
void ShootEnemy(void);
bool CheckHunt(void);
bool HuntEnemy(void);
+24 -5
View File
@@ -18,8 +18,8 @@ extern weaponinfo_s WeaponInfoTable[MAX_WEAPONS];
vec CBot::GetEnemyPos(playerent *d)
{
// Aim offset idea by botman
vec o = d->o, offset;
float flDist = GetDistance(d->o), flScale;
vec o = m_pMyEnt->weaponsel->type == GUN_SNIPER && d->head.x >= 0 ? d->head : d->o, offset;
float flDist = GetDistance(o), flScale;
if (WeaponInfoTable[m_pMyEnt->gunselect].eWeaponType == TYPE_ROCKET)
{
@@ -751,7 +751,7 @@ int CBot::GetShootDelay()
void CBot::CheckReload() // reload gun if no enemies are around
{
//if(m_pMyEnt->mag[m_pMyEnt->weaponsel->type] >= WeaponInfoTable[m_pMyEnt->weaponsel->type].sMinDesiredAmmo) return; // do not reload if mindesiredammo is satisfied
if(m_pMyEnt->mag[m_pMyEnt->weaponsel->type] >= WeaponInfoTable[m_pMyEnt->weaponsel->type].sMinDesiredAmmo) return; // do not reload if mindesiredammo is satisfied
if(m_pMyEnt->enemy && m_pMyEnt->mag[m_pMyEnt->weaponsel->type])
{
return; // ignore the enemy, if no ammo in mag.
@@ -760,6 +760,23 @@ void CBot::CheckReload() // reload gun if no enemies are around
return;
}
void CBot::CheckScope()
{
#define MINSCOPEDIST 15
#define MINSCOPETIME 1000
if(m_pMyEnt->weaponsel->type != GUN_SNIPER) return;
sniperrifle *sniper = (sniperrifle *)m_pMyEnt->weaponsel;
if(m_pMyEnt->enemy && m_pMyEnt->o.dist(m_pMyEnt->enemy->o) > MINSCOPEDIST)
{
sniper->setscope(true);
}
else if(m_pMyEnt->scoping && lastmillis - sniper->scoped_since < MINSCOPETIME)
{
sniper->setscope(false);
}
}
void CBot::MainAI()
{
// Default bots will run forward
@@ -784,6 +801,7 @@ void CBot::MainAI()
if (BotManager.BotsShoot() && FindEnemy()) // Combat
{
CheckReload();
CheckScope();
AddDebugText("has enemy");
// Use best weapon
ChoosePreferredWeapon();
@@ -802,14 +820,15 @@ void CBot::MainAI()
}
else if (CheckHunt() && HuntEnemy())
{
CheckReload();
CheckReload();
CheckScope();
AddDebugText("Hunting to %s", m_pHuntTarget->name);
m_eCurrentBotState = STATE_HUNT;
}
// Heading to an interesting entity(ammo, armour etc)
else if (CheckItems())
{
CheckReload();
CheckReload();
AddDebugText("has ent");
m_eCurrentBotState = STATE_ENT;
}
+2 -2
View File
@@ -623,7 +623,7 @@ void raydamage(vec &from, vec &to, playerent *d)
switch(d->weaponsel->type)
{
case GUN_KNIFE: gib = true; break;
case GUN_SNIPER: if(d==player1 && hitzone==2) { dam *= 3; gib = true; }; break;
case GUN_SNIPER: if(hitzone==2) { dam *= 3; gib = true; }; break;
case GUN_SUBGUN: if(flag4subgunDMGalt) dam +=1; break;
default: break;
}
@@ -1301,7 +1301,7 @@ void sniperrifle::setscope(bool enable)
if(this == owner->weaponsel && !reloading && owner->state == CS_ALIVE)
{
if(scoped == false && enable == true) scoped_since = lastmillis;
if(player1 == owner && enable != scoped) player1->scoping = enable;
if(enable != scoped) owner->scoping = enable;
scoped = enable;
}
}