mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge branch 'develop' into FF/Ops
This commit is contained in:
@@ -5832,6 +5832,7 @@ RATMANAGER={
|
||||
rat={},
|
||||
name={},
|
||||
alive={},
|
||||
planned={},
|
||||
min={},
|
||||
nrat=0,
|
||||
ntot=nil,
|
||||
@@ -5880,6 +5881,7 @@ function RATMANAGER:Add(ratobject,min)
|
||||
|
||||
self.rat[self.nrat]=ratobject
|
||||
self.alive[self.nrat]=0
|
||||
self.planned[self.nrat]=0
|
||||
self.name[self.nrat]=ratobject.alias
|
||||
self.min[self.nrat]=min or 1
|
||||
|
||||
@@ -6020,11 +6022,25 @@ function RATMANAGER:_Manage()
|
||||
for i=1,self.nrat do
|
||||
for j=1,N[i] do
|
||||
time=time+self.dTspawn
|
||||
SCHEDULER:New(nil, RAT._SpawnWithRoute, {self.rat[i]}, time)
|
||||
self.planned[i]=self.planned[i]+1
|
||||
SCHEDULER:New(nil, RATMANAGER._Spawn, {self, i}, time)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Instantly starts the RAT manager and spawns the initial random number RAT groups for each RAT object.
|
||||
-- @param #RATMANAGER self
|
||||
-- @param #RATMANAGER RATMANAGER self object.
|
||||
-- @param #number i Index.
|
||||
function RATMANAGER:_Spawn(i)
|
||||
|
||||
local rat=self.rat[i] --#RAT
|
||||
|
||||
rat:_SpawnWithRoute()
|
||||
self.planned[i]=self.planned[i]-1
|
||||
|
||||
end
|
||||
|
||||
--- Counts the number of alive RAT objects.
|
||||
-- @param #RATMANAGER self
|
||||
function RATMANAGER:_Count()
|
||||
@@ -6053,7 +6069,7 @@ function RATMANAGER:_Count()
|
||||
ntotal=ntotal+n
|
||||
|
||||
-- Debug output.
|
||||
local text=string.format("Number of alive groups of %s = %d", self.name[i], n)
|
||||
local text=string.format("Number of alive groups of %s = %d, planned=%d", self.name[i], n, self.planned[i])
|
||||
self:T(RATMANAGER.id..text)
|
||||
end
|
||||
|
||||
@@ -6083,9 +6099,10 @@ function RATMANAGER:_RollDice(nrat,ntot,min,alive)
|
||||
local M={}
|
||||
local P={}
|
||||
for i=1,nrat do
|
||||
local a=alive[i]+self.planned[i]
|
||||
N[#N+1]=0
|
||||
M[#M+1]=math.max(alive[i], min[i])
|
||||
P[#P+1]=math.max(min[i]-alive[i],0)
|
||||
M[#M+1]=math.max(a, min[i])
|
||||
P[#P+1]=math.max(min[i]-a,0)
|
||||
end
|
||||
|
||||
-- Min/max group arrays.
|
||||
@@ -6102,7 +6119,7 @@ function RATMANAGER:_RollDice(nrat,ntot,min,alive)
|
||||
-- Number of new groups to be added.
|
||||
local nnew=ntot
|
||||
for i=1,nrat do
|
||||
nnew=nnew-alive[i]
|
||||
nnew=nnew-alive[i]-self.planned[i]
|
||||
end
|
||||
|
||||
for i=1,nrat-1 do
|
||||
@@ -6134,7 +6151,7 @@ function RATMANAGER:_RollDice(nrat,ntot,min,alive)
|
||||
end
|
||||
|
||||
-- Debug info
|
||||
self:T3(string.format("RATMANAGER: i=%d, alive=%d, min=%d, mini=%d, maxi=%d, add=%d, sumN=%d, sumP=%d", j, alive[j], min[j], mini[j], maxi[j], N[j],sN, sP))
|
||||
self:T3(string.format("RATMANAGER: i=%d, alive=%d, planned=%d, min=%d, mini=%d, maxi=%d, add=%d, sumN=%d, sumP=%d", j, alive[j], self.planned[i], min[j], mini[j], maxi[j], N[j],sN, sP))
|
||||
|
||||
end
|
||||
|
||||
@@ -6149,7 +6166,7 @@ function RATMANAGER:_RollDice(nrat,ntot,min,alive)
|
||||
-- Debug info
|
||||
local text=RATMANAGER.id.."\n"
|
||||
for i=1,nrat do
|
||||
text=text..string.format("%s: i=%d, alive=%d, min=%d, mini=%d, maxi=%d, add=%d\n", self.name[i], i, alive[i], min[i], mini[i], maxi[i], N[i])
|
||||
text=text..string.format("%s: i=%d, alive=%d, planned=%d, min=%d, mini=%d, maxi=%d, add=%d\n", self.name[i], i, alive[i], self.planned[i], min[i], mini[i], maxi[i], N[i])
|
||||
end
|
||||
text=text..string.format("Total # of groups to add = %d", sum(N, done))
|
||||
self:T(text)
|
||||
|
||||
@@ -715,11 +715,11 @@ function SCORING:AddGoalScorePlayer( PlayerName, GoalTag, Text, Score )
|
||||
PlayerData.Goals[GoalTag] = PlayerData.Goals[GoalTag] or { Score = 0 }
|
||||
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
||||
PlayerData.Score = PlayerData.Score + Score
|
||||
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
|
||||
if Text then
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
end
|
||||
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, nil )
|
||||
end
|
||||
end
|
||||
@@ -738,7 +738,7 @@ function SCORING:AddGoalScore( PlayerUnit, GoalTag, Text, Score )
|
||||
|
||||
local PlayerName = PlayerUnit:GetPlayerName()
|
||||
|
||||
self:F( { PlayerUnit.UnitName, PlayerName, GoalTag, Text, Score } )
|
||||
self:T2( { PlayerUnit.UnitName, PlayerName, GoalTag, Text, Score } )
|
||||
|
||||
-- PlayerName can be nil, if the Unit with the player crashed or due to another reason.
|
||||
if PlayerName then
|
||||
@@ -747,11 +747,12 @@ function SCORING:AddGoalScore( PlayerUnit, GoalTag, Text, Score )
|
||||
PlayerData.Goals[GoalTag] = PlayerData.Goals[GoalTag] or { Score = 0 }
|
||||
PlayerData.Goals[GoalTag].Score = PlayerData.Goals[GoalTag].Score + Score
|
||||
PlayerData.Score = PlayerData.Score + Score
|
||||
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||
|
||||
if Text then
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Text,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
|
||||
end
|
||||
self:ScoreCSV( PlayerName, "", "GOAL_" .. string.upper( GoalTag ), 1, Score, PlayerUnit:GetName() )
|
||||
end
|
||||
end
|
||||
@@ -784,11 +785,12 @@ function SCORING:_AddMissionTaskScore( Mission, PlayerUnit, Text, Score )
|
||||
|
||||
PlayerData.Score = self.Players[PlayerName].Score + Score
|
||||
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
|
||||
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Mission:GetText() .. " : " .. Text .. " Score: " .. Score,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
|
||||
|
||||
if Text then
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. Mission:GetText() .. " : " .. Text .. " Score: " .. Score,
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
end
|
||||
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score, PlayerUnit:GetName() )
|
||||
end
|
||||
end
|
||||
@@ -820,9 +822,11 @@ function SCORING:_AddMissionGoalScore( Mission, PlayerName, Text, Score )
|
||||
|
||||
PlayerData.Score = self.Players[PlayerName].Score + Score
|
||||
PlayerData.Mission[MissionName].ScoreTask = self.Players[PlayerName].Mission[MissionName].ScoreTask + Score
|
||||
|
||||
MESSAGE:NewType( string.format( "%s%s: %s! Player %s receives %d score!", self.DisplayMessagePrefix, Mission:GetText(), Text, PlayerName, Score ), MESSAGE.Type.Information ):ToAll()
|
||||
|
||||
|
||||
if Text then
|
||||
MESSAGE:NewType( string.format( "%s%s: %s! Player %s receives %d score!", self.DisplayMessagePrefix, Mission:GetText(), Text, PlayerName, Score ), MESSAGE.Type.Information ):ToAll()
|
||||
end
|
||||
|
||||
self:ScoreCSV( PlayerName, "", "TASK_" .. MissionName:gsub( ' ', '_' ), 1, Score )
|
||||
end
|
||||
end
|
||||
@@ -847,11 +851,12 @@ function SCORING:_AddMissionScore( Mission, Text, Score )
|
||||
|
||||
PlayerData.Score = PlayerData.Score + Score
|
||||
PlayerData.Mission[MissionName].ScoreMission = PlayerData.Mission[MissionName].ScoreMission + Score
|
||||
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' has " .. Text .. " in " .. Mission:GetText() .. ". " .. Score .. " mission score!",
|
||||
|
||||
if Text then
|
||||
MESSAGE:NewType( self.DisplayMessagePrefix .. "Player '" .. PlayerName .. "' has " .. Text .. " in " .. Mission:GetText() .. ". " .. Score .. " mission score!",
|
||||
MESSAGE.Type.Information )
|
||||
:ToAll()
|
||||
|
||||
end
|
||||
self:ScoreCSV( PlayerName, "", "MISSION_" .. MissionName:gsub( ' ', '_' ), 1, Score )
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user