| 11-22-2003, 08:11 PM | #1 |
I've got some questions about the basic functionality of AIs. I tried to search for a tutorial, but there were no AI tutorials. Captains 1) What are exactly captains? 2) Is there always one captain, or can there be more? 3) Is the first hero equal to a captain, or what is the difference? 4) Are there captains if the AI does not have heros? 5) What properties does a captain have? He/she can be empty, at least, referring to units? 6) What is the basic design behind captains (if it is not apparent from earlier replies)? 7) What do the basic functions, with which you work with captains, do exactly? Attack groups 1) Is it possible to have more than one attack group (would seem so obvious in a strategy game, but...)? 2) If yes, how does this work, how do you reference them in an AI script? 3) What do the basic functions, with which you work with attack groups, do exactly (e.g. FormGroup etc.)? Cheers, Tommi |
| 11-22-2003, 09:12 PM | #2 |
1) Captains are special invisible widgets that the hard coded AI uses to coordinate movement. In game terms they are widgets that are neither items, destructables nor units. 2) There are always 2 per AI. The defensive captain and the offensive captain. 3) The captains are no visible units. 4) Yes, there are. 5) I think most of the captain natives refer to the group they are associated with (attack and defense) 6) They coordinate the movement of groups. When the AI moves groups they use move orders to the captain. Also the behaviour of the units seems to depend on how near the captain is. They often won't fight back when attacked when the captain is not near. All that is pretty hard to determine without seeing the captains and since they do not belong to one of the subtypes of widget there are no natives to get them. I found a workaround though. You can get them by catching the orders of the AI units. The target is sometimes the captain. That is how you can get their widget reference and then it can be used to track them. I wrote a trigger to get them and display their movement by pinging the minimap. By catching the orders the things the hard coded AI does can also be displayed pretty nice. 7) native CreateCaptains takes nothing returns nothing I guess that is the native that creates the captains since it is called in common.ai but I have never tried not to call it. native SetCaptainHome takes integer which, real x, real y returns nothing Each captain has a home which is usually the start location of the player. That is the place he returns to when he is idle. native ResetCaptainLocs takes nothing returns nothing I have not tried it out. native TeleportCaptain takes real x, real y returns nothing That native teleports the captain around. So you can change the captains location with it (it does not change the location of the group) native ClearCaptainTargets takes nothing returns nothing native CaptainAttack takes real x, real y returns nothing These ones are self explaining. native CaptainVsUnits takes player id returns nothing native CaptainVsPlayer takes player id returns nothing I have not tried these out. native CaptainGoHome takes nothing returns nothing Makes the captain move home (not teleport) native CaptainIsHome takes nothing returns boolean Checks if the captain is at home location. native CaptainIsFull takes nothing returns boolean native CaptainIsEmpty takes nothing returns boolean native CaptainGroupSize takes nothing returns integer native CaptainReadiness takes nothing returns integer These check the states of the attack group. native CaptainRetreating takes nothing returns boolean True when the attack group is fleeing. native CaptainReadinessHP takes nothing returns integer native CaptainReadinessMa takes nothing returns integer Checks further attack group states. native CaptainAtGoal takes nothing returns boolean Checks if the captain has reached a given goal. 1) No, there is only support for one attack group in the hard coded AI. But I guess you could simulate an additional attack group by using direct orders. 3) FormGroup reads the array in which the attack group the script wants is stored. Then it passes that info to natives that add the specified units to the attack group. |
