Cleanup code

Fixed a bug after killing czbot by headshot, angles turn at 180 degrees.
Fixed some bugs with mp_nadedrops
This commit is contained in:
s1lent 2017-11-01 22:01:24 +07:00 committed by Dmitry Novikov
parent 9dcab4bd49
commit 0eed08c133
34 changed files with 1497 additions and 1419 deletions

View File

@ -1,6 +1,6 @@
#include "precompiled.h" #include "precompiled.h"
// BModelOrigin - calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0 // Calculates origin of a bmodel from absmin/size because all bmodel origins are 0 0 0
Vector VecBModelOrigin(entvars_t *pevBModel) Vector VecBModelOrigin(entvars_t *pevBModel)
{ {
return pevBModel->absmin + (pevBModel->size * 0.5f); return pevBModel->absmin + (pevBModel->size * 0.5f);
@ -477,7 +477,7 @@ void CFuncRotating::Precache()
} }
} }
// Touch - will hurt others based on how fast the brush is spinning // Will hurt others based on how fast the brush is spinning
void CFuncRotating::HurtTouch(CBaseEntity *pOther) void CFuncRotating::HurtTouch(CBaseEntity *pOther)
{ {
entvars_t *pevOther = pOther->pev; entvars_t *pevOther = pOther->pev;
@ -494,7 +494,7 @@ void CFuncRotating::HurtTouch(CBaseEntity *pOther)
pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev)).Normalize() * pev->dmg; pevOther->velocity = (pevOther->origin - VecBModelOrigin(pev)).Normalize() * pev->dmg;
} }
// RampPitchVol - ramp pitch and volume up to final values, based on difference // Ramp pitch and volume up to final values, based on difference
// between how fast we're going vs how fast we plan to go // between how fast we're going vs how fast we plan to go
void CFuncRotating::RampPitchVol(BOOL fUp) void CFuncRotating::RampPitchVol(BOOL fUp)
{ {
@ -540,7 +540,7 @@ void CFuncRotating::RampPitchVol(BOOL fUp)
EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), fvol, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), pitch); EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char *)STRING(pev->noiseRunning), fvol, m_flAttenuation, (SND_CHANGE_PITCH | SND_CHANGE_VOL), pitch);
} }
// SpinUp - accelerates a non-moving func_rotating up to it's speed // Accelerates a non-moving func_rotating up to it's speed
void CFuncRotating::SpinUp() void CFuncRotating::SpinUp()
{ {
// rotational velocity // rotational velocity
@ -616,7 +616,7 @@ void CFuncRotating::Rotate()
pev->nextthink = pev->ltime + 10; pev->nextthink = pev->ltime + 10;
} }
// Rotating Use - when a rotating brush is triggered // When a rotating brush is triggered
void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value)
{ {
// is this a brush that should accelerate and decelerate when turned on/off (fan)? // is this a brush that should accelerate and decelerate when turned on/off (fan)?
@ -662,7 +662,7 @@ void CFuncRotating::RotatingUse(CBaseEntity *pActivator, CBaseEntity *pCaller, U
} }
} }
// RotatingBlocked - An entity has blocked the brush // An entity has blocked the brush
void CFuncRotating::Blocked(CBaseEntity *pOther) void CFuncRotating::Blocked(CBaseEntity *pOther)
{ {
pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH);

View File

@ -1643,6 +1643,15 @@ public:
cost += crouchPenalty * dist; cost += crouchPenalty * dist;
} }
// if this is a "walk" area, add penalty
if (area->GetAttributes() & NAV_WALK)
{
// these areas are kinda slow to move through
float_precision walkPenalty = (m_route == FASTEST_ROUTE) ? 2.5f : 1.5f;
cost += walkPenalty * dist;
}
// if this is a "jump" area, add penalty // if this is a "jump" area, add penalty
if (area->GetAttributes() & NAV_JUMP) if (area->GetAttributes() & NAV_JUMP)
{ {

View File

@ -270,6 +270,7 @@ void CCSBotManager::AddServerCommands()
AddServerCommand("bot_nav_crouch"); AddServerCommand("bot_nav_crouch");
AddServerCommand("bot_nav_jump"); AddServerCommand("bot_nav_jump");
AddServerCommand("bot_nav_precise"); AddServerCommand("bot_nav_precise");
AddServerCommand("bot_nav_walk");
AddServerCommand("bot_nav_no_jump"); AddServerCommand("bot_nav_no_jump");
AddServerCommand("bot_nav_analyze"); AddServerCommand("bot_nav_analyze");
AddServerCommand("bot_nav_strip"); AddServerCommand("bot_nav_strip");
@ -525,6 +526,10 @@ void CCSBotManager::ServerCommand(const char *pcmd)
{ {
m_editCmd = EDIT_ATTRIB_PRECISE; m_editCmd = EDIT_ATTRIB_PRECISE;
} }
else if (FStrEq(pcmd, "bot_nav_walk"))
{
m_editCmd = EDIT_ATTRIB_WALK;
}
else if (FStrEq(pcmd, "bot_nav_no_jump")) else if (FStrEq(pcmd, "bot_nav_no_jump"))
{ {
m_editCmd = EDIT_ATTRIB_NO_JUMP; m_editCmd = EDIT_ATTRIB_NO_JUMP;

View File

@ -1352,9 +1352,10 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
SetPathIndex(newIndex); SetPathIndex(newIndex);
} }
// Crouching
if (!IsUsingLadder()) if (!IsUsingLadder())
{ {
// Crouching
// if we are approaching a crouch area, crouch // if we are approaching a crouch area, crouch
// if there are no crouch areas coming up, stand // if there are no crouch areas coming up, stand
const float crouchRange = 50.0f; const float crouchRange = 50.0f;
@ -1388,6 +1389,29 @@ CCSBot::PathResult CCSBot::UpdatePathMovement(bool allowSpeedChange)
StandUp(); StandUp();
} }
// end crouching logic // end crouching logic
// Walking
bool didWalk = false;
for (int i = prevIndex; i < m_pathLength; ++i)
{
const CNavArea *to = m_path[i].area;
Vector close;
to->GetClosestPointOnArea(&pev->origin, &close);
if ((close - pev->origin).Make2D().IsLengthGreaterThan(crouchRange))
break;
if (to->GetAttributes() & NAV_WALK)
{
Walk();
didWalk = true;
break;
}
}
if (!didWalk)
Run();
} }
// compute our forward facing angle // compute our forward facing angle

