Jump to content

AI script execution flow


qwerty12345

Recommended Posts

I understand that a script assigned to a creature runs continuously. How does it actually transform into actions?

I mean, suppose there's a matching IF block containing RandomWalk(). When will the creature stop RandomWalk-ing? In the next round? Or never? If there's some action next to it in the same block, when will it be performed? Will it be performed at all?

Link to comment
I understand that a script assigned to a creature runs continuously. How does it actually transform into actions?

I mean, suppose there's a matching IF block containing RandomWalk(). When will the creature stop RandomWalk-ing? In the next round? Or never? If there's some action next to it in the same block, when will it be performed? Will it be performed at all?

The scripts have hierarchy, and then the script blocks have one too... So if the creature only has RandomWalk() in the blocks with true IF statement, then it will randomly walk, or until a higher hierarchy IF statement becomes true... now the states are checked every 2 frames, and the game usually runs with 30 Frames per second... so the frequency is lesser of a concern than the correct IF states...

 

I would remember that the creatures script hierarchy goes according to the lowest bite mark in the .cre file... so first: Override, Class, Race, General, and then last and least Default -script.

The scripts files hierarchy goes according the top downs notion, so if the first IF statement is true and it doesn't have the Continue() -action in the response before the END, then only the first block is executed, until the IF state becomes untrue.

Link to comment

The scripts have hierarchy, and then the script blocks have one too... So if the creature only has RandomWalk() in the blocks with true IF statement, then it will randomly walk, or until a higher hierarchy IF statement becomes true... now the states are checked every 2 frames, and the game usually runs with 30 Frames per second... so the frequency is lesser of a concern than the correct IF states...

Do you mean that in something like

 

IF (...)

THEN

RESPONSE #100

RandomWalk()

DisplayStringHead(...)

 

the string will never be displayed?

Link to comment
Do you mean that in something like

 

IF (...)

THEN

RESPONSE #100

RandomWalk()

DisplayStringHead(...)

 

the string will never be displayed?

Nope, quite the opposite, it will be displayed constantly ... but this wouldn't be:
IF (...)
THEN
RESPONSE #100
RandomWalk()
END

IF (...)
THEN
RESPONSE #100
DisplayStringHead(...)
END 

Link to comment

RandomWalk will ever stop if some other script block's condition becomes true.

 

1. No action will be executed after RandomWalk in the same block.

2. No response block will ever be executed in a script, if some earlier block's condition evaluated true that didn't end with continue.

 

Therefore, it is best to add RandomWalk to the end of the script, and add nothing after it (neither in the block, nor after the block).

Link to comment
Therefore, it is best to add RandomWalk to the end of the script, and add nothing after it (neither in the block, nor after the block).

This works fine

IF
// searching for enemies
THEN
 RESPONSE #100
   RandomWalkContinuous()
END

IF
// search timer expired
THEN
 RESPONSE #100
   MoveToSavedLocation("default_position","LOCALS")
END

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...