Commit graph

180 commits

Author SHA1 Message Date
mattsc
23fc509256 Lua AIs: fix some incorrectly used variables
Fixes #5586
2021-03-14 08:59:42 -07:00
mattsc
0c7ea59613 Multipack Wolves MAI: fix error when a wolf is surrounded 2021-03-14 08:59:41 -07:00
mattsc
778fde4fbe Protect Unit Micro AI: ensure units are on AI side
In general, the units specified in the MAI setup should be on the AI side.  However, that might change during a scenario, for example when there is an event that switches units to other sides.
2021-03-14 08:59:41 -07:00
mattsc
c61494e1dc Goto Micro AI: fix possible error when ignoring enemies
The final determination of the hex to move to must take enemies into account, otherwise the MAI might try to move the unit to a hex it cannot actually reach.
2021-03-14 08:59:41 -07:00
mattsc
768c5f8315 Goto Micro AI: fix checks of avoid_enemies key
Numerical values are sometimes transferred from WML to Lua using the string type. This applies, for example, to very small numbers, such as 0.0000000000001. This needs to be taken into account when checking whether avoid_enemies is a number.
2021-03-14 08:59:41 -07:00
mattsc
465ba7cc41 Forest Animals Micro AI: exclude rabbit holes on map border
Previously, a rabbit hole item on the map border could be selected for spawning a new rabbit, resulting in an error message on screen and abandoning the CA for the rest of the turn.
2020-01-21 16:30:26 -08:00
mattsc
e82469adcb Bottleneck Micro AI: bug fix for units in front of bottleneck
Previously, units so far in front of the bottleneck that they could not get behind it in one move were left stranded. Now they are moved toward it.
2019-12-16 12:41:32 -08:00
mattsc
f77dbe4804 Herding Micro AI: fix variables not being local 2019-10-05 20:17:00 -07:00
mattsc
2c94696f83 Forest Animals MAI: fix AI crash when using custom rabbit hole image 2018-12-27 14:51:18 -08:00
mattsc
f24bd96f42 Fast Micro AI: fix for chance-to-hit specials without id
All mainline chance-to-hit weapon specials have ids, but it is not required for UMC specials.
2018-08-10 07:05:01 -07:00
mattsc
7727130e24 Goto Micro AI: add [and] to a filter
Another efficiency improvement.  This ensures that the side of the unit
is checked first before the potentially complex rest of the filter is
evaluated.
2018-06-06 20:24:04 -07:00
mattsc
4b8870ed93 Goto Micro AI: change order of SLF and SUF evaluation
This is for efficiency reasons, as location filters do not necessarily
change throughout a side’s turn, while fewer and fewer units have moves
left.
2018-06-06 20:24:03 -07:00
mattsc
c9ef14ad54 Do not load helper.lua where it is not used any more 2018-05-12 17:41:42 -07:00
mattsc
0396461309 Remove unnecessary inclusions of helper.set_wml_action_metatable {} 2018-05-12 17:41:42 -07:00
mattsc
8ff8acea72 Lua code: replace deprecated helper.[gs]et_variable_array() calls 2018-05-12 17:41:40 -07:00
mattsc
c7f32b1ed5 Lua code: replace deprecated helper.child_range() calls 2018-05-12 17:41:40 -07:00
mattsc
a5bd46e172 Lua code: replace deprecated helper.get_child() calls 2018-05-12 17:41:39 -07:00
Charles Dang
134353f863 Further cleanup of deprecated Lua API usecases (inc. ones from fef953a)
[ci skip]
2018-03-17 00:41:32 +11:00
gfgtdf
fef953a48e remove ai.synced_command
fixes #1649 . ai.synced_command could easily be used to implement all types of
undeteced cheats so it was removed. As a replacement this commit adds a
[custom_command] synced command that just calls
wesnoth.game_events.on_synced_command which calls a lua handler that
must first be set.
2018-03-16 13:43:05 +01:00
mattsc
85b46f34b0 Fast Micro AI: make code robust against events removing units
The previous version caused errors under some circumstances when an
event removed units other than the attacker during or immediately after
an AI attack.
2018-02-11 08:05:58 -08:00
Matthias Krüger
b11d3fdcbe fix a bunch of typos found by codespell in data directory.
https://github.com/lucasdemarchi/codespell
2018-02-06 23:03:06 +11:00
mattsc
d53243daa9 Fast Micro AI: fix typo from commit 6efc5ae090 2017-10-03 20:55:34 -07:00
mattsc
24891d85e2 Lua AIs: remove unused library inclusions after distance_between change
Follow-up to 6efc5ae090
2017-05-11 10:22:00 -07:00
Celtic Minstrel
6efc5ae090 Replace helper.distance_between -> wesnoth.map.distance_between (fixes #1686) 2017-05-11 04:14:03 -04:00
Celtic Minstrel
0539a68eb4 Migrate ai_helper.LS_random_hex to location_set:random 2017-05-10 17:40:21 -04:00
Celtic Minstrel
9b635994e1 Add location_set.(of|to)_triples (migrated from ai_helper) 2017-05-10 17:40:14 -04:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
Celtic Minstrel
f45d795134 fixup 0f01f97b (GNA25615) 2017-03-23 17:00:51 -04:00
Celtic Minstrel
0f01f97b30 Update Micro AIs to use new Lua API functions for altering AI 2017-03-20 12:00:21 +11:00
mattsc
3236a4b085 Micro AIs: fix some MAIs not working under shroud
This is done by ignoring shroud for path finding (while still taking
hidden units into account correctly), consistent with default Wesnoth
AI behavior.
2016-12-09 18:59:52 -08:00
mattsc
acecd77bb4 Lua AIs: use new syntax for iterating over attacks
This is both simpler and faster than the old syntax.
2016-10-22 13:54:32 -07:00
mattsc
93f95f1d4c Fast Micro AI: better recovery from ambushes etc.
This is not necessary for most other Micro AIs, but this AI moves many
units per execution for speed reasons. If an ambush or failed teleport
or similar happens, it is better to reconsider rather than pull through
with the rest of the moves.
2016-10-21 20:57:16 -07:00
mattsc
d375321e64 Fast Micro AI: fix behavior with attack_hidden_enemies=yes
ai_helper.get_attacks() now excludes hidden enemies by default -> they
need to be specifically included if they are to be attacked, as opposed
to having to be excluded when not.
2016-10-21 17:25:11 -07:00
mattsc
cf731dd923 Wolves Micro AI: fix problem with target unit filtering 2016-10-21 17:25:11 -07:00
mattsc
67fd4367fd Wolves Micro AI: better recovery from ambushes etc.
This is not necessary for most other Micro AIs, but this AI moves
several units per execution. If an ambush or failed teleport or similar
happens, it is better to reconsider rather than pull through with the
previously planned moves.
2016-10-21 07:59:03 -07:00
mattsc
348f64f4a0 Multipack Wolves Micro AI: better recovery from ambushes etc.
This is not necessary for most other Micro AIs, but this AI moves
several units per execution. If an ambush or failed teleport or similar
happens, it is better to reconsider rather than pull through with the
previously planned moves.
2016-10-21 07:53:24 -07:00
mattsc
7647a4ad42 Fast Micro AI: replace tabs by spaces
To be consistent with the rest of the file.
2016-10-20 19:15:55 -07:00
mattsc
6ff7e1112d Fast Micro AI: clear all persistent variables after use 2016-10-20 19:15:55 -07:00
mattsc
fef404fdb9 Fast Micro AI: simplify code by using new ai.aspect.attacks
Note that this requires that the enemy filter in the utils function now
matches the enemy units to be attacked, while previously it was set to
all enemy units NOT matching the filter. As this is not used anywhere
else, that’s not a problem, it’s just noted here for completeness.
2016-10-20 09:36:32 -07:00
mattsc
25eb3dd20f Fast Micro AI: fix attack_filter when excluding leader
“canrecruit = nil” does not give the same result as “canrecruit =
false” in a standard unit filter.
2016-10-20 09:36:32 -07:00
Charles Dang
e8a499fcec Merge pull request #822 from GregoryLundberg/GL_Upgrade_Lua
Upgrade to Lua 5.3.3+
2016-10-18 12:58:12 +11: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
Gregory A Lundberg
fc6774289e Upgrade deprecated Lua
loadstring was removed, load does the same thing.
atan2 was remvoed, atan works instead
2016-10-17 10:34:43 -05:00
mattsc
b302289402 Micro AIs: correctly deal with hidden and petrified enemies
Previously, the Micro AI behavior was inconsistent at best when it came
to dealing with these units and could even result in AI errors when an
AI unit was ambushed or a petrified unit was in the way of a move. Now,
both types of units are properly "ignored" and the AI moves have been
made robust against unexpected events such as ambushes. Incidentally,
the latter also makes the AI more robust against WML events doing
things the AI cannot know about (such as removing units).
2016-10-16 19:59:19 -07:00
mattsc
2c2f79545e Assassin Micro AI: remove unused parameters from function calls 2016-10-12 15:17:11 -07:00
mattsc
7834b25b57 Forest Animals Micro AI: move only one unit per execution
There is essentially no time saving involved with doing it all in one
execution as all tables need to be reevaluated for each unit anyway in
order to adapt to potential changes due to ambushes or WML events. (The
latter is not all done yet, will be added in a follow-up commit.)
2016-10-11 10:11:01 -07:00
mattsc
3d2fd331d3 Hunter Micro AI: goto hex must be passable for hunter 2016-10-10 17:13:13 -07:00
mattsc
2eeed5ad35 Big Animals Micro AI: move only one unit per execution
There is essentially no time saving involved with doing it all in one
execution as all tables need to be reevaluated for each unit anyway in
order to adapt to potential changes due to ambushes or WML events. (The
latter is not all done yet, will be added in a follow-up commit.)
2016-10-10 17:13:13 -07:00
mattsc
f28d4336bf ai_helper.move_unit_out_of_way: normalize dx/dy here
Instead of making it a requirement that they should be normalized by
the calling function.
2016-10-09 14:25:15 -07:00
mattsc
b00e6d5d96 ai_helper.LS_to_triples: fix function name
For consistency with LS_of_triples.
2016-10-04 17:17:16 -07:00