You must be logged in to post messages.
Please login or register

AI & RM Scripting
Moderated by Sebastien, Leif Ericson

Hop to:    
Welcome! You are not logged in. Please Login or Register.3 replies
Age of Kings Heaven » Forums » AI & RM Scripting » Untrainable units/heroes as condition for training
Bottom
Topic Subject:Untrainable units/heroes as condition for training
Zungen
Squire
posted 11-29-19 08:04 AM CT (US)         
So, let's say I want player A to train rams until it has 8 archers or whatever, just because I can. I can do
(defrule
(unit-type-count-total archer-line < 8)
(can-train battering-ram-line)
=>
(train battering-ram-line)
)

Now, what should I do if I wanted to train militaman-line until I have 8 legionaries? I guess I could use triggers and send signals to the AI, something like

Condition:legion count>=8
Effect: SignalAI

but as far as I know, I can only SignalAI once. So, any workaround for creating militaman-line all the game, as long as there are less than a fixed amount of legions? Or whatever: Paladins and Frankish Paladins; Archers and Archers of the eyes, Monks and Priests.
And then, making them part of attack waves and defense.
AuthorReplies:
Leif Ericson
Seraph Emeritus
posted 11-29-19 08:27 AM CT (US)     1 / 3       
You can actually check for the amount of legionaries with AIs directly. The game assigns each unit in the game an ID number, and you can always use this ID number in AIs instead of their name. This is helpful for scenario units that lack the auto-defined names.

For example, Archer is ID 4. Militia is 74. Legionary is 1.

(defrule
(unit-type-count 1 < 8) ;if the number of legionaries is less than 8
(can-train militiaman-line)
=>
(train militiaman-line)
)

If you want to get more sophisticated, you can define your own names for your AI with a defconst command (i.e. you can define constants):

(defconst legionary 1)

Whenever your AI sees "legionary" in your AI, it now will know that legionary equals the value 1, so now you can change the rule to use the word legionary instead:

(defconst legionary 1)

(defrule
(unit-type-count legionary < 8)
(can-train militiaman-line)
=>
(train militiaman-line)
)

~`o~|\  Join the fresh and exciting AI Ladder for its fourth season!
 `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-

[This message has been edited by Leif Ericson (edited 11-29-2019 @ 08:28 AM).]

Zungen
Squire
posted 11-29-19 09:10 AM CT (US)     2 / 3       
That's great. So, buildings should be similar, right?

Edit: using numerical ID's, how would I differentiate between militaman and militiaman-line, for example?

[This message has been edited by Zungen (edited 11-29-2019 @ 09:17 AM).]

Leif Ericson
Seraph Emeritus
posted 11-29-19 09:32 AM CT (US)     3 / 3       
Yeah, buildings are similar. You can find all the unit and building IDs with Advanced Genie Editor.

The unit line IDs are negative values. It looks like militiaman-line is -296. There are also class IDs in the 900s like an infantry class (ID 906) and a villager class (ID 904) to can reference all units of a particular class. This chart might be useful for you: https://userpatch.aiscripters.net/unit.ids.html

~`o~|\  Join the fresh and exciting AI Ladder for its fourth season!
 `  |_\
       |    Learn the joy of AI scripting in my guide: The World of AI Scripting
______|______
 \        /
   .....Hinga Dinga Durgen! - SpongeBob
  `-=<.__.>=-

[This message has been edited by Leif Ericson (edited 11-29-2019 @ 09:34 AM).]

You must be logged in to post messages.
Please login or register

Hop to:    

Age of Kings Heaven | HeavenGames