Skip to content

Commit 9efef93

Browse files
committed
make alien jump parameters into convars
1 parent b4362fb commit 9efef93

2 files changed

Lines changed: 20 additions & 38 deletions

File tree

src/game/server/swarm/asw_alien_jumper.cpp

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ extern ConVar sv_gravity;
3636
int AE_ASW_ALIEN_START_JUMP;
3737
int AE_ASW_ALIEN_GLIDE;
3838

39-
#define ANTLION_JUMP_MIN 128.0f
40-
41-
#define ANTLION_JUMP_MAX_RISE 512.0f
42-
#define ANTLION_JUMP_MAX 1024.0f
43-
44-
4539
enum
4640
{
4741
SQUAD_SLOT_ALIEN_JUMP = LAST_SHARED_SQUADSLOT,
@@ -50,6 +44,14 @@ enum
5044
int ACT_ASW_ALIEN_JUMP_START;
5145
int ACT_ASW_ALIEN_LAND;
5246

47+
ConVar asw_alien_jump_max_speed( "asw_alien_jump_max_speed", "1024.0", FCVAR_CHEAT );
48+
ConVar asw_alien_jump_max_rise( "asw_alien_jump_max_rise", "512.0", FCVAR_CHEAT );
49+
ConVar asw_alien_jump_max_drop( "asw_alien_jump_max_drop", "512.0", FCVAR_CHEAT );
50+
ConVar asw_alien_jump_max_distance( "asw_alien_jump_max_distance", "1024.0", FCVAR_CHEAT );
51+
ConVar asw_alien_jump_min_distance( "asw_alien_jump_min_distance", "128.0", FCVAR_CHEAT );
52+
ConVar asw_alien_jump_min_distance_between_attempts( "asw_alien_jump_min_distance_between_attempts", "128.0", FCVAR_CHEAT );
53+
ConVar asw_alien_jump_min_predicted_distance( "asw_alien_jump_min_predicted_distance", "512.0", FCVAR_CHEAT );
54+
5355

5456
CASW_Alien_Jumper::CASW_Alien_Jumper()
5557
{
@@ -275,20 +277,8 @@ void CASW_Alien_Jumper::RunTask( const Task_t *pTask )
275277
// Purpose: Returns true if a reasonable jumping distance
276278
bool CASW_Alien_Jumper::IsJumpLegal( const Vector &startPos, const Vector &apex, const Vector &endPos ) const
277279
{
278-
const float MAX_JUMP_RISE = 512;
279-
//const float MIN_JUMP_RISE = 16;
280-
const float MAX_JUMP_DROP = 512;
281-
const float MAX_JUMP_DISTANCE = 1024;
282-
const float MIN_JUMP_DISTANCE = 128;
283-
284-
// make sure we don't do really flat jumps
285-
//float fHeight = (apex.z - startPos.z);
286-
//Msg("checking legality of jump with height %f\n", fHeight);
287-
//if ((apex.z - startPos.z) < 10 || fHeight != 0)
288-
//return false;
289-
290280
//Adrian: Don't try to jump if my destination is right next to me.
291-
if ( ( endPos - GetAbsOrigin()).Length() < MIN_JUMP_DISTANCE )
281+
if ( ( endPos - GetAbsOrigin()).Length() < asw_alien_jump_min_distance.GetFloat() )
292282
return false;
293283

294284
if ( HasSpawnFlags( SF_ANTLION_USE_GROUNDCHECKS ) )
@@ -316,9 +306,13 @@ bool CASW_Alien_Jumper::IsJumpLegal( const Vector &startPos, const Vector &apex,
316306
}
317307
}
318308

319-
return BaseClass::IsJumpLegal( startPos, apex, endPos, MAX_JUMP_RISE, MAX_JUMP_DROP, MAX_JUMP_DISTANCE );
309+
return BaseClass::IsJumpLegal( startPos, apex, endPos, asw_alien_jump_max_rise.GetFloat(), asw_alien_jump_max_drop.GetFloat(), asw_alien_jump_max_distance.GetFloat() );
320310
}
321311

312+
float CASW_Alien_Jumper::GetMaxJumpSpeed() const
313+
{
314+
return asw_alien_jump_max_speed.GetFloat();
315+
}
322316

323317
//-----------------------------------------------------------------------------
324318
// Purpose:
@@ -361,14 +355,14 @@ bool CASW_Alien_Jumper::ShouldJump( void )
361355
UTIL_PredictedPosition( GetEnemy(), flDot * 2.5f, &vecPredictedPos );
362356

363357
// Don't jump if we're already near the target
364-
if ( ( GetAbsOrigin() - vecPredictedPos ).LengthSqr() < (512*512) )
358+
if ( ( GetAbsOrigin() - vecPredictedPos ).LengthSqr() < Square( asw_alien_jump_min_predicted_distance.GetFloat() ) )
365359
return false;
366360

367361
//Don't retest if the target hasn't moved enough
368362
//FIXME: Check your own distance from last attempt as well
369-
if ( ( ( m_vecLastJumpAttempt - vecPredictedPos ).LengthSqr() ) < (128*128) )
363+
if ( ( ( m_vecLastJumpAttempt - vecPredictedPos ).LengthSqr() ) < Square( asw_alien_jump_min_distance_between_attempts.GetFloat() ) )
370364
{
371-
m_flJumpTime = gpGlobals->curtime + random->RandomFloat( 1.0f, 2.0f );
365+
m_flJumpTime = gpGlobals->curtime + random->RandomFloat( 1.0f, 2.0f );
372366
return false;
373367
}
374368

@@ -377,7 +371,7 @@ bool CASW_Alien_Jumper::ShouldJump( void )
377371
float flDist = VectorNormalize( targetDir );
378372

379373
// don't jump at target it it's very close
380-
if (flDist < ANTLION_JUMP_MIN)
374+
if ( flDist < asw_alien_jump_min_distance.GetFloat() )
381375
return false;
382376

383377
Vector targetPos = vecPredictedPos + ( targetDir * (GetHullWidth()*4.0f) );
@@ -501,15 +495,6 @@ bool CASW_Alien_Jumper::CheckLanding( void )
501495
CreateDust( false );
502496
EmitSound( "ASW_Drone.Land" );
503497

504-
// asw todo: make the alien attack here?
505-
//if ( GetEnemy() && GetEnemy()->IsPlayer() )
506-
//{
507-
//CBasePlayer *pPlayer = ToBasePlayer( GetEnemy() );
508-
509-
//if ( pPlayer && pPlayer->IsInAVehicle() == false )
510-
//MeleeAttack( ANTLION_MELEE1_RANGE, sk_antlion_swipe_damage.GetFloat(), QAngle( 4.0f, 0.0f, 0.0f ), Vector( -250.0f, 1.0f, 1.0f ) );
511-
//}
512-
513498
SetAbsVelocity( GetAbsVelocity() * 0.33f );
514499
return false;
515500
}
@@ -629,9 +614,6 @@ bool CASW_Alien_Jumper::DoJumpOffHead()
629614
m_bDisableJump = false;
630615
CapabilitiesAdd( bits_CAP_MOVE_JUMP );
631616

632-
//Vector vecDest = RandomVector(-1, 1);
633-
//vecDest.z = 0;
634-
//vecDest *= random->RandomFloat(30, 100);
635617
Vector vecDest;
636618
AngleVectors(GetAbsAngles(), &vecDest);
637619
vecDest *= 200.0f;
@@ -793,4 +775,4 @@ AI_BEGIN_CUSTOM_NPC( asw_alien_jumper, CASW_Alien_Jumper )
793775
" Interrupts"
794776
" COND_TASK_FAILED"
795777
)
796-
AI_END_CUSTOM_NPC()
778+
AI_END_CUSTOM_NPC()

src/game/server/swarm/asw_alien_jumper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class CASW_Alien_Jumper : public CASW_Alien_Shover
3434
void BuildScheduleTestBits( void );
3535
void PrescheduleThink();
3636
bool IsJumpLegal( const Vector &startPos, const Vector &apex, const Vector &endPos ) const;
37-
float GetMaxJumpSpeed() const { return 1024.0f; }
37+
float GetMaxJumpSpeed() const;
3838
float m_flNextJumpPushTime;
3939
void InputDisableJump( inputdata_t &inputdata );
4040
void InputEnableJump( inputdata_t &inputdata );

0 commit comments

Comments
 (0)