-
Notifications
You must be signed in to change notification settings - Fork 1
/
monster_protector.as
42 lines (34 loc) · 1.52 KB
/
monster_protector.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
40
41
42
/* "The GoldSRC Ministry of Defence has has raised conerns with the unethical practices of the SC Task Forces, namely "spawncamping"
and thus have issued a statement on behalf of all npcs that those npcs spawning in must be allowed a few seconds of
invulnerbility to gain a footing before being able to fight.
The SC Ethics Committee have enforced measures to prevent this."
--------------------------------------------------------------
A script that allows a few seconds of spawn invulnerblity for npcs spawning
Usage:-
Call "MONSTERPROTECTOR::Activate( flProtectionTimeSetting );" where "flProtectionTimeSetting is any number between 0 and 6, fractions allowed
- Outerbeast*/
namespace MONSTERPROTECTOR
{
float flProtectionTime;
void Activate(const float flProtectionTimeSetting)
{
flProtectionTime = Math.clamp( 0.1, 6.0, flProtectionTimeSetting );
CBaseEntity@ pNpcSpawner;
while( ( @pNpcSpawner = g_EntityFuncs.FindEntityByClassname( pNpcSpawner, "squadmaker" ) ) !is null )
g_EntityFuncs.DispatchKeyValue( pNpcSpawner.edict(), "function_name", "MONSTERPROTECTOR::NpcSpawnProtect" );
}
void NpcSpawnProtect(CBaseMonster@ pSquadmaker, CBaseEntity@ pMonster)
{
if( pMonster !is null )
{
pMonster.pev.takedamage = DAMAGE_NO;
g_Scheduler.SetTimeout( "NpcProtectionOff", flProtectionTime, EHandle( pMonster ) );
}
}
void NpcProtectionOff(EHandle hMonster)
{
if( !hMonster )
return;
hMonster.GetEntity().pev.takedamage = DAMAGE_YES;
}
}