Adding units to AI recall lists

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.
Post Reply
User avatar
Chris NS
Posts: 541
Joined: May 6th, 2006, 3:22 pm
Location: Where the Queen lives

Adding units to AI recall lists

Post by Chris NS »

I've been trying to add level 2 units to AI players' recall lists, because I feel this is slightly fairer than giving them unlimited recruits of level 2 units. However, although I can successfully add units to a human player's recall list, the AI players don't seem to show any signs of recalling these units.

Does the AI program support recalling powerful units? If so, can anyone point me to a scenario where this has been done successfully?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Adding units to AI recall lists

Post by zookeeper »

Chris NS wrote:Does the AI program support recalling powerful units? If so, can anyone point me to a scenario where this has been done successfully?
I don't think the AI knows how to recall units. I think I remember trying something like this long ago, and the AI just simply wouldn't recall.

Alternative solution: give the AI a limited number of lvl2 recruits. For example, every other turn allow the recruit of lvl2 units ([allow_recruit]), and make a recruit event that triggers when such a unit is recruited, and remove the lvl2 recruits in that event ([disallow_recruit]). You'll end up with the AI capable of recruiting one lvl2 unit every other turn. Tweak the values a bit (like max one lvl2 unit every turn, or two units every three turns, or whatever) and you should be able to end up with a nice mixed recruit pattern, so the AI mostly recruits lvl1 units but occasionally gets a lvl2 unit.
toms
Posts: 1717
Joined: November 6th, 2005, 2:15 pm

Post by toms »

I don't think the ai can recall, as the ai players normaly just appear in one scenario and then not again.

However, I have a solution how you can make that the ai does only can have two of a certain unit type.

Code: Select all

#define LIMIT_RECRUIT TYPE SIDE LIMIT
[event]
name=prestart
 {VARIABLE recruits.{TYPE} 0}
[event]
name=recruit
first_time_only=no
 [filter]
 side={SIDE}
 type={TYPE}
 [/filter]
   {VARIABLE_OP (recruits.{TYPE} add 1}
   [if]
   [variable]
   name=recruits.{TYPE}
   numerical_equals={LIMIT}
   [/variable]
    [then]
     [disallow_recruit]
     side={SIDE}
     type={TYPE}
     [disallow_recruit]
    [/then]
   [/if]
[/event]
#enddef
Though it might not work because of the filter. If not, try storing the unit and check its variables (type,side)
First read, then think. Read again, think again. And then post!
Post Reply