Skip to content

Commit

Permalink
Merge remote branch 'speed/fix/exps_desync'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheeo committed Sep 12, 2015
2 parents 3b5e544 + 8dada81 commit 62009f7
Showing 1 changed file with 162 additions and 0 deletions.
162 changes: 162 additions & 0 deletions mods/coop/hook/lua/editor/OtherArmyUnitCountBuildConditions.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
--****************************************************************************
--**
--** File : /lua/editor/OtherArmyUnitCountBuildConditions.lua
--** Author(s): Dru Staltman
--**
--** Summary : Generic AI Platoon Build Conditions
--** Build conditions always return true or false
--**
--** Copyright © 2005 Gas Powered Games, Inc. All rights reserved.
--****************************************************************************
local AIUtils = import('/lua/ai/aiutilities.lua')
local ScenarioFramework = import('/lua/scenarioframework.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')

--#############################################################################################################
-- function: BrainGreaterThanNumCategory = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string targetBrain = "ArmyName"
-- parameter 2: int numReq = 0 doc = "docs for param1"
-- parameter 3: expr category = categories.ALLUNITS doc = "param2 docs"
--
--#############################################################################################################
function BrainGreaterThanNumCategory( aiBrain, targetBrain, numReq, category )
local testBrain = ArmyBrains[1]
for k,v in ArmyBrains do
if v.Name == targetBrain then
testBrain = v
break
end
end
local numUnits = testBrain:GetCurrentUnits(category)
if numUnits > numReq then
return true
else
return false
end
end


--#############################################################################################################
-- function: BrainLessThanNumCategory = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string targetBrain = "ArmyName"
-- parameter 2: int numReq = 0 doc = "docs for param1"
-- parameter 3: expr category = categories.ALLUNITS doc = "param2 docs"
--
--#############################################################################################################
function BrainLessThanNumCategory( aiBrain, targetBrain, numReq, category )
local testBrain = ArmyBrains[1]
for k,v in ArmyBrains do
if v.Name == targetBrain then
testBrain = v
break
end
end
local numUnits = testBrain:GetCurrentUnits(category)
if numUnits < numReq then
return true
else
return false
end
end


--#############################################################################################################
-- function: BrainGreaterThanOrEqualNumCategory = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string targetBrain = "ArmyName"
-- parameter 2: int numReq = 0 doc = "docs for param1"
-- parameter 3: expr category = categories.ALLUNITS doc = "param2 docs"
--
--#############################################################################################################
function BrainGreaterThanOrEqualNumCategory( aiBrain, targetBrain, numReq, category )
local testBrain = ArmyBrains[1]
for k,v in ArmyBrains do
if v.Name == targetBrain then
testBrain = v
break
end
end
local numUnits = testBrain:GetCurrentUnits(category)
if numUnits >= numReq then
return true
else
return false
end
end


--#############################################################################################################
-- function: BrainLessThanOrEqualNumCategory = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: string targetBrain = "ArmyName"
-- parameter 2: int numReq = 0 doc = "docs for param1"
-- parameter 3: expr category = categories.ALLUNITS doc = "param2 docs"
--
--#############################################################################################################
function BrainLessThanOrEqualNumCategory( aiBrain, targetBrain, numReq, category )
local testBrain = ArmyBrains[1]
for k,v in ArmyBrains do
if v.Name == targetBrain then
testBrain = v
break
end
end
local numUnits = testBrain:GetCurrentUnits(category)
if numUnits <= numReq then
return true
else
return false
end
end

--#############################################################################################################
-- function: FocusBrainBeingBuiltOrActiveCategoryCompare = BuildCondition doc = "Please work function docs."
--
-- parameter 0: string aiBrain = "default_brain"
-- parameter 1: int numReq = 0 doc = "docs for param1"
-- parameter 2: expr categories = categories.ALLUNITS doc = "param2 docs"
-- parameter 3: string compareType = ">="
--
--#############################################################################################################
function FocusBrainBeingBuiltOrActiveCategoryCompare( aiBrain, numReq, categories, compareType )
local num = 0
local tblArmy = ListArmies()
for iArmy, strArmy in pairs(tblArmy) do
if ScenarioInfo.ArmySetup[strArmy].Human then
local testBrain = GetArmyBrain(strArmy)
for k,v in categories do
num = num + testBrain:GetBlueprintStat('Units_BeingBuilt', v)
num = num + testBrain:GetBlueprintStat('Units_Active', v)
end
end
end

if not compareType or compareType == '>=' then
if num >= numReq then
return true
end
elseif compareType == '==' then
if num == numReq then
return true
end
elseif compareType == '<=' then
if num <= numReq then
return true
end
elseif compareType == '>' then
if num > numReq then
return true
end
elseif compareType == '<' then
if num < numReq then
return true
end
end
return false
end

0 comments on commit 62009f7

Please sign in to comment.