Page 1 of 1

Events and AI triggers

Posted: Fri Oct 05, 2007 3:20 am
by McNaughton
I want to have an event triggered only if the nation is played by the AI. I am aware of this set of commands, but, have not had any success using them.

CheckAILevel command, syntax is: CheckAILevel = AILevel

// AI Level
_aiHuman = 0;
_aiLvlEasy = 1;
_aiLvlNormal = 2;
_aiLvlHard = 3;
_aiLvlVHard = 4;

Here's an event I created based on the above (done as a place holder, if the event triggers, that means the player is human, and 'blocks' other AI specific events, if the player is the AI, then the event should not trigger, thereby allowing AI events to take place).

Code: Select all

SelectFaction = $CSA
StartEvent = evt_nam_AIonEvent|1|1|NULL|NULL|NULL|NULL

Conditions
  MinDate = 1861/05/01

CheckAILevel = 0

Actions

EndEvent


I created an event that looked to see if the AI level was zero (human according to the above), and then this event would deactivate other AI specific events (as I didn't want to have to do a series of events for each level). However, here's what I got in the script report with the CSA as AI...

Code: Select all

Line 2405:  SelectFactions, 1 Faction selected: Confederate States of America
Line 2406:  Started processing event: evt_nam_AIonEvent
Line 2406:  This event is not yet referenced, base number of allowed occurences 1
Line 2409:  Min date evaluated: 1861/05/01 converted to turn  2673 current turn 2678  True
Line 2411:  CheckAILevel: Checking AI Level of faction  Confederate States of America at least equal to 0 True
Line 2413:  Entering triggered actions for event evt_nam_AIonEvent
Line 2415:  Finished processing event: evt_nam_AIonEvent


Looking at line 2411. Even though the player was AI, and the selection was Zero, it still triggered this as True (even though it should not). I want the event to trigger, if and only if, the player is human (thereby, if this event is triggered, all other events tagged on will not fire). If the player is any AI (i.e., not player 0), then the event should not trigger, thereby allow all of the other AI events to fire.

Here's the event that should have triggered, but didn't (even though the AI was playing the CSA). Note that line 2423 says False (that the above event actually did trigger).

Code: Select all

Line 2417:  SelectFactions, 1 Faction selected: Confederate States of America
Line 2418:  Started processing event: evt_nam_CSA_Beauregard1
Line 2418:  This event is not yet referenced, base number of allowed occurences 1
Line 2421:  Min date evaluated: 1861/07/01 converted to turn  2677 current turn 2678  True
Line 2422:  Max date evaluated: 1861/08/01 converted to turn  2679 current turn 2678 True
Line 2423:  EvalEvent evaluated: Checking evt_nam_AIonEvent 1 equal to 0 False
Line 2431:  Finished processing event: evt_nam_CSA_Beauregard1


Any help as to what is wrong in my event?

Posted: Fri Oct 05, 2007 8:42 am
by Primasprit
Hi McNaughton!

As I understand you want to deactivate certain events which help the AI if the player is human.
As [font="Courier New"]CheckAILevel[/font] does not check if the AILevel is equal to a given number but checks if the AILevel is equal or bigger than a given number you have to do it the other way:
Use [font="Courier New"]CheckAILevel = 1[/font] (player is an AI) and activate the AI events which had a Occurrences value of zero before ([font="Courier New"]ChgEvtOccurs[/font]).

Cheers
Norbert

Posted: Fri Oct 05, 2007 9:10 am
by Pocus
I forgot something, the test is 'is the player AI level at least equal to'.

So you can't check if a player is human, but you can check if a player is AI, by testing CheckAILevel = 1


(Primasprit beats me on that. He truely desserve his abandonned title) :) )

Posted: Fri Oct 05, 2007 9:12 am
by Rafiki
Pocus, is there a generic "NOT" that can applied to conditions to reverse the result of the check performed in it?

Posted: Fri Oct 05, 2007 9:16 am
by Primasprit
As far as I know there is no general way to invert conditions, some accept a 'not' as parameter though.

Posted: Fri Oct 05, 2007 9:24 am
by Pocus
Rafiki wrote:Pocus, is there a generic "NOT" that can applied to conditions to reverse the result of the check performed in it?


No, it has to be coded on a per command basis.

Posted: Fri Oct 05, 2007 11:12 am
by McNaughton
Ok, thanks! I get it now. Actually, I have been very impressed with the way events run in AACW. I like their format, and you can do a lot with them.

When I have time, I will put all that I have found out for events, and models, and units, etc. on the How-To-WIKI. I really appreciate the help!

Posted: Fri Oct 05, 2007 11:18 am
by Rafiki
McNaughton wrote:When I have time, I will put all that I have found out for events, and models, and units, etc. on the How-To-WIKI.

If there's any help I can provide in that endeavor, let me know :)

Posted: Fri Oct 05, 2007 11:19 am
by Pocus
I appreciate you appreciate the format :)
And we all appreciate what added value modders like you (and others) give to the game. We don't want modders to be left alone, wondering during a whole day why their script don't work, whereas with a 1-mn answer, the team can give the right clue.