reverted some changes
This commit is contained in:
parent
1db285cdcd
commit
77ed0bedd1
3 changed files with 39 additions and 61 deletions
|
|
@ -240,8 +240,7 @@ enum CollisionState
|
|||
COLLISION_JUMP,
|
||||
COLLISION_DUCK,
|
||||
COLLISION_STRAFELEFT,
|
||||
COLLISION_STRAFERIGHT,
|
||||
COLLISION_BACKOFF
|
||||
COLLISION_STRAFERIGHT
|
||||
};
|
||||
|
||||
// counter-strike team id's
|
||||
|
|
@ -408,8 +407,7 @@ enum CollisionProbe
|
|||
{
|
||||
PROBE_JUMP = (1 << 0), // probe jump when colliding
|
||||
PROBE_DUCK = (1 << 1), // probe duck when colliding
|
||||
PROBE_STRAFE = (1 << 2), // probe strafing when colliding
|
||||
PROBE_BACKOFF = (1 << 3) // probe going back when colliding
|
||||
PROBE_STRAFE = (1 << 2) // probe strafing when colliding
|
||||
};
|
||||
|
||||
// vgui menus (since latest steam updates is obsolete, but left for old cs)
|
||||
|
|
@ -595,6 +593,9 @@ const int NUM_WEAPONS = 26;
|
|||
const int WEAPON_PRIMARY = ((1 << WEAPON_XM1014) | (1 <<WEAPON_M3) | (1 << WEAPON_MAC10) | (1 << WEAPON_UMP45) | (1 << WEAPON_MP5) | (1 << WEAPON_TMP) | (1 << WEAPON_P90) | (1 << WEAPON_AUG) | (1 << WEAPON_M4A1) | (1 << WEAPON_SG552) | (1 << WEAPON_AK47) | (1 << WEAPON_SCOUT) | (1 << WEAPON_SG550) | (1 << WEAPON_AWP) | (1 << WEAPON_G3SG1) | (1 << WEAPON_M249) | (1 << WEAPON_FAMAS) | (1 << WEAPON_GALIL));
|
||||
const int WEAPON_SECONDARY = ((1 << WEAPON_P228) | (1 << WEAPON_ELITE) | (1 << WEAPON_USP) | (1 << WEAPON_GLOCK) | (1 << WEAPON_DEAGLE) | (1 << WEAPON_FIVESEVEN));
|
||||
|
||||
// maximum collide moves
|
||||
const int MAX_COLLIDE_MOVES = 4;
|
||||
|
||||
// this structure links waypoints returned from pathfinder
|
||||
struct PathNode
|
||||
{
|
||||
|
|
@ -857,7 +858,7 @@ private:
|
|||
float m_lastCollTime; // time until next collision check
|
||||
|
||||
unsigned int m_collisionProbeBits; // bits of possible collision moves
|
||||
unsigned int m_collideMoves[5]; // sorted array of movements
|
||||
unsigned int m_collideMoves[MAX_COLLIDE_MOVES]; // sorted array of movements
|
||||
unsigned int m_collStateIndex; // index into collide moves
|
||||
CollisionState m_collisionState; // collision State
|
||||
|
||||
|
|
|
|||
|
|
@ -3606,6 +3606,7 @@ void Bot::RunTask (void)
|
|||
if (!IsEntityNull (m_enemy))
|
||||
{
|
||||
ResetCollideState ();
|
||||
m_lastCollTime = GetWorldTime () + 0.5f;
|
||||
|
||||
if (IsOnLadder ())
|
||||
{
|
||||
|
|
@ -5287,19 +5288,6 @@ bool Bot::HasHostage (void)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Bot::ResetCollideState (void)
|
||||
{
|
||||
m_collideTime = 0.0;
|
||||
m_probeTime = 0.0;
|
||||
|
||||
m_collisionProbeBits = 0;
|
||||
m_collisionState = COLLISION_NOTDECICED;
|
||||
m_collStateIndex = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
m_collideMoves[i] = 0;
|
||||
}
|
||||
|
||||
int Bot::GetAmmo (void)
|
||||
{
|
||||
if (g_weaponDefs[m_currentWeapon].ammo1 == -1)
|
||||
|
|
@ -5627,7 +5615,9 @@ void Bot::ResetDoubleJumpState (void)
|
|||
|
||||
void Bot::DebugMsg (const char *format, ...)
|
||||
{
|
||||
if (yb_debug.GetInt () <= 2)
|
||||
int level = yb_debug.GetInt ();
|
||||
|
||||
if (level <= 2)
|
||||
return;
|
||||
|
||||
va_list ap;
|
||||
|
|
@ -5637,10 +5627,12 @@ void Bot::DebugMsg (const char *format, ...)
|
|||
vsprintf (buffer, format, ap);
|
||||
va_end (ap);
|
||||
|
||||
if (yb_debug.GetInt () == 3 && !IsEntityNull (g_hostEntity) && g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
|
||||
if (level == 3 && !IsEntityNull (g_hostEntity) && g_hostEntity->v.iuser2 == IndexOfEntity (GetEntity ()))
|
||||
ServerPrint ("%s: %s", STRING (pev->netname), buffer);
|
||||
else if (level != 3)
|
||||
ServerPrint ("%s: %s", STRING (pev->netname), buffer);
|
||||
|
||||
if (yb_debug.GetInt () > 3)
|
||||
if (level > 3)
|
||||
AddLogEntry (false, LL_DEFAULT, "%s: %s", STRING (pev->netname), buffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -304,6 +304,19 @@ bool Bot::GoalIsValid (void)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Bot::ResetCollideState (void)
|
||||
{
|
||||
m_collideTime = 0.0;
|
||||
m_probeTime = 0.0;
|
||||
|
||||
m_collisionProbeBits = 0;
|
||||
m_collisionState = COLLISION_NOTDECICED;
|
||||
m_collStateIndex = 0;
|
||||
|
||||
for (int i = 0; i < MAX_COLLIDE_MOVES; i++)
|
||||
m_collideMoves[i] = 0;
|
||||
}
|
||||
|
||||
void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &dirNormal)
|
||||
{
|
||||
m_isStuck = false;
|
||||
|
|
@ -317,7 +330,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
TraceResult tr;
|
||||
edict_t *nearest = NULL;
|
||||
|
||||
if (g_timeRoundStart + 10.0f < GetWorldTime () && FindNearestPlayer (reinterpret_cast <void **> (&nearest), GetEntity (), pev->maxspeed, true, false, true, true) && nearest != NULL && !(nearest->v.flags & FL_FAKECLIENT)) // found somebody?
|
||||
if (g_timeRoundStart + 10.0f < GetWorldTime () && FindNearestPlayer (reinterpret_cast <void **> (&nearest), GetEntity (), pev->maxspeed, true, false, true, true)) // found somebody?
|
||||
{
|
||||
MakeVectors (m_moveAngles); // use our movement angles
|
||||
|
||||
|
|
@ -394,21 +407,19 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
// not yet decided what to do?
|
||||
if (m_collisionState == COLLISION_NOTDECICED)
|
||||
{
|
||||
char bits = 0;
|
||||
int bits = 0;
|
||||
|
||||
if (IsOnLadder ())
|
||||
bits = PROBE_STRAFE;
|
||||
else if (IsInWater ())
|
||||
bits = (PROBE_JUMP | PROBE_STRAFE);
|
||||
else if (cantMoveForward)
|
||||
bits = (PROBE_BACKOFF | PROBE_DUCK | PROBE_STRAFE);
|
||||
else
|
||||
bits = ((Random.Long (0, 10) > 5 ? PROBE_JUMP : 0) | PROBE_STRAFE | PROBE_DUCK);
|
||||
bits = ((Random.Long (0, 10) > (cantMoveForward ? 7 : 5) ? PROBE_JUMP : 0) | PROBE_STRAFE | PROBE_DUCK);
|
||||
|
||||
// collision check allowed if not flying through the air
|
||||
if (IsOnFloor () || IsOnLadder () || IsInWater ())
|
||||
{
|
||||
char state[10];
|
||||
char state[MAX_COLLIDE_MOVES * 2];
|
||||
int i = 0;
|
||||
|
||||
// first 4 entries hold the possible collision states
|
||||
|
|
@ -416,7 +427,6 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
state[i++] = COLLISION_DUCK;
|
||||
state[i++] = COLLISION_STRAFELEFT;
|
||||
state[i++] = COLLISION_STRAFERIGHT;
|
||||
state[i++] = COLLISION_BACKOFF;
|
||||
|
||||
// now weight all possible states
|
||||
if (bits & PROBE_JUMP)
|
||||
|
|
@ -547,53 +557,33 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
state[i] = 0;
|
||||
}
|
||||
|
||||
if (bits & PROBE_BACKOFF)
|
||||
{
|
||||
state[i] = 0;
|
||||
|
||||
MakeVectors (m_moveAngles);
|
||||
|
||||
src = pev->origin;
|
||||
dst = src - g_pGlobals->v_forward * 32;
|
||||
|
||||
TraceLine (src, dst, true, true, GetEntity (), &tr);
|
||||
|
||||
if (tr.flFraction != 1.0 || IsDeadlyDrop (dst))
|
||||
state[i] -= 70;
|
||||
else
|
||||
state[i] += 40;
|
||||
}
|
||||
else
|
||||
state[i] = 0;
|
||||
i++;
|
||||
|
||||
// weighted all possible moves, now sort them to start with most probable
|
||||
int temp = 0;
|
||||
bool isSorting = false;
|
||||
|
||||
do
|
||||
{
|
||||
isSorting = false;
|
||||
for (i = 0; i < 4; i++)
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (state[i + 5] < state[i + 6])
|
||||
if (state[i + MAX_COLLIDE_MOVES] < state[i + MAX_COLLIDE_MOVES + 1])
|
||||
{
|
||||
temp = state[i];
|
||||
int temp = state[i];
|
||||
|
||||
state[i] = state[i + 1];
|
||||
state[i + 1] = temp;
|
||||
|
||||
temp = state[i + 5];
|
||||
temp = state[i + MAX_COLLIDE_MOVES];
|
||||
|
||||
state[i + 5] = state[i + 6];
|
||||
state[i + 6] = temp;
|
||||
state[i + MAX_COLLIDE_MOVES] = state[i + MAX_COLLIDE_MOVES + 1];
|
||||
state[i + MAX_COLLIDE_MOVES + 1] = temp;
|
||||
|
||||
isSorting = true;
|
||||
}
|
||||
}
|
||||
} while (isSorting);
|
||||
|
||||
for (i = 0; i < 5; i++)
|
||||
for (i = 0; i < MAX_COLLIDE_MOVES; i++)
|
||||
m_collideMoves[i] = state[i];
|
||||
|
||||
m_collideTime = GetWorldTime ();
|
||||
|
|
@ -618,7 +608,7 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
}
|
||||
}
|
||||
|
||||
if (m_collStateIndex <= 5)
|
||||
if (m_collStateIndex <= MAX_COLLIDE_MOVES)
|
||||
{
|
||||
switch (m_collideMoves[m_collStateIndex])
|
||||
{
|
||||
|
|
@ -641,11 +631,6 @@ void Bot::CheckTerrain (float movedDistance, const Vector &dir, const Vector &di
|
|||
pev->button |= IN_MOVERIGHT;
|
||||
SetStrafeSpeed (directionNormal, pev->maxspeed);
|
||||
break;
|
||||
|
||||
case COLLISION_BACKOFF:
|
||||
pev->button |= IN_BACK;
|
||||
m_moveSpeed = -pev->maxspeed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue