aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-31 23:14:58 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-31 23:14:58 +0100
commit9a96d0bff56f1969c68bb52a2f33296095bdc67d (patch)
tree4175928e488632705692e3cccafa1a38dd854615 /Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut
parent27bd240871b7c0f2f49fef137718b2e3c208e3b4 (diff)
downloadNorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.tar.gz
NorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.zip
move to new mod format
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut65
1 files changed, 65 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut
new file mode 100644
index 000000000..b3868359e
--- /dev/null
+++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_riff_instagib.gnut
@@ -0,0 +1,65 @@
+global function RiffInstagib_Init
+
+struct {
+ table<entity, int> playerWeapons
+ array<string> instagibWeapons
+} file
+
+void function RiffInstagib_Init()
+{
+ if ( GetCurrentPlaylistVarInt( "riff_instagib", 0 ) == 0 )
+ return
+
+ SetLoadoutGracePeriodEnabled( false )
+ SetWeaponDropsEnabled( false )
+
+ file.instagibWeapons = [
+ "mp_weapon_sniper",
+ "mp_weapon_wingman",
+ "mp_weapon_defender",
+ "mp_weapon_arena3",
+ "mp_weapon_wingman_n",
+ "mp_weapon_doubletake",
+ ]
+ file.instagibWeapons.randomize()
+
+ AddCallback_OnPlayerRespawned( InstagibSetWeapons )
+ AddCallback_OnPlayerKilled( InstagibCycleWeaponsForKill )
+ AddCallback_OnClientDisconnected( InstagibCleanupClient )
+}
+
+void function InstagibSetWeapons( entity player )
+{
+ if ( !( player in file.playerWeapons ) )
+ file.playerWeapons[ player ] <- 0
+
+ player.SetMaxHealth( 1 )
+ InstagibUpdateWeapons( player )
+}
+
+void function InstagibUpdateWeapons( entity player )
+{
+ foreach( entity weapon in player.GetMainWeapons() )
+ player.TakeWeaponNow( weapon.GetWeaponClassName() )
+
+ player.TakeWeaponNow( player.GetOffhandWeapon( OFFHAND_RIGHT ).GetWeaponClassName() )
+ if ( !HasOffhandWeapon( player, "mp_weapon_grenade_sonar" ) )
+ player.GiveOffhandWeapon( "mp_weapon_grenade_sonar", OFFHAND_RIGHT )
+
+ player.GiveWeapon( file.instagibWeapons[ file.playerWeapons[ player ] ] )
+}
+
+void function InstagibCycleWeaponsForKill( entity victim, entity attacker, var damageInfo )
+{
+ if ( !victim.IsPlayer() || !attacker.IsPlayer() || victim == attacker )
+ return
+
+ file.playerWeapons[ attacker ] = ( file.playerWeapons[ attacker ] + 1 ) % file.instagibWeapons.len()
+ InstagibUpdateWeapons( attacker )
+}
+
+void function InstagibCleanupClient( entity player )
+{
+ if ( player in file.playerWeapons )
+ delete file.playerWeapons[ player ]
+} \ No newline at end of file