OK, so the 'SummonCityDefenders' thing apparently only works for the first combat in a given city in a given turn.
I had a thought in the relevant support thread (great, being sidetracked from being sidetracked from being sidetracked) about using BattleAutoCastSpell or something to summon the available defenders each time.
The issue I see with this is that, if the City gives everyone the ability, either directly (some other gamemodifiers are handed down by cities to units) or via a 'give unique resource to everyone, that some spell everyone already has through say Blood_MyRace or whatever, well either EVERYONE can cast their own version of the spell (so say if you had 6 units, you might have up to 6x the normal number of defenders).
This could also have a side effect (don't really see an issue) of allowing units that start a turn in a city, gaining the 'city granted ability or resource' to 'leave' the city, taking some city defenders with them into combat that turn.
This opens the game up to a significant exploit: Throw a token unit into battle with the City for Battle 1, draw off city defenders, attack with the rest of your forces in the next Battle(s).
OK, so I'm going to do some 'If-Then-Else' flowcharting here, and see if the Collective can hit on some way to make this work.
City is Built. A specialty 'CityDefenseSummon' unit is created, that will (of course) show up in the first combat. On turn one, this unit casts 'BattleAutoCastSpell' which summons the requisite defenders. Said unit could stay or die at that point. I'm thinking this makes a great excuse for a city strongpoint unit, that has to be taken out to 'win' that section of the city/the first battle.
This unit should have 0 strategic move, so it 'has to' remain in the city. Note that a player might still move him out accidentally, which is a significant issue but for now let's follow this chain of thought.
OK, so the battle commences.
No non-CityDefenders present:
- Only City defenders show up, so if they lose, city falls.
- If the defenders win, what happens? Currently, they won't be around for battle #2...
Other units present:
- All units eliminated - Attacker wins the city (as expected)
- Attacker defeated/escapes:
- -If 'regular' units are still there, they are available for Battle #2, and could theoretically 'resummon defenders via a spell.
- If 'the CityDefenseSummoner' unit is present, and has survived, it would be around for the next Battle, and could summon more defenders...
- If all 'regular' unts are defeated, including the 'CityDefenseSummoner(s)', then the city is wide open for Battle #2.
Sooooo, this is what I'm pondering...
A 'baseline' unit is created, that resides in a city (visible in the strategic window). This unit has 0 or negative Move in strategic. This unit is the City Marshall/Headquarters
This unit will use 'BattleAutoCastSpell' to summon all other city defenders (Defender's Call)
- It remains until the end of combat. If it survives, then it is returned to the City/Map and is available for Battle# 2...
- It is eventually killed. If it is 'tough enough, chances are all of the other units will have been killed off by this point, as they were easier targets... hence why I'm leaning to this being a 'Tower with HP' or similar strong point that the Attacker needs to eliminate to win.
If this unit is essentially a 'strongpoint', it could have say 1 intiative, 0 movement, say 1000 HP, and no attack abilities. This would mean that other units will have completed say 16 or more actions (assuming the lowest initiative is 16), before this unit is 'asked' to act again. Of course, it's action would probably be to 'Pass', but perhaps it might have the ability to summon more defenders, heal a unit, or some such.
If the Attackers decide to 'focus' on killing this unit, that'll divert a bunch of attacks away from the other defenders (except perhaps for Area Effect, Sweeping, etc. attacks), giving the other defenders a 'leg up'. If the attackers kill everyone else off first, well at that point they can finish this unit off, so it shouldn't be TOO tough - lest you endu upspending a whole bunch of rounds basically 'beating down the tower until it is dead', or watch, more or less helplessly while this happens...
Anyways, in order to 'track' the number of city defenders available to it, this 'Strongpoint' unit could have a 'CityDefenseUnitCounter'stat, that tracks the number of units that this unit is able to summon. It'd also be cool if there was some way to 'track' the number of units this unit has summoned. Perhaps via the Summoning cap mechanic or some such. How to do that...
At the start of the battle, BattleAutoCastSpell creates a number of defenders equal to the value of the 'CityDefenseUnitCounter' stat. Before this happens, the stat is checked against a 'default value', and if the 'CityDefenseUnitCounter' stat is higher than the Default value, it is Set to the default value (see below for why)
Summoned City Defenders each cost 1 'LivingDefenseUnitCounterResource' point each round to maintain. (The 'Strongpoint' unit is the Caster in this case)
The Caster/Strongpoint unit has alreadya been assigned a 'Max Number' of 'LivingDefenseUnitCounterResource' points each round, equal to the 'maximum number of summons we want to see'. Note that this value is set when the Stronghold unit was first assigned the 'BattleAutoCastSpell' that summons defenders, and does not change unless an Improvement is built that 'ups' the value.
After earning the new points, a 'comparison check' is made between 'LivingDefenseUnitCounterResource' and the 'Max Value' stat, and if more points are coming in than are going out, this 'adjusts' the 'CityDefenseUnitCounter' stat to a new (lower) value, to account for the lost defenders. We don't want this value going up or down each time this unit 'acts', hence the need for a comparison attribute.
1 -Set value of 'CityDefenseUnitCounter'to:
- Calc [['Max Value'] - ['LivingDefenseUnitCounterResource']]
- Calc2 [[Calc 1] * -1] (example: max value:6 - LivingMaint:5 (someone died). Total is 1, so we invert it to -1 for (Calc 3)
- Calc 3 [['Max Value'] - [Calc2]] (example: Max Value 6, Calc 2 -1, new value 5)
- Value [Calc3]
2 -Then, Set value of LivingDefenseUnitCounterResource to:
- Calc [['Max Value']]
- Value [Calc]
Step 2 resets this value to 6, which you then subtract the 'summoning maintenance' from on this unit's next action. Of course, this needs to be 'checked' every round, which means a spell needs to be in effect to make this check.
If this unit survives the combat, when it is called upon at the start of the next battle, the 'CityDefenseUnitCounter' stat will determine the available # of defenders for that next battle. E.G. if say after the comparison is made the value is '6', then 6 units are available in the next Battle. If the Value is '3', then only 3 units would be available.
OK, now about that 'CityDefenseUnitCounter' stat being higher check? I'm thinking that the 'Stronghold' unit will earn a number of 'CityDefenseUnitCounter' stat points each strategic turn. This adder could reset the value to the 'Maximum', or perhaps regenerate this value at a lower rate. Since 'calcs' can't be done outside of Spelldefs, this is why you'd need have the check at the start of combat, when the units are first summoned, to set this stat a lower value, if it is higher than the 'maximum number of defenders we want this unit to be able to summon.
Clear as mud, right?
Anyways, the Stronghold unit's summoning abilities will increase as cities grow in size, via a CityModifyAbility stat tied to the new improvement, or perhaps via an 'Unlock spell'. Note that even if the city ended up 'giving' DefenderCount points to every stationed unit, ONLY the Stronghold unit can actually use them... so by definition this would have to be a 'unit' stat, not a 'global' resource.
In short, it might actually be easier to allow up to 15 units in a city, and then create units with a '0 strategic move' stat. And then have the appropriate Improvements create new Defender units when they are built (similar to what happens with Elementals and Shards, if you have that particular Ability). Once they die, you'll have to replace them manually (via building), but at least they will be around for every battle until they die.
OK, that ate up a couple of hours of valuable modding time! If nothing else, maybe this will spark some other ideas at least...