aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_turret_sentry.gnut
blob: e34b3082641c9a91b8f2076a6522508c9583d9d8 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
global function AiTurretSentry_Init

const DEAD_SENTRY_TURRET_FX		= $"P_impact_exp_med_air"
const DEAD_SENTRY_TURRET_SFX	= "SentryTurret_DeathExplo"
const SENTRY_TURRET_AIM_FX_RED = $"P_wpn_lasercannon_aim_short"
const SENTRY_TURRET_AIM_FX_BLUE = $"P_wpn_lasercannon_aim_short_blue"

void function AiTurretSentry_Init()
{
	PrecacheParticleSystem( DEAD_SENTRY_TURRET_FX )
	//PrecacheParticleSystem( SENTRY_TURRET_AIM_FX_RED )
	//PrecacheParticleSystem( SENTRY_TURRET_AIM_FX_BLUE )
	//PrecacheParticleSystem( SENTRY_TURRET_AIM_FX2 )

	AddSpawnCallback( "npc_turret_sentry", LightTurretSpawnFunction )
	AddDeathCallback( "npc_turret_sentry", LightTurretDeathFX )

	//RegisterSignal( "TurretDisabled" )
	//RegisterSignal( "HandleTargetDeath" )
	//RegisterSignal( "OnPlayerDisconnectResetTurret" )
	//RegisterSignal( "Deactivate_Turret" )
	//RegisterSignal( "TurretShieldWallRelease")
	//RegisterSignal( "DestroyShieldFX")
}

void function LightTurretDeathFX( entity turret, var damageInfo )
{
	turret.SetBodygroup( 0, 1 )

	int turretEHandle = turret.GetEncodedEHandle()
	array<entity> players = GetPlayerArray()
	foreach( player in players )
	{
		Remote_CallFunction_Replay( player, "ServerCallback_TurretRefresh", turretEHandle )
	}

	EmitSoundAtPosition( turret.GetTeam(), turret.GetOrigin(), DEAD_SENTRY_TURRET_SFX )
	PlayFX( DEAD_SENTRY_TURRET_FX, turret.GetOrigin() + Vector( 0,0,38 ) )	// played with a slight offset as requested by BigRig
}

//////////////////////////////////////////////////////////
void function LightTurretSpawnFunction( entity turret )
{
 	turret.UnsetUsable()

//	float windupTime = TurretGetWindupTime( turret )
//	if ( windupTime > 0 )
//		thread HACK_TurretManagePreAttack( turret, OnWindupBegin_SentryTurret, OnWindupEnd_Turret )
//
	if ( turret.Dev_GetAISettingByKeyField( "aim_laser_disabled" ) )
		return

	thread SentryTurretAimLaser( turret )
}

void function SentryTurretAimLaser( entity turret )
{
	entity fx1 = PlayLoopFXOnEntity( SENTRY_TURRET_AIM_FX_RED, turret, "camera_glow", null, null, ENTITY_VISIBLE_TO_ENEMY )
	entity fx2 = PlayLoopFXOnEntity( SENTRY_TURRET_AIM_FX_BLUE, turret, "camera_glow", null, null, ENTITY_VISIBLE_TO_FRIENDLY )

	OnThreadEnd(
		function() : ( fx1, fx2 )
		{
			if ( IsValid( fx1 ) )
				EffectStop( fx1 )
			if ( IsValid( fx2 ) )
				EffectStop( fx2 )
		}
	)

	WaitSignal( turret, "OnDeath" )
}