I'm trying to figure out how to implement some new kinds of promotions beyond what one can do with the XML files (at least as far as I've seen). For instance, I would like to be able to grant a unit a "promotion" on creation (or by an event) that would act like a trait or tag. I'd also like to be able to create some promotions which tested for the existance of other promotions on the target unit before determining what bonuses to give.
Some random examples...
"Burning"
A unit given the "Burning" promotion would take a certain amount of damage every turn. This one I think I could manage. You'd make a promotion with no bonuses, that wasn't available to any unit type by default, then in your custom EventManager class OnBeginTurn (or EndTurn, whatever), you'd cycle through the active player's (via CyPlayer) unit list for units with the Burning Promotion and deduct your damage.
Fair enough. So then how about this one...
"Zombie"
A zombie unit can not die. When OnUnitKilled is triggered, you add the unit's location and information to the ScriptData cache, and then on the owning's players next EndTurn, you recreate the unit with some sort of "The Zombie gets back up" message. So far so good, maybe (I haven't actually implemented it, just sounds like it would work to me). Let's say I want to add another new promotion called "Headshot". A unit with Headshot.. nevermind, I can solve that one too. Ok, "Zombie Hunter". A Zombie Hunter gets a +25% attack bonus against any unit with the "Zombie" promotion. *That's* the one I want to solve. There are the OnCombatCalc and OnCombatHit events, but I don't see anyway to change the odds in Calc, which makes me wonder if maybe it's only triggered when you hold down the alt key. For OnCombatHit, it seems like you could only mitigate the damage the unit was taking? Or is there a piece of the API I'm missing? Can you return values from these to make the game ignore the rest of it's processing and you do it yourself? Are the values passed in, pass by val, so you can, for instance, change the values of the arguments to the event and have those changes propagated back to the engine proper? Maybe I haven't dug deeply enough into the API? Anyone have any suggestions?
Any help would be greatly appreciated
.
Some random examples...
"Burning"
A unit given the "Burning" promotion would take a certain amount of damage every turn. This one I think I could manage. You'd make a promotion with no bonuses, that wasn't available to any unit type by default, then in your custom EventManager class OnBeginTurn (or EndTurn, whatever), you'd cycle through the active player's (via CyPlayer) unit list for units with the Burning Promotion and deduct your damage.
Fair enough. So then how about this one...
"Zombie"
A zombie unit can not die. When OnUnitKilled is triggered, you add the unit's location and information to the ScriptData cache, and then on the owning's players next EndTurn, you recreate the unit with some sort of "The Zombie gets back up" message. So far so good, maybe (I haven't actually implemented it, just sounds like it would work to me). Let's say I want to add another new promotion called "Headshot". A unit with Headshot.. nevermind, I can solve that one too. Ok, "Zombie Hunter". A Zombie Hunter gets a +25% attack bonus against any unit with the "Zombie" promotion. *That's* the one I want to solve. There are the OnCombatCalc and OnCombatHit events, but I don't see anyway to change the odds in Calc, which makes me wonder if maybe it's only triggered when you hold down the alt key. For OnCombatHit, it seems like you could only mitigate the damage the unit was taking? Or is there a piece of the API I'm missing? Can you return values from these to make the game ignore the rest of it's processing and you do it yourself? Are the values passed in, pass by val, so you can, for instance, change the values of the arguments to the event and have those changes propagated back to the engine proper? Maybe I haven't dug deeply enough into the API? Anyone have any suggestions?
Any help would be greatly appreciated
