Hello everyone !
So, when I saw the engy at spawn mod (no acu mod), I thought of making a mod where you have 2 acu at spawn (the same one obviously, it could be 2 factions but uh... let's keep it easy), and you loose if you loose one of them, so I copy pasta-ed the all factions mod(which add the 3 other com at spawn, like that you have 4 factions), and removed the other coms, and make him spawn a com of your faction.
So for the time being, it's fine, you have 2 com of the same faction. But the problem is the victory condition of assassination, if you loose only one com, you don't loose the game, you need to loose both of them... So I've looked into the files(I never made a mod on this game before, so I'm totally new) and I've found the answer may be in the victory.lua file.
I've tried to do that but uh, no way, it doesn't work, you only loose when you don't have a com anymore...It's weird because I'm pretty sure it's the answer....
Before :
- Code: Select all
local categoryCheck = nil
if scenarioInfo.Options.Victory == 'demoralization' then
# You're dead if you have no commanders
categoryCheck = categories.COMMAND
elseif scenarioInfo.Options.Victory == 'domination' then
# You're dead if all structures and engineers are destroyed
categoryCheck = categories.STRUCTURE + categories.ENGINEER - categories.WALL
elseif scenarioInfo.Options.Victory == 'eradication' then
# You're dead if you have no units
categoryCheck = categories.ALLUNITS - categories.WALL
else
# no victory condition
return
end
After :
- Code: Select all
local categoryCheck = nil
if scenarioInfo.Options.Victory == 'demoralization' then
# You're dead if you have no commanders
if categories.COMMAND == 1 then
categoryCheck = 0
else
categoryCheck = categories.COMMAND
end
elseif scenarioInfo.Options.Victory == 'domination' then
# You're dead if all structures and engineers are destroyed
categoryCheck = categories.STRUCTURE + categories.ENGINEER - categories.WALL
elseif scenarioInfo.Options.Victory == 'eradication' then
# You're dead if you have no units
categoryCheck = categories.ALLUNITS - categories.WALL
else
# no victory condition
return
end
Tbh I did nothing special... but uh it doesn't work..weird. You loose only when you loose both of your coms.
I've tried that
- Code: Select all
if scenarioInfo.Options.Victory == 'demoralization' then
# You're dead if you have no commanders
categoryCheck = categories.COMMAND +1
elseif scenarioInfo.Options.Victory == 'domination' then
so you never loose with that. So it looks like the answer is here. But I really don't get why my code doesn't work.
----
PS : Btw my files have that :
mod_info.lua in 2coms folder :
name = "2coms"
uid = "WTFISTHATUDISUFIDUSIF2COMS"
version = 2
copyright = "Copyright © 2008, Legion Darrath. Adapted the code to spawn only one com of your faction by odin002"
description = "Spawns an other acu of your faction. You need to turn on prebuild units for this mod to work."
author = "Legion Darrath"
selectable = true
enabled = true
exclusive = false
ui_only = false
requires = {}
requiresNames = {}
conflicts = {}
before = {}
after = {}
victory.lua in 2coms/hook/lua/ :
function CheckVictory(scenarioInfo)
local categoryCheck = nil
if scenarioInfo.Options.Victory == 'demoralization' then
# You're dead if you have no commanders
if categories.COMMAND == 1 then
categoryCheck = 0
else
categoryCheck = categories.COMMAND
end
elseif scenarioInfo.Options.Victory == 'domination' then
# You're dead if all structures and engineers are destroyed
categoryCheck = categories.STRUCTURE + categories.ENGINEER - categories.WALL
elseif scenarioInfo.Options.Victory == 'eradication' then
# You're dead if you have no units
categoryCheck = categories.ALLUNITS - categories.WALL
else
# no victory condition
return
end
# tick number we are going to issue a victory on. Or nil if we are not.
local victoryTime = nil
local potentialWinners = {}
while true do
# Look for newly defeated brains and tell them they're dead
local stillAlive = {}
for index,brain in ArmyBrains do
if not brain:IsDefeated() and not ArmyIsCivilian(brain:GetArmyIndex()) then
if brain:GetCurrentUnits(categoryCheck) == 0 then
brain:OnDefeat()
CallEndGame(false, true)
else
table.insert(stillAlive, brain)
end
end
end
# uh-oh, there is nobody alive... It's a draw.
if table.empty(stillAlive) then
CallEndGame(true, false)
return
end
# check to see if everyone still alive is allied and is requesting an allied victory.
local win = true
local draw = true
for index,brain in stillAlive do
for index2,other in stillAlive do
if index != index2 then
if not brain.RequestingAlliedVictory or not IsAlly(brain:GetArmyIndex(), other:GetArmyIndex()) then
win = false
end
end
end
if not brain.OfferingDraw then
draw = false
end
end
if win then
if table.equal(stillAlive, potentialWinners) then
if GetGameTimeSeconds() > victoryTime then
# It's a win!
for index,brain in stillAlive do
brain:OnVictory()
end
CallEndGame(true, true)
return
end
else
victoryTime = GetGameTimeSeconds() + 15
potentialWinners = stillAlive
end
elseif draw then
for index,brain in stillAlive do
brain:OnDraw()
end
CallEndGame(true, true)
return
else
victoryTime = nil
potentialWinners = {}
end
WaitSeconds(3.0)
end
end
function CallEndGame(callEndGame, submitXMLStats)
if submitXMLStats then
SubmitXMLArmyStats()
end
if callEndGame then
gameOver = true
ForkThread(function()
WaitSeconds(3)
EndGame()
end)
end
end
gameOver = false
the aibrain.lua in 2coms/hook/lua/ :
local origBrain = AIBrain
AIBrain = Class(origBrain ) {
OnSpawnPreBuiltUnits = function(self)
local factionIndex = self:GetFactionIndex()
local resourceStructures = nil
local initialUnits = nil
local posX, posY = self:GetArmyStartPos()
if factionIndex == 1 then
initialUnits = { 'UEL0001' }
elseif factionIndex == 2 then
initialUnits = { 'UAL0001' }
elseif factionIndex == 3 then
initialUnits = { 'URL0001' }
elseif factionIndex == 4 then
initialUnits = { 'XSL0001' }
end
if resourceStructures then
# place resource structures down
for k, v in resourceStructures do
self:CreateResourceBuildingNearest(v, posX, posY)
end
end
if initialUnits then
# place initial units down
for k, v in initialUnits do
self:CreateUnitNearSpot(v, posX, posY)
end
end
self.PreBuilt = true
end,
}