Commit graph

774 commits

Author SHA1 Message Date
mattsc
f1764d182f Lua code: replace deprecated wesnoth.get_variable() calls 2018-05-13 20:03:34 -07:00
mattsc
5e5a9e69e5 MAI test scenarios: remove uses of deprecated MESSAGE macro 2018-05-13 15:41:10 -07:00
Celtic Minstrel
c266b35528 Fix rabbits AI being broken by save-load 2018-03-17 17:16:22 -04:00
Celtic Minstrel
23aac4f72f Cleanup of fef953a48e
- Fix the rabbit AI
- Enable invoke_synced_command to also call (some) built-in commands
  and give an error message in the case of an unknown command
- Remove some unnecessary implementation details
2018-03-17 16:48:00 -04: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
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
Charles Dang
33725add8f Data/AI: wmlindent run
[ci skip]

Addresses some of the whitespace issues noted in #2613.
2018-03-09 11:07:23 +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
Charles Dang
4bf5c9341f Revert "Remove invalid attribute from idle AI"
This reverts commit 1d84d83c6c.

I had introduced use of the hidden= key in b2df837d8e, but
apparently didn't add them to the valid list of non-aspect keys.
2018-02-22 12:21:20 +11:00
Jyrki Vesterinen
1d84d83c6c Remove invalid attribute from idle AI
It was interpreted as a simplified aspect, resulting in a warning when
loading a replay.

Found with WML unit tests.
2018-02-21 22:34:11 +02: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
b7efaadec4 Protect Unit Micro AI: fix typo/bug in AI aspect change 2017-11-27 06:54:14 -08: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
Charles Dang
b2df837d8e Hide AIs with hidden=yes from list of available AI options (fixes #2095)
This is enough to hide them as AI options in the UI, but I don't know if other parts of the AI
engine need to know about this key.
2017-10-11 08:41:38 +11:00
mattsc
70bd919631 Idle AI: remove from data/ai/dev after all
It was left there in cfb2aa8050 for backward compatibility. However,
this causes a “duplicate AI” error at start-up in debug mode.
Furthermore, the file is not included in any current 1.12 or 1.13
add-on, so it should be safe to remove it. Using
[ai]ai_algorithm=idle_ai is the preferred option to include the Idle AI.
2017-10-05 08:34:37 -07:00
mattsc
f097c3d7f6 Idle AI: add to comment on when empty [stage] tag is needed 2017-10-04 16:48:08 -07:00
mattsc
cfb2aa8050 AIs: idle_ai is not a "Dev AI", fixes #1955
As indicated in the comment of the idle_ai config file, an AI needs to
contain at least one stage, otherwise the default AI will be injected
under certain circumstances. Unlike indicated in the comment, this now
also applies to loading a mid-scenario save. (I will add that to the
comment in the next commit.)

As this AI was in data/ai/dev/, it was previously only loaded when
Wesnoth was started in debug mode. The config was thus not available
when playing in no-debug mode, causing the default AI to be injected on
reload. This caused issue #1955.

While not strictly necessary, we keep a redirect in data/ai/dev for
backward compatibility, in case the file is included in add-ons.
2017-10-04 16:48:08 -07:00
mattsc
d53243daa9 Fast Micro AI: fix typo from commit 6efc5ae090 2017-10-03 20:55:34 -07:00
Jozrael
e175bb1c7d Fix crash when unable to find closest enemy. 2017-10-02 14:43:16 -07:00
mattsc
a673e64d44 FAI files: remove trailing whitespaces 2017-10-01 13:43:27 -07:00
mattsc
6751172282 Poisoner FAI: prevent passing empty list to min(), fixes #1999
The WFL min() function was changed from returning zero to returning an
error when an empty list is passed as argument (commits eccd3d8e and
fd9f1153).  This adapts the Poisoner FAI code to deal with that
correctly.
2017-10-01 13:41:35 -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
4b8e37044c Micro AIs: Fix Lua error in AIs that use unit variables 2017-05-11 16:00:51 -04: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
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
e945755793 Accidentally committed this 2017-05-08 13:52:31 -04:00
Celtic Minstrel
5da2d71a20 Move [micro_ai] implementation to data/lua/wml 2017-05-03 02:45:54 -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
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
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
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
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