aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/ai/_ai_lethality.gnut
blob: 771fe6d9305b2da1243745fc0dcaa1827a72c0b1 (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 enum eAILethality
{
	VeryLow,
	Low,
	Medium,
	High,
	VeryHigh
}

global function SetAILethality

global function UpdateNPCForAILethality

function SetAILethality( aiLethality )
{
	Assert( IsMultiplayer() )
	level.nv.aiLethality = aiLethality

	switch ( aiLethality )
	{
		case eAILethality.Medium:
			break

		case eAILethality.High:
			NPCSetAimConeFocusParams( 6, 2.5 )
			NPCSetAimPatternFocusParams( 4, 0.3, 0.8 )
			break
		case eAILethality.VeryHigh:
			NPCSetAimConeFocusParams( 5, 2.0 )
			NPCSetAimPatternFocusParams( 4, 0.3, 0.8 )
			break
	}

	// reset ai lethality

	array<entity> npcs = GetNPCArray()
	foreach ( npc in npcs )
	{
		UpdateNPCForAILethality( npc )
	}
}


function SetTitanAccuracyAndProficiency( entity npcTitan )
{
	Assert( IsMultiplayer() )
	int lethality = Riff_AILethality()
	float accuracyMultiplier = 1.0
	int weaponProficiency = eWeaponProficiency.GOOD

	entity player = GetPetTitanOwner( npcTitan )
	entity soul = npcTitan.GetTitanSoul()

	// auto titans have lower proficiency
	if ( player && soul == null)
	{
		soul = player.GetTitanSoul() // in mid transfer
	}

	if ( IsValid( soul ) )
	{
		if ( SoulHasPassive( soul, ePassives.PAS_ENHANCED_TITAN_AI ) )
		{
			weaponProficiency = eWeaponProficiency.GOOD
 		}
		else if ( player )
		{
			weaponProficiency = eWeaponProficiency.AVERAGE
			entity ordnanceWeapon = npcTitan.GetOffhandWeapon( OFFHAND_ORDNANCE )
			if ( IsValid( ordnanceWeapon ) )
				ordnanceWeapon.AllowUse( false )

			entity centerWeapon = npcTitan.GetOffhandWeapon( OFFHAND_TITAN_CENTER )
			if ( IsValid( centerWeapon ) )
				centerWeapon.AllowUse( false )
		}
	}

	npcTitan.kv.AccuracyMultiplier = accuracyMultiplier
	npcTitan.kv.WeaponProficiency = weaponProficiency
}

function UpdateNPCForAILethality( entity npc )
{
	Assert( IsMultiplayer() )
	if ( npc.IsTitan() )
	{
		SetTitanAccuracyAndProficiency( npc )
		return
	}

	if ( IsMinion( npc ) )
		SetProficiency( npc )
}