64009 Commits

Author SHA1 Message Date
Celtic Minstrel
5954e3f2f4 [modify_ai]action=change now automatically inserts an id= key if not present
Also when changing an aspect, name= is inserted if not present.
2016-03-22 07:22:22 -07:00
Celtic Minstrel
155d7007c9 Produce error message when attempting to write to ai.aspects 2016-03-22 07:22:22 -07:00
Celtic Minstrel
c86b4ee5a9 Implement invalidate_on_tod_change for aspects 2016-03-22 07:22:22 -07:00
Celtic Minstrel
b4720562fa Generalize/fix some aspect stuff
- Facets no longer have to be standard aspects - they can be lua aspects or even a nested composite aspect
- Ensure aspect tags from simplified aspect contain name=composite_aspect (normally not a problem, but could be in some unusual cases)
- Merge default aspect tags instead of simply taking the first one
- Fix crash that occurred if a composite aspect somehow lacked a default (an unusual case, but not impossible)
- Fix Lua aspects
- Fix simple Lua aspects (with value= instead of code=) quoting numeric values
- Ensure Lua aspects always have name=lua_aspect and standard aspects always have name=standard_aspect
- A few additional [modify_ai] cases:
    - aspect[id].facet[*] matches the default facet; this facet can be changed but not deleted, and if it's composite, subfacets can be referenced
    - action=change works on aspects (with path=aspect[id]); requires the new aspect to have matching id= key
    - aspect[id].facet[id].facet[id] etc works in the case of more deeply nested aspects (or even aspect[id].facet[*].facet[id])
2016-03-22 07:22:22 -07:00
Celtic Minstrel
597ab40a2c Fix Lua AI component return values being lost 2016-03-22 07:22:22 -07:00
Celtic Minstrel
c49fc8a72b Fix wesnoth.debug_ai()
(Also change some internal variable names)
2016-03-22 07:22:22 -07:00
Celtic Minstrel
1d7c1c74f6 Improve backwards compatibility for Lua AI
This changes the following:
- Fixes the experimental AI, without changing any of its code except for that in the [engine] tag
- Returns a dummy self from the dummy Lua engine, so that external CAs are more easily switched to using [params]
- Changes the order in which parameters are passed to AI component code. The order is now:
        state/self,    params,    data
2016-03-22 07:22:22 -07:00
Celtic Minstrel
e2cbe50781 Allow external Lua CAs to use [params] instead of {exec,eval}_parms 2016-03-22 07:22:22 -07:00
Celtic Minstrel
d0e3bc6a70 Change syntax of fallback stage
I've done this avoid giving the illusion that it merely loads another composite AI definition by its ID.
It can, of course, still be used to do so, if that's really what you want, but normally it should not be needed.
2016-03-22 07:22:22 -07:00
Celtic Minstrel
7c9e24aa29 Remove several deprecated recruitment-related aspects
- number_of_possible_recruits_to_force_recruit
- recruitment_ignore_bad_combat
- recruitment_ignore_bad_movement
2016-03-22 07:22:22 -07:00
Celtic Minstrel
ca8cb3bd6a Remove the deprecated recruitment stage, candidate action, and aspect 2016-03-22 07:22:22 -07:00
Celtic Minstrel
6972d5170f Add ai.aspects table which provides access to all aspects
The advantage of this over the get_* functions is that it will automatically
update whenever new aspects are added.

It doesn't support the deprecated recruitement aspect.
2016-03-22 07:22:22 -07:00
Celtic Minstrel
f8f5557eb0 Huge refactor of Lua AI engine
This commit potentially breaks any Lua AI customization, except for external Lua candidate actions.
In practice, though, Lua aspects and goals will probably continue to work for the most part.

- The ai table now has a read_only attribute.
  If true, functions that change the game state will be missing from the table.
  The read_only attribute is false in CA execution and in stages.
  It is true everywhere else.
- Every Lua AI component now supports a [args] subtag.
  The contents of this tag are passed as parameters to the component code.
  This data is immutable; components cannot alter its contents.
  (External Lua candidate actions do not receive this data.)
- Accessing the persistent engine data is now supported in all Lua components.

When calling a Lua component, the Lua engine now passes two parameters:
1. The contents of the [args] tag in the specific component.
2. The contents of the [data] tag in the Lua [engine].

