-
Notifications
You must be signed in to change notification settings - Fork 1
/
button_los.as
39 lines (30 loc) · 1.12 KB
/
button_los.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace BUTTON_LOS
{
CScheduledFunction@ fnPatchButtons = g_Scheduler.SetTimeout( "PatchButtons", 0.0f );
void PatchButtons()
{
dictionary dictTs =
{
{ "targetname", "ts_check_los" },
{ "m_iszScriptFunctionName", "BUTTON_LOS::CheckLOS" },
{ "m_iMode", "1" }
};
CBaseEntity@ pEntity;
while( ( @pEntity = g_EntityFuncs.FindEntityByClassname( pEntity, "func_button" ) ) !is null )
{
if( pEntity is null || !pEntity.pev.SpawnFlagBitSet( 1 << 1 ) )
continue;
pEntity.GetUserData()["targ"] = string( pEntity.pev.target );
pEntity.pev.target = string( dictTs["targetname"] );
}
g_EntityFuncs.CreateEntity( "trigger_script", dictTs );
}
void CheckLOS(CBaseEntity@ pActivator, CBaseEntity@ pCaller, USE_TYPE useType, float flValue)
{
if( pActivator is null || pCaller is null )
return;
if( !pCaller.FVisibleFromPos( pActivator.pev.origin, pCaller.Center() ) )
return;
g_EntityFuncs.FireTargets( string( pCaller.GetUserData( "targ" ) ), pActivator, pCaller, useType, 0.0f, 0.0f );
}
}