aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/mod
diff options
context:
space:
mode:
Diffstat (limited to 'Northstar.CustomServers/mod')
-rw-r--r--Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_at.nut124
1 files changed, 123 insertions, 1 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_at.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_at.nut
index 915e03e0..3d4f2d0c 100644
--- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_at.nut
+++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_at.nut
@@ -1,3 +1,4 @@
+untyped
global function GamemodeAt_Init
global function RateSpawnpoints_AT
@@ -5,6 +6,7 @@ const int BH_AI_TEAM = TEAM_BOTH
const int BOUNTY_TITAN_DAMAGE_POOL = 400 // Rewarded for damage
const int BOUNTY_TITAN_KILL_REWARD = 100 // Rewarded for kill
const float WAVE_STATE_TRANSITION_TIME = 5.0
+const float BANK_OPEN_TIME = 40.0
const array<string> VALID_BOUNTY_TITAN_SETTINGS = [
"npc_titan_atlas_stickybomb_bounty",
@@ -60,6 +62,11 @@ void function CreateATBank( entity spawnpoint )
entity bank = CreatePropDynamic( spawnpoint.GetModelName(), spawnpoint.GetOrigin(), spawnpoint.GetAngles(), SOLID_VPHYSICS )
bank.SetScriptName( "AT_Bank" )
+
+ bank.SetUsableByGroup( "pilot" )
+ bank.SetUsePrompts( "#HOLD_TO_USE_GENERIC", "#PRESS_TO_USE_GENERIC" )
+ bank.UnsetUsable()
+
// create tracker ent
// we don't need to store these at all, client just needs to get them
DispatchSpawn( GetAvailableBankTracker( bank ) )
@@ -120,6 +127,11 @@ void function AT_SetPlayerCash( entity player, int amount )
player.SetPlayerNetInt( "AT_bonusPoints", amount - stacks * 256 )
}
+int function AT_GetPlayerCash( entity player )
+{
+ return player.GetPlayerNetInt( "AT_bonusPoints256" ) * 256 + player.GetPlayerNetInt( "AT_bonusPoints" )
+}
+
void function AT_AddPlayerCash( entity player, int amount )
{
// update score difference
@@ -254,8 +266,118 @@ void function RunATGame_Threaded()
wait WAVE_STATE_TRANSITION_TIME
- // banking phase
+ waitthread BanksOpen_Threaded()
+ }
+}
+
+// Think function for banks
+void function BanksOpen_Threaded()
+{
+ // Open
+ SetGlobalNetBool( "banksOpen", true )
+
+ foreach ( entity player in GetPlayerArray() )
+ Remote_CallFunction_NonReplay( player, "ServerCallback_AT_BankOpen" )
+
+ foreach ( entity bank in file.banks )
+ {
+ bank.SetUsable()
+ thread PlayAnim( bank, "mh_inactive_2_active" )
+ }
+
+ // Think
+ // table < player, moneyDeposited >
+ table < entity, int > depositingPlayers
+ foreach ( entity bank in file.banks )
+ {
+ AddCallback_OnUseEntity( bank, function( b, p ) : ( depositingPlayers ) {
+ expect entity( b )
+ expect entity( p )
+
+ if ( !( p in depositingPlayers ) )
+ {
+ depositingPlayers[p] <- 0
+ p.SetPlayerNetBool( "AT_playerUploading", true )
+ }
+ } )
+ }
+
+
+ float bankOpenTime = Time()
+
+ SetGlobalNetTime( "AT_bankStartTime", Time() )
+ SetGlobalNetTime( "AT_bankEndTime", Time() + BANK_OPEN_TIME )
+
+ while ( Time() - bankOpenTime < BANK_OPEN_TIME )
+ {
+ foreach ( player, amount in depositingPlayers )
+ {
+ entity closestBank = GetClosest( file.banks, player.GetOrigin(), 300 )
+
+ // we're close to a bank
+ if ( closestBank != null && AT_GetPlayerCash( player ) > 0 )
+ {
+ depositingPlayers[player] += DepositMoney( player )
+ continue
+ }
+
+ // we've failed the check above, either no more money left or too far from bank
+ Remote_CallFunction_NonReplay( player, "ServerCallback_AT_FinishDeposit", depositingPlayers[player] )
+ player.SetPlayerNetBool( "AT_playerUploading", false )
+ delete depositingPlayers[ player ]
+ }
+ wait 0.1
+ }
+
+
+ // remove players after closing banks
+ foreach ( player, amount in depositingPlayers )
+ {
+ Remote_CallFunction_NonReplay( player, "ServerCallback_AT_FinishDeposit", depositingPlayers[player] )
+ player.SetPlayerNetBool( "AT_playerUploading", false )
+ delete depositingPlayers[ player ]
+ }
+
+
+ // Close
+ foreach ( entity bank in file.banks )
+ {
+ bank.UnsetUsable()
+ thread PlayAnim( bank, "mh_active_2_inactive" )
}
+
+ foreach ( entity player in GetPlayerArray() )
+ Remote_CallFunction_NonReplay( player, "ServerCallback_AT_BankClose" )
+
+ SetGlobalNetBool( "banksOpen", false )
+}
+
+// deposits money
+// returns the amount deposited, this wont always be 10
+int function DepositMoney( entity player )
+{
+ int newValue = AT_GetPlayerCash( player ) - 10
+
+ if ( newValue < 0 )
+ newValue = 0
+
+ int deposited = AT_GetPlayerCash( player ) - newValue
+
+ AT_SetPlayerCash( player, newValue )
+ player.SetPlayerGameStat( PGS_SCORE, newValue )
+ player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, deposited )
+ AddTeamScore( player.GetTeam(), deposited )
+
+ return deposited
+}
+
+// splits money between player and their team bank
+void function GiveMoneyToPlayer( entity player, int money )
+{
+ player.AddToPlayerGameStat( PGS_ASSAULT_SCORE, money / 2 ) // score
+ player.AddToPlayerGameStat( PGS_SCORE, money / 2 ) // bonus
+ AddTeamScore( player.GetTeam(), money / 2 )
+ AT_SetPlayerCash( player, AT_GetPlayerCash( player ) + money / 2 )
}
// entity funcs