Commit graph

205 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
9b6008be54 ExpAI: fix bug in finding hexes next to healers
The CA was supposed to mark hexes next to healers as potential healing locations, but because of this bug that did not work.
2021-03-14 08:59:09 -07:00
mattsc
0421a524f9 ai_helper.get_closest_location: bug fix for border hexes
If a unit is passed as the last argument to this function, the returned hex is supposed to be passable for that unit. Hexes on the map border need to be excluded in this case.

This specifically also fixes a bug in the Messenger Escort Micro AI. Previously, waypoints right at the map border could sometimes lead to the AI showing an on-screen error message and becoming inactive.
2020-09-26 14:06:17 -07:00
mattsc
9020c92498 AI retreat CA: bug fix for cure-only abilities
That is, those that cure poison, but do not provide any healing.
2020-02-11 12:33:39 -08:00
mattsc
ecbb41b0ae Experimental AI: fix use of 1.15 syntax
Commit f528188c67 backported a bug fix from Wesnoth 1.15 and accidentally introduced Wesnoth 1.15-only syntax.
2020-01-15 19:51:46 -08:00
mattsc
450e3d1a48 Experimental AI: do not use village hunt CA
The algorithm used in this CA is too simple to work reliably in a general setting, it tends to send whole groups of units toward small numbers of villages, or even individual ones. In its current version, it should not be used at all, not even in the Experimental AI. The recommended way to emphasize village hunting is to set the village_value aspect to a larger-than-default value and let the move-to-targets CA take care of it.

An updated version of this CA's code is, however, left in place for potential future work as an external CA in Wesnoth 1.15.
2020-01-01 19:22:11 -08:00
mattsc
8fc6cabf7d Experimental AI: fix village_hunt CA bug
This is really just a work around for a CA that is very much sub-par though.  I will remove this CA from the ExpAI next.
2020-01-01 19:12:37 -08:00
mattsc
f528188c67 Experimental AI castle switch: bug fix for units on keep check
This also fixes the score assignment, with the 'break' being in the wrong part of the conditional.
2019-12-16 07:27:07 -08:00
mattsc
bf6b66a789 battle_calcs.lua: fix bug in relative_damage_map() 2019-12-16 07:21:13 -08:00
mattsc
71464b1a7c Lua AI utility functions: 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.
2019-10-05 20:22:24 -07:00
mattsc
882ba311c6 Experimental AI recruiting: fix eval debug output 2019-10-05 20:13:23 -07:00
mattsc
2436195012 Lua AIs: replace print() by std_print() 2019-10-05 20:05:12 -07:00
mattsc
d98b7f6746 Lua AIs: remove unused debug output 2019-10-05 20:01:04 -07:00
mattsc
91b84539de Experimental AI: fix poisoners ignoring [avoid] tag 2019-10-05 07:21:28 -07:00
mattsc
da080dd94c Experimental AI: fix guardians being used for village actions 2019-09-18 19:41:12 -07:00
mattsc
ac2e90faca ai_helper: get_unit functions should only return live units
Live beiing defined as in get_live_units(), that is, non-petrified units
2019-09-18 16:27:18 -07:00
mattsc
aa93baacbf ExpAI recruiting: fix AI crash for unit type with unknown race 2018-11-13 06:58:06 -08:00
mattsc
4450da2b80 ai_helper.move_unit_out_of_way: prevent potential for divide-by-zero
dx = dy = 0 is a perfectly acceptable choice of values when there is no preferred direction.
2018-10-21 19:25:46 -07:00
mattsc
fb364cf2b7 AI helper: improve efficiency of get_unit functions
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.
2018-06-06 20:23:56 -07:00
mattsc
84837f0a91 Experimental AI recruiting: use math.huge instead of 9e99 2018-05-20 07:36:05 -07:00
mattsc
d5a910c358 Experimental AI: clear recruit cache when no recruit action found 2018-05-19 18:46:59 -07:00
mattsc
09fe71911f Fix Experimental AI not working without enemy units
An example are the first two turns of Dark Forecast.
2018-05-19 18:39:45 -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
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
3a90f86674 Addressed more whitespace issues from #2613
[ci skip]
2018-03-12 03:48:59 +11:00
Charles Dang
471c9e876a Addressed a large chunk of the whitespace issues from #2613
[ci skip]
2018-03-09 11:37:00 +11:00
Celtic Minstrel
dabf09fce1 Fix deprecation spam
This removes the Lua deprecation_message function in favour of exposing the C++ variant to Lua instead.
It also moves all deprecation messages to a separate logdomain, making them easily enabled en masse.
2018-03-04 21:21:33 -05:00
mattsc
3b2077fdc3 Fast Micro AI ai_helper functions: fix rarely occurring bug
When the AI moves a unit out of the way for another unit’s move, it is
occasionally possible for the former unit to use up all its movement
points (e.g. if it has few MP or on narrow crowded maps). If that unit
is on the list to be moved later during the same sequence, this caused
ai_helper.robust_move_and_attack() to return nil, which then made the
Fast Micro AI produce an error message.
2017-11-08 22:33:24 -08:00
Jozrael
e175bb1c7d Fix crash when unable to find closest enemy. 2017-10-02 14:43:16 -07:00
Celtic Minstrel
d192f07123 Implement standard deprecation system for Lua API
(as proposed by @DeFender1031)

All existing deprecation messages in the Lua code have been changed to
use the new deprecation system.

The goal is to eventually use an equivalent system for ALL areas of the API.
2017-08-14 12:36:09 -04: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
f6c04e7dd1 Add functional.lua which implements higher-order functions
This covers all the main higher-order functions included in WFL, except zip.
The two already implemented in ai_helper have been replaced with redirection stubs.
2017-05-10 17:40:20 -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
37f1c490a5 Lua: Use the second argument to error() where appropriate 2017-05-10 17:40:13 -04:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
mattsc
36b2b4e9a7 AI helper functions: consistently ignore shroud when path finding
This is the default Wesnoth AI behavior. It is done in a way that still
ignores hidden units.
2016-12-09 18:57:18 -08:00
mattsc
8d76ad32b0 ai_helper: new function find_path_with_shroud() 2016-12-09 18:53:40 -08: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
fa48c9c2ac ai_helper: compare unit proxies directly, not by coordinate
This was not possible when this code was first written, but it is valid
syntax now.
2016-10-22 15:14:26 -07: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
1cef83b08a ai_helper: fix indentation 2016-10-21 21:09:54 -07:00
mattsc
cc6679159b ai_helper.robust_move_and_attack: return action result to calling function
This function is supposed to be able to deal with all kinds of rare and
weird events without throwing errors, but it should still return a
status table describing what happened. The vast majority of situations
will simply return the move_result tables. For all the strange stuff
that could also happen due to WML events etc., we set up dummy tables
with the same structure and (somewhat) descriptive error messages
instead.
2016-10-21 20:57:16 -07:00
mattsc
bd1b45e814 ai_helper checked actions: move error string into call to error()
… rather than making it a separate message.
2016-10-21 17:25:11 -07:00
mattsc
74792845d7 ai_helper.movefull_stopunit: return action result to calling function 2016-10-21 07:26:26 -07:00
mattsc
13d2cdfc29 ai_helper checked actions: return action result to calling function 2016-10-21 07:22:45 -07:00
mattsc
204ccb0584 ai_helper: move checks for incomplete/empty moves to functions 2016-10-21 07:04:02 -07:00
mattsc
022d2cd725 ai_helper checked actions: some modifications to error messages 2016-10-21 06:46:41 -07:00