"City Defense" unit and drafting

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Ignatus
Hardened
Posts: 230
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

"City Defense" unit and drafting

Postby Ignatus » Sat Jul 13, 2019 4:13 pm

A development of my older suggestion that seems easier to realize. We introduce a unit role "CityDefense" and a city-ranged effect "City_Defense". Each city with nonzero value of the effect (or sum of the effect and "City_Defense_per_Specialist" × number of specialists in the range previous turn) gets a free of building and upkeep the best unit of that role for which it fits its requirements (the unit may have "Unbuildable" flag). The unit has all the properties of a regular unit with exceptions:
* Requirement "UnitState" is fulfilled for this unit with a value "CityDefense" (the type flag itself not distinguishes the unit because you might build regular units of the same type).
* It can not leave the city.
* Actions that it can perform are listed in a ruleset game setting city_defense_actions that is empty by default; the actions can not be actor-consuming.
* Its type full hitpoints are multiplied on the effect value, so cities can have defenders of different ability of combat resistance. If the effect grows the next turn, the unit gets the additional hitpoints. If the effect is reduced, the unit loses hitpoints.
* The unit upgrades automatically between turns if the city gets ability to build a better one, even if the new type does not obsolete the old one (but may as well downgrade). The new unit inherites the damage of the previous unit (or does not upgrade as long the damage exceeds new unit modified health). The veteranship is maximal of the unit earned veteranship (may be sane to disallow him to get it) and "Veteran_Build" effect; the former is subject to normal veteranship upgrade loss.
* If the effect falls to 0, the unit as a result loses all health and is destroyed. The city may ever have defense again but if it was a veteran the experience will be lost.
* There could be a ruleset setting if, when a city is attacked, the best present unit will defend or only the defender, in the latter case if it loses, the city is lost with any units inside (CivV/VI behaves so), in the former an enemy unit must enter the city before.

Additionally to aforementioned effects, we could make another way to defend a city which lacks enough units when enemy comes: a draft of citizens to convert population into defense. You can draft at maximum "Max_Draft" effect value citizens during a turn. There can be a switch in the ruleset to what will immediately happen when you push "Draft" button on the city:
* Civ3 style: you get a regular unit with "CityDefense" role but of the lowest veteranship. Each drafted citizen makes the rest of them angrier a number of coming turns.
* Your city defense counter increases the maximum health of the defender over the effect value. The unhappiness can be removed and the population restored as you allow the militiamen to retire. But if the defender's health falls under the draft value, the citizens will be finally lost (and will be mourned for a number of turns).

Also, the defender may get one-turn health bonus from investing shields into a special building, as I described it before.

Ignatus
Hardened
Posts: 230
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: "City Defense" unit and drafting

Postby Ignatus » Sun Jul 14, 2019 1:38 pm

Probable correction: instead of growing health, we probably should put another units. Maybe it distracts player's attention from normal units and uses more memory, but it allows considerable part of troops storming a strong city to survive. Also, it increases other characteriatics like the opportunity to bombard siegers.