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.15 replies
Age of Kings Heaven » Forums » AI & RM Scripting » Ai script goal trigger problem
Bottom
Topic Subject:Ai script goal trigger problem
Melchior31
Squire
posted 07-11-18 04:46 AM CT (US)         
Hi

I am making a scenario without town-center , but i want to use
the town-under attack fact.

So I decided to create a loop trigger 0 in scenario editor

condition :to detect enemy units in a specific aerea .
effect effect : Ai script goal trigger 0 with the specific AI player.

Then in AI script I put :

(defrule
(event-detected trigger 0)
=>
(acknowledge-event trigger 0)
(set-goal 1 1)
)

(defrule
(not (goal 1 1))
(military-population > 20)
=>
attack method
(set-goal 1 0)
)

It work only one time with (not (goal 1 1)),
i would like to work every time with the loop effect. If the enemy units are not detected then you can attack .

Strangely, (goal 1 1) without the not , the loop worked.Strange.

Thanks

[This message has been edited by Melchior31 (edited 07-11-2018 @ 04:47 AM).]

AuthorReplies:
scripter64
Wolved
posted 07-11-18 08:57 PM CT (US)     1 / 15       
Hi! Which version of the game are you targeting and is this a multiplayer scenario?
Melchior31
Squire
posted 07-12-18 03:50 AM CT (US)     2 / 15       
I use Userpatch 1.5 on the original age of conquerors version , it's a scenario for single player. but i would like to use it for multiplayer too.
scripter64
Wolved
posted 07-12-18 06:12 AM CT (US)     3 / 15       
For multiplayer, the scenario trigger script goal things won't work, I think. It would be easier to do things from the AI itself. Which player number is the AI here and which player numbers are the enemies that it should be watching for? Where is the AI's "town center" and how large should the range be?
Melchior31
Squire
posted 07-12-18 12:25 PM CT (US)     4 / 15       
The scenario have no town center , i would like to have

like a condition like :

(not (town-under-attack))
=>
attack

How can I do it via triggers or Ai script ?

thanks
scripter64
Wolved
posted 07-12-18 03:30 PM CT (US)     5 / 15       
Yes, that's why I asked where the "town center" is, as in where is the center of the AI town? Is there a barracks at the center or an outpost or is it maybe just an (x,y) point on the map? Sorry for the confusion.

Please answer the following questions:
1. which player number is the AI here?
2. which player number(s) should the AI be watching for? just any enemy coming into town?
3. what is the AI town's center object or center point on the map? a unique object at the center like a pavilion or something would make things easier.
4. how large is the radius of the town (in tile distance) from its center?

With the answers here, it will be possible to have the AI find enemies in its "town" without a town center object.
Melchior31
Squire
posted 07-12-18 04:04 PM CT (US)     6 / 15       
just a misunderstand no problem



1. which player number is the AI here?

player number 2

2. which player number(s) should the AI be watching for? just any enemy coming into town?

any enemy coming in town

3. what is the AI town's center object or center point on the map? a unique object at the center like a pavilion or something would make things easier.

castle

4. how large is the radius of the town (in tile distance) from its center?

small like 10

thanks
scripter64
Wolved
posted 07-12-18 08:24 PM CT (US)     7 / 15       
One more question: Does the AI only have that one castle or does it own multiple castles? With one castle, it's a bit more simple for the AI to locate it from the script.
Melchior31
Squire
posted 07-13-18 02:39 AM CT (US)     8 / 15       
multiple castles.

But you can give me both situations because in the scenario AI can just have one castle at the endgame if the others are detroyed.

thanks.
scripter64
Wolved
posted 07-13-18 04:57 PM CT (US)     9 / 15       
I think this should work: http://www.files.com/shared/5b491f5b378cf/TownAttack.zip

The first castle placed on the map for the AI player will be its center point. If it finds the wrong one, you can either remove all of the AI's castles and place them back onto the map in order or the script will need to be adjusted. Without the scenario, finding the right castle might take a while, though lol

[This message has been edited by scripter64 (edited 07-13-2018 @ 05:00 PM).]

Melchior31
Squire
posted 07-14-18 07:47 AM CT (US)     10 / 15       
Thank you very much. It works !


it detects everything from enemy , buildings,wall, units etc...
as expected !

I have some questions to go deeper:

I would like to detect only the units , ignoring walls and buildings.
It is possible ?

if there are more than 1 reference point like 3 castles , it choose one randomly ?

Can I change the reference point at any moment in the game ,for example changing castle to barracks and its range detection ?


Thanks

[This message has been edited by Melchior31 (edited 07-14-2018 @ 08:00 AM).]

scripter64
Wolved
posted 07-14-18 08:30 AM CT (US)     11 / 15       
1. Yes, it's possible to ignore walls and buildings. Would you want to ignore villagers and monks, as well?

2. Yes, it can pick a random castle as the center reference point, but you would need to decide if that selection would be locked as the reference for the rest of the game or if it would continue to randomly change and when.

3. Yes, it can change the center reference point to other objects dynamically. However, this would require detailed information about which objects to switch to and when.

The AI could even monitor the area around multiple objects at the same time, so switching wouldn't be necessary.
Melchior31
Squire
posted 07-14-18 08:48 AM CT (US)     12 / 15       
Answers:

1- all the units included villager and monks.

2- if it's locked , the farthest building (castle) from enemy , if it's possible.

3- how make AI monitor the area around multiple objects at the same time ?

Thanks

[This message has been edited by Melchior31 (edited 07-14-2018 @ 08:49 AM).]

scripter64
Wolved
posted 07-14-18 06:17 PM CT (US)     13 / 15       
1. That's no problem.

2. Need to see the scenario layout to figure out where the enemy units are coming from.

3. Just need the object types if they're unique or the unique object ids from trigger studio or some list.
Melchior31
Squire
posted 07-15-18 02:19 AM CT (US)     14 / 15       
Ok thank you.

My last question :

(defconst find-attacker 0)
(defconst find-random 1)
(defconst find-closest 2)
(defconst find-ordered 3)


The find method enemy works without town-center ?

In your example you use find-ordered , it seems working.

thanks.

[This message has been edited by Melchior31 (edited 07-15-2018 @ 02:19 AM).]

scripter64
Wolved
posted 07-15-18 03:14 AM CT (US)     15 / 15       
Oh, ordered and random should definitely work always. The attacker search might work without a TC, but closest will probably not work as expected. I've never tried this, but you could give the AI a town center and use a up-effect in a scenario trigger to "upgrade" it into a custom castle. In this way, the AI will be able to use all town center based information and actions without a visible town center on the map.

Display Instructions Effect, Timer:99999, Number:9, Message:
up-effect 2,3,109,82,0,1
up-effect 2,3,618,625,0,1
up-effect 2,3,619,625,0,1
up-effect 2,3,620,684,0,1

[This message has been edited by scripter64 (edited 07-15-2018 @ 07:11 AM).]

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

Hop to:    

Age of Kings Heaven | HeavenGames