mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2025-01-26 13:47:56 +03:00
Added WIP options for vehicle driver AI node usage and combat behavior
This commit is contained in:
parent
763c836d45
commit
cd4a4c8f70
@ -78,6 +78,10 @@ void CNPC_APCDriver::Spawn( void )
|
||||
m_flTimeLastSeenEnemy = -NPC_APCDRIVER_REMEMBER_TIME;
|
||||
CapabilitiesClear();
|
||||
CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK1 | bits_CAP_INNATE_RANGE_ATTACK2 );
|
||||
#ifdef MAPBASE
|
||||
if (m_bUseAINodes)
|
||||
CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_MOVE_SHOOT );
|
||||
#endif
|
||||
m_bFiringDisabled = false;
|
||||
}
|
||||
|
||||
|
@ -57,6 +57,11 @@ BEGIN_DATADESC( CNPC_VehicleDriver )
|
||||
//DEFINE_KEYFIELD( m_flInitialSpeed, FIELD_FLOAT ),
|
||||
DEFINE_FIELD( m_flSteering, FIELD_FLOAT ),
|
||||
|
||||
#ifdef MAPBASE
|
||||
DEFINE_KEYFIELD( m_bUseAINodes, FIELD_BOOLEAN, "UseAINodes" ),
|
||||
DEFINE_KEYFIELD( m_bUseCombatAI, FIELD_BOOLEAN, "UseCombatAI" ),
|
||||
#endif
|
||||
|
||||
// Inputs
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDriversMaxSpeed", InputSetDriversMaxSpeed ),
|
||||
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDriversMinSpeed", InputSetDriversMinSpeed ),
|
||||
@ -67,6 +72,11 @@ BEGIN_DATADESC( CNPC_VehicleDriver )
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "StopFiring", InputStopFiring ),
|
||||
DEFINE_INPUTFUNC( FIELD_STRING, "GotoPathCorner", InputGotoPathCorner ),
|
||||
|
||||
#ifdef MAPBASE
|
||||
DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetUseAINodes", InputSetUseAINodes ),
|
||||
DEFINE_INPUTFUNC( FIELD_BOOLEAN, "SetUseCombatAI", InputSetUseCombatAI ),
|
||||
#endif
|
||||
|
||||
END_DATADESC()
|
||||
|
||||
LINK_ENTITY_TO_CLASS( npc_vehicledriver, CNPC_VehicleDriver );
|
||||
@ -129,7 +139,11 @@ void CNPC_VehicleDriver::Spawn( void )
|
||||
m_flDistanceAlongSpline = 0.2;
|
||||
m_pCurrentWaypoint = m_pNextWaypoint = NULL;
|
||||
|
||||
#ifdef MAPBASE
|
||||
GetNavigator()->SetPathcornerPathfinding( m_bUseAINodes );
|
||||
#else
|
||||
GetNavigator()->SetPathcornerPathfinding( false );
|
||||
#endif
|
||||
|
||||
NPCInit();
|
||||
|
||||
@ -277,6 +291,12 @@ int CNPC_VehicleDriver::SelectSchedule( void )
|
||||
|
||||
case NPC_STATE_COMBAT:
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
// Don't use vehicle schedules if we're allowed to use any combat AI
|
||||
if (m_bUseCombatAI)
|
||||
break;
|
||||
#endif
|
||||
|
||||
if ( HasCondition(COND_NEW_ENEMY) || HasCondition( COND_ENEMY_DEAD ) )
|
||||
return BaseClass::SelectSchedule();
|
||||
|
||||
@ -378,6 +398,15 @@ int CNPC_VehicleDriver::TranslateSchedule( int scheduleType )
|
||||
return SCHED_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef MAPBASE
|
||||
case SCHED_TAKE_COVER_FROM_ENEMY:
|
||||
{
|
||||
if (m_bUseCombatAI)
|
||||
return SCHED_VEHICLEDRIVER_COMBAT_WAIT;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
|
||||
return BaseClass::TranslateSchedule(scheduleType);
|
||||
@ -722,8 +751,8 @@ bool CNPC_VehicleDriver::OverridePathMove( float flInterval )
|
||||
// Have we reached our target? See if we've passed the current waypoint's plane.
|
||||
Vector vecAbsMins, vecAbsMaxs;
|
||||
#ifdef MAPBASE
|
||||
vecAbsMins = m_hVehicleEntity->CollisionProp()->OBBMins();
|
||||
vecAbsMaxs = m_hVehicleEntity->CollisionProp()->OBBMaxs();
|
||||
//vecAbsMins = m_hVehicleEntity->CollisionProp()->OBBMins();
|
||||
//vecAbsMaxs = m_hVehicleEntity->CollisionProp()->OBBMaxs();
|
||||
m_hVehicleEntity->CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs );
|
||||
#else
|
||||
CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs );
|
||||
@ -1139,6 +1168,26 @@ void CNPC_VehicleDriver::InputGotoPathCorner( inputdata_t &inputdata )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNPC_VehicleDriver::InputSetUseAINodes( inputdata_t &inputdata )
|
||||
{
|
||||
m_bUseAINodes = inputdata.value.Bool();
|
||||
GetNavigator()->SetPathcornerPathfinding( m_bUseAINodes );
|
||||
m_bUseAINodes ? CapabilitiesAdd( bits_CAP_MOVE_GROUND | bits_CAP_MOVE_SHOOT ) : CapabilitiesRemove( bits_CAP_MOVE_GROUND | bits_CAP_MOVE_SHOOT );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNPC_VehicleDriver::InputSetUseCombatAI( inputdata_t &inputdata )
|
||||
{
|
||||
m_bUseCombatAI = inputdata.value.Bool();
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Schedules
|
||||
|
@ -168,6 +168,11 @@ public:
|
||||
void InputStopFiring( inputdata_t &inputdata );
|
||||
void InputGotoPathCorner( inputdata_t &inputdata );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void InputSetUseAINodes( inputdata_t &inputdata );
|
||||
void InputSetUseCombatAI( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
public:
|
||||
string_t m_iszVehicleName;
|
||||
IServerVehicle *m_pVehicleInterface;
|
||||
@ -187,6 +192,11 @@ public:
|
||||
float m_flDriversMaxSpeed;
|
||||
float m_flDriversMinSpeed;
|
||||
|
||||
#ifdef MAPBASE
|
||||
bool m_bUseAINodes = false;
|
||||
bool m_bUseCombatAI = false;
|
||||
#endif
|
||||
|
||||
// Speed
|
||||
float m_flMaxSpeed; // Maximum speed this driver will go
|
||||
float m_flGoalSpeed; // Desired speed
|
||||
|
Loading…
x
Reference in New Issue
Block a user