The method used in the battle_outcome() function is somewhat simplified compared to the default engine calculation and faster in the vast majority of cases, but it can become extremely slow when the combined number of strikes of the attacker and defender is very large.
- get_terrain and set_terrain replaced with direct indexing operations
- get_map_size mostly replaced with either the iterator or an on_board call.
Only a few cases really needed to know the size of the map for some other purpose.
- shroud and fog operations, village owner, time areas, and location filters
- get_terrain_info replaced with terrain_types table
- Map generation functions create_map and create_filter
I switched to using defense_on() and resistance_against() incorrectly in 55478e20. I had tested these, but apparently for cases when it does not make a difference ...
The change for movement_on() is for convenience and consistency with other code only.
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
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.
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)
Apparently, when this is the case, the number key is not included at
all, rather than set to zero, when the Lua table containing the attack
information is retrieved.
This is done for cases when the value cannot be read from the unit_info
table, which might happen in some UMC. This fixes a rare bug affecting
the Fast Micro AI attack evaluation
This was an idea we tried so that we’d start with the most uncertain
attack first, but it did not work very well.
Keep the code for now, just comment it out.
That’s what wesnoth.simulate_combat() does, but is different from the
other functions in battle_calcs. Only hp_chance[0] needs to be set,
even if it is zero.
It’s slow for finding units with moves or attacks left. The alternative
method of getting all units and then looping over the table with a
condition is much faster.
These function libraries are still work in progress and change
frequently, so the code cleanup is mostly just to make sure the syntax
is consistent with that used in the Micro AIs. Changes or improvements
to the algorithms might be made at a later time.
This is a table of enemy units whose ZoC is to be ignored for route
finding. It is useful for determing where the enemy can move while
ignoring own units (enemies of the enemy) that have not moved yet.