blob: 46b730d60e5db2123983cc310f55eb1b654881b9 (
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
|
untyped
global function MeleeRewards_Init
function MeleeRewards_Init()
{
AddSyncedMeleeServerCallback( GetSyncedMeleeChooser( "human", "human" ), GiveMeleeRewards )
}
void function GiveMeleeRewards( SyncedMeleeChooser actions, SyncedMelee action, entity player, entity enemy )
{
thread GiveMeleeRewards_Internal( player, enemy )
}
enum eMeleeReward
{
NONE
AMMO
MAPHACK
}
function GiveMeleeRewards_Internal( entity player, entity enemy )
{
player.EndSignal( "OnDeath" )
local reward = eMeleeReward.NONE
if ( enemy.IsPlayer() )
reward = eMeleeReward.MAPHACK
else if ( enemy.IsNPC() )
reward = eMeleeReward.AMMO
player.WaitSignal( "SyncedMeleeComplete" )
switch ( reward )
{
case eMeleeReward.MAPHACK:
ExecutionGivesMapHack( player )
break
case eMeleeReward.AMMO:
ExecutionGivesAmmo( player )
break
default:
break
}
}
function ExecutionGivesMapHack( entity player )
{
printt( "melee gave map hack!" )
thread ScanMinimap( player, true )
}
function ExecutionGivesAmmo( entity player )
{
printt( "melee gave ammo!" )
local grenadeWeapon = player.GetOffhandWeapon( 0 )
if ( !IsValid( grenadeWeapon ) )
return
local maxAmmoClip = player.GetWeaponAmmoMaxLoaded( grenadeWeapon )
local remainingAmmo = player.GetWeaponAmmoLoaded( grenadeWeapon )
if ( remainingAmmo == maxAmmoClip )
return
local ammo = remainingAmmo + 1
grenadeWeapon.SetWeaponPrimaryClipCount( ammo )
EmitSoundOnEntity( player, "Coop_AmmoBox_AmmoRefill" )
}
|