This is the function I created to do this:
1. If Bot (m_pPlayer->pev->flags, FL_FAKECLIENT)...
2. Depletes its ammo (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0)
3. m_flFreeammotime (declered in weapons.h) increases its value 5 secs ( 8.0f )
4. Then if time (I think I wrote this right) is greater than m_flFreeammotime (m_flFreeammotime && gpGlobals->time > m_flFreeammotime)
5. Give some ammo to the bo (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]+=25;) , but not before 5 seconds have passed...
The function:
/================================================================================================ / Modulo para limitar la actividad de los Bots cuando se quedan sin munición y le regalamos un poco
//================================================================================================
if (FBitSet(m_pPlayer->pev->flags, FL_FAKECLIENT) && (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] == 0))
{
m_flFreeammotime = gpGlobals->time + 8.0f;
}
if (FBitSet(m_pPlayer->pev->flags, FL_FAKECLIENT) && (m_flFreeammotime && gpGlobals->time > m_flFreeammotime))
{
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]+=25;
}
//================================================================================================
It does not work. Bots deplete their ammo and remain that way, no ammo is given to them. The "m_flFreeammotime && gpGlobals->time > m_flFreeammotime" it´s the same code ( using m_flFreezeTime instead) used to detect if that time (5 secs) has passed and let the bots move after firing the weapons, and it works!, I thought that using the same code will work too but it does not.
What I am doing wrong?