add lua scripts to the download file list

fixed sentrygun not being able to retarget closer targets
fixed sentrygun to favor all visible players over buildables
This commit is contained in:
drevil 2007-10-19 04:37:26 +00:00
parent 54b4a348e5
commit 3e9f94be1a
11 changed files with 81 additions and 33 deletions

View File

@ -1372,7 +1372,8 @@ void CBaseAnimating::UpdateStepOrigin()
if (toAbs.z == 0.0)
{
CAI_BaseNPC *pNPC = MyNPCPointer();
// FIXME: There needs to be a default step height somewhere
// FIXME: There needs to be a default step height somewhere
float height = 18.0f;
if (pNPC)
{

View File

@ -20,6 +20,8 @@
#include "doors.h"
#include "recipientfilter.h"
#include "triggers.h"
#include "filesystem.h"
#include "sharedInterface.h"
// Lua includes
extern "C"
@ -363,23 +365,26 @@ namespace FFLib
strcat(realscript, script);
strcat(realscript, ".lua");
*/
Q_snprintf( realscript, sizeof( realscript ), "maps/includes/%s.lua", script );
//////////////////////////////////////////////////////////////////////////
// Try a precache, rumor has it this will cause the engine to send the lua files to clients
if(PRECACHE_LUA_FILES)
{
if(filesystem->FileExists(realscript))
{
Util_AddDownload(realscript);
}
}
//////////////////////////////////////////////////////////////////////////
if( !CFFScriptManager::LoadFile( _scriptman.GetLuaState(), realscript ) )
{
// Try looking in the maps directory
Q_snprintf( realscript, sizeof( realscript ), "maps/%s.lua", script );
if(CFFScriptManager::LoadFile( _scriptman.GetLuaState(), realscript ))
{
// Try a precache, rumor has it this will cause the engine to send the lua files to clients
//engine->PrecacheGeneric(realscript, true);
}
CFFScriptManager::LoadFile( _scriptman.GetLuaState(), realscript );
}
//else
//{
// // Try a precache, rumor has it this will cause the engine to send the lua files to clients
// engine->PrecacheGeneric(realscript, true);
//}
}
else
{

View File

@ -216,15 +216,20 @@ void CFFScriptManager::LevelInit(const char* szMapName)
if ( !filename[0] )
Q_snprintf( filename, sizeof(filename), "maps/%s.lua", szMapName );
//////////////////////////////////////////////////////////////////////////
// Try a precache, rumor has it this will cause the engine to send the lua files to clients
if(PRECACHE_LUA_FILES)
{
if(filesystem->FileExists(filename))
{
Util_AddDownload(filename);
}
}
//////////////////////////////////////////////////////////////////////////
m_ScriptExists = LoadFile(L, filename);
EndScriptLoad();
// Try a precache, rumor has it this will cause the engine to send the lua files to clients
/*if(m_ScriptExists)
{
engine->PrecacheGeneric(filename, true);
}*/
// spawn the helper entity
CFFEntitySystemHelper::Create();
}

View File

@ -10,6 +10,8 @@
#include "checksum_crc.h"
#endif
#define PRECACHE_LUA_FILES 1
/////////////////////////////////////////////////////////////////////////////
// forward declarations
struct lua_State;

View File

@ -500,24 +500,41 @@ CBaseEntity *SG_IsBetterTarget( CBaseEntity *cur, CBaseEntity *latest, float dis
return cur;
if( !cur )
{
lastdistance = distance;
return latest;
}
// A player is always preferable to a buildable
if( latest->IsPlayer() && !cur->IsPlayer() )
{
lastdistance = distance;
return latest;
}
// If we're on a player already, don't consider non players
// Do we want to do this?
if(cur->IsPlayer() && !latest->IsPlayer())
return cur;
// Check radio tagged players
if( latest->IsPlayer() && cur->IsPlayer() )
{
if( ToFFPlayer( latest )->IsRadioTagged() && !ToFFPlayer( cur )->IsRadioTagged() )
{
lastdistance = distance;
return latest;
}
else if( !ToFFPlayer( latest )->IsRadioTagged() && ToFFPlayer( cur )->IsRadioTagged() )
return cur;
}
// Go for the nearest
if( distance < lastdistance )
{
lastdistance = distance;
return latest;
}
return cur;
}

View File

@ -34,6 +34,7 @@
#include "ndebugoverlay.h"
#include "engine/ivdebugoverlay.h"
#include "datacache/imdlcache.h"
#include "networkstringtable_gamedll.h"
#include "util.h"
// memdbgon must be the last include file in a .cpp file!!!
@ -3100,6 +3101,24 @@ void CC_CollisionTest( void )
}
static ConCommand collision_test("collision_test", CC_CollisionTest, "Tests collision system", FCVAR_CHEAT );
bool Util_AddDownload(const char *pszFile)
{
INetworkStringTable *pDownloadablesTable = networkstringtable->FindTable( "downloadables" );
if ( pDownloadablesTable )
{
bool bSave = engine->LockNetworkStringTables( false );
int iRet = pDownloadablesTable->FindStringIndex( pszFile );
//Don't add duplicates.
if ( iRet == INVALID_STRING_INDEX )
{
pDownloadablesTable->AddString( pszFile, strlen( pszFile ) + 1 );
engine->LockNetworkStringTables( bSave );
return true;
}
}
return false;
}

