There are rating contributions for hexes which heal (not all of which are villages) and others for hexes that provide income (villages). Previously only villages were considered for both types of hexes.
Ths is the enemy type list to be considered if the AI has no information about the enemies to expect, that is, if no enemy units are on the map and no enemy recruit lists can be found. It can be used to prepare AI recruiting for enemy sides that get added later during a scenario.
This is a generalized version of ai_helper.get_reachable_unocc(). It can include or exclude hexes with own units with moves > 0. It also allows passing an optional location set 'avoid_map' with hexes to be excluded.
In principle, this makes get_reachable_unocc() unnecessary, but we keep that function for backward compatibility.
This is done for consistency with similar functions in mainline, and so that the function actual returns what it name says. This breaks backward compatibility, but note that the only practical difference for that is the order in which the arguments are returned, as both 'closest_enemy' and 'location' contain the enemy location in .x/.y format.
This is done for consistency with similar functions in mainline. In principle this breaks backward compatibility. However, while it is theoretically possible for this to happen, this function will generally always return at least the hex the unit is on, so it is very unlikely that this actually makes a difference somewhere.
The ai_helper functions are optimized for speed (as much as possible in a general setting) and do all the necessary tests. For example, get_units_with_attacks() checks both whether the unit has attacks left, and whether it has any attacks in the first place.
(cherry-picked from commit 75843541bcf92e743b911ef49046c54a050e8a0f)
The relative ranking of the CA scores is not changed, except for one case when two CAs had the same score.
Reasons:
- All scores should be lower than the scores of the default Goto CA (200,000) and the default scores of most Micro AIs (300,000).
- Break tie, resulting in uncertain order of execution, of place_healers and retreat_injured CA. Healers should be placed first, to allow retreating injured units to adjacent hexes.
- Set default for generic_recruit_engine to slightly above default AI recruiting score. That way it takes effect even if the default CA is not removed.
- Increase move_to_any_enemy CA score from 1 to 1,000. It is still the lowest score that way, but allows for setting up custom CAs with even lower scores (even if it is just for end-of-turn statistics or the like).
(cherry-picked from commit 35ba82050954c2cee86321e05d6706993c08e143)
So that it is possible to use the recruit_rushers CA without the castle_switch CA.
(cherry-picked from commit 0bcb98cf5026710871d8b90919752c90808c56d0)
Now that all the AIs use external CAs, there is no need to use the persistent 'data' variable any more, unless information is to be exchanged between different CAs or is supposed to be persistent across save/load cycles.
(cherry-picked from commit 3bfd59f28ba7f70a6ac32782e98cba9ca6c2a44a)
It probably doen't make a noticeable difference for these AIs, but in general we should not call the slow functions more than necessary.
(cherry-picked from commit 42b443084125ab7a989465e5f7f19835a17ba85b)
This involves making the output independent of the stats CA (which is not used any more) and adding missing output to some CAs.
(cherry-picked from commit c2635abde1c6eea8bb74019ab78c61bddb219fff)
... unless there is a difference between nil and false. Done mostly for consistency with all the other uses.
(cherry-picked from commit 35d257f8fd35fad70539dfdc57da69e38bc10536)
All mainline chance-to-hit weapon specials have ids, but it is not required for UMC specials.
(cherry-picked from commit 5335a2af335ffdce65097e26359e96a0cbe2c733)
These used to be accessible only through unit.__cfg or wesnoth.unit_types. The Fast Micro AI is not included here as it requires a larger clean-up.
(cherry-picked from commit 8af988c6972abe75e985d0e43bd8186fe4826cb6)
The old method is very slightly faster in some circumstances (e.g. for
simple filters and when all units have moves/attacks/etc. left), but we
are talking fractions of micro seconds. By contrast, depending on the
filter used, the new method can save large amounts of evaluation time
once some units have move or attacked.
(cherry-picked from commit 972ecc2f56c3cc1391db165518324b1a3757431d)