| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| 2 |
<html><head> |
| 3 |
<!-- |
| 4 |
---- (c) Copyright 2002-2007 by Lutz Sammer, Russell Smith |
| 5 |
|
| 6 |
---- This program is free software; you can redistribute it and/or modify |
| 7 |
---- it under the terms of the GNU General Public License as published by |
| 8 |
---- the Free Software Foundation; only version 2 of the License. |
| 9 |
---- |
| 10 |
---- This program is distributed in the hope that it will be useful, |
| 11 |
---- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
---- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
---- GNU General Public License for more details. |
| 14 |
---- |
| 15 |
---- You should have received a copy of the GNU General Public License |
| 16 |
---- along with this program; if not, write to the Free Software |
| 17 |
---- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 18 |
---- 02111-1307, USA. |
| 19 |
--> |
| 20 |
<title>Bos Wars Scripting API: UnitType</title> |
| 21 |
<meta http-equiv="Content-Type" content="text/html; CHARSET=iso-8859-1"> |
| 22 |
<link rel="stylesheet" type="text/css" href="scripts.css"> |
| 23 |
</head> |
| 24 |
<body> |
| 25 |
<h1>Bos Wars Scripting API: UnitType</h1> |
| 26 |
<hr> |
| 27 |
<a href="../index.html">Bos Wars</a> |
| 28 |
<a href="../faq.html">FAQ</a> |
| 29 |
<a href="ui.html">PREV</a> |
| 30 |
<a href="ai.html">NEXT</a> |
| 31 |
<a href="index.html">LUA Index</a> |
| 32 |
<hr> |
| 33 |
<a href="#DefineAnimations">DefineAnimations</a> |
| 34 |
<a href="#DefineVariables">DefineVariables</a> |
| 35 |
<a href="#DefineUnitType">DefineUnitType</a> |
| 36 |
<a href="#frame_numbers">frame numbers</a> |
| 37 |
<hr> |
| 38 |
<h2>Intro - Introduction to unit-type functions and variables</h2> |
| 39 |
|
| 40 |
Everything around the C UnitType structure. |
| 41 |
|
| 42 |
<h2>Conceptual</h2> |
| 43 |
|
| 44 |
<a name="frame_numbers"></a> |
| 45 |
<h3>Frame numbers and flipping</h3> |
| 46 |
|
| 47 |
<p>The engine draws units and missiles using frames that it loads from |
| 48 |
graphic files. The frames within a file all have the same size and |
| 49 |
are numbered from zero up. When a unit or a missile moves, the engine |
| 50 |
tries to automatically choose a frame that faces the correct direction.</p> |
| 51 |
|
| 52 |
<table border="1"> |
| 53 |
<caption>Example: unit with Flip = false, NumDirections = 8</caption> |
| 54 |
<colgroup span="1"> |
| 55 |
<colgroup span="8"> |
| 56 |
<tr> |
| 57 |
<th></th> |
| 58 |
<th colspan="8">All frames are in the graphic file.</th> |
| 59 |
</tr> |
| 60 |
<tr> |
| 61 |
<th></th> |
| 62 |
<th>N</th> |
| 63 |
<th>NE</th> |
| 64 |
<th>E</th> |
| 65 |
<th>SE</th> |
| 66 |
<th>S</th> |
| 67 |
<th>SW</th> |
| 68 |
<th>W</th> |
| 69 |
<th>NW</th> |
| 70 |
</tr> |
| 71 |
<tr> |
| 72 |
<th>still</th> |
| 73 |
<td>frame 0</td> |
| 74 |
<td>frame 1</td> |
| 75 |
<td>frame 2</td> |
| 76 |
<td>frame 3</td> |
| 77 |
<td>frame 4</td> |
| 78 |
<td>frame 5</td> |
| 79 |
<td>frame 6</td> |
| 80 |
<td>frame 7</td> |
| 81 |
</tr> |
| 82 |
<tr> |
| 83 |
<th>death step 1</th> |
| 84 |
<td>frame 8</td> |
| 85 |
<td>frame 9</td> |
| 86 |
<td>frame 10</td> |
| 87 |
<td>frame 11</td> |
| 88 |
<td>frame 12</td> |
| 89 |
<td>frame 13</td> |
| 90 |
<td>frame 14</td> |
| 91 |
<td>frame 15</td> |
| 92 |
</tr> |
| 93 |
<tr> |
| 94 |
<th>death step 2</th> |
| 95 |
<td>frame 16</td> |
| 96 |
<td>frame 17</td> |
| 97 |
<td>frame 18</td> |
| 98 |
<td>frame 19</td> |
| 99 |
<td>frame 20</td> |
| 100 |
<td>frame 21</td> |
| 101 |
<td>frame 22</td> |
| 102 |
<td>frame 23</td> |
| 103 |
</tr> |
| 104 |
</table> |
| 105 |
|
| 106 |
<pre class="lua"> |
| 107 |
<a href="#DefineAnimations">DefineAnimations</a>("animations-example", { |
| 108 |
Still = {"frame 0", …}, |
| 109 |
Death = {…, "frame 8", …, "frame 16", …}}) |
| 110 |
</pre> |
| 111 |
|
| 112 |
<p>To save effort and memory, the frames that face the west can be |
| 113 |
omitted from the graphic file. The engine will then generate them |
| 114 |
on demand by flipping the corresponding frames that face the east. |
| 115 |
To enable this feature, set <code>Flip = true</code> |
| 116 |
in <a href="#DefineUnitType">DefineUnitType</a> |
| 117 |
or <a href="magic.html#DefineMissileType">DefineMissileType</a>.</p> |
| 118 |
|
| 119 |
<p>Flipping changes the numbers of frames. Only the frames that |
| 120 |
are left in the graphic file have contiguous nonnegative numbers. |
| 121 |
Each flipped frame has a negative number that the engine computes as |
| 122 |
(-1 - <var>original number</var>).</p> |
| 123 |
|
| 124 |
<table border="1"> |
| 125 |
<caption>Example: unit or missile with Flip = true, NumDirections = 8</caption> |
| 126 |
<colgroup span="1"> |
| 127 |
<colgroup span="5"> |
| 128 |
<colgroup span="3" style="background: #eee"> |
| 129 |
<tr> |
| 130 |
<th></th> |
| 131 |
<th colspan="5">These frames are in the graphic file.</th> |
| 132 |
<th colspan="3">Not in the file. Flipped at run time.</th> |
| 133 |
</tr> |
| 134 |
<tr> |
| 135 |
<th></th> |
| 136 |
<th>N</th> |
| 137 |
<th>NE</th> |
| 138 |
<th>E</th> |
| 139 |
<th>SE</th> |
| 140 |
<th>S</th> |
| 141 |
<th>SW</th> |
| 142 |
<th>W</th> |
| 143 |
<th>NW</th> |
| 144 |
</tr> |
| 145 |
<tr> |
| 146 |
<th>still</th> |
| 147 |
<td>frame 0</td> |
| 148 |
<td>frame 1</td> |
| 149 |
<td>frame 2</td> |
| 150 |
<td>frame 3</td> |
| 151 |
<td>frame 4</td> |
| 152 |
<td>frame -4 flipped from 3</td> |
| 153 |
<td>frame -3 flipped from 2</td> |
| 154 |
<td>frame -2 flipped from 1</td> |
| 155 |
</tr> |
| 156 |
<tr> |
| 157 |
<th>death step 1</th> |
| 158 |
<td>frame 5</td> |
| 159 |
<td>frame 6</td> |
| 160 |
<td>frame 7</td> |
| 161 |
<td>frame 8</td> |
| 162 |
<td>frame 9</td> |
| 163 |
<td>frame -9 flipped from 8</td> |
| 164 |
<td>frame -8 flipped from 7</td> |
| 165 |
<td>frame -7 flipped from 6</td> |
| 166 |
</tr> |
| 167 |
<tr> |
| 168 |
<th>death step 2</th> |
| 169 |
<td>frame 10</td> |
| 170 |
<td>frame 11</td> |
| 171 |
<td>frame 12</td> |
| 172 |
<td>frame 13</td> |
| 173 |
<td>frame 14</td> |
| 174 |
<td>frame -14 flipped from 13</td> |
| 175 |
<td>frame -13 flipped from 12</td> |
| 176 |
<td>frame -12 flipped from 11</td> |
| 177 |
</tr> |
| 178 |
</table> |
| 179 |
|
| 180 |
<pre class="lua"> |
| 181 |
<a href="#DefineAnimations">DefineAnimations</a>("animations-example", { |
| 182 |
Still = {"frame 0", …}, |
| 183 |
Death = {…, "frame 5", …, "frame 10", …}}) |
| 184 |
</pre> |
| 185 |
|
| 186 |
<p>In missiles, the engine always numbers frames as if |
| 187 |
<a href="magic.html#DefineMissileType.Flip">Flip</a> were true.</p> |
| 188 |
|
| 189 |
<table border="1"> |
| 190 |
<caption>Example: missile with Flip = false, NumDirections = 8, Frames = 3*5</caption> |
| 191 |
<colgroup span="1"> |
| 192 |
<colgroup span="5"> |
| 193 |
<colgroup span="3" style="background: #eee"> |
| 194 |
<tr> |
| 195 |
<th></th> |
| 196 |
<th colspan="8">All frames are in the graphic file.</th> |
| 197 |
</tr> |
| 198 |
<tr> |
| 199 |
<th></th> |
| 200 |
<th>N</th> |
| 201 |
<th>NE</th> |
| 202 |
<th>E</th> |
| 203 |
<th>SE</th> |
| 204 |
<th>S</th> |
| 205 |
<th>SW</th> |
| 206 |
<th>W</th> |
| 207 |
<th>NW</th> |
| 208 |
</tr> |
| 209 |
<tr> |
| 210 |
<th>animation step 0</th> |
| 211 |
<td>frame 0</td> |
| 212 |
<td>frame 1</td> |
| 213 |
<td>frame 2</td> |
| 214 |
<td>frame 3</td> |
| 215 |
<td>frame 4</td> |
| 216 |
<td>frame -4</td> |
| 217 |
<td>frame -3</td> |
| 218 |
<td>frame -2</td> |
| 219 |
</tr> |
| 220 |
<tr> |
| 221 |
<th>animation step 1</th> |
| 222 |
<td>frame 5</td> |
| 223 |
<td>frame 6</td> |
| 224 |
<td>frame 7</td> |
| 225 |
<td>frame 8</td> |
| 226 |
<td>frame 9</td> |
| 227 |
<td>frame -9</td> |
| 228 |
<td>frame -8</td> |
| 229 |
<td>frame -7</td> |
| 230 |
</tr> |
| 231 |
<tr> |
| 232 |
<th>animation step 2</th> |
| 233 |
<td>frame 10</td> |
| 234 |
<td>frame 11</td> |
| 235 |
<td>frame 12</td> |
| 236 |
<td>frame 13</td> |
| 237 |
<td>frame 14</td> |
| 238 |
<td>frame -14</td> |
| 239 |
<td>frame -13</td> |
| 240 |
<td>frame -12</td> |
| 241 |
</tr> |
| 242 |
</table> |
| 243 |
|
| 244 |
<pre class="lua"><a href="magic.html#DefineMissileType">DefineMissileType</a>("missile-example", { |
| 245 |
Flip = false, |
| 246 |
NumDirections = 8, |
| 247 |
Frames = 3*5, -- Not 3*8, even though all frames are in the file. |
| 248 |
…}) |
| 249 |
</pre> |
| 250 |
|
| 251 |
<h2>Functions</h2> |
| 252 |
<a name="DefineAnimations"></a> |
| 253 |
<h3>DefineAnimations("ident-name", {type = {script}, ...})</h3> |
| 254 |
|
| 255 |
Define animations. |
| 256 |
|
| 257 |
<dl> |
| 258 |
<dt>"ident-name"</dt> |
| 259 |
<dd>Name of the animation to define. The name tells stratagus when to play the |
| 260 |
animation.</dd> |
| 261 |
<dt>type</dt> |
| 262 |
<dd>Supported types: |
| 263 |
<ul> |
| 264 |
<li>Still</li> |
| 265 |
<li>Move</li> |
| 266 |
<li>Attack</li> |
| 267 |
<li>Repair</li> |
| 268 |
<li>Train</li> |
| 269 |
<li>Build</li> |
| 270 |
<li>Harvest_ followed by the name of the harvested resource</li> |
| 271 |
<li>Death</li> |
| 272 |
</ul> |
| 273 |
</dd> |
| 274 |
<dt>script</dt> |
| 275 |
<dd> |
| 276 |
A script is a list of operations. Supported operations: |
| 277 |
<ul> |
| 278 |
<li>"frame X": Display this frame (see <a href="#frame_numbers">Frame numbers and flipping</a>) plus the direction offset</li> |
| 279 |
<li>"exact-frame X": Display this exact frame</li> |
| 280 |
<li>"wait X": Wait this number of cycles</li> |
| 281 |
<li>"random-wait X Y": Wait a random number of cycles between X and Y</li> |
| 282 |
<li>"sound X": Play this sound</li> |
| 283 |
<li>"random-sound X Y Z ...": Randomly play one of the listed sounds</li> |
| 284 |
<li>"attack": Attack</li> |
| 285 |
<li>"rotate X": Rotate unit, positive for clockwise, negative for counterclockwise</li> |
| 286 |
<li>"random-rotate X": Rotate in a random direction</li> |
| 287 |
<li>"move X": Move this number of pixels</li> |
| 288 |
<li>"unbreakable {begin|end}": Start or end an unbreakable section</li> |
| 289 |
<li>"label X": Create a label (used by goto and random-goto)</li> |
| 290 |
<li>"goto X": Goto a label position</li> |
| 291 |
<li>"random-goto X Y": Goto label Y with X percent probability</li> |
| 292 |
</dd> |
| 293 |
</dl> |
| 294 |
|
| 295 |
<h4>Example</h4> |
| 296 |
|
| 297 |
<pre class="lua"> |
| 298 |
DefineAnimations("animations-footman", { |
| 299 |
Still = {"frame 0", "wait 4", "frame 0", "wait 1",}, |
| 300 |
Move = {"unbreakable begin", "frame 0", "move 3", "wait 2", "frame 5", "move 3", "wait 1", |
| 301 |
"frame 5", "move 3", "wait 2", "frame 10", "move 2", "wait 1", |
| 302 |
"frame 10", "move 3", "wait 1", "frame 0", "move 2", "wait 1", |
| 303 |
"frame 0", "move 3", "wait 2", "frame 15", "move 3", "wait 1", |
| 304 |
"frame 15", "move 3", "wait 2", "frame 20", "move 2", "wait 1", |
| 305 |
"frame 20", "move 3", "wait 1", "frame 0", "move 2", "unbreakable end", "wait 1",}, |
| 306 |
Attack = {"unbreakable begin", "frame 25", "wait 3", "frame 30", "wait 3", "frame 35", "wait 3", |
| 307 |
"frame 40", "attack", "sound footman-attack", "wait 5", "frame 0", "wait 10", |
| 308 |
"frame 0", "unbreakable end", "wait 1",}, |
| 309 |
Death = {"unbreakable begin", "frame 45", "wait 3", "frame 50", "wait 3", "frame 55", "wait 100", |
| 310 |
"frame 55", "unbreakable end", "wait 1",} |
| 311 |
</pre> |
| 312 |
|
| 313 |
<a name="DefineVariables"></a> |
| 314 |
<h3>DefineVariables( "varname-1", {tag = value}, "varname-2", {tag = value}, ...)</h3> |
| 315 |
|
| 316 |
Define variable for unit. Spells could use these to determine who to hit, and units can be restricted too. |
| 317 |
Try to avoid using names with other meanings (nothing from unit definitions |
| 318 |
or spell condition definition). |
| 319 |
tag = value represent default value for UnitType. These values can be overwritten in UnitType definition. |
| 320 |
|
| 321 |
<dl> |
| 322 |
<dt>Value = number</dt> |
| 323 |
<dd>Initial value for the variable</dd> |
| 324 |
<dt>Max = number</dt> |
| 325 |
<dd>Max value for the number, assuming 0 is the min.</dd> |
| 326 |
<dt>Increase = number</dt> |
| 327 |
<dd>Number to add each simulated second if possible, negative value are possible.</dd> |
| 328 |
<dt>Enable = boolean</dt> |
| 329 |
<dd>if the variable is active by default. |
| 330 |
For example, Mana is active only for caster, but HP is available for every unit. |
| 331 |
When a variable is disabled, the Increase does not take effect, |
| 332 |
and the Value usually becomes invisible (but see |
| 333 |
<a href="config.html#DefineDecorations.ShowIfNotEnable">ShowIfNotEnable in DefineDecorations</a>). |
| 334 |
</dd> |
| 335 |
</dl> |
| 336 |
|
| 337 |
<h4 id="predefined-variables">Note</h4> |
| 338 |
Some variables are predefined and could be used with some restriction. You cannot modify their values, |
| 339 |
there are readonly (but no errors are generated), |
| 340 |
So see <a href="#DefineUnitType">DefineUnitType()</a> for initialise them |
| 341 |
(some variables are computed in play and be initialised). |
| 342 |
Also, the max value which is always greater than value, may have no sense or be equal at some player statistic.<br> |
| 343 |
The predefined values are : |
| 344 |
<dl> |
| 345 |
<dt id="variable.HitPoints">HitPoints</dt> |
| 346 |
<dd>Hp of the unit.</dd> |
| 347 |
<dt id="variable.Build">Build</dt> |
| 348 |
<dd>State of the construction in building.</dd> |
| 349 |
<dt id="variable.Mana">Mana</dt> |
| 350 |
<dd>Mana point of the unit.</dd> |
| 351 |
<dt id="variable.Transport">Transport</dt> |
| 352 |
<dd>Number of unit inside (for transporter only, no build inside).</dd> |
| 353 |
<dt id="variable.Training">Training</dt> |
| 354 |
<dd>Remaining cost to build the unit being training.</dd> |
| 355 |
<dt id="variable.GiveResource">GiveResource</dt> |
| 356 |
<dd>Resource that the unit gives ("resource-name" mine for exemple)</dd> |
| 357 |
<dt id="variable.Kill">Kill</dt> |
| 358 |
<dd>Number of unit killed by the unit.</dd> |
| 359 |
<dt id="variable.Armor">Armor</dt> |
| 360 |
<dd>Basic armor of the unit.</dd> |
| 361 |
<dt id="variable.SightRange">SightRange</dt> |
| 362 |
<dd>Sight range (in tiles) of the unit. |
| 363 |
See also <a href="config.html#Preference.ShowSightRange">Preference.ShowSightRange</a>.</dd> |
| 364 |
<dt id="variable.RadarRange">RadarRange</dt> |
| 365 |
<dd>Radar range of the unit.</dd> |
| 366 |
<dt id="variable.RadarJammerRange">RadarJammerRange</dt> |
| 367 |
<dd>Radar Jamming range of the unit.</dd> |
| 368 |
<dt id="variable.AttackRange">AttackRange</dt> |
| 369 |
<dd>Attack range of the unit. |
| 370 |
See also <a href="config.html#Preference.ShowAttackRange">Preference.ShowAttackRange</a>.</dd> |
| 371 |
<dt id="variable.PiercingDamage">PiercingDamage</dt> |
| 372 |
<dd>piercing damage of the unit. FIXME calculations?</dd> |
| 373 |
<dt id="variable.BasicDamage">BasicDamage</dt> |
| 374 |
<dd>Basic damage of the unit. FIXME calculations?</dd> |
| 375 |
<dt id="variable.PosX">PosX</dt> |
| 376 |
<dd>X position of the unit. Max is the Map size.</dd> |
| 377 |
<dt id="variable.PosY">PosY</dt> |
| 378 |
<dd>Y position of the unit. Max is the Map size.</dd> |
| 379 |
<dt id="variable.AutoRepairRange">AutoRepairRange</dt> |
| 380 |
<dd>Range to check for unit to repair. (for unit which can repair)<dd> |
| 381 |
<dt id="variable.Slot">Slot</dt> |
| 382 |
<dd>Unique number that identifies the unit (begin at 0). Max is the last valid slot number.</dd> |
| 383 |
</dl> |
| 384 |
|
| 385 |
<h4>Example</h4> |
| 386 |
|
| 387 |
<pre class="lua"> |
| 388 |
DefineVariable("cooldown", {Value = 0, Increase = -1, Max = 50, Enable = false}) |
| 389 |
</pre> |
| 390 |
|
| 391 |
<a name="DefineUnitType"></a> |
| 392 |
<h3>DefineUnitType( "ident", { tag1 = value1, tag2 = value2, ...})</h3> |
| 393 |
|
| 394 |
Define the unit types in game. A lot of the data in this struct used to be |
| 395 |
based on the UDTA section of puds, with unit statistics, but it is now a lot |
| 396 |
bigger and more configurable. |
| 397 |
|
| 398 |
<dl> |
| 399 |
<dt>ident</dt> |
| 400 |
<dd>The unit-type unique identifier. It is used to reference unit-types in |
| 401 |
game. F.E: "unit-knight", "unit-gold-mine". Please use all-lowercase names |
| 402 |
prefixed with unit-, it is easier to read this way. |
| 403 |
</dd> |
| 404 |
</dl> |
| 405 |
Possible tags: |
| 406 |
<dl> |
| 407 |
<dt>Name = "show-name"</dt> |
| 408 |
<dd>The unit-type name shown in the game. F.E: "Knight", "Gold Mine". |
| 409 |
If the name is too long, it is split at space. |
| 410 |
</dd> |
| 411 |
<dt id="DefineUnitType.Image">Image = {"file", filename, "size", {x, y}}</dt> |
| 412 |
<dd>Defines the graphics used to display the unit-type in game.</dd> |
| 413 |
<dt>Offset = {x, y}</dt> |
| 414 |
<dd>Defines the offset for the graphics in pixels used to display the unit-type</dd> |
| 415 |
<dt>Shadow = {tag, value, ...}</dt> |
| 416 |
<dd>Defines the Parameters for the shadow the unit is casting in the game</dd> |
| 417 |
<dd>Possible tags: |
| 418 |
<dl> |
| 419 |
<dt>"file", filename</dt> |
| 420 |
<dd>Defines the graphics used to display the shadow of the unit-type</dd> |
| 421 |
<dt>"size", {width, height}</dt> |
| 422 |
<dd>Defines the size of the graphics in pixels used to display the shadow of the unit-type</dd> |
| 423 |
<dt>"offset", {x, y}</dt> |
| 424 |
<dd>Defines the offset of the graphics in pixels used to display the shadow of the unit-type. Note that this is relative to the unit graphics including its own offset</dd> |
| 425 |
</dl></dd> |
| 426 |
<dt>Flip = boolean</dt> |
| 427 |
<dd>Flip = false (the default) means the unit type has separate frames |
| 428 |
for all directions. The graphic file defined with the |
| 429 |
<a href="#DefineUnitType.Image">Image</a> tag must thus have |
| 430 |
<a href="#DefineUnitType.NumDirections">NumDirections</a> frames |
| 431 |
for each animation posture.</dd> |
| 432 |
<dd>Flip = true means the frames facing west are not included in the |
| 433 |
graphic file because they are mirror images of the frames facing east. |
| 434 |
The file must then have only <var>NumDirections</var> / 2 + 1 frames |
| 435 |
for each animation posture. |
| 436 |
Please see <a href="#frame_numbers">Frame numbers and flipping</a> |
| 437 |
for details.</dd> |
| 438 |
<dt>DrawLevel = number</dt> |
| 439 |
<dd>This is used when sorting units and missiles for drawing. Units with a higher draw |
| 440 |
order will always be on top of units with lower draw order. Units are also sorted from |
| 441 |
top to the bottom of the screen. |
| 442 |
</dd> |
| 443 |
<dt>Animations = "animation-type"</dt> |
| 444 |
<dd>Identifier to reference the animation sequences (scripts) for the |
| 445 |
unit-type. F.E. "animations-knight", "animations-gold-mine". |
| 446 |
See <a href="#DefineAnimations">DefineAnimations</a>. |
| 447 |
</dd> |
| 448 |
<dt>TileSize = {x, y}</dt> |
| 449 |
<dd>Define the unit-type size in tiles. NOTE: currently only buildings could |
| 450 |
be bigger than one tile. |
| 451 |
</dd> |
| 452 |
<dt>BoxSize = {width, height}</dt> |
| 453 |
<dd>Define the size of the unit selection box. This is drawn centered around |
| 454 |
the unit and most of the time it is equal to the tile size of the unit* the size |
| 455 |
of a terrain tile, for an almost perfect fit. |
| 456 |
</dd> |
| 457 |
<dt id="DefineUnitType.NumDirections">NumDirections = number</dt> |
| 458 |
<dd>Define the number of directions a unit can face. Default 1 for buildings and 8 |
| 459 |
for units. Can be adjusted from the default. |
| 460 |
Useful for cannons or turrets that are considered buildings but must |
| 461 |
aim towards the enemy. |
| 462 |
</dd> |
| 463 |
<dt>IsNotSelectable = boolean</dt> |
| 464 |
<dd>set whether the unit is able to be selected or not.</dd> |
| 465 |
<dt>Decoration = boolean</dt> |
| 466 |
<dd>set whether the unit is a decoration (act like a tile) or not.</dd> |
| 467 |
<dt>Indestructible = boolean</dt> |
| 468 |
<dd>set whether the unit is indestructible not.</dd> |
| 469 |
<dt>NeutralMinimapColor = {r, g, b}</dt> |
| 470 |
<dd>sets the color of a unit when belonging to the neutral player. F.E. '(0 0 0) for a |
| 471 |
black oil patch. |
| 472 |
</dd> |
| 473 |
<dt>Icon = "Icon-name"</dt> |
| 474 |
<dd>Identifier to reference the icon shown in game for this unit-type. |
| 475 |
F.E. "icon-knight", "icon-gold-mine". |
| 476 |
</dd> |
| 477 |
<dt>Sounds = {event, "sound-name", ...}</dt> |
| 478 |
<dd>The following events are supported: |
| 479 |
<dl><dd> |
| 480 |
<ul> |
| 481 |
<li>"selected": Happens when the unit is selected. |
| 482 |
<li>"acknowledge": Happens when the unit received an order. |
| 483 |
<li>"ready": Happens when the unit finished training (and it's ready) |
| 484 |
<li>"help": Happens when the unit is under attack. |
| 485 |
<li>"dead": Happens when the unit is killed. |
| 486 |
</ul></dd> |
| 487 |
</dl></dd> |
| 488 |
<dd> |
| 489 |
You can use the same help or ready sound for all units if you want generic |
| 490 |
"Your unit is under attack", "Some unit was trained" sounds. The actual sound |
| 491 |
files are not declared here. Please see the documentation on <a href="sound.html#MakeSound">sounds</a> |
| 492 |
</dd> |
| 493 |
<dt>CanGroundAttack = boolean</dt> |
| 494 |
<dd>Whether the unit can attack a place where there is no known enemy unit. |
| 495 |
</dd> |
| 496 |
<dt id="DefineUnitType.CanAttack">CanAttack = boolean</dt> |
| 497 |
<dd>Whether the unit can attack at all. |
| 498 |
</dd> |
| 499 |
<dt id="DefineUnitType.CanTargetLand">CanTargetLand = boolean<dt> |
| 500 |
<dd>Whether the unit can attack land units (<a href="#DefineUnitType.Type">Type</a> = "land"). |
| 501 |
Actually, it can attack naval units too, if they are explicitly allowed on land |
| 502 |
(see <a href="#DefineUnitType.AllowTerrainLand">AllowTerrainLand</a>). |
| 503 |
It does not matter whether the targeted unit currently is on land. |
| 504 |
</dd> |
| 505 |
<dt id="DefineUnitType.CanTargetSea">CanTargetSea = boolean<dt> |
| 506 |
<dd>Whether the unit can attack naval units (<a href="#DefineUnitType.Type">Type</a> = "naval"). |
| 507 |
Actually, it can attack land units too, if they are explicitly allowed in some type of water |
| 508 |
(see <a href="#DefineUnitType.AllowTerrainShallowWater">AllowTerrainShallowWater</a> |
| 509 |
and <a href="#DefineUnitType.AllowTerrainDeepWater">AllowTerrainDeepWater</a>). |
| 510 |
It does not matter whether the targeted unit currently is in water. |
| 511 |
</dd> |
| 512 |
<dt id="DefineUnitType.CanTargetAir">CanTargetAir = boolean<dt> |
| 513 |
<dd>Whether the unit can attack flying units (<a href="#DefineUnitType.Type">Type</a> = "fly"). |
| 514 |
</dd> |
| 515 |
<dt>MaxMana = number</dt> |
| 516 |
<dd>Maximum mana of the unit. When a unit of this type is created, it |
| 517 |
initially has only 33% of this mana.<br> |
| 518 |
MaxMana = <var>number</var> is equivalent to |
| 519 |
<a href="#DefineUnitType.Mana">Mana</a> = {Initial = <var>number</var> * 33 / 100, |
| 520 |
Max = <var>number</var>, Increase = 1, Enable = true}. |
| 521 |
</dd> |
| 522 |
<dt>MaxAttackRange = number</dt> |
| 523 |
<dd>Attack range (in tiles) of this unit. Use 1 for melee units.<br> |
| 524 |
This is the same as <a href="#variable.AttackRange">the predefined AttackRange variable</a>. |
| 525 |
You can set it using either name. |
| 526 |
</dd> |
| 527 |
<dt>MinAttackRange = number</dt> |
| 528 |
<dd>Minimum attack range (in tiles) of this unit. This is useful for siege units you |
| 529 |
want to make vulnerable to close range attacks. |
| 530 |
</dd> |
| 531 |
<dt id="DefineUnitType.RegenerationRate">RegenerationRate = number</dt> |
| 532 |
<dd>Amount of HP a unit gains per simulated second.<br> |
| 533 |
RegenerationRate = <var>number</var> is equivalent to |
| 534 |
<a href="#DefineUnitType.HitPoints">HitPoints</a> = {Increase = <var>number</var>}. |
| 535 |
</dd> |
| 536 |
<dt>EnergyValue = number</dt> |
| 537 |
<dd>The energy cost of building or training a unit of this type. |
| 538 |
This also affects how much energy can be harvested from the unit. |
| 539 |
</dd> |
| 540 |
<dt>MagmaValue = number</dt> |
| 541 |
<dd>The magma cost of building or training a unit of this type. |
| 542 |
This also affects how much magma can be harvested from the unit. |
| 543 |
</dd> |
| 544 |
<dt>MaxEnergyUtilizationRate = number</dt> |
| 545 |
<dd>How much energy the unit can consume per simulated second, |
| 546 |
typically when it is training or building something. |
| 547 |
If you make this number smaller, then training will take longer. |
| 548 |
</dd> |
| 549 |
<dt>MaxMagmaUtilizationRate = number</dt> |
| 550 |
<dd>How much magma the unit can consume per simulated second. |
| 551 |
</dd> |
| 552 |
<dt id="DefineUnitType.EnergyProductionRate">EnergyProductionRate = number</dt> |
| 553 |
<dd>How much energy the unit produces per simulated second, just by existing. |
| 554 |
This does not include any energy it can produce by harvesting other units. |
| 555 |
</dd> |
| 556 |
<dt id="DefineUnitType.MagmaProductionRate">MagmaProductionRate = number</dt> |
| 557 |
<dd>How much magma the unit produces per simulated second, just by existing. |
| 558 |
</dd> |
| 559 |
<dt>EnergyStorageCapacity = number</dt> |
| 560 |
<dd>How much more energy the player can store by having this unit. |
| 561 |
The engine only keeps track of the total amount of stored energy per player, |
| 562 |
and not exactly where it has been stored. |
| 563 |
</dd> |
| 564 |
<dt>MagmaStorageCapacity = number</dt> |
| 565 |
<dd>How much more magma the player can store by having this unit. |
| 566 |
</dd> |
| 567 |
<dt>RightMouseAction = "none" or "move" or "attack" or "harvest" |
| 568 |
or "spell-cast"</dt> |
| 569 |
<dd><dl> |
| 570 |
<dt>"none"</dt> |
| 571 |
<dd>Do nothing.</dd> |
| 572 |
<dt>"move"</dt> |
| 573 |
<dd>Right clicking defaults to move. This should be used for unit's that can't attack. |
| 574 |
</dd> |
| 575 |
<dt>"attack"</dt> |
| 576 |
<dd>Right clicking defaults to attack. This should be used for most combat units. |
| 577 |
</dd> |
| 578 |
<dt>"harvest"</dt> |
| 579 |
<dd>This should be used for resource gathering units. It will return goods when |
| 580 |
on a deposit and mine when on a resource. |
| 581 |
</dd> |
| 582 |
<dt>"spell-cast"</dt> |
| 583 |
<dd>This is an ugly hack for demolishing units. The unit will cast it's first |
| 584 |
known spell(in order of spell definition) instead of attacking a hostile unit. |
| 585 |
</dd> |
| 586 |
</dl></dd> |
| 587 |
<dt id="DefineUnitType.Construction">Construction = construction-name</dt> |
| 588 |
<dd>How to draw units of this type while they are being built. |
| 589 |
See <a href="game.html#DefineConstruction">DefineConstruction</a>. |
| 590 |
</dd> |
| 591 |
<dt id="DefineUnitType.ProductionEfficiency">ProductionEfficiency = number</dt> |
| 592 |
<dd>Efficiency percentage for energy and magma production |
| 593 |
of units built on top of this one, using an |
| 594 |
<a href="#DefineUnitType.BuildingRules.ontop">"ontop" building rule</a>. |
| 595 |
If the unit type that has a ProductionEfficiency is itself producing |
| 596 |
energy (<a href="#DefineUnitType.EnergyProductionRate">EnergyProductionRate</a>) |
| 597 |
or magma (<a href="#DefineUnitType.EnergyProductionRate">MagmaProductionRate</a>), |
| 598 |
the ProductionEfficiency does not affect those. |
| 599 |
</dd> |
| 600 |
<dt id="DefineUnitType.CanHarvestFrom">CanHarvestFrom = boolean</dt> |
| 601 |
<dd>This is a flag for harvestable resource buildings. |
| 602 |
</dd> |
| 603 |
<dt id="DefineUnitType.Vanishes">Vanishes = boolean</dt> |
| 604 |
<dd>True means the unit is <a href="#DefineUnitType.Corpse">a corpse or a destroyed building</a>. |
| 605 |
It cannot be selected, targeted, or killed again; |
| 606 |
it just lies there until its animation ends, and then it vanishes. |
| 607 |
</dd> |
| 608 |
<dt id="DefineUnitType.Building">Building = boolean</dt> |
| 609 |
<dd>Unit is a building, and immobile. Available as a spell target check. |
| 610 |
</dd> |
| 611 |
<dt id="DefineUnitType.Type">Type = "land" or "fly" or "naval"</dt> |
| 612 |
<dd>Whether the unit stands/walks/rolls on dry land, flies in the air, |
| 613 |
or sails/dives in the water. This affects several things: |
| 614 |
<ul> |
| 615 |
<li>Flying units cannot be blocked by land or naval units, and vice versa.</li> |
| 616 |
<li>Flying units ignore the movement costs defined in map patches. |
| 617 |
They can fly over swamps as fast as over roads.</li> |
| 618 |
<li>By default, land units cannot move in the water, |
| 619 |
and naval units cannot move on the land, but flying units can move anywhere. |
| 620 |
However, you can override these defaults with |
| 621 |
<a href="#DefineUnitType.AllowTerrainLand">AllowTerrainLand</a>, |
| 622 |
<a href="#DefineUnitType.AllowTerrainCoast">AllowTerrainCoast</a>, |
| 623 |
<a href="#DefineUnitType.AllowTerrainShallowWater">AllowTerrainShallowWater</a>, and |
| 624 |
<a href="#DefineUnitType.AllowTerrainDeepWater">AllowTerrainDeepWater</a>.</li> |
| 625 |
<li>Only land units can board <a href="#DefineUnitType.CanTransport">transporters</a>. |
| 626 |
(FIXME: allow different restrictions for different transporter types.)</li> |
| 627 |
<li>Land units may be unable to attack naval units, or vice versa. |
| 628 |
See <a href="#DefineUnitType.CanTargetLand">CanTargetLand</a>, |
| 629 |
<a href="#DefineUnitType.CanTargetSea">CanTargetSea</a>, |
| 630 |
and <a href="#DefineUnitType.CanTargetAir">CanTargetAir</a>.</li> |
| 631 |
<li>When selecting units with a rectangle, the player can |
| 632 |
press Alt to select only land and naval units, |
| 633 |
or Control to select only flying units.</li> |
| 634 |
<li><a href="magic.html#DefineSpell.action.demolish">The spell action "demolish"</a> |
| 635 |
does not hit flying units.</li> |
| 636 |
</ul></dd> |
| 637 |
<dt>VisibleUnderFog = boolean</dt> |
| 638 |
<dd>Unit remains visible under fog of war. In most games this is true for and only for |
| 639 |
<a href="#DefineUnitType.Building">buildings</a>. |
| 640 |
</dd> |
| 641 |
<dt id="DefineUnitType.ShoreBuilding">ShoreBuilding = boolean</dt> |
| 642 |
<dd>Unit is a shore building, and immobile. This is used for those unique buildings |
| 643 |
that have to be built on sea and have at least one point on coast. |
| 644 |
This restriction is like <a href="#DefineUnitType.BuildingRules">BuildingRules</a> = |
| 645 |
{{<a href="#DefineUnitType.BuildingRules.terrain">"terrain"</a>, {CountCoast=true, Min=1}}}, |
| 646 |
but ShoreBuilding also affects other things: |
| 647 |
see <a href="#DefineUnitType.AllowTerrainCoast">AllowTerrainCoast</a>. |
| 648 |
</dd> |
| 649 |
<dt id="DefineUnitType.AllowTerrainLand">AllowTerrainLand = boolean</dt> |
| 650 |
<dd>Explicitly allow or forbid moving the unit to dry land. |
| 651 |
By default, only <a href="#DefineUnitType.Type">air units and land units</a> are allowed there. |
| 652 |
This also affects whether the unit can be targeted as a land unit |
| 653 |
(see <a href="#DefineUnitType.CanTargetLand">CanTargetLand</a>). |
| 654 |
</dd> |
| 655 |
<dt id="DefineUnitType.AllowTerrainCoast">AllowTerrainCoast = boolean</dt> |
| 656 |
<dd>Explicitly allow or forbid moving the unit to coasts. |
| 657 |
By default, only air units, naval <a href="#DefineUnitType.CanTransport">transporter</a> units, |
| 658 |
and <a href="#DefineUnitType.ShoreBuilding">shore buildings</a> are allowed there. |
| 659 |
This does not affect which units can target the unit. |
| 660 |
</dd> |
| 661 |
<dt id="DefineUnitType.AllowTerrainShallowWater">AllowTerrainShallowWater = boolean</dt> |
| 662 |
<dd>Explicitly allow or forbid moving the unit to shallow water. |
| 663 |
By default, only air units and naval units are allowed there. |
| 664 |
This also affects whether the unit can be targeted as a naval unit |
| 665 |
(see <a href="#DefineUnitType.CanTargetSea">CanTargetSea</a>). |
| 666 |
</dd> |
| 667 |
<dt id="DefineUnitType.AllowTerrainDeepWater">AllowTerrainDeepWater = boolean</dt> |
| 668 |
<dd>Explicitly allow or forbid moving the unit to deep water. |
| 669 |
By default, only air units and naval units are allowed there. |
| 670 |
This also affects whether the unit can be targeted as a naval unit |
| 671 |
(see <a href="#DefineUnitType.CanTargetSea">CanTargetSea</a>). |
| 672 |
</dd> |
| 673 |
<dt id="DefineUnitType.BuildingRules">BuildingRules = { { "distance", { Distance = 3, DistanceType = ">", Type = "unit-gold-mine"}}} |
| 674 |
<dd>BuildingRules allows you to specify a list of restrictions to make when building. The |
| 675 |
list is in nested tables, the inter list is and'd together, and or'd with the other lists. See |
| 676 |
the example for details. |
| 677 |
<dl> |
| 678 |
<dt>"distance"</dt> |
| 679 |
<dd>Specifies a distance constraint. |
| 680 |
<dl> |
| 681 |
<dt>Distance</dt> |
| 682 |
<dd>The distance in tiles to measure</dd> |
| 683 |
<dt>DistanceType</dt> |
| 684 |
<dd><, >, <=, >=, ==, !=</dd> |
| 685 |
<dt>Type</dt> |
| 686 |
<dd>The type of the unit that this distance restriction applies to</dd> |
| 687 |
<dt>Except <b>NOT IMPLEMENTED</b></dt> |
| 688 |
<dd>boolen, #t implies all units, except this type must be</dd> |
| 689 |
</dl></dd> |
| 690 |
<dt>"addon"</dt> |
| 691 |
<dd>Specifies an addon to an existing building. |
| 692 |
<dl> |
| 693 |
<dt>OffsetX</dt> |
| 694 |
<dd>Offset from the top left of the parent building that this unit must be placed. |
| 695 |
eg, -2 would left two of the building. (you need to consider the size of the |
| 696 |
parent building)</dd> |
| 697 |
<dt>OffsetY</dt> |
| 698 |
<dd>As with OffsetX, except in the Y direction</dd> |
| 699 |
<dt>Type</dt> |
| 700 |
<dd>Type of the unit that this unit is an addon too</dd> |
| 701 |
</dl></dd> |
| 702 |
<dt id="DefineUnitType.BuildingRules.ontop">"ontop"</dt> |
| 703 |
<dd>Building must be built on top of another building type.<br> |
| 704 |
NOTE: the engine may not be able to guess the correct parent if the rules are complex enough. |
| 705 |
For example, if you define that unit-magmapump can be built |
| 706 |
on top of either unit-hotspot and unit-weakhotspot, |
| 707 |
and building the pump removes the hot spot but destroying the pump restores it, |
| 708 |
then the engine does not remember which type of hot spot it was. |
| 709 |
This matters especially if the possible underlying unit types have different |
| 710 |
<a href="#DefineUnitType.ProductionEfficiency">ProductionEfficiency</a> values, |
| 711 |
but in that case, removing the underlying units during building seems unusual anyway. |
| 712 |
<dl> |
| 713 |
<dt>Type</dt> |
| 714 |
<dd>The unit-type that we are to build on top of</dd> |
| 715 |
<dt>ReplaceOnDie</dt> |
| 716 |
<dd>boolean, true if you want the original unit to be replaced when this unit dies</dd> |
| 717 |
<dt>ReplaceOnBuild</dt> |
| 718 |
<dd>boolean, true if you want to remove the old unit underneath when you build this one</dd> |
| 719 |
</dl></dd> |
| 720 |
<dt id="DefineUnitType.BuildingRules.terrain">"terrain"</dt> |
| 721 |
<dd>Implement a tile restriction, unit must be placed on certain types of tiles. |
| 722 |
<dl> |
| 723 |
<dt>CountLand = boolean</dt> |
| 724 |
<dt>CountCoast = boolean</dt> |
| 725 |
<dt>CountShallowWater = boolean</dt> |
| 726 |
<dt>CountDeepWater = boolean</dt> |
| 727 |
<dd>Which types of terrain tiles are being counted.</dd> |
| 728 |
<dt>Min = number</dt> |
| 729 |
<dd>Smallest permitted number of such terrain tiles under the unit. |
| 730 |
If omitted, there is no minimum limit.</dd> |
| 731 |
<dt>Max = number</dt> |
| 732 |
<dd>Greatest permitted number of such terrain tiles under the unit. |
| 733 |
If omitted, there is no maximum limit.</dd> |
| 734 |
</dl></dd> |
| 735 |
<dt>"direction" <b>NOT IMPLEMENTED</b></dt> |
| 736 |
<dd><dl> |
| 737 |
<dt>Direction</dt> |
| 738 |
<dd>A bitmask in int format for the directions to build. (bits not specified yet)</dd> |
| 739 |
</dl></dd> |
| 740 |
</dl> |
| 741 |
<dt>Coward = boolean</dt> |
| 742 |
<dd>Unit will not attack on sight, and will run away instead of retaliating. |
| 743 |
Use this for units that can't attack or are next to useless in combat (like |
| 744 |
resource workers) Available as a spell target check. |
| 745 |
</dd> |
| 746 |
<dt>Harvester = boolean</dt> |
| 747 |
<dd>Whether this unit can harvest resources from units that have |
| 748 |
<a href="#DefineUnitType.CanHarvestFrom">CanHarvestFrom</a> = true. |
| 749 |
</dd> |
| 750 |
<dt>Neutral = boolean</dt> |
| 751 |
<dd>The unit must always be owned by the neutral player. |
| 752 |
The map editor displays the neutral unit types in a separate list. |
| 753 |
Neutral unit types for plants and minerals should have |
| 754 |
<a href="#DefineUnitType.Building">Building</a> = true so that |
| 755 |
the corpses of such units cannot fuel spells; but unlike other buildings, |
| 756 |
neutral units can be placed on map fields that do not allow buildings. |
| 757 |
</dd> |
| 758 |
<dt>CanCastSpell = {spell-name, ...}</dt> |
| 759 |
<dd>This is used to determine what spells can this unit cast. It is followed by a |
| 760 |
list of spell names. Spells have to be declared already. Since some spells also |
| 761 |
rely on units being defined this can lead to a chicken and egg problem. It's |
| 762 |
better to declare an unit type in advance with just DefineUnitType( "unit-whatever", {}). |
| 763 |
Please see the documentation on spells. F.E. CanCastSpell = {"spell-healing", "spell-exorcism"} |
| 764 |
</dd> |
| 765 |
<dt>AutoCastActive = {spell-name, ...}</dt> |
| 766 |
<dd>Lists the spells that the unit casts automatically. |
| 767 |
The exact conditions for autocast must be defined under |
| 768 |
<a href="magic.html#DefineSpell.autocast">"autocast" in DefineSpell</a>. |
| 769 |
The player can switch autocast on and off for individual units |
| 770 |
during the game but cannot change the default for new units. |
| 771 |
AI players ignore this setting because they have their own |
| 772 |
<a href="magic.html#DefineSpell.ai-cast">"ai-cast" section in DefineSpell</a> |
| 773 |
and always enable autocast if possible. |
| 774 |
</dd> |
| 775 |
<dt id="DefineUnitType.RepairRange">RepairRange = number</dt> |
| 776 |
<dd>Range that a unit can repair from, eg. RepairRange = 1. |
| 777 |
</dd> |
| 778 |
<dt>RepairHp = number</dt> |
| 779 |
<dd>Defines the amount of hp a unit gain for each repair animation. Units can only be |
| 780 |
repaired if this value is non-zero. |
| 781 |
F.E.: RepairHp = 4. |
| 782 |
</dd> |
| 783 |
<dt id="DefineUnitType.ComputerReactionRange">ComputerReactionRange = number</dt> |
| 784 |
<dd>The reaction range for units of AI players. Each unit can |
| 785 |
automatically attack enemy units that enter its reaction range. |
| 786 |
See also <a href="config.html#Preference.ShowReactionRange">Preference.ShowReactionRange</a>. |
| 787 |
</dd> |
| 788 |
<dt id="DefineUnitType.PersonReactionRange">PersonReactionRange = number</dt> |
| 789 |
<dd>The reaction range for units of human players. Each unit can |
| 790 |
automatically attack enemy units that enter its reaction range. |
| 791 |
See also <a href="config.html#Preference.ShowReactionRange">Preference.ShowReactionRange</a>. |
| 792 |
</dd> |
| 793 |
<dt>Priority = number</dt> |
| 794 |
<dd>This is the ai priority level. High damage low-hp units for instancce should have |
| 795 |
higher priorities than say a peasant. It can be safely ignored. |
| 796 |
</dd> |
| 797 |
<dt>AnnoyComputerFactor = number</dt> |
| 798 |
<dd>This is another ai priority level. This is not used, but included in wc2 data. Maybe |
| 799 |
it should be used to attack resource buildings first? You can safely ignore it. |
| 800 |
</dd> |
| 801 |
<dt>DecayRate = number</dt> |
| 802 |
<dd>This is the unit's decay rate, in 1/6 seconds. It should be really really really changed to |
| 803 |
cycles. If you set this the unit will die by itself after a while. Don't use it for spells, |
| 804 |
spells will override this with their own ttl setting. |
| 805 |
</dd> |
| 806 |
<dt>BurnPercent = number</dt> |
| 807 |
<dd>The unit will start burning when it has less health than this, in percents. |
| 808 |
</dd> |
| 809 |
<dt>BurnDamageRate = number</dt> |
| 810 |
<dd>The rate at which the unit will get damaged. The period is the same |
| 811 |
as with <a href="#DefineUnitType.RegenerationRate">regeneration</a>. |
| 812 |
</dd> |
| 813 |
<dt>Points = number</dt> |
| 814 |
<dd>This is the score value of an unit. Used for the final score. |
| 815 |
</dd> |
| 816 |
<dt>Missile = missile-name</dt> |
| 817 |
<dd>Some units fire by throwing missiles, this is the missile thrown. You can use it for |
| 818 |
close range units as well, but I can't really see the point. |
| 819 |
</dd> |
| 820 |
<dt id="DefineUnitType.Corpse">Corpse = {unittype-name, number}</dt> |
| 821 |
<dd>This is the corpse of the unit. When the unit dies and passes through it's |
| 822 |
death animation it turns into this. It's a list of an unittype-name and a a corpse frame |
| 823 |
number. The unit type to which refers should have <a href="#DefineUnitType.Vanishes">Vanishes</a> = true. |
| 824 |
As you can see in <a href="#DefineAnimations">DefineAnimations()</a>, |
| 825 |
an animation is composed out of several script frames, this is the frame to |
| 826 |
start the script from. FE: Corpse = {"unit-dead-body", 0} |
| 827 |
</dd> |
| 828 |
<dt>ExplodeWhenKilled = missile-name</dt> |
| 829 |
<dd>Sets unit to explode when killed, syntax is followed by the missile to use. |
| 830 |
eg. ExplodeWhenKilled "missile-explosion" |
| 831 |
</dd> |
| 832 |
<dt>DeathExplosion = explosion-function</dt> |
| 833 |
<dd>Set the lua function that will create the particles of the explosion. |
| 834 |
</dd> |
| 835 |
<dt>AttackFromTransporter = boolean</dt> |
| 836 |
<dd>Gives units with range the ability to attack from within a transporter such as a building. |
| 837 |
These can act like amoured personnel carriers or bunkers |
| 838 |
</dd> |
| 839 |
<dt id="DefineUnitType.CanTransport">CanTransport = boolean</dt> |
| 840 |
<dd>Unit is a transporter, you can place <a href="#DefineUnitType.Organic">organic</a> |
| 841 |
<a href="#DefineUnitType.Type">land</a> units inside. |
| 842 |
(FIXME: allow different restrictions for different transporter types.) |
| 843 |
</dd> |
| 844 |
<dt>MaxOnBoard = number</dt> |
| 845 |
<dd>This is only used for transporters, It's the maximum allowed on board. Curently |
| 846 |
you can't have more that 6, or you won't get any buttons for the rest. |
| 847 |
</dd> |
| 848 |
<dt id="DefineUnitType.Organic">Organic = boolean</dt> |
| 849 |
<dd>Only organic units can be carried in <a href="#DefineUnitType.CanTransport">transporters</a>. |
| 850 |
<a href="magic.html#DefineSpell.conditions">Spell conditions in DefineSpell</a> |
| 851 |
can check the Organic flag, so that you can prevent healing spells |
| 852 |
from affecting machines. |
| 853 |
</dd> |
| 854 |
<dt>Revealer = boolean</dt> |
| 855 |
<dd>This is a special flag to use for reveal map spells. A reveal map smell is |
| 856 |
in fact a summon spell with an infinite range, that summons an unit with the |
| 857 |
revealer flag. Revealer are summoned and marked removed, but they still keep |
| 858 |
their sight. This way a revealer unit can't be attacked, won't show on the minimap |
| 859 |
and can't be interacted with. Please see the documentation on spells.</dd> |
| 860 |
<dt>SelectableByRectangle = boolean</dt> |
| 861 |
<dd>Most units should have this flag. When false the unit will only get selected |
| 862 |
alone, use this for buildings. Enemy units are never selectable by rectangle. |
| 863 |
</dd> |
| 864 |
<dt id="DefineUnitType.Mana"><a href="#variable.Mana">Mana</a> = number or boolean or {tag = value, ...}</dt> |
| 865 |
<dt><a href="#variable.SightRange">SightRange</a> = number or boolean or {tag = value, ...}</dt> |
| 866 |
<dt><a href="#variable.RadarRange">RadarRange</a> = number or boolean or {tag = value, ...}</dt> |
| 867 |
<dt><a href="#variable.RadarJammerRange">RadarJammerRange</a> = number or boolean or {tag = value, ...}</dt> |
| 868 |
<dt><a href="#variable.Armor">Armor</a> = number or boolean or {tag = value, ...}</dt> |
| 869 |
<dt><a href="#variable.BasicDamage">BasicDamage</a> = number or boolean or {tag = value, ...}</dt> |
| 870 |
<dt><a href="#variable.PiercingDamage">PiercingDamage</a> = number or boolean or {tag = value, ...}</dt> |
| 871 |
<dt id="DefineUnitType.HitPoints"><a href="#variable.HitPoints">HitPoints</a> = number or boolean or {tag = value, ...}</dt> |
| 872 |
<dt><a href="#variable.AutoRepairRange">AutoRepairRange</a> = number or boolean or {tag = value, ...}</dt> |
| 873 |
<dt><var>custom variable</var> = number or boolean or {tag = value, ...}</dt> |
| 874 |
<dd>Each of these tags makes the unit type override some properties |
| 875 |
of the identically-named (predefined or custom) variable. |
| 876 |
Which properties get overridden depends on the type of the value you provide: |
| 877 |
<dl> |
| 878 |
<dt><var>variable</var> = {Value = number, Max = number, Increase = number, Enable = boolean}</dt> |
| 879 |
<dd>Overrides individual properties of the variable. |
| 880 |
The tags and values of the table have the same meanings |
| 881 |
as in <a href="#DefineVariables">DefineVariables</a>. |
| 882 |
If you omit some tags from the table, then the corresponding properties |
| 883 |
set with DefineVariables remain in force.</dd> |
| 884 |
<dt><var>variable</var> = number</dt> |
| 885 |
<dd>Assigns the number as both the initial value and the maximum value |
| 886 |
of the variable, and enables the variable.<br>This is the same as |
| 887 |
<var>variable</var> = {Value = number, Max = number, Enable = true}.</dd> |
| 888 |
<dt><var>variable</var> = boolean</dt> |
| 889 |
<dd>Enables or disables the variable.<br>This is the same as |
| 890 |
<var>variable</var> = {Enable = boolean}.</dd> |
| 891 |
</dl> |
| 892 |
If you use custom variables, you must define them with |
| 893 |
<a href="#DefineVariables">DefineVariables</a> before you define any unit types. |
| 894 |
</dd> |
| 895 |
<!--IDEA:<dt>force-minimap-color<dt> |
| 896 |
<dd>An unit with this flag will ignore any friend/foe/owning player considerations |
| 897 |
for the minimap color, and will force this. It takes a number from the palette here. |
| 898 |
</dd>--> |
| 899 |
</dl> |
| 900 |
|
| 901 |
|
| 902 |
<h4>Example</h4> |
| 903 |
Sorry, but due to the huge number of available flags we can only show a limited example. |
| 904 |
|
| 905 |
<pre class="lua"> |
| 906 |
DefineUnitType("unit-footman", { Name = "Footman", |
| 907 |
Image = {"file", "alliance/units/footman.png", "size", {72, 72}}, |
| 908 |
Animations = "animations-footman", Icon = "icon-footman", |
| 909 |
EnergyValue = 600, |
| 910 |
MagmaValue = 60, |
| 911 |
HitPoints = 60, |
| 912 |
DrawLevel = 40, |
| 913 |
TileSize = {1, 1}, BoxSize = {31, 31}, |
| 914 |
SightRange = 4, ComputerReactionRange = 6, PersonReactionRange = 4, |
| 915 |
Armor = 2, BasicDamage = 6, PiercingDamage = 3, Missile = "missile-none", |
| 916 |
MaxAttackRange = 1, |
| 917 |
Priority = 60, |
| 918 |
Points = 50, |
| 919 |
Corpse = {"unit-dead-body", 6}, |
| 920 |
Type = "land", |
| 921 |
RightMouseAction = "attack", |
| 922 |
CanAttack = true, |
| 923 |
CanTargetLand = true, |
| 924 |
Organic = true, |
| 925 |
SelectableByRectangle = true, |
| 926 |
-- distance is >3 from gold, and <2 from a watch tower |
| 927 |
-- or distance is >6 from goldmine |
| 928 |
BuildingRules = { { "distance", { Distance = 3, DistanceType = ">", Type = "unit-gold-mine"}, |
| 929 |
"distance", { Distance = 2, DistanceType = "<", Type = "unit-gold-mine"}}, |
| 930 |
{ "distance", { Distance = 6, DistanceType = ">", Type = "unit-gold-mine"}, |
| 931 |
} |
| 932 |
}, |
| 933 |
Sounds = { |
| 934 |
"selected", "footman-selected", |
| 935 |
"acknowledge", "footman-acknowledge", |
| 936 |
"ready", "footman-ready", |
| 937 |
"help", "basic alliance voices help 1", |
| 938 |
"dead", "basic alliance voices dead"} } ) |
| 939 |
</pre> |
| 940 |
|
| 941 |
<!-- |
| 942 |
|
| 943 |
<LI><var>unit-type</var><br> |
| 944 |
Get the pointer to the unit type structure.<p> |
| 945 |
(unit-type ident) |
| 946 |
<dl> |
| 947 |
<dt>ident</dt> |
| 948 |
<dd>The unit-type unique identifier.</dd> |
| 949 |
</dl> |
| 950 |
<p> |
| 951 |
<h4>Example:</h4> |
| 952 |
(unit-type "unit-peon")<p> |
| 953 |
Get the unit type structure of the peon. #<unittype 0x80ac350 unit-peon><p> |
| 954 |
|
| 955 |
<li><var>unit-type-array</var><br> |
| 956 |
Get an array of all currently defined unit type structures.<p> |
| 957 |
(unit-type-array) |
| 958 |
<p> |
| 959 |
|
| 960 |
<li><var>get-unit-type-ident</var><br> |
| 961 |
Get the unique identfier of the unit type structure.<p> |
| 962 |
(get-unit-type-ident type) |
| 963 |
<dl> |
| 964 |
<dt>type</dt> |
| 965 |
<dd>Unit type pointer</dd> |
| 966 |
</dl> |
| 967 |
<p> |
| 968 |
<h4>Example:</h4> |
| 969 |
(get-unit-type-ident (unit-type "unit-peon"))<p> |
| 970 |
Get the identifier of the unit type peon.<p> |
| 971 |
--> |
| 972 |
|
| 973 |
<hr> |
| 974 |
All trademarks and copyrights on this page are owned by their respective owners. |
| 975 |
<address>(c) 2002-2007 by <a href="http://boswars.org"> |
| 976 |
The Bos Wars Project</a></address></body></html> |