View File

@ -616,4 +616,6 @@ AngularImpulse WorldToLocalRotation( const VMatrix &localToWorld, const Vector &
bool UTIL_LoadAndSpawnEntitiesFromScript( CUtlVector <CBaseEntity*> &entities, const char *pScriptFile, const char *pBlock, bool bActivate = true );
bool Util_AddDownload(const char *pszFile);
#endif // UTIL_H

View File

@ -1,14 +1,16 @@
////////////////////////////////////////////////////////////////////////////////
//
// $LastChangedBy: DrEvil $
// $LastChangedDate: 2007-03-07 08:28:59 -0800 (Wed, 07 Mar 2007) $
// $LastChangedRevision: 1697 $
// $LastChangedBy: drevil $
// $LastChangedDate: 2007-10-16 21:53:00 -0700 (Tue, 16 Oct 2007) $
// $LastChangedRevision: 2149 $
//
////////////////////////////////////////////////////////////////////////////////
#ifndef __MESSAGEHELPER_H__
#define __MESSAGEHELPER_H__
#include <assert.h>
//////////////////////////////////////////////////////////////////////////
struct SubscriberHandle

View File

@ -1,8 +1,8 @@
////////////////////////////////////////////////////////////////////////////////
//
// $LastChangedBy: DrEvil $
// $LastChangedDate: 2007-08-31 23:25:33 -0700 (Fri, 31 Aug 2007) $
// $LastChangedRevision: 2142 $
// $LastChangedBy: drevil $
// $LastChangedDate: 2007-10-13 14:55:48 -0700 (Sat, 13 Oct 2007) $
// $LastChangedRevision: 2148 $
//
// about: Generic Bot Events
//

View File

@ -1,8 +1,8 @@
////////////////////////////////////////////////////////////////////////////////
//
// $LastChangedBy: DrEvil $
// $LastChangedDate: 2007-08-31 23:25:33 -0700 (Fri, 31 Aug 2007) $
// $LastChangedRevision: 2142 $
// $LastChangedBy: drevil $
// $LastChangedDate: 2007-10-13 14:55:48 -0700 (Sat, 13 Oct 2007) $
// $LastChangedRevision: 2148 $
//
// Title: TF Config
//

View File

@ -1551,12 +1551,7 @@ namespace Omnibot
if(!pEntity->CollisionProp() || pEntity->entindex() == 0)
return InvalidEntity;
Vector vOrig(0.f, 0.f, 0.f);
if(pEntity->CollisionProp()->IsBoundsDefinedInEntitySpace())
vOrig = pEntity->GetAbsOrigin();
vMins = vOrig + pEntity->CollisionProp()->OBBMins();;
vMaxs = vOrig + pEntity->CollisionProp()->OBBMaxs();
pEntity->CollisionProp()->WorldSpaceAABB(&vMins, &vMaxs);
}
_aabb.m_Mins[0] = vMins.x;