The return value of the [engine] code, if any, is stored for later used.
It will be passed as the third parameter to any other Lua component.
This data can be changed, but will not be saved.
The default engine does not return any such data.
2016-03-22 07:22:22 -07:00
Celtic Minstrel
56a99175da Fix main_loop stage being duplicated in MP 2016-03-22 07:22:22 -07:00
Celtic Minstrel
f545fbcbe8 Remove deprecated [goal]name=protect_my_unit 2016-03-22 07:22:22 -07:00
Celtic Minstrel
bcbba6dde3 Change ID of Idle AI 2016-03-22 07:22:22 -07:00
Celtic Minstrel
4f710ea805 Allow Lua goals to set target types as descriptive strings instead of opaque integer values 2016-03-22 07:22:22 -07:00
Celtic Minstrel
b04cca2b30 Special handling for [recruitment] tag in AI config 2016-03-22 07:22:22 -07:00
Celtic Minstrel
f57343d6f1 Minor simplification of AI config parsing 2016-03-22 07:22:22 -07:00
Celtic Minstrel
08b11139a1 Log useful error messages (and don't crash) when creating a goal with the wrong engine 2016-03-22 07:22:22 -07:00
Celtic Minstrel
852a25593e Split gamestate inspector AI config up by component type 2016-03-22 07:22:22 -07:00
Celtic Minstrel
a5d131cc1f Fix potential crash when using an [engine]name=lua 2016-03-22 07:22:22 -07:00
Celtic Minstrel
ad075afd51 Don't interpret description or id attributes as simple aspects. 2016-03-22 07:22:22 -07:00
Celtic Minstrel
28937124f3 Remove [goal]name=protect and add [goal]name=target_unit
- name=protect was a synonym for protect_location, which I consider confusing when name=target refers to a unit
- name=target_unit is of course a synonym for target, added for greater consistency of syntax
2016-03-22 07:22:22 -07:00
Celtic Minstrel
b0b02d61c6 In [leader_goal], never set facet ID to * or a number 2016-03-22 07:22:22 -07:00
Celtic Minstrel
e2ea9cd699 Lua AI: Add string version of status to AI action result table 2016-03-22 07:22:22 -07:00
Celtic Minstrel
a9a22c9721 Allow old goal syntax and [modify_ai] in AI definitions 2016-03-22 07:22:22 -07:00
Celtic Minstrel
fbb770ef3f Suppress an erroneous error message 2016-03-22 07:22:22 -07:00
Celtic Minstrel
e3679ff547 Remove list of known aspects.
This is no longer needed, since the new generalized simplified aspects syntax assumes any unknown tag or key is intended to be an aspect.
2016-03-22 07:22:22 -07:00
Celtic Minstrel
9c2027a8d8 Remove version key from AI configs
This has a lot of cascade effects and may remove support for some old syntaxes, such as [protect_unit].
2016-03-22 07:22:22 -07:00
Celtic Minstrel
0400661533 Generalize simplified aspect syntax
- Recruitment can now be specified as a simple attribute
- Attacks can now be specified with an [attacks] tag
- Allows unknown aspects to be added using simplified syntax
- [leader_goal] now sets facet ID directly
- Aspects added using simplified syntax use [ai]engine= as their engine, if present
  (Maybe this will allow adding Lua aspects with simplified syntax?)
- All of the above is only if version=11302 for all [ai] tags
2016-03-22 07:22:22 -07:00
loonycyborg
8d948765f9 wmlxgettext comments fixes needed by python wmlxgettext
they don't break perl wmlxgettext either
2016-03-22 15:23:14 +03:00
Bruno Macabeus
74b72bb846 Added attributes of the [ai]
Added the optional parameter "limit-max(number)"
2016-03-22 11:05:58 +01:00
Bruno Macabeus
58e8bc7246 Added almost the attributes of the [side]
Added the optional parameter "limit-lower(number)"
Improved the optional parameter "need-file-in(dir)"
2016-03-22 11:05:58 +01:00
Bruno Macabeus
a0c882b02d Added the optional parameter "need-file-in(dir)", to check if the file exists 2016-03-22 11:05:58 +01:00
Bruno Macabeus
71b4d75f15 Fixbug: Not correctly checked if using the optional parameters 'limit(a,b)' and 'list' simultaneously 2016-03-22 11:05:58 +01:00
Bruno Macabeus
f76a0596d9 Various attributes' [scenario] and derived elements' of it have been implemented. But missing several. 2016-03-22 11:05:58 +01:00
Bruno Macabeus
426abfd46e Added check "FORBIDDEN" for element 2016-03-22 11:05:58 +01:00
Bruno Macabeus
5e5128680c Fixbug commit f1006f1adcb56fa823108a819ec5d4c739424a22: I forgot to take the case to send a file, not a directory 2016-03-22 11:05:58 +01:00
Bruno Macabeus
7009d360ab Ops, I had written twice accidentally 2016-03-22 11:05:58 +01:00
Bruno Macabeus
31794109ad Update schema.cfg: terrain_type finished 2016-03-22 11:05:57 +01:00
Bruno Macabeus
42d4ae9109 Added the optional parameter "limit(\d+,\d+)", to specify the range of the value's attribute
Added, partly, toplevel [terrain_type] tag
2016-03-22 11:05:57 +01:00
Bruno Macabeus
98833e2b5b Added optional parameter "optional-translatable" to some rare cases 2016-03-22 11:05:57 +01:00
Bruno Macabeus
a2f8d93785 Added some comments to organize 2016-03-22 11:05:57 +01:00
Bruno Macabeus
a6fec89753 If you specify a directory, will scan all files from directory.
Now can use environment variables.
2016-03-22 11:05:57 +01:00
Bruno Macabeus
ff6aca4192 Revert change in .gitignore 2016-03-22 11:05:57 +01:00
Bruno Macabeus
128fc64f60 Return message is now more readable 2016-03-22 11:05:57 +01:00
Bruno Macabeus
b9f1ff84be Update to Python3: using print function 2016-03-22 11:05:56 +01:00
Bruno Macabeus
adacf79111 Improved the regexp of symbols in schema.cfg 2016-03-22 11:05:56 +01:00
Bruno Macabeus
67e79f7563 I forgot to translate two comments 2016-03-22 11:05:56 +01:00