Commit graph

360 commits

Author SHA1 Message Date
Celtic Minstrel
f145dc2bba Replace uses of the moved interface functions 2021-06-19 12:09:46 -05:00
Celtic Minstrel
a03d59d7eb Lua: Add a new schedule module
The primary components of this are:
- wesnoth.current.schedule
- wesnoth.map.get_time_area()
- wesnoth.schedule module
2021-06-19 11:07:53 -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
Celtic Minstrel
bf746a0207 Update mainline content to use the wesnoth.scenario module 2021-05-11 14:52:21 -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
b56a44ed66 ExpAI recruiting: prevent potential divide-by-zero 2021-03-07 14:46:04 -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
mattsc
cab4446580 Lua AI helper functions: remove trailing spaces 2021-03-06 09:53:27 -08:00
Celtic Minstrel
86c3c30c46
Fix a syntax error 2021-03-04 23:33:33 -05:00
Celtic Minstrel
3a7eef0310 Merge pull request #4580 from wesnoth/lua_gamemap
Refactor the game map to permit exposing it to Lua
2021-03-04 14:00:43 -05: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
mattsc
f67a5b269e AI retreat_injured CA: fix retreat_enemy_weight use
Only enemy threats are to be multiplied by this factor, not the ally support.
2021-02-27 08:56:14 -08:00
mattsc
f799269fa1 AI retreat_injured CA: improve retreat location evaluation
This includes several improvements to the retreat hex evaluation:
- Enemy threats are not the dominant rating contribution any more
- Enemy threats are based mostly on HP balance, rather than simply enemy number
- Enemy threat assessment can be modified with the retreat_enemy_weight aspect
- By default, only healing locations are considered as retreat locations, but this can be overridden with the retreat_enemy_weight aspect
2021-02-26 17:03:06 -08:00
mattsc
663a0ef8ec AI retreat_injured CA: 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-02-26 16:27:43 -08:00
mattsc
903e03d68a AI retreat_injured CA: improve retreat threshold calculation
The main problem was that the previous calculation was based on the 'caution' aspect. While that is not technically wrong, caution is also used for other purposes and there are mainline (and presumably UMC) scenarios that use large values for caution. In those cases, units retreated that were barely injured. This, again, might even be desirable for some use cases, but it needs to be decoupled from the other uses of caution. Thus, the new 'retreat_factor' aspect is used now.

In addition, the calculation is now based on a unit's maximum hitpoints, rather than its level.
2021-02-26 06:49:37 -08: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
Pentarctagon
5af1f129cd Mass convert of *^Uf terrain for SP. 2020-09-15 09:26:00 -05: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
396b258203 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:10:43 -08: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
c81ecca23b Experimental AI: do not target units without advancements in high_xp_attack CA 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
0806a2bbe1 AI spread poison CA: take attacks aspect into account 2019-12-11 07:12:10 -08:00
mattsc
6a3015f0e2 battle_calcs.lua: fix bug in relative_damage_map() 2019-12-07 19:08:48 -08:00
mattsc
009a9ef2da AI spread poison CA: apply aggression aspect
In the same way as it is done in the combat CA
2019-12-07 08:02:00 -08:00
mattsc
1ba7e9c76c AI spread poison CA: use more complete attack rating
battle_calcs.attack_rating() includes most of the contributions to the previous rating, plus a lot more.
2019-12-07 08:01:43 -08:00
mattsc
2cc8cce0e8 AI: use ai_helper.robust_move_and_attack() in all CAs 2019-12-06 08:18:47 -08:00
mattsc
96dd9c1712 AI castle switch CA: use leader-specific cheapest recruit cost 2019-12-06 08:18:47 -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
fd05a01af5 AI: make recruitment work with multi-leader castle switch
Recruiting itself still only handles one leader. This will be taken care of later.
2019-12-06 08:18:47 -08:00
mattsc
917f7ef9a5 AI castle_switch: reconsider CA score when using saved data
If the units previously on the keep moved off, we don't have to use the low score any more.
2019-12-06 08:18:47 -08:00