diff options
Diffstat (limited to 'Northstar.CustomServers/mod/scripts/vscripts/gamemodes')
5 files changed, 226 insertions, 81 deletions
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut index 8e5599a19..56e1d04f6 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_cp.nut @@ -2,6 +2,7 @@ untyped global function GamemodeCP_Init global function RateSpawnpoints_CP +global function DEV_PrintHardpointsInfo // needed for sh_gamemode_cp_dialogue global array<entity> HARDPOINTS @@ -157,104 +158,210 @@ void function StartHardpointThink() void function HardpointThink( HardpointStruct hardpoint ) { entity hardpointEnt = hardpoint.hardpoint - + float lastTime = Time() float lastScoreTime = Time() - + WaitFrame() // wait a frame so deltaTime is never zero + while ( GamePlayingOrSuddenDeath() ) { - int imcCappers = hardpoint.imcCappers.len() - int militiaCappers = hardpoint.militiaCappers.len() - - float deltaTime = Time() - lastTime - - int cappingTeam - if ( imcCappers > militiaCappers ) - cappingTeam = TEAM_IMC - else if ( militiaCappers > imcCappers ) - cappingTeam = TEAM_MILITIA - - if ( cappingTeam != TEAM_UNASSIGNED ) + int imcPilotCappers = 0 + int militiaPilotCappers = 0 + + int imcTitanCappers = 0 + int militiaTitanCappers = 0 + + float currentTime = Time() + float deltaTime = currentTime - lastTime + + foreach(entity p in hardpoint.imcCappers) { - // hardpoint is owned by controlling team - if ( hardpointEnt.GetTeam() == cappingTeam ) + if(p.IsPlayer()) { - // hardpoint is being neutralised, reverse the neutralisation - if ( GetHardpointCappingTeam( hardpoint ) != cappingTeam || GetHardpointCaptureProgress( hardpoint ) < 1.0 ) + if(p.IsTitan()) { - SetHardpointCappingTeam( hardpoint, cappingTeam ) - SetHardpointCaptureProgress( hardpoint, min( 1.0, GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / CAPTURE_DURATION_CAPTURE ) ) ) + imcTitanCappers = imcTitanCappers + 1 } - // hardpoint is fully captured, start amping if amping is enabled - else if ( file.ampingEnabled && GetHardpointState( hardpoint ) < CAPTURE_POINT_STATE_AMPING ) - SetHardpointState( hardpoint, CAPTURE_POINT_STATE_AMPING ) - - // amp the hardpoint - if ( GetHardpointState( hardpoint ) == CAPTURE_POINT_STATE_AMPING ) + else { - SetHardpointCaptureProgress( hardpoint, min( 2.0, GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / HARDPOINT_AMPED_DELAY ) ) ) - if ( GetHardpointCaptureProgress( hardpoint ) == 2.0 ) + imcPilotCappers = imcPilotCappers + 1 + } + } + } + foreach(entity p in hardpoint.militiaCappers) + { + if(p.IsPlayer()) + { + if(p.IsTitan()) + { + militiaTitanCappers = militiaTitanCappers + 1 + } + else + { + + militiaPilotCappers = militiaPilotCappers + 1 + } + } + } + int imcCappers + int militiaCappers + + bool hardpointBlocked = false + if((imcTitanCappers+militiaTitanCappers)>0) + { + imcCappers = imcTitanCappers + militiaCappers = militiaTitanCappers + } + else + { + imcCappers = imcPilotCappers + militiaCappers = militiaPilotCappers + } + + int cappingTeam + int capperAmount = 0 + + if((imcCappers > 0) && (militiaCappers > 0)){ + hardpointBlocked = true + } + else if ( imcCappers > 0 ) + { + cappingTeam = TEAM_IMC + capperAmount = imcCappers + } + else if ( militiaCappers > 0 ) + { + cappingTeam = TEAM_MILITIA + capperAmount = militiaCappers + } + capperAmount = int(min(capperAmount, 3)) + + if(hardpointBlocked) + { + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_HALTED) + } + else if(cappingTeam==TEAM_UNASSIGNED)//nobody on point + { + + switch(GetHardpointState(hardpoint)) + { + case CAPTURE_POINT_STATE_UNASSIGNED: + SetHardpointCaptureProgress(hardpoint,max(0.0,GetHardpointCaptureProgress(hardpoint)-(deltaTime/CAPTURE_DURATION_CAPTURE))) + if(GetHardpointCaptureProgress(hardpoint)==0.0) { - SetHardpointState( hardpoint, CAPTURE_POINT_STATE_AMPED ) - - // can't use the dialogue functions here because for some reason GamemodeCP_VO_Amped isn't global? - PlayFactionDialogueToTeam( "amphp_youAmped" + hardpointEnt.kv.hardpointGroup, cappingTeam ) - PlayFactionDialogueToTeam( "amphp_enemyAmped" + hardpointEnt.kv.hardpointGroup, GetOtherTeam( cappingTeam ) ) + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_UNASSIGNED) + SetHardpointCappingTeam(hardpoint,TEAM_UNASSIGNED) } + break + case CAPTURE_POINT_STATE_CAPTURED: + SetHardpointCappingTeam(hardpoint,hardpointEnt.GetTeam()) + SetHardpointCaptureProgress(hardpoint,min(1.0,GetHardpointCaptureProgress(hardpoint)+(deltaTime/CAPTURE_DURATION_CAPTURE))) + break + case CAPTURE_POINT_STATE_AMPED: + case CAPTURE_POINT_STATE_AMPING: + SetHardpointCappingTeam(hardpoint,hardpointEnt.GetTeam()) + SetHardpointCaptureProgress(hardpoint,max(1.0,GetHardpointCaptureProgress(hardpoint)-(deltaTime/HARDPOINT_AMPED_DELAY))) + if(GetHardpointCaptureProgress(hardpoint)<=1.001) + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED) + break + } + } + else if(hardpointEnt.GetTeam()==TEAM_UNASSIGNED) + { + if(GetHardpointCappingTeam(hardpoint)==TEAM_UNASSIGNED) + { + SetHardpointCaptureProgress( hardpoint, min(1.0,GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / CAPTURE_DURATION_CAPTURE * capperAmount) ) ) + SetHardpointCappingTeam(hardpoint,cappingTeam) + if(GetHardpointCaptureProgress(hardpoint)>=1.0) + { + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED) + SetTeam( hardpointEnt, cappingTeam ) + SetTeam( hardpoint.prop, cappingTeam ) + EmitSoundOnEntityToTeamExceptPlayer( hardpointEnt, "hardpoint_console_captured", cappingTeam, null ) + GamemodeCP_VO_Captured( hardpointEnt ) } } - else // we don't own this hardpoint, cap it + else if(GetHardpointCappingTeam(hardpoint)==cappingTeam) { - SetHardpointCappingTeam( hardpoint, cappingTeam ) - GamemodeCP_VO_StartCapping( hardpointEnt ) // this doesn't consistently trigger for some reason - - SetHardpointCaptureProgress( hardpoint, min( 1.0, GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / CAPTURE_DURATION_CAPTURE ) ) ) - - if ( GetHardpointCaptureProgress( hardpoint ) >= 1.0 ) + SetHardpointCaptureProgress( hardpoint,min(1.0, GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / CAPTURE_DURATION_CAPTURE * capperAmount) ) ) + if(GetHardpointCaptureProgress(hardpoint)>=1.0) { + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED) SetTeam( hardpointEnt, cappingTeam ) SetTeam( hardpoint.prop, cappingTeam ) - SetHardpointState( hardpoint, CAPTURE_POINT_STATE_CAPTURED ) - EmitSoundOnEntityToTeamExceptPlayer( hardpointEnt, "hardpoint_console_captured", cappingTeam, null ) GamemodeCP_VO_Captured( hardpointEnt ) } } + else + { + SetHardpointCaptureProgress( hardpoint,max(0.0, GetHardpointCaptureProgress( hardpoint ) - ( deltaTime / CAPTURE_DURATION_CAPTURE * capperAmount) ) ) + if(GetHardpointCaptureProgress(hardpoint)==0.0) + { + SetHardpointCappingTeam(hardpoint,cappingTeam) + if(GetHardpointCaptureProgress(hardpoint)>=1) + { + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED) + SetTeam( hardpointEnt, cappingTeam ) + SetTeam( hardpoint.prop, cappingTeam ) + EmitSoundOnEntityToTeamExceptPlayer( hardpointEnt, "hardpoint_console_captured", cappingTeam, null ) + GamemodeCP_VO_Captured( hardpointEnt ) + } + } + + } } - // capture halting - else if ( imcCappers > 0 && imcCappers == militiaCappers ) - SetHardpointState( hardpoint, CAPTURE_POINT_STATE_HALTED ) - // amped decay - else if ( imcCappers == 0 && militiaCappers == 0 && GetHardpointState( hardpoint ) >= CAPTURE_POINT_STATE_AMPING ) + else if(hardpointEnt.GetTeam()!=cappingTeam) { - // it seems like network vars won't change if they're too similar? often we get situations here where it's tryna change from 1.00098 to 1 which doesn't work - // so we need to check the "real" progress manually - // have only gotten this issue here so far, but in theory i think this could be an issue in a good few places, worth looking out for - // tho, idk might not be, we don't work with numbers at this small of a scale too often - float realProgress = max( 1.0, GetHardpointCaptureProgress( hardpoint ) - ( deltaTime / HARDPOINT_AMPED_DELAY ) ) - SetHardpointCaptureProgress( hardpoint, realProgress ) - - if ( realProgress == 1 ) - SetHardpointState( hardpoint, CAPTURE_POINT_STATE_CAPTURED ) - // dont use unamping atm - //else - // SetHardpointState( hardpoint, CAPTURE_POINT_STATE_SELF_UNAMPING ) + SetHardpointCappingTeam(hardpoint,cappingTeam) + SetHardpointCaptureProgress( hardpoint,max(0.0, GetHardpointCaptureProgress( hardpoint ) - ( deltaTime / CAPTURE_DURATION_CAPTURE * capperAmount) ) ) + if(GetHardpointCaptureProgress(hardpoint)<=1.0) + { + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED)//unamp + } + if(GetHardpointCaptureProgress(hardpoint)<=0.0) + { + SetHardpointCaptureProgress(hardpoint,1.0) + SetTeam( hardpointEnt, cappingTeam ) + SetTeam( hardpoint.prop, cappingTeam ) + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_CAPTURED) + EmitSoundOnEntityToTeamExceptPlayer( hardpointEnt, "hardpoint_console_captured", cappingTeam, null ) + GamemodeCP_VO_Captured( hardpointEnt ) + } } - - // scoring - if ( hardpointEnt.GetTeam() != TEAM_UNASSIGNED && GetHardpointState( hardpoint ) >= CAPTURE_POINT_STATE_CAPTURED && Time() - lastScoreTime >= TEAM_OWNED_SCORE_FREQ ) + else if(hardpointEnt.GetTeam()==cappingTeam) { - lastScoreTime = Time() - - // 2x score if amped + SetHardpointCappingTeam(hardpoint,cappingTeam) + if(GetHardpointCaptureProgress(hardpoint)<1.0) + { + SetHardpointCaptureProgress(hardpoint,GetHardpointCaptureProgress(hardpoint)+(deltaTime/CAPTURE_DURATION_CAPTURE*capperAmount)) + } + else if(file.ampingEnabled)//amping or reamping + { + if(GetHardpointState(hardpoint)<CAPTURE_POINT_STATE_AMPING) + SetHardpointState(hardpoint,CAPTURE_POINT_STATE_AMPING) + SetHardpointCaptureProgress( hardpoint, min( 2.0, GetHardpointCaptureProgress( hardpoint ) + ( deltaTime / HARDPOINT_AMPED_DELAY * capperAmount ) ) ) + if(GetHardpointCaptureProgress(hardpoint)==2.0&&!(GetHardpointState(hardpoint)==CAPTURE_POINT_STATE_AMPED)) + { + SetHardpointState( hardpoint, CAPTURE_POINT_STATE_AMPED ) + // can't use the dialogue functions here because for some reason GamemodeCP_VO_Amped isn't global? + PlayFactionDialogueToTeam( "amphp_youAmped" + hardpointEnt.kv.hardpointGroup, cappingTeam ) + PlayFactionDialogueToTeam( "amphp_enemyAmped" + hardpointEnt.kv.hardpointGroup, GetOtherTeam( cappingTeam ) ) + } + } + } + + if ( hardpointEnt.GetTeam() != TEAM_UNASSIGNED && GetHardpointState( hardpoint ) >= CAPTURE_POINT_STATE_CAPTURED && currentTime - lastScoreTime >= TEAM_OWNED_SCORE_FREQ && !hardpointBlocked&&!(cappingTeam==GetOtherTeam(hardpointEnt.GetTeam()))) + { + lastScoreTime = currentTime if ( GetHardpointState( hardpoint ) == CAPTURE_POINT_STATE_AMPED ) AddTeamScore( hardpointEnt.GetTeam(), 2 ) - else + else if( GetHardpointState( hardpoint) >= CAPTURE_POINT_STATE_CAPTURED) AddTeamScore( hardpointEnt.GetTeam(), 1 ) } - - lastTime = Time() + + lastTime = currentTime WaitFrame() } } @@ -264,33 +371,33 @@ void function HardpointThink( HardpointStruct hardpoint ) void function TrackChevronStates() { // you get 1 amped arrow for chevron / 4, 1 unamped arrow for every 1 the amped chevrons - + while ( true ) { int imcChevron int militiaChevron - + foreach ( HardpointStruct hardpoint in file.hardpoints ) { if ( hardpoint.hardpoint.GetTeam() == TEAM_IMC ) { if ( hardpoint.hardpoint.GetHardpointState() == CAPTURE_POINT_STATE_AMPED ) imcChevron += 4 - else if ( hardpoint.hardpoint.GetHardpointState() >= CAPTURE_POINT_STATE_CAPTURED ) + else imcChevron++ } else if ( hardpoint.hardpoint.GetTeam() == TEAM_MILITIA ) { if ( hardpoint.hardpoint.GetHardpointState() == CAPTURE_POINT_STATE_AMPED ) militiaChevron += 4 - else if ( hardpoint.hardpoint.GetHardpointState() >= CAPTURE_POINT_STATE_CAPTURED ) + else militiaChevron++ } } - + SetGlobalNetInt( "imcChevronState", imcChevron ) SetGlobalNetInt( "milChevronState", militiaChevron ) - + WaitFrame() } } @@ -319,4 +426,35 @@ void function OnHardpointLeft( entity trigger, entity player ) hardpoint.imcCappers.remove( hardpoint.imcCappers.find( player ) ) else hardpoint.militiaCappers.remove( hardpoint.militiaCappers.find( player ) ) -}
\ No newline at end of file +} + +string function CaptureStateToString( int state ) +{ + switch ( state ) + { + case CAPTURE_POINT_STATE_UNASSIGNED: + return "UNASSIGNED" + case CAPTURE_POINT_STATE_HALTED: + return "HALTED" + case CAPTURE_POINT_STATE_CAPTURED: + return "CAPTURED" + case CAPTURE_POINT_STATE_AMPING: + return "AMPING" + case CAPTURE_POINT_STATE_AMPED: + return "AMPED" + } + return "UNKNOWN" +} + +void function DEV_PrintHardpointsInfo() +{ + foreach (entity hardpoint in HARDPOINTS) + { + printt( + "Hardpoint:", hardpoint.kv.hardpointGroup, + "|Team:", Dev_TeamIDToString(hardpoint.GetTeam()), + "|State:", CaptureStateToString(hardpoint.GetHardpointState()), + "|Progress:", GetGlobalNetFloat("objective" + hardpoint.kv.hardpointGroup + "Progress") + ) + } +} diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ps.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ps.nut index 64a78d355..a02b9072e 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ps.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ps.nut @@ -30,7 +30,7 @@ void function GamemodePs_Init() void function GiveScoreForPlayerKill( entity victim, entity attacker, var damageInfo )
{
- if ( victim != attacker && victim.IsPlayer() && attacker.IsPlayer() || GetGameState() != eGameState.Playing )
+ if ( victim != attacker && victim.IsPlayer() && attacker.IsPlayer() && GetGameState() == eGameState.Playing )
AddTeamScore( attacker.GetTeam(), 1 )
table<int, bool> alreadyAssisted
@@ -230,4 +230,4 @@ void function RateSpawnpoints_SpawnZones( int checkClass, array<entity> spawnpoi spawn.CalculateRating( checkClass, player.GetTeam(), rating, rating )
}
-}
\ No newline at end of file +}
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_speedball.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_speedball.nut index 974481c18..207af721e 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_speedball.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_speedball.nut @@ -23,6 +23,7 @@ void function GamemodeSpeedball_Init() AddCallback_GameStateEnter( eGameState.Prematch, CreateFlagIfNoFlagSpawnpoint ) AddCallback_GameStateEnter( eGameState.Playing, ResetFlag ) + AddCallback_GameStateEnter( eGameState.WinnerDetermined,GamemodeSpeedball_OnWinnerDetermined) AddCallback_OnTouchHealthKit( "item_flag", OnFlagCollected ) AddCallback_OnPlayerKilled( OnPlayerKilled ) SetTimeoutWinnerDecisionFunc( TimeoutCheckFlagHolder ) @@ -147,3 +148,9 @@ int function TimeoutCheckFlagHolder() return file.flagCarrier.GetTeam() } + +void function GamemodeSpeedball_OnWinnerDetermined() +{ + if(IsValid(file.flagCarrier)) + file.flagCarrier.AddToPlayerGameStat( PGS_ASSAULT_SCORE, 1 ) +}
\ No newline at end of file diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_tdm.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_tdm.nut index 8699375ad..a3ea51725 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_tdm.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_tdm.nut @@ -10,7 +10,7 @@ void function GamemodeTdm_Init() void function GiveScoreForPlayerKill( entity victim, entity attacker, var damageInfo )
{
- if ( victim != attacker && victim.IsPlayer() && attacker.IsPlayer() || GetGameState() != eGameState.Playing )
+ if ( victim != attacker && victim.IsPlayer() && attacker.IsPlayer() && GetGameState() == eGameState.Playing )
AddTeamScore( attacker.GetTeam(), 1 )
table<int, bool> alreadyAssisted
@@ -48,4 +48,4 @@ int function CheckScoreForDraw() return TEAM_MILITIA
return TEAM_UNASSIGNED
-}
\ No newline at end of file +}
diff --git a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ttdm.nut b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ttdm.nut index 417d0fbfd..3102326cd 100644 --- a/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ttdm.nut +++ b/Northstar.CustomServers/mod/scripts/vscripts/gamemodes/_gamemode_ttdm.nut @@ -71,7 +71,7 @@ void function PlayerWatchesTTDMIntroIntermissionCam( entity player ) void function AddTeamScoreForPlayerKilled( entity victim, entity attacker, var damageInfo )
{
- if ( victim == attacker || !victim.IsPlayer() || !attacker.IsPlayer() || GetGameState() != eGameState.Playing )
+ if ( victim == attacker || !victim.IsPlayer() || !attacker.IsPlayer() && GetGameState() == eGameState.Playing )
return
AddTeamScore( GetOtherTeam( victim.GetTeam() ), 1 )
@@ -85,4 +85,4 @@ int function CheckScoreForDraw() return TEAM_MILITIA
return TEAM_UNASSIGNED
-}
\ No newline at end of file +}
|