Oh. I think my bots will act like that forever because I am not able to code a complex combat algorythm. :/
EDIT: Well. I have long thought about what you told me and, after trying and trying variations of the code, the closest thing to what I want to achieve is this:
//=====================================================================
// FEMP
// 30-Nov-2018 1er. Intento de que lo usen los BOTS
//=====================================================================
if ((pev->weapons & (1<<WEAPON_FEMP)) )
{
if (
((distance < 100) && (distance > 10 ) && ( fempshot == 0 ))
&& (weapon_choice == 0)
&& (weapon_choice == WEAPON_FEMP)
|| (primary_ammo[WEAPON_TWOHAND] < 10)
|| ( primary_ammo[WEAPON_SHORYUKEN] < 10 )
|| ( primary_ammo[WEAPON_SIEGE] < 10 )
|| ( primary_ammo[WEAPON_MJOLNIR] < 10 )
|| ( primary_ammo[WEAPON_SHREDDER] < 10 )
)
{
if (primary_ammo[WEAPON_FEMP] > 0) // check if the bot has any ammo left for this weapon...
{
if (m_pActiveItem != new_weapon)// check if the bot isn't already using this item...
SelectItem("weapon_femp"); // select the FEMP
pev->button |= IN_ATTACK; // use primary attack (bang! bang!)
f_shoot_time = gpGlobals->time + 10.0 + RANDOM_FLOAT(primary_fire_delay[WEAPON_FEMP][bot_skill][0],primary_fire_delay[WEAPON_FEMP][bot_skill][1]); // set next time to shoot
fempshot +=1; // Damos un fempshot para limitar su uso
return TRUE;
if ( ( pev->health <= 100 ) )
{
pev->button |= IN_ATTACK2;
} // Posicion original del codigo del AUTO-HEALTH
if ( f_shoot_time = gpGlobals->time = 15.0 )
{
fempshot -=1;
}
}
}
}
return FALSE;
}
And this:
//=============================================================================================
// WEAPON URAKEN/CROWBAR I cannot make the bot use this weapon!!! I suck in coding...4-May-2015
// GOT IT!! 24-November-2018 but with Issues...
//=============================================================================================
if (pev->weapons & (1<<WEAPON_CROWBAR))
{
if (
(distance == 0)
&& (weapon_choice == 0)
|| (( fempshot == 1) && ( f_shoot_time = gpGlobals->time == 0.0 ))
&& (weapon_choice == WEAPON_CROWBAR)
|| ( primary_ammo[WEAPON_TWOHAND] ==0 )
|| ( primary_ammo[WEAPON_SHORYUKEN] ==0 )
|| ( primary_ammo[WEAPON_SIEGE] ==0 )
|| ( primary_ammo[WEAPON_MJOLNIR] ==0 )
|| ( primary_ammo[WEAPON_SHREDDER] ==0 )
)
{
new_weapon = weapon_ptr[WEAPON_CROWBAR];
{
if (m_pActiveItem != new_weapon)// check if the bot isn't already using this item...
SelectItem("weapon_crowbar"); // select the crowbar
pev->button |= IN_ATTACK; // use primary attack (whack! whack!)
f_shoot_time = gpGlobals->time + 4.0 + RANDOM_FLOAT(primary_fire_delay[WEAPON_CROWBAR][bot_skill][0],primary_fire_delay[WEAPON_CROWBAR][bot_skill][1]);
return TRUE;
}
}
}
//========================================================================================
Well. What I obtained is that the Bots now "seem" to act differently: some of them use one weapon and others use a different weapon, but, if one or two of them are slightly close to each ohter, they tend to use the same weapon. For them to use a diferent weapon the distance must be much bigger i.e: one in the outer circle and the ohter in the third farthest of the bridges.
What I want is the Bots use the Uraken when the enemy is very close, and the FEMP if the distance is farther, BUT, keeping them from sticking to that weapon, because, once they start to use one or another, they seem to like it so much and hardly choose another weapon...
Also, they seem to not detect very well the distances, because they use short range weapons when thereĀ“s no close enemy.
Also. I have one more doubt and probably the dumbest, but... how can I measure distances in the map editor?. I mean, I want the Bot to use weapon X if distance is Y, but I donĀ“t know how to measure it (remember that I use a block the size of the info_player_start to do calculations!!).
Thanks in anticipation,