aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod
diff options
context:
space:
mode:
authorhummusbird <hummusbirb@gmail.com>2022-01-12 17:49:56 +0000
committerGitHub <noreply@github.com>2022-01-12 14:49:56 -0300
commit398b9439edc2fa51c284f09fa9ea30cfb0403043 (patch)
tree91462106db45630f489fb6138325d3702cba3d1b /Northstar.Custom/mod
parentfc917867b288c5fbbc3ecf2b45542224d1f5c622 (diff)
downloadNorthstarMods-398b9439edc2fa51c284f09fa9ea30cfb0403043.tar.gz
NorthstarMods-398b9439edc2fa51c284f09fa9ea30cfb0403043.zip
Add tactical ability restriction (#97)
Diffstat (limited to 'Northstar.Custom/mod')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/_disallowed_tacticals.gnut51
1 files changed, 51 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/_disallowed_tacticals.gnut b/Northstar.Custom/mod/scripts/vscripts/_disallowed_tacticals.gnut
new file mode 100644
index 00000000..b4a41931
--- /dev/null
+++ b/Northstar.Custom/mod/scripts/vscripts/_disallowed_tacticals.gnut
@@ -0,0 +1,51 @@
+global function DisallowedTacticals_Init
+
+struct {
+ array<string> disallowedTacticals
+ string disallowedTacticalsStringLastVal
+ string disallowedTacticalReplacement
+} file
+
+void function DisallowedTacticals_Init()
+{
+ UpdateDisallowedTacticalList()
+ AddCallback_OnPlayerRespawned( ReplacePlayerTactical )
+ AddCallback_OnPlayerGetsNewPilotLoadout( ReplacePlayerTacticalForLoadoutChange )
+}
+
+void function UpdateDisallowedTacticalList()
+{
+ string cvar = GetConVarString( "ns_disallowed_tacticals" )
+ if ( file.disallowedTacticalsStringLastVal == cvar )
+ return
+
+ file.disallowedTacticals = split( cvar, "," )
+ foreach ( string tactical in file.disallowedTacticals )
+ StringReplace( tactical, " ", "" )
+
+ file.disallowedTacticalReplacement = GetConVarString( "ns_disallowed_tactical_replacement")
+}
+
+void function ReplacePlayerTactical( entity player )
+{
+ UpdateDisallowedTacticalList()
+ if ( file.disallowedTacticals.len() == 0 )
+ return
+ array<entity> offhand = player.GetOffhandWeapons()
+
+ if ( file.disallowedTacticals.contains( offhand[1].GetWeaponClassName() ) )
+ {
+ player.TakeOffhandWeapon( 1 )
+ if ( file.disallowedTacticalReplacement != ""){
+ player.GiveOffhandWeapon( file.disallowedTacticalReplacement, OFFHAND_SPECIAL )
+ SendHudMessage( player, "Restricted tactical was replaced", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 )
+ }
+ else { SendHudMessage( player, "Restricted tactical was removed", -1, 0.4, 255, 255, 255, 255, 0.15, 3.0, 0.5 ) }
+ }
+
+}
+
+void function ReplacePlayerTacticalForLoadoutChange( entity player, PilotLoadoutDef loadout )
+{
+ ReplacePlayerTactical( player )
+} \ No newline at end of file