Skip to content

Commit

Permalink
turret_max_range
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Apr 7, 2024
1 parent 333b897 commit 9928062
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions game/cfg/skills/skill_default.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,9 @@
"turret_turn_rate2": 40,
"turret_turn_rate3": 45,

// range of the turret
"turret_max_range": 1200,

// 0 = turret can not take damage when it's off
// affects both turret and miniturret.
"turret_takedamage_off1": 1,
Expand Down
15 changes: 7 additions & 8 deletions src/game/server/entities/NPCs/military/turret.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "cbase.h"

#define TURRET_SHOTS 2
#define TURRET_RANGE (100 * 12)
#define TURRET_SPREAD Vector(0, 0, 0)
#define TURRET_MAXSPIN 5 //!< seconds turret barrel will spin w/o a target
#define TURRET_MACHINE_VOLUME 0.5
Expand Down Expand Up @@ -268,7 +267,7 @@ void CBaseTurret::Spawn()
SetBoneController(0, 0);
SetBoneController(1, 0);
m_flFieldOfView = VIEW_FIELD_FULL;
// m_flSightRange = TURRET_RANGE;
// m_flSightRange = GetSkillFloat( "turret_max_range"sv, 1200 );
}

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

// Current enmey is not visible.
if (!fEnemyVisible || (flDistToEnemy > TURRET_RANGE))
if (!fEnemyVisible || (flDistToEnemy > GetSkillFloat( "turret_max_range"sv, 1200 ) ))
{
if (0 == m_flLastSight)
m_flLastSight = gpGlobals->time + 0.5;
Expand Down Expand Up @@ -628,14 +627,14 @@ void CBaseTurret::ActiveThink()

void CTurret::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_12MM, 1);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, GetSkillFloat( "turret_max_range"sv, 1200 ), BULLET_MONSTER_12MM, 1);
EmitSound(CHAN_WEAPON, "turret/tu_fire1.wav", 1, 0.6);
pev->effects = pev->effects | EF_MUZZLEFLASH;
}

void CMiniTurret::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_9MM, 1);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, GetSkillFloat( "turret_max_range"sv, 1200 ), BULLET_MONSTER_9MM, 1);

switch (RANDOM_LONG(0, 2))
{
Expand Down Expand Up @@ -854,7 +853,7 @@ void CBaseTurret::SearchThink()
// Acquire Target
if (m_hEnemy == nullptr)
{
Look(TURRET_RANGE);
Look(GetSkillFloat( "turret_max_range"sv, 1200 ));
m_hEnemy = BestVisibleEnemy();
}

Expand Down Expand Up @@ -909,7 +908,7 @@ void CBaseTurret::AutoSearchThink()

if (m_hEnemy == nullptr)
{
Look(TURRET_RANGE);
Look(GetSkillFloat( "turret_max_range"sv, 1200 ));
m_hEnemy = BestVisibleEnemy();
}

Expand Down Expand Up @@ -1200,7 +1199,7 @@ void CSentry::Spawn()

void CSentry::Shoot(Vector& vecSrc, Vector& vecDirToEnemy)
{
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, TURRET_RANGE, BULLET_MONSTER_MP5, 1);
FireBullets(1, vecSrc, vecDirToEnemy, TURRET_SPREAD, GetSkillFloat( "turret_max_range"sv, 1200 ), BULLET_MONSTER_MP5, 1);

switch (RANDOM_LONG(0, 2))
{
Expand Down

0 comments on commit 9928062

Please sign in to comment.