diff --git a/Gamedata/alldefs_post.lua b/Gamedata/alldefs_post.lua index 0c81da88a..85df5990d 100644 --- a/Gamedata/alldefs_post.lua +++ b/Gamedata/alldefs_post.lua @@ -23,7 +23,7 @@ SaveDefsToCustomParams = false ------------------------- unitHealthModifier = tonumber(Spring.GetModOptions().unithealthmodifier) if unitHealthModifier == nil then - unitHealthModifier = 250 + unitHealthModifier = 500 end unitHealthModifier = unitHealthModifier * 0.01 @@ -358,7 +358,7 @@ function ModOptions_Post (UnitDefs, WeaponDefs) for id,wDef in pairs(WeaponDefs) do if wDef.customparams and wDef.customparams.effectedbyunithealthmodifier == true then if wDef.damage.default then - wDef.damage.default = wDef.damage.default * unitHealthModifier + wDef.damage.default = wDef.damage.default * (unitHealthModifier * 0.33) end --Spring.Echo(wDef.damage.default) end diff --git a/Gamedata/sounds.lua b/Gamedata/sounds.lua index 8720c40df..5fdea8e0d 100644 --- a/Gamedata/sounds.lua +++ b/Gamedata/sounds.lua @@ -252,65 +252,65 @@ local Sounds = { }, } -local files = VFS.DirList("sounds/deathsounds/generic/") -local t = Sounds.SoundItems -for i=1,#files do - local fileName = files[i] - t[fileName] = { - file = fileName; - pitchmod = 0.3; - --gainmod = 0.2; - maxconcurrent = 16; - rolloff = 2, - dopplerscale = 2, - in3d = true, - } -end +-- local files = VFS.DirList("sounds/deathsounds/generic/") +-- local t = Sounds.SoundItems +-- for i=1,#files do + -- local fileName = files[i] + -- t[fileName] = { + -- file = fileName; + -- pitchmod = 0.3; + ----gainmod = 0.2; + -- maxconcurrent = 16; + -- rolloff = 2, + -- dopplerscale = 2, + -- in3d = true, + -- } +-- end -local files = VFS.DirList("sounds/explosions/") -local t = Sounds.SoundItems -for i=1,#files do - local fileName = files[i] - t[fileName] = { - file = fileName; - pitchmod = 0.3; - --gainmod = 0.2; - maxconcurrent = 16; - rolloff = 2, - dopplerscale = 2, - in3d = true, - } -end +-- local files = VFS.DirList("sounds/explosions/") +-- local t = Sounds.SoundItems +-- for i=1,#files do + -- local fileName = files[i] + -- t[fileName] = { + -- file = fileName; + -- pitchmod = 0.3; + ----gainmod = 0.2; + -- maxconcurrent = 16; + -- rolloff = 2, + -- dopplerscale = 2, + -- in3d = true, + -- } +-- end -local files = VFS.DirList("sounds/deathsounds/nuke/") -local t = Sounds.SoundItems -for i=1,#files do - local fileName = files[i] - t[fileName] = { - file = fileName; - pitchmod = 0.3; - --gainmod = 0.2; - maxconcurrent = 16; - rolloff = 2, - dopplerscale = 2, - in3d = true, - } -end +-- local files = VFS.DirList("sounds/deathsounds/nuke/") +-- local t = Sounds.SoundItems +-- for i=1,#files do + -- local fileName = files[i] + -- t[fileName] = { + -- file = fileName; + -- pitchmod = 0.3; + ----gainmod = 0.2; + -- maxconcurrent = 16; + -- rolloff = 2, + -- dopplerscale = 2, + -- in3d = true, + -- } +-- end -local files = VFS.DirList("sounds/weapons/") -local t = Sounds.SoundItems -for i=1,#files do - local fileName = files[i] - t[fileName] = { - file = fileName; - pitchmod = 0.2; - --gainmod = 0.2; - maxconcurrent = 16; - rolloff = 2, - dopplerscale = 1.5, - in3d = true, - } -end +-- local files = VFS.DirList("sounds/weapons/") +-- local t = Sounds.SoundItems +-- for i=1,#files do + -- local fileName = files[i] + -- t[fileName] = { + -- file = fileName; + -- pitchmod = 0.2; + ----gainmod = 0.2; + -- maxconcurrent = 16; + -- rolloff = 2, + -- dopplerscale = 1.5, + -- in3d = true, + -- } +-- end local files = VFS.DirList("sounds/selfdcountdown/") local t = Sounds.SoundItems diff --git a/LuaAI.lua b/LuaAI.lua index 7adc788d3..1fedaf087 100644 --- a/LuaAI.lua +++ b/LuaAI.lua @@ -12,14 +12,30 @@ return { -- name = 'DAI', -- desc = 'Shard by AF for Spring Lua', -- }, - { - name = 'ScavengersAI', - desc = 'scavs', - }, - { - name = 'Sandbox', - desc = 'Does absolutely Nothing', - }, + { + name = 'ScavengersAI', + desc = 'scavs', + }, + { + name = 'Sandbox', + desc = 'Does absolutely Nothing', + }, + { + name = 'SimpleAI', + desc = 'EasyAI (Simple)', + }, + { + name = 'SimpleCheaterAI', + desc = 'EasyAI (Cheater)', + }, + { + name = 'SimpleDefenderAI', + desc = 'EasyAI (Defender)', + }, + { + name = 'SimpleConstructorAI', + desc = 'EasyAI (Constructor)', + }, } diff --git a/LuaRules/Gadgets/ai_simpleai.lua b/LuaRules/Gadgets/ai_simpleai.lua new file mode 100644 index 000000000..7ab3bca34 --- /dev/null +++ b/LuaRules/Gadgets/ai_simpleai.lua @@ -0,0 +1,670 @@ +local enabled = false +local teams = Spring.GetTeamList() +local SimpleAITeamIDs = {} +local SimpleAITeamIDsCount = 0 +local SimpleCheaterAITeamIDs = {} +local SimpleCheaterAITeamIDsCount = 0 +local UDN = UnitDefNames +local wind = Game.windMax +local mapsizeX = Game.mapSizeX +local mapsizeZ = Game.mapSizeZ + +local gameShortName = Game.gameShortName + +-- team locals +SimpleFactoriesCount = {} +SimpleFactories = {} +SimpleT1Mexes = {} +SimpleFactoryDelay = {} + +for i = 1, #teams do + local teamID = teams[i] + local luaAI = Spring.GetTeamLuaAI(teamID) + if luaAI and luaAI ~= "" and (string.sub(luaAI, 1, 8) == 'SimpleAI' or string.sub(luaAI, 1, 15) == 'SimpleCheaterAI' or string.sub(luaAI, 1, 16) == 'SimpleDefenderAI' or string.sub(luaAI, 1, 19) == 'SimpleConstructorAI') then + enabled = true + SimpleAITeamIDsCount = SimpleAITeamIDsCount + 1 + SimpleAITeamIDs[SimpleAITeamIDsCount] = teamID + + SimpleFactoriesCount[teamID] = 0 + SimpleFactories[teamID] = {} + SimpleT1Mexes[teamID] = 0 + SimpleFactoryDelay[teamID] = 0 + + if string.sub(luaAI, 1, 15) == 'SimpleCheaterAI' or string.sub(luaAI, 1, 16) == 'SimpleDefenderAI' or string.sub(luaAI, 1, 19) == 'SimpleConstructorAI' then + SimpleCheaterAITeamIDsCount = SimpleCheaterAITeamIDsCount + 1 + SimpleCheaterAITeamIDs[SimpleCheaterAITeamIDsCount] = teamID + end + end +end + +function gadget:GetInfo() + return { + name = "SimpleAI", + desc = "123", + author = "Damgam", + date = "2020", + layer = -100, + enabled = enabled, + } +end + +-------- lists +BadUnitsList = {} +if gameShortName == "BYAR" then + BadUnitsList = { + -- transports + "armthovr", + "corthovr", + "armatlas", + "armtship", + "corvalk", + "cortship", + "armdfly", + "corseah", + "corint", + + -- stockpilers + "armscab", + "armemp", + "armjuno", + "armamd", + "armmercury", + "armsilo", + "armcarry", + "corfmd", + "corjuno", + "corscreamer", + "corsilo", + "cortron", + "corcarry", + "cormabm", + + -- minelayers + "armmlv", + "cormlv", + + -- depth charge launchers + "armdl", + "cordl", + + -- walls + "armdrag", + "cordrag", + } +end + +if gameShortName == "EvoRTS" then + BadUnitsList = {} +end + +local BadUnitDefs = {} +local SimpleCommanderDefs = {} +local SimpleFactoriesDefs = {} +local SimpleConstructorDefs = {} +local SimpleExtractorDefs = {} +local SimpleGeneratorDefs = {} +local SimpleConverterDefs = {} +local SimpleTurretDefs = {} +local SimpleUndefinedBuildingDefs = {} +local SimpleUndefinedUnitDefs = {} + +for unitDefID, unitDef in pairs(UnitDefs) do + BadUnitDef = false + for a = 1,#BadUnitsList do + if BadUnitsList[a] == unitDef.name then + BadUnitDef = true + break + else + BadUnitDef = false + end + end + if BadUnitDef == false then + if unitDef.name == "armcom" or unitDef.name == "corcom" or unitDef.name == "armdecom" or unitDef.name == "cordecom" then + SimpleCommanderDefs[#SimpleCommanderDefs + 1] = unitDefID + elseif unitDef.isFactory and #unitDef.buildOptions > 0 then + SimpleFactoriesDefs[#SimpleFactoriesDefs + 1] = unitDefID + elseif unitDef.canMove and unitDef.isBuilder and #unitDef.buildOptions > 0 then + SimpleConstructorDefs[#SimpleConstructorDefs + 1] = unitDefID + elseif unitDef.extractsMetal > 0 or (unitDef.customParams and unitDef.customParams.metal_extractor) then + SimpleExtractorDefs[#SimpleExtractorDefs + 1] = unitDefID + elseif (unitDef.energyMake > 19 and (not unitDef.energyUpkeep or unitDef.energyUpkeep < 10)) or (unitDef.windGenerator > 0 and wind > 10) or unitDef.tidalGenerator > 0 or (unitDef.customParams and unitDef.customParams.solar) then + SimpleGeneratorDefs[#SimpleGeneratorDefs + 1] = unitDefID + elseif unitDef.customParams and unitDef.customParams.energyconv_capacity and unitDef.customParams.energyconv_efficiency then + SimpleConverterDefs[#SimpleConverterDefs + 1] = unitDefID + elseif unitDef.isBuilding and #unitDef.weapons > 0 then + SimpleTurretDefs[#SimpleTurretDefs + 1] = unitDefID + + + elseif not unitDef.canMove then + SimpleUndefinedBuildingDefs[#SimpleUndefinedBuildingDefs + 1] = unitDefID + else + SimpleUndefinedUnitDefs[#SimpleUndefinedUnitDefs + 1] = unitDefID + end + end +end + +-------- functions + +local function SimpleGetClosestMexSpot(x, z) + local bestSpot + local bestDist = math.huge + local metalSpots = GG.metalSpots + if metalSpots then + for i = 1, #metalSpots do + local spot = metalSpots[i] + local dx, dz = x - spot.x, z - spot.z + local dist = dx * dx + dz * dz + local units = Spring.GetUnitsInCylinder(spot.x, spot.z, 128) + --local height = Spring.GetGroundHeight(spot.x, spot.z) + if dist < bestDist and #units == 0 then + --and height > 0 then + bestSpot = spot + bestDist = dist + end + end + end + return bestSpot +end + +local function SimpleBuildOrder(cUnitID, building) + searchRange = 0 + for b2 = 1,20 do + searchRange = searchRange + 300 + local team = Spring.GetUnitTeam(cUnitID) + local cunitposx, _, cunitposz = Spring.GetUnitPosition(cUnitID) + local units = Spring.GetUnitsInCylinder(cunitposx, cunitposz, searchRange, team) + if #units > 1 then + local buildnear = units[math.random(1, #units)] + local refDefID = Spring.GetUnitDefID(buildnear) + local isBuilding = UnitDefs[refDefID].isBuilding + local isCommander = (UnitDefs[refDefID].name == "armcom" or UnitDefs[refDefID].name == "corcom") + local isExtractor = UnitDefs[refDefID].extractsMetal > 0 + if (isBuilding or isCommander) then-- and not isExtractor then + local refx, refy, refz = Spring.GetUnitPosition(buildnear) + local reffootx = UnitDefs[refDefID].xsize * 8 + local reffootz = UnitDefs[refDefID].zsize * 8 + local spacing = math.random(64, 128) + local testspacing = spacing * 0.75 + local buildingDefID = building + local r = math.random(0, 3) + if r == 0 then + local bposx = refx + local bposz = refz + reffootz + spacing + local bposy = Spring.GetGroundHeight(bposx, bposz)--+100 + local testpos = Spring.TestBuildOrder(buildingDefID, bposx, bposy, bposz, r) + local nearbyunits = Spring.GetUnitsInRectangle(bposx - testspacing, bposz - testspacing, bposx + testspacing, bposz + testspacing) + if testpos == 2 and #nearbyunits <= 0 then + Spring.GiveOrderToUnit(cUnitID, -buildingDefID, { bposx, bposy, bposz, r }, { "shift" }) + break + end + elseif r == 1 then + local bposx = refx + reffootx + spacing + local bposz = refz + local bposy = Spring.GetGroundHeight(bposx, bposz)--+100 + local testpos = Spring.TestBuildOrder(buildingDefID, bposx, bposy, bposz, r) + local nearbyunits = Spring.GetUnitsInRectangle(bposx - testspacing, bposz - testspacing, bposx + testspacing, bposz + testspacing) + if testpos == 2 and #nearbyunits <= 0 then + Spring.GiveOrderToUnit(cUnitID, -buildingDefID, { bposx, bposy, bposz, r }, { "shift" }) + break + end + elseif r == 2 then + local bposx = refx + local bposz = refz - reffootz - spacing + local bposy = Spring.GetGroundHeight(bposx, bposz)--+100 + local testpos = Spring.TestBuildOrder(buildingDefID, bposx, bposy, bposz, r) + local nearbyunits = Spring.GetUnitsInRectangle(bposx - testspacing, bposz - testspacing, bposx + testspacing, bposz + testspacing) + if testpos == 2 and #nearbyunits <= 0 then + Spring.GiveOrderToUnit(cUnitID, -buildingDefID, { bposx, bposy, bposz, r }, { "shift" }) + break + end + elseif r == 3 then + local bposx = refx - reffootx - spacing + local bposz = refz + local bposy = Spring.GetGroundHeight(bposx, bposz)--+100 + local testpos = Spring.TestBuildOrder(buildingDefID, bposx, bposy, bposz, r) + local nearbyunits = Spring.GetUnitsInRectangle(bposx - testspacing, bposz - testspacing, bposx + testspacing, bposz + testspacing) + if testpos == 2 and #nearbyunits <= 0 then + Spring.GiveOrderToUnit(cUnitID, -buildingDefID, { bposx, bposy, bposz, r }, { "shift" }) + break + end + end + end + --local buildingDefID = UnitDefNames.building.id + --local testpos = Spring.TestBuildOrder(buildingDefID, bposx, bposy, bposz, facing) + end + end +end + +local function SimpleConstructionProjectSelection(unitID, unitDefID, unitName, unitTeam, allyTeamID, units, allunits, type) + success = false + + local mcurrent, mstorage, _, mincome, mexpense = Spring.GetTeamResources(unitTeam, "metal") + local ecurrent, estorage, _, eincome, eexpense = Spring.GetTeamResources(unitTeam, "energy") + local unitposx, unitposy, unitposz = Spring.GetUnitPosition(unitID) + + local unitCommands = Spring.GetCommandQueue(unitID, 0) + local buildOptions = UnitDefs[unitDefID].buildOptions + -- Builders + for b1 = 1,10 do + if type == "Builder" or type == "Commander" then + SimpleFactoryDelay[unitTeam] = SimpleFactoryDelay[unitTeam]-1 + local r = math.random(0, 20) + local mexspotpos = SimpleGetClosestMexSpot(unitposx, unitposz) + if (mexspotpos and SimpleT1Mexes[unitTeam] < 3) and type == "Commander" then + local project = SimpleExtractorDefs[math.random(1, #SimpleExtractorDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + Spring.GiveOrderToUnit(unitID, -project, { mexspotpos.x, mexspotpos.y, mexspotpos.z, 0 }, { "shift" }) + --Spring.Echo("Success! Project Type: Extractor.") + success = true + break + end + end + elseif ecurrent < estorage * 0.75 or r == 0 then + local project = SimpleGeneratorDefs[math.random(1, #SimpleGeneratorDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + SimpleBuildOrder(unitID, project) + --Spring.Echo("Success! Project Type: Generator.") + success = true + break + end + end + + elseif mcurrent < mstorage * 0.30 or r == 1 then + -- if type == "Commander" then + -- for t = 1,10 do + -- local targetUnit = units[math.random(1,#units)] + -- if UnitDefs[Spring.GetUnitDefID(targetUnit)].isBuilding == true then + -- local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + -- Spring.GiveOrderToUnit(unitID, CMD.MOVE, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, { "shift", "alt", "ctrl" }) + -- success = true + -- break + -- end + -- end + -- elseif + if (not mexspotpos) and (ecurrent > estorage * 0.85 or r == 1) then + local project = SimpleConverterDefs[math.random(1, #SimpleConverterDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + SimpleBuildOrder(unitID, project) + --Spring.Echo("Success! Project Type: Converter.") + success = true + break + end + end + elseif mexspotpos then + local project = SimpleExtractorDefs[math.random(1, #SimpleExtractorDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + Spring.GiveOrderToUnit(unitID, -project, { mexspotpos.x, mexspotpos.y, mexspotpos.z, 0 }, { "shift" }) + --Spring.Echo("Success! Project Type: Extractor.") + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x+100, mexspotpos.y, mexspotpos.z, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x-100, mexspotpos.y, mexspotpos.z, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x, mexspotpos.y, mexspotpos.z-100, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x, mexspotpos.y, mexspotpos.z-100, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x+100, mexspotpos.y, mexspotpos.z+100, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x-100, mexspotpos.y, mexspotpos.z+100, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x+100, mexspotpos.y, mexspotpos.z-100, math.random(0,3) }, { "shift" }) + break + end + end + for i3 = 1,50 do + local projectturret = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + if buildOptions[i3] == projectturret then + Spring.GiveOrderToUnit(unitID, -projectturret, { mexspotpos.x-100, mexspotpos.y, mexspotpos.z-100, math.random(0,3) }, { "shift" }) + break + end + end + success = true + break + end + end + + end + elseif r == 2 or r == 3 or r == 4 or r == 5 then + local project = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + SimpleBuildOrder(unitID, project) + --Spring.Echo("Success! Project Type: Turret.") + success = true + break + end + end + elseif SimpleFactoriesCount[unitTeam] < 1 or ((mcurrent > mstorage * 0.75 and ecurrent > estorage * 0.75) and SimpleFactoryDelay[unitTeam] <= 0) then + local project = SimpleFactoriesDefs[math.random(1, #SimpleFactoriesDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project and (not SimpleFactories[unitTeam][project]) then + SimpleBuildOrder(unitID, project) + SimpleFactoryDelay[unitTeam] = 30 + --Spring.Echo("Success! Project Type: Factory.") + success = true + break + end + end + elseif r == 11 then + for t = 1,10 do + local targetUnit = units[math.random(1,#units)] + if UnitDefs[Spring.GetUnitDefID(targetUnit)].isBuilding == true then + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + Spring.GiveOrderToUnit(unitID, CMD.MOVE, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, { "shift", "alt", "ctrl" }) + success = true + break + end + end + elseif r == 12 and type ~= "Commander" then + local mapcenterX = mapsizeX/2 + local mapcenterZ = mapsizeZ/2 + local mapcenterY = Spring.GetGroundHeight(mapcenterX, mapcenterZ) + local mapdiagonal = math.ceil(math.sqrt((mapsizeX*mapsizeX)+(mapsizeZ*mapsizeZ))) + Spring.GiveOrderToUnit(unitID, CMD.RECLAIM,{mapcenterX+math.random(-100,100),mapcenterY,mapcenterZ+math.random(-100,100),mapdiagonal}, 0) + success = true + elseif r == 13 and type ~= "Commander" then + local mapcenterX = mapsizeX/2 + local mapcenterZ = mapsizeZ/2 + local mapcenterY = Spring.GetGroundHeight(mapcenterX, mapcenterZ) + local mapdiagonal = math.ceil(math.sqrt((mapsizeX*mapsizeX)+(mapsizeZ*mapsizeZ))) + Spring.GiveOrderToUnit(unitID, CMD.REPAIR,{mapcenterX+math.random(-100,100),mapcenterY,mapcenterZ+math.random(-100,100),mapdiagonal}, 0) + success = true + else + local r2 = math.random(0, 1) + if r2 == 0 then + local project = SimpleUndefinedBuildingDefs[math.random(1, #SimpleUndefinedBuildingDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + SimpleBuildOrder(unitID, project) + --Spring.Echo("Success! Project Type: Other.") + success = true + break + end + end + else + local project = SimpleTurretDefs[math.random(1, #SimpleTurretDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + SimpleBuildOrder(unitID, project) + --Spring.Echo("Success! Project Type: Turret.") + success = true + break + end + end + end + end + elseif type == "Factory" then + if #Spring.GetFullBuildQueue(unitID, 0) < 5 then + local r = math.random(0, 5) + local luaAI = Spring.GetTeamLuaAI(unitTeam) + if r == 0 or string.sub(luaAI, 1, 19) == 'SimpleConstructorAI' then + local project = SimpleConstructorDefs[math.random(1, #SimpleConstructorDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + local x, y, z = Spring.GetUnitPosition(unitID) + Spring.GiveOrderToUnit(unitID, -project, { x, y, z, 0 }, 0) + --Spring.Echo("Success! Project Type: Constructor.") + success = true + break + end + end + else + local project = SimpleUndefinedUnitDefs[math.random(1, #SimpleUndefinedUnitDefs)] + for i2 = 1,#buildOptions do + if buildOptions[i2] == project then + local x, y, z = Spring.GetUnitPosition(unitID) + Spring.GiveOrderToUnit(unitID, -project, { x, y, z, 0 }, 0) + --Spring.Echo("Success! Project Type: Unit.") + success = true + break + end + end + end + else + success = true + end + end + if success == true then + break + end + end +end + +function gadget:GameOver() + gadgetHandler:RemoveGadget(self) +end + +if gadgetHandler:IsSyncedCode() then + + function gadget:GameFrame(n) + if n % 15 == 0 then + for i = 1, SimpleAITeamIDsCount do + if n%(15*SimpleAITeamIDsCount) == 15*(i-1) then + local teamID = SimpleAITeamIDs[i] + local _, _, isDead, _, faction, allyTeamID = Spring.GetTeamInfo(teamID) + local mcurrent, mstorage, _, mincome, mexpense = Spring.GetTeamResources(teamID, "metal") + local ecurrent, estorage, _, eincome, eexpense = Spring.GetTeamResources(teamID, "energy") + for j = 1, #SimpleCheaterAITeamIDs do + if teamID == SimpleCheaterAITeamIDs[j] then + -- --cheats + if mcurrent < mstorage * 0.20 then + Spring.SetTeamResource(teamID, "m", mstorage * 0.25) + end + if ecurrent < estorage * 0.20 then + Spring.SetTeamResource(teamID, "e", estorage * 0.25) + end + end + end + + local units = Spring.GetTeamUnits(teamID) + local allunits = Spring.GetAllUnits() + for k = 1, #units do + local unitID = units[k] + local unitDefID = Spring.GetUnitDefID(unitID) + local unitName = UnitDefs[unitDefID].name + local unitTeam = teamID + local unitHealth, unitMaxHealth, _, _, unitBuildProgress = Spring.GetUnitHealth(unitID) + local unitMaxRange = Spring.GetUnitMaxRange(unitID) + local unitCommands = Spring.GetCommandQueue(unitID, 0) + local unitposx, unitposy, unitposz = Spring.GetUnitPosition(unitID) + --Spring.Echo(faction) + + --if faction == "arm" then + + -- builders + for u = 1, #SimpleCommanderDefs do + if unitDefID == SimpleCommanderDefs[u] then + local nearestEnemyCloak = Spring.GetUnitNearestEnemy(unitID, 2000, false) + if nearestEnemyCloak and ecurrent > 1000 then + Spring.GiveOrderToUnit(unitID, 37382, {1}, 0) + else + Spring.GiveOrderToUnit(unitID, 37382, {0}, 0) + end + + + local nearestEnemy = Spring.GetUnitNearestEnemy(unitID, 250, true) + local unitHealthPercentage = (unitHealth/unitMaxHealth)*100 + + if nearestEnemy and unitHealthPercentage > 30 then + if ecurrent < estorage*0.9 then + Spring.SetTeamResource(teamID, "e", estorage*0.9) + end + Spring.GiveOrderToUnit(unitID, CMD.DGUN, {nearestEnemy}, 0) + local nearestEnemies = Spring.GetUnitsInCylinder(unitposx, unitposz, 300) + for x = 1,#nearestEnemies do + local enemy = nearestEnemies[x] + if Spring.GetUnitTeam(enemy) == Spring.GetUnitTeam(nearestEnemy) and enemy ~= nearestEnemy then + Spring.GiveOrderToUnit(unitID, CMD.DGUN, {enemy}, {"shift"}) + end + end + Spring.GiveOrderToUnit(unitID, CMD.MOVE, {unitposx, unitposy, unitposz}, {"shift"}) + elseif nearestEnemy then + for x = 1,10 do + local targetUnit = units[math.random(1,#units)] + if UnitDefs[Spring.GetUnitDefID(targetUnit)].isBuilding == true then + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + Spring.GiveOrderToUnit(unitID, CMD.MOVE, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, 0) + break + end + end + end + end + end + + for u = 1, #SimpleConstructorDefs do + if unitDefID == SimpleConstructorDefs[u] then + local unitHealthPercentage = (unitHealth/unitMaxHealth)*100 + local nearestEnemy = Spring.GetUnitNearestEnemy(unitID, 500, true) + if nearestEnemy and unitHealthPercentage > 90 then + Spring.GiveOrderToUnit(unitID, CMD.RECLAIM, {nearestEnemy}, 0) + elseif nearestEnemy then + for x = 1,100 do + local targetUnit = units[math.random(1,#units)] + if UnitDefs[Spring.GetUnitDefID(targetUnit)].isBuilding == true then + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + Spring.GiveOrderToUnit(unitID, CMD.MOVE, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, 0) + break + end + end + end + end + end + + if unitCommands == 0 then + for u = 1, #SimpleConstructorDefs do + if unitDefID == SimpleConstructorDefs[u] then + SimpleConstructionProjectSelection(unitID, unitDefID, unitName, unitTeam, allyTeamID, units, allunits, "Builder") + break + end + end + for u = 1, #SimpleCommanderDefs do + if unitDefID == SimpleCommanderDefs[u] then + SimpleConstructionProjectSelection(unitID, unitDefID, unitName, unitTeam, allyTeamID, units, allunits, "Commander") + break + end + end + + for u = 1, #SimpleFactoriesDefs do + if unitDefID == SimpleFactoriesDefs[u] then + SimpleConstructionProjectSelection(unitID, unitDefID, unitName, unitTeam, allyTeamID, units, allunits, "Factory") + break + end + end + + -- army + + for u = 1, #SimpleUndefinedUnitDefs do + + if unitDefID == SimpleUndefinedUnitDefs[u] then + local luaAI = Spring.GetTeamLuaAI(teamID) + if string.sub(luaAI, 1, 16) == 'SimpleDefenderAI' then + for t = 1,10 do + local targetUnit = allunits[math.random(1,#allunits)] + if Spring.GetUnitAllyTeam(targetUnit) == allyTeamID then + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, { "shift", "alt", "ctrl" }) + break + end + end + else + local targetUnitNear = Spring.GetUnitNearestEnemy(unitID, 2000, false) + if targetUnitNear then + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnitNear) + Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, { "shift", "alt", "ctrl" }) + elseif n%3600 <= 15*SimpleAITeamIDsCount then + local targetUnit = Spring.GetUnitNearestEnemy(unitID, 999999, false) + local tUnitX, tUnitY, tUnitZ = Spring.GetUnitPosition(targetUnit) + Spring.GiveOrderToUnit(unitID, CMD.FIGHT, { tUnitX + math.random(-100, 100), tUnitY, tUnitZ + math.random(-100, 100) }, { "shift", "alt", "ctrl" }) + end + break + end + end + end + end + end + end + end + end + end + + function gadget:UnitCreated(unitID, unitDefID, unitTeam, builderID) + local unitName = UnitDefs[unitDefID].name + for i = 1, SimpleAITeamIDsCount do + if SimpleAITeamIDs[i] == unitTeam then + for u = 1, #SimpleFactoriesDefs do + if unitDefID == SimpleFactoriesDefs[u] then + SimpleFactoriesCount[unitTeam] = SimpleFactoriesCount[unitTeam] + 1 + SimpleFactories[unitTeam][unitDefID] = true + break + end + end + for u = 1, #SimpleExtractorDefs do + if unitDefID == SimpleExtractorDefs[u] then + SimpleT1Mexes[unitTeam] = SimpleT1Mexes[unitTeam] + 1 + break + end + end + end + end + end + + function gadget:UnitDestroyed(unitID, unitDefID, unitTeam, attackerID, attackerDefID, attackerTeam) + local unitName = UnitDefs[unitDefID].name + for i = 1, SimpleAITeamIDsCount do + if SimpleAITeamIDs[i] == unitTeam then + for u = 1, #SimpleFactoriesDefs do + if unitDefID == SimpleFactoriesDefs[u] then + SimpleFactoriesCount[unitTeam] = SimpleFactoriesCount[unitTeam] - 1 + SimpleFactories[unitTeam][unitDefID] = nil + break + end + end + for u = 1, #SimpleExtractorDefs do + if unitDefID == SimpleExtractorDefs[u] then + SimpleT1Mexes[unitTeam] = SimpleT1Mexes[unitTeam] - 1 + break + end + end + end + end + end + + +end diff --git a/LuaRules/Gadgets/game_spawn.lua b/LuaRules/Gadgets/game_spawn.lua index 117e8a09a..0a0de0014 100644 --- a/LuaRules/Gadgets/game_spawn.lua +++ b/LuaRules/Gadgets/game_spawn.lua @@ -37,11 +37,11 @@ end local aiStartUnits = { ["ecommander"] = { "ecommanderbattleai", - "ecommanderbuildai", - "ecommandercloakai", - "ecommanderfactoryai", - "ecommandershieldai", - "ecommanderhealerai", + -- "ecommanderbuildai", + -- "ecommandercloakai", + -- "ecommanderfactoryai", + -- "ecommandershieldai", + -- "ecommanderhealerai", }, ["zarm"] = { "zarm", diff --git a/ModOptions.lua b/ModOptions.lua index d3e4259d8..17d07cbce 100644 --- a/ModOptions.lua +++ b/ModOptions.lua @@ -273,9 +273,9 @@ local options= { desc = 'This acts as a percentage of base unit health. Setting to 200 would double unit hitpoints.', type = 'number', section= 'gameplayoptions', - def = 250, + def = 500, min = 1, - max = 400, + max = 2000, step = 1, -- quantization is aligned to the def value -- (step <= 0) means that there is no quantization }, diff --git a/Units-Configs-Basedefs/basedefs/hover/elighttank3_basedef.lua b/Units-Configs-Basedefs/basedefs/hover/elighttank3_basedef.lua index ff67d3030..fe90a3b14 100644 --- a/Units-Configs-Basedefs/basedefs/hover/elighttank3_basedef.lua +++ b/Units-Configs-Basedefs/basedefs/hover/elighttank3_basedef.lua @@ -112,7 +112,7 @@ weaponDefs = { craterBoost = 0, craterMult = 0, beamTTL = 10, - explosionGenerator = "custom:genericshellexplosion-medium-lightning", + explosionGenerator = "custom:genericshellexplosion-small-lightning", energypershot = 0, edgeeffectiveness = 1, impulseBoost = 0, diff --git a/Units/aiunits/ecommanderbattleai.lua b/Units/aiunits/ecommanderbattleai.lua index 8f32ae7d2..98b05c0d5 100644 --- a/Units/aiunits/ecommanderbattleai.lua +++ b/Units/aiunits/ecommanderbattleai.lua @@ -6,7 +6,7 @@ local unitName = "ecommanderbattleai" -------------------------------------------------------------------------------- local armortype = [[armored]] local supplyGiven = [[0]] -local techprovided = [[tech0, 1 tech0ai]] +local techprovided = [[tech0, tech1, tech2, tech3, 1 tech0ai]] local techrequired = [[0 overseer]] local weapon1Damage = 200 diff --git a/Units/ebuilding/esolar2.lua b/Units/ebuilding/esolar2.lua index 328368154..5480e8318 100644 --- a/Units/ebuilding/esolar2.lua +++ b/Units/ebuilding/esolar2.lua @@ -6,9 +6,9 @@ local unitName = "esolar2" -------------------------------------------------------------------------------- local armortype = [[building]] -local energyproduced = [[10]] +local energyproduced = [[5]] -local buildCostMetal = 100 +local buildCostMetal = 50 local maxDamage = buildCostMetal * 12.5 local unitDef = { diff --git a/Units/zaal/buildings/zespire1.lua b/Units/zaal/buildings/zespire1.lua index 51825cbc3..aaf7b9497 100644 --- a/Units/zaal/buildings/zespire1.lua +++ b/Units/zaal/buildings/zespire1.lua @@ -4,10 +4,10 @@ unitName = "zespire1" -------------------------------------------------------------------------------- -buildCostMetal = 100 +buildCostMetal = 50 supplygranted = 0 -energyMake = 10 +energyMake = 5 humanName = "Basic Energy Spire" diff --git a/Units/zaal/buildings/zmex.lua b/Units/zaal/buildings/zmex.lua index 05676bced..1fc2b729f 100644 --- a/Units/zaal/buildings/zmex.lua +++ b/Units/zaal/buildings/zmex.lua @@ -9,7 +9,7 @@ metalMultiplier = 1 energyUse = 0 -buildCostMetal = 50 +buildCostMetal = 35 yardMap = [[oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo oooooooo]]