From 3712231df3e61781b443f3e0f2c29198cd6ab91a Mon Sep 17 00:00:00 2001 From: Lucas GAUTHERON Date: Sun, 24 Apr 2011 17:21:47 +0000 Subject: [PATCH] finishing custom bot fov support git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6321 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- bot/bot_skill.cfg | 10 +++++----- source/src/bot/bot_ai.cpp | 24 +++++++++++++++--------- source/src/bot/botmanager.cpp | 14 +++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/bot/bot_skill.cfg b/bot/bot_skill.cfg index 1d962ff1..e1c096a1 100644 --- a/bot/bot_skill.cfg +++ b/bot/bot_skill.cfg @@ -108,7 +108,7 @@ can_search_items_in_combat 1 shoot_at_feet_percent 85 max_hear_volume 75 -field_of_view 120 +field_of_view 200 [SKILL2] min_general_delay 0.035 @@ -136,7 +136,7 @@ can_search_items_in_combat 1 shoot_at_feet_percent 60 max_hear_volume 60 -field_of_view 105 +field_of_view 160 [SKILL3] min_x_aim_speed 190 @@ -161,7 +161,7 @@ can_search_items_in_combat 0 shoot_at_feet_percent 25 max_hear_volume 40 -field_of_view 95 +field_of_view 140 [SKILL4] min_x_aim_speed 155 @@ -186,7 +186,7 @@ can_search_items_in_combat 0 shoot_at_feet_percent 10 max_hear_volume 30 -field_of_view 85 +field_of_view 120 [SKILL5] min_x_aim_speed 60 @@ -211,4 +211,4 @@ can_search_items_in_combat 0 shoot_at_feet_percent 0 max_hear_volume 15 -field_of_view 75 \ No newline at end of file +field_of_view 110 \ No newline at end of file diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index fb98d761..f00016c0 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -2026,18 +2026,24 @@ void CBot::HearSound(int n, vec *o) bool CBot::IsInFOV(const vec &o) { - vec v2, forward, right, up; + vec target, dir, forward, right, up; float flDot, flAngle; AnglesToVectors(GetViewAngles(), forward, right, up); - v2 = o; - v2.sub(m_pMyEnt->o); - v2.z = 0.0f; // Make 2D - forward.z = 0; // Make 2D + // direction the bot is aiming at + dir = forward; + dir.z = 0; // Make 2D - flDot = v2.dot(forward); - flAngle = acos(flDot/(v2.magnitude() * forward.magnitude())); - return (float)m_pBotSkill->iFov >= flAngle/RAD; -} + // ideal direction + target = o; + target.sub(m_pMyEnt->o); + target.z = 0.0f; // Make 2D + + // angle between these two directions + flDot = target.dot(dir); + flAngle = acos(flDot/(target.magnitude() * dir.magnitude())); + + return m_pBotSkill->iFov/2.0f >= flAngle/RAD; +} // Code of CBot - End diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 43fc352a..e9a4a83d 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -627,8 +627,8 @@ void CBotManager::CreateSkillData() } else if (strcasecmp(cmd, "field_of_view") == 0) { - if (value < 60) value = 60; - else if (value > 130) value = 130; + if (value < 80) value = 80; + else if (value > 240) value = 120; m_BotSkills[SkillNr].iFov = (int)value; } else if (strcasecmp(cmd, "max_hear_volume") == 0) @@ -670,7 +670,7 @@ void CBotManager::InitSkillData() m_BotSkills[0].sShootAtFeetWithRLPercent = 85; m_BotSkills[0].bCanPredict = true; m_BotSkills[0].iMaxHearVolume = 75; - m_BotSkills[0].iFov = 120; + m_BotSkills[0].iFov = 200; m_BotSkills[0].bCircleStrafe = true; m_BotSkills[0].bCanSearchItemsInCombat = true; @@ -692,7 +692,7 @@ void CBotManager::InitSkillData() m_BotSkills[1].sShootAtFeetWithRLPercent = 60; m_BotSkills[1].bCanPredict = true; m_BotSkills[1].iMaxHearVolume = 60; - m_BotSkills[1].iFov = 105; + m_BotSkills[1].iFov = 160; m_BotSkills[1].bCircleStrafe = true; m_BotSkills[1].bCanSearchItemsInCombat = true; @@ -714,7 +714,7 @@ void CBotManager::InitSkillData() m_BotSkills[2].sShootAtFeetWithRLPercent = 25; m_BotSkills[2].bCanPredict = false; m_BotSkills[2].iMaxHearVolume = 45; - m_BotSkills[2].iFov = 95; + m_BotSkills[2].iFov = 130; m_BotSkills[2].bCircleStrafe = true; m_BotSkills[2].bCanSearchItemsInCombat = false; @@ -736,7 +736,7 @@ void CBotManager::InitSkillData() m_BotSkills[3].sShootAtFeetWithRLPercent = 10; m_BotSkills[3].bCanPredict = false; m_BotSkills[3].iMaxHearVolume = 30; - m_BotSkills[3].iFov = 85; + m_BotSkills[3].iFov = 120; m_BotSkills[3].bCircleStrafe = false; m_BotSkills[3].bCanSearchItemsInCombat = false; @@ -758,7 +758,7 @@ void CBotManager::InitSkillData() m_BotSkills[4].sShootAtFeetWithRLPercent = 0; m_BotSkills[4].bCanPredict = false; m_BotSkills[4].iMaxHearVolume = 15; - m_BotSkills[4].iFov = 75; + m_BotSkills[4].iFov = 110; m_BotSkills[4].bCircleStrafe = false; m_BotSkills[4].bCanSearchItemsInCombat = false; }