got another ai question, which is somewhat related to my old question (I tried to check your profile to email you, but it sends me back to the forum page):
Is it possible to make an Ai receive the same signal (event-detected 1 1) more than once?
What I want to do: An allied unit is near you, and he should not see your units fight somebody else. So he should also get annoyed if one of your archers stands on his feet, firing at a target... or if a swordsman next to him draws his sword to charge an enemy unit.
The trigger conditions are easy: "Bring unit (archer) to unit (friendly unit)" and "unit (archer) has target".
Trouble is, this trigger can lead to bugs. Your friend will also think your archer is attacking if your archer does some other targeting business: Your ally will also scream "no violence, please" if your archer tries to get into a transport, ram, or building, or if he is assigned to guard/follow the allied unit.
Therefore, I thought of this: The trigger sends a signal to the enemies Ai. The Ai checks for 3 seconds if there is just some harmless targeting going on, and then goes back to normal. However, if it notices any violence happening in those three seconds, the Ai sends a signal back to the triggers, and THEN your allied friend says "no violence, please."
To help the Ai to check out if there is any violence, I tried this:
(defrule (defrule (defrule This seems to work, more or less. Trouble is, the Ai checks this stuff only once. If the triggers send the same signal again, the Ai does not bother not check it another time. So: Is there any way I can "delete" the received signal from the Ai's memory, so that it goes through the same checking process again whenever a trigger sends that signal? Ingo
(event-detected 0 1)
=>
(acknowledge-event 0 1)
(chat-to-all "targeting business")
(set-goal 1 1)
(enable-timer 1 3) ; search for attack for three seconds
(disable-self)
)
(goal 1 1)
(players-unit-type-count my-player-number 112 >
=>
(chat-to-all "targeting business is an attack!!!")
(set-signal 1)
(disable-self)
)
(goal 1 1)
(timer-triggered 1) ;no attack found, back to normal
=>
(set-goal 1 0)
(disable-self)
)