/** * Buy weapons, armor, etc. */ void BuyState::OnEnter( CCSBot *me ) { m_retries = 0; m_prefRetries = 0; m_prefIndex = 0; const char *cheatWeaponString = bot_loadout.GetString(); if ( cheatWeaponString && *cheatWeaponString ) { m_doneBuying = false; // we're going to be given weapons - ignore the eco limit } else { // check if we are saving money for the next round if (me->m_iAccount < cv_bot_eco_limit.GetFloat()) { me->PrintIfWatched( "Saving money for next round.\n" ); m_doneBuying = true; } else { m_doneBuying = false; } } m_isInitialDelay = true; // this will force us to stop holding live grenade me->EquipBestWeapon( MUST_EQUIP ); m_buyDefuseKit = false; m_buyShield = false; if (me->GetTeamNumber() == TEAM_CT) { if (TheCSBots()->GetScenario() == CCSBotManager::SCENARIO_DEFUSE_BOMB) { // CT's sometimes buy defuse kits in the bomb scenario (except in career mode, where the player should defuse) if (CSGameRules()->IsCareer() == false) { const float buyDefuseKitChance = 100.0f * (me->GetProfile()->GetSkill() + 0.2f); if (RandomFloat( 0.0f, 100.0f ) < buyDefuseKitChance) { m_buyDefuseKit = true; } } } // determine if we want a tactical shield if (!me->HasPrimaryWeapon() && TheCSBots()->AllowTacticalShield()) { if (me->m_iAccount > 2500) { if (me->m_iAccount < 4000) m_buyShield = (RandomFloat( 0, 100.0f ) < 33.3f) ? true : false; else m_buyShield = (RandomFloat( 0, 100.0f ) < 10.0f) ? true : false; } } } if (TheCSBots()->AllowGrenades()) { m_buyGrenade = (RandomFloat( 0.0f, 100.0f ) < 33.3f) ? true : false; } else { m_buyGrenade = false; } m_buyPistol = false; if (TheCSBots()->AllowPistols()) { // check if we have a pistol if (me->Weapon_GetSlot( WEAPON_SLOT_PISTOL )) { // if we have our default pistol, think about buying a different one if (HasDefaultPistol( me )) { // if everything other than pistols is disallowed, buy a pistol if (TheCSBots()->AllowShotguns() == false && TheCSBots()->AllowSubMachineGuns() == false && TheCSBots()->AllowRifles() == false && TheCSBots()->AllowMachineGuns() == false && TheCSBots()->AllowTacticalShield() == false && TheCSBots()->AllowSnipers() == false) { m_buyPistol = (RandomFloat( 0, 100 ) < 75.0f); } else if (me->m_iAccount < 1000) { // if we're low on cash, buy a pistol m_buyPistol = (RandomFloat( 0, 100 ) < 75.0f); } else { m_buyPistol = (RandomFloat( 0, 100 ) < 33.3f); } } } else { // we dont have a pistol - buy one m_buyPistol = true; } } }
// Buy weapons, armor, etc. void BuyState::__MAKE_VHOOK(OnEnter)(CCSBot *me) { m_retries = 0; m_prefRetries = 0; m_prefIndex = 0; m_doneBuying = false; m_isInitialDelay = true; // this will force us to stop holding live grenade me->EquipBestWeapon(); m_buyDefuseKit = false; m_buyShield = false; if (me->m_iTeam == CT) { if (TheCSBots()->GetScenario() == CCSBotManager::SCENARIO_DEFUSE_BOMB) { // CT's sometimes buy defuse kits in the bomb scenario (except in career mode, where the player should defuse) if (!CSGameRules()->IsCareer()) { const float buyDefuseKitChance = 50.0f; // 100.0f * (me->GetProfile()->GetSkill() + 0.2f); if (RANDOM_FLOAT(0.0f, 100.0f) < buyDefuseKitChance) { m_buyDefuseKit = true; } } } // determine if we want a tactical shield if (!me->m_bHasPrimary && TheCSBots()->AllowTacticalShield()) { if (me->m_iAccount > 2500) { if (me->m_iAccount < 4000) m_buyShield = (RANDOM_FLOAT(0, 100.0f) < 33.3f) ? true : false; else m_buyShield = (RANDOM_FLOAT(0, 100.0f) < 10.0f) ? true : false; } } } if (TheCSBots()->AllowGrenades()) { m_buyGrenade = (RANDOM_FLOAT(0.0f, 100.0f) < 33.3f) ? true : false; } else { m_buyGrenade = false; } m_buyPistol = false; if (TheCSBots()->AllowPistols()) { CBasePlayerWeapon *pistol = static_cast<CBasePlayerWeapon *>(me->m_rgpPlayerItems[ PISTOL_SLOT ]); // check if we have a pistol if (pistol != NULL) { // if we have our default pistol, think about buying a different one if (HasDefaultPistol(me)) { // if everything other than pistols is disallowed, buy a pistol if (TheCSBots()->AllowShotguns() == false && TheCSBots()->AllowSubMachineGuns() == false && TheCSBots()->AllowRifles() == false && TheCSBots()->AllowMachineGuns() == false && TheCSBots()->AllowTacticalShield() == false && TheCSBots()->AllowSnipers() == false) { m_buyPistol = (RANDOM_FLOAT(0, 100) < 75.0f); } else if (me->m_iAccount < 1000) { // if we're low on cash, buy a pistol m_buyPistol = (RANDOM_FLOAT(0, 100) < 75.0f); } else { m_buyPistol = (RANDOM_FLOAT(0, 100) < 33.3f); } } } else { // we dont have a pistol - buy one m_buyPistol = true; } } }