Compare commits
1 Commits
restore-st
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2412e451ca |
@@ -41,7 +41,7 @@ function DefineFactions()
|
|||||||
RebelFaction.DisplayName = "Rebellion"
|
RebelFaction.DisplayName = "Rebellion"
|
||||||
RebelFaction.Color = ColorStruct:New(1, 0, 0, 1)
|
RebelFaction.Color = ColorStruct:New(1, 0, 0, 1)
|
||||||
RebelFaction.Icon = "I_ICON_SPECTATOR_REBEL.TGA"
|
RebelFaction.Icon = "I_ICON_SPECTATOR_REBEL.TGA"
|
||||||
RebelFaction.LandStartUnitName = "Rebel_Infantry_Squad"
|
RebelFaction.LandStartUnitName = "Rebel_Trooper_Team"
|
||||||
RebelFaction.SpaceStartUnitName = "Rebel_X-Wing_Squadron"
|
RebelFaction.SpaceStartUnitName = "Rebel_X-Wing_Squadron"
|
||||||
factions[RebelFaction.Name] = RebelFaction
|
factions[RebelFaction.Name] = RebelFaction
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ function DefineFactions()
|
|||||||
EmpireFaction.DisplayName = "Empire"
|
EmpireFaction.DisplayName = "Empire"
|
||||||
EmpireFaction.Color = ColorStruct:New(0, 1, 1, 1)
|
EmpireFaction.Color = ColorStruct:New(0, 1, 1, 1)
|
||||||
EmpireFaction.Icon = "I_ICON_SPECTATOR_EMPIRE.TGA"
|
EmpireFaction.Icon = "I_ICON_SPECTATOR_EMPIRE.TGA"
|
||||||
EmpireFaction.LandStartUnitName = "Imperial_Stormtrooper_Squad"
|
EmpireFaction.LandStartUnitName = "Stormtrooper_Team"
|
||||||
EmpireFaction.SpaceStartUnitName = "TIE_Interceptor_Squadron_Container"
|
EmpireFaction.SpaceStartUnitName = "TIE_Interceptor_Squadron_Container"
|
||||||
factions[EmpireFaction.Name] = EmpireFaction
|
factions[EmpireFaction.Name] = EmpireFaction
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ function DefineFactions()
|
|||||||
UnderworldFaction.DisplayName = "Zann Consortium"
|
UnderworldFaction.DisplayName = "Zann Consortium"
|
||||||
UnderworldFaction.Color = ColorStruct:New(1, 1, 0, 1)
|
UnderworldFaction.Color = ColorStruct:New(1, 1, 0, 1)
|
||||||
UnderworldFaction.Icon = "I_ICON_SPECTATOR_UNDERWORLD.TGA"
|
UnderworldFaction.Icon = "I_ICON_SPECTATOR_UNDERWORLD.TGA"
|
||||||
UnderworldFaction.LandStartUnitName = "Underworld_Merc_Squad"
|
UnderworldFaction.LandStartUnitName = "Underworld_Merc_Team"
|
||||||
UnderworldFaction.SpaceStartUnitName = "StarViper_Team"
|
UnderworldFaction.SpaceStartUnitName = "StarViper_Team"
|
||||||
factions[UnderworldFaction.Name] = UnderworldFaction
|
factions[UnderworldFaction.Name] = UnderworldFaction
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ function DefineFactions()
|
|||||||
HuttFaction.DisplayName = "Hutt Cartel"
|
HuttFaction.DisplayName = "Hutt Cartel"
|
||||||
HuttFaction.Color = ColorStruct:New(1, 0, 1, 1)
|
HuttFaction.Color = ColorStruct:New(1, 0, 1, 1)
|
||||||
HuttFaction.Icon = "I_ICON_SPECTATOR_HUTTS.TGA"
|
HuttFaction.Icon = "I_ICON_SPECTATOR_HUTTS.TGA"
|
||||||
HuttFaction.LandStartUnitName = "Hutt_Soldier_Squad"
|
HuttFaction.LandStartUnitName = "Hutt_Soldier_Team"
|
||||||
HuttFaction.SpaceStartUnitName = "V_Wing_Squadron_Container"
|
HuttFaction.SpaceStartUnitName = "V_Wing_Squadron_Container"
|
||||||
factions[HuttFaction.Name] = HuttFaction
|
factions[HuttFaction.Name] = HuttFaction
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ function DefineFactions()
|
|||||||
PirateFaction.DisplayName = "Pirates"
|
PirateFaction.DisplayName = "Pirates"
|
||||||
PirateFaction.Color = ColorStruct:New(0, 1, 0, 1)
|
PirateFaction.Color = ColorStruct:New(0, 1, 0, 1)
|
||||||
PirateFaction.Icon = "I_ICON_SPECTATOR_PIRATES.TGA"
|
PirateFaction.Icon = "I_ICON_SPECTATOR_PIRATES.TGA"
|
||||||
PirateFaction.LandStartUnitName = "Pirate_Soldier_Squad"
|
PirateFaction.LandStartUnitName = "Pirate_Trooper_Team"
|
||||||
PirateFaction.SpaceStartUnitName = "Pirate_Fighter_Squadron"
|
PirateFaction.SpaceStartUnitName = "Pirate_Fighter_Squadron"
|
||||||
factions[PirateFaction.Name] = PirateFaction
|
factions[PirateFaction.Name] = PirateFaction
|
||||||
|
|
||||||
@@ -94,31 +94,6 @@ end
|
|||||||
---@type FactionStruct[]
|
---@type FactionStruct[]
|
||||||
Factions = DefineFactions()
|
Factions = DefineFactions()
|
||||||
|
|
||||||
---Faction Title Rank table. Rebel at 2, Empire at 3
|
|
||||||
---@type table
|
|
||||||
FactionTitleTable = {
|
|
||||||
{ 145000, "TEXT_REBEL_TITLE19", "TEXT_EMPIRE_TITLE19" },
|
|
||||||
{ 125000, "TEXT_REBEL_TITLE18", "TEXT_EMPIRE_TITLE18" },
|
|
||||||
{ 115000, "TEXT_REBEL_TITLE17", "TEXT_EMPIRE_TITLE17" },
|
|
||||||
{ 100000, "TEXT_REBEL_TITLE16", "TEXT_EMPIRE_TITLE16" },
|
|
||||||
{ 90000, "TEXT_REBEL_TITLE15", "TEXT_EMPIRE_TITLE15" },
|
|
||||||
{ 85000, "TEXT_REBEL_TITLE14", "TEXT_EMPIRE_TITLE14" },
|
|
||||||
{ 80000, "TEXT_REBEL_TITLE13", "TEXT_EMPIRE_TITLE13" },
|
|
||||||
{ 75000, "TEXT_REBEL_TITLE12", "TEXT_EMPIRE_TITLE12" },
|
|
||||||
{ 70000, "TEXT_REBEL_TITLE11", "TEXT_EMPIRE_TITLE11" },
|
|
||||||
{ 60000, "TEXT_REBEL_TITLE10", "TEXT_EMPIRE_TITLE10" },
|
|
||||||
{ 55000, "TEXT_REBEL_TITLE9", "TEXT_EMPIRE_TITLE9" },
|
|
||||||
{ 50000, "TEXT_REBEL_TITLE8", "TEXT_EMPIRE_TITLE8" },
|
|
||||||
{ 45000, "TEXT_REBEL_TITLE7", "TEXT_EMPIRE_TITLE7" },
|
|
||||||
{ 40000, "TEXT_REBEL_TITLE6", "TEXT_EMPIRE_TITLE6" },
|
|
||||||
{ 25000, "TEXT_REBEL_TITLE5", "TEXT_EMPIRE_TITLE5" },
|
|
||||||
{ 20000, "TEXT_REBEL_TITLE4", "TEXT_EMPIRE_TITLE4" },
|
|
||||||
{ 15000, "TEXT_REBEL_TITLE3", "TEXT_EMPIRE_TITLE3" },
|
|
||||||
{ 10000, "TEXT_REBEL_TITLE2", "TEXT_EMPIRE_TITLE2" },
|
|
||||||
{ 5000, "TEXT_REBEL_TITLE1", "TEXT_EMPIRE_TITLE1" },
|
|
||||||
{ 0, "TEXT_REBEL_TITLE0", "TEXT_EMPIRE_TITLE0" }
|
|
||||||
}
|
|
||||||
|
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
-- Define Spectator Constants
|
-- Define Spectator Constants
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
@@ -153,3 +128,6 @@ UI_PlanetaryPop = "text_planetary_pop"
|
|||||||
|
|
||||||
---GUI Component to enable/disable tactical credits.
|
---GUI Component to enable/disable tactical credits.
|
||||||
UI_CreditsTactical = "text_credits_tactical"
|
UI_CreditsTactical = "text_credits_tactical"
|
||||||
|
|
||||||
|
---GUI Component to enable/disable tactical tech.
|
||||||
|
UI_TechTactical = "text_tactical_tech"
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ function GUIManager:InitSkirmish(isSpectator)
|
|||||||
|
|
||||||
GUI_Component_Visibility(UI_PlanetaryPop, false)
|
GUI_Component_Visibility(UI_PlanetaryPop, false)
|
||||||
GUI_Component_Visibility(UI_CreditsTactical, false)
|
GUI_Component_Visibility(UI_CreditsTactical, false)
|
||||||
|
GUI_Component_Visibility(UI_TechTactical, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ function GUIManager:Reset()
|
|||||||
|
|
||||||
GUI_Component_Visibility(UI_PlanetaryPop, true)
|
GUI_Component_Visibility(UI_PlanetaryPop, true)
|
||||||
GUI_Component_Visibility(UI_CreditsTactical, true)
|
GUI_Component_Visibility(UI_CreditsTactical, true)
|
||||||
|
GUI_Component_Visibility(UI_TechTactical, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Services Game Time display.
|
---Services Game Time display.
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ require("GameManager/UnitClass")
|
|||||||
---@class GalacticGameClass
|
---@class GalacticGameClass
|
||||||
---@field StartTime integer The start time.
|
---@field StartTime integer The start time.
|
||||||
---@field Players PlayerClass[] The combatant players in this game.
|
---@field Players PlayerClass[] The combatant players in this game.
|
||||||
---@field BuildStatsTable table The engine-owned GalacticBuildStatsTable reference, set from GameScoring.lua.
|
---@field Units UnitClass[] The units in this game.
|
||||||
---@field KillStatsTable table The engine-owned GalacticKillStatsTable reference, set from GameScoring.lua.
|
|
||||||
---@field NeutralizedStatsTable table The engine-owned GalacticNeutralizedTable reference, set from GameScoring.lua.
|
|
||||||
---@field GalacticConquestTable table The engine-owned GalacticConquestTable reference, set from GameScoring.lua.
|
|
||||||
GalacticGameClass = {}
|
GalacticGameClass = {}
|
||||||
GalacticGameClass.__index = GalacticGameClass
|
GalacticGameClass.__index = GalacticGameClass
|
||||||
|
|
||||||
@@ -18,8 +15,15 @@ function GalacticGameClass:New()
|
|||||||
ScriptMessage("Initializing Galactic game...")
|
ScriptMessage("Initializing Galactic game...")
|
||||||
local self = setmetatable({}, GalacticGameClass)
|
local self = setmetatable({}, GalacticGameClass)
|
||||||
|
|
||||||
|
---Finds all combatant players in the game.
|
||||||
|
---@return PlayerClass[]
|
||||||
|
local function FindPlayers()
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
self.StartTime = GetCurrentTime()
|
self.StartTime = GetCurrentTime()
|
||||||
self.Players = self:_FindPlayers()
|
self.Players = FindPlayers()
|
||||||
|
self.Units = {}
|
||||||
ScriptMessage("Galactic Game initialized!")
|
ScriptMessage("Galactic Game initialized!")
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@@ -30,15 +34,11 @@ function GalacticGameClass:Service()
|
|||||||
ScriptMessage("Servicing Galactic game...")
|
ScriptMessage("Servicing Galactic game...")
|
||||||
|
|
||||||
-- Service Players
|
-- Service Players
|
||||||
for _, player in pairs(self.Players) do
|
for playerId, player in pairs(self.Players) do
|
||||||
player:Service()
|
player:Service()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ==================================================
|
|
||||||
-- Player event handlers
|
|
||||||
-- ==================================================
|
|
||||||
|
|
||||||
---Gets the Player by ID.
|
---Gets the Player by ID.
|
||||||
---@param id integer Player ID
|
---@param id integer Player ID
|
||||||
---@return PlayerClass|nil
|
---@return PlayerClass|nil
|
||||||
@@ -60,263 +60,14 @@ function GalacticGameClass:PlayerQuit(id)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ==================================================
|
|
||||||
-- Unit event handlers
|
|
||||||
-- ==================================================
|
|
||||||
|
|
||||||
---Adds a built unit to the Unit table.
|
---Adds a built unit to the Unit table.
|
||||||
---@param objectType GameObjectType The game object type that was built.
|
---@param objectType table The FoC GameObjectTypeWrapper object type that was built.
|
||||||
---@param player PlayerObject The player that owns the new game object.
|
---@param player table The FoC PlayerWrapper object that owns the new Unit.
|
||||||
---@param planet PlanetObject The planet the game object type was built at.
|
function GalacticGameClass:UnitBuilt(objectType, player)
|
||||||
function GalacticGameClass:UnitBuilt(objectType, player, planet)
|
|
||||||
local playerId = player.Get_ID()
|
local playerId = player.Get_ID()
|
||||||
local playerEntry = self.Players[playerId]
|
local playerEntry = self.Players[playerId]
|
||||||
|
|
||||||
if playerEntry then
|
if playerEntry then
|
||||||
local unit = playerEntry:AddUnit(objectType)
|
playerEntry:AddUnit(objectType)
|
||||||
|
|
||||||
self:UpdateGalacticBuildStatsTable(unit, planet)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Sets a unit as killed.
|
|
||||||
---@param gameObject GameObject The game object that was killed.
|
|
||||||
---@param killer PlayerObject The player that killed the game object.
|
|
||||||
function GalacticGameClass:UnitKilled(gameObject, killer)
|
|
||||||
local ownerId = gameObject.Get_Owner().Get_ID()
|
|
||||||
local owner = self.Players[ownerId]
|
|
||||||
|
|
||||||
if not owner then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
---@type UnitClass|nil
|
|
||||||
local killedUnit = nil
|
|
||||||
|
|
||||||
for _, unit in pairs(owner.Units) do
|
|
||||||
if unit.GameObject == gameObject then
|
|
||||||
killedUnit = unit
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if killedUnit then
|
|
||||||
killedUnit:SetDead(killer.Get_ID())
|
|
||||||
self:UpdateGalacticKillStatsTable(killedUnit, killer)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function GalacticGameClass:UnitNeutralized(objectType, killer)
|
|
||||||
self:UpdateGalacticNeutralizedTable(objectType, killer)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ==================================================
|
|
||||||
-- Planet event handlers
|
|
||||||
-- ==================================================
|
|
||||||
|
|
||||||
---Sets a planet as changed faction.
|
|
||||||
---@param planet PlanetObject
|
|
||||||
---@param newOwner PlayerObject
|
|
||||||
---@param oldOwner PlayerObject
|
|
||||||
function GalacticGameClass:PlanetFactionChange(planet, newOwner, oldOwner)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ==================================================
|
|
||||||
-- Stat tables
|
|
||||||
-- ==================================================
|
|
||||||
|
|
||||||
---Updates the Galactic Build Stats Table with the build object type.
|
|
||||||
---@param unit UnitClass The game object type that was built.
|
|
||||||
---@param planet PlanetObject|nil The planet where the game object was built.
|
|
||||||
function GalacticGameClass:UpdateGalacticBuildStatsTable(unit, planet)
|
|
||||||
---@type GameObjectType|integer
|
|
||||||
local planetType = 1
|
|
||||||
|
|
||||||
if planet then
|
|
||||||
planetType = planet.Get_Type()
|
|
||||||
end
|
|
||||||
|
|
||||||
local playerEntry = self.BuildStatsTable[unit.OwnerId]
|
|
||||||
|
|
||||||
if not playerEntry then
|
|
||||||
playerEntry = {}
|
|
||||||
self.BuildStatsTable[unit.OwnerId] = playerEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local planetEntry = playerEntry[planetType]
|
|
||||||
|
|
||||||
if not planetEntry then
|
|
||||||
planetEntry = {}
|
|
||||||
playerEntry[planetType] = planetEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local typeEntry = planetEntry[unit.Name]
|
|
||||||
|
|
||||||
if not typeEntry then
|
|
||||||
typeEntry = {
|
|
||||||
build_count = 1,
|
|
||||||
combat_power = unit.CombatRating,
|
|
||||||
build_cost = unit.BuildCost,
|
|
||||||
score_value = unit.ScoreValue
|
|
||||||
}
|
|
||||||
planetEntry[unit.Name] = typeEntry
|
|
||||||
else
|
|
||||||
typeEntry.build_count = typeEntry.build_count + 1
|
|
||||||
typeEntry.combat_power = typeEntry.combat_power + unit.CombatRating
|
|
||||||
typeEntry.build_cost = typeEntry.build_cost + unit.BuildCost
|
|
||||||
typeEntry.score_value = typeEntry.score_value + unit.ScoreValue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---Updates the Galactic Kill Stats Table with the killed object.
|
|
||||||
---@param unit UnitClass The unit that was killed.
|
|
||||||
---@param killer PlayerObject The player that killed the unit.
|
|
||||||
function GalacticGameClass:UpdateGalacticKillStatsTable(unit, killer)
|
|
||||||
if not TestValid(killer) then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update Frags
|
|
||||||
local fragEntry = self.KillStatsTable[FragIndex]
|
|
||||||
|
|
||||||
if not fragEntry then
|
|
||||||
fragEntry = {}
|
|
||||||
self.KillStatsTable[FragIndex] = fragEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local killerId = killer.Get_ID()
|
|
||||||
local killerEntry = fragEntry[killerId]
|
|
||||||
|
|
||||||
if not killerEntry then
|
|
||||||
killerEntry = {}
|
|
||||||
fragEntry[killerId] = killerEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local killerObjEntry = killerEntry[unit.GameObjectType]
|
|
||||||
|
|
||||||
if not killerObjEntry then
|
|
||||||
killerObjEntry = {
|
|
||||||
kills = 1,
|
|
||||||
combat_power = unit.CombatRating,
|
|
||||||
build_cost = unit.BuildCost,
|
|
||||||
score_value = unit.ScoreValue
|
|
||||||
}
|
|
||||||
killerEntry[unit.GameObjectType] = killerObjEntry
|
|
||||||
else
|
|
||||||
killerObjEntry.kills = killerObjEntry.kills + 1
|
|
||||||
killerObjEntry.combat_power = killerObjEntry.combat_power + unit.CombatRating
|
|
||||||
killerObjEntry.build_cost = killerObjEntry.build_cost + unit.BuildCost
|
|
||||||
killerObjEntry.score_value = killerObjEntry.score_value + unit.ScoreValue
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Update Deaths
|
|
||||||
local deathEntry = self.KillStatsTable[DeathIndex]
|
|
||||||
|
|
||||||
if not deathEntry then
|
|
||||||
deathEntry = {}
|
|
||||||
self.KillStatsTable[DeathIndex] = deathEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local ownerEntry = deathEntry[unit.OwnerId]
|
|
||||||
|
|
||||||
if not ownerEntry then
|
|
||||||
ownerEntry = {}
|
|
||||||
deathEntry[unit.OwnerId] = ownerEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local ownerObjEntry = ownerEntry[unit.GameObjectType]
|
|
||||||
|
|
||||||
if not ownerObjEntry then
|
|
||||||
ownerObjEntry = {
|
|
||||||
kills = 1,
|
|
||||||
combat_power = unit.CombatRating,
|
|
||||||
build_cost = unit.BuildCost,
|
|
||||||
score_value = unit.ScoreValue
|
|
||||||
}
|
|
||||||
ownerEntry[unit.GameObjectType] = ownerObjEntry
|
|
||||||
else
|
|
||||||
ownerObjEntry.kills = ownerObjEntry.kills + 1
|
|
||||||
ownerObjEntry.combat_power = ownerObjEntry.combat_power + unit.CombatRating
|
|
||||||
ownerObjEntry.build_cost = ownerObjEntry.build_cost + unit.BuildCost
|
|
||||||
ownerObjEntry.score_value = ownerObjEntry.score_value + unit.ScoreValue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---Updates the Galactic Neutralized Table with the neutralized hero.
|
|
||||||
---@param objectType GameObjectType The hero type that was neutralized.
|
|
||||||
---@param killer GameObject The hero that killed this hero.
|
|
||||||
function GalacticGameClass:UpdateGalacticNeutralizedTable(objectType, killer)
|
|
||||||
local killerId = killer.Get_Owner().Get_ID()
|
|
||||||
local killerEntry = self.NeutralizedStatsTable[killerId]
|
|
||||||
|
|
||||||
if not killerEntry then
|
|
||||||
killerEntry = {}
|
|
||||||
self.NeutralizedStatsTable[killerId] = killerEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local neutralizedEntry = killerEntry[objectType]
|
|
||||||
|
|
||||||
if not neutralizedEntry then
|
|
||||||
neutralizedEntry = {
|
|
||||||
neutralized = 1
|
|
||||||
}
|
|
||||||
killerEntry[objectType] = neutralizedEntry
|
|
||||||
else
|
|
||||||
neutralizedEntry.neutralized = neutralizedEntry.neutralized + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ==================================================
|
|
||||||
-- Private functions
|
|
||||||
-- ==================================================
|
|
||||||
|
|
||||||
---@private
|
|
||||||
---Finds all players of defined Factions via FoCAPI.
|
|
||||||
---@return PlayerClass[]
|
|
||||||
function GalacticGameClass:_FindPlayers()
|
|
||||||
local isSuccess, result = pcall(Get_All_Players)
|
|
||||||
|
|
||||||
if isSuccess then
|
|
||||||
local players = {}
|
|
||||||
|
|
||||||
for _, playerWrapper in pairs(result) do
|
|
||||||
local factionName = playerWrapper.Get_Faction_Name()
|
|
||||||
|
|
||||||
for _, faction in pairs(Factions) do
|
|
||||||
if faction.Name == factionName then
|
|
||||||
local player = PlayerClass:New(playerWrapper)
|
|
||||||
|
|
||||||
players[player.Id] = player
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return players
|
|
||||||
end
|
|
||||||
|
|
||||||
return self:_FindPlayersFallback()
|
|
||||||
end
|
|
||||||
|
|
||||||
---@private
|
|
||||||
---Finds all players of defined Factions via planets.
|
|
||||||
---@return PlayerClass[]
|
|
||||||
function GalacticGameClass:_FindPlayersFallback()
|
|
||||||
---@type PlayerClass[]
|
|
||||||
local players = {}
|
|
||||||
|
|
||||||
for _, planet in pairs(FindPlanet.Get_All_Planets()) do
|
|
||||||
local owner = planet.Get_Owner()
|
|
||||||
local factionName = owner.Get_Faction_Name()
|
|
||||||
|
|
||||||
for _, faction in pairs(Factions) do
|
|
||||||
if faction.Name == factionName then
|
|
||||||
local player = PlayerClass:New(owner)
|
|
||||||
|
|
||||||
players[player.Id] = player
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return players
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ function PlayerClass:HasQuit()
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Adds a Unit type to the Player's reinforcement list.
|
---Adds a Unit type to the Player's reinforcement list.
|
||||||
---@param objectType GameObjectType FoC GameObjectTypeWrapper object that was built.
|
---@param objectType table FoC GameObjectTypeWrapper object that was built.
|
||||||
---@return UnitClass
|
---@return UnitClass
|
||||||
function PlayerClass:AddUnit(objectType)
|
function PlayerClass:AddUnit(objectType)
|
||||||
local unit = UnitClass:New(objectType, self.Id)
|
local unit = UnitClass:New(objectType, self.Id)
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ require("GameManager/TutorialTextFeed")
|
|||||||
---@field StartTime integer The start time.
|
---@field StartTime integer The start time.
|
||||||
---@field Players PlayerClass[] The combatant players in this game.
|
---@field Players PlayerClass[] The combatant players in this game.
|
||||||
---@field CombatFeed TutorialTextFeed Text feed for unit builds and kills.
|
---@field CombatFeed TutorialTextFeed Text feed for unit builds and kills.
|
||||||
---@field BuildStatsTable table The engine-owned TacticalBuildStatsTable reference, set from GameScoring.lua.
|
|
||||||
---@field KillStatsTable table The engine-owned TacticalKillStatsTable reference, set from GameScoring.lua.
|
---@field KillStatsTable table The engine-owned TacticalKillStatsTable reference, set from GameScoring.lua.
|
||||||
TacticalGameClass = {}
|
TacticalGameClass = {}
|
||||||
TacticalGameClass.__index = TacticalGameClass
|
TacticalGameClass.__index = TacticalGameClass
|
||||||
@@ -84,17 +83,15 @@ end
|
|||||||
-- ==================================================
|
-- ==================================================
|
||||||
|
|
||||||
---Adds a built unit to the Unit table.
|
---Adds a built unit to the Unit table.
|
||||||
---@param objectType GameObjectType The game object type that was built.
|
---@param objectType GameObjectType The FoC GameObjectTypeWrapper object type that was built.
|
||||||
---@param player PlayerObject The player that owns the new game object.
|
---@param player PlayerObject The FoC PlayerWrapper object that owns the new Unit.
|
||||||
---@param planet PlanetObject|nil The planet the game object type was built at.
|
function TacticalGameClass:UnitBuilt(objectType, player)
|
||||||
function TacticalGameClass:UnitBuilt(objectType, player, planet)
|
|
||||||
local playerId = player.Get_ID()
|
local playerId = player.Get_ID()
|
||||||
local playerEntry = self.Players[playerId]
|
local playerEntry = self.Players[playerId]
|
||||||
|
|
||||||
if playerEntry then
|
if playerEntry then
|
||||||
local unit = playerEntry:AddUnit(objectType)
|
local unit = playerEntry:AddUnit(objectType)
|
||||||
|
|
||||||
self:UpdateTacticalBuildStatsTable(unit, planet)
|
|
||||||
self:CombatTextUnitBuilt(unit)
|
self:CombatTextUnitBuilt(unit)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -129,8 +126,8 @@ function TacticalGameClass:CombatTextUnitBuilt(unit)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---Sets a unit as killed.
|
---Sets a unit as killed.
|
||||||
---@param gameObject GameObject The game object that was killed.
|
---@param gameObject GameObject The FoC GameObjectWrapper object that was killed.
|
||||||
---@param killer PlayerObject The player that killed the game object.
|
---@param killer PlayerObject The FoC PlayerWrapper object that killed the Unit.
|
||||||
function TacticalGameClass:UnitKilled(gameObject, killer)
|
function TacticalGameClass:UnitKilled(gameObject, killer)
|
||||||
local ownerId = gameObject.Get_Owner().Get_ID()
|
local ownerId = gameObject.Get_Owner().Get_ID()
|
||||||
local owner = self.Players[ownerId]
|
local owner = self.Players[ownerId]
|
||||||
@@ -198,49 +195,6 @@ end
|
|||||||
--- Stat tables
|
--- Stat tables
|
||||||
--- ==================================================
|
--- ==================================================
|
||||||
|
|
||||||
---Updates the Tactical Build Stats Table with the build object type.
|
|
||||||
---@param unit UnitClass The game object type that was built.
|
|
||||||
---@param planet PlanetObject|nil The planet the game object type was built at.
|
|
||||||
function TacticalGameClass:UpdateTacticalBuildStatsTable(unit, planet)
|
|
||||||
---@type GameObjectType|integer
|
|
||||||
local planetType = 1
|
|
||||||
|
|
||||||
if planet then
|
|
||||||
planetType = planet.Get_Type()
|
|
||||||
end
|
|
||||||
|
|
||||||
local playerEntry = self.BuildStatsTable[unit.OwnerId]
|
|
||||||
|
|
||||||
if not playerEntry then
|
|
||||||
playerEntry = {}
|
|
||||||
self.BuildStatsTable[unit.OwnerId] = playerEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local planetEntry = playerEntry[planetType]
|
|
||||||
|
|
||||||
if not planetEntry then
|
|
||||||
planetEntry = {}
|
|
||||||
playerEntry[planetType] = planetEntry
|
|
||||||
end
|
|
||||||
|
|
||||||
local typeEntry = planetEntry[unit.Name]
|
|
||||||
|
|
||||||
if not typeEntry then
|
|
||||||
typeEntry = {
|
|
||||||
build_count = 1,
|
|
||||||
combat_power = unit.CombatRating,
|
|
||||||
build_cost = unit.BuildCost,
|
|
||||||
score_value = unit.ScoreValue
|
|
||||||
}
|
|
||||||
planetEntry[unit.Name] = typeEntry
|
|
||||||
else
|
|
||||||
typeEntry.build_count = typeEntry.build_count + 1
|
|
||||||
typeEntry.combat_power = typeEntry.combat_power + unit.CombatRating
|
|
||||||
typeEntry.build_cost = typeEntry.build_cost + unit.BuildCost
|
|
||||||
typeEntry.score_value = typeEntry.score_value + unit.ScoreValue
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---Updates the Tactical Kill Stats Table with the killed object.
|
---Updates the Tactical Kill Stats Table with the killed object.
|
||||||
---@param unit UnitClass The object that was killed.
|
---@param unit UnitClass The object that was killed.
|
||||||
---@param killer PlayerObject The player that killed the object.
|
---@param killer PlayerObject The player that killed the object.
|
||||||
@@ -320,40 +274,9 @@ end
|
|||||||
-- ==================================================
|
-- ==================================================
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
---Finds all players of defined Factions via FoCAPI.
|
|
||||||
---@param gameMode string The current game mode.
|
---@param gameMode string The current game mode.
|
||||||
---@return PlayerClass[]
|
---@return PlayerClass[]
|
||||||
function TacticalGameClass:_FindPlayers(gameMode)
|
function TacticalGameClass:_FindPlayers(gameMode)
|
||||||
local isSuccess, result = pcall(Get_All_Players)
|
|
||||||
|
|
||||||
if isSuccess then
|
|
||||||
local players = {}
|
|
||||||
|
|
||||||
for _, playerWrapper in pairs(result) do
|
|
||||||
local factionName = playerWrapper.Get_Faction_Name()
|
|
||||||
|
|
||||||
for _, faction in pairs(Factions) do
|
|
||||||
if faction.Name == factionName then
|
|
||||||
local player = PlayerClass:New(playerWrapper)
|
|
||||||
|
|
||||||
players[player.Id] = player
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return players
|
|
||||||
end
|
|
||||||
|
|
||||||
return self:_FindPlayersFallback(gameMode)
|
|
||||||
end
|
|
||||||
|
|
||||||
---@private
|
|
||||||
---Finds all players of defined Factions via starting unit.
|
|
||||||
---Note: this will not work when starting units are disabled.
|
|
||||||
---For the spectator team, it will only ever find the player in seat 1.
|
|
||||||
---@param gameMode string The current game mode.
|
|
||||||
---@return PlayerClass[]
|
|
||||||
function TacticalGameClass:_FindPlayersFallback(gameMode)
|
|
||||||
---@type PlayerClass[]
|
---@type PlayerClass[]
|
||||||
local players = {}
|
local players = {}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,9 @@ require("PGBase")
|
|||||||
|
|
||||||
---@class UnitClass
|
---@class UnitClass
|
||||||
---@field Name string Unit name.
|
---@field Name string Unit name.
|
||||||
---@field DisplayName string|nil The localized display name.
|
---@field DisplayName string The localized display name.
|
||||||
---@field OwnerId integer Owner Player ID.
|
---@field OwnerId integer Owner Player ID.
|
||||||
---@field BuildCost integer Galactic build cost.
|
---@field BuildCost integer Tactical build cost.
|
||||||
---@field TacticalBuildCost integer Tactical build cost.
|
|
||||||
---@field CombatRating integer AI combat power rating.
|
---@field CombatRating integer AI combat power rating.
|
||||||
---@field ScoreValue integer Score cost credits.
|
---@field ScoreValue integer Score cost credits.
|
||||||
---@field BuildTime number Game time that this unit was built.
|
---@field BuildTime number Game time that this unit was built.
|
||||||
@@ -18,16 +17,15 @@ UnitClass = {}
|
|||||||
UnitClass.__index = UnitClass
|
UnitClass.__index = UnitClass
|
||||||
|
|
||||||
---Constructs a new Unit object.
|
---Constructs a new Unit object.
|
||||||
---@param objectType GameObjectType The game object type.
|
---@param objectType GameObjectType FoC GameObjectTypeWrapper object
|
||||||
---@param playerId integer The Owner Player ID
|
---@param playerId integer The Owner Player ID
|
||||||
function UnitClass:New(objectType, playerId)
|
function UnitClass:New(objectType, playerId)
|
||||||
local self = setmetatable({}, UnitClass)
|
local self = setmetatable({}, UnitClass)
|
||||||
|
|
||||||
self.Name = objectType.Get_Name()
|
self.Name = objectType.Get_Name()
|
||||||
_, self.DisplayName = pcall(objectType.Get_Display_Name)
|
self.DisplayName = objectType.Get_Display_Name()
|
||||||
self.OwnerId = playerId
|
self.OwnerId = playerId
|
||||||
self.BuildCost = objectType.Get_Build_Cost()
|
self.BuildCost = objectType.Get_Tactical_Build_Cost()
|
||||||
self.TacticalBuildCost = objectType.Get_Tactical_Build_Cost()
|
|
||||||
self.CombatRating = objectType.Get_Combat_Rating()
|
self.CombatRating = objectType.Get_Combat_Rating()
|
||||||
self.ScoreValue = objectType.Get_Score_Cost_Credits()
|
self.ScoreValue = objectType.Get_Score_Cost_Credits()
|
||||||
self.BuildTime = GetCurrentTime()
|
self.BuildTime = GetCurrentTime()
|
||||||
|
|||||||
@@ -38,10 +38,6 @@ GameSpy_Game_Stats = {}
|
|||||||
---@deprecated
|
---@deprecated
|
||||||
GameSpy_Player_Stats = {}
|
GameSpy_Player_Stats = {}
|
||||||
|
|
||||||
---Tactical Build Stat Table for post-game.
|
|
||||||
---[playerid][planetname][object_type][build_count, credits_spent, combat_power]
|
|
||||||
TacticalBuildStatsTable = {}
|
|
||||||
|
|
||||||
---Tactical Frag/Death Stat Table for post-game.
|
---Tactical Frag/Death Stat Table for post-game.
|
||||||
---[frag|death][playerid][object_type][build_count, credits_spent, combat_power]
|
---[frag|death][playerid][object_type][build_count, credits_spent, combat_power]
|
||||||
TacticalKillStatsTable = {
|
TacticalKillStatsTable = {
|
||||||
@@ -49,32 +45,6 @@ TacticalKillStatsTable = {
|
|||||||
[DeathIndex] = {}
|
[DeathIndex] = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
---Tactical Team Frag/Death Stat Table for post-game.
|
|
||||||
---[frag|death][playerid][object_type][build_count, credits_spent, combat_power]
|
|
||||||
TacticalTeamKillStatsTable = {
|
|
||||||
[FragIndex] = {},
|
|
||||||
[DeathIndex] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
---Galactic Build Stat Table for post-game.
|
|
||||||
---[playerid][planetname][object_type][build_count, credits_spent, combat_power]
|
|
||||||
GalacticBuildStatsTable = {}
|
|
||||||
|
|
||||||
---Galactic Frag/Death Stat Table for post-game.
|
|
||||||
---[frag|death][playerid][object_type][build_count, credits_spent, combat_power]
|
|
||||||
GalacticKillStatsTable = {
|
|
||||||
[FragIndex] = {},
|
|
||||||
[DeathIndex] = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
---Galactic Neutralized Hero Table for post-game.
|
|
||||||
---[playerid][object_type][neutralized_count]
|
|
||||||
GalacticNeutralizedTable = {}
|
|
||||||
|
|
||||||
---Galactic Planet Conquest Table for post-game.
|
|
||||||
---[playerid][planet_type][sacked_count, lost_count]
|
|
||||||
GalacticConquestTable = {}
|
|
||||||
|
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
-- Script State Functions
|
-- Script State Functions
|
||||||
-- ==================================================
|
-- ==================================================
|
||||||
@@ -156,7 +126,6 @@ end
|
|||||||
function Reset_Tactical_Stats()
|
function Reset_Tactical_Stats()
|
||||||
DebugMessage("%s -- In Reset_Tactical_Stats", tostring(Script))
|
DebugMessage("%s -- In Reset_Tactical_Stats", tostring(Script))
|
||||||
|
|
||||||
TacticalBuildStatsTable = {}
|
|
||||||
TacticalKillStatsTable = {
|
TacticalKillStatsTable = {
|
||||||
[FragIndex] = {},
|
[FragIndex] = {},
|
||||||
[DeathIndex] = {}
|
[DeathIndex] = {}
|
||||||
@@ -174,14 +143,6 @@ function Reset_Stats()
|
|||||||
DebugMessage("%s -- In Reset_Stats", tostring(Script))
|
DebugMessage("%s -- In Reset_Stats", tostring(Script))
|
||||||
|
|
||||||
Reset_Tactical_Stats()
|
Reset_Tactical_Stats()
|
||||||
|
|
||||||
GalacticBuildStatsTable {}
|
|
||||||
GalacticKillStatsTable = {
|
|
||||||
[FragIndex] = {},
|
|
||||||
[DeathIndex] = {}
|
|
||||||
}
|
|
||||||
GalacticNeutralizedTable = {}
|
|
||||||
GalacticConquestTable = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---A dirty hack to reset tactical script registry values
|
---A dirty hack to reset tactical script registry values
|
||||||
@@ -202,6 +163,8 @@ function Game_Mode_Starting_Event(mode, map)
|
|||||||
|
|
||||||
LocalPlayer = Find_Player("local")
|
LocalPlayer = Find_Player("local")
|
||||||
|
|
||||||
|
DebugMessage("Local Player: %s (%d)", LocalPlayer.Get_Name(), LocalPlayer.Get_ID())
|
||||||
|
|
||||||
if StringCompare(mode, "Galactic") then
|
if StringCompare(mode, "Galactic") then
|
||||||
-- Galactic Campaign
|
-- Galactic Campaign
|
||||||
Init_Galactic()
|
Init_Galactic()
|
||||||
@@ -296,25 +259,18 @@ end
|
|||||||
---@param object GameObject|GameObjectType FoC GameObjectWrapper or GameObjectTypeWrapper of the object that was just created.
|
---@param object GameObject|GameObjectType FoC GameObjectWrapper or GameObjectTypeWrapper of the object that was just created.
|
||||||
function Galactic_Production_End_Event(planet, object)
|
function Galactic_Production_End_Event(planet, object)
|
||||||
local typeName = ""
|
local typeName = ""
|
||||||
local type = nil
|
|
||||||
|
|
||||||
if object.Get_Type == nil then
|
if object.Get_Type == nil then
|
||||||
-- object must be a GameObjectTypeWrapper if it doesn't have a Get_Type function.
|
-- object must be a GameObjectTypeWrapper not a GameObjectWrapper if it doesn't
|
||||||
---@cast object GameObjectType
|
-- have a Get_Type function.
|
||||||
type = object
|
|
||||||
typeName = object.Get_Name()
|
typeName = object.Get_Name()
|
||||||
else
|
else
|
||||||
-- object points to the GameObjectWrapper that was just created.
|
-- object points to the GameObjectWrapper that was just created.
|
||||||
type = object.Get_Type()
|
|
||||||
typeName = object.Get_Type().Get_Name()
|
typeName = object.Get_Type().Get_Name()
|
||||||
end
|
end
|
||||||
|
|
||||||
DebugMessage("%s -- Galactic production of %s ended at %s.", tostring(Script), typeName,
|
DebugMessage("%s -- Galactic production of %s ended at %s.", tostring(Script), typeName,
|
||||||
planet.Get_Type().Get_Name())
|
planet.Get_Type().Get_Name())
|
||||||
|
|
||||||
if GalacticGame then
|
|
||||||
GalacticGame:UnitBuilt(type, planet.Get_Owner(), planet)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---This event is triggered when a unit is destroyed in galactic mode.
|
---This event is triggered when a unit is destroyed in galactic mode.
|
||||||
@@ -322,14 +278,6 @@ end
|
|||||||
---@param killer PlayerObject FoC PlayerWrapper object that killed the object.
|
---@param killer PlayerObject FoC PlayerWrapper object that killed the object.
|
||||||
function Galactic_Unit_Destroyed_Event(object, killer)
|
function Galactic_Unit_Destroyed_Event(object, killer)
|
||||||
DebugMessage("%s -- Object %s killed by %s.", tostring(Script), object.Get_Type().Get_Name(), killer.Get_Name())
|
DebugMessage("%s -- Object %s killed by %s.", tostring(Script), object.Get_Type().Get_Name(), killer.Get_Name())
|
||||||
|
|
||||||
if GalacticGame then
|
|
||||||
GalacticGame:UnitKilled(object, killer)
|
|
||||||
end
|
|
||||||
|
|
||||||
if TacticalGame then
|
|
||||||
TacticalGame:UnitKilled(object, killer)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---This event is triggered when the level of a starbase changes.
|
---This event is triggered when the level of a starbase changes.
|
||||||
@@ -488,10 +436,10 @@ function Init_Tactical(gameMode)
|
|||||||
DebugMessage("%s -- Initializing Tactical %s rules.", tostring(Script), gameMode)
|
DebugMessage("%s -- Initializing Tactical %s rules.", tostring(Script), gameMode)
|
||||||
Reset_Tactical_Stats()
|
Reset_Tactical_Stats()
|
||||||
TacticalGame = TacticalGameClass:New(gameMode)
|
TacticalGame = TacticalGameClass:New(gameMode)
|
||||||
TacticalGame.KillStatsTable = TacticalTeamKillStatsTable
|
TacticalGame.KillStatsTable = TacticalKillStatsTable
|
||||||
GUIManager:InitTactical()
|
GUIManager:InitTactical()
|
||||||
--TextManager:RegisterView(TacticalGame.CombatFeed)
|
TextManager:RegisterView(TacticalGame.CombatFeed)
|
||||||
--TextManager:SetCurrentView("combat_feed")
|
TextManager:SetCurrentView("combat_feed")
|
||||||
end
|
end
|
||||||
|
|
||||||
---Resets Tactical mode.
|
---Resets Tactical mode.
|
||||||
|
|||||||
Reference in New Issue
Block a user