diff options
author | hummusbird <hummusbirb@gmail.com> | 2022-01-14 00:57:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-13 21:57:51 -0300 |
commit | 9d346f8c96cbfad841c82eaefa437015c9bf4ce4 (patch) | |
tree | cf17f8b1b7a622e70c324a648033ffdd5902991e /Northstar.Custom/mod/scripts/vscripts | |
parent | 526fe19517a3c2415026deabcd36ac9542fea5bd (diff) | |
download | NorthstarMods-9d346f8c96cbfad841c82eaefa437015c9bf4ce4.tar.gz NorthstarMods-9d346f8c96cbfad841c82eaefa437015c9bf4ce4.zip |
Add ns_force_melee cvar (#105)
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts')
-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 |