Xalzar's WML Headaches

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
Xalzar
Posts: 310
Joined: April 4th, 2009, 10:03 pm
Location: New Saurgrath

Re: Xalzar's WML Headaches

Post by Xalzar »

:augh: Another question... is there any star-of-turn event which triggers after an ai turn event? :hmm:

Since I cannot filter the controller of the side with a filter (it's disabled in networked games) I've used a side turn event to set a variable with a value and an ai turn event to set a different value to that variable and mark that the side is ai controlled.
This worked wonderfully until I introduced a side turn 1 event that triggers after the side turn event event but before the ai turn event, so the variable is always set to the "human-control" value when the effects of this event take place, and after that the ai turn event changes the variable, too little too late. :cry:
So, how can I make the side turn 1 event take the "ai-controlled" value of the variable set in side turn/ai turn? Are there other ways to disable that event for ai?

I've tried changing the event to a turn 1 refresh (following the list in Event WML but no, apparently ai turn
Triggered just before the AI is invoked for a side. This is called after side turn, and thus the WML variable side_number still holds the number of this side. Note that this event might be called several times per turn in case that fallbacks to human or droiding is involved. I.e. it happens at the middle of turn of human side 1 if the human player droids his side. It happens after the selection of ai to play the turn but before AI is told that new turn has come.
comes very late, at the very end of that list ("after side turn" - dear wiki - it implies right after, where I come from!). :evil:

EDIT: I may have been too hasty with this question, I've found a workaround using a prerecruit event (instead of a side turn 1) nested inside a side turn 1 event, it's not foolproof (if a player doesn't recruit during turn 1 he loses all the leader and side modifications, but that would be intentional self-sabotage) and in some fringe cases a bit confusing (if the leader's first recruit is a unit of the same type the menu could be slightly unexpected for first-timers), but it's otherwise workable.
User avatar
Xalzar
Posts: 310
Joined: April 4th, 2009, 10:03 pm
Location: New Saurgrath

Re: Xalzar's WML Headaches

Post by Xalzar »

I've hit a hurdle, in the form of ai manipulation - so maybe my questions necessitate an ai expert.

I thought [modify_side] would be sufficient for my goals (more on that later), but I've read the wiki better and maybe it's not so simple after all...
Maybe I need to use [modify_ai] instead and the documentation about it is quite imposing.

The finality is modifying various aspects of the recruitment choices of the ai - such as recruitment pattern, unit types preferred, recruitment variance, limit to recruits. What do I need to know to use the code correctly? I need help sorting the relevant information in the wiki.

Maybe in the future I'll ask about aggression, leader stuff and goals, but it's secondary. First I need to see how it works without those parameters.

Side question: how does grouping=defensive behaviour work? Is the ai too passive with it?

Wiki pages I've found:
DirectActions for [modify_side] and [modify_ai]
AiWML
AI Recruitment
Modifying AI Components
User avatar
Nagasushi
Posts: 6
Joined: February 9th, 2019, 12:14 am

Re: Xalzar's WML Headaches

Post by Nagasushi »

Thanks a lot for the solution of that ai-filter! I'm currently trying to use Ravana's lua in my mod, and it works quite well for me (not tested for connected mp). But actually I need something slightly different and I can't sort it out: How can I make some different prestart events applicable to different ai sides? It seems that is_ai condition can only be applied on side 1 when it's in a prestart event block...
mattsc
Inactive Developer
Posts: 1217
Joined: October 13th, 2010, 6:14 pm

Re: Xalzar's WML Headaches

Post by mattsc »

Xalzar: It depends on whether you want to change a "simple" AI aspect (one that has a syntax using a key, such as recruitment_pattern=...) or a "composite" aspect (taking a tag, such as recruitment_instructions). For the former, you can use [modify_side], for the latter you need [modify_ai].

An example of modifying recruitment_instructions would be something like this (untested, so beware of typos; I just combined examples of the two relevant wiki pages you quote):

Code: Select all

[modify_ai]
    side=1
    action=add  # or possibly action=change
    path=aspect[recruitment_instructions].facet[]
    [facet]
      [value] 
        [recruit]
          type=Orcish Grunt
          number=3
        [/recruit]
      [/value]
    [/facet]
[/modify_ai]
Hope that helps.
Post Reply