EDIT: ninja'd by Eric, but I'm still posting because of the time stamps in the log
Switeck wrote:The use of ROLL_1 is only as a delay of sorts until "DESIRED_RANGE_ACHIEVED" occurs.
That doesn't work.
rollD:
doesn't delay anything.
As an example I have modified the HEAD_FOR_PLANET state of the normal route1traderAI. Instead of
Code: Select all
ATTACKED = (
"setAITo: traderInterceptAI.plist",
fightOrFleeHostiles
);
I have added
Code: Select all
ATTACKED = (
"rollD: 1"
);
"ROLL_1" = (
"setAITo: traderInterceptAI.plist",
fightOrFleeHostiles
);
Then I have spawned a trader, made sure he's in HEAD_FOR_PLANET, and attacked him. Here's the result in the log:
Code: Select all
09:05:21.669 [ai.message.receive]: AI route1traderAI.plist for Cobra Courier 201 in state 'HEAD_FOR_PLANET' receives message 'ATTACKED'. Context: unspecified, stack depth: 0
09:05:21.669 [ai.takeAction]: Cobra Courier 201 to take action rollD: 1
09:05:21.669 [ai.message.receive]: AI route1traderAI.plist for Cobra Courier 201 in state 'HEAD_FOR_PLANET' receives message 'ROLL_1'. Context: rollD:, stack depth: 1
09:05:21.669 [ai.takeAction]: Cobra Courier 201 to take action setAITo: traderInterceptAI.plist
09:05:21.697 [ai.stack.push]: Pushing state machine for <AI 0x11eadd690>{"route1traderAI.plist" in state: "HEAD_FOR_PLANET" for Cobra Courier 201}
09:05:21.697 [ai.message.receive]: AI traderInterceptAI.plist for Cobra Courier 201 in state 'GLOBAL' receives message 'ENTER'. Context: changing AI, stack depth: 2
09:05:21.697 [ai.takeAction]: Cobra Courier 201 to take action fightOrFleeHostiles
Look at the time stamps. The ship receives the ATTACKED message and rolls a die the very same millisecond. It then receives the ROLL_1 message the very same millisecond. In other words: there is no delay whatsoever, not even for a single millisecond.
Not only ATTACKED, but also ROLL_n are
priority messages which are sent
instantaneously, not waiting for the next update time. See [wiki]State_machine[/wiki] for an explanation of the difference between normal and priority messages. And see [wiki]OXP_howto_AI[/wiki] for referencing which messages are priority messages. They appear in
boldface, while normal messages are printed in plain face.
P.S.: I only now discovered the [wiki]Messages[/wiki] page via its link on the [wiki]State_machine[/wiki] page. Didn't know that it existed, but I always wanted a complete list of AI messages. However, this page hasn't been updated since 2006 and is therefore clearly out of date. But it could perhaps get updated with all new AI messages, a distinction between normal and priority messages, and—most important—be taken out of the Oolite category page and moved to the Oolite scripting category page. Perhaps it should also be renamed to OXP_howto_AI-AI_messages or something like that, so that it appears right beneath the OXP_howto_AI link on the category page. Or all AI-related pages could get their own subcategory, or something like that.