View File

@ -39,7 +39,7 @@ void FetchBombState::OnUpdate(CCSBot *me)
{ {
if (me->IsCarryingBomb()) if (me->IsCarryingBomb())
{ {
me->PrintIfWatched( "I picked up the bomb\n" ); me->PrintIfWatched("I picked up the bomb\n");
me->Idle(); me->Idle();
return; return;
} }

View File

@ -146,7 +146,6 @@ void MoveToState::OnUpdate(CCSBot *me)
me->Idle(); me->Idle();
return; return;
} }
break; break;
} }
default: default:

View File

@ -103,7 +103,7 @@ void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
vecSpot = pev->origin + Vector(0, 0, 8); vecSpot = pev->origin + Vector(0, 0, 8);
UTIL_TraceLine(vecSpot, vecSpot + Vector (0, 0, -40), ignore_monsters, ENT(pev), & tr); UTIL_TraceLine(vecSpot, vecSpot + Vector(0, 0, -40), ignore_monsters, ENT(pev), &tr);
// Pull out of the wall a bit // Pull out of the wall a bit
if (tr.flFraction != 1.0f) if (tr.flFraction != 1.0f)
@ -112,7 +112,7 @@ void CEnvExplosion::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE
} }
// draw decal // draw decal
if (! (pev->spawnflags & SF_ENVEXPLOSION_NODECAL)) if (!(pev->spawnflags & SF_ENVEXPLOSION_NODECAL))
{ {
if (RANDOM_FLOAT(0, 1) < 0.5f) if (RANDOM_FLOAT(0, 1) < 0.5f)
{ {

View File

@ -555,7 +555,6 @@ void CBreakable::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecD
break; break;
} }
case matUnbreakableGlass: case matUnbreakableGlass:
{ {
UTIL_Ricochet(ptr->vecEndPos, RANDOM_FLOAT(0.5, 1.5)); UTIL_Ricochet(ptr->vecEndPos, RANDOM_FLOAT(0.5, 1.5));

View File

@ -57,7 +57,7 @@ enum HostageChatterType
HOSTAGE_CHATTER_PLEASE_RESCUE_ME, HOSTAGE_CHATTER_PLEASE_RESCUE_ME,
HOSTAGE_CHATTER_SEE_RESCUE_ZONE, HOSTAGE_CHATTER_SEE_RESCUE_ZONE,
HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE, HOSTAGE_CHATTER_IMPATIENT_FOR_RESCUE,
HOSTAGE_CHATTER_CTS_WIN , HOSTAGE_CHATTER_CTS_WIN,
HOSTAGE_CHATTER_TERRORISTS_WIN, HOSTAGE_CHATTER_TERRORISTS_WIN,
HOSTAGE_CHATTER_RESCUED, HOSTAGE_CHATTER_RESCUED,
HOSTAGE_CHATTER_WARN_NEARBY, HOSTAGE_CHATTER_WARN_NEARBY,

View File

@ -155,7 +155,7 @@ void CHostageImprov::MoveTowards(const Vector &pos, float deltaT)
Vector stepAhead = GetFeet() + farLookAheadRange * aheadRay; Vector stepAhead = GetFeet() + farLookAheadRange * aheadRay;
stepAhead.z += HumanHeight; stepAhead.z += HumanHeight;
if (GetSimpleGroundHeightWithFloor(&stepAhead, &ground, &normal )) if (GetSimpleGroundHeightWithFloor(&stepAhead, &ground, &normal))
{ {
if (normal.z > 0.9f) if (normal.z > 0.9f)
jumped = DiscontinuityJump(ground, HOSTAGE_ONLY_JUMP_DOWN); jumped = DiscontinuityJump(ground, HOSTAGE_ONLY_JUMP_DOWN);

View File

@ -247,7 +247,7 @@ BOOL CItemBattery::MyTouch(CBasePlayer *pPlayer)
pct--; pct--;
char szcharge[64]; char szcharge[64];
Q_sprintf(szcharge,"!HEV_%1dP", pct); Q_sprintf(szcharge, "!HEV_%1dP", pct);
pPlayer->SetSuitUpdate(szcharge, SUIT_SENTENCE, SUIT_NEXT_IN_30SEC); pPlayer->SetSuitUpdate(szcharge, SUIT_SENTENCE, SUIT_NEXT_IN_30SEC);
return TRUE; return TRUE;

View File

@ -1328,9 +1328,15 @@ BOOL CFuncTrackTrain::OnControls(entvars_t *pevTest)
local.y = -DotProduct(offset, gpGlobals->v_right); local.y = -DotProduct(offset, gpGlobals->v_right);
local.z = DotProduct(offset, gpGlobals->v_up); local.z = DotProduct(offset, gpGlobals->v_up);
if (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && if (local.x >= m_controlMins.x
local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z) && local.y >= m_controlMins.y
&& local.z >= m_controlMins.z
&& local.x <= m_controlMaxs.x
&& local.y <= m_controlMaxs.y
&& local.z <= m_controlMaxs.z)
{
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@ -1718,8 +1724,9 @@ TRAIN_CODE CFuncTrackChange::EvaluateTrain(CPathTrack *pcurrent)
if (!pcurrent || !m_train) if (!pcurrent || !m_train)
return TRAIN_SAFE; return TRAIN_SAFE;
if (m_train->m_ppath == pcurrent || (pcurrent->m_pprevious && m_train->m_ppath == pcurrent->m_pprevious) || if (m_train->m_ppath == pcurrent
(pcurrent->m_pnext && m_train->m_ppath == pcurrent->m_pnext)) || (pcurrent->m_pprevious && m_train->m_ppath == pcurrent->m_pprevious)
|| (pcurrent->m_pnext && m_train->m_ppath == pcurrent->m_pnext))
{ {
if (m_train->pev->speed != 0) if (m_train->pev->speed != 0)
return TRAIN_BLOCKING; return TRAIN_BLOCKING;

View File

@ -1228,7 +1228,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
return bTookDamage; return bTookDamage;
} }
void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) void PackPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
{ {
if (!pItem) if (!pItem)
return; return;
@ -1260,7 +1260,7 @@ void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
} }
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo) void PackPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
{ {
if (!pItem) if (!pItem)
return; return;
@ -1282,16 +1282,9 @@ void packPlayerNade(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo)
break; break;
} }
auto& ammoNades = pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()]; if ((pPlayer->pev->button & IN_ATTACK) && pPlayer->m_rgAmmo[pItem->PrimaryAmmoIndex()] <= 0) {
if (pItem->m_flStartThrow != 0)
{
if (ammoNades < 2)
return; return;
ammoNades--;
} }
else if (pItem->m_flReleaseThrow > 0 && ammoNades < 1)
return;
Vector vecAngles = pPlayer->pev->angles; Vector vecAngles = pPlayer->pev->angles;
Vector dir(Q_cos(vecAngles.y) * flOffset, Q_sin(vecAngles.y) * flOffset, 0.0f); Vector dir(Q_cos(vecAngles.y) * flOffset, Q_sin(vecAngles.y) * flOffset, 0.0f);
@ -1367,19 +1360,19 @@ void CBasePlayer::PackDeadPlayerItems()
else if (pPlayerItem->iItemSlot() == GRENADE_SLOT) else if (pPlayerItem->iItemSlot() == GRENADE_SLOT)
{ {
if (AreRunningCZero()) if (AreRunningCZero())
packPlayerItem(this, pPlayerItem, true); PackPlayerItem(this, pPlayerItem, true);
#ifdef REGAMEDLL_ADD #ifdef REGAMEDLL_ADD
else else
{ {
switch ((int)nadedrops.value) switch ((int)nadedrops.value)
{ {
case 1: case 1:
packPlayerNade(this, pPlayerItem, true); PackPlayerNade(this, pPlayerItem, true);
break; break;
case 2: case 2:
{ {
CBasePlayerItem *pNext = pPlayerItem->m_pNext; CBasePlayerItem *pNext = pPlayerItem->m_pNext;
packPlayerNade(this, pPlayerItem, true); PackPlayerNade(this, pPlayerItem, true);
pPlayerItem = pNext; pPlayerItem = pNext;
continue; continue;
} }
@ -1392,7 +1385,7 @@ void CBasePlayer::PackDeadPlayerItems()
} }
} }
packPlayerItem(this, pBestItem, bPackAmmo); PackPlayerItem(this, pBestItem, bPackAmmo);
} }
RemoveAllItems(TRUE); RemoveAllItems(TRUE);
@ -1950,6 +1943,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
if ((pev->button & IN_ATTACK) && m_rgAmmo[pHEGrenade->m_iPrimaryAmmoType]) if ((pev->button & IN_ATTACK) && m_rgAmmo[pHEGrenade->m_iPrimaryAmmoType])
{ {
CGrenade::ShootTimed2(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, m_iTeam, pHEGrenade->m_usCreateExplosion); CGrenade::ShootTimed2(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, m_iTeam, pHEGrenade->m_usCreateExplosion);
#ifdef REGAMEDLL_FIXES
m_rgAmmo[m_pActiveItem->PrimaryAmmoIndex()]--;
#endif
} }
break; break;
} }
@ -1958,6 +1955,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
if ((pev->button & IN_ATTACK) && m_rgAmmo[((CBasePlayerWeapon *)m_pActiveItem)->m_iPrimaryAmmoType]) if ((pev->button & IN_ATTACK) && m_rgAmmo[((CBasePlayerWeapon *)m_pActiveItem)->m_iPrimaryAmmoType])
{ {
CGrenade::ShootTimed(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5); CGrenade::ShootTimed(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5);
#ifdef REGAMEDLL_FIXES
m_rgAmmo[m_pActiveItem->PrimaryAmmoIndex()]--;
#endif
} }
break; break;
} }
@ -1967,6 +1968,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
if ((pev->button & IN_ATTACK) && m_rgAmmo[pSmoke->m_iPrimaryAmmoType]) if ((pev->button & IN_ATTACK) && m_rgAmmo[pSmoke->m_iPrimaryAmmoType])
{ {
CGrenade::ShootSmokeGrenade(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, pSmoke->m_usCreateSmoke); CGrenade::ShootSmokeGrenade(pev, (pev->origin + pev->view_ofs), pev->angles, 1.5, pSmoke->m_usCreateSmoke);
#ifdef REGAMEDLL_FIXES
m_rgAmmo[m_pActiveItem->PrimaryAmmoIndex()]--;
#endif
} }
break; break;
} }
@ -1997,7 +2002,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
MESSAGE_END(); MESSAGE_END();
} }
else else
{
UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT)); UTIL_ScreenFade(this, Vector(0, 0, 0), 3, 3, 255, (FFADE_OUT | FFADE_STAYOUT));
}
SetScoreboardAttributes(); SetScoreboardAttributes();
@ -2056,7 +2063,12 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
break; break;
} }
#ifdef REGAMEDLL_FIXES
pev->angles.y = UTIL_VecToAngles(pev->velocity).y;
#else
pev->angles.y = UTIL_VecToAngles(-pev->velocity).y; pev->angles.y = UTIL_VecToAngles(-pev->velocity).y;
#endif
pev->v_angle.y = pev->angles.y; pev->v_angle.y = pev->angles.y;
m_iThrowDirection = THROW_NONE; m_iThrowDirection = THROW_NONE;
@ -4728,6 +4740,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PostThink)()
// NOTE: play on item channel because we play footstep landing on body channel // NOTE: play on item channel because we play footstep landing on body channel
EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM); EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", VOL_NORM, ATTN_NORM);
} }
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
if (flFallDamage >= 1.0f) if (flFallDamage >= 1.0f)
#else #else

