diff options
Diffstat (limited to 'Northstar.Custom/mod/scripts')
-rw-r--r-- | Northstar.Custom/mod/scripts/vscripts/_force_melee.gnut | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/_force_melee.gnut b/Northstar.Custom/mod/scripts/vscripts/_force_melee.gnut new file mode 100644 index 00000000..cdc14fff --- /dev/null +++ b/Northstar.Custom/mod/scripts/vscripts/_force_melee.gnut @@ -0,0 +1,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 ) +}
\ No newline at end of file |