/*---------------------------------------------------------
IsTableOfEntitiesValid
---------------------------------------------------------*/
function IsTableOfEntitiesValid( tab )
if (!tab) then return false end
for k, v
in pairs( tab
) do
if ( !IsValid( v
) ) then return false end
end
return true
end
/*---------------------------------------------------------
To easily create a colour table
---------------------------------------------------------*/
function Color( r, g, b, a
)
a = a or 255
end
/*---------------------------------------------------------
Prints a table to the console
---------------------------------------------------------*/
done = done or {}
indent = indent or 0
for key, value
in pairs (t
) do
if type (value
) == "table" and not done
[value
] then
done [value] = true
else
end
end
end
/*---------------------------------------------------------
Returns a random vector
---------------------------------------------------------*/
end
/*---------------------------------------------------------
Convenience function to precache a sound
---------------------------------------------------------*/
return name
end
/*---------------------------------------------------------
Convenience function to precache a model
---------------------------------------------------------*/
return name
end
// Some nice globals so we don't keep creating objects for no reason
vector_origin
= Vector( 0,
0,
0 )
color_white
= Color( 255,
255,
255,
255 )
color_black
= Color( 0,
0,
0,
255 )
color_transparent
= Color( 255,
255,
255,
0 )
/*---------------------------------------------------------
For shared files. Includes the file if clientside,
marks for send it if serverside.
---------------------------------------------------------*/
if ( CLIENT ) then
else
end
end
// Globals..
FORCE_STRING = 1
FORCE_NUMBER = 2
FORCE_BOOL = 3
/*---------------------------------------------------------
AccessorFunc
Quickly make Get/Set accessor fuctions on the specified table
---------------------------------------------------------*/
tab[ "Get"..name ] = function ( self ) return self[ varname ] end
if ( iForce == FORCE_STRING ) then
tab
[ "Set"..name
] = function ( self, v
) self
[ varname
] = tostring(v
) end
return end
if ( iForce == FORCE_NUMBER ) then
tab
[ "Set"..name
] = function ( self, v
) self
[ varname
] = tonumber(v
) end
return end
if ( iForce == FORCE_BOOL ) then
tab
[ "Set"..name
] = function ( self, v
) self
[ varname
] = tobool(v
) end
return end
tab[ "Set"..name ] = function ( self, v ) self[ varname ] = v end
end
/*---------------------------------------------------------
AccessorFuncNW - FOR ENTITIES ONLY
Quickly make Get/Set accessor fuctions on the specified entity
---------------------------------------------------------*/
tab
[ "Get"..name
] = function ( self
) return self:
GetNetworkedVar( varname, varDefault
) end
if ( iForce == FORCE_STRING ) then
return end
if ( iForce == FORCE_NUMBER ) then
return end
if ( iForce == FORCE_BOOL ) then
return end
tab
[ "Set"..name
] = function ( self, v
) self:
SetNetworkedVar( varname, v
) end
end
/*---------------------------------------------------------
Returns true if object is valid (is not nil and IsValid)
---------------------------------------------------------*/
if (!object) then return false end
end
/*---------------------------------------------------------
Returns true if entity is valid
---------------------------------------------------------*/
/*---------------------------------------------------------
Utility function, automatically prints error
---------------------------------------------------------*/
if ( !errored ) then
return false, retval
end
return true, retval
end
/*---------------------------------------------------------
Safely remove an entity
---------------------------------------------------------*/
end
/*---------------------------------------------------------
Safely remove an entity (delayed)
---------------------------------------------------------*/
if (!ent
|| !ent:
IsValid()) then return end
end
/*---------------------------------------------------------
Simple lerp
---------------------------------------------------------*/
function Lerp( delta, from, to
)
if ( delta > 1 ) then return to end
if ( delta < 0 ) then return from end
return from + (to - from) * delta;
end
/*---------------------------------------------------------
Convert Var to Bool
---------------------------------------------------------*/
if ( val == nil || val == false || val == 0 || val == "0" || val == "false" ) then return false end
return true
end
/*---------------------------------------------------------
Universal function to filter out crappy models by name
---------------------------------------------------------*/
local modelname = modelname:lower()
if ( modelname:find( "_gesture" ) ) then return true end
if ( modelname:find( "_anim" ) ) then return true end
if ( modelname:find( "_gst" ) ) then return true end
if ( modelname:find( "_pst" ) ) then return true end
if ( modelname:find( "_shd" ) ) then return true end
if ( modelname:find( "_ss" ) ) then return true end
if ( modelname:find( "_posture" ) ) then return true end
if ( modelname:find( "_anm" ) ) then return true end
if ( modelname:find( "ghostanim" ) ) then return true end
if ( modelname:find( "_paths" ) ) then return true end
if ( modelname:find( "_shared" ) ) then return true end
return false
end
/*---------------------------------------------------------
Remember/Restore cursor position..
Clientside only
If you have a system where you hold a key to show the cursor
Call RememberCursorPosition when the key is released and call
RestoreCursorPosition to restore the cursor to where it was
when the key was released.
If you don't the cursor will appear in the middle of the screen
---------------------------------------------------------*/
local StoredCursorPos = {}
// If the cursor isn't visible it will return 0,0 ignore it.
if ( x == 0 && y == 0 ) then return end
StoredCursorPos.x, StoredCursorPos.y = x, y
end
if ( !StoredCursorPos.x || !StoredCursorPos.y ) then return end
end
/*---------------------------------------------------------
Given a number, returns the right 'th
---------------------------------------------------------*/
if ( num == 1 ) then return "st" end
if ( num == 2 ) then return "nd" end
if ( num == 3 ) then return "rd" end
return "th"
end
/*---------------------------------------------------------
From Simple Gamemode Base (Rambo_9)
---------------------------------------------------------*/
end
/*---------------------------------------------------------
From Simple Gamemode Base (Rambo_9)
---------------------------------------------------------*/
end
/*---------------------------------------------------------
IsEnemyEntityName
---------------------------------------------------------*/
function IsEnemyEntityName( victimtype )
if ( victimtype == "npc_combine_s" ) then return true; end
if ( victimtype == "npc_cscanner" ) then return true; end
if ( victimtype == "npc_manhack" ) then return true; end
if ( victimtype == "npc_hunter" ) then return true; end
if ( victimtype == "npc_antlion" ) then return true; end
if ( victimtype == "npc_antlionguard" ) then return true; end
if ( victimtype == "npc_antlion_worker" ) then return true; end
if ( victimtype == "npc_fastzombie_torso" ) then return true; end
if ( victimtype == "npc_fastzombie" ) then return true; end
if ( victimtype == "npc_headcrab" ) then return true; end
if ( victimtype == "npc_headcrab_fast" ) then return true; end
if ( victimtype == "npc_poisonzombie" ) then return true; end
if ( victimtype == "npc_headcrab_poison" ) then return true; end
if ( victimtype == "npc_zombie" ) then return true; end
if ( victimtype == "npc_zombie_torso" ) then return true; end
if ( victimtype == "npc_zombine" ) then return true; end
if ( victimtype == "npc_gman" ) then return true; end
if ( victimtype == "npc_breen" ) then return true; end
return false
end
/*---------------------------------------------------------
IsFriendEntityName
---------------------------------------------------------*/
function IsFriendEntityName( victimtype )
if ( victimtype == "npc_monk" ) then return true; end
if ( victimtype == "npc_alyx" ) then return true; end
if ( victimtype == "npc_barney" ) then return true; end
if ( victimtype == "npc_citizen" ) then return true; end
if ( victimtype == "npc_kleiner" ) then return true; end
if ( victimtype == "npc_magnusson" ) then return true; end
if ( victimtype == "npc_eli" ) then return true; end
if ( victimtype == "npc_mossman" ) then return true; end
if ( victimtype == "npc_vortigaunt" ) then return true; end
return false
end