Commit graph

143 commits

Author SHA1 Message Date
Celtic Minstrel
bbe353c8dd [Lua] Fix obviously broken functions in ai_helper.
These functions are not used anywhere, and they have other issues besides the one fixed in this commit – they're implied to return all moves, but they only return one move for each possibly destination hex. However, this will make them at least be minimally usable.
2024-02-26 13:19:55 -05:00
Celtic Minstrel
da12e97bca [Lua] Suppress nodiscard warning 2024-02-26 13:19:55 -05:00
Celtic Minstrel
652f98792e [Lua] Fix incorrect function name 2024-02-26 13:19:55 -05:00
Celtic Minstrel
3ac99d1d86 [Lua] Fix missing parameter warning when passing empty filter 2024-02-26 13:19:55 -05:00
Celtic Minstrel
7f5c687196 [Lua] Avoid reusing no-longer-needed variables for different meanings
This raises Lua warnings about mismatched types
2024-02-26 13:19:55 -05:00
Toom
0e99d4b38b Revert renaming of ai_helper.checked_move_core
@CelticMinstrel #fixes #8412
2024-02-16 15:32:00 +01:00
Celtic Minstrel
f7ef5e1362 [LuaDoc] Convert all the ai_helper documentation to LuaDoc format, and add LuaDoc for all previously-undocumented functions. 2024-02-13 19:29:21 -05:00
Celtic Minstrel
94adca0fff [LuaDoc] Fix some non-nullable warnings by adding explicit type annotations on local variables 2024-02-13 19:29:21 -05:00
Celtic Minstrel
9eefcda17a Deprecate ai_helper.split
I used level 3 deprecation because this is something that was intended for internal use in the ai_helper module, and the ai_helper module itself is not an officially stable API
2024-02-04 13:28:19 -05:00
mattsc
c7b3393a9d ai_helper: add handle_user_interact calls 2022-07-12 22:57:16 -04:00
mattsc
21475ced4f Micro AIs: add error messages if parameters are of wrong type
Fixes #6408.
2022-06-27 20:20:06 -07:00
mattsc
fdb931bb16 Remove Lua AI code deprecated at level 3 in 1.15 2022-06-21 19:15:00 -07:00
mattsc
768b930fc4 ai_helper: fix visibility bug in get_attackable_enemies()
The passed filter needs to be enclosed in an [and] tag, otherwise the check for visibility might not work correctly, for example if the filter contains a top level [or] tag.
2022-06-04 09:13:53 -07: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
5d70dd9aca Lua: Add a new ai_helper debug function to print a simulate_combat HP distribution more succinctly 2021-09-04 22:20:28 -04: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
Celtic Minstrel
1f62eae3ce Replace uses of wesnoth.find_path 2021-06-19 15:43:33 -04:00
mattsc
0a56a1af5d ai_helper.lua: remove unused variable 2021-05-22 13:33:50 -07:00
Celtic Minstrel
6584302d41
Merge pull request #5537 from wesnoth/lua_reorg
Various Lua reorganization work
2021-05-11 19:12:40 -04:00
Hejnewar
16c8fcc49c Remove remaining uses of wesnoth.special_locations 2021-05-10 11:26:12 +02:00
Celtic Minstrel
1dccc3ad76 Update mainline content to use the mathx module 2021-05-08 17:20:49 -04:00
Celtic Minstrel
1fc31c23d0 Replace all uses of get_time_stamp -> ms_since_init 2021-05-08 17:20:49 -04:00
mattsc
0c4d8ebbe6 ai_helper.lua: add 'avoid_map' functionality to move_unit_out_of_way()
Also add comment about passing it through from robust_move_and_attack().
2021-03-13 17:16:50 -08:00
mattsc
a50415b5e1 ai_helper.get_closest_location: add avoid_map parameter 2021-03-13 17:16:50 -08:00
mattsc
51e4b56a1e ai_helper.lua: fix a typo 2021-03-06 15:35:43 -08:00
mattsc
cadb233d6c Update some deprecated Lua uses 2021-03-06 15:08:54 -08:00
Celtic Minstrel
a2d7a26365
Fix several Lua issues, mostly unintentional globals (#5587) 2021-03-06 17:01:53 -05:00
mattsc
d9e8f69718 Lua AIs: fix some incorrectly used variables
Fixes #5586
2021-03-06 09:53:53 -08:00
Celtic Minstrel
9d3bf196b0 Update everything to use the new wesnoth.map module
- 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
2021-02-28 18:16:33 -05:00
Celtic Minstrel
0802779f9e Found a deprecated thing not in WC 2021-02-20 16:12:49 -05:00
Celtic Minstrel
56bdd42815
Fix segfaults and a few other issues in wesnoth.find_path
Co-authored-by: mattsc
2021-02-18 22:15:31 -06:00
mattsc
d80214d9fc 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:02:19 -07:00
mattsc
a666a34055 ai_helper.next_hop: fix bug in fan-out code
This fixes the case when the unit cannot reach the previously found next_hop location from the ideal next_hop location in the part of the code that tries to keep units from moving in single file.
2020-07-07 20:14:11 -07:00
mattsc
5f05ae31d6 ai_helper: deprecate has_ability() 2020-01-01 20:50:32 -08:00
mattsc
800c943221 ai_helper.has_ability: restore previous functionality
Before the recent change, the ability type (tag name) was checked. It then got changed to ability id. This commit changes it back to the old behavior.

For the record, there are situation when either the id or the type is needed. In addition, one sometimes wants to check wheter the ability is active (or will be active). Thus, no matter how this is done, neither will serve all purposes and sometimes other functions/functionality should be used. This commit does, however, restore the previous behavior and thus preserves backward compatibilty.
2020-01-01 20:33:59 -08:00
mattsc
34e3c9103f AI: convert leader related aspects to variants 2019-12-31 20:33:19 -08:00
mattsc
926662216a AI: allow list of ids for two passive leader aspects
In addition to 'yes' and 'no', comma separated lists of leader ids are now also accepted as values for these aspects. This allows setting the behavior only for specific leaders.
2019-12-30 19:43:28 -08:00
mattsc
a90964fd41 ai_helper: deprecate has_weapon_special() 2019-12-19 07:09:13 -08:00
mattsc
68bb48ddf1 Lua AIs: fix uses of new unit functions
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.
2019-12-18 09:23:23 -08:00
mattsc
f1e8807330 ai_helper.has_ability: add optional parameter 'exact_match'
The default behavior is unchanged.
2019-12-18 07:40:16 -08:00
mattsc
f2df220579 Lua AIs: eliminate usages of __cfg
These are cases for which the respective variable was not accessible otherwise when the code was originally written.
2019-12-18 07:21:33 -08:00
mattsc
55478e20ad Lua AI code: update deprecated functions 2019-12-17 07:34:48 -08:00
mattsc
d650a8336d
Merge pull request #4600 from mattsc/expai_ca_merge
Merge Experimental AI candidate actions into the default AI
2019-12-15 14:15:55 -08:00
mattsc
f8a9238e3f ai_helper.get_cheapest_recruit_cost: add optional input 'leader' 2019-12-06 08:18:47 -08:00
mattsc
a227e768f9 ai_helper.get_cheapest_recruit_cost: add extra recruits 2019-12-06 08:18:47 -08:00
mattsc
2d86cb20ce ai_helper.find_path_with_avoid: add 'ignore_enemies' option
Note that we do not add an 'ignore_units' option, as allies and enemies are taken into account in different ways and we want to have a way of ignoring each type individually.
2019-12-06 08:14:56 -08:00
mattsc
07d149cbfb ai_helper.next_hop: let units fan out
... as opposed to lining up if there are allied units in the way.

This changes (fixes) the default behavior. An optional 'no_fan_out' parameter is provided in order to restore the old behavior.
2019-12-06 08:14:57 -08:00
mattsc
f5990b7e95 ai_helper.get_attackable_enemies: add optional parameter 'avoid_map' 2019-12-06 08:14:56 -08:00
mattsc
891ca93710 ai_helper.put_labels: add two optional parameters 2019-12-06 08:14:45 -08:00