amadeus
Serenity now
Absolutely. I used to bug check web surveys for the public sector—no amount of tedium is too much for me.Probably the biggest help is just if you'd be willing to take a shot at it single player before it's released,
Absolutely. I used to bug check web surveys for the public sector—no amount of tedium is too much for me.Probably the biggest help is just if you'd be willing to take a shot at it single player before it's released,
if civ.hasTech(object.pAmericans, object.aJetFightersVII) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF15Eagle, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersVI) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF16FightingFalcon, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersV) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF14Tomcat, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersIV) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF4PhantomII, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersIII) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF104Starfighter, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersII) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF100SuperSabre, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif civ.hasTech(object.pAmericans, object.aJetFightersI) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF86Sabre, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
elseif not civ.hasTech(object.pAmericans, object.aJetFightersI) then
local usaDefendsTaiwanTile = gen.nearbyOpenTilesForTribe({object.cTaipei.location.x,object.cTaipei.location.y,object.cTaipei.location.z},1,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},object.pAmericans)
gen.createUnit(object.uF51Mustang, object.pAmericans, usaDefendsTaiwanTile, {count=4,randomize=true, veteran=true,scatter=true})
end
-- priorityList[i] = {techToCheck,unitTypeToCreate,numberToCreate}
-- Starting at key i = 1, WITH NO MISSING INTEGER,
-- if the tribe has the specified technology,
-- then the unit type is created in the quantity specified
-- if techToCheck is true, stop checking the list, and create the unit.
-- if numberToCreate is nil, use defaultCount supplied in function arguments
local taiwanTechPriorityList = {
{object.aJetFightersVII,object.uF15Eagle,4},
{object.aJetFightersVI, object.uF16FightingFalcon,4},
{true, object.uF51Mustang,4},
}
-- createBasedOnTech(tribe,techPriorityList,location,radius,vetStatus,validPlacementTerrainTable,defaultCount)
-- tribe is the owner of units to be created
-- techPriorityList determines what unit type will be created based on the tech
-- location is the place near where the units will be created
-- radius is how many tiles away from location will be searched for a place to put units
-- vetStatus is the value of the 'veteran' option for gen.createUnit
-- validPlacementTerrainTable is a table of integers corresponding to the terrain types the created
-- units can be placed on
-- defaultCount is the default number of units to be created
local function createBasedOnTech(tribe,techPriorityList,location,radius,vetStatus,validPlacementTerrainTable,defaultCount)
local number = nil
local unitType = nil
for _,data in ipairs(techPriorityList) do
if data[1] == true then
unitType = data[2]
number = data[3] or defaultCount
elseif tribe:hasTech(data[1]) then
unitType = data[2]
number = data[3] or defaultCount
break
end
end
local eligibleTiles = gen.nearbyOpenTilesForTribe(location,radius,validPlacementTerrainTable,tribe)
gen.createUnit(unitType,tribe,eligibleTiles,{count = number,randomize=true,veteran=vetStatus,scatter=true})
end
createBasedOnTech(object.pAmericans,taiwanTechPriorityList,object.cTaipei.location,1,true,{0,1,2,3,4,5,6,7,9,10,11,12,13,14,15},4)
Something I did notice is that neither your code nor mine handles the situation where the 8 tiles around Taipei are occupied. Maybe gen.moveUnitAdjacent might be helpful. Let me know if you need more help.
If they're all occupied, gen.createUnit should just not create anything.Will the game crash if all are occupied? If so I do probably need to do something about it. I'm not quite sure how to use gen.moveUnitAdjacent in this situation?
local function createBasedOnTech(tribe,techPriorityList,location,radius,vetStatus,validPlacementTerrainTable,defaultCount)
local number = nil
local unitType = nil
for _,data in ipairs(techPriorityList) do
if data[1] == true then
unitType = data[2]
number = data[3] or defaultCount
elseif tribe:hasTech(data[1]) then
unitType = data[2]
number = data[3] or defaultCount
break
end
end
local eligibleTiles = gen.nearbyOpenTilesForTribe(location,radius,validPlacementTerrainTable,tribe)
local function tileCleared(tile)
local result = false
for unit in tile.units do
result = gen.moveUnitAdjacent(unit)
if not result then
return false
end
end
-- if we get here, the tile has been cleared
return true
end
if gen.isEmpty(eligibleTiles) then
for _,tile in pairs(gen.getTilesInRadius(location,radius,1)) do
if tileCleared(tile) then
eligibleTiles = {tile}
break
end
end
end
gen.createUnit(unitType,tribe,eligibleTiles,{count = number,randomize=true,veteran=vetStatus,scatter=true})
end
local usaFighterTechPriorityList = {
{object.aJetFightersVII,object.uF15Eagle,nil},
{object.aJetFightersVI, object.uF16FightingFalcon,nil},
{object.aJetFightersV, object.uF14Tomcat ,nil},
{object.aJetFightersIV, object.uF4PhantomII,nil},
{object.aJetFightersIII, object.uF104Starfighter,nil},
{object.aJetFightersII, object.uF100SuperSabre,nil},
{object.aJetFightersI, object.uF86Sabre,nil},
{true, object.uF51Mustang,nil},
}
local usaBomberTechPriorityList = {
{object.aJetFightersIII, object.uB1Lancer,nil},
{object.aJetFightersII, object.uB52Stratofortress,nil},
{object.aJetFightersI, object.uB47Stratojet,nil},
{true, object.uStrategicBomber,nil},
}
local usaAttackTechPriorityList = {
{object.aAttackAircraftIV, object.uF111Aardvark,nil},
{object.aAttackAircraftIII, object.uF105Thunderchief,nil},
{object.aAttackAircraftII, object.uB57Canberra,nil},
{true, object.uF4UCorsair,nil},
}
local usaHelicopterTechPriorityList = {
{object.aAttackHelicopterII, object.uAH64Apache,nil},
{object.aAttackHelicopterI, object.uUH1Huey,nil},
{true, object.uUSInfantry,nil},
}
local usaTankTechPriorityList = {
{object.aMainBattleTankIV, object.uM1A1Abrams,nil},
{object.aMainBattleTankIII, object.uM60A3Patton,nil},
{object.aMainBattleTankII, object.uM60A1Patton,nil},
{object.aMainBattleTankI, object.uM48Patton,nil},
{true, object.uM26Pershing,nil},
}
local usaArtilleryTechPriorityList = {
{object.aMobileArtillery, object.uSPArtillery,nil},
{true, object.uArtillery,nil},
}
local usaIFVTechPriorityList = {
{object.aIFV, object.uBradleyIFV,nil},
{true, object.uUSInfantry,nil},
}
local usaNukeTechPriorityList = {
{object.aICBM, object.uICBM,nil},
{object.aMRBM, object.uMRBM,nil},
{true, object.uStrategicBomber,nil},
}
local usaNavalTech1PriorityList = {
{object.aTiconderogaClassCGN, object.uTiconderogaCGN,nil},
{object.aNPMissileCruisers, object.uCGN,nil},
{true, object.uCA,nil},
}
local usaNavalTech2PriorityList = {
{object.aMissileDestroyers, object.uDDG,nil},
{object.aMissileFrigates, object.uFFG,nil},
{true, object.uDD,nil},
}
local usaNavalTech3PriorityList = {
{object.aNuclearPoweredNavy, object.uCVN,nil},
{true, object.uCV,nil},
}
local usaAttackSubPriorityList = {
{object.aAdvancedSSN, object.uLosAngelesClassSSN,nil},
{object.aImprovedSSN, object.uSturgeonClassSSN,nil},
{object.aNuclearPoweredNavy, object.uSkipjackClassSSN,nil},
{true, object.uSSK,nil},
}
local usaMissileSubPriorityList = {
{object.aLateSSBN, object.uOhioClassSSBN,nil},
{object.aEarlySSBN, object.uLafayetteClassSSBN,nil},
{true, object.uSSK,nil},
}
local priorities = {}
priorities.usaFighterTechPriorityList = {
{object.aJetFightersVII,object.uF15Eagle,nil},
{object.aJetFightersVI, object.uF16FightingFalcon,nil},
{object.aJetFightersV, object.uF14Tomcat ,nil},
{object.aJetFightersIV, object.uF4PhantomII,nil},
{object.aJetFightersIII, object.uF104Starfighter,nil},
{object.aJetFightersII, object.uF100SuperSabre,nil},
{object.aJetFightersI, object.uF86Sabre,nil},
{true, object.uF51Mustang,nil},
}
priorities.usaBomberTechPriorityList = {
{object.aJetFightersIII, object.uB1Lancer,nil},
{object.aJetFightersII, object.uB52Stratofortress,nil},
{object.aJetFightersI, object.uB47Stratojet,nil},
{true, object.uStrategicBomber,nil},
}
priorities.usaAttackTechPriorityList = {
{object.aAttackAircraftIV, object.uF111Aardvark,nil},
{object.aAttackAircraftIII, object.uF105Thunderchief,nil},
{object.aAttackAircraftII, object.uB57Canberra,nil},
{true, object.uF4UCorsair,nil},
}
priorities.usaHelicopterTechPriorityList = {
{object.aAttackHelicopterII, object.uAH64Apache,nil},
{object.aAttackHelicopterI, object.uUH1Huey,nil},
{true, object.uUSInfantry,nil},
}
priorities.usaTankTechPriorityList = {
{object.aMainBattleTankIV, object.uM1A1Abrams,nil},
{object.aMainBattleTankIII, object.uM60A3Patton,nil},
{object.aMainBattleTankII, object.uM60A1Patton,nil},
{object.aMainBattleTankI, object.uM48Patton,nil},
{true, object.uM26Pershing,nil},
}
priorities.usaArtilleryTechPriorityList = {
{object.aMobileArtillery, object.uSPArtillery,nil},
{true, object.uArtillery,nil},
}
priorities.usaIFVTechPriorityList = {
{object.aIFV, object.uBradleyIFV,nil},
{true, object.uUSInfantry,nil},
}
priorities.usaNukeTechPriorityList = {
{object.aICBM, object.uICBM,nil},
{object.aMRBM, object.uMRBM,nil},
{true, object.uStrategicBomber,nil},
}
priorities.usaNavalTech1PriorityList = {
{object.aTiconderogaClassCGN, object.uTiconderogaCGN,nil},
{object.aNPMissileCruisers, object.uCGN,nil},
{true, object.uCA,nil},
}
priorities.usaNavalTech2PriorityList = {
{object.aMissileDestroyers, object.uDDG,nil},
{object.aMissileFrigates, object.uFFG,nil},
{true, object.uDD,nil},
}
priorities.usaNavalTech3PriorityList = {
{object.aNuclearPoweredNavy, object.uCVN,nil},
{true, object.uCV,nil},
}
priorities.usaAttackSubPriorityList = {
{object.aAdvancedSSN, object.uLosAngelesClassSSN,nil},
{object.aImprovedSSN, object.uSturgeonClassSSN,nil},
{object.aNuclearPoweredNavy, object.uSkipjackClassSSN,nil},
{true, object.uSSK,nil},
}
priorities.usaMissileSubPriorityList = {
{object.aLateSSBN, object.uOhioClassSSBN,nil},
{object.aEarlySSBN, object.uLafayetteClassSSBN,nil},
{true, object.uSSK,nil},
}
return priorities
local priorities = require("priorities")
someFunction(priorities)