This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Fwd: Xconq messages


>What is the difference between :
>
>TableUU: stack-protection u1 u2 -> n%
>TableUU: cellwide-protection-for u1 u2 -> n%
>
>and the advantages of each one ?
>
>a+
>  manu

This is somewhat complicated, but since you asked ...

uu_cellwide_protection_for is a generalization of uu_stack_protection (and
also uu_protection) that catches some situations not covered adequately by
either of the two latter. Here is how they work:

uu_stack_protection works between "top level" units within the same cell
(the stack). This means that one ship (e.g. a carrier) can protect another
ship in the same cell. However, an occupant of the carrier (e.g. a fighter)
cannot protect either its own carrier or another ship in the same square.
The former of these two cases *can* be handled by uu_protection which
actually (and somewhat confusingly) is a table with dual function since it
can be used to specify both protection of occupant by transport and of
transport by occupant. But that's another story.

There was, however, no way to handle the second case, i.e. for an occupant
of one unit to protect other units in the same cell, or an occupant within
an occupant (e.g. a fighter on a carrier inside a city) to protect the
city. This is because the macros used (for_all_stack and for_all_occupants)
do not recurse into sub-occupants.

In order to handle such situations (and other problems related to
occupants-within-occupants) I wrote two new macros (for_all_stack_with_occs
and for_all_ occs_with_occs) that check all occs within occs four levels
down from the stack. Since I wanted to use nested protection in the game I
was writing (advances.g) but did not want to change anything in existing
games, I also added uu_cellwide_protection_for which uses the
for_all_stack_with_occs macro to check for protection by any other unit
(including sub-occupants) in the same cell.

A related table that was added at the same time is
uu_cellwide_protection_against. It differs from uu_cellwide_protection_for
in that it focuses on the type of attacking unit. It can therefore be used
to specify that a given unit type (e.g. triple-A) can protect all other
units in the cell against one specific attacker (bomber) but not against
another (infantry). In contrast, uu_cellwide_protection_for (as well as
uu_stack_protection and uu_protection) specify protection of one specific
unit type by another specific unit type against *all* possible attackers.

If you are writing a new game I would therefore recommend that you use the
two new functions since they handle occs-within-occs correctly, and since
you also have the option of specifying protection against specific types of
attackers. For examples of how to use them see advances.g.

If you want to find out more about how these tables really work you should
check out maybe_hit_unit in combat.c where you can find the relevant code.

BTW, all that I have said sofar applies only to combat model 0 games
(classic xconq). Combat model 1 games such as civ2.g and 3rd-age.g use a
different combat code. I recently added support for various types of
protection and other unit-unit interactions to this code, but they were all
implemented as new tables. Please note that in the new tables a higher
value means a greater instead of a smaller effect, which I think makes more
sense. The opposite is true for uu_protection etc. where zero means full
protection. The new tables also handle some other situations (effects on
attack values instead of defense, effects of terrain) which have no
counterparts in the old combat model 0 code.

The new combat model 1 tables (uu_occ_affects_attack etc.) can be found at
the end of table.def. The underlying code is found in real_attack_value,
real_defense_value and occ_can_defend_transport in combat.c. For example on
how to use them see 3rd-age.g.

Hope this answers your question,

Hans

Hans Ronne

hronne@pp.sbbs.se



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]