Re: [Freeciv-Dev] [2 x Patch] struct government + unit upkeep
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Thu, Jun 03, 1999 at 10:26:02PM -0500, Bobby D. Bryant wrote:
> Sune Kirkeby wrote:
>
> > Second is the unit upkeep patch, which removes the hardcoded
> > unit upkeep costs, and replaces them with values from four new
> > fields in units.rulesets. (The fourth being a recently suggested
> > suggested gold upkeep cost).
>
> Keep in mind that upkeep is a function both of unit type *and* government
> type. What you want to implement might require a slightly more complicated
> scheme, such as adding an "upkeep class" flag to units.ruleset (rather than
> the explicit upkeep costs), and then adding the effects of the "upkeep
> classes" wherever the government info is stored.
>
> As an example, upkeep classes might include "settlers", "military", etc., and
> their costs would be itemized per class (not per unit) under each of the
> government definitions, crudely something like this -
>
I am not entirely sure that I understand how this would work, but please
bear with me for now. I have actually implemented the city_support in
common/cityturn.c, and having it work under Despotism (that's as far as
I have come in my testing, more to follow :-).
I will describe the way I implemented things, then you can comment wether
you thing it isflexible enough.
[ SNIP rulesets SNIP ]
>
> Even the above crude outline does not allow management of how many units must
> exist before the costs come into play, which I presume would be specified in
> the government definitions. For instance, IIRC a monarchy allows up to three
> units of any type without shield costs, but settlers have a food cost
> regarless of how many units of any type exist. How should the new scheme
> handle this? More flexible --> more code and more .ruleset dependencies.
>
The patch actually handles the "three free units" in monarchy and the
"units up to city size free" in despotism and anarchy. The way I do it
is two groups of fields in struct governments:
int extra_cost_happy
int extra_cost_shield
int extra_cost_food
int extra_cost_gold
and:
int free_happy
int free_shield
int free_food
int free_gold
There are two special values NO_UPKEEP (for extra_cost_*) and CITY_SIZE_FREE
(for free_*). A few examples of how the current governments are
implemented:
Anarch and Despotismy:
extra_happy_cost = NO_UPKEEP; no unhappy people caused by aggressive units
free_shield = CITY_SIZE_FREE; units up to city size cost no shields
Democracy:
extra_happy_cost = 1; units that have >1 base level happy cost have one
more added
extra_food_cost = 1; settlers are more expensive in later govs
This system allow all the current Civ II governmentes to be supported,
as far as I can tell.
The implementation I did works something like this:
init four counters with the free_* values of current gov
loop over units {
calculate unit cost + extra_cost_* taking NO_UPKEEP into account
reevaluate happy_cost based on aggressiveness, police and wonders
military units at home might suppress unhappy citizens
if (cost > 0) {
if (free_counter_for_cost) {
--free_counter_for_cost
} else {
cause unhappyness, eat food, use shields, etc
}
}
}
As you can see it's not implemented via unit classes, but the only thing
I have not figured out how to handle yet is Fanatics under Fundamentalism,
but since Fundamentalism is not yet in Freeciv that's not too big a problem,
yet :-)
Did I forget anything?
> And again, keep in mind that it might be desirable to allow a modpack
> designer to define the number of upkeep classes as well as the number of
> government types, and write the code accordingly. Keep everything as
> ruleset-driven as possible.
>
I hope to do rulesets of some form (inlined in tech or a new gov) once
the code actually works to everyones satisfaction.
> Bobby Bryant
> Austin, Texas
>
>
Re: [Freeciv-Dev] [2 x Patch] struct government + unit upkeep, Bobby D. Bryant, 1999/06/03
- Re: [Freeciv-Dev] [2 x Patch] struct government + unit upkeep,
Sune Kirkeby <=
|
|