Commit graph

39 commits

Author SHA1 Message Date
gfgtdf
e08676d6a8 Fix Lua errors when checking abilities #7890
Nowdays ability.value and similar attributes can also contain formulas
(That for example make a heal amount dependent on the remaining hitpointsthe unit has
)
With this the lua ai code should no longer crash in these cases.
2023-12-24 00:51:57 +01:00
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
mattsc
6796ac3d56
Merge pull request #6792 from mattsc/retreat_allied_villages
Fix retreat injured CA taking allied villages
2022-06-24 16:31:15 -07:00
mattsc
b55148ce91 Retreat injured CA: fix for regenerate ability without value key
The ability does not need to contain a value key if it only heals poison.
2022-06-24 16:03:51 -07:00
mattsc
b9506ff795 Retreat injured CA: allow taking ally villages when aspect is set 2022-06-22 08:16:31 -07:00
mattsc
2b3824f44c Retreat injured CA: do not take villages from ally 2022-06-22 07:51:46 -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
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
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
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
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
55478e20ad Lua AI code: update deprecated functions 2019-12-17 07:34:48 -08:00
mattsc
64e969af11 AI: ensure all CAs respect passive_leader aspect
Most of the former Experimental AI CAs did already (or don't use the leader in the first place), but not quite all of them.
2019-12-06 08:18:47 -08:00
mattsc
1391745c9f AI: consider caution in retreat_injured CA
Not retreating at all for caution <= 0 is the same as for the old retreating CA. The rest is specific to this CA.
2019-12-06 08:18:24 -08:00
mattsc
34956ac15d AI: ensure all CAs respect [avoid] tags
This is for the candidate actions that were merged into the default AI from the former Experimental AI.
2019-12-06 08:14:56 -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
5e0df80ad0 ExpAI retreating: take healthy trait into account 2018-11-05 07:02:46 -08:00
mattsc
f761493c75 Lua AIs: no need to set variables to nil explicitely
This is mostly done for consistency across the Lua AI code

(cherry-picked from commit 0e7c09f7b5)
2018-10-07 03:24:40 +00:00
mattsc
37e83f1262 Lua AIs: use math.huge to initialize extrema variables
(cherry-picked from commit cb423b2fbd)
2018-10-07 03:24:40 +00:00
mattsc
25b2024ee8 Lua AIs: use unit methods instead of wesnoth functions
(cherry-picked from commit a6866390df)
2018-10-07 03:24:36 +00:00
mattsc
4586e04eca Lua code: replace deprecated helper.child_range() calls
(cherry-picked from commit 7c137e1a33)
2018-10-07 03:21:09 +00:00
mattsc
58529e95f8 Lua code: replace deprecated helper.get_child() calls
(cherry-picked from commit f0bb40590f)
2018-10-07 03:21:08 +00:00
Celtic Minstrel
8d4cf3cf62 Shorten requires where possible 2017-05-03 02:42:25 -04:00
mattsc
f2406ac829 Experimental AI: correctly deal with hidden and petrified units 2016-10-19 07:37:19 -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
c46d8459d6 Retreat AI eval: poisoned units do not get resting healing bonus
... in evaluation of best retreat positions.
2013-11-14 20:04:52 -08:00
mattsc
9c86a71ef7 ExpAI retreat code: also return enemy attack map 2013-11-01 08:51:21 -07:00
mattsc
1fa06a6811 Exp AI retreat code: make function min_hp() externally accessible 2013-11-01 08:51:21 -07:00
mattsc
938b2e6520 ExpAI retreat: count amount of hp healed when choosing retreat location 2013-11-01 08:51:21 -07:00
mattsc
456f60a9ee ExpAI: make sure injured regenerating units are not stranded if ...
... no non-regenerating units can get to safe locations.
2013-11-01 08:51:20 -07:00
Simon Forsyth
3c41b7c75a Fix bug preventing regenerating units from retreating with experimental AI
(thanks mattsc)
2013-02-16 03:11:14 +00:00
Simon Forsyth
f5a4a83def New experimental CAs to improve village capturing and retreat when injured 2013-01-21 19:54:58 +00:00