aboutsummaryrefslogtreecommitdiff
path: root/Northstar.CustomServers/scripts/vscripts/_objective.gnut
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-06-22 14:30:49 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-06-22 14:30:49 +0100
commit207facbc402f5639cbcd31f079214351ef605cf2 (patch)
tree4710b2a88dd64f3dfea1609d31a5de9141640951 /Northstar.CustomServers/scripts/vscripts/_objective.gnut
parentc2d438568df6d98cf731807e30eaa7da31e5ea52 (diff)
downloadNorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.tar.gz
NorthstarMods-207facbc402f5639cbcd31f079214351ef605cf2.zip
initial commit after moving to new repo
Diffstat (limited to 'Northstar.CustomServers/scripts/vscripts/_objective.gnut')
-rw-r--r--Northstar.CustomServers/scripts/vscripts/_objective.gnut108
1 files changed, 108 insertions, 0 deletions
diff --git a/Northstar.CustomServers/scripts/vscripts/_objective.gnut b/Northstar.CustomServers/scripts/vscripts/_objective.gnut
new file mode 100644
index 00000000..893861bf
--- /dev/null
+++ b/Northstar.CustomServers/scripts/vscripts/_objective.gnut
@@ -0,0 +1,108 @@
+untyped
+
+global function Objective_Init
+
+global function RegisterObjective
+global function SetCurrentTeamObjectiveForPlayer
+global function SetTeamActiveObjective
+global function ClearTeamActiveObjective
+
+global function SetPlayerActiveObjective
+global function ClearPlayerActiveObjective
+
+int convIndex = 0 //Note that objectiveIndex 0 is reserved by code to mean no objective active!
+
+//Split this out into _objective_shared, _objective and cl_objective once QA gets a chance to hammer at it.
+function Objective_Init()
+{
+ level.objToIndex <- {}
+ level.teamActiveObjective <- { [TEAM_IMC] = null, [TEAM_MILITIA] = null }
+
+}
+
+function RegisterObjective( objectiveName )
+{
+ convIndex++
+ level.objToIndex[ objectiveName ] <- convIndex
+}
+
+function CreateTeamActiveObjectiveTable( objectiveName, objectiveTimer = 0, objectiveEntity = null )
+{
+ local Table = {}
+ Table.objectiveName <- objectiveName
+ Table.objectiveTimer <- objectiveTimer
+ Table.objectiveEntity <- objectiveEntity
+
+ return Table
+}
+
+function SetCurrentTeamObjectiveForPlayer( entity player )
+{
+ int team = player.GetTeam()
+ local objectiveTable = GetTeamActiveObjective( team )
+
+ if ( objectiveTable )
+ {
+ local objectiveName = objectiveTable.objectiveName
+ local objectiveTimer = objectiveTable.objectiveTimer
+ local objectiveEntity = objectiveTable.objectiveEntity
+ SetPlayerActiveObjective( player, objectiveName, objectiveTimer, objectiveEntity )
+ }
+}
+
+function GetTeamActiveObjective( team )
+{
+ if ( (team != TEAM_IMC) && (team != TEAM_MILITIA) )
+ return null
+ return level.teamActiveObjective[team]
+}
+
+function SetTeamActiveObjective( team, objectiveName, objectiveTimer = 0, objectiveEntity = null )
+{
+ Assert( team == TEAM_IMC || team == TEAM_MILITIA )
+ array<entity> players = GetPlayerArrayOfTeam( team )
+
+ local objectiveIndex = level.objToIndex[ objectiveName ]
+
+ foreach ( player in players )
+ {
+ SetPlayerActiveObjective_Internal( player, objectiveIndex, objectiveTimer, objectiveEntity )
+ }
+
+ level.teamActiveObjective[ team ] = CreateTeamActiveObjectiveTable( objectiveName, objectiveTimer, objectiveEntity )
+}
+
+function ClearTeamActiveObjective( team )
+{
+ Assert( team == TEAM_IMC || team == TEAM_MILITIA )
+ array<entity> players = GetPlayerArrayOfTeam( team )
+ foreach ( player in players )
+ {
+ ClearPlayerActiveObjective( player )
+ }
+
+ level.teamActiveObjective[ team ] = null
+
+}
+
+function SetPlayerActiveObjective( player, objectiveName, objectiveTimer = 0, objectiveEntity = null )
+{
+ local objectiveIndex = level.objToIndex[ objectiveName ]
+
+ SetPlayerActiveObjective_Internal( player, objectiveIndex, objectiveTimer, objectiveEntity )
+}
+
+function SetPlayerActiveObjective_Internal( player, objectiveIndex, objectiveTimer, objectiveEntity )
+{
+ player.SetObjectiveEndTime( objectiveTimer )
+ player.SetObjectiveEntity( objectiveEntity )
+ player.SetObjectiveIndex( objectiveIndex )
+}
+
+function ClearPlayerActiveObjective( player )
+{
+ player.SetObjectiveEndTime( 0 )
+ player.SetObjectiveEntity( null )
+ player.SetObjectiveIndex( 0 )
+}
+