aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/_force_melee.gnut
blob: cdc14ffff7a3336c319d58e09f171e847f67e50b (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
global function ForceMelee_Init

struct {
    string forcedMeleeWeapon
} file

void function ForceMelee_Init()
{
    GetForcedMelee()
    AddCallback_OnPlayerRespawned( ReplaceMelee )
    AddCallback_OnPlayerGetsNewPilotLoadout( ReplaceMeleeForLoadoutChange )
}

void function GetForcedMelee()
{
    string cvar = GetConVarString( "ns_force_melee" )
    if ( cvar == "" || cvar.len() == 0 )
        return

    file.forcedMeleeWeapon = cvar
}

void function ReplaceMelee( entity player )
{
    GetForcedMelee()
    if ( file.forcedMeleeWeapon.len() == 0 )
        return

    player.TakeOffhandWeapon( 5 )
    player.GiveOffhandWeapon( file.forcedMeleeWeapon, OFFHAND_MELEE )
}

void function ReplaceMeleeForLoadoutChange( entity player, PilotLoadoutDef loadout )
{
    ReplaceMelee( player )
}