All unit trigger uniques start with a targetting parameter

This commit is contained in:
yairm210 2024-08-22 01:21:38 +03:00
parent 3798dadad4
commit f6efdd105f
9 changed files with 96 additions and 52 deletions

View File

@ -20,7 +20,7 @@
{
"name": "your exploring unit receives training",
"notification": "An ancient tribe trained us in their ways of combat!",
"uniques": ["This Unit gains [10] XP", "Only available <after turn number [10]>"]
"uniques": ["[This Unit] gains [10] XP", "Only available <after turn number [10]>"]
},
{
"name": "survivors (adds population to a city)",
@ -43,7 +43,7 @@
{
"name": "advanced weaponry for your explorer",
"notification": "Our unit finds advanced weaponry hidden in the ruins!",
"uniques": ["This Unit upgrades for free including special upgrades"]
"uniques": ["[This Unit] upgrades for free including special upgrades"]
},
{
"name": "reveal nearby Barbarian camps",

View File

@ -2,7 +2,7 @@
{
"name": "Heal Instantly",
"uniques": ["Heal this unit by [50] HP", "Doing so will consume this opportunity to choose a Promotion"],
"uniques": ["[This Unit] heals [50] HP", "Doing so will consume this opportunity to choose a Promotion"],
"unitTypes": ["Sword","Gunpowder","Mounted","Scout","Siege","Archery","Ranged Gunpowder","Armored","Melee Water","Ranged Water","Submarine"],
"innerColor": [195,53,43],
"outerColor": [253,236,234],

View File

@ -20,7 +20,7 @@
{
"name": "your exploring unit receives training",
"notification": "An ancient tribe trained us in their ways of combat!",
"uniques": ["This Unit gains [10] XP", "Only available <after turn number [10]>"]
"uniques": ["[This Unit] gains [10] XP", "Only available <after turn number [10]>"]
},
{
"name": "survivors (adds population to a city)",
@ -43,7 +43,7 @@
{
"name": "advanced weaponry for your explorer",
"notification": "Our unit finds advanced weaponry hidden in the ruins!",
"uniques": ["This Unit upgrades for free including special upgrades"]
"uniques": ["[This Unit] upgrades for free including special upgrades"]
},
{
"name": "reveal nearby Barbarian camps",

View File

@ -2,7 +2,7 @@
{
"name": "Heal Instantly",
"uniques": ["Heal this unit by [50] HP", "Doing so will consume this opportunity to choose a Promotion"],
"uniques": ["[This Unit] heals [50] HP", "Doing so will consume this opportunity to choose a Promotion"],
"unitTypes": ["Sword","Gunpowder","Mounted","Scout","Siege","Archery","Ranged Gunpowder","Armored","Melee Water","Ranged Water","Submarine"],
"innerColor": [195,53,43],
"outerColor": [253,236,234]

View File

@ -68,6 +68,8 @@ object Constants {
const val cancelImprovementOrder = "Cancel improvement order"
const val tutorialPopupNamePrefix = "Tutorial: "
const val thisUnit = "This Unit"
const val targetUnit = "Target Unit"
const val OK = "OK"
const val close = "Close"

View File

@ -561,8 +561,8 @@ enum class UniqueParameterType(
},
UnitTriggerTarget("unitTriggerTarget", "This Unit", "`This Unit` or `Target Unit`") {
override val staticKnownValues = setOf("This Unit", "Target Unit")
UnitTriggerTarget("unitTriggerTarget", Constants.thisUnit, "`${Constants.thisUnit}` or `${Constants.targetUnit}`") {
override val staticKnownValues = setOf(Constants.thisUnit, Constants.targetUnit)
},
/** Mod declarative compatibility: Define Mod relations by their name. */

View File

@ -924,40 +924,46 @@ object UniqueTriggerActivation {
}
}
UniqueType.OneTimeUnitHeal -> {
UniqueType.OneTimeUnitHeal, UniqueType.OneTimeUnitHealOld -> {
if (unit == null) return null
if (unit.health == 100) return null
return {
unit.healBy(unique.params[0].toInt())
val paramOffset = if (unique.type == UniqueType.OneTimeUnitHealOld) 0 else 1
unit.healBy(unique.params[0 + paramOffset].toInt())
if (notification != null)
unit.civ.addNotification(notification, MapUnitAction(unit), NotificationCategory.Units) // Do we have a heal icon?
true
}
}
UniqueType.OneTimeUnitDamage -> {
UniqueType.OneTimeUnitDamage, UniqueType.OneTimeUnitDamageOld -> {
if (unit == null) return null
return {
unit.takeDamage(unique.params[0].toInt())
val paramOffset = if (unique.type == UniqueType.OneTimeUnitDamageOld) 0 else 1
unit.takeDamage(unique.params[paramOffset].toInt())
if (notification != null)
unit.civ.addNotification(notification, MapUnitAction(unit), NotificationCategory.Units) // Do we have a heal icon?
true
}
}
UniqueType.OneTimeUnitGainXP -> {
UniqueType.OneTimeUnitGainXP, UniqueType.OneTimeUnitGainXPOld -> {
if (unit == null) return null
return {
unit.promotions.XP += unique.params[0].toInt()
val paramOffset = if (unique.type == UniqueType.OneTimeUnitGainXPOld) 0 else 1
unit.promotions.XP += unique.params[paramOffset].toInt()
if (notification != null)
unit.civ.addNotification(notification, MapUnitAction(unit), NotificationCategory.Units)
true
}
}
UniqueType.OneTimeUnitGainMovement, UniqueType.OneTimeUnitLoseMovement -> {
UniqueType.OneTimeUnitGainMovement, UniqueType.OneTimeUnitLoseMovement,
UniqueType.OneTimeUnitGainMovementOld, UniqueType.OneTimeUnitLoseMovementOld -> {
if (unit == null) return null
return {
val offset = if (unique.type == UniqueType.OneTimeUnitGainMovementOld || unique.type == UniqueType.OneTimeUnitLoseMovementOld) 0 else 1
val movementToUse =
if (unique.type == UniqueType.OneTimeUnitLoseMovement) unique.params[0].toFloat()
else -unique.params[0].toFloat()
if (unique.type == UniqueType.OneTimeUnitLoseMovement || unique.type == UniqueType.OneTimeUnitLoseMovementOld)
unique.params[offset].toFloat()
else -unique.params[offset].toFloat()
unit.useMovementPoints(movementToUse)
true
}
@ -978,23 +984,27 @@ object UniqueTriggerActivation {
true
}
}
UniqueType.OneTimeUnitUpgrade, UniqueType.OneTimeUnitSpecialUpgrade -> {
UniqueType.OneTimeUnitUpgrade, UniqueType.OneTimeUnitSpecialUpgrade,
UniqueType.OneTimeUnitUpgradeOld, UniqueType.OneTimeUnitSpecialUpgradeOld -> {
if (unit == null) return null
val upgradeAction =
if (unique.type == UniqueType.OneTimeUnitSpecialUpgrade) UnitActionsUpgrade.getAncientRuinsUpgradeAction(unit)
if (unique.type == UniqueType.OneTimeUnitSpecialUpgrade || unique.type == UniqueType.OneTimeUnitSpecialUpgradeOld)
UnitActionsUpgrade.getAncientRuinsUpgradeAction(unit)
else UnitActionsUpgrade.getFreeUpgradeAction(unit)
if (upgradeAction.none()) return null
return {
(upgradeAction.minBy { (it as UpgradeUnitAction).unitToUpgradeTo.cost }).action!!()
if (notification != null)
unit.civ.addNotification(notification, MapUnitAction(unit), NotificationCategory.Units)
true
}
}
UniqueType.OneTimeUnitGainPromotion -> {
UniqueType.OneTimeUnitGainPromotion, UniqueType.OneTimeUnitGainPromotionOld -> {
if (unit == null) return null
val offset = if (unique.type == UniqueType.OneTimeUnitGainPromotionOld) 0 else 1
val promotion = unit.civ.gameInfo.ruleset.unitPromotions.keys
.firstOrNull { it == unique.params[0] }
.firstOrNull { it == unique.params[offset] }
?: return null
return {
unit.promotions.addPromotion(promotion, true)
@ -1003,10 +1013,11 @@ object UniqueTriggerActivation {
true
}
}
UniqueType.OneTimeUnitRemovePromotion -> {
UniqueType.OneTimeUnitRemovePromotion, UniqueType.OneTimeUnitRemovePromotionOld -> {
if (unit == null) return null
val offset = if (unique.type == UniqueType.OneTimeUnitRemovePromotionOld) 0 else 1
val promotion = unit.civ.gameInfo.ruleset.unitPromotions.keys
.firstOrNull { it == unique.params[0]}
.firstOrNull { it == unique.params[offset]}
?: return null
return {
unit.promotions.removePromotion(promotion)

View File

@ -844,16 +844,43 @@ enum class UniqueType(
//endregion
///////////////////////////////////////// region 09 UNIT TRIGGERABLES /////////////////////////////////////////
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] heals [positiveAmount] HP"))
OneTimeUnitHealOld("Heal this unit by [positiveAmount] HP", UniqueTarget.UnitTriggerable),
OneTimeUnitHeal("[unitTriggerTarget] heals [positiveAmount] HP", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] takes [positiveAmount] damage"))
OneTimeUnitDamageOld("This Unit takes [positiveAmount] damage", UniqueTarget.UnitTriggerable),
OneTimeUnitDamage("[unitTriggerTarget] takes [positiveAmount] damage", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] gains [amount] XP"))
OneTimeUnitGainXPOld("This Unit gains [amount] XP", UniqueTarget.UnitTriggerable),
OneTimeUnitGainXP("[unitTriggerTarget] gains [amount] XP", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] upgrades for free"))
OneTimeUnitUpgradeOld("This Unit upgrades for free", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitUpgrade("[unitTriggerTarget] upgrades for free", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] upgrades for free including special upgrades"))
OneTimeUnitSpecialUpgradeOld("This Unit upgrades for free including special upgrades", UniqueTarget.UnitTriggerable),
OneTimeUnitSpecialUpgrade("[unitTriggerTarget] upgrades for free including special upgrades", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] gains the [promotion] promotion"))
OneTimeUnitGainPromotionOld("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitGainPromotion("[unitTriggerTarget] gains the [promotion] promotion", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] loses the [promotion] promotion"))
OneTimeUnitRemovePromotionOld("This Unit loses the [promotion] promotion", UniqueTarget.UnitTriggerable),
OneTimeUnitRemovePromotion("[unitTriggerTarget] loses the [promotion] promotion", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] gains [amount] movement"))
OneTimeUnitGainMovementOld("This Unit gains [amount] movement", UniqueTarget.UnitTriggerable),
OneTimeUnitGainMovement("[unitTriggerTarget] gains [amount] movement", UniqueTarget.UnitTriggerable),
@Deprecated("As of 4.13.2", ReplaceWith("[This Unit] loses [amount] movement"))
OneTimeUnitLoseMovementOld("This Unit loses [amount] movement", UniqueTarget.UnitTriggerable),
OneTimeUnitLoseMovement("[unitTriggerTarget] loses [amount] movement", UniqueTarget.UnitTriggerable),
OneTimeUnitHeal("Heal this unit by [positiveAmount] HP", UniqueTarget.UnitTriggerable),
OneTimeUnitDamage("This Unit takes [positiveAmount] damage", UniqueTarget.UnitTriggerable),
OneTimeUnitGainXP("This Unit gains [amount] XP", UniqueTarget.UnitTriggerable),
OneTimeUnitUpgrade("This Unit upgrades for free", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitSpecialUpgrade("This Unit upgrades for free including special upgrades", UniqueTarget.UnitTriggerable),
OneTimeUnitGainPromotion("This Unit gains the [promotion] promotion", UniqueTarget.UnitTriggerable), // Not used in Vanilla
OneTimeUnitRemovePromotion("This Unit loses the [promotion] promotion", UniqueTarget.UnitTriggerable),
OneTimeUnitGainMovement("This Unit gains [amount] movement", UniqueTarget.UnitTriggerable),
OneTimeUnitLoseMovement("This Unit loses [amount] movement", UniqueTarget.UnitTriggerable),
OneTimeUnitGainStatus("[unitTriggerTarget] gains the [promotion] status for [positiveAmount] turn(s)", UniqueTarget.UnitTriggerable,
docDescription = "Statuses are temporary promotions. They do not stack, and reapplying a specific status take the highest number - so reapplying a 3-turn on a 1-turn makes it 3, but doing the opposite will have no effect. " +
"Turns left on the status decrease at the *start of turn*, so bonuses applied for 1 turn are stll applied during other civ's turns."),

View File

@ -196,44 +196,48 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
Uniques that have immediate, one-time effects on a unit.They can be added to units (on unit, unit type, or promotion) to grant them the ability to trigger this effect as an action, which can be modified with UnitActionModifier and UnitTriggerCondition conditionals.
??? example "Heal this unit by [positiveAmount] HP"
Example: "Heal this unit by [3] HP"
??? example "[unitTriggerTarget] heals [positiveAmount] HP"
Example: "[This Unit] heals [3] HP"
Applicable to: UnitTriggerable
??? example "This Unit takes [positiveAmount] damage"
Example: "This Unit takes [3] damage"
??? example "[unitTriggerTarget] takes [positiveAmount] damage"
Example: "[This Unit] takes [3] damage"
Applicable to: UnitTriggerable
??? example "This Unit gains [amount] XP"
Example: "This Unit gains [3] XP"
??? example "[unitTriggerTarget] gains [amount] XP"
Example: "[This Unit] gains [3] XP"
Applicable to: UnitTriggerable
??? example "This Unit upgrades for free"
Applicable to: UnitTriggerable
??? example "This Unit upgrades for free including special upgrades"
Applicable to: UnitTriggerable
??? example "This Unit gains the [promotion] promotion"
Example: "This Unit gains the [Shock I] promotion"
??? example "[unitTriggerTarget] upgrades for free"
Example: "[This Unit] upgrades for free"
Applicable to: UnitTriggerable
??? example "This Unit loses the [promotion] promotion"
Example: "This Unit loses the [Shock I] promotion"
??? example "[unitTriggerTarget] upgrades for free including special upgrades"
Example: "[This Unit] upgrades for free including special upgrades"
Applicable to: UnitTriggerable
??? example "This Unit gains [amount] movement"
Example: "This Unit gains [3] movement"
??? example "[unitTriggerTarget] gains the [promotion] promotion"
Example: "[This Unit] gains the [Shock I] promotion"
Applicable to: UnitTriggerable
??? example "This Unit loses [amount] movement"
Example: "This Unit loses [3] movement"
??? example "[unitTriggerTarget] loses the [promotion] promotion"
Example: "[This Unit] loses the [Shock I] promotion"
Applicable to: UnitTriggerable
??? example "[unitTriggerTarget] gains [amount] movement"
Example: "[This Unit] gains [3] movement"
Applicable to: UnitTriggerable
??? example "[unitTriggerTarget] loses [amount] movement"
Example: "[This Unit] loses [3] movement"
Applicable to: UnitTriggerable