mirror of
https://github.com/ValveSoftware/source-sdk-2013.git
synced 2025-04-09 03:24:52 +00:00
Merge 767204db08
into 0565403b15
This commit is contained in:
commit
403f4fdbff
16 changed files with 588 additions and 573 deletions
|
@ -42,9 +42,8 @@ HSCRIPT INextBotComponent::GetScriptInstance()
|
|||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
#ifdef TF_DLL
|
||||
DEFINE_SCRIPT_INSTANCE_HELPER( INextBotComponent, &g_NextBotComponentScriptInstanceHelper )
|
||||
#endif
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC_ROOT( INextBotComponent, "Next bot component" )
|
||||
DEFINE_SCRIPTFUNC( Reset, "Resets the internal update state" )
|
||||
DEFINE_SCRIPTFUNC( ComputeUpdateInterval, "Recomputes the component update interval" )
|
||||
|
|
|
@ -7,21 +7,15 @@
|
|||
#define _NEXT_BOT_LOCOMOTION_INTERFACE_H_
|
||||
|
||||
#include "NextBotComponentInterface.h"
|
||||
#ifdef TF_DLL
|
||||
#include "tf/nav_mesh/tf_nav_area.h"
|
||||
|
||||
#ifdef USE_NAV_MESH
|
||||
#include "nav_area.h"
|
||||
#else
|
||||
class CTFNavArea;
|
||||
|
||||
inline HSCRIPT ToHScript( CNavArea *pArea )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline HSCRIPT ToHScript( CTFNavArea *pArea )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline CNavArea *ToNavArea( HSCRIPT hScript )
|
||||
{
|
||||
return NULL;
|
||||
|
|
|
@ -39,10 +39,6 @@
|
|||
#include "saverestoretypes.h"
|
||||
#include "nav_mesh.h"
|
||||
|
||||
#ifdef TF_DLL
|
||||
#include "nav_mesh/tf_nav_area.h"
|
||||
#endif
|
||||
|
||||
#ifdef NEXT_BOT
|
||||
#include "NextBot/NextBotManager.h"
|
||||
#endif
|
||||
|
@ -3622,11 +3618,7 @@ float CBaseCombatCharacter::GetTimeSinceLastInjury( int team /*= TEAM_ANY */ ) c
|
|||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CBaseCombatCharacter::ScriptGetLastKnownArea( void ) const
|
||||
{
|
||||
#ifdef TF_DLL
|
||||
return ToHScript( GetLastKnownArea() );
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CBaseCombatCharacter, CBaseFlex, "Base combat characters." )
|
||||
|
|
|
@ -156,6 +156,377 @@ size_t CNavVectorNoEditAllocator::GetSize( void *pMem )
|
|||
return m_nBytesCurrent;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
// Script access to manipulate the nav
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
DEFINE_SCRIPT_INSTANCE_HELPER( CNavArea, &g_NavAreaScriptInstanceHelper )
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC_ROOT( CNavArea, "Navigation areas class" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetID, "GetID", "Get area ID." )
|
||||
DEFINE_SCRIPTFUNC( GetAttributes, "Get area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( SetAttributes, "Set area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( HasAttributes, "Has area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( RemoveAttributes, "Removes area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( GetCenter, "Get center origin of area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCorner, "GetCorner", "( corner ) - Get corner origin of area" )
|
||||
DEFINE_SCRIPTFUNC( FindRandomSpot, "Get random origin within extent of area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptConnectToArea, "ConnectTo", "( area, dir ) - Connect this area to given area in given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptDisconnectArea, "Disconnect", "( area ) - Disconnect this area from given area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsConnectedArea, "IsConnected", "( area, dir ) - Return true if given area is connected in given direction" )
|
||||
DEFINE_SCRIPTFUNC( IsDamaging, "Return true if continuous damage (ie: fire) is in this area" )
|
||||
DEFINE_SCRIPTFUNC( MarkAsDamaging, "( duration ) - Mark this area is damaging for the next 'duration' seconds" )
|
||||
DEFINE_SCRIPTFUNC( IsBlocked, "( team ) - Return true if team is blocked in this area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptMarkAsBlocked, "MarkAsBlocked", "( team ) - Mark this area as blocked for team" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentCount, "GetAdjacentCount", "( dir ) - Get the number of adjacent areas in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentAreas, "GetAdjacentAreas", "( dir, table ) - Fills a passed in table with all adjacent areas in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentArea, "GetAdjacentArea", "( dir, n ) - Return the i'th adjacent area in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRandomAdjacentArea, "GetRandomAdjacentArea", "( dir ) - Return a random adjacent area in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetIncomingConnections, "GetIncomingConnections", "( dir, table ) - Fills a passed in table with areas connected TO this area by a ONE-WAY link (ie: we have no connection back to them)" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptAddIncomingConnection, "AddIncomingConnection", "( area, dir ) - Add areas that connect TO this area by a ONE-WAY link" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPlaceName, "GetPlaceName", "Get place name" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetPlaceName, "SetPlaceName", "( name ) - Set place name" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptComputeDirection, "ComputeDirection", "( point ) - Return direction from this area to the given point" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPlayerCount, "GetPlayerCount", "( team ) - Return number of players of given team currently within this area (team of zero means any/all)" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsOverlapping, "IsOverlapping", "( area ) - Return true if 'area' overlaps our 2D extents" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsOverlappingOrigin, "IsOverlappingOrigin", "( pos, tolerance ) - Return true if 'pos' is within 2D extents of area" )
|
||||
DEFINE_SCRIPTFUNC( IsPotentiallyVisibleToTeam, "( team ) - Return true if any portion of this area is visible to anyone on the given team" )
|
||||
DEFINE_SCRIPTFUNC( IsCompletelyVisibleToTeam, "( team ) - Return true if given area is completely visible from somewhere in this area by someone on the team" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsEdge, "IsEdge", "( dir ) - Return true if there are no bi-directional links on the given side" )
|
||||
DEFINE_SCRIPTFUNC( HasAvoidanceObstacle, "( maxheight ) - Returns true if there's a large, immobile object obstructing this area" )
|
||||
DEFINE_SCRIPTFUNC( MarkObstacleToAvoid, "( height ) - Marks the obstructed status of the nav area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptContains, "Contains", "( area ) - Return true if other area is on or above this area, but no others" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptContainsOrigin, "ContainsOrigin", "( point ) - Return true if given point is on or above this area, but no others" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetParent, "GetParent", "Returns the area just prior to this one in the search path" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetParentHow, "GetParentHow", "Returns how we get from parent to us" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( DrawFilled, "DebugDrawFilled", "Draw area as a filled rect of the given color" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptUnblockArea, "UnblockArea", "Unblocks this area" )
|
||||
DEFINE_SCRIPTFUNC( IsRoughlySquare, "Return true if this area is approximately square" )
|
||||
DEFINE_SCRIPTFUNC( IsFlat, "Return true if this area is approximately flat" )
|
||||
DEFINE_SCRIPTFUNC( IsDegenerate, "Return true if this area is badly formed" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsVisible, "IsVisible", "( point ) - Return true if area is visible from the given eyepoint" )
|
||||
DEFINE_SCRIPTFUNC( GetSizeX, "Return the area size along the X axis" )
|
||||
DEFINE_SCRIPTFUNC( GetSizeY, "Return the area size along the Y axis" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetZ, "GetZ", "( pos ) - Return Z of area at (x,y) of 'pos'" )
|
||||
DEFINE_SCRIPTFUNC( GetDistanceSquaredToPoint, "( pos ) - Return shortest distance between point and this area" )
|
||||
DEFINE_SCRIPTFUNC( IsUnderwater, "Return true if area is underwater" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsCoplanar, "IsCoplanar", "( area ) - Return true if this area and given area are approximately co-planar" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveOrthogonalConnections, "RemoveOrthogonalConnections", "( dir ) - Removes all connections in directions to left and right of specified direction" )
|
||||
DEFINE_SCRIPTFUNC( GetAvoidanceObstacleHeight, "Returns the maximum height of the obstruction above the ground" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetElevator, "GetElevator", "Returns the elevator if in an elevator's path" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetElevatorAreas, "GetElevatorAreas", "( table ) - Fills table with a collection of areas reachable via elevator from this area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDoor, "GetDoor", "Returns the door entity above the area" )
|
||||
DEFINE_SCRIPTFUNC( IsBottleneck, "Returns true if area is a bottleneck" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptComputeClosestPointInPortal, "ComputeClosestPointInPortal", "Compute closest point within the portal between to adjacent areas." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
|
||||
HSCRIPT CNavArea::GetScriptInstance()
|
||||
{
|
||||
if ( !m_hScriptInstance )
|
||||
{
|
||||
m_hScriptInstance = g_pScriptVM->RegisterInstance( GetScriptDesc(), this );
|
||||
}
|
||||
return m_hScriptInstance;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptGetAdjacentAreas( int dir, HSCRIPT hTable )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS || !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector *pConnections = GetAdjacentAreas( (NavDirType)dir );
|
||||
FOR_EACH_VEC( (*pConnections), it )
|
||||
{
|
||||
NavConnect connect = (*pConnections)[ it ];
|
||||
CNavArea *area = connect.area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CNavArea::ScriptGetAdjacentArea( int dir, int i )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetAdjacentArea( (NavDirType)dir, i ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CNavArea::ScriptGetRandomAdjacentArea( int dir )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetRandomAdjacentArea( (NavDirType)dir ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptGetIncomingConnections( int dir, HSCRIPT hTable )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS || !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector *pConnections = GetIncomingConnections( (NavDirType)dir );
|
||||
FOR_EACH_VEC( (*pConnections), it )
|
||||
{
|
||||
NavConnect connect = (*pConnections)[ it ];
|
||||
CNavArea *area = connect.area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptAddIncomingConnection( HSCRIPT hSource, int incomingEdgeDir )
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hSource );
|
||||
if ( incomingEdgeDir >= NUM_DIRECTIONS || !pArea )
|
||||
return;
|
||||
|
||||
AddIncomingConnection( pArea, (NavDirType)incomingEdgeDir );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptConnectToArea( HSCRIPT hArea, int dir )
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( dir >= NUM_DIRECTIONS || !pArea )
|
||||
return;
|
||||
|
||||
if ( dir == -1 )
|
||||
{
|
||||
Vector center;
|
||||
float halfWidth;
|
||||
NavDirType autoDir = ComputeLargestPortal( pArea, ¢er, &halfWidth );
|
||||
if ( autoDir != NUM_DIRECTIONS )
|
||||
{
|
||||
ConnectTo( pArea, autoDir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectTo( pArea, (NavDirType)dir );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptDisconnectArea( HSCRIPT hArea )
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return;
|
||||
|
||||
Disconnect( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CNavArea::ScriptIsConnectedArea( HSCRIPT hArea, int dir )
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( dir > NUM_DIRECTIONS || !pArea )
|
||||
return false;
|
||||
|
||||
if ( dir == -1 )
|
||||
dir = NUM_DIRECTIONS;
|
||||
return IsConnected( pArea, (NavDirType) dir );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptMarkAsBlocked( int teamID )
|
||||
{
|
||||
m_attributeFlags |= NAV_MESH_NAV_BLOCKER;
|
||||
MarkAsBlocked( teamID, NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CNavArea::ScriptGetPlaceName()
|
||||
{
|
||||
return TheNavMesh->PlaceToName( GetPlace() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptSetPlaceName( const char *pszName )
|
||||
{
|
||||
if ( !pszName )
|
||||
{
|
||||
SetPlace( UNDEFINED_PLACE );
|
||||
return;
|
||||
}
|
||||
|
||||
Place place = TheNavMesh->PartialNameToPlace( pszName );
|
||||
if ( place == UNDEFINED_PLACE )
|
||||
return;
|
||||
|
||||
SetPlace( place );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CNavArea::ScriptIsOverlapping( HSCRIPT hArea ) const
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return IsOverlapping( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CNavArea::ScriptContains( HSCRIPT hArea ) const
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return Contains( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CNavArea::ScriptGetParent()
|
||||
{
|
||||
return ToHScript( GetParent() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int CNavArea::ScriptComputeDirection( const Vector &point ) const
|
||||
{
|
||||
Vector pos = point;
|
||||
return ComputeDirection( &pos );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptUnblockArea( void )
|
||||
{
|
||||
UnblockArea();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CNavArea::ScriptIsCoplanar( HSCRIPT hArea ) const
|
||||
{
|
||||
CNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return IsCoplanar( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptGetElevatorAreas( HSCRIPT hTable )
|
||||
{
|
||||
if ( !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector &pElevatorAreas = GetElevatorAreas();
|
||||
FOR_EACH_VEC( pElevatorAreas, it )
|
||||
{
|
||||
CNavArea *area = pElevatorAreas[ it ].area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Vector CNavArea::ScriptComputeClosestPointInPortal( HSCRIPT to, int dir, const Vector &fromPos ) const
|
||||
{
|
||||
CNavArea *pNavArea = ToNavArea( to );
|
||||
if ( !pNavArea )
|
||||
{
|
||||
DevMsg( "ComputeClosestPointInPortal: the to area was invalid. Returning origin.\n" );
|
||||
return vec3_origin;
|
||||
}
|
||||
|
||||
Vector closePos = vec3_origin;
|
||||
this->ComputeClosestPointInPortal( pNavArea, (NavDirType)dir, fromPos, &closePos );
|
||||
return closePos;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CNavArea::ScriptRemoveOrthogonalConnections( int dir )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return;
|
||||
|
||||
RemoveOrthogonalConnections( (NavDirType) dir );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Invoked when a door is created
|
||||
*/
|
||||
void CNavArea::OnDoorCreated( CBaseEntity *door )
|
||||
{
|
||||
m_hDoor = door;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// return a door contained in this area
|
||||
CBaseEntity * CNavArea::GetDoor( void ) const
|
||||
{
|
||||
return m_hDoor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Return a random spot in this area
|
||||
*/
|
||||
Vector CNavArea::FindRandomSpot( void ) const
|
||||
{
|
||||
const float margin = 25.0f;
|
||||
Vector spot;
|
||||
|
||||
if (GetSizeX() < 2.0f * margin || GetSizeY() < 2.0f * margin)
|
||||
{
|
||||
spot = GetCenter();
|
||||
spot.z += 10.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
spot.x = GetCorner( NORTH_WEST ).x + margin + RandomFloat( 0.0f, GetSizeX() - 2.0f * margin );
|
||||
spot.y = GetCorner( NORTH_WEST ).y + margin + RandomFloat( 0.0f, GetSizeY() - 2.0f * margin );
|
||||
spot.z = GetZ( spot.x, spot.y ) + 10.0f;
|
||||
}
|
||||
|
||||
return spot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* A bottleneck is a small nav area with connections on only two opposing sides (ie: a doorway)
|
||||
*/
|
||||
bool CNavArea::IsBottleneck( void ) const
|
||||
{
|
||||
const float narrow = 2.1f * GenerationStepSize;
|
||||
|
||||
if ( GetAdjacentCount( NORTH ) == 0 && GetAdjacentCount( SOUTH ) == 0 &&
|
||||
GetAdjacentCount( EAST ) > 0 && GetAdjacentCount( WEST ) > 0 )
|
||||
{
|
||||
if ( GetSizeY() < narrow )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( GetAdjacentCount( NORTH ) > 0 && GetAdjacentCount( SOUTH ) > 0 &&
|
||||
GetAdjacentCount( EAST ) == 0 && GetAdjacentCount( WEST ) == 0 )
|
||||
{
|
||||
if ( GetSizeX() < narrow )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
void CNavArea::CompressIDs( void )
|
||||
{
|
||||
|
@ -172,7 +543,6 @@ void CNavArea::CompressIDs( void )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Constructor used during normal runtime.
|
||||
|
@ -248,6 +618,9 @@ CNavArea::CNavArea( void )
|
|||
m_funcNavCostVector.RemoveAll();
|
||||
|
||||
m_nVisTestCounter = (uint32)-1;
|
||||
|
||||
m_hDoor = NULL;
|
||||
m_hScriptInstance = NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
@ -531,6 +904,12 @@ public:
|
|||
*/
|
||||
CNavArea::~CNavArea()
|
||||
{
|
||||
if ( g_pScriptVM && m_hScriptInstance )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||
m_hScriptInstance = NULL;
|
||||
}
|
||||
|
||||
// spot encounters aren't owned by anything else, so free them up here
|
||||
m_spotEncounters.PurgeAndDeleteElements();
|
||||
|
||||
|
|
|
@ -256,6 +256,8 @@ class CNavArea : protected CNavAreaCriticalData
|
|||
public:
|
||||
DECLARE_CLASS_NOBASE( CNavArea )
|
||||
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
|
||||
CNavArea( void );
|
||||
virtual ~CNavArea();
|
||||
|
||||
|
@ -639,6 +641,48 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
//- Script access to nav functions ------------------------------------------------------------------
|
||||
HSCRIPT GetScriptInstance();
|
||||
bool IsBottleneck( void ) const;
|
||||
Vector FindRandomSpot( void ) const; // return a random spot in this area
|
||||
void OnDoorCreated( CBaseEntity *door ); // invoked when a door is created
|
||||
CBaseEntity *GetDoor( void ) const; // return a door contained in this area
|
||||
|
||||
int ScriptGetID( void ) const { return (int)GetID(); }
|
||||
void ScriptGetAdjacentAreas( int dir, HSCRIPT hTable );
|
||||
HSCRIPT ScriptGetAdjacentArea( int dir, int i );
|
||||
HSCRIPT ScriptGetRandomAdjacentArea( int dir );
|
||||
void ScriptGetIncomingConnections( int dir, HSCRIPT hTable );
|
||||
void ScriptAddIncomingConnection( HSCRIPT hSource, int incomingEdgeDir );
|
||||
void ScriptConnectToArea( HSCRIPT hArea, int dir );
|
||||
void ScriptDisconnectArea( HSCRIPT hArea );
|
||||
bool ScriptIsConnectedArea( HSCRIPT hArea, int dir );
|
||||
Vector ScriptGetCorner( int corner ) const { return GetCorner( (NavCornerType)corner ); }
|
||||
void ScriptMarkAsBlocked( int teamID );
|
||||
int ScriptGetAdjacentCount( int dir ) const { return GetAdjacentCount( (NavDirType)dir ); }
|
||||
const char* ScriptGetPlaceName();
|
||||
void ScriptSetPlaceName( const char* pszName );
|
||||
int ScriptComputeDirection( const Vector &point ) const;
|
||||
int ScriptGetPlayerCount( int teamID ) const { return GetPlayerCount( teamID ); }
|
||||
bool ScriptIsOverlapping( HSCRIPT hArea ) const;
|
||||
bool ScriptIsOverlappingOrigin( const Vector &pos, float tolerance ) const { return IsOverlapping( pos, tolerance ); }
|
||||
bool ScriptIsEdge( int dir ) const { return IsEdge( (NavDirType) dir ); }
|
||||
bool ScriptContains( HSCRIPT hArea ) const;
|
||||
bool ScriptContainsOrigin( const Vector &pos ) const { return Contains( pos ); }
|
||||
float ScriptComputeGroundHeightChange( HSCRIPT hArea );
|
||||
HSCRIPT ScriptGetParent( void );
|
||||
int ScriptGetParentHow( void ) const { return GetParentHow(); }
|
||||
void ScriptUnblockArea( void );
|
||||
bool ScriptIsVisible( const Vector &eye ) const { return IsVisible( eye ); }
|
||||
float ScriptGetZ( const Vector &pos ) const { return GetZ( pos ); }
|
||||
bool ScriptIsCoplanar( HSCRIPT hArea ) const;
|
||||
bool ScriptIsContiguous( HSCRIPT hArea ) const;
|
||||
float ScriptComputeAdjacentConnectionHeightChange( HSCRIPT hArea ) const;
|
||||
void ScriptRemoveOrthogonalConnections( int dir );
|
||||
HSCRIPT ScriptGetElevator( void ) { return ToHScript( (CBaseEntity*)GetElevator() ); }
|
||||
void ScriptGetElevatorAreas( HSCRIPT hTable );
|
||||
HSCRIPT ScriptGetDoor( void ) { return ToHScript( GetDoor() ); }
|
||||
Vector ScriptComputeClosestPointInPortal( HSCRIPT to, int dir, const Vector &fromPos ) const;
|
||||
|
||||
private:
|
||||
friend class CNavMesh;
|
||||
|
@ -757,11 +801,25 @@ private:
|
|||
static uint32 s_nCurrVisTestCounter;
|
||||
|
||||
CUtlVector< CHandle< CFuncNavCost > > m_funcNavCostVector; // active, overlapping cost entities
|
||||
|
||||
EHANDLE m_hDoor;
|
||||
|
||||
HSCRIPT m_hScriptInstance;
|
||||
};
|
||||
|
||||
typedef CUtlVector< CNavArea * > NavAreaVector;
|
||||
extern NavAreaVector TheNavAreas;
|
||||
|
||||
inline HSCRIPT ToHScript( CNavArea *pArea )
|
||||
{
|
||||
return ( pArea ) ? pArea->GetScriptInstance() : NULL;
|
||||
}
|
||||
|
||||
template <> ScriptClassDesc_t *GetScriptDesc<CNavArea>( CNavArea * );
|
||||
inline CNavArea *ToNavArea( HSCRIPT hScript )
|
||||
{
|
||||
return ( IsValid( hScript ) ) ? (CNavArea *)g_pScriptVM->GetInstanceValue( hScript, GetScriptDescForClass(CNavArea) ) : NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -22,10 +22,6 @@
|
|||
#include "functorutils.h"
|
||||
#include "nav_pathfind.h"
|
||||
|
||||
#ifdef TF_DLL
|
||||
#include "tf/nav_mesh/tf_nav_area.h"
|
||||
#endif
|
||||
|
||||
#ifdef NEXT_BOT
|
||||
#include "NextBot/NavMeshEntities/func_nav_prerequisite.h"
|
||||
#endif
|
||||
|
@ -3127,40 +3123,32 @@ END_SCRIPTDESC();
|
|||
//--------------------------------------------------------------------------------------------------------
|
||||
HSCRIPT CNavMesh::ScriptGetNavAreaByID( int areaID )
|
||||
{
|
||||
#ifdef TF_DLL
|
||||
CNavArea *area = GetNavAreaByID( areaID );
|
||||
if ( area )
|
||||
{
|
||||
return ToHScript( area );
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
HSCRIPT CNavMesh::ScriptGetNavArea( const Vector &pos, float beneathLimt )
|
||||
{
|
||||
#ifdef TF_DLL
|
||||
CNavArea *area = GetNavArea( pos, beneathLimt );
|
||||
if ( area )
|
||||
{
|
||||
return ToHScript( area );
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
HSCRIPT CNavMesh::ScriptGetNearestNavArea( const Vector &pos, float maxDist, bool checkLOS, bool checkGround )
|
||||
{
|
||||
#ifdef TF_DLL
|
||||
CNavArea *area = GetNearestNavArea( pos, false, maxDist, checkLOS, checkGround );
|
||||
if ( area )
|
||||
{
|
||||
return ToHScript( area );
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7782,6 +7782,23 @@ BEGIN_ENT_SCRIPTDESC( CBasePlayer, CBaseCombatCharacter, "The player entity." )
|
|||
DEFINE_SCRIPTFUNC( GetForceLocalDraw, "Gets the state of whether the player is being forced by SetForceLocalDraw to be drawn" )
|
||||
DEFINE_SCRIPTFUNC( GetScriptOverlayMaterial, "Gets the current view overlay material" )
|
||||
DEFINE_SCRIPTFUNC( SetScriptOverlayMaterial, "Sets a view overlay material" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetActiveWeapon, "GetActiveWeapon", "Get the player's current weapon" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_ShootPosition, "" ) // Needs this slim wrapper or the world falls apart on MSVC.
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_CanUse, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Equip, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Drop, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_DropEx, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Switch, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_SetLast, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( GetLastWeapon, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( IsFakeClient, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( AddHudHideFlags, "Hides a hud element based on Constants.FHideHUD." )
|
||||
DEFINE_SCRIPTFUNC( RemoveHudHideFlags, "Unhides a hud element based on Constants.FHideHUD." )
|
||||
DEFINE_SCRIPTFUNC( SetHudHideFlags, "Force hud hide flags to a value" )
|
||||
DEFINE_SCRIPTFUNC( GetHudHideFlags, "Gets current hidden hud elements" )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
void CStripWeapons::InputStripWeapons(inputdata_t &data)
|
||||
|
@ -9631,7 +9648,74 @@ void CBasePlayer::AdjustDrownDmg( int nAmount )
|
|||
}
|
||||
}
|
||||
|
||||
HSCRIPT CBasePlayer::ScriptGetActiveWeapon()
|
||||
{
|
||||
return ToHScript( GetActiveWeapon() );
|
||||
}
|
||||
|
||||
Vector CBasePlayer::ScriptWeapon_ShootPosition()
|
||||
{
|
||||
return this->Weapon_ShootPosition();
|
||||
}
|
||||
|
||||
bool CBasePlayer::ScriptWeapon_CanUse( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return false;
|
||||
|
||||
return this->Weapon_CanUse( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CBasePlayer::ScriptWeapon_Equip( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Equip( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CBasePlayer::ScriptWeapon_Drop( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Drop( pCombatWeapon, NULL, NULL );
|
||||
}
|
||||
|
||||
void CBasePlayer::ScriptWeapon_DropEx( HSCRIPT hWeapon, Vector vecTarget, Vector vecVelocity )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Drop( pCombatWeapon, &vecTarget, &vecVelocity );
|
||||
}
|
||||
|
||||
void CBasePlayer::ScriptWeapon_Switch( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Switch( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CBasePlayer::ScriptWeapon_SetLast( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_SetLast( pCombatWeapon );
|
||||
}
|
||||
|
||||
HSCRIPT CBasePlayer::ScriptGetLastWeapon()
|
||||
{
|
||||
return ToHScript( this->GetLastWeapon() );
|
||||
}
|
||||
|
||||
#if !defined(NO_STEAM)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -1221,6 +1221,11 @@ public:
|
|||
// NVNT sets weather a user should receive haptic device messages.
|
||||
virtual void SetHaptics(bool has) { m_bhasHaptics = has;}
|
||||
|
||||
void AddHudHideFlags(int flags) { m_Local.m_iHideHUD |= flags; }
|
||||
void RemoveHudHideFlags(int flags) { m_Local.m_iHideHUD &= ~flags; }
|
||||
void SetHudHideFlags(int flags) { m_Local.m_iHideHUD = flags; }
|
||||
int GetHudHideFlags() { return m_Local.m_iHideHUD; }
|
||||
|
||||
const char* GetScriptOverlayMaterial() const { return m_Local.m_szScriptOverlayMaterial; }
|
||||
void SetScriptOverlayMaterial( const char *pszMaterial )
|
||||
{
|
||||
|
@ -1237,6 +1242,19 @@ public:
|
|||
{
|
||||
SetScriptOverlayMaterial( inputdata.value.String() );
|
||||
}
|
||||
|
||||
HSCRIPT ScriptGetActiveWeapon( void );
|
||||
Vector ScriptWeapon_ShootPosition();
|
||||
bool ScriptWeapon_CanUse( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_Equip( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_Drop( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_DropEx( HSCRIPT hWeapon, Vector vecTarget, Vector vecVelocity );
|
||||
void ScriptWeapon_Switch( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_SetLast( HSCRIPT hWeapon );
|
||||
HSCRIPT ScriptGetLastWeapon();
|
||||
|
||||
bool ScriptIsFakeClient() const { return this->IsFakeClient(); }
|
||||
|
||||
private:
|
||||
// NVNT member variable holding if this user is using a haptic device.
|
||||
bool m_bhasHaptics;
|
||||
|
|
|
@ -293,7 +293,7 @@ public:
|
|||
|
||||
void SetHomeArea( CTFNavArea *area );
|
||||
CTFNavArea *GetHomeArea( void ) const;
|
||||
void ScriptSetHomeArea( HSCRIPT hScript ) { this->SetHomeArea( ToNavArea( hScript ) ); }
|
||||
void ScriptSetHomeArea( HSCRIPT hScript ) { this->SetHomeArea( ToTFNavArea( hScript ) ); }
|
||||
HSCRIPT ScriptGetHomeArea( void ) { return ToHScript( this->GetHomeArea() ); }
|
||||
|
||||
CObjectSentrygun *GetEnemySentry( void ) const; // if we've been attacked/killed by an enemy sentry, this will return it, otherwise NULL
|
||||
|
|
|
@ -31,380 +31,17 @@ ConVar tf_show_incursion_range_max( "tf_show_incursion_range_max", "0", FCVAR_CH
|
|||
// Script access to manipulate the nav
|
||||
//--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
DEFINE_SCRIPT_INSTANCE_HELPER( CTFNavArea, &g_NavAreaScriptInstanceHelper )
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC_ROOT( CTFNavArea, "Navigation areas class" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetID, "GetID", "Get area ID." )
|
||||
DEFINE_SCRIPTFUNC( GetAttributes, "Get area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( SetAttributes, "Set area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( HasAttributes, "Has area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( RemoveAttributes, "Removes area attribute bits" )
|
||||
BEGIN_ENT_SCRIPTDESC( CTFNavArea, CNavArea, "TF Navigation areas class" )
|
||||
DEFINE_SCRIPTFUNC( SetAttributeTF, "Set TF-specific area attributes" )
|
||||
DEFINE_SCRIPTFUNC( HasAttributeTF, "Has TF-specific area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( ClearAttributeTF, "Clear TF-specific area attribute bits" )
|
||||
DEFINE_SCRIPTFUNC( GetCenter, "Get center origin of area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetCorner, "GetCorner", "( corner ) - Get corner origin of area" )
|
||||
DEFINE_SCRIPTFUNC( FindRandomSpot, "Get random origin within extent of area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptConnectToArea, "ConnectTo", "( area, dir ) - Connect this area to given area in given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptDisconnectArea, "Disconnect", "( area ) - Disconnect this area from given area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsConnectedArea, "IsConnected", "( area, dir ) - Return true if given area is connected in given direction" )
|
||||
DEFINE_SCRIPTFUNC( IsDamaging, "Return true if continuous damage (ie: fire) is in this area" )
|
||||
DEFINE_SCRIPTFUNC( MarkAsDamaging, "( duration ) - Mark this area is damaging for the next 'duration' seconds" )
|
||||
DEFINE_SCRIPTFUNC( IsBlocked, "( team ) - Return true if team is blocked in this area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptMarkAsBlocked, "MarkAsBlocked", "( team ) - Mark this area as blocked for team" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentCount, "GetAdjacentCount", "( dir ) - Get the number of adjacent areas in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentAreas, "GetAdjacentAreas", "( dir, table ) - Fills a passed in table with all adjacent areas in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetAdjacentArea, "GetAdjacentArea", "( dir, n ) - Return the i'th adjacent area in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetRandomAdjacentArea, "GetRandomAdjacentArea", "( dir ) - Return a random adjacent area in the given direction" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetIncomingConnections, "GetIncomingConnections", "( dir, table ) - Fills a passed in table with areas connected TO this area by a ONE-WAY link (ie: we have no connection back to them)" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptAddIncomingConnection, "AddIncomingConnection", "( area, dir ) - Add areas that connect TO this area by a ONE-WAY link" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPlaceName, "GetPlaceName", "Get place name" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptSetPlaceName, "SetPlaceName", "( name ) - Set place name" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptComputeDirection, "ComputeDirection", "( point ) - Return direction from this area to the given point" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPlayerCount, "GetPlayerCount", "( team ) - Return number of players of given team currently within this area (team of zero means any/all)" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsOverlapping, "IsOverlapping", "( area ) - Return true if 'area' overlaps our 2D extents" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsOverlappingOrigin, "IsOverlappingOrigin", "( pos, tolerance ) - Return true if 'pos' is within 2D extents of area" )
|
||||
DEFINE_SCRIPTFUNC( IsPotentiallyVisibleToTeam, "( team ) - Return true if any portion of this area is visible to anyone on the given team" )
|
||||
DEFINE_SCRIPTFUNC( IsCompletelyVisibleToTeam, "( team ) - Return true if given area is completely visible from somewhere in this area by someone on the team" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsEdge, "IsEdge", "( dir ) - Return true if there are no bi-directional links on the given side" )
|
||||
DEFINE_SCRIPTFUNC( HasAvoidanceObstacle, "( maxheight ) - Returns true if there's a large, immobile object obstructing this area" )
|
||||
DEFINE_SCRIPTFUNC( MarkObstacleToAvoid, "( height ) - Marks the obstructed status of the nav area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptContains, "Contains", "( area ) - Return true if other area is on or above this area, but no others" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptContainsOrigin, "ContainsOrigin", "( point ) - Return true if given point is on or above this area, but no others" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetParent, "GetParent", "Returns the area just prior to this one in the search path" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetParentHow, "GetParentHow", "Returns how we get from parent to us" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( DrawFilled, "DebugDrawFilled", "Draw area as a filled rect of the given color" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptUnblockArea, "UnblockArea", "Unblocks this area" )
|
||||
DEFINE_SCRIPTFUNC( IsRoughlySquare, "Return true if this area is approximately square" )
|
||||
DEFINE_SCRIPTFUNC( IsFlat, "Return true if this area is approximately flat" )
|
||||
DEFINE_SCRIPTFUNC( IsDegenerate, "Return true if this area is badly formed" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsVisible, "IsVisible", "( point ) - Return true if area is visible from the given eyepoint" )
|
||||
DEFINE_SCRIPTFUNC( GetSizeX, "Return the area size along the X axis" )
|
||||
DEFINE_SCRIPTFUNC( GetSizeY, "Return the area size along the Y axis" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetZ, "GetZ", "( pos ) - Return Z of area at (x,y) of 'pos'" )
|
||||
DEFINE_SCRIPTFUNC( GetDistanceSquaredToPoint, "( pos ) - Return shortest distance between point and this area" )
|
||||
DEFINE_SCRIPTFUNC( IsUnderwater, "Return true if area is underwater" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptIsCoplanar, "IsCoplanar", "( area ) - Return true if this area and given area are approximately co-planar" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveOrthogonalConnections, "RemoveOrthogonalConnections", "( dir ) - Removes all connections in directions to left and right of specified direction" )
|
||||
DEFINE_SCRIPTFUNC( GetAvoidanceObstacleHeight, "Returns the maximum height of the obstruction above the ground" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetElevator, "GetElevator", "Returns the elevator if in an elevator's path" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetElevatorAreas, "GetElevatorAreas", "( table ) - Fills table with a collection of areas reachable via elevator from this area" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetDoor, "GetDoor", "Returns the door entity above the area" )
|
||||
DEFINE_SCRIPTFUNC( IsBottleneck, "Returns true if area is a bottleneck" )
|
||||
DEFINE_SCRIPTFUNC( IsValidForWanderingPopulation, "Returns true if area is valid for wandering population" )
|
||||
DEFINE_SCRIPTFUNC( GetTravelDistanceToBombTarget, "Gets the travel distance to the MvM bomb target" )
|
||||
DEFINE_SCRIPTFUNC( IsReachableByTeam, "Is this area reachable by the given team?" )
|
||||
DEFINE_SCRIPTFUNC( IsValidForWanderingPopulation, "Returns true if area is valid for wandering population" )
|
||||
DEFINE_SCRIPTFUNC( IsTFMarked, "Is this nav area marked with the current marking scope?" )
|
||||
DEFINE_SCRIPTFUNC( TFMark, "Mark this nav area with the current marking scope." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptComputeClosestPointInPortal, "ComputeClosestPointInPortal", "Compute closest point within the portal between to adjacent areas." )
|
||||
END_SCRIPTDESC();
|
||||
|
||||
HSCRIPT CTFNavArea::GetScriptInstance()
|
||||
{
|
||||
if ( !m_hScriptInstance )
|
||||
{
|
||||
m_hScriptInstance = g_pScriptVM->RegisterInstance( GetScriptDesc(), this );
|
||||
}
|
||||
return m_hScriptInstance;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptGetAdjacentAreas( int dir, HSCRIPT hTable )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS || !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector *pConnections = GetAdjacentAreas( (NavDirType)dir );
|
||||
FOR_EACH_VEC( (*pConnections), it )
|
||||
{
|
||||
NavConnect connect = (*pConnections)[ it ];
|
||||
CNavArea *area = connect.area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CTFNavArea::ScriptGetAdjacentArea( int dir, int i )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetAdjacentArea( (NavDirType)dir, i ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CTFNavArea::ScriptGetRandomAdjacentArea( int dir )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return NULL;
|
||||
|
||||
return ToHScript( GetRandomAdjacentArea( (NavDirType)dir ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptGetIncomingConnections( int dir, HSCRIPT hTable )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS || !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector *pConnections = GetIncomingConnections( (NavDirType)dir );
|
||||
FOR_EACH_VEC( (*pConnections), it )
|
||||
{
|
||||
NavConnect connect = (*pConnections)[ it ];
|
||||
CNavArea *area = connect.area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptAddIncomingConnection( HSCRIPT hSource, int incomingEdgeDir )
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hSource );
|
||||
if ( incomingEdgeDir >= NUM_DIRECTIONS || !pArea )
|
||||
return;
|
||||
|
||||
AddIncomingConnection( pArea, (NavDirType)incomingEdgeDir );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptConnectToArea( HSCRIPT hArea, int dir )
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( dir >= NUM_DIRECTIONS || !pArea )
|
||||
return;
|
||||
|
||||
if ( dir == -1 )
|
||||
{
|
||||
Vector center;
|
||||
float halfWidth;
|
||||
NavDirType autoDir = ComputeLargestPortal( pArea, ¢er, &halfWidth );
|
||||
if ( autoDir != NUM_DIRECTIONS )
|
||||
{
|
||||
ConnectTo( pArea, autoDir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectTo( pArea, (NavDirType)dir );
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptDisconnectArea( HSCRIPT hArea )
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return;
|
||||
|
||||
Disconnect( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTFNavArea::ScriptIsConnectedArea( HSCRIPT hArea, int dir )
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( dir > NUM_DIRECTIONS || !pArea )
|
||||
return false;
|
||||
|
||||
if ( dir == -1 )
|
||||
dir = NUM_DIRECTIONS;
|
||||
return IsConnected( pArea, (NavDirType) dir );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptMarkAsBlocked( int teamID )
|
||||
{
|
||||
m_attributeFlags |= NAV_MESH_NAV_BLOCKER;
|
||||
MarkAsBlocked( teamID, NULL );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CTFNavArea::ScriptGetPlaceName()
|
||||
{
|
||||
return TheNavMesh->PlaceToName( GetPlace() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptSetPlaceName( const char *pszName )
|
||||
{
|
||||
if ( !pszName )
|
||||
{
|
||||
SetPlace( UNDEFINED_PLACE );
|
||||
return;
|
||||
}
|
||||
|
||||
Place place = TheNavMesh->PartialNameToPlace( pszName );
|
||||
if ( place == UNDEFINED_PLACE )
|
||||
return;
|
||||
|
||||
SetPlace( place );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTFNavArea::ScriptIsOverlapping( HSCRIPT hArea ) const
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return IsOverlapping( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTFNavArea::ScriptContains( HSCRIPT hArea ) const
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return Contains( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
HSCRIPT CTFNavArea::ScriptGetParent()
|
||||
{
|
||||
return ToHScript( GetParent() );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
int CTFNavArea::ScriptComputeDirection( const Vector &point ) const
|
||||
{
|
||||
Vector pos = point;
|
||||
return ComputeDirection( &pos );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptUnblockArea( void )
|
||||
{
|
||||
UnblockArea();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CTFNavArea::ScriptIsCoplanar( HSCRIPT hArea ) const
|
||||
{
|
||||
CTFNavArea *pArea = ToNavArea( hArea );
|
||||
if ( !pArea )
|
||||
return false;
|
||||
|
||||
return IsCoplanar( pArea );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptGetElevatorAreas( HSCRIPT hTable )
|
||||
{
|
||||
if ( !IsValid( hTable ) )
|
||||
return;
|
||||
|
||||
const NavConnectVector &pElevatorAreas = GetElevatorAreas();
|
||||
FOR_EACH_VEC( pElevatorAreas, it )
|
||||
{
|
||||
CNavArea *area = pElevatorAreas[ it ].area;
|
||||
if ( area )
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, CFmtStr( "area%i", it ), ToHScript( area ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Vector CTFNavArea::ScriptComputeClosestPointInPortal( HSCRIPT to, int dir, const Vector &fromPos ) const
|
||||
{
|
||||
CTFNavArea *pNavArea = ToNavArea( to );
|
||||
if ( !pNavArea )
|
||||
{
|
||||
DevMsg( "ComputeClosestPointInPortal: the to CTFNavArea was invalid. Returning origin.\n" );
|
||||
return vec3_origin;
|
||||
}
|
||||
|
||||
Vector closePos = vec3_origin;
|
||||
this->ComputeClosestPointInPortal( pNavArea, (NavDirType)dir, fromPos, &closePos );
|
||||
return closePos;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CTFNavArea::ScriptRemoveOrthogonalConnections( int dir )
|
||||
{
|
||||
if ( dir >= NUM_DIRECTIONS )
|
||||
return;
|
||||
|
||||
RemoveOrthogonalConnections( (NavDirType) dir );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Invoked when a door is created
|
||||
*/
|
||||
void CTFNavArea::OnDoorCreated( CBaseEntity *door )
|
||||
{
|
||||
m_hDoor = door;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
// return a door contained in this area
|
||||
CBaseEntity *CTFNavArea::GetDoor( void ) const
|
||||
{
|
||||
return m_hDoor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* Return a random spot in this area
|
||||
*/
|
||||
Vector CTFNavArea::FindRandomSpot( void ) const
|
||||
{
|
||||
const float margin = 25.0f;
|
||||
Vector spot;
|
||||
|
||||
if (GetSizeX() < 2.0f * margin || GetSizeY() < 2.0f * margin)
|
||||
{
|
||||
spot = GetCenter();
|
||||
spot.z += 10.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
spot.x = GetCorner( NORTH_WEST ).x + margin + RandomFloat( 0.0f, GetSizeX() - 2.0f * margin );
|
||||
spot.y = GetCorner( NORTH_WEST ).y + margin + RandomFloat( 0.0f, GetSizeY() - 2.0f * margin );
|
||||
spot.z = GetZ( spot.x, spot.y ) + 10.0f;
|
||||
}
|
||||
|
||||
return spot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* A bottleneck is a small nav area with connections on only two opposing sides (ie: a doorway)
|
||||
*/
|
||||
bool CTFNavArea::IsBottleneck( void ) const
|
||||
{
|
||||
const float narrow = 2.1f * GenerationStepSize;
|
||||
|
||||
if ( GetAdjacentCount( NORTH ) == 0 && GetAdjacentCount( SOUTH ) == 0 &&
|
||||
GetAdjacentCount( EAST ) > 0 && GetAdjacentCount( WEST ) > 0 )
|
||||
{
|
||||
if ( GetSizeY() < narrow )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if ( GetAdjacentCount( NORTH ) > 0 && GetAdjacentCount( SOUTH ) > 0 &&
|
||||
GetAdjacentCount( EAST ) == 0 && GetAdjacentCount( WEST ) == 0 )
|
||||
{
|
||||
if ( GetSizeX() < narrow )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
CTFNavArea::CTFNavArea( void )
|
||||
{
|
||||
|
@ -414,16 +51,10 @@ CTFNavArea::CTFNavArea( void )
|
|||
m_distanceToBombTarget = 0.0f;
|
||||
m_TFMark = 0;
|
||||
m_invasionSearchMarker = (unsigned int)-1;
|
||||
m_hScriptInstance = NULL;
|
||||
}
|
||||
|
||||
CTFNavArea::~CTFNavArea( void )
|
||||
{
|
||||
if ( g_pScriptVM && m_hScriptInstance )
|
||||
{
|
||||
g_pScriptVM->RemoveInstance( m_hScriptInstance );
|
||||
m_hScriptInstance = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -63,6 +63,8 @@ class CTFNavArea : public CNavArea
|
|||
public:
|
||||
DECLARE_CLASS( CTFNavArea, CNavArea );
|
||||
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
|
||||
CTFNavArea( void );
|
||||
~CTFNavArea( void );
|
||||
|
||||
|
@ -129,50 +131,6 @@ public:
|
|||
// Distance for MvM bomb delivery
|
||||
float GetTravelDistanceToBombTarget( void ) const;
|
||||
|
||||
//- Script access to nav functions ------------------------------------------------------------------
|
||||
DECLARE_ENT_SCRIPTDESC();
|
||||
HSCRIPT GetScriptInstance();
|
||||
bool IsBottleneck( void ) const;
|
||||
Vector FindRandomSpot( void ) const; // return a random spot in this area
|
||||
void OnDoorCreated( CBaseEntity *door ); // invoked when a door is created
|
||||
CBaseEntity *GetDoor( void ) const; // return a door contained in this area
|
||||
|
||||
int ScriptGetID( void ) const { return (int)GetID(); }
|
||||
void ScriptGetAdjacentAreas( int dir, HSCRIPT hTable );
|
||||
HSCRIPT ScriptGetAdjacentArea( int dir, int i );
|
||||
HSCRIPT ScriptGetRandomAdjacentArea( int dir );
|
||||
void ScriptGetIncomingConnections( int dir, HSCRIPT hTable );
|
||||
void ScriptAddIncomingConnection( HSCRIPT hSource, int incomingEdgeDir );
|
||||
void ScriptConnectToArea( HSCRIPT hArea, int dir );
|
||||
void ScriptDisconnectArea( HSCRIPT hArea );
|
||||
bool ScriptIsConnectedArea( HSCRIPT hArea, int dir );
|
||||
Vector ScriptGetCorner( int corner ) const { return GetCorner( (NavCornerType)corner ); }
|
||||
void ScriptMarkAsBlocked( int teamID );
|
||||
int ScriptGetAdjacentCount( int dir ) const { return GetAdjacentCount( (NavDirType)dir ); }
|
||||
const char* ScriptGetPlaceName();
|
||||
void ScriptSetPlaceName( const char* pszName );
|
||||
int ScriptComputeDirection( const Vector &point ) const;
|
||||
int ScriptGetPlayerCount( int teamID ) const { return GetPlayerCount( teamID ); }
|
||||
bool ScriptIsOverlapping( HSCRIPT hArea ) const;
|
||||
bool ScriptIsOverlappingOrigin( const Vector &pos, float tolerance ) const { return IsOverlapping( pos, tolerance ); }
|
||||
bool ScriptIsEdge( int dir ) const { return IsEdge( (NavDirType) dir ); }
|
||||
bool ScriptContains( HSCRIPT hArea ) const;
|
||||
bool ScriptContainsOrigin( const Vector &pos ) const { return Contains( pos ); }
|
||||
float ScriptComputeGroundHeightChange( HSCRIPT hArea );
|
||||
HSCRIPT ScriptGetParent( void );
|
||||
int ScriptGetParentHow( void ) const { return GetParentHow(); }
|
||||
void ScriptUnblockArea( void );
|
||||
bool ScriptIsVisible( const Vector &eye ) const { return IsVisible( eye ); }
|
||||
float ScriptGetZ( const Vector &pos ) const { return GetZ( pos ); }
|
||||
bool ScriptIsCoplanar( HSCRIPT hArea ) const;
|
||||
bool ScriptIsContiguous( HSCRIPT hArea ) const;
|
||||
float ScriptComputeAdjacentConnectionHeightChange( HSCRIPT hArea ) const;
|
||||
void ScriptRemoveOrthogonalConnections( int dir );
|
||||
HSCRIPT ScriptGetElevator( void ) { return ToHScript( (CBaseEntity*)GetElevator() ); }
|
||||
void ScriptGetElevatorAreas( HSCRIPT hTable );
|
||||
HSCRIPT ScriptGetDoor( void ) { return ToHScript( GetDoor() ); }
|
||||
Vector ScriptComputeClosestPointInPortal( HSCRIPT to, int dir, const Vector &fromPos ) const;
|
||||
|
||||
private:
|
||||
friend class CTFNavMesh;
|
||||
|
||||
|
@ -195,27 +153,11 @@ private:
|
|||
// Raid mode -------------------------------------------------
|
||||
|
||||
float m_distanceToBombTarget;
|
||||
|
||||
EHANDLE m_hDoor;
|
||||
|
||||
HSCRIPT m_hScriptInstance;
|
||||
};
|
||||
|
||||
inline HSCRIPT ToHScript( CNavArea *pArea )
|
||||
inline CTFNavArea* ToTFNavArea( HSCRIPT hScript )
|
||||
{
|
||||
CTFNavArea* pTerrorArea = ( CTFNavArea* )pArea;
|
||||
return ( pTerrorArea ) ? pTerrorArea->GetScriptInstance() : NULL;
|
||||
}
|
||||
|
||||
inline HSCRIPT ToHScript( CTFNavArea *pArea )
|
||||
{
|
||||
return ( pArea ) ? pArea->GetScriptInstance() : NULL;
|
||||
}
|
||||
|
||||
template <> ScriptClassDesc_t *GetScriptDesc<CTFNavArea>( CTFNavArea * );
|
||||
inline CTFNavArea *ToNavArea( HSCRIPT hScript )
|
||||
{
|
||||
return ( IsValid( hScript ) ) ? (CTFNavArea *)g_pScriptVM->GetInstanceValue( hScript, GetScriptDescForClass(CTFNavArea) ) : NULL;
|
||||
return static_cast< CTFNavArea* >( ToNavArea( hScript ) );
|
||||
}
|
||||
|
||||
inline float CTFNavArea::GetTravelDistanceToBombTarget( void ) const
|
||||
|
|
|
@ -542,8 +542,6 @@ BEGIN_DATADESC( CTFPlayer )
|
|||
END_DATADESC()
|
||||
|
||||
BEGIN_ENT_SCRIPTDESC( CTFPlayer, CBaseMultiplayerPlayer , "Team Fortress 2 Player" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetActiveWeapon, "GetActiveWeapon", "Get the player's current weapon" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( ForceRespawn, "Force respawns the player" )
|
||||
DEFINE_SCRIPTFUNC( ForceRegenerateAndRespawn, "Force regenerates and respawns the player" )
|
||||
DEFINE_SCRIPTFUNC( Regenerate, "Resupplies a player. If regen health/ammo is set, clears negative conds, gives back player health/ammo" )
|
||||
|
@ -670,25 +668,11 @@ BEGIN_ENT_SCRIPTDESC( CTFPlayer, CBaseMultiplayerPlayer , "Team Fortress 2 Playe
|
|||
DEFINE_SCRIPTFUNC_NAMED( ScriptRemoveAllItems, "RemoveAllItems", "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( UpdateSkin, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_ShootPosition, "" ) // Needs this slim wrapper or the world falls apart on MSVC.
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_CanUse, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Equip, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Drop, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_DropEx, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_Switch, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( Weapon_SetLast, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( GetLastWeapon, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( EquipWearableViewModel, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( IsFakeClient, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( GetBotType, "" )
|
||||
DEFINE_SCRIPTFUNC_WRAPPED( IsBotOfType, "" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( AddHudHideFlags, "Hides a hud element based on Constants.FHideHUD." )
|
||||
DEFINE_SCRIPTFUNC( RemoveHudHideFlags, "Unhides a hud element based on Constants.FHideHUD." )
|
||||
DEFINE_SCRIPTFUNC( SetHudHideFlags, "Force hud hide flags to a value" )
|
||||
DEFINE_SCRIPTFUNC( GetHudHideFlags, "Gets current hidden hud elements" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( IsTaunting, "" )
|
||||
DEFINE_SCRIPTFUNC( DoTauntAttack, "" )
|
||||
DEFINE_SCRIPTFUNC( CancelTaunt, "" )
|
||||
|
@ -22994,70 +22978,6 @@ HSCRIPT CTFPlayer::ScriptGetDisguiseTarget()
|
|||
return ToHScript( m_Shared.GetDisguiseTarget() );
|
||||
}
|
||||
|
||||
Vector CTFPlayer::ScriptWeapon_ShootPosition()
|
||||
{
|
||||
return this->Weapon_ShootPosition();
|
||||
}
|
||||
|
||||
bool CTFPlayer::ScriptWeapon_CanUse( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return false;
|
||||
|
||||
return this->Weapon_CanUse( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptWeapon_Equip( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Equip( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptWeapon_Drop( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Drop( pCombatWeapon, NULL, NULL );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptWeapon_DropEx( HSCRIPT hWeapon, Vector vecTarget, Vector vecVelocity )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Drop( pCombatWeapon, &vecTarget, &vecVelocity );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptWeapon_Switch( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_Switch( pCombatWeapon );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptWeapon_SetLast( HSCRIPT hWeapon )
|
||||
{
|
||||
CBaseCombatWeapon *pCombatWeapon = ScriptToEntClass< CBaseCombatWeapon >( hWeapon );
|
||||
if ( !pCombatWeapon )
|
||||
return;
|
||||
|
||||
this->Weapon_SetLast( pCombatWeapon );
|
||||
}
|
||||
|
||||
HSCRIPT CTFPlayer::ScriptGetLastWeapon()
|
||||
{
|
||||
return ToHScript(this->GetLastWeapon() );
|
||||
}
|
||||
|
||||
void CTFPlayer::ScriptEquipWearableViewModel( HSCRIPT hWearableViewModel )
|
||||
{
|
||||
CTFWearableVM *pVM = ScriptToEntClass< CTFWearableVM >( hWearableViewModel );
|
||||
|
|
|
@ -734,8 +734,6 @@ public:
|
|||
bool IsViewingCYOAPDA( void ) const { return m_bViewingCYOAPDA; }
|
||||
bool IsRegenerating( void ) const { return m_bRegenerating; }
|
||||
|
||||
HSCRIPT ScriptGetActiveWeapon( void ) { return ToHScript( GetActiveTFWeapon() ); }
|
||||
|
||||
void ScriptAddCond( int nCond );
|
||||
void ScriptAddCondEx( int nCond, float flDuration, HSCRIPT hProvider );
|
||||
void ScriptRemoveCond( int nCond );
|
||||
|
@ -809,16 +807,7 @@ public:
|
|||
RemoveAllItems( bRemoveSuit );
|
||||
}
|
||||
|
||||
Vector ScriptWeapon_ShootPosition();
|
||||
bool ScriptWeapon_CanUse( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_Equip( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_Drop( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_DropEx( HSCRIPT hWeapon, Vector vecTarget, Vector vecVelocity );
|
||||
void ScriptWeapon_Switch( HSCRIPT hWeapon );
|
||||
void ScriptWeapon_SetLast( HSCRIPT hWeapon );
|
||||
HSCRIPT ScriptGetLastWeapon();
|
||||
void ScriptEquipWearableViewModel( HSCRIPT hWearableViewModel );
|
||||
bool ScriptIsFakeClient() const { return this->IsFakeClient(); }
|
||||
int ScriptGetBotType() const { return this->GetBotType(); }
|
||||
bool ScriptIsBotOfType(int nType) const { return this->IsBotOfType(nType); }
|
||||
|
||||
|
@ -1428,11 +1417,6 @@ public:
|
|||
HSCRIPT ScriptGetGrapplingHookTarget() const { return ToHScript( m_hGrapplingHookTarget.Get() ); }
|
||||
void ScriptSetGrapplingHookTarget( HSCRIPT pTarget, bool bShouldBleed ) { return SetGrapplingHookTarget( ToEnt( pTarget ), bShouldBleed ); }
|
||||
|
||||
void AddHudHideFlags(int flags) { m_Local.m_iHideHUD |= flags; }
|
||||
void RemoveHudHideFlags(int flags) { m_Local.m_iHideHUD &= ~flags; }
|
||||
void SetHudHideFlags(int flags) { m_Local.m_iHideHUD = flags; }
|
||||
int GetHudHideFlags() { return m_Local.m_iHideHUD; }
|
||||
|
||||
bool IsUsingActionSlot() const { return m_bUsingActionSlot; }
|
||||
|
||||
void SetSecondaryLastWeapon( CBaseCombatWeapon *pSecondaryLastWeapon ) { m_hSecondaryLastWeapon = pSecondaryLastWeapon; }
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "sceneentity.h" // for exposing scene precache function
|
||||
#include "isaverestore.h"
|
||||
#include "gamerules.h"
|
||||
#include "player_voice_listener.h"
|
||||
#include "particle_parse.h"
|
||||
#include "usermessages.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
|
@ -30,11 +31,19 @@
|
|||
#include "coordsize.h"
|
||||
#include "team.h"
|
||||
|
||||
#ifdef USE_NAV_MESH
|
||||
#include "nav_mesh.h"
|
||||
#include "nav_area.h"
|
||||
#endif
|
||||
|
||||
#ifdef NEXT_BOT
|
||||
#include "NextBot/NextBotInterface.h"
|
||||
#endif
|
||||
|
||||
#ifdef TF_DLL
|
||||
#include "tf/tf_gamerules.h"
|
||||
#include "nav_mesh/tf_nav_mesh.h"
|
||||
#include "nav_mesh/tf_nav_area.h"
|
||||
#include "NextBot/NextBotLocomotionInterface.h"
|
||||
#include "bot/tf_bot.h"
|
||||
#endif
|
||||
|
||||
|
@ -2616,8 +2625,9 @@ bool VScriptServerInit()
|
|||
{
|
||||
GameRules()->RegisterScriptFunctions();
|
||||
}
|
||||
|
||||
#ifdef TF_DLL
|
||||
|
||||
g_pScriptVM->RegisterInstance( &PlayerVoiceListener(), "PlayerVoiceListener" );
|
||||
#ifdef USE_NAV_MESH
|
||||
g_pScriptVM->RegisterInstance( TheNavMesh, "NavMesh" );
|
||||
#endif
|
||||
g_pScriptVM->RegisterInstance( &g_ScriptEntityIterator, "Entities" );
|
||||
|
@ -2634,7 +2644,7 @@ bool VScriptServerInit()
|
|||
#define DECLARE_SCRIPT_CONST_NAMED( type, name, x ) g_pScriptVM->SetValue( (HSCRIPT)vConstantsTable_##type, name, x );
|
||||
#define DECLARE_SCRIPT_CONST( type, x ) DECLARE_SCRIPT_CONST_NAMED( type, #x, x )
|
||||
#define REGISTER_SCRIPT_CONST_TABLE( x ) g_pScriptVM->SetValue( (HSCRIPT) vConstantsTable, #x, vConstantsTable_##x );
|
||||
#ifdef TF_DLL
|
||||
|
||||
DECLARE_SCRIPT_CONST_TABLE( EScriptRecipientFilter )
|
||||
DECLARE_SCRIPT_CONST( EScriptRecipientFilter, RECIPIENT_FILTER_DEFAULT )
|
||||
DECLARE_SCRIPT_CONST( EScriptRecipientFilter, RECIPIENT_FILTER_PAS_ATTENUATION )
|
||||
|
@ -2645,6 +2655,7 @@ DECLARE_SCRIPT_CONST( EScriptRecipientFilter, RECIPIENT_FILTER_GLOBAL )
|
|||
DECLARE_SCRIPT_CONST( EScriptRecipientFilter, RECIPIENT_FILTER_TEAM )
|
||||
REGISTER_SCRIPT_CONST_TABLE( EScriptRecipientFilter )
|
||||
|
||||
#ifdef TF_DLL
|
||||
DECLARE_SCRIPT_CONST_TABLE( ETFCond )
|
||||
DECLARE_SCRIPT_CONST( ETFCond, TF_COND_INVALID )
|
||||
DECLARE_SCRIPT_CONST( ETFCond, TF_COND_AIMING )
|
||||
|
@ -2825,7 +2836,9 @@ DECLARE_SCRIPT_CONST_NAMED( ETFBotDifficultyType, "HARD", CTFBot::DifficultyType
|
|||
DECLARE_SCRIPT_CONST_NAMED( ETFBotDifficultyType, "EXPERT", CTFBot::DifficultyType::EXPERT )
|
||||
DECLARE_SCRIPT_CONST_NAMED( ETFBotDifficultyType, "NUM_DIFFICULTY_LEVELS", CTFBot::DifficultyType::NUM_DIFFICULTY_LEVELS )
|
||||
REGISTER_SCRIPT_CONST_TABLE( ETFBotDifficultyType )
|
||||
#endif
|
||||
|
||||
#ifdef USE_NAV_MESH
|
||||
DECLARE_SCRIPT_CONST_TABLE( ENavDirType )
|
||||
DECLARE_SCRIPT_CONST( ENavDirType, NORTH )
|
||||
DECLARE_SCRIPT_CONST( ENavDirType, EAST )
|
||||
|
@ -2889,6 +2902,7 @@ DECLARE_SCRIPT_CONST( FNavAttributeType, NAV_MESH_FUNC_COST )
|
|||
DECLARE_SCRIPT_CONST( FNavAttributeType, NAV_MESH_HAS_ELEVATOR )
|
||||
DECLARE_SCRIPT_CONST( FNavAttributeType, NAV_MESH_NAV_BLOCKER )
|
||||
REGISTER_SCRIPT_CONST_TABLE( FNavAttributeType )
|
||||
#endif
|
||||
|
||||
DECLARE_SCRIPT_CONST_TABLE( FButtons )
|
||||
DECLARE_SCRIPT_CONST( FButtons, IN_ATTACK )
|
||||
|
@ -2932,15 +2946,18 @@ DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_CROSSHAIR )
|
|||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_VEHICLE_CROSSHAIR )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_INVEHICLE )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_BONUS_PROGRESS )
|
||||
#ifdef TF_DLL
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_BUILDING_STATUS )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_CLOAK_AND_FEIGN )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_PIPES_AND_CHARGE )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_METAL )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_TARGET_ID )
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_MATCH_STATUS )
|
||||
#endif
|
||||
DECLARE_SCRIPT_CONST( FHideHUD, HIDEHUD_BITCOUNT )
|
||||
REGISTER_SCRIPT_CONST_TABLE( FHideHUD )
|
||||
|
||||
#ifdef TF_DLL
|
||||
DECLARE_SCRIPT_CONST_TABLE( FTaunts )
|
||||
DECLARE_SCRIPT_CONST( FTaunts, TAUNT_BASE_WEAPON )
|
||||
DECLARE_SCRIPT_CONST( FTaunts, TAUNT_MISC_ITEM )
|
||||
|
@ -2948,6 +2965,7 @@ DECLARE_SCRIPT_CONST( FTaunts, TAUNT_SHOW_ITEM )
|
|||
DECLARE_SCRIPT_CONST( FTaunts, TAUNT_LONG )
|
||||
DECLARE_SCRIPT_CONST( FTaunts, TAUNT_SPECIAL )
|
||||
REGISTER_SCRIPT_CONST_TABLE( FTaunts )
|
||||
#endif
|
||||
|
||||
DECLARE_SCRIPT_CONST_TABLE( EHitGroup )
|
||||
DECLARE_SCRIPT_CONST( EHitGroup, HITGROUP_GENERIC )
|
||||
|
@ -3276,14 +3294,17 @@ DECLARE_SCRIPT_CONST( ETFTeam, TEAM_INVALID )
|
|||
DECLARE_SCRIPT_CONST( ETFTeam, TEAM_UNASSIGNED )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TEAM_SPECTATOR )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TEAM_SPECTATOR )
|
||||
#ifdef TF_DLL
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_RED )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_BLUE )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_COUNT )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_PVE_INVADERS )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_PVE_DEFENDERS )
|
||||
DECLARE_SCRIPT_CONST( ETFTeam, TF_TEAM_PVE_INVADERS_GIANTS )
|
||||
#endif
|
||||
REGISTER_SCRIPT_CONST_TABLE( ETFTeam )
|
||||
|
||||
#ifdef TF_DLL
|
||||
// ETFDmgCustom
|
||||
DECLARE_SCRIPT_CONST_TABLE( ETFDmgCustom )
|
||||
DECLARE_SCRIPT_CONST( ETFDmgCustom, TF_DMG_CUSTOM_NONE )
|
||||
|
@ -3464,6 +3485,7 @@ DECLARE_SCRIPT_CONST( FTFNavAttributeType, TF_NAV_DOOR_ALWAYS_BLOCKS )
|
|||
DECLARE_SCRIPT_CONST( FTFNavAttributeType, TF_NAV_UNBLOCKABLE )
|
||||
DECLARE_SCRIPT_CONST( FTFNavAttributeType, TF_NAV_PERSISTENT_ATTRIBUTES )
|
||||
REGISTER_SCRIPT_CONST_TABLE( FTFNavAttributeType )
|
||||
#endif
|
||||
|
||||
DECLARE_SCRIPT_CONST_TABLE( EHudNotify )
|
||||
DECLARE_SCRIPT_CONST( EHudNotify, HUD_PRINTNOTIFY )
|
||||
|
@ -3472,9 +3494,11 @@ DECLARE_SCRIPT_CONST( EHudNotify, HUD_PRINTTALK )
|
|||
DECLARE_SCRIPT_CONST( EHudNotify, HUD_PRINTCENTER )
|
||||
REGISTER_SCRIPT_CONST_TABLE( EHudNotify )
|
||||
|
||||
#ifdef TF_DLL
|
||||
DECLARE_SCRIPT_CONST_TABLE( EBotType )
|
||||
DECLARE_SCRIPT_CONST( EBotType, TF_BOT_TYPE )
|
||||
REGISTER_SCRIPT_CONST_TABLE( EBotType )
|
||||
#endif
|
||||
|
||||
DECLARE_SCRIPT_CONST_TABLE( Math )
|
||||
DECLARE_SCRIPT_CONST_NAMED( Math, "Epsilon", FLT_EPSILON)
|
||||
|
@ -3494,7 +3518,7 @@ DECLARE_SCRIPT_CONST( Server, MAX_PLAYERS )
|
|||
DECLARE_SCRIPT_CONST( Server, DIST_EPSILON )
|
||||
DECLARE_SCRIPT_CONST_NAMED( Server, "ConstantNamingConvention", "Constants are named as follows: F -> flags, E -> enums, (nothing) -> random values/constants" )
|
||||
REGISTER_SCRIPT_CONST_TABLE( Server )
|
||||
#endif
|
||||
|
||||
g_pScriptVM->SetValue( "Constants", vConstantsTable );
|
||||
|
||||
if ( scriptLanguage == SL_SQUIRREL )
|
||||
|
@ -4165,16 +4189,18 @@ void *CBaseEntityScriptInstanceHelper::BindOnRead( HSCRIPT hInstance, void *pOld
|
|||
|
||||
CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
|
||||
|
||||
#ifdef TF_DLL
|
||||
#ifdef USE_NAV_MESH
|
||||
bool CNavAreaScriptInstanceHelper::ToString( void *p, char *pBuf, int bufSize )
|
||||
{
|
||||
CTFNavArea *pArea = (CTFNavArea *)p;
|
||||
CNavArea *pArea = (CNavArea *)p;
|
||||
V_snprintf( pBuf, bufSize, "([%u] Area)", pArea->GetID() );
|
||||
return true;
|
||||
}
|
||||
|
||||
CNavAreaScriptInstanceHelper g_NavAreaScriptInstanceHelper;
|
||||
#endif
|
||||
|
||||
#ifdef NEXT_BOT
|
||||
bool INextBotComponentScriptInstanceHelper::ToString( void *p, char *pBuf, int bufSize )
|
||||
{
|
||||
INextBotComponent *pNextBotComponent = (INextBotComponent *)p;
|
||||
|
|
|
@ -31,14 +31,16 @@ class CBaseEntityScriptInstanceHelper : public IScriptInstanceHelper
|
|||
|
||||
extern CBaseEntityScriptInstanceHelper g_BaseEntityScriptInstanceHelper;
|
||||
|
||||
#ifdef TF_DLL
|
||||
#ifdef USE_NAV_MESH
|
||||
class CNavAreaScriptInstanceHelper : public IScriptInstanceHelper
|
||||
{
|
||||
bool ToString( void *p, char *pBuf, int bufSize );
|
||||
};
|
||||
|
||||
extern CNavAreaScriptInstanceHelper g_NavAreaScriptInstanceHelper;
|
||||
#endif
|
||||
|
||||
#ifdef NEXT_BOT
|
||||
class INextBotComponentScriptInstanceHelper : public IScriptInstanceHelper
|
||||
{
|
||||
bool ToString( void *p, char *pBuf, int bufSize );
|
||||
|
|
|
@ -22431,8 +22431,6 @@ void CTFGameRules::RegisterScriptFunctions()
|
|||
|
||||
TF_GAMERULES_SCRIPT_FUNC( ForceEnableUpgrades, "Whether to force on MvM-styled upgrades on/off. 0 -> default, 1 -> force off, 2 -> force on" );
|
||||
TF_GAMERULES_SCRIPT_FUNC( ForceEscortPushLogic, "Forces payload pushing logic. 0 -> default, 1 -> force off, 2 -> force on" );
|
||||
|
||||
g_pScriptVM->RegisterInstance( &PlayerVoiceListener(), "PlayerVoiceListener" );
|
||||
}
|
||||
|
||||
#endif // GAME_DLL
|
||||
|
|
Loading…
Reference in a new issue