View File

@ -939,7 +939,6 @@ Vector VecVelocityForDamage(float flDamage);
int TrainSpeed(int iSpeed, int iMax); int TrainSpeed(int iSpeed, int iMax);
const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller); const char *GetWeaponName(entvars_t *pevInflictor, entvars_t *pKiller);
void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name); void LogAttack(CBasePlayer *pAttacker, CBasePlayer *pVictim, int teamAttack, int healthHit, int armorHit, int newHealth, int newArmor, const char *killer_weapon_name);
void packPlayerItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, bool packAmmo);
bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity); bool CanSeeUseable(CBasePlayer *me, CBaseEntity *entity);
void FixPlayerCrouchStuck(edict_t *pPlayer); void FixPlayerCrouchStuck(edict_t *pPlayer);
BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot); BOOL IsSpawnPointValid(CBaseEntity *pPlayer, CBaseEntity *pSpot);

View File

@ -15,7 +15,7 @@ NOXREF float GetSkillCvar(char *pName)
if (flValue <= 0.0f) if (flValue <= 0.0f)
{ {
ALERT(at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n",szBuffer); ALERT(at_console, "\n\n** GetSkillCVar Got a zero for %s **\n\n", szBuffer);
} }
return flValue; return flValue;

View File

@ -1788,7 +1788,7 @@ float TEXTURETYPE_PlaySound(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int
{ {
UTIL_Sparks(ptr->vecEndPos); UTIL_Sparks(ptr->vecEndPos);
//random volume range // random volume range
float flVolume = RANDOM_FLOAT(0.7 , 1.0); float flVolume = RANDOM_FLOAT(0.7 , 1.0);
switch (RANDOM_LONG(0, 1)) switch (RANDOM_LONG(0, 1))

View File

@ -1127,8 +1127,8 @@ public:
void EXPORT Smack(); void EXPORT Smack();
void WeaponAnimation(int iAnimation); void WeaponAnimation(int iAnimation);
int Stab(int fFirst); BOOL Stab(BOOL fFirst);
int Swing(int fFirst); BOOL Swing(BOOL fFirst);
public: public:
bool ShieldSecondaryFire(int iUpAnim, int iDownAnim); bool ShieldSecondaryFire(int iUpAnim, int iDownAnim);

View File

@ -248,9 +248,9 @@ void CKnife::WeaponIdle()
SendWeaponAnim(KNIFE_IDLE, UseDecrement() != FALSE); SendWeaponAnim(KNIFE_IDLE, UseDecrement() != FALSE);
} }
int CKnife::Swing(int fFirst) BOOL CKnife::Swing(BOOL fFirst)
{ {
int fDidHit = FALSE; BOOL fDidHit = FALSE;
TraceResult tr; TraceResult tr;
Vector vecSrc, vecEnd; Vector vecSrc, vecEnd;
@ -422,9 +422,9 @@ int CKnife::Swing(int fFirst)
return fDidHit; return fDidHit;
} }
int CKnife::Stab(int fFirst) BOOL CKnife::Stab(BOOL fFirst)
{ {
int fDidHit = FALSE; BOOL fDidHit = FALSE;
TraceResult tr; TraceResult tr;
Vector vecSrc, vecEnd; Vector vecSrc, vecEnd;

View File

@ -69,6 +69,7 @@ enum NavAttributeType
NAV_JUMP = 0x02, // must jump to traverse this area NAV_JUMP = 0x02, // must jump to traverse this area
NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area NAV_PRECISE = 0x04, // do not adjust for obstacles, just move along area
NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping NAV_NO_JUMP = 0x08, // inhibit discontinuity jumping
NAV_WALK = 0x10, // must not run through this area
}; };
enum NavDirType enum NavDirType

View File

@ -2338,6 +2338,7 @@ void CNavArea::Draw(byte red, byte green, byte blue, int duration)
UTIL_DrawBeamPoints(nw, se, duration, red, green, blue); UTIL_DrawBeamPoints(nw, se, duration, red, green, blue);
UTIL_DrawBeamPoints(ne, sw, duration, red, green, blue); UTIL_DrawBeamPoints(ne, sw, duration, red, green, blue);
} }
if (GetAttributes() & NAV_PRECISE) if (GetAttributes() & NAV_PRECISE)
{ {
float size = 8.0f; float size = 8.0f;
@ -2349,6 +2350,7 @@ void CNavArea::Draw(byte red, byte green, byte blue, int duration)
Vector right(m_center.x + size, m_center.y, m_center.z + cv_bot_nav_zdraw.value); Vector right(m_center.x + size, m_center.y, m_center.z + cv_bot_nav_zdraw.value);
UTIL_DrawBeamPoints(left, right, duration, red, green, blue); UTIL_DrawBeamPoints(left, right, duration, red, green, blue);
} }
if (GetAttributes() & NAV_NO_JUMP) if (GetAttributes() & NAV_NO_JUMP)
{ {
float size = 8.0f; float size = 8.0f;
@ -2361,6 +2363,19 @@ void CNavArea::Draw(byte red, byte green, byte blue, int duration)
UTIL_DrawBeamPoints(down, left, duration, red, green, blue); UTIL_DrawBeamPoints(down, left, duration, red, green, blue);
UTIL_DrawBeamPoints(left, up, duration, red, green, blue); UTIL_DrawBeamPoints(left, up, duration, red, green, blue);
} }
if (GetAttributes() & NAV_WALK)
{
float size = 8.0f;
Vector up(m_center.x - size, m_center.y - size, m_center.z + cv_bot_nav_zdraw.value);
Vector down(m_center.x + size, m_center.y + size, m_center.z + cv_bot_nav_zdraw.value);
Vector left(m_center.x - size, m_center.y + size, m_center.z + cv_bot_nav_zdraw.value);
Vector right(m_center.x + size, m_center.y - size, m_center.z + cv_bot_nav_zdraw.value);
UTIL_DrawBeamPoints(up, right, duration, red, green, blue);
UTIL_DrawBeamPoints(right, down, duration, red, green, blue);
UTIL_DrawBeamPoints(down, left, duration, red, green, blue);
UTIL_DrawBeamPoints(left, up, duration, red, green, blue);
}
} }
// Draw selected corner for debugging // Draw selected corner for debugging
@ -3826,11 +3841,12 @@ void EditNavAreas(NavEditCmdType cmd)
} }
else else
{ {
Q_sprintf(attrib, "%s%s%s%s", Q_sprintf(attrib, "%s%s%s%s%s",
(area->GetAttributes() & NAV_CROUCH) ? "CROUCH " : "", (area->GetAttributes() & NAV_CROUCH) ? "CROUCH " : "",
(area->GetAttributes() & NAV_JUMP) ? "JUMP " : "", (area->GetAttributes() & NAV_JUMP) ? "JUMP " : "",
(area->GetAttributes() & NAV_PRECISE) ? "PRECISE " : "", (area->GetAttributes() & NAV_PRECISE) ? "PRECISE " : "",
(area->GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP " : ""); (area->GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP " : "",
(area->GetAttributes() & NAV_WALK) ? "WALK " : "");
} }
Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib); Q_sprintf(buffer, "Area #%d %s %s\n", area->GetID(), locName, attrib);
@ -3974,6 +3990,10 @@ void EditNavAreas(NavEditCmdType cmd)
EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_PRECISE); area->SetAttributes(area->GetAttributes() ^ NAV_PRECISE);
break; break;
case EDIT_ATTRIB_WALK:
EMIT_SOUND_DYN(ENT(UTIL_GetLocalPlayer()->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_WALK);
break;
case EDIT_ATTRIB_NO_JUMP: case EDIT_ATTRIB_NO_JUMP:
EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100); EMIT_SOUND_DYN(ENT(pLocalPlayer->pev), CHAN_ITEM, "buttons/bell1.wav", 1, ATTN_NORM, 0, 100);
area->SetAttributes(area->GetAttributes() ^ NAV_NO_JUMP); area->SetAttributes(area->GetAttributes() ^ NAV_NO_JUMP);

View File

@ -50,6 +50,7 @@ enum NavEditCmdType
EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area EDIT_ATTRIB_CROUCH, // toggle crouch attribute on current area
EDIT_ATTRIB_JUMP, // toggle jump attribute on current area EDIT_ATTRIB_JUMP, // toggle jump attribute on current area
EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area EDIT_ATTRIB_PRECISE, // toggle precise attribute on current area
EDIT_ATTRIB_WALK, // toggle walk attribute on current area
EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area EDIT_ATTRIB_NO_JUMP, // toggle inhibiting discontinuity jumping in current area
EDIT_BEGIN_AREA, // begin creating a new nav area EDIT_BEGIN_AREA, // begin creating a new nav area
EDIT_END_AREA, // end creation of the new nav area EDIT_END_AREA, // end creation of the new nav area

View File

@ -130,12 +130,13 @@ void CNavArea::Save(FILE *fp) const
fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ); fprintf(fp, "v %f %f %f\n", m_extent.lo.x, m_extent.hi.y, m_swZ);
static int base = 1; static int base = 1;
fprintf(fp, "\n\ng %04dArea%s%s%s%s\n", m_id, fprintf(fp, "\n\ng %04dArea%s%s%s%s%s\n", m_id,
(GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "", (GetAttributes() & NAV_CROUCH) ? "CROUCH" : "", (GetAttributes() & NAV_JUMP) ? "JUMP" : "",
(GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", (GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP" : ""); (GetAttributes() & NAV_PRECISE) ? "PRECISE" : "", (GetAttributes() & NAV_NO_JUMP) ? "NO_JUMP" : "",
(GetAttributes() & NAV_WALK) ? "NAV_WALK" : "");
fprintf(fp, "f %d %d %d %d\n\n", base, base + 1, base + 2, base + 3); fprintf(fp, "f %d %d %d %d %d\n\n", base, base + 1, base + 2, base + 3, base + 4);
base += 4; base += 5;
} }
void CNavArea::Save(int fd, unsigned int version) void CNavArea::Save(int fd, unsigned int version)