removed metamod-messages, since there will be nor updates to metamod ifaces.

This commit is contained in:
jeefo 2016-03-05 23:08:07 +03:00
commit 95d9d4db0c
15 changed files with 259 additions and 268 deletions

View file

@ -281,7 +281,7 @@ void Bot::AvoidGrenades (void)
return;
// check if old pointers to grenade is invalid
if (IsNullEntity (m_avoidGrenade))
if (engine.IsNullEntity (m_avoidGrenade))
{
m_avoidGrenade = NULL;
m_needAvoidGrenade = 0;
@ -318,10 +318,10 @@ void Bot::AvoidGrenades (void)
}
else if (strcmp (STRING (ent->v.model) + 9, "hegrenade.mdl") == 0)
{
if (!IsNullEntity (m_avoidGrenade))
if (!engine.IsNullEntity (m_avoidGrenade))
return;
if (GetTeam (ent->v.owner) == m_team && ent->v.owner != GetEntity ())
if (engine.GetTeam (ent->v.owner) == m_team && ent->v.owner != GetEntity ())
return;
if ((ent->v.flags & FL_ONGROUND) == 0)
@ -469,7 +469,7 @@ void Bot::VerifyBreakable (edict_t *touch)
m_breakableEntity = FindBreakable ();
if (IsNullEntity (m_breakableEntity))
if (engine.IsNullEntity (m_breakableEntity))
return;
m_campButtons = pev->button & IN_DUCK;
@ -572,12 +572,12 @@ void Bot::FindItem (void)
const float searchRadius = 340.0f;
if (!IsNullEntity (m_pickupItem))
if (!engine.IsNullEntity (m_pickupItem))
{
bool itemExists = false;
pickupItem = m_pickupItem;
while (!IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, searchRadius)))
while (!engine.IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, searchRadius)))
{
if ((ent->v.effects & EF_NODRAW) || IsValidPlayer (ent->v.owner))
continue; // someone owns this weapon or it hasn't re spawned yet
@ -612,7 +612,7 @@ void Bot::FindItem (void)
m_pickupItem = NULL;
m_pickupType = PICKUP_NONE;
while (!IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, searchRadius)))
while (!engine.IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, searchRadius)))
{
bool allowPickup = false; // assume can't use it until known otherwise
@ -772,11 +772,11 @@ void Bot::FindItem (void)
{
if (pickupType == PICKUP_HOSTAGE)
{
if (IsNullEntity (ent) || ent->v.health <= 0)
if (engine.IsNullEntity (ent) || ent->v.health <= 0)
allowPickup = false; // never pickup dead hostage
else for (int i = 0; i < engine.MaxClients (); i++)
{
if ((bot = bots.GetBot (i)) != NULL && IsAlive (bot->GetEntity ()))
if ((bot = bots.GetBot (i)) != NULL && bot->m_notKilled)
{
for (int j = 0; j < MAX_HOSTAGES; j++)
{
@ -866,11 +866,11 @@ void Bot::FindItem (void)
}
} // end of the while loop
if (!IsNullEntity (pickupItem))
if (!engine.IsNullEntity (pickupItem))
{
for (int i = 0; i < engine.MaxClients (); i++)
{
if ((bot = bots.GetBot (i)) != NULL && IsAlive (bot->GetEntity ()) && bot->m_pickupItem == pickupItem)
if ((bot = bots.GetBot (i)) != NULL && bot->m_notKilled && bot->m_pickupItem == pickupItem)
{
m_pickupItem = NULL;
m_pickupType = PICKUP_NONE;
@ -1002,9 +1002,9 @@ void Bot::InstantChatterMessage (int type)
for (int i = 0; i < engine.MaxClients (); i++)
{
edict_t *ent = EntityOfIndex (i);
edict_t *ent = engine.EntityOfIndex (i);
if (!IsValidPlayer (ent) || IsValidBot (ent) || GetTeam (ent) != m_team)
if (!IsValidPlayer (ent) || IsValidBot (ent) || engine.GetTeam (ent) != m_team)
continue;
g_sendAudioFinished = false;
@ -1165,7 +1165,7 @@ void Bot::CheckMessageQueue (void)
if (bot != NULL)
{
if (pev != bot->pev && GetTeam (bot->GetEntity ()) == m_team)
if (pev != bot->pev && bot->m_team == m_team)
{
bot->m_radioOrder = m_radioSelect;
bot->m_radioEntity = GetEntity ();
@ -1654,7 +1654,7 @@ void Bot::PurchaseWeapons (void)
else // steam cs buy menu is different from old one
{
if (GetTeam (GetEntity ()) == TERRORIST)
if (engine.GetTeam (GetEntity ()) == TERRORIST)
engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectT);
else
engine.IssueBotCommand (GetEntity (), "menuselect %d", selectedWeapon->newBuySelectCT);
@ -1846,9 +1846,9 @@ void Bot::SetConditions (void)
}
// did bot just kill an enemy?
if (!IsNullEntity (m_lastVictim))
if (!engine.IsNullEntity (m_lastVictim))
{
if (GetTeam (m_lastVictim) != m_team)
if (engine.GetTeam (m_lastVictim) != m_team)
{
// add some aggression because we just killed somebody
m_agressionLevel += 0.1f;
@ -1913,7 +1913,7 @@ void Bot::SetConditions (void)
}
// check if our current enemy is still valid
if (!IsNullEntity (m_lastEnemy))
if (!engine.IsNullEntity (m_lastEnemy))
{
if (!IsAlive (m_lastEnemy) && m_shootAtDeadTime < engine.Time ())
{
@ -1936,7 +1936,7 @@ void Bot::SetConditions (void)
else if (m_heardSoundTime < engine.Time ())
m_states &= ~STATE_HEARING_ENEMY;
if (IsNullEntity (m_enemy) && !IsNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.IsZero ())
if (engine.IsNullEntity (m_enemy) && !engine.IsNullEntity (m_lastEnemy) && !m_lastEnemyOrigin.IsZero ())
{
m_aimFlags |= AIM_PREDICT_PATH;
@ -1946,7 +1946,7 @@ void Bot::SetConditions (void)
CheckGrenadeThrow ();
// check if there are items needing to be used/collected
if (m_itemCheckTime < engine.Time () || !IsNullEntity (m_pickupItem))
if (m_itemCheckTime < engine.Time () || !engine.IsNullEntity (m_pickupItem))
{
m_itemCheckTime = engine.Time () + 0.4f;
FindItem ();
@ -1979,7 +1979,7 @@ void Bot::ApplyTaskFilters (void)
}
// bot found some item to use?
if (!IsNullEntity (m_pickupItem) && GetTaskId () != TASK_ESCAPEFROMBOMB)
if (!engine.IsNullEntity (m_pickupItem) && GetTaskId () != TASK_ESCAPEFROMBOMB)
{
m_states |= STATE_PICKUP_ITEM;
@ -2039,7 +2039,7 @@ void Bot::ApplyTaskFilters (void)
// if half of the round is over, allow hunting
// FIXME: it probably should be also team/map dependant
if (GetTaskId () != TASK_ESCAPEFROMBOMB && IsNullEntity (m_enemy) && g_timeRoundMid < engine.Time () && !m_isUsingGrenade && m_currentWaypointIndex != waypoints.FindNearest (m_lastEnemyOrigin) && m_personality != PERSONALITY_CAREFUL)
if (GetTaskId () != TASK_ESCAPEFROMBOMB && engine.IsNullEntity (m_enemy) && g_timeRoundMid < engine.Time () && !m_isUsingGrenade && m_currentWaypointIndex != waypoints.FindNearest (m_lastEnemyOrigin) && m_personality != PERSONALITY_CAREFUL)
{
float desireLevel = 4096.0f - ((1.0f - tempAgression) * distance);
@ -2228,7 +2228,7 @@ void Bot::TaskComplete (void)
bool Bot::EnemyIsThreat (void)
{
if (IsNullEntity (m_enemy) || GetTaskId () == TASK_SEEKCOVER)
if (engine.IsNullEntity (m_enemy) || GetTaskId () == TASK_SEEKCOVER)
return false;
// if bot is camping, he should be firing anyway and not leaving his position
@ -2276,7 +2276,7 @@ bool Bot::ReactOnEnemy (void)
bool Bot::LastEnemyShootable (void)
{
// don't allow shooting through walls
if (!(m_aimFlags & AIM_LAST_ENEMY) || m_lastEnemyOrigin.IsZero () || IsNullEntity (m_lastEnemy))
if (!(m_aimFlags & AIM_LAST_ENEMY) || m_lastEnemyOrigin.IsZero () || engine.IsNullEntity (m_lastEnemy))
return false;
return GetShootingConeDeviation (GetEntity (), &m_lastEnemyOrigin) >= 0.90f && IsShootableThruObstacle (m_lastEnemyOrigin);
@ -2305,7 +2305,7 @@ void Bot::CheckRadioCommands (void)
// check if line of sight to object is not blocked (i.e. visible)
if ((EntityIsVisible (m_radioEntity->v.origin)) || (m_radioOrder == Radio_StickTogether))
{
if (IsNullEntity (m_targetEntity) && IsNullEntity (m_enemy) && Random.Long (0, 100) < (m_personality == PERSONALITY_CAREFUL ? 80 : 20))
if (engine.IsNullEntity (m_targetEntity) && engine.IsNullEntity (m_enemy) && Random.Long (0, 100) < (m_personality == PERSONALITY_CAREFUL ? 80 : 20))
{
int numFollowers = 0;
@ -2316,7 +2316,7 @@ void Bot::CheckRadioCommands (void)
if (bot != NULL)
{
if (IsAlive (bot->GetEntity ()))
if (bot->m_notKilled)
{
if (bot->m_targetEntity == m_radioEntity)
numFollowers++;
@ -2350,7 +2350,7 @@ void Bot::CheckRadioCommands (void)
if (bot != NULL)
{
if (IsAlive (bot->GetEntity ()))
if (bot->m_notKilled)
{
if (bot->m_targetEntity == m_radioEntity)
{
@ -2370,7 +2370,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_HoldPosition:
if (!IsNullEntity (m_targetEntity))
if (!engine.IsNullEntity (m_targetEntity))
{
if (m_targetEntity == m_radioEntity)
{
@ -2389,9 +2389,9 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_TakingFire:
if (IsNullEntity (m_targetEntity))
if (engine.IsNullEntity (m_targetEntity))
{
if (IsNullEntity (m_enemy) && m_seeEnemyTime + 4.0f < engine.Time ())
if (engine.IsNullEntity (m_enemy) && m_seeEnemyTime + 4.0f < engine.Time ())
{
// decrease fear levels to lower probability of bot seeking cover again
m_fearLevel -= 0.2f;
@ -2420,7 +2420,7 @@ void Bot::CheckRadioCommands (void)
case Radio_NeedBackup:
case Chatter_ScaredEmotion:
case Chatter_Pinned_Down:
if (((IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f || !m_moveToC4) && Random.Long (0, 100) > 50 && m_seeEnemyTime + 4.0f < engine.Time ())
if (((engine.IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f || !m_moveToC4) && Random.Long (0, 100) > 50 && m_seeEnemyTime + 4.0f < engine.Time ())
{
m_fearLevel -= 0.1f;
@ -2452,7 +2452,7 @@ void Bot::CheckRadioCommands (void)
if (m_fearLevel < 0.0f)
m_fearLevel = 0.0f;
}
else if ((IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f)
else if ((engine.IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 2048.0f)
{
TaskID taskID = GetTaskId ();
@ -2476,7 +2476,7 @@ void Bot::CheckRadioCommands (void)
PushTask (TASK_MOVETOPOSITION, TASKPRI_MOVETOPOSITION, -1, 0.0f, true);
}
}
else if (!IsNullEntity (m_doubleJumpEntity))
else if (!engine.IsNullEntity (m_doubleJumpEntity))
{
RadioMessage (Radio_Affirmative);
ResetDoubleJumpState ();
@ -2487,7 +2487,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_ShesGonnaBlow:
if (IsNullEntity (m_enemy) && distance < 2048.0f && g_bombPlanted && m_team == TERRORIST)
if (engine.IsNullEntity (m_enemy) && distance < 2048.0f && g_bombPlanted && m_team == TERRORIST)
{
RadioMessage (Radio_Affirmative);
@ -2516,7 +2516,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_StormTheFront:
if (((IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f) && Random.Long (0, 100) > 50)
if (((engine.IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f) && Random.Long (0, 100) > 50)
{
RadioMessage (Radio_Affirmative);
@ -2547,7 +2547,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_Fallback:
if ((IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f)
if ((engine.IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f)
{
m_fearLevel += 0.5f;
@ -2612,7 +2612,7 @@ void Bot::CheckRadioCommands (void)
int bombPoint = -1;
// check if it's a ct command
if (GetTeam (m_radioEntity) == CT && m_team == CT && IsValidBot (m_radioEntity) && g_timeNextBombUpdate < engine.Time ())
if (engine.GetTeam (m_radioEntity) == CT && m_team == CT && IsValidBot (m_radioEntity) && g_timeNextBombUpdate < engine.Time ())
{
float minDistance = 99999.0f;
@ -2650,7 +2650,7 @@ void Bot::CheckRadioCommands (void)
break;
case Radio_GetInPosition:
if ((IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f)
if ((engine.IsNullEntity (m_enemy) && EntityIsVisible (m_radioEntity->v.origin)) || distance < 1024.0f)
{
RadioMessage (Radio_Affirmative);
@ -2745,11 +2745,11 @@ void Bot::SelectLeaderEachTeam (int team)
}
g_leaderChoosen[CT] = true;
}
else if ((team == TERRORIST) && !g_leaderChoosen[TERRORIST])
else if (team == TERRORIST && !g_leaderChoosen[TERRORIST])
{
Bot *botLeader = bots.GetHighestFragsBot(team);
if (botLeader != NULL && IsAlive (botLeader->GetEntity()))
if (botLeader != NULL && botLeader->m_notKilled)
{
botLeader->m_isLeader = true;
@ -2928,7 +2928,7 @@ void Bot::ThinkDelayed (void)
m_canChooseAimDirection = true;
m_notKilled = IsAlive (GetEntity ());
m_team = GetTeam (GetEntity ());
m_team = engine.GetTeam (GetEntity ());
if (m_team == TERRORIST && (g_mapType & MAP_DE))
m_hasC4 = !!(pev->weapons & (1 << WEAPON_C4));
@ -2947,10 +2947,10 @@ void Bot::ThinkDelayed (void)
m_lastVoteKick = m_voteKickIndex;
// if bot tk punishment is enabled slay the tk
if (yb_tkpunish.GetInt () != 2 || IsValidBot (EntityOfIndex (m_voteKickIndex)))
if (yb_tkpunish.GetInt () != 2 || IsValidBot (engine.EntityOfIndex (m_voteKickIndex)))
return;
edict_t *killer = EntityOfIndex (m_lastVoteKick);
edict_t *killer = engine.EntityOfIndex (m_lastVoteKick);
killer->v.frags++;
MDLL_ClientKill (killer);
@ -3006,7 +3006,7 @@ void Bot::ThinkDelayed (void)
CheckMessageQueue (); // check for pending messages
// remove voice icon
if (g_lastRadioTime[g_clients[IndexOfEntity (GetEntity ()) - 1].realTeam] + Random.Float (0.8f, 2.1f) < engine.Time ())
if (g_lastRadioTime[g_clients[engine.IndexOfEntity (GetEntity ()) - 1].realTeam] + Random.Float (0.8f, 2.1f) < engine.Time ())
SwitchChatterIcon (false); // hide icon
if (botMovement)
@ -3031,7 +3031,7 @@ void Bot::PeriodicThink (void)
CheckSpawnTimeConditions ();
// clear enemy far away
if (!m_lastEnemyOrigin.IsZero () && !IsNullEntity (m_lastEnemy) && (pev->origin - m_lastEnemyOrigin).GetLength () >= 1600.0f)
if (!m_lastEnemyOrigin.IsZero () && !engine.IsNullEntity (m_lastEnemy) && (pev->origin - m_lastEnemyOrigin).GetLength () >= 1600.0f)
{
m_lastEnemy = NULL;
m_lastEnemyOrigin.Zero ();
@ -3051,7 +3051,7 @@ void Bot::RunTask_Normal (void)
}
// bots rushing with knife, when have no enemy (thanks for idea to nicebot project)
if (m_currentWeapon == WEAPON_KNIFE && (IsNullEntity (m_lastEnemy) || !IsAlive (m_lastEnemy)) && IsNullEntity (m_enemy) && m_knifeAttackTime < engine.Time () && !HasShield () && GetNearbyFriendsNearPosition (pev->origin, 96) == 0)
if (m_currentWeapon == WEAPON_KNIFE && (engine.IsNullEntity (m_lastEnemy) || !IsAlive (m_lastEnemy)) && engine.IsNullEntity (m_enemy) && m_knifeAttackTime < engine.Time () && !HasShield () && GetNearbyFriendsNearPosition (pev->origin, 96) == 0)
{
if (Random.Long (0, 100) < 40)
pev->button |= IN_ATTACK;
@ -3081,7 +3081,7 @@ void Bot::RunTask_Normal (void)
m_prevGoalIndex = -1;
// spray logo sometimes if allowed to do so
if (m_timeLogoSpray < engine.Time () && yb_spraypaints.GetBool () && Random.Long (1, 100) < 60 && m_moveSpeed > GetWalkSpeed () && IsNullEntity (m_pickupItem))
if (m_timeLogoSpray < engine.Time () && yb_spraypaints.GetBool () && Random.Long (1, 100) < 60 && m_moveSpeed > GetWalkSpeed () && engine.IsNullEntity (m_pickupItem))
{
if (!((g_mapType & MAP_DE) && g_bombPlanted && m_team == CT))
PushTask (TASK_SPRAY, TASKPRI_SPRAYLOGO, -1, engine.Time () + 1.0f, false);
@ -3305,7 +3305,7 @@ void Bot::RunTask_HuntEnemy (void)
m_checkTerrain = true;
// if we've got new enemy...
if (!IsNullEntity (m_enemy) || IsNullEntity (m_lastEnemy))
if (!engine.IsNullEntity (m_enemy) || engine.IsNullEntity (m_lastEnemy))
{
// forget about it...
TaskComplete ();
@ -3314,7 +3314,7 @@ void Bot::RunTask_HuntEnemy (void)
m_lastEnemy = NULL;
m_lastEnemyOrigin.Zero ();
}
else if (GetTeam (m_lastEnemy) == m_team)
else if (engine.GetTeam (m_lastEnemy) == m_team)
{
// don't hunt down our teammate...
RemoveCertainTask (TASK_HUNTENEMY);
@ -3371,7 +3371,7 @@ void Bot::RunTask_SeekCover (void)
{
m_aimFlags |= AIM_NAVPOINT;
if (IsNullEntity (m_lastEnemy) || !IsAlive (m_lastEnemy))
if (engine.IsNullEntity (m_lastEnemy) || !IsAlive (m_lastEnemy))
{
TaskComplete ();
m_prevGoalIndex = -1;
@ -3459,7 +3459,7 @@ void Bot::RunTask_Attack (void)
m_moveToGoal = false;
m_checkTerrain = false;
if (!IsNullEntity (m_enemy))
if (!engine.IsNullEntity (m_enemy))
{
IgnoreCollisionShortly ();
@ -3683,7 +3683,7 @@ void Bot::RunTask_Hide (void)
m_campButtons = 0;
m_prevGoalIndex = -1;
if (!IsNullEntity (m_enemy))
if (!engine.IsNullEntity (m_enemy))
CombatFight ();
return;
@ -3967,7 +3967,7 @@ void Bot::RunTask_DefuseBomb (void)
void Bot::RunTask_FollowUser (void)
{
if (IsNullEntity (m_targetEntity) || !IsAlive (m_targetEntity))
if (engine.IsNullEntity (m_targetEntity) || !IsAlive (m_targetEntity))
{
m_targetEntity = NULL;
TaskComplete ();
@ -3982,7 +3982,7 @@ void Bot::RunTask_FollowUser (void)
TraceResult tr;
engine.TestLine (m_targetEntity->v.origin + m_targetEntity->v.view_ofs, g_pGlobals->v_forward * 500.0f, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
if (!IsNullEntity (tr.pHit) && IsValidPlayer (tr.pHit) && GetTeam (tr.pHit) != m_team)
if (!engine.IsNullEntity (tr.pHit) && IsValidPlayer (tr.pHit) && engine.GetTeam (tr.pHit) != m_team)
{
m_targetEntity = NULL;
m_lastEnemy = tr.pHit;
@ -4077,7 +4077,7 @@ void Bot::RunTask_Throw_HE (void)
m_moveSpeed = 0.0f;
m_moveToGoal = false;
}
else if (!(m_states & STATE_SUSPECT_ENEMY) && !IsNullEntity (m_enemy))
else if (!(m_states & STATE_SUSPECT_ENEMY) && !engine.IsNullEntity (m_enemy))
dest = m_enemy->v.origin + m_enemy->v.velocity.Get2D () * 0.5f;
m_isUsingGrenade = true;
@ -4112,7 +4112,7 @@ void Bot::RunTask_Throw_HE (void)
{
edict_t *ent = NULL;
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
{
if (ent->v.owner == GetEntity () && strcmp (STRING (ent->v.model) + 9, "hegrenade.mdl") == 0)
{
@ -4129,7 +4129,7 @@ void Bot::RunTask_Throw_HE (void)
}
}
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
{
if (m_currentWeapon != WEAPON_EXPLOSIVE)
{
@ -4153,7 +4153,7 @@ void Bot::RunTask_Throw_FL (void)
m_strafeSpeed = 0.0f;
m_moveSpeed = 0.0f;
}
else if (!(m_states & STATE_SUSPECT_ENEMY) && !IsNullEntity (m_enemy))
else if (!(m_states & STATE_SUSPECT_ENEMY) && !engine.IsNullEntity (m_enemy))
dest = m_enemy->v.origin + m_enemy->v.velocity.Get2D () * 0.5;
m_isUsingGrenade = true;
@ -4177,7 +4177,7 @@ void Bot::RunTask_Throw_FL (void)
else
{
edict_t *ent = NULL;
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
{
if (ent->v.owner == GetEntity () && strcmp (STRING (ent->v.model) + 9, "flashbang.mdl") == 0)
{
@ -4193,7 +4193,7 @@ void Bot::RunTask_Throw_FL (void)
}
}
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
{
if (m_currentWeapon != WEAPON_FLASHBANG)
{
@ -4225,7 +4225,7 @@ void Bot::RunTask_Throw_SG (void)
Vector src = m_lastEnemyOrigin - pev->velocity;
// predict where the enemy is in 0.5 secs
if (!IsNullEntity (m_enemy))
if (!engine.IsNullEntity (m_enemy))
src = src + m_enemy->v.velocity * 0.5f;
m_grenade = (src - EyePosition ()).Normalize ();
@ -4385,7 +4385,7 @@ void Bot::RunTask_ShootBreakable (void)
m_aimFlags |= AIM_OVERRIDE;
// Breakable destroyed?
if (IsNullEntity (FindBreakable ()))
if (engine.IsNullEntity (FindBreakable ()))
{
TaskComplete ();
return;
@ -4419,7 +4419,7 @@ void Bot::RunTask_ShootBreakable (void)
void Bot::RunTask_PickupItem ()
{
if (IsNullEntity (m_pickupItem))
if (engine.IsNullEntity (m_pickupItem))
{
m_pickupItem = NULL;
TaskComplete ();
@ -4559,7 +4559,7 @@ void Bot::RunTask_PickupItem ()
for (int i = 0; i < MAX_HOSTAGES; i++)
{
if (IsNullEntity (m_hostages[i])) // store pointer to hostage so other bots don't steal from this one or bot tries to reuse it
if (engine.IsNullEntity (m_hostages[i])) // store pointer to hostage so other bots don't steal from this one or bot tries to reuse it
{
m_hostages[i] = m_pickupItem;
m_pickupItem = NULL;
@ -4585,7 +4585,7 @@ void Bot::RunTask_PickupItem ()
case PICKUP_BUTTON:
m_aimFlags |= AIM_ENTITY;
if (IsNullEntity (m_pickupItem) || m_buttonPushTime < engine.Time ()) // it's safer...
if (engine.IsNullEntity (m_pickupItem) || m_buttonPushTime < engine.Time ()) // it's safer...
{
TaskComplete ();
m_pickupType = PICKUP_NONE;
@ -4750,7 +4750,7 @@ void Bot::CheckSpawnTimeConditions (void)
}
m_checkKnifeSwitch = false;
if (Random.Long (0, 100) < yb_user_follow_percent.GetInt () && IsNullEntity (m_targetEntity) && !m_isLeader && !m_hasC4)
if (Random.Long (0, 100) < yb_user_follow_percent.GetInt () && engine.IsNullEntity (m_targetEntity) && !m_isLeader && !m_hasC4)
AttachToUser ();
}
@ -4825,7 +4825,7 @@ void Bot::BotAI (void)
// some stuff required by by chatter engine
if (yb_communication_type.GetInt () == 2)
{
if ((m_states & STATE_SEEING_ENEMY) && !IsNullEntity (m_enemy))
if ((m_states & STATE_SEEING_ENEMY) && !engine.IsNullEntity (m_enemy))
{
int hasFriendNearby = GetNearbyFriendsNearPosition (pev->origin, 512.0f);
@ -4835,7 +4835,7 @@ void Bot::BotAI (void)
else if (!hasFriendNearby && Random.Long (0, 100) < 45 && m_team == TERRORIST && IsPlayerVIP (m_enemy))
ChatterMessage (Chatter_VIPSpotted);
else if (!hasFriendNearby && Random.Long (0, 100) < 50 && GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384.0f))
else if (!hasFriendNearby && Random.Long (0, 100) < 50 && engine.GetTeam (m_enemy) != m_team && IsGroupOfEnemies (m_enemy->v.origin, 2, 384.0f))
ChatterMessage (Chatter_ScaredEmotion);
else if (!hasFriendNearby && Random.Long (0, 100) < 40 && ((m_enemy->v.weapons & (1 << WEAPON_AWP)) || (m_enemy->v.weapons & (1 << WEAPON_SCOUT)) || (m_enemy->v.weapons & (1 << WEAPON_G3SG1)) || (m_enemy->v.weapons & (1 << WEAPON_SG550))))
@ -4847,7 +4847,7 @@ void Bot::BotAI (void)
}
// if bomb planted warn teammates !
if (g_canSayBombPlanted && g_bombPlanted && GetTeam (GetEntity ()) == CT)
if (g_canSayBombPlanted && g_bombPlanted && engine.GetTeam (GetEntity ()) == CT)
{
g_canSayBombPlanted = false;
ChatterMessage (Chatter_GottaFindTheBomb);
@ -4928,12 +4928,12 @@ void Bot::BotAI (void)
}
// time to reach waypoint
if (m_navTimeset + GetEstimatedReachTime () < engine.Time () && IsNullEntity (m_enemy))
if (m_navTimeset + GetEstimatedReachTime () < engine.Time () && engine.IsNullEntity (m_enemy))
{
GetValidWaypoint ();
// clear these pointers, bot mingh be stuck getting to them
if (!IsNullEntity (m_pickupItem) && !m_hasProgressBar)
if (!engine.IsNullEntity (m_pickupItem) && !m_hasProgressBar)
m_itemIgnore = m_pickupItem;
m_pickupItem = NULL;
@ -4971,7 +4971,7 @@ void Bot::BotAI (void)
}
// display some debugging thingy to host entity
if (!IsNullEntity (g_hostEntity) && yb_debug.GetInt () >= 1)
if (!engine.IsNullEntity (g_hostEntity) && yb_debug.GetInt () >= 1)
DisplayDebugOverlay ();
// save the previous speed (for checking if stuck)
@ -4983,7 +4983,7 @@ void Bot::DisplayDebugOverlay (void)
{
bool displayDebugOverlay = false;
if (g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
if (g_hostEntity->v.iuser2 == engine.IndexOfEntity (GetEntity ()))
displayDebugOverlay = true;
if (!displayDebugOverlay && yb_debug.GetInt () >= 2)
@ -5099,9 +5099,9 @@ void Bot::DisplayDebugOverlay (void)
char enemyName[80], weaponName[80], aimFlags[64], botType[32];
if (!IsNullEntity (m_enemy))
if (!engine.IsNullEntity (m_enemy))
strncpy (enemyName, STRING (m_enemy->v.netname), SIZEOF_CHAR (enemyName));
else if (!IsNullEntity (m_lastEnemy))
else if (!engine.IsNullEntity (m_lastEnemy))
{
strcpy (enemyName, " (L)");
strncat (enemyName, STRING (m_lastEnemy->v.netname), SIZEOF_CHAR (enemyName));
@ -5112,7 +5112,7 @@ void Bot::DisplayDebugOverlay (void)
char pickupName[80];
memset (pickupName, 0, sizeof (pickupName));
if (!IsNullEntity (m_pickupItem))
if (!engine.IsNullEntity (m_pickupItem))
strncpy (pickupName, STRING (m_pickupItem->v.classname), SIZEOF_CHAR (pickupName));
else
strcpy (pickupName, " (null)");
@ -5233,7 +5233,7 @@ bool Bot::HasHostage (void)
{
for (int i = 0; i < MAX_HOSTAGES; i++)
{
if (!IsNullEntity (m_hostages[i]))
if (!engine.IsNullEntity (m_hostages[i]))
{
// don't care about dead hostages
if (m_hostages[i]->v.health <= 0.0f || (pev->origin - m_hostages[i]->v.origin).GetLength () > 600.0f)
@ -5265,7 +5265,7 @@ void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits)
if (IsValidPlayer (inflictor))
{
if (yb_tkpunish.GetBool () && GetTeam (inflictor) == m_team && !IsValidBot (inflictor))
if (yb_tkpunish.GetBool () && engine.GetTeam (inflictor) == m_team && !IsValidBot (inflictor))
{
// alright, die you teamkiller!!!
m_actualReactionTime = 0.0f;
@ -5299,7 +5299,7 @@ void Bot::TakeDamage (edict_t *inflictor, int damage, int armor, int bits)
}
RemoveCertainTask (TASK_CAMP);
if (IsNullEntity (m_enemy) && m_team != GetTeam (inflictor))
if (engine.IsNullEntity (m_enemy) && m_team != engine.GetTeam (inflictor))
{
m_lastEnemy = inflictor;
m_lastEnemyOrigin = inflictor->v.origin;
@ -5415,7 +5415,7 @@ void Bot::CollectExperienceData (edict_t *attacker, int damage)
if (!IsValidPlayer (attacker))
return;
int attackerTeam = GetTeam (attacker);
int attackerTeam = engine.GetTeam (attacker);
int victimTeam = m_team;
if (attackerTeam == victimTeam )
@ -5590,7 +5590,7 @@ void Bot::DebugMsg (const char *format, ...)
bool playMessage = false;
if (level == 3 && !IsNullEntity (g_hostEntity) && g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
if (level == 3 && !engine.IsNullEntity (g_hostEntity) && g_hostEntity->v.iuser2 == engine.IndexOfEntity (GetEntity ()))
playMessage = true;
else if (level != 3)
playMessage = true;
@ -5883,7 +5883,7 @@ bool Bot::OutOfBombTimer (void)
Bot *bot = NULL; // temporaly pointer to bot
// search players with defuse kit
if ((bot = bots.GetBot (i)) != NULL && GetTeam (bot->GetEntity ()) == CT && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500.0f)
if ((bot = bots.GetBot (i)) != NULL && bot->m_team == CT && bot->m_hasDefuser && (bombOrigin - bot->pev->origin).GetLength () < 500.0f)
{
hasTeammatesWithDefuserKit = true;
break;
@ -5951,7 +5951,7 @@ void Bot::ReactOnSound (void)
m_heardSoundTime = engine.Time ();
m_states |= STATE_HEARING_ENEMY;
if ((Random.Long (0, 100) < 15) && IsNullEntity (m_enemy) && IsNullEntity (m_lastEnemy) && m_seeEnemyTime + 7.0f < engine.Time ())
if ((Random.Long (0, 100) < 15) && engine.IsNullEntity (m_enemy) && engine.IsNullEntity (m_lastEnemy) && m_seeEnemyTime + 7.0f < engine.Time ())
ChatterMessage (Chatter_HeardEnemy);
// didn't bot already have an enemy ? take this one...
@ -6045,7 +6045,7 @@ bool Bot::IsBombDefusing (const Vector &bombOrigin)
if (bot == NULL || bot == this)
continue; // skip invalid bots
if (m_team != GetTeam (bot->GetEntity ()) || bot->GetTaskId () == TASK_ESCAPEFROMBOMB)
if (m_team != bot->m_team || bot->GetTaskId () == TASK_ESCAPEFROMBOMB)
continue; // skip other mess
if ((bot->pev->origin - bombOrigin).GetLength () < 140.0f && (bot->GetTaskId () == TASK_DEFUSEBOMB || bot->m_hasProgressBar))

View file

@ -156,7 +156,7 @@ void Bot::PrepareChatMessage (char *text)
if (!yb_chat.GetBool () || IsNullString (text))
return;
#define ASSIGN_TALK_ENTITY() if (!IsNullEntity (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
#define ASSIGN_TALK_ENTITY() if (!engine.IsNullEntity (talkEntity)) strncat (m_tempStrings, HumanizeName (const_cast <char *> (STRING (talkEntity->v.netname))), SIZEOF_CHAR (m_tempStrings))
memset (&m_tempStrings, 0, sizeof (m_tempStrings));
@ -214,7 +214,7 @@ void Bot::PrepareChatMessage (char *text)
// chat reply?
else if (*pattern == 's')
{
talkEntity = EntityOfIndex (m_sayTextBuffer.entityIndex);
talkEntity = engine.EntityOfIndex (m_sayTextBuffer.entityIndex);
ASSIGN_TALK_ENTITY ();
}
// teammate alive?
@ -232,7 +232,7 @@ void Bot::PrepareChatMessage (char *text)
if (i < engine.MaxClients ())
{
if (!IsNullEntity (pev->dmg_inflictor) && m_team == GetTeam (pev->dmg_inflictor))
if (!engine.IsNullEntity (pev->dmg_inflictor) && m_team == engine.GetTeam (pev->dmg_inflictor))
talkEntity = pev->dmg_inflictor;
else
talkEntity = g_clients[i].ent;

View file

@ -48,7 +48,7 @@ int Bot::GetNearbyEnemiesNearPosition(const Vector &origin, float radius)
bool Bot::IsEnemyHiddenByRendering (edict_t *enemy)
{
if (IsNullEntity (enemy) || !yb_check_enemy_rendering.GetBool ())
if (engine.IsNullEntity (enemy) || !yb_check_enemy_rendering.GetBool ())
return false;
entvars_t &v = enemy->v;
@ -183,12 +183,12 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
bool Bot::IsEnemyViewable (edict_t *player)
{
if (IsNullEntity (player))
if (engine.IsNullEntity (player))
return false;
bool forceTrueIfVisible = false;
if (IsValidPlayer (pev->dmg_inflictor) && GetTeam (pev->dmg_inflictor) != m_team)
if (IsValidPlayer (pev->dmg_inflictor) && engine.GetTeam (pev->dmg_inflictor) != m_team)
forceTrueIfVisible = true;
if ((IsInViewCone (player->v.origin + pev->view_ofs) || forceTrueIfVisible) && CheckVisibility (player, &m_enemyOrigin, &m_visibility))
@ -218,7 +218,7 @@ bool Bot::LookupEnemy (void)
if (m_seeEnemyTime + 3.0f < engine.Time ())
m_states &= ~STATE_SUSPECT_ENEMY;
if (!IsNullEntity (m_enemy) && m_enemyUpdateTime > engine.Time ())
if (!engine.IsNullEntity (m_enemy) && m_enemyUpdateTime > engine.Time ())
{
player = m_enemy;
@ -228,7 +228,7 @@ bool Bot::LookupEnemy (void)
}
// the old enemy is no longer visible or
if (IsNullEntity (newEnemy))
if (engine.IsNullEntity (newEnemy))
{
m_enemyUpdateTime = engine.Time () + 0.5f;
@ -289,7 +289,7 @@ bool Bot::LookupEnemy (void)
}
}
if (IsNullEntity (newEnemy) && !IsNullEntity (shieldEnemy))
if (engine.IsNullEntity (newEnemy) && !engine.IsNullEntity (shieldEnemy))
newEnemy = shieldEnemy;
}
@ -314,7 +314,7 @@ bool Bot::LookupEnemy (void)
}
else
{
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !IsNullEntity (m_targetEntity)))
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !engine.IsNullEntity (m_targetEntity)))
RadioMessage (Radio_EnemySpotted);
m_targetEntity = NULL; // stop following when we see an enemy...
@ -345,7 +345,7 @@ bool Bot::LookupEnemy (void)
Bot *friendBot = bots.GetBot (g_clients[j].ent);
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < engine.Time () && IsNullEntity (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && friendBot->IsInViewCone (pev->origin))
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < engine.Time () && engine.IsNullEntity (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && friendBot->IsInViewCone (pev->origin))
{
friendBot->m_lastEnemy = newEnemy;
friendBot->m_lastEnemyOrigin = m_lastEnemyOrigin;
@ -357,7 +357,7 @@ bool Bot::LookupEnemy (void)
return true;
}
}
else if (!IsNullEntity (m_enemy))
else if (!engine.IsNullEntity (m_enemy))
{
newEnemy = m_enemy;
m_lastEnemy = newEnemy;
@ -406,7 +406,7 @@ bool Bot::LookupEnemy (void)
}
// check if bots should reload...
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < engine.Time () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsNullEntity (m_lastEnemy) && IsNullEntity (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < engine.Time () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && engine.IsNullEntity (m_lastEnemy) && engine.IsNullEntity (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
{
if (!m_reloadState)
m_reloadState = RELOAD_PRIMARY;
@ -560,9 +560,9 @@ bool Bot::IsFriendInLineOfFire (float distance)
engine.TestLine (EyePosition (), EyePosition () + 10000.0f * pev->v_angle, TRACE_IGNORE_NONE, GetEntity (), &tr);
// check if we hit something
if (!IsNullEntity (tr.pHit) && tr.pHit != g_worldEntity)
if (!engine.IsNullEntity (tr.pHit))
{
int playerIndex = IndexOfEntity (tr.pHit) - 1;
int playerIndex = engine.IndexOfEntity (tr.pHit) - 1;
// check valid range
if (playerIndex >= 0 && playerIndex < engine.MaxClients () && g_clients[playerIndex].team == m_team && (g_clients[playerIndex].flags & CF_ALIVE))
@ -731,7 +731,7 @@ void Bot::FireWeapon (void)
}
// or if friend in line of fire, stop this too but do not update shoot time
if (!IsNullEntity (m_enemy))
if (!engine.IsNullEntity (m_enemy))
{
if (IsFriendInLineOfFire (distance))
{
@ -753,7 +753,7 @@ void Bot::FireWeapon (void)
goto WeaponSelectEnd;
// use knife if near and good difficulty (l33t dude!)
if (m_difficulty >= 3 && pev->health > 80.0f && !IsNullEntity (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
if (m_difficulty >= 3 && pev->health > 80.0f && !engine.IsNullEntity (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
goto WeaponSelectEnd;
// loop through all the weapons until terminator is found...
@ -844,7 +844,7 @@ WeaponSelectEnd:
{
if (distance >= 750.0f && !IsShieldDrawn ())
pev->button |= IN_ATTACK2; // draw the shield
else if (IsShieldDrawn () || (!IsNullEntity (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
else if (IsShieldDrawn () || (!engine.IsNullEntity (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
pev->button |= IN_ATTACK2; // draw out the shield
m_shieldCheckTime = engine.Time () + 1.0f;
@ -863,7 +863,7 @@ WeaponSelectEnd:
m_zoomCheckTime = engine.Time ();
if (!IsNullEntity (m_enemy) && (m_states & STATE_SEEING_ENEMY))
if (!engine.IsNullEntity (m_enemy) && (m_states & STATE_SEEING_ENEMY))
{
m_moveSpeed = 0.0f;
m_strafeSpeed = 0.0f;
@ -1011,7 +1011,7 @@ void Bot::FocusEnemy (void)
void Bot::CombatFight (void)
{
// no enemy? no need to do strafing
if (IsNullEntity (m_enemy))
if (engine.IsNullEntity (m_enemy))
return;
float distance = (m_lookAt - EyePosition ()).GetLength2D (); // how far away is the enemy scum?
@ -1223,7 +1223,7 @@ bool Bot::IsEnemyProtectedByShield (edict_t *enemy)
{
// this function returns true, if enemy protected by the shield
if (IsNullEntity (enemy) || IsShieldDrawn ())
if (engine.IsNullEntity (enemy) || IsShieldDrawn ())
return false;
// check if enemy has shield and this shield is drawn

View file

@ -9,7 +9,7 @@
#include <core.h>
void Engine::Precache (void)
void Engine::Precache (edict_t *startEntity)
{
// this function precaches needed models and initialize class variables
@ -19,6 +19,9 @@ void Engine::Precache (void)
m_isBotCommand = false;
m_argumentCount = 0;
m_arguments[0] = { 0, };
m_localEntity = NULL;
m_startEntity = startEntity;
}
void Engine::Printf (const char *fmt, ...)
@ -89,7 +92,7 @@ void Engine::ClientPrintf (edict_t *ent, const char *fmt, ...)
vsnprintf (string, SIZEOF_CHAR (string), locale.TranslateInput (fmt), ap);
va_end (ap);
if (IsNullEntity (ent) || ent == g_hostEntity)
if (engine.IsNullEntity (ent) || ent == g_hostEntity)
{
engine.Printf (string);
return;
@ -267,7 +270,7 @@ Vector Engine::GetAbsOrigin (edict_t *ent)
// this expanded function returns the vector origin of a bounded entity, assuming that any
// entity that has a bounding box has its center at the center of the bounding box itself.
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return Vector::GetZero ();
if (ent->v.origin.IsZero ())
@ -299,7 +302,7 @@ void Engine::IssueBotCommand (edict_t *ent, const char *fmt, ...)
// supply directly the whole string as if you were typing it in the bot's "console". It
// is supposed to work exactly like the pfnClientCommand (server-sided client command).
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return;
va_list ap;

View file

@ -9,13 +9,6 @@
#include <core.h>
// forward for super-globals
NetworkMsg netmsg;
Localizer locale;
Waypoint waypoints;
BotManager bots;
Engine engine;
bool g_canSayBombPlanted = true;
bool g_isMetamod = false;
bool g_radioInsteadVoice = false;
@ -75,7 +68,6 @@ enginefuncs_t g_engfuncs;
Client g_clients[32];
WeaponProperty g_weaponDefs[MAX_WEAPONS + 1];
edict_t *g_worldEntity = NULL;
edict_t *g_hostEntity = NULL;
globalvars_t *g_pGlobals = NULL;
Experience *g_experienceData = NULL;
@ -432,3 +424,10 @@ MenuText g_menus[21] =
"0. Exit"
}
};
// forward for super-globals
NetworkMsg netmsg;
Localizer locale;
Waypoint waypoints;
BotManager bots;
Engine engine;

View file

@ -205,7 +205,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// waypoint manimupulation (really obsolete, can be edited through menu) (supported only on listen server)
else if (stricmp (arg0, "waypoint") == 0 || stricmp (arg0, "wp") == 0 || stricmp (arg0, "wpt") == 0)
{
if (engine.IsDedicatedServer () || IsNullEntity (g_hostEntity))
if (engine.IsDedicatedServer () || engine.IsNullEntity (g_hostEntity))
return 2;
// enables or disable waypoint displaying
@ -250,11 +250,11 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
if (stricmp (arg2, "on") == 0)
{
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_start")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_start")))
spawnEntity->v.effects &= ~EF_NODRAW;
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_deathmatch")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_deathmatch")))
spawnEntity->v.effects &= ~EF_NODRAW;
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_vip_start")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_vip_start")))
spawnEntity->v.effects &= ~EF_NODRAW;
engine.IssueCmd ("mp_roundtime 9"); // reset round time to maximum
@ -263,11 +263,11 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
}
else if (stricmp (arg2, "off") == 0)
{
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_start")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_start")))
spawnEntity->v.effects |= EF_NODRAW;
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_deathmatch")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_player_deathmatch")))
spawnEntity->v.effects |= EF_NODRAW;
while (!IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_vip_start")))
while (!engine.IsNullEntity (spawnEntity = FIND_ENTITY_BY_CLASSNAME (spawnEntity, "info_vip_start")))
spawnEntity->v.effects |= EF_NODRAW;
}
}
@ -373,7 +373,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// path waypoint editing system (supported only on listen server)
else if (stricmp (arg0, "pathwaypoint") == 0 || stricmp (arg0, "path") == 0 || stricmp (arg0, "pwp") == 0)
{
if (engine.IsDedicatedServer () || IsNullEntity (g_hostEntity))
if (engine.IsDedicatedServer () || engine.IsNullEntity (g_hostEntity))
return 2;
// opens path creation menu
@ -404,7 +404,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// automatic waypoint handling (supported only on listen server)
else if (stricmp (arg0, "autowaypoint") == 0 || stricmp (arg0, "autowp") == 0)
{
if (engine.IsDedicatedServer () || IsNullEntity (g_hostEntity))
if (engine.IsDedicatedServer () || engine.IsNullEntity (g_hostEntity))
return 2;
// enable autowaypointing
@ -425,7 +425,7 @@ int BotCommandHandler (edict_t *ent, const char *arg0, const char *arg1, const c
// experience system handling (supported only on listen server)
else if (stricmp (arg0, "experience") == 0 || stricmp (arg0, "exp") == 0)
{
if (engine.IsDedicatedServer () || IsNullEntity (g_hostEntity))
if (engine.IsDedicatedServer () || engine.IsNullEntity (g_hostEntity))
return 2;
// write experience table (and visibility table) to hard disk
@ -977,7 +977,7 @@ void Touch (edict_t *pentTouched, edict_t *pentOther)
// the two entities both have velocities, for example two players colliding, this function
// is called twice, once for each entity moving.
if (!IsNullEntity (pentOther) && (pentOther->v.flags & FL_FAKECLIENT))
if (!engine.IsNullEntity (pentOther) && (pentOther->v.flags & FL_FAKECLIENT))
{
Bot *bot = bots.GetBot (pentOther);
@ -1002,8 +1002,7 @@ int Spawn (edict_t *ent)
if (strcmp (entityClassname, "worldspawn") == 0)
{
engine.Precache ();
g_worldEntity = ent; // save the world entity for future use
engine.Precache (ent);
ConVarWrapper::GetReference ().PushRegisteredConVarsToEngine (true);
@ -1153,7 +1152,7 @@ void ClientDisconnect (edict_t *ent)
bots.AdjustQuota (false, ent);
int i = IndexOfEntity (ent) - 1;
int i = engine.IndexOfEntity (ent) - 1;
InternalAssert (i >= 0 && i < 32);
@ -1191,7 +1190,7 @@ void ClientUserInfoChanged (edict_t *ent, char *infobuffer)
if (!IsNullString (passwordField) || !IsNullString (password))
{
int clientIndex = IndexOfEntity (ent) - 1;
int clientIndex = engine.IndexOfEntity (ent) - 1;
if (strcmp (password, INFOKEY_VALUE (infobuffer, const_cast <char *> (passwordField))) == 0)
g_clients[clientIndex].flags |= CF_ADMIN;
@ -1227,7 +1226,7 @@ void ClientCommand (edict_t *ent)
static int fillServerTeam = 5;
static bool fillCommand = false;
if (!engine.IsBotCommand () && (ent == g_hostEntity || (g_clients[IndexOfEntity (ent) - 1].flags & CF_ADMIN)))
if (!engine.IsBotCommand () && (ent == g_hostEntity || (g_clients[engine.IndexOfEntity (ent) - 1].flags & CF_ADMIN)))
{
if (stricmp (command, "yapb") == 0 || stricmp (command, "yb") == 0)
{
@ -1248,9 +1247,9 @@ void ClientCommand (edict_t *ent)
return;
}
else if (stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[IndexOfEntity (ent) - 1].menu != NULL)
else if (stricmp (command, "menuselect") == 0 && !IsNullString (arg1) && g_clients[engine.IndexOfEntity (ent) - 1].menu != NULL)
{
Client *client = &g_clients[IndexOfEntity (ent) - 1];
Client *client = &g_clients[engine.IndexOfEntity (ent) - 1];
int selection = atoi (arg1);
if (client->menu == &g_menus[12])
@ -2023,7 +2022,7 @@ void ClientCommand (edict_t *ent)
int team = -1;
if (FStrEq (command, "say_team"))
team = GetTeam (ent);
team = engine.GetTeam (ent);
for (int i = 0; i < engine.MaxClients (); i++)
{
@ -2034,7 +2033,7 @@ void ClientCommand (edict_t *ent)
if (target != NULL)
{
target->m_sayTextBuffer.entityIndex = IndexOfEntity (ent);
target->m_sayTextBuffer.entityIndex = engine.IndexOfEntity (ent);
if (IsNullString (CMD_ARGS ()))
continue;
@ -2044,7 +2043,7 @@ void ClientCommand (edict_t *ent)
}
}
}
int clientIndex = IndexOfEntity (ent) - 1;
int clientIndex = engine.IndexOfEntity (ent) - 1;
// check if this player alive, and issue something
if ((g_clients[clientIndex].flags & CF_ALIVE) && g_radioSelect[clientIndex] != 0 && strncmp (command, "menuselect", 10) == 0)
@ -2062,7 +2061,7 @@ void ClientCommand (edict_t *ent)
Bot *bot = bots.GetBot (i);
// validate bot
if (bot != NULL && GetTeam (bot->GetEntity ()) == g_clients[clientIndex].team && VARS (ent) != bot->pev && bot->m_radioOrder == 0)
if (bot != NULL && bot->m_team == g_clients[clientIndex].team && VARS (ent) != bot->pev && bot->m_radioOrder == 0)
{
bot->m_radioOrder = radioCommand;
bot->m_radioEntity = ent;
@ -2162,9 +2161,9 @@ void StartFrame (void)
// record some stats of all players on the server
for (int i = 0; i < engine.MaxClients (); i++)
{
edict_t *player = EntityOfIndex (i + 1);
edict_t *player = engine.EntityOfIndex (i + 1);
if (!IsNullEntity (player) && (player->v.flags & FL_CLIENT))
if (!engine.IsNullEntity (player) && (player->v.flags & FL_CLIENT))
{
g_clients[i].ent = player;
g_clients[i].flags |= CF_USED;
@ -2191,7 +2190,7 @@ void StartFrame (void)
}
}
if (!engine.IsDedicatedServer () && !IsNullEntity (g_hostEntity))
if (!engine.IsDedicatedServer () && !engine.IsNullEntity (g_hostEntity))
{
if (g_waypointOn)
waypoints.Think ();
@ -2204,10 +2203,10 @@ void StartFrame (void)
{
for (int i = 0; i < engine.MaxClients (); i++)
{
edict_t *player = EntityOfIndex (i + 1);
edict_t *player = engine.EntityOfIndex (i + 1);
// code below is executed only on dedicated server
if (engine.IsDedicatedServer () && !IsNullEntity (player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT))
if (engine.IsDedicatedServer () && !engine.IsNullEntity (player) && (player->v.flags & FL_CLIENT) && !(player->v.flags & FL_FAKECLIENT))
{
if (g_clients[i].flags & CF_ADMIN)
{
@ -2435,7 +2434,7 @@ void pfnMessageBegin (int msgDest, int msgType, const float *origin, edict_t *ed
netmsg.HandleMessageIfRequired (msgType, NETMSG_WEAPONLIST);
if (!IsNullEntity (ed))
if (!engine.IsNullEntity (ed))
{
int index = bots.GetIndex (ed);
@ -2777,7 +2776,7 @@ void pfnAlertMessage (ALERT_TYPE alertType, char *format, ...)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && GetTeam (bot->GetEntity ()) == TERRORIST && IsAlive (bot->GetEntity ()))
if (bot != NULL && bot->m_team == TERRORIST && bot->m_notKilled)
{
bot->ResetTasks ();
bot->MoveToVector (waypoints.GetBombPosition ());
@ -2961,15 +2960,6 @@ export int Meta_Detach (PLUG_LOADTIME now, PL_UNLOAD_REASON reason)
// this function is called when metamod unloads the plugin. A basic check is made in order
// to prevent unloading the plugin if its processing should not be interrupted.
// is metamod allowed to unload the plugin?
if (now > Plugin_info.unloadable && reason != PNL_CMD_FORCED)
{
LOG_CONSOLE (PLID, "%s: plugin not detaching (can't unload plugin right now)", Plugin_info.name);
LOG_MMERROR (PLID, "%s: plugin not detaching (can't unload plugin right now)", Plugin_info.name);
return FALSE; // returning false prevents metamod from unloading this plugin
}
bots.RemoveAll (); // kick all bots off this server
FreeLibraryMemory ();

View file

@ -66,13 +66,13 @@ void BotManager::CreateKillerEntity (void)
void BotManager::DestroyKillerEntity (void)
{
if (!IsNullEntity (m_killerEntity))
if (!engine.IsNullEntity (m_killerEntity))
g_engfuncs.pfnRemoveEntity (m_killerEntity);
}
void BotManager::TouchWithKillerEntity (Bot *bot)
{
if (IsNullEntity (m_killerEntity))
if (engine.IsNullEntity (m_killerEntity))
{
MDLL_ClientKill (bot->GetEntity ());
return;
@ -194,12 +194,12 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
strcpy (outputName, prefixedName);
}
if (IsNullEntity ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName))))
if (engine.IsNullEntity ((bot = (*g_engfuncs.pfnCreateFakeClient) (outputName))))
{
engine.CenterPrintf ("Maximum players reached (%d/%d). Unable to create Bot.", engine.MaxClients (), engine.MaxClients ());
return 2;
}
int index = IndexOfEntity (bot) - 1;
int index = engine.IndexOfEntity (bot) - 1;
InternalAssert (index >= 0 && index <= 32); // check index
InternalAssert (m_bots[index] == NULL); // check bot slot
@ -217,10 +217,10 @@ int BotManager::CreateBot (const String &name, int difficulty, int personality,
int BotManager::GetIndex (edict_t *ent)
{
// this function returns index of bot (using own bot array)
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return -1;
int index = IndexOfEntity (ent) - 1;
int index = engine.IndexOfEntity (ent) - 1;
if (index < 0 || index >= 32)
return -1;
@ -536,7 +536,7 @@ void BotManager::RemoveFromTeam (Team team, bool removeAll)
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL && team == GetTeam (m_bots[i]->GetEntity ()))
if (m_bots[i] != NULL && team == engine.GetTeam (m_bots[i]->GetEntity ()))
{
m_bots[i]->Kick ();
@ -563,10 +563,10 @@ void BotManager::RemoveMenu (edict_t *ent, int selection)
for (int i = ((selection - 1) * 8); i < selection * 8; i++)
{
if ((m_bots[i] != NULL) && !IsNullEntity (m_bots[i]->GetEntity ()))
if ((m_bots[i] != NULL) && !engine.IsNullEntity (m_bots[i]->GetEntity ()))
{
validSlots |= 1 << (i - ((selection - 1) * 8));
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
sprintf (buffer, "%s %1.1d. %s%s\n", buffer, i - ((selection - 1) * 8) + 1, STRING (m_bots[i]->pev->netname), engine.GetTeam (m_bots[i]->GetEntity ()) == CT ? " \\y(CT)\\w" : " \\r(T)\\w");
}
else
sprintf (buffer, "%s\\d %1.1d. Not a Bot\\w\n", buffer, i - ((selection - 1) * 8) + 1);
@ -803,7 +803,7 @@ void BotManager::CheckTeamEconomics (int team, bool setTrue)
// start calculating
for (int i = 0; i < engine.MaxClients (); i++)
{
if (m_bots[i] != NULL && GetTeam (m_bots[i]->GetEntity ()) == team)
if (m_bots[i] != NULL && engine.GetTeam (m_bots[i]->GetEntity ()) == team)
{
if (m_bots[i]->m_moneyAmount <= g_botBuyEconomyTable[0])
numPoorPlayers++;
@ -847,7 +847,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
// when bot setup completed, (this is a bot class constructor)
char rejectReason[128];
int clientIndex = IndexOfEntity (bot);
int clientIndex = engine.IndexOfEntity (bot);
memset (reinterpret_cast <void *> (this), 0, sizeof (*this));
@ -870,7 +870,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int member, c
SET_CLIENT_KEYVALUE (clientIndex, buffer, "*bot", "1");
rejectReason[0] = 0; // reset the reject reason template string
MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", IndexOfEntity (bot) + 100), rejectReason);
MDLL_ClientConnect (bot, "BOT", FormatBuffer ("127.0.0.%d", engine.IndexOfEntity (bot) + 100), rejectReason);
// should be set after client connect
if (yb_avatar_display.GetBool () && !steamId.IsEmpty ())
@ -1066,7 +1066,7 @@ void Bot::NewRound (void)
m_prevWptIndex[i] = -1;
m_navTimeset = engine.Time ();
m_team = GetTeam (GetEntity ());
m_team = engine.GetTeam (GetEntity ());
switch (m_personality)
{
@ -1347,7 +1347,7 @@ void BotManager::CalculatePingOffsets (void)
for (int i = 0; i < engine.MaxClients (); i++)
{
edict_t *ent = EntityOfIndex (i + 1);
edict_t *ent = engine.EntityOfIndex (i + 1);
if (!IsValidPlayer (ent))
continue;
@ -1399,7 +1399,7 @@ void BotManager::CalculatePingOffsets (void)
void BotManager::SendPingDataOffsets (edict_t *to)
{
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || IsNullEntity (to))
if ((g_gameFlags & GAME_LEGACY) || yb_latency_display.GetInt () != 2 || engine.IsNullEntity (to))
return;
if (!(to->v.flags & FL_CLIENT) && !(((to->v.button & IN_SCORE) || !(to->v.oldbuttons & IN_SCORE))))
@ -1477,7 +1477,7 @@ void BotManager::UpdateActiveGrenades (void)
m_activeGrenades.RemoveAll ();
// search the map for any type of grenade
while (!IsNullEntity (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade")))
while (!engine.IsNullEntity (grenade = FIND_ENTITY_BY_CLASSNAME (grenade, "grenade")))
{
// do not count c4 as a grenade
if (strcmp (STRING (grenade->v.model) + 9, "c4.mdl") == 0)

View file

@ -18,7 +18,7 @@ int Bot::FindGoal (void)
{
edict_t *pent = NULL;
while (!IsNullEntity (pent = FIND_ENTITY_BY_STRING (pent, "classname", "weaponbox")))
while (!engine.IsNullEntity (pent = FIND_ENTITY_BY_STRING (pent, "classname", "weaponbox")))
{
if (strcmp (STRING (pent->v.model), "models/w_backpack.mdl") == 0)
{
@ -734,7 +734,7 @@ bool Bot::DoWaypointNav (void)
engine.TestLine (m_currentPath->origin, m_currentPath->origin + Vector (0.0f, 0.0f, -50.0f), TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
// if trace result shows us that it is a lift
if (!IsNullEntity (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
if (!engine.IsNullEntity (tr.pHit) && m_navNode != NULL && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0) && !liftClosedDoorExists)
{
if ((m_liftState == LIFT_NO_NEARBY || m_liftState == LIFT_WAITING_FOR || m_liftState == LIFT_LOOKING_BUTTON_OUTSIDE) && tr.pHit->v.velocity.z == 0.0f)
{
@ -760,7 +760,7 @@ bool Bot::DoWaypointNav (void)
{
engine.TestLine (m_currentPath->origin, waypoints.GetPath (m_navNode->next->index)->origin, TRACE_IGNORE_EVERYTHING, GetEntity (), &tr);
if (!IsNullEntity (tr.pHit) && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0))
if (!engine.IsNullEntity (tr.pHit) && (strcmp (STRING (tr.pHit->v.classname), "func_door") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_plat") == 0 || strcmp (STRING (tr.pHit->v.classname), "func_train") == 0))
m_liftEntity = tr.pHit;
}
m_liftState = LIFT_LOOKING_BUTTON_OUTSIDE;
@ -795,7 +795,7 @@ bool Bot::DoWaypointNav (void)
if (bot == NULL || bot == this)
continue;
if (!IsAlive (bot->GetEntity ()) || GetTeam (bot->GetEntity ()) != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER)
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER)
continue;
if (bot->pev->groundentity == m_liftEntity && bot->IsOnFloor ())
@ -834,7 +834,7 @@ bool Bot::DoWaypointNav (void)
if (bot == NULL)
continue; // skip invalid bots
if (!IsAlive (bot->GetEntity ()) || GetTeam (bot->GetEntity ()) != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER || bot->m_liftEntity != m_liftEntity)
if (!bot->m_notKilled || bot->m_team != m_team || bot->m_targetEntity != GetEntity () || bot->GetTaskId () != TASK_FOLLOWUSER || bot->m_liftEntity != m_liftEntity)
continue;
if (bot->pev->groundentity == m_liftEntity || !bot->IsOnFloor ())
@ -875,7 +875,7 @@ bool Bot::DoWaypointNav (void)
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
// got a valid button entity ?
if (!IsNullEntity (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0f < engine.Time () && m_liftEntity->v.velocity.z == 0.0f && IsOnFloor ())
if (!engine.IsNullEntity (button) && pev->groundentity == m_liftEntity && m_buttonPushTime + 1.0f < engine.Time () && m_liftEntity->v.velocity.z == 0.0f && IsOnFloor ())
{
m_pickupItem = button;
m_pickupType = PICKUP_BUTTON;
@ -887,7 +887,7 @@ bool Bot::DoWaypointNav (void)
// is lift activated and bot is standing on it and lift is moving ?
if (m_liftState == LIFT_LOOKING_BUTTON_INSIDE || m_liftState == LIFT_ENTERING_IN || m_liftState == LIFT_WAIT_FOR_TEAMMATES || m_liftState == LIFT_WAITING_FOR)
{
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !IsNullEntity (m_targetEntity)))
if (pev->groundentity == m_liftEntity && m_liftEntity->v.velocity.z != 0.0f && IsOnFloor () && ((waypoints.GetPath (m_prevWptIndex[0])->flags & FLAG_LIFT) || !engine.IsNullEntity (m_targetEntity)))
{
m_liftState = LIFT_TRAVELING_BY;
m_liftUsageTime = engine.Time () + 14.0f;
@ -945,12 +945,12 @@ bool Bot::DoWaypointNav (void)
ResetCollideState ();
}
}
else if (!IsNullEntity(m_liftEntity))
else if (!engine.IsNullEntity(m_liftEntity))
{
edict_t *button = FindNearestButton (STRING (m_liftEntity->v.targetname));
// if we got a valid button entity
if (!IsNullEntity (button))
if (!engine.IsNullEntity (button))
{
// lift is already used ?
bool liftUsed = false;
@ -958,7 +958,7 @@ bool Bot::DoWaypointNav (void)
// iterate though clients, and find if lift already used
for (int i = 0; i < engine.MaxClients (); i++)
{
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity () || IsNullEntity (g_clients[i].ent->v.groundentity))
if (!(g_clients[i].flags & CF_USED) || !(g_clients[i].flags & CF_ALIVE) || g_clients[i].team != m_team || g_clients[i].ent == GetEntity () || engine.IsNullEntity (g_clients[i].ent->v.groundentity))
continue;
if (g_clients[i].ent->v.groundentity == m_liftEntity)
@ -1047,7 +1047,7 @@ bool Bot::DoWaypointNav (void)
}
}
if (!IsNullEntity (m_liftEntity) && !(m_currentPath->flags & FLAG_LIFT))
if (!engine.IsNullEntity (m_liftEntity) && !(m_currentPath->flags & FLAG_LIFT))
{
if (m_liftState == LIFT_TRAVELING_BY)
{
@ -1087,7 +1087,7 @@ bool Bot::DoWaypointNav (void)
// check if we are going through a door...
engine.TestLine (pev->origin, m_waypointOrigin, TRACE_IGNORE_MONSTERS, GetEntity (), &tr);
if (!IsNullEntity (tr.pHit) && IsNullEntity (m_liftEntity) && strncmp (STRING (tr.pHit->v.classname), "func_door", 9) == 0)
if (!engine.IsNullEntity (tr.pHit) && engine.IsNullEntity (m_liftEntity) && strncmp (STRING (tr.pHit->v.classname), "func_door", 9) == 0)
{
// if the door is near enough...
if ((engine.GetAbsOrigin (tr.pHit) - pev->origin).GetLengthSquared () < 2500.0f)
@ -1104,7 +1104,7 @@ bool Bot::DoWaypointNav (void)
edict_t *button = FindNearestButton (STRING (tr.pHit->v.targetname));
// check if we got valid button
if (!IsNullEntity (button))
if (!engine.IsNullEntity (button))
{
m_pickupItem = button;
m_pickupType = PICKUP_BUTTON;
@ -1122,21 +1122,21 @@ bool Bot::DoWaypointNav (void)
edict_t *ent = NULL;
if (m_doorOpenAttempt > 2 && !IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, 256.0f)))
if (m_doorOpenAttempt > 2 && !engine.IsNullEntity (ent = FIND_ENTITY_IN_SPHERE (ent, pev->origin, 512.0f)))
{
if (IsValidPlayer (ent) && IsAlive (ent) && m_team != GetTeam (ent) && GetWeaponPenetrationPower (m_currentWeapon) > 0)
if (IsValidPlayer (ent) && IsAlive (ent) && m_team != engine.GetTeam (ent) && GetWeaponPenetrationPower (m_currentWeapon) > 0)
{
m_seeEnemyTime = engine.Time ();
m_seeEnemyTime = engine.Time () - 0.5f;
m_states |= STATE_SUSPECT_ENEMY;
m_aimFlags |= AIM_LAST_ENEMY;
m_states |= STATE_SEEING_ENEMY;
m_aimFlags |= AIM_ENEMY;
m_lastEnemy = ent;
m_enemy = ent;
m_lastEnemyOrigin = ent->v.origin;
}
else if (IsValidPlayer (ent) && IsAlive (ent) && m_team == GetTeam (ent))
else if (IsValidPlayer (ent) && IsAlive (ent) && m_team == engine.GetTeam (ent))
{
DeleteSearchNodes ();
ResetTasks ();
@ -1943,7 +1943,7 @@ void Bot::GetValidWaypoint (void)
// FIXME: Do some error checks if we got a waypoint
}
else if (m_navTimeset + GetEstimatedReachTime () < engine.Time () && IsNullEntity (m_enemy))
else if (m_navTimeset + GetEstimatedReachTime () < engine.Time () && engine.IsNullEntity (m_enemy))
{
if (m_team == TERRORIST)
{
@ -2490,7 +2490,7 @@ bool Bot::HeadTowardWaypoint (void)
}
// is there a jump waypoint right ahead and do we need to draw out the light weapon ?
if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210.0f || (dst.z + 32.0f > src.z && jumpDistance > 150.0f) || ((dst - src).GetLength2D () < 60.0f && jumpDistance > 60.0f)) && IsNullEntity (m_enemy))
if (willJump && m_currentWeapon != WEAPON_KNIFE && m_currentWeapon != WEAPON_SCOUT && !m_isReloading && !UsesPistol () && (jumpDistance > 210.0f || (dst.z + 32.0f > src.z && jumpDistance > 150.0f) || ((dst - src).GetLength2D () < 60.0f && jumpDistance > 60.0f)) && engine.IsNullEntity (m_enemy))
SelectWeaponByName ("weapon_knife"); // draw out the knife if we needed
// bot not already on ladder but will be soon?
@ -3310,7 +3310,7 @@ int Bot::FindPlantedBomb (void)
edict_t *bombEntity = NULL; // temporaly pointer to bomb
// search the bomb on the map
while (!IsNullEntity (bombEntity = FIND_ENTITY_BY_CLASSNAME (bombEntity, "grenade")))
while (!engine.IsNullEntity (bombEntity = FIND_ENTITY_BY_CLASSNAME (bombEntity, "grenade")))
{
if (strcmp (STRING (bombEntity->v.model) + 9, "c4.mdl") == 0)
{
@ -3367,7 +3367,7 @@ edict_t *Bot::FindNearestButton (const char *targetName)
edict_t *searchEntity = NULL, *foundEntity = NULL;
// find the nearest button which can open our target
while (!IsNullEntity(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))
while (!engine.IsNullEntity(searchEntity = FIND_ENTITY_BY_TARGET (searchEntity, targetName)))
{
Vector entityOrign = engine.GetAbsOrigin (searchEntity);

View file

@ -259,10 +259,10 @@ void NetworkMsg::Execute (void *p)
if (killerIndex != 0 && killerIndex != victimIndex)
{
edict_t *killer = EntityOfIndex (killerIndex);
edict_t *victim = EntityOfIndex (victimIndex);
edict_t *killer = engine.EntityOfIndex (killerIndex);
edict_t *victim = engine.EntityOfIndex (victimIndex);
if (IsNullEntity (killer) || IsNullEntity (victim))
if (engine.IsNullEntity (killer) || engine.IsNullEntity (victim))
break;
if (yb_communication_type.GetInt () == 2)
@ -272,7 +272,7 @@ void NetworkMsg::Execute (void *p)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && IsAlive (bot->GetEntity ()) && killer != bot->GetEntity () && bot->EntityIsVisible (victim->v.origin) && GetTeam (killer) == GetTeam (bot->GetEntity ()) && GetTeam (killer) != GetTeam (victim))
if (bot != NULL && bot->m_notKilled && killer != bot->GetEntity () && bot->EntityIsVisible (victim->v.origin) && engine.GetTeam (killer) == bot->m_team && engine.GetTeam (killer) != engine.GetTeam (victim))
{
if (killer == g_hostEntity)
bot->HandleChatterMessage ("#Bot_NiceShotCommander");
@ -289,7 +289,7 @@ void NetworkMsg::Execute (void *p)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && bot->m_seeEnemyTime + 2.0f < engine.Time () && IsAlive (bot->GetEntity ()) && GetTeam (bot->GetEntity ()) == GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && IsNullEntity (bot->m_enemy) && GetTeam (killer) != GetTeam (victim))
if (bot != NULL && bot->m_seeEnemyTime + 2.0f < engine.Time () && bot->m_notKilled && bot->m_team == engine.GetTeam (victim) && IsVisible (killer->v.origin, bot->GetEntity ()) && engine.IsNullEntity (bot->m_enemy) && engine.GetTeam (killer) != engine.GetTeam (victim))
{
bot->m_actualReactionTime = 0.0f;
bot->m_seeEnemyTime = engine.Time ();
@ -311,7 +311,7 @@ void NetworkMsg::Execute (void *p)
if (target != NULL)
{
if (GetTeam (killer) == GetTeam (victim))
if (engine.GetTeam (killer) == engine.GetTeam (victim))
target->m_voteKickIndex = killerIndex;
target->m_notKilled = false;
@ -399,7 +399,7 @@ void NetworkMsg::Execute (void *p)
{
Bot *bot = bots.FindOneValidAliveBot ();
if (bot != NULL && IsAlive (bot->GetEntity ()))
if (bot != NULL && bot->m_notKilled)
bot->HandleChatterMessage (PTR_TO_STR (p));
}
}
@ -418,7 +418,7 @@ void NetworkMsg::Execute (void *p)
{
Bot *bot = bots.FindOneValidAliveBot ();
if (bot != NULL && IsAlive (bot->GetEntity ()))
if (bot != NULL && bot->m_notKilled)
bot->HandleChatterMessage (PTR_TO_STR (p));
}
}
@ -435,12 +435,12 @@ void NetworkMsg::Execute (void *p)
{
Bot *bot = bots.GetBot (i);
if (bot != NULL && IsAlive (bot->GetEntity ()))
if (bot != NULL && bot->m_notKilled)
{
bot->DeleteSearchNodes ();
bot->ResetTasks ();
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && GetTeam (bot->GetEntity ()) == CT)
if (yb_communication_type.GetInt () == 2 && Random.Long (0, 100) < 75 && bot->m_team == CT)
bot->ChatterMessage (Chatter_WhereIsTheBomb);
}
}

View file

@ -59,7 +59,7 @@ const char *FormatBuffer (const char *format, ...)
bool IsAlive (edict_t *ent)
{
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return false;
return ent->v.deadflag == DEAD_NO && ent->v.health > 0 && ent->v.movetype != MOVETYPE_NOCLIP;
@ -86,7 +86,7 @@ bool IsInViewCone (const Vector &origin, edict_t *ent)
bool IsVisible (const Vector &origin, edict_t *ent)
{
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return false;
TraceResult tr;
@ -103,7 +103,7 @@ void DisplayMenuToClient (edict_t *ent, MenuText *menu)
if (!IsValidPlayer (ent))
return;
int clientIndex = IndexOfEntity (ent) - 1;
int clientIndex = engine.IndexOfEntity (ent) - 1;
if (menu != NULL)
{
@ -178,10 +178,10 @@ void DecalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex)
if (trace->flFraction == 1.0f)
return;
if (!IsNullEntity (trace->pHit))
if (!engine.IsNullEntity (trace->pHit))
{
if (trace->pHit->v.solid == SOLID_BSP || trace->pHit->v.movetype == MOVETYPE_PUSHSTEP)
entityIndex = IndexOfEntity (trace->pHit);
entityIndex = engine.IndexOfEntity (trace->pHit);
else
return;
}
@ -211,11 +211,11 @@ void DecalTrace (entvars_t *pev, TraceResult *trace, int logotypeIndex)
{
MESSAGE_BEGIN (MSG_BROADCAST, SVC_TEMPENTITY);
WRITE_BYTE (TE_PLAYERDECAL);
WRITE_BYTE (IndexOfEntity (ENT (pev)));
WRITE_BYTE (engine.IndexOfEntity (ENT (pev)));
WRITE_COORD (trace->vecEndPos.x);
WRITE_COORD (trace->vecEndPos.y);
WRITE_COORD (trace->vecEndPos.z);
WRITE_SHORT (static_cast <short> (IndexOfEntity (trace->pHit)));
WRITE_SHORT (static_cast <short> (engine.IndexOfEntity (trace->pHit)));
WRITE_BYTE (decalIndex);
MESSAGE_END ();
}
@ -427,7 +427,7 @@ int GetWeaponPenetrationPower (int id)
bool IsValidPlayer (edict_t *ent)
{
if (IsNullEntity (ent))
if (engine.IsNullEntity (ent))
return false;
if (ent->v.flags & FL_PROXY)
@ -452,7 +452,7 @@ bool IsPlayerVIP (edict_t *ent)
bool IsValidBot (edict_t *ent)
{
if (bots.GetBot (ent) != NULL || (!IsNullEntity (ent) && (ent->v.flags & FL_FAKECLIENT)))
if (bots.GetBot (ent) != NULL || (!engine.IsNullEntity (ent) && (ent->v.flags & FL_FAKECLIENT)))
return true;
return false;
@ -719,7 +719,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
edict_t *survive = NULL; // pointer to temporaly & survive entity
float nearestPlayer = 4096.0f; // nearest player
int toTeam = GetTeam (to);
int toTeam = engine.GetTeam (to);
for (int i = 0; i < engine.MaxClients (); i++)
{
@ -740,7 +740,7 @@ bool FindNearestPlayer (void **pvHolder, edict_t *to, float searchDistance, bool
}
}
if (IsNullEntity (survive))
if (engine.IsNullEntity (survive))
return false; // nothing found
// fill the holder
@ -757,11 +757,11 @@ void SoundAttachToClients (edict_t *ent, const char *sample, float volume)
// this function called by the sound hooking code (in emit_sound) enters the played sound into
// the array associated with the entity
if (IsNullEntity (ent) || IsNullString (sample))
if (engine.IsNullEntity (ent) || IsNullString (sample))
return; // reliability check
const Vector &origin = engine.GetAbsOrigin (ent);
int index = IndexOfEntity (ent) - 1;
int index = engine.IndexOfEntity (ent) - 1;
if (index < 0 || index >= engine.MaxClients ())
{

View file

@ -143,7 +143,7 @@ void Waypoint::FindInRadius (Array <int> &radiusHolder, float radius, const Vect
void Waypoint::Add (int flags, const Vector &waypointOrigin)
{
if (IsNullEntity (g_hostEntity))
if (engine.IsNullEntity (g_hostEntity))
return;
int index = -1, i;
@ -1309,7 +1309,7 @@ bool Waypoint::IsNodeReachable (const Vector &src, const Vector &destination)
// check if we go through a func_illusionary, in which case return false
engine.TestHull (src, destination, TRACE_IGNORE_MONSTERS, head_hull, g_hostEntity, &tr);
if (!IsNullEntity (tr.pHit) && strcmp ("func_illusionary", STRING (tr.pHit->v.classname)) == 0)
if (!engine.IsNullEntity (tr.pHit) && strcmp ("func_illusionary", STRING (tr.pHit->v.classname)) == 0)
return false; // don't add pathwaypoints through func_illusionaries
// check if this waypoint is "visible"...
@ -1497,7 +1497,7 @@ void Waypoint::Think (void)
{
// this function executes frame of waypoint operation code.
if (IsNullEntity (g_hostEntity))
if (engine.IsNullEntity (g_hostEntity))
return; // this function is only valid on listenserver, and in waypoint enabled mode.
float nearestDistance = 99999.0f;
@ -1731,10 +1731,10 @@ void Waypoint::Think (void)
// draw the danger directions
if (!g_waypointsChanged)
{
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex != -1 && GetTeam (g_hostEntity) == TERRORIST)
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex != -1 && engine.GetTeam (g_hostEntity) == TERRORIST)
engine.DrawLine (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team0DangerIndex]->origin, 15, 0, 255, 0, 0, 200, 0, 10, DRAW_ARROW); // draw a red arrow to this index's danger point
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex != -1 && GetTeam (g_hostEntity) == CT)
if ((g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex != -1 && engine.GetTeam (g_hostEntity) == CT)
engine.DrawLine (g_hostEntity, path->origin, m_paths[(g_experienceData + (nearestIndex * g_numWaypoints) + nearestIndex)->team1DangerIndex]->origin, 15, 0, 0, 0, 255, 200, 0, 10, DRAW_ARROW); // draw a blue arrow to this index's danger point
}
@ -2209,7 +2209,7 @@ void Waypoint::CreateBasic (void)
edict_t *ent = NULL;
// first of all, if map contains ladder points, create it
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_ladder")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_ladder")))
{
Vector ladderLeft = ent->v.absmin;
Vector ladderRight = ent->v.absmax;
@ -2258,7 +2258,7 @@ void Waypoint::CreateBasic (void)
}
// then terrortist spawnpoints
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_deathmatch")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_deathmatch")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2267,7 +2267,7 @@ void Waypoint::CreateBasic (void)
}
// then add ct spawnpoints
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_start")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_player_start")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2276,7 +2276,7 @@ void Waypoint::CreateBasic (void)
}
// then vip spawnpoint
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_vip_start")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_vip_start")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2285,7 +2285,7 @@ void Waypoint::CreateBasic (void)
}
// hostage rescue zone
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_hostage_rescue")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_hostage_rescue")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2294,7 +2294,7 @@ void Waypoint::CreateBasic (void)
}
// hostage rescue zone (same as above)
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_hostage_rescue")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_hostage_rescue")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2303,7 +2303,7 @@ void Waypoint::CreateBasic (void)
}
// bombspot zone
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_bomb_target")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_bomb_target")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2312,7 +2312,7 @@ void Waypoint::CreateBasic (void)
}
// bombspot zone (same as above)
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_bomb_target")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "info_bomb_target")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2321,7 +2321,7 @@ void Waypoint::CreateBasic (void)
}
// hostage entities
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "hostage_entity")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "hostage_entity")))
{
// if already saved || moving skip it
if ((ent->v.effects & EF_NODRAW) && ent->v.speed > 0.0f)
@ -2334,7 +2334,7 @@ void Waypoint::CreateBasic (void)
}
// vip rescue (safety) zone
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_vip_safetyzone")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_vip_safetyzone")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2343,7 +2343,7 @@ void Waypoint::CreateBasic (void)
}
// terrorist escape zone
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_escapezone")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "func_escapezone")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2352,7 +2352,7 @@ void Waypoint::CreateBasic (void)
}
// weapons on the map ?
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "armoury_entity")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "armoury_entity")))
{
Vector origin = engine.GetAbsOrigin (ent);
@ -2417,7 +2417,7 @@ void Waypoint::SetBombPosition (bool shouldReset)
edict_t *ent = NULL;
while (!IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
while (!engine.IsNullEntity (ent = FIND_ENTITY_BY_CLASSNAME (ent, "grenade")))
{
if (strcmp (STRING (ent->v.model) + 9, "c4.mdl") == 0)
{