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

AI & RM Scripting
Moderated by Leif Ericson

Hop to:    
Welcome! You are not logged in. Please Login or Register.13 replies
Age of Kings Heaven » Forums » AI & RM Scripting » Moving individual unit IDs with AI
Bottom
Topic Subject:Moving individual unit IDs with AI
Khan Ivayl
Squire
posted 02-12-19 06:07 AM CT (US)         
I am afraid I had asked this many times before, every time with little to no reaction...

How to use AI in assigning tasks/behavior to individual unit types (instead of unit classes) and which AI files need to be accessed for that?
AuthorReplies:
scripter64
Wolved
posted 02-12-19 08:21 AM CT (US)     1 / 13       
Hi! The answer depends on the game version that you're using (CD v1.0c, HD, UP). Please also provide an example of which units you'd like to control and what you'd like them to do.
Khan Ivayl
Squire
posted 02-12-19 10:35 AM CT (US)     2 / 13       
I use the patched version of Conquerors (not HD), the one which allows you to modify the number of civilizations...

The unit ID is for now not relevant, because it's an extra unit (the ID is not in the original game, but a new number), however the unit is the same class as priests, but I'd like it to be garrisoned and not compete with priests for getting the relics...

Thank you dearly in advance!!

[This message has been edited by Khan Ivayl (edited 02-12-2019 @ 10:40 AM).]

scripter64
Wolved
posted 02-12-19 11:23 AM CT (US)     3 / 13       
What kind of building should this new unit type garrison into? Town center, castle? As for the version, if you click on the banner between "Learn to Play" and "Single Player", which version does it show?

In addition, do you already have an AI script prepared for this with an .ai and .per file? Here's an example rule to insert into your AI's .per file:

(defconst new-unit 101) ;define to the actual unit type id
(defrule
(true)
=>
(up-garrison castle c: new-unit) ;put new-unit into castles
(disable-self)
)

[This message has been edited by scripter64 (edited 02-12-2019 @ 11:27 AM).]

Khan Ivayl
Squire
posted 02-12-19 11:58 AM CT (US)     4 / 13       
Looks like a rule that could work in my version Thank you dearly! I'll try insert it in the standard AI files that can be opened with turtlepack

What are the commands for making units or classes of units fight? (This could be useful for fixing some Age of Vampires stuff as well).
Khan Ivayl
Squire
posted 02-12-19 12:31 PM CT (US)     5 / 13       
scripter64
Wolved
posted 02-12-19 12:48 PM CT (US)     6 / 13       
That rule alone won't work since it will run on the first second of the game and disable itself, so it won't affect things later on. To force them to garrison every 10 seconds:

(defconst tm-garrison 20)
(defconst timer-running 2)
(defconst new-unit 101) ;redefine to the actual unit type id

(defrule
(true)
=>
(up-gather-inside c: castle c: -1) ;keep garrisoned units inside
(disable-self)
)
(defrule
(up-timer-status tm-garrison != timer-running)
=>
(up-garrison castle c: new-unit) ;put new-unit into castles
(enable-timer tm-garrison 10) ;repeat after 10 seconds
)
Khan Ivayl
Squire
posted 02-13-19 03:39 AM CT (US)     7 / 13       
I am so grateful for the fast responses, but I am missing out on something relevant I am afraid, so I'll need to dig deeper.

Is there programming language differences between the versions? (Again I use Conquerors 1.4 patched NOT HD)

Does it matter which file we write the command in? Seems like .per 60001 is not ideal for this enterprise :/

One other thing, maybe this will be the perfect tutorial, what line does the game use, literally, to get the king in and keep him there?

Many thanks in advance
scripter64
Wolved
posted 02-13-19 10:10 AM CT (US)     8 / 13       
Just to verify that the .per file you're editing is actually being loaded, please add the following rule to flood the chat:

(defrule
(true)
=>
(chat-to-all "This rule is loaded.")
)

If you don't see this chat, please check to ensure that the .per file you're editing is actually being loaded by the active game/mod/expansion.
Khan Ivayl
Squire
posted 02-13-19 10:23 AM CT (US)     9 / 13       
No the chat works... could it be the AI thinks that the number in defconst is referencing a class instead of a unit?
scripter64
Wolved
posted 02-13-19 11:07 AM CT (US)     10 / 13       
What is the unit id of your new unit? Unit ids 900-999 are reserved for classes. For UP v1.5, 1000-1959 can be used for units, but it's best to keep AI controlled units and buildings between 0-899.
Khan Ivayl
Squire
posted 02-13-19 11:14 AM CT (US)     11 / 13       
Khan Ivayl
Squire
posted 02-13-19 12:22 PM CT (US)     12 / 13       
But, now that I know... the problem was solved...

Thank you, deeply!

[This message has been edited by Khan Ivayl (edited 02-13-2019 @ 12:23 PM).]

scripter64
Wolved
posted 02-13-19 12:35 PM CT (US)     13 / 13       
Nice
You must be logged in to post messages.
Please login or register

Hop to:    

Age of Kings Heaven | HeavenGames