aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.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/_gamemode_gg.gnut
parent27bd240871b7c0f2f49fef137718b2e3c208e3b4 (diff)
downloadNorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.tar.gz
NorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.zip
move to new mod format
Diffstat (limited to 'Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut')
-rw-r--r--Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut114
1 files changed, 114 insertions, 0 deletions
diff --git a/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut
new file mode 100644
index 000000000..b9ee40f1f
--- /dev/null
+++ b/Northstar.Custom/mod/scripts/vscripts/gamemodes/_gamemode_gg.gnut
@@ -0,0 +1,114 @@
+global function GamemodeGG_Init
+
+void function GamemodeGG_Init()
+{
+ SetSpawnpointGamemodeOverride( FFA )
+
+ SetShouldUseRoundWinningKillReplay( true )
+ Evac_SetEnabled( false )
+ SetLoadoutGracePeriodEnabled( false ) // prevent modifying loadouts with grace period
+ SetWeaponDropsEnabled( false )
+ Riff_ForceTitanAvailability( eTitanAvailability.Never )
+ Riff_ForceBoostAvailability( eBoostAvailability.Disabled )
+
+ AddCallback_OnPlayerRespawned( OnPlayerRespawned )
+ AddCallback_OnPlayerKilled( OnPlayerKilled )
+
+ AddCallback_GameStateEnter( eGameState.WinnerDetermined, OnWinnerDetermined )
+}
+
+void function OnPlayerRespawned( entity player )
+{
+ UpdateLoadout( player )
+ thread OnPlayerRespawned_Threaded( player )
+}
+
+void function OnPlayerRespawned_Threaded( entity player )
+{
+ // bit of a hack, need to rework earnmeter code to have better support for completely disabling it
+ // rn though this just waits for earnmeter code to set the mode before we set it back
+ WaitFrame()
+ PlayerEarnMeter_SetMode( player, eEarnMeterMode.DISABLED )
+}
+
+void function OnPlayerKilled( entity victim, entity attacker, var damageInfo )
+{
+ if ( !victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing )
+ return
+
+ if ( attacker == victim ) // suicide
+ {
+ string message = victim.GetPlayerName() + " committed suicide."
+ foreach ( entity player in GetPlayerArray() )
+ SendHudMessage( player, message, -1, 0.4, 255, 0, 0, 0, 0, 3, 0.15 )
+
+ if ( GameRules_GetTeamScore( victim.GetTeam() ) != 0 )
+ {
+ AddTeamScore( victim.GetTeam(), -1 ) // get absolutely fucking destroyed lol
+ victim.AddToPlayerGameStat( PGS_ASSAULT_SCORE, -1 )
+ }
+ }
+ else
+ {
+ if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) != eDamageSourceId.melee_pilot_emptyhanded )
+ {
+ AddTeamScore( attacker.GetTeam(), 1 )
+ attacker.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 )
+ UpdateLoadout( attacker )
+ }
+
+ if ( DamageInfo_GetDamageSourceIdentifier( damageInfo ) == eDamageSourceId.human_execution )
+ {
+ string message = victim.GetPlayerName() + " got executed."
+ foreach ( entity player in GetPlayerArray() )
+ SendHudMessage( player, message, -1, 0.4, 255, 0, 0, 0, 0, 3, 0.15 )
+
+ if ( GameRules_GetTeamScore( victim.GetTeam() ) != 0 )
+ {
+ AddTeamScore( victim.GetTeam(), -1 ) // get absolutely fucking destroyed lol
+ victim.AddToPlayerGameStat( PGS_ASSAULT_SCORE, -1 )
+ }
+ }
+ }
+}
+
+void function UpdateLoadout( entity player )
+{
+ // todo: honestly, this should be reworked to use PilotLoadoutDefs instead of directly modifying weapons and shit
+
+ int currentWeaponIndex = GameRules_GetTeamScore( player.GetTeam() )
+ array<GunGameWeapon> weapons = GetGunGameWeapons()
+
+ if ( currentWeaponIndex >= weapons.len() )
+ currentWeaponIndex = weapons.len() - 1
+
+ if ( currentWeaponIndex > 18 ) // play end of game music for special weapons
+ PlayMusicToAll( eMusicPieceID.LEVEL_LAST_MINUTE ) // this *shouldn't* overlap if done multiple times
+
+ GunGameWeapon weapon = weapons[ currentWeaponIndex ]
+
+ foreach ( entity weapon in player.GetMainWeapons() )
+ player.TakeWeaponNow( weapon.GetWeaponClassName() )
+
+ foreach ( entity weapon in player.GetOffhandWeapons() )
+ player.TakeWeaponNow( weapon.GetWeaponClassName() )
+
+ if ( weapon.offhandSlot != -1 )
+ {
+ // TEMP: give archer so player so player has a weapon which lets them use offhands
+ // need to replace this with a custom empty weapon at some point
+ player.GiveWeapon( "mp_weapon_rocket_launcher" )
+
+ player.GiveOffhandWeapon( weapon.weapon, weapon.offhandSlot, weapon.mods )
+ }
+ else
+ player.GiveWeapon( weapon.weapon, weapon.mods )
+
+ player.GiveOffhandWeapon( "melee_pilot_emptyhanded", OFFHAND_MELEE )
+}
+
+void function OnWinnerDetermined()
+{
+ SetRespawnsEnabled( false )
+ SetKillcamsEnabled( false )
+} \ No newline at end of file