Generified "[X] free [] units"

Barbarians don't try to attack with civilian units (classic Mod)
This commit is contained in:
Yair Morgenstern 2020-09-16 20:46:34 +03:00
parent 1ceb3548dd
commit a0d18889e0
4 changed files with 13 additions and 4 deletions

View file

@ -132,7 +132,7 @@
"culture": 1,
"greatPersonPoints": {"production": 1},
"isWonder": true,
"uniques": ["Worker construction increased 25%","Provides 2 free workers"],
"uniques": ["Worker construction increased 25%","[2] free [Worker] units appear"],
"requiredTech": "Masonry",
"quote": "'O, let not the pains of death which come upon thee enter into my body. I am the god Tem, and I am the foremost part of the sky, and the power which protecteth me is that which is with all the gods forever.' - The Book of the Dead, translated by Sir Ernest Alfred Wallis Budge"
},
@ -667,7 +667,7 @@
"culture": 1,
"happiness": 4,
"isWonder": true,
"uniques": ["2 free Great Artists appear"],
"uniques": ["[2] free [Great Artist] units appear"],
"requiredTech": "Archaeology",
"quote": "'Every genuine work of art has as much reason for being as the earth and the sun' - Ralph Waldo Emerson"
},
@ -955,7 +955,7 @@
"isWonder": true,
"greatPersonPoints": {"science": 1},
"providesFreeBuilding": "Spaceship Factory",
"uniques": ["2 free great scientists appear",
"uniques": ["[2] free [Great Scientist] units appear",
"+[25]% production when building [Spaceship part] in this city"],
"requiredTech": "Satellites",
"quote": "'The wonder is, not that the field of stars is so vast, but that man has measured it.' - Anatole France"

View file

@ -66,7 +66,7 @@ class BarbarianAutomation(val civInfo: CivilizationInfo) {
// 3 - trying to attack enemy
// if a embarked melee unit can land and attack next turn, do not attack from water.
if (BattleHelper.tryDisembarkUnitToAttackPosition(unit)) return
if (BattleHelper.tryAttackNearbyEnemy(unit)) return
if (!unit.type.isCivilian() && BattleHelper.tryAttackNearbyEnemy(unit)) return
// 4 - trying to pillage tile or route
if (UnitAutomation.tryPillageImprovement(unit)) return

View file

@ -352,6 +352,7 @@ class Building : NamedStats(), IConstruction {
for (unique in uniqueObjects)
UniqueTriggerActivation.triggerCivwideUnique(unique, civInfo)
// ALL these are deprecated as of 3.10.10 and are currently here to not break mods relying on them
if ("2 free Great Artists appear" in uniques) {
civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
civInfo.addUnit("Great Artist", cityConstructions.cityInfo)
@ -364,6 +365,8 @@ class Building : NamedStats(), IConstruction {
civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
civInfo.addUnit(Constants.worker, cityConstructions.cityInfo)
}
if ("Enemy land units must spend 1 extra movement point when inside your territory (obsolete upon Dynamite)" in uniques)
civInfo.updateHasActiveGreatWall()

View file

@ -34,6 +34,12 @@ object UniqueTriggerActivation {
if (civInfo.cities.any { it.isCapital() } && (unitName != Constants.settler || !civInfo.isOneCityChallenger()))
civInfo.addUnit(unitName, civInfo.getCapital())
}
"[] free [] units appear" -> {
val unitName = unique.params[1]
if (civInfo.cities.any { it.isCapital() } && (unitName != Constants.settler || !civInfo.isOneCityChallenger()))
for (i in 1..unique.params[0].toInt())
civInfo.addUnit(unitName, civInfo.getCapital())
}
"Free Social Policy" -> civInfo.policies.freePolicies++
"Empire enters golden age" ->
civInfo.goldenAges.enterGoldenAge()