View Single Post
Another IsShootableThruObstacle() function!!!!!!!!
Old
  (#1)
Immortal_BLG
Member
 
Status: Offline
Posts: 171
Join Date: Nov 2007
Location: Russian Federation
Thumbs up Another IsShootableThruObstacle() function!!!!!!!! - 26-08-2009

I wrote the function, placed below, that's 99,99% more accuracy than functions from PoDBot, YaPB or another bot!!!!!!!! - It based on cheat's CanPenetrate() function.

Code:
const bool Bot::IsShootableThruObstacle (const Math::Vector3D &destination)
{
	// This function returns true if enemy can be shoot through some obstacle, false otherwise.

	if (m_profile->skill <= 70u)
		return false;

	unsigned char currentWeaponPenetrationPower = g_weaponProperties[m_currentWeapon->GetID ()].penetrationPower;

	if (currentWeaponPenetrationPower == 0u)
		return false;

	// set conditions....
	Math::Vector3D source (m_edict->GetEyePosition ());
	const Math::Vector3D &direction ((destination - source).Normalize () * 8.0f);	// 8 units long

	do
	{
		// trace from the bot's eyes to destination...
		HalfLifeEngine::Globals::g_halfLifeEngine->TraceLine (source, destination, HalfLifeEngine::SDK::Constants::TraceIgnore_Monsters, m_edict, m_traceResult);

		if (m_traceResult.isStartSolid)
		{
			if (m_traceResult.isAllSolid)
				return false;

			// move 8 units closer to the destination....
			source += direction;
		}
		else
		{
			// check if line hit anything
			if (m_traceResult.fraction == 1.0f)
				return true;

			--currentWeaponPenetrationPower;

			// move 8 units closer to the destination....
			source = m_traceResult.endPosition + direction;
		}
	} while (currentWeaponPenetrationPower > 0u);

	return false;
}
There 'm_traceResult' it's a HL engine TraceResult structure, placed in main bot class for memory economy .
'currentWeaponPenetrationPower' it's a number, that's can be calculated with below function (from cheat, too)
Code:
int CorrectGun(int weaponID)
{
	if (weaponID == WEAPONLIST_SG550 || weaponID == WEAPONLIST_G3SG1 || weaponID == WEAPONLIST_SCOUT || weaponID == WEAPONLIST_AWP) 
		return 3; 
	if (weaponID == WEAPONLIST_AUG || weaponID == WEAPONLIST_M249 || weaponID == WEAPONLIST_M4A1 || weaponID == WEAPONLIST_DEAGLE || weaponID == WEAPONLIST_SG552 || weaponID == WEAPONLIST_AK47|| weaponID == WEAPONLIST_FAMAS || weaponID == WEAPONLIST_GALIL) 
		return 2; 

	return 0; 
}
- but for me it's too slow, and I placed the numbers above into the WeaponProperties_t structure.
  
Reply With Quote