Skip to content

Commit

Permalink
add max attack range to turrets
Browse files Browse the repository at this point in the history
also increased rpg laser brightness
  • Loading branch information
wootguy committed Sep 16, 2024
1 parent 924d1a4 commit c31b4e8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
13 changes: 9 additions & 4 deletions dlls/monster/CBaseTurret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void CBaseTurret::KeyValue(KeyValueData* pkvd)
m_iBaseTurnRate = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "attackrange"))
{
m_flSightRange = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else if (FStrEq(pkvd->szKeyName, "style") ||
FStrEq(pkvd->szKeyName, "height") ||
FStrEq(pkvd->szKeyName, "value1") ||
Expand Down Expand Up @@ -115,7 +120,7 @@ void CBaseTurret::Spawn()
SetBoneController(0, 0);
SetBoneController(1, 0);
m_flFieldOfView = VIEW_FIELD_FULL;
// m_flSightRange = TURRET_RANGE;
m_flSightRange = m_flSightRange ? m_flSightRange : TURRET_RANGE;
}

void CBaseTurret::Precache()
Expand Down Expand Up @@ -312,7 +317,7 @@ void CBaseTurret::ActiveThink(void)
Vector vec = UTIL_VecToAngles(vecMidEnemy - vecMid);

// Current enmey is not visible.
if (!fEnemyVisible || (flDistToEnemy > TURRET_RANGE))
if (!fEnemyVisible || (flDistToEnemy > m_flSightRange))
{
if (!m_flLastSight)
m_flLastSight = gpGlobals->time + 0.5;
Expand Down Expand Up @@ -589,7 +594,7 @@ void CBaseTurret::SearchThink(void)
// Acquire Target
if (m_hEnemy == NULL)
{
Look(TURRET_RANGE);
Look(m_flSightRange);
m_hEnemy = BestVisibleEnemy();
}

Expand Down Expand Up @@ -648,7 +653,7 @@ void CBaseTurret::AutoSearchThink(void)

if (m_hEnemy == NULL)
{
Look(TURRET_RANGE);
Look(m_flSightRange);
m_hEnemy = BestVisibleEnemy();
}

Expand Down
1 change: 1 addition & 0 deletions dlls/monster/CBaseTurret.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class EXPORT CBaseTurret : public CBaseMonster
float m_flLastSight; // Last time we saw a target
float m_flMaxWait; // Max time to seach w/o a target
int m_iSearchSpeed; // Not Used!
float m_flSightRange;

// movement
float m_flStartYaw;
Expand Down
3 changes: 2 additions & 1 deletion dlls/monster/CMiniTurret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void CMiniTurret::Precache()

void CMiniTurret::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_9MM, 1);
float bulletRange = V_max(m_flSightRange, TURRET_RANGE);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, bulletRange, BULLET_MONSTER_9MM, 1);

switch (RANDOM_LONG(0, 2))
{
Expand Down
3 changes: 2 additions & 1 deletion dlls/monster/CSentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ void CSentry::DropInit() {

void CSentry::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_MP5, 1);
float bulletRange = V_max(m_flSightRange, TURRET_RANGE);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, bulletRange, BULLET_MONSTER_MP5, 1);

switch (RANDOM_LONG(0, 2))
{
Expand Down
3 changes: 2 additions & 1 deletion dlls/monster/CTurret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ const char* CTurret::DisplayName() {

void CTurret::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_12MM, 1);
float bulletRange = V_max(m_flSightRange, TURRET_RANGE);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, bulletRange, BULLET_MONSTER_12MM, 1);
EMIT_SOUND(ENT(pev), CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.6);
PLAY_DISTANT_SOUND(edict(), DISTANT_357);
pev->effects = pev->effects | EF_MUZZLEFLASH;
Expand Down
2 changes: 1 addition & 1 deletion dlls/weapon/CRpg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ void CRpg::UpdateSpot( void )
beam->SetStartAttachment(1);
beam->SetColor(255, 32, 32);
beam->SetNoise(0);
beam->SetBrightness(16);
beam->SetBrightness(48);
beam->SetScrollRate(64);
m_hBeam = beam;
}
Expand Down

0 comments on commit c31b4e8

Please sign in to comment.