25 Commits

Author SHA1 Message Date
mattsc
b1b521f582 Lua AI CAs: add handle_user_interact calls
Insert these calls in loops that do expensive calculations for the CAs of the default and experimental AIs.
2022-07-12 22:57:16 -04:00
Pentarctagon
370d03ccb7 Fix luacheck warnings and add to CI.
Note the `exclude_files` in .luacheckrc should be deleted once the eventual Ubuntu 22.04 base image has an updated luacheck that supports lua 5.4.
2021-11-28 14:26:02 -06:00
Celtic Minstrel
4ec60b99d9 Lua: Update all mainline references to the helper module 2021-07-07 01:32:05 -04:00
Celtic Minstrel
91f6bf93a4 Fix a broken deprecation and replace some deprecated uses
Fixes #5877
2021-06-20 00:59:59 -04:00
mattsc
c81ecca23b Experimental AI: do not target units without advancements in high_xp_attack CA 2019-12-30 19:43:28 -08:00
mattsc
626d7ee381 AI: add [filter_own] to all default AI candidate actions
This allows restricting each CA individually to only a subset of the units. It also means that several instances of the same CA can be used in the same AI configuration, in order to, for example, force the order in which units are dealt with, or to apply different settings to different units.
2019-11-21 12:09:33 -08:00
Celtic Minstrel
977f05d77f Lua: Replace uses of deprecated (moved) unit functions
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
2019-11-15 22:39:08 -05:00
mattsc
0c57ae16e4 Lua AIs: do not use hard-coded values for modifiable parameters 2018-11-05 20:22:11 -08:00
mattsc
ed406495d7 Lua AIs: do not use engine's 'data' variable unless necessary
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)
2018-10-07 03:24:48 +00:00
mattsc
b5c8c60ad0 Lua AIs: get unit cost/level directly from proxy unit
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)
2018-10-07 03:24:37 +00:00
mattsc
25b2024ee8 Lua AIs: use unit methods instead of wesnoth functions
(cherry-picked from commit a6866390dfa64097fa4cb099b39736c3e2220ce4)
2018-10-07 03:24:36 +00:00
Celtic Minstrel
6efc5ae090 Replace helper.distance_between -> wesnoth.map.distance_between (fixes #1686) 2017-05-11 04:14:03 -04:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
mattsc
70b9aea5a4 High-XP Attack CA: do not use AI leader for this type of attack
Otherwise it is too easy to exploit this by baiting the AI leader to
run into a trap, and it is too difficult for what it's worth to make
sure the attack location is safe. If only the side leader is left to do
such an attack, it's more often than not not a good idea to do so
anyway.
2016-11-01 06:27:38 -07:00
mattsc
1bed30c8c3 High XP Attack CA: respect the attacks aspect 2016-10-17 17:59:03 -07:00
mattsc
a333b9a5b7 High XP Attack CA: correctly deal with hidden and petrified units 2016-10-17 17:59:03 -07:00
Celtic Minstrel
e81131fcc5 Add deprecation messages for old AI aspect fetchers
This commit also updates uses of these fetchers in mainline Lua code.
2016-10-17 14:24:51 -04:00
mattsc
52826a3824 High XP attack CA: do not try to attack petrified enemies 2016-10-02 09:13:54 -07:00
mattsc
20a8a2f456 High XP attack CA: fix rare case of AI choosing wrong weapon
Because the attack simulation during CA evaluation is done with enemy
XP set to zero, the AI previously sometimes chose a different weapon
during execution than what was used for evaluation. This resulted, for
example, in archers sometimes attacking an enemy without ranged attacks
with their melee attack when aggression=1.
2016-09-23 08:32:34 -07:00
mattsc
d3a3825a26 High XP attack CA: don't attack hidden enemies 2016-09-23 07:54:29 -07:00
mattsc
0e87d7fd43 High XP attack CA: respect the default 'avoid' aspect 2016-09-17 16:41:41 -07:00
mattsc
c03bd5411f Various Lua AI code: use simpler and faster new syntax
No change in behavior.
2016-09-04 18:54:26 -07:00
mattsc
f76e2d0c59 High XP attack CA: remove a debug message
Also remove a related message from the test scenario.
2016-09-03 16:47:15 -07:00
mattsc
390d1fdc10 High XP CA: simplify attack conditions with 1.13 syntax 2016-09-03 07:03:00 -07:00
mattsc
6950ee1dd0 New high_xp_attack candidate action for default AI
This CA performs attacks on enemy units so close to leveling that the
default AI's combat CA would not attack them (with some exceptions).
This is meant to keep players from being able to exploit this known
weakness of the default AI.
2016-09-02 20:22:17 -07:00