Statistics: Posted by Mavr390 — 05 Aug 2020, 22:02
Statistics: Posted by Mavr390 — 21 Jul 2020, 05:34
Statistics: Posted by Uveso — 20 Jul 2020, 21:49
Statistics: Posted by Uveso — 20 Jul 2020, 17:38
Uveso wrote:
Basically you can just copy this function:
- Code:
BuildEnhancement = function(unit,enhancement)
IssueStop({unit})
IssueClearCommands({unit})
if not unit:HasEnhancement(enhancement) then
local tempEnhanceBp = unit:GetBlueprint().Enhancements[enhancement]
local unitEnhancements = import('/lua/enhancementcommon.lua').GetEnhancements(unit.EntityId)
-- Do we have already a enhancment in this slot ?
if unitEnhancements[tempEnhanceBp.Slot] and unitEnhancements[tempEnhanceBp.Slot] ~= tempEnhanceBp.Prerequisite then
-- remove the enhancement
--LOG('* AI-Uveso: * ACUAttackAIUveso: Found enhancement ['..unitEnhancements[tempEnhanceBp.Slot]..'] in Slot ['..tempEnhanceBp.Slot..']. - Removing...')
local order = { TaskName = "EnhanceTask", Enhancement = unitEnhancements[tempEnhanceBp.Slot]..'Remove' }
IssueScript({unit}, order)
coroutine.yield(10)
end
--LOG('* AI-Uveso: * ACUAttackAIUveso: BuildEnhancement: '..platoon:GetBrain().Nickname..' IssueScript: '..enhancement)
local order = { TaskName = "EnhanceTask", Enhancement = enhancement }
IssueScript({unit}, order)
end
while not unit.Dead and not unit:HasEnhancement(enhancement) do
-- waiting for the enhancement to build
coroutine.yield(10)
end
--LOG('* AI-Uveso: * ACUAttackAIUveso: BuildEnhancement: '..platoon:GetBrain().Nickname..' Upgrade finished '..enhancement)
return true
end,
Statistics: Posted by Mavr390 — 20 Jul 2020, 17:29
platoon:BuildEnhancement(cdr, NextEnhancement)
BuildEnhancement = function(unit,enhancement)
IssueStop({unit})
IssueClearCommands({unit})
if not unit:HasEnhancement(enhancement) then
local tempEnhanceBp = unit:GetBlueprint().Enhancements[enhancement]
local unitEnhancements = import('/lua/enhancementcommon.lua').GetEnhancements(unit.EntityId)
-- Do we have already a enhancment in this slot ?
if unitEnhancements[tempEnhanceBp.Slot] and unitEnhancements[tempEnhanceBp.Slot] ~= tempEnhanceBp.Prerequisite then
-- remove the enhancement
--LOG('* AI-Uveso: * ACUAttackAIUveso: Found enhancement ['..unitEnhancements[tempEnhanceBp.Slot]..'] in Slot ['..tempEnhanceBp.Slot..']. - Removing...')
local order = { TaskName = "EnhanceTask", Enhancement = unitEnhancements[tempEnhanceBp.Slot]..'Remove' }
IssueScript({unit}, order)
coroutine.yield(10)
end
--LOG('* AI-Uveso: * ACUAttackAIUveso: BuildEnhancement: '..platoon:GetBrain().Nickname..' IssueScript: '..enhancement)
local order = { TaskName = "EnhanceTask", Enhancement = enhancement }
IssueScript({unit}, order)
end
while not unit.Dead and not unit:HasEnhancement(enhancement) do
-- waiting for the enhancement to build
coroutine.yield(10)
end
--LOG('* AI-Uveso: * ACUAttackAIUveso: BuildEnhancement: '..platoon:GetBrain().Nickname..' Upgrade finished '..enhancement)
return true
end,
BuildEnhancement( unit, enhancementName )
Statistics: Posted by Uveso — 19 Jul 2020, 23:50
Statistics: Posted by Sprouto — 19 Jul 2020, 23:26
Statistics: Posted by Mavr390 — 19 Jul 2020, 20:31
if self.BrainType ~= 'Human' then
-- do AI stuff
end
BuilderGroup {
BuilderGroupName = 'NuclearRepulsorShields',
BuildersType = 'EngineerBuilder',
Builder {
BuilderName = 'U4 Village Shield',
PlatoonTemplate = 'T3EngineerBuilder',
Priority = 16000,
InstanceCount = 1,
BuilderConditions = {
-- When do we want to build this ?
{ UCBC, 'HaveGreaterThanUnitsWithCategory', { 2, categories.TECH3 * categories.ENERGYPRODUCTION }},
-- Do we need additional conditions to build it ?
-- Have we the eco to build it ?
{ EBC, 'GreaterThanEconTrend', { 0.0, 12.0 } },
{ EBC, 'GreaterThanEconStorageRatio', { 0.50, 0.99 } },
-- Don't build it if...
{ UCBC, 'HaveLessThanUnitsInCategoryBeingBuilt', { 1, categories.STRUCTURE * categories.SHIELD * categories.EXPERIMENTAL }},
{ UCBC, 'UnitsLessAtLocation', { 'LocationType', 3, categories.STRUCTURE * categories.SHIELD * categories.EXPERIMENTAL * categories.VILLAGESHIELD }},
-- Respect UnitCap
{ UCBC, 'UnitCapCheckLess', { 0.95 } },
},
BuilderType = 'Any',
BuilderData = {
Construction = {
DesiresAssist = true,
NumAssistees = 4,
BuildClose = true,
AdjacencyCategory = 'STRUCTURE ENERGYPRODUCTION TECH3',
AvoidCategory = categories.EXPERIMENTAL * categories.SHIELD,
maxUnits = 1,
maxRadius = 40,
LocationType = 'LocationType',
BuildStructures = {
'T4VillageShield',
},
}
}
},
},
local OLDSetupSession = SetupSession
function SetupSession()
OLDSetupSession()
import('/mods/nuclearrepulsorshields/lua/AI/AIBuilders/NuclearRepulsorShields.lua')
end
local OLDAddGlobalBaseTemplate = AddGlobalBaseTemplate
function AddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
SPEW('Nuclear Repulsor Shields: Injecting BuilderGroup "NuclearRepulsorShields"')
AddGlobalBuilderGroup(aiBrain, locationType, 'NuclearRepulsorShields')
OLDAddGlobalBaseTemplate(aiBrain, locationType, baseBuilderName)
end
--key 5 is for the Nomands Mod and not present in normal game.
BuildingTemplates[5] = BuildingTemplates[5] or {}
table.insert(BuildingTemplates[1], { 'T4VillageShield', 'qeb4408'} )
table.insert(BuildingTemplates[2], { 'T4VillageShield', 'qab4408'} )
table.insert(BuildingTemplates[3], { 'T4VillageShield', 'qrb4208'} )
table.insert(BuildingTemplates[4], { 'T4VillageShield', 'qsb4408'} )
table.insert(BuildingTemplates[5], { 'T4VillageShield', 'qnb4408'} )
table.insert(BuildingTemplates[1], { 'T4CityShield', 'qeb4409'} )
table.insert(BuildingTemplates[2], { 'T4CityShield', 'qab4409'} )
table.insert(BuildingTemplates[3], { 'T4CityShield', 'qrb4409'} )
table.insert(BuildingTemplates[4], { 'T4CityShield', 'qsb4409'} )
table.insert(BuildingTemplates[5], { 'T4CityShield', 'qnb4409'} )
table.insert(BuildingTemplates[1], { 'T4MetropolisShield', 'qeb4410'} )
table.insert(BuildingTemplates[2], { 'T4MetropolisShield', 'qab4410'} )
table.insert(BuildingTemplates[3], { 'T4MetropolisShield', 'qrb4410'} )
table.insert(BuildingTemplates[4], { 'T4MetropolisShield', 'qsb4410'} )
table.insert(BuildingTemplates[5], { 'T4MetropolisShield', 'qnb4410'} )
Statistics: Posted by Uveso — 19 Jul 2020, 18:55
Statistics: Posted by Mavr390 — 17 Jul 2020, 20:33