From 398b9439edc2fa51c284f09fa9ea30cfb0403043 Mon Sep 17 00:00:00 2001 From: hummusbird Date: Wed, 12 Jan 2022 17:49:56 +0000 Subject: Add tactical ability restriction (#97) --- .../scripts/vscripts/_disallowed_tacticals.gnut | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Northstar.Custom/mod/scripts/vscripts/_disallowed_tacticals.gnut (limited to 'Northstar.Custom/mod/scripts') 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 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 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 -- cgit v1.2.3