All pastes #1293579 Raw Edit

RA2/YR: AI Triggers: Making an A

public html v1 · immutable
#1293579 ·published 2008-12-25 20:02 UTC
rendered paste body
<!--SECTION01--><a name="section01"></a>	<table width="95%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="bartopl" width="12" height="15">&nbsp;</td><td class="bartop" width="*" height="15">&nbsp;</td><td class="bartopr" width="12" height="15">&nbsp;</td></tr><tr><td class="edgel" width="12">&nbsp;</td><td class="txt_body1" valign="top" width="*" align="left">	<p align="center"><span class="txt_body3">RA2/YR: AI Triggers: Making an AI Trigger Viewer</span><br><i>by CannisRabidus. Published: 3/24/03. Last update: 3/24/03.</i>	</p><p align="center"><span class="txt_body2">Introduction</span>	</p><p>Modifications to Red Alert2 and Yuri's Revenge can add new computer attacks for the skirmish AI, or <b>AI Triggers</b>. Of course everyone knows this. Such AI Triggers are known as global triggers, in that they are in effect for all maps unless specifically disabled. New AI Triggers can be added to individual maps too, so this tutorial is aimed at the mapmaker as well as the modmaker. In any event, adding new AI Triggers can be really cool and can make the skirmish AI do things that the player would not consider typical, within the limits of the AI coding of the game of course.	</p><p>How to make such new AI Triggers is beyond the scope of this tutorial. However, making new AI Triggers is not really that hard, especially if you can look at what the Red Alert2 and Yuri's Revenge programmers used for the skirmish AI in the standard game. All of the AI Triggers can be found in the file <b>AI.INI</b> (for Red Alert2) and in <b>AIMD.INI</b> (for Yuri's Revenge). These files are part of the game installed on your hard disk, and you can extract them using <a href="http://xccu.sourceforge.net/">XCC Mixer</a>. For Red Alert2, use the mixer to open <b>RA2.MIX</b>, then <b>LOCAL.MIX</b> within that, then you will find <b>AI.INI</b>. Right-click and choose "extract". For Yuri's Revenge, the operation is identical, except you open <b>RA2MD.MIX</b>, and within that find <b>LOCALMD.MIX</b>, then extract <b>AIMD.INI</b>. You should save these AI files to a different folder than where you have installed RA2 and YR, else the game will read them rather than the versions in the MIX files.	</p><p>Opening either AI file in a text editor (Wordpad does nicely), you will see lots of text which might make no real sense to you. The files are formatted in this way:</p><ul><li>List of all Taskforces</li><li>All the Taskforces themselves</li><li>List of all Scripts</li><li>All the Scripts themselves</li><li>List of all Teams</li><li>All the Teams themselves</li><li>All the AITriggers</li></ul>What these things do and how they work is, again, beyond the scope of this tutorial. All we are trying to do here is get access to the AI code and be able to read it in a form that isn't just gibberish. Reading the AI ini files is admittedly confusing, but we'll fix that right up, and we'll use the <b>Final Alert2 Yuri</b> map editor to do it.	</td><td class="edger" width="12">&nbsp;</td></tr><tr><td class="barbotl" width="12" height="15">&nbsp;</td><td class="barbot" width="*" height="15">&nbsp;</td><td class="barbotr" width="12" height="15">&nbsp;</td></tr><tr><td colspan="3" class="bg1" height="15">&nbsp;</td></tr></tbody></table><!--SECTION01--><!--SECTION02--><a name="section02"></a>	<table width="95%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="bartopl" width="12" height="15">&nbsp;</td><td class="bartop" width="*" height="15">&nbsp;</td><td class="bartopr" width="12" height="15">&nbsp;</td></tr><tr><td class="edgel" width="12">&nbsp;</td><td class="txt_body1" valign="top" width="*" align="left">	<p align="center"><span class="txt_body2">Making the AI Trigger Viewer</span>	</p><blockquote><p>1. Make sure the appropriate AI file (<b>AI.INI</b> or <b>AIMD.INI</b>) is extracted as described above, and exists on your hard disk.	</p><p>2. Open <b>Final Alert2 Yuri</b>. (You should be using the latest version, v1.01, since it includes AITrigger editing support).	</p><p>3. On the <b>File</b> menu, click <b>New</b>.	</p><p>4. On the <b>Create New Map - Step 1</b> dialog, make sure the <b>Multiplayer map</b> radio button is selected and click <b>Next</b>.	</p><p>5. On the <b>Create New Map - Step 2</b> dialog, make sure the <b>Create a completely new map</b> radio button is checked. The status of the <b>Activate AI Triggers</b> checkbox does not matter, so I advise unchecking it. Click <b>Next</b>.	</p><p>6. On the <b>Create New Map - Step 3</b> dialog, nothing you set matters since this map will <i>never</i> be loaded in the game. This map you are creating is for reference purposes only. Just click <b>Next</b> now.	</p><p>7. Once the graphics load, go to the <b>Edit</b> menu and click <b>INI editing</b>.	</p><p>8. On the <b>INI Editor</b> dialog, click the <b>Insert another INI file content</b> button.	</p><p>9. A "Save As" dialog pops up. You are not actually saving anything here, this dialog is just acting as a file browser. Find the AI INI file you extracted (<b>AI.INI</b> or <b>AIMD.INI</b>), select it, and click the <b>Save</b> button.	</p><p>10. Now yet another dialog pops up - <b>Insert INI file section</b>. Make sure the <b>Import all sections</b> radio button is selected and click <b>OK</b>. You have just added the entire contents of the selected AI file to the map you are creating.	</p><p>11. Close the <b>INI Editor</b>.	</p><p>12. On the <b>File</b> menu, click <b>Save as</b>.	</p><p>13. On the <b>Check Map</b> dialog, ignore any complaints that may appear, and click <b>OK</b>.	</p><p>14. Now the <b>Save As</b> dialog pops up again. This time you really are saving something - this map. Now, this map will never be run in the game, so there's no need to make RA2/YR waste time parsing it on startup. Browse to a folder other than your Red Alert2 folder (where you are keeping those extracted AI INI files would be a good place). Type in a filename for the map - I would suggest using the filenames <b>AI.MPR</b> if this map contains the RA2 AI Triggers, or <b>AIMD.YRM</b> if this map contains the YR AI Triggers. Once done click <b>Save</b>.	</p><p>15. On the <b>Save Options</b> dialog, nothing you set will matter. Just click <b>OK</b> now. You are done.	</p></blockquote>	<p>At any time you need to study the game's AI, you can open this special "AI Trigger" map in FA2-Yuri. Using the <b>Edit</b> menu, you can:</p><ul><li>Use the <b>Scripts</b> editor to view the game's AI Trigger scripts</li><li>Use the <b>Taskforces</b> editor to view the game's AI Trigger Taskforces</li><li>Use the <b>Teams</b> editor to view the game's AI Trigger Teams</li><li>Use the <b>AITrigger</b> editor to view the game's AI Triggers</li></ul>	</td><td class="edger" width="12">&nbsp;</td></tr><tr><td class="barbotl" width="12" height="15">&nbsp;</td><td class="barbot" width="*" height="15">&nbsp;</td><td class="barbotr" width="12" height="15">&nbsp;</td></tr><tr><td colspan="3" class="bg1" height="15">&nbsp;</td></tr></tbody></table><!--SECTION02--><!--SECTION03--><a name="section03"></a>	<table width="95%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="bartopl" width="12" height="15">&nbsp;</td><td class="bartop" width="*" height="15">&nbsp;</td><td class="bartopr" width="12" height="15">&nbsp;</td></tr><tr><td class="edgel" width="12">&nbsp;</td><td class="txt_body1" valign="top" width="*" align="left">	<p align="center"><span class="txt_body2">Some Notes on How AI Triggers Work</span>	</p><p>In very general terms, this is how the elements of the AI Triggers, Teams, Scripts and Taskforces relate to each other:	</p><ul><li>An <b>AITrigger</b> will be used under certain conditions, and will call a certain <b>Team</b>.	</li><li>A <b>Team</b> will describe the properties of the units' behavior, and will call a certain <b>Taskforce</b> and will call a certain <b>Script</b>.	</li><li>A <b>Script</b> will describe the series of actions that a <b>Team</b> will follow.	</li><li>A <b>Taskforce</b> will describe the unit type(s) and how many of each that will be assigned to a <b>Team</b>.	</li></ul>Naturally, two or more <b>AITriggers</b> could call a common <b>Team</b>, and two or more <b>Teams</b> can call a common <b>Script</b> and/or a common <b>Taskforce</b>. If you make a new AITrigger, whether it be in a mod or in a map, you could use elements that are already present rather than duplicate them. Like make that new AITrigger call an already existing Team, or make a new Team call an already existing Taskforce and/or Script. This is especially important in maps, where file size is a consideration.	</td><td class="edger" width="12">&nbsp;</td></tr><tr><td class="barbotl" width="12" height="15">&nbsp;</td><td class="barbot" width="*" height="15">&nbsp;</td><td class="barbotr" width="12" height="15">&nbsp;</td></tr><tr><td colspan="3" class="bg1" height="15">&nbsp;</td></tr></tbody></table><!--SECTION03--><!--SECTION04--><a name="section04"></a>	<table width="95%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="bartopl" width="12" height="15">&nbsp;</td><td class="bartop" width="*" height="15">&nbsp;</td><td class="bartopr" width="12" height="15">&nbsp;</td></tr><tr><td class="edgel" width="12">&nbsp;</td><td class="txt_body1" valign="top" width="*" align="left">	<p align="center"><span class="txt_body2">Conclusion</span>	</p><p>As stated in the introduction, how to make your own AI Triggers is beyond the scope of this tutorial. For information on the workings of the game's AI, and how to write your own AI Trigger code, I refer you to <a href="http://www.deezire.net/">DeeZire's INI Editing Guide</a>. Once you get this resource, you will find nearly all you will need to know in <b>AI.DOC</b>.	</p><p>Once you start using FA2 as an AI Trigger viewer, you might well believe it's a natural thing to create your own AI Triggers in FA2 as well. I would strongly advise against it, at least not doing it to create your final AI Trigger code! There are a couple of reasons that I say this. One is that FA2 is prone to creating corrupt AI Triggers from time to time. Another is that FA2 writes Team code oddly, with their properties in an odd order, and includes properties that are unnecessary for mod AI. Yet another is that FA2 does not list all the available script actions. Instead, you should write your AI Triggers, Teams, Taksforces, and Scripts in text, using DeeZire's guide as a reference. You can always load your mod's AI code into FA2 to view it later, in the same manner as this tutorial tells you how to view the game's stock AI.	</p><p>Hopefully you will find this AI Trigger viewer technique to be valuable in helping you understand how the existing AI code works, so you can then begin writing your own.	</p></td><td class="edger" width="12">&nbsp;</td></tr><tr><td class="barbotl" width="12" height="15">&nbsp;</td><td class="barbot" width="*" height="15">&nbsp;</td><td class="barbotr" width="12" height="15">&nbsp;</td></tr><tr><td colspan="3" class="bg1" height="15">&nbsp;</td></tr></tbody></table><!--SECTION04-->