aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod/scripts/vscripts/ai/_ai_gunship.gnut
blob: 2f1fdc96f2a2d7243f9e1d1e700f0c264afdf957 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
untyped

global function AiGunship_Init

global function GunshipThink

global const SOUND_GUNSHIP_HOVER = "Gunship_Hover"
global const SOUND_GUNSHIP_EXPLODE_DEFAULT = "Gunship_Explode"
global const FX_GUNSHIP_EXPLOSION = $"P_veh_exp_crow"

function AiGunship_Init()
{
	PrecacheParticleSystem( FX_GUNSHIP_EXPLOSION )
	AddDeathCallback( "npc_gunship", GunshipDeath )
}


function GunshipThink( gunship )
{
	gunship.EndSignal( "OnDeath" )

	entity owner
	entity currentTarget
	local accuracyMultiplierBase = gunship.kv.AccuracyMultiplier
	local accuracyMultiplierAgainstDrones = 100

	while( true )
	{
		wait 0.25

		//----------------------------------
		// Get owner and current enemy
		//----------------------------------
		currentTarget = expect entity( gunship.GetEnemy() )
		owner = expect entity( gunship.GetFollowTarget() )

		//----------------------------------
		// Free roam if owner is dead or HasEnemy
		//----------------------------------
		if ( ( !IsAlive( owner ) ) || ( currentTarget != null ) )
		{
			gunship.DisableBehavior( "Follow" )
		}

		//---------------------------------------------------------------------
		// If owner is alive and no enemies in sight, go back and follow owner
		//----------------------------------------------------------------------
		if ( ( IsAlive( owner ) ) && ( currentTarget == null ) )
		{
			gunship.EnableBehavior( "Follow" )
		}


		//----------------------------------------------
		// Jack up accuracy if targeting a small target (like a drone)
		//----------------------------------------------
		if ( ( currentTarget != null ) && ( IsAirDrone( currentTarget ) ) )
		{
			gunship.kv.AccuracyMultiplier = accuracyMultiplierAgainstDrones
		}
		else
		{
			gunship.kv.AccuracyMultiplier = accuracyMultiplierBase
		}
	}

}


void function GunshipDeath( entity gunship, var damageInfo )
{
	/*
	Script errors

	// Explosion effect
	entity explosion = CreateEntity( "info_particle_system" )
	explosion.SetOrigin( gunship.GetWorldSpaceCenter() )
	explosion.SetAngles( gunship.GetAngles() )
	explosion.SetValueForEffectNameKey( FX_GUNSHIP_EXPLOSION )
	explosion.kv.start_active = 1
	DispatchSpawn( explosion )
	EmitSoundAtPosition( TEAM_UNASSIGNED, gunship.GetOrigin(), SOUND_GUNSHIP_EXPLODE_DEFAULT )
	explosion.destroy( 3 )

	gunship.Destroy()

	P_veh_exp_hornet, TAG_ORIGIN, attach

	*/

	//TEMP
	PlayFX( FX_GUNSHIP_EXPLOSION, gunship.GetOrigin() )
	EmitSoundAtPosition( TEAM_UNASSIGNED, gunship.GetOrigin(), "Goblin_Dropship_Explode" )
	gunship.Destroy()
}