vrtc / honeydew (public) (License: CC0) (since 2023-12-20) (hash sha1)
Warcraft 3: The Frozen Throne 1.27 custom scenario.
List of commits:
Subject Hash Author Date (UTC)
feat!: build skeleton project da405d9978fcb6c8414249ceda4e07848e34f62a Vladyslav Bondarenko 2023-12-14 11:59:17
Commit da405d9978fcb6c8414249ceda4e07848e34f62a - feat!: build skeleton project
Use a collection of tools to build and package a valid map file.

Parse custom Jass snippets with pjass. Generate a valid war3map.j with
m4. Patch the map file, that was originally created with native World
Editor, with the generated war3map.j. Bundle the project into a zip
archive, together with sources and instructions. Orchestrate the build
with make.
Author: Vladyslav Bondarenko
Author date (UTC): 2023-12-14 11:59
Committer name: Vladyslav Bondarenko
Committer date (UTC): 2023-12-14 11:59
Parent(s):
Signer:
Signing key: EFF9624877D25D02
Signing status: E
Tree: 76f3cf5551760b62c6bda1ea7ba57a8328946398
File Lines added Lines deleted
.gitignore 10 0
Makefile 42 0
doc/honeydew.md 13 0
etc/Blizzard.j 10229 0
etc/README.md 28 0
etc/common.ai 2582 0
etc/common.j 2417 0
honeydew-0_0WIP-1_27-en.w3x 0 0
src/config.j 115 0
src/main.j 54 0
src/war3map.m4 16 0
File .gitignore added (mode: 100644) (index 0000000..0550d82)
1 *.pub
2 *.sig
3 *.swp
4 *.zip
5 *~
6 Makefile.config
7 target
8 target/
9 target/*
10 war3map.j
File Makefile added (mode: 100644) (index 0000000..73ec001)
1 include Makefile.config
2
3 NAME=honeydew
4 VERSION=0_0WIP
5 CLASSIFIER=1_27
6 LANG=en
7 NAMEFULL=$(NAME)-$(VERSION)-$(CLASSIFIER)-$(LANG)
8
9 PJASS_OPTS=etc/common.j etc/Blizzard.j etc/common.ai -rb +filter +shadow +checkglobalsinit +checkstringhash
10 SNIPPETS=src/main.j src/config.j
11
12 BUILDDIR=target
13 BASEDIR=.
14
15 all:
16 $(MAKE) build
17 $(MAKE) clean
18
19 clean:
20 rm war3map.j
21
22 generate-sources: src/war3map.m4
23 pjass $(PJASS_OPTS) $(SNIPPETS)
24 m4 --debug=aeqp -I ${BASEDIR} src/war3map.m4 > war3map.j
25
26 compile: generate-sources
27 pjass $(PJASS_OPTS) war3map.j
28
29 build: compile
30 smpq --append --overwrite ${NAMEFULL}.w3x war3map.j
31
32 binary: build
33 # Cannot use '.gitignore' for exclusion, because of how paths are expanded in this case.
34 zip --include "*.j" "*.m4" "*.w3x" "*.md" ".git*" --exclude "*target*" "*.zip" "*war3map.j*" -r "${NAMEFULL}.zip" "../${NAME}"
35 gpg --detach-sign --yes "${NAMEFULL}.zip"
36
37 package: binary
38
39 test: build
40 # Path to the map relative to data directory (game installation directory in almost every case).
41 # Must be given exact file name. Wildcards or tokens will not be expanded.
42 $(WAR3EXE) -loadfile "Maps/${NAME}/${NAMEFULL}.w3x"
File doc/honeydew.md added (mode: 100644) (index 0000000..c2133c0)
1 # Honeydew
2
3 ## Boss battle
4
5 Periodically boss channells a spell for 3 seconds. When it finishes, a doom guard appears in a random place on the arena. Players should interrupt the cast with spells like Storm Bolt or Hex, to prevent the appearence of the doom guard.
6
7 When at half health or less, boss will attempt to sacrifice a doom guard with death pact.
8
9 Periodically, about every half a minute since the fight starts, the boss will make infernals fall from the sky. Infernals destroy nearby trees adding to the spectacle.
10
11 Maybe death knights (revenant creature, not hero) periodically appear and cast death coil on the boss to heal it.
12
13 Felhunters (mage hunters) appear from portals and mana burn player heroes.
The diff for file etc/Blizzard.j is too big (10229 changes) and cannot be shown.
File etc/README.md added (mode: 100644) (index 0000000..ee81c8b)
1 # Blizzard Jass2 scripts
2
3 This directory should contain the following Blizzard script files:
4 - common.j
5 - Blizzard.j
6 - common.ai
7
8 These files are distributed with the game and contain declarations of
9 funcctions and variables for Jass2 scripting language, that is available to
10 users at runtime.
11
12 These files are duplicated in the project's repository for several practical
13 reasons.
14
15 When the project is built, 'pjass' parses all the project specific scripts and
16 checks them for validtity before the game is even run or the campaign packaged.
17 Files with native declarations must be included in the tool's path for it to
18 work. Hence why these files must be readily present during development.
19
20 Additionally, these files specifically are used to decisively test the project
21 for validity against specific game version (1.27), from which these native
22 declarations were obtained from. If the project should be ported to some other
23 game version, these files must be upgraded to appropriate version.
24
25 'pjass' is a free community tool that is used to parse Jass2 scripts. Since
26 game version >1.31, 'pjass' should be included in the official game
27 distribution. Note that 'pjass' is easily built for GNU/Linux natively from
28 source.
File etc/common.ai added (mode: 100644) (index 0000000..d00120a)
1 //==================================================================================================
2 // $Id: common.ai,v 1.68 2003/05/12 02:34:18 bfitch Exp $
3 //==================================================================================================
4 native DebugS takes string str returns nothing
5 native DebugFI takes string str, integer val returns nothing
6 native DebugUnitID takes string str, integer val returns nothing
7 native DisplayText takes integer p, string str returns nothing
8 native DisplayTextI takes integer p, string str, integer val returns nothing
9 native DisplayTextII takes integer p, string str, integer v1, integer v2 returns nothing
10 native DisplayTextIII takes integer p, string str, integer v1, integer v2, integer v3 returns nothing
11 native DoAiScriptDebug takes nothing returns boolean
12
13 native GetAiPlayer takes nothing returns integer
14 native GetHeroId takes nothing returns integer
15 native GetHeroLevelAI takes nothing returns integer
16
17 native GetUnitCount takes integer unitid returns integer
18 native GetPlayerUnitTypeCount takes player p, integer unitid returns integer
19 native GetUnitCountDone takes integer unitid returns integer
20 native GetTownUnitCount takes integer id, integer tn, boolean dn returns integer
21 native GetUnitGoldCost takes integer unitid returns integer
22 native GetUnitWoodCost takes integer unitid returns integer
23 native GetUnitBuildTime takes integer unitid returns integer
24
25 native GetMinesOwned takes nothing returns integer
26 native GetGoldOwned takes nothing returns integer
27 native TownWithMine takes nothing returns integer
28 native TownHasMine takes integer townid returns boolean
29 native TownHasHall takes integer townid returns boolean
30
31 native GetUpgradeLevel takes integer id returns integer
32 native GetUpgradeGoldCost takes integer id returns integer
33 native GetUpgradeWoodCost takes integer id returns integer
34 native GetNextExpansion takes nothing returns integer
35 native GetMegaTarget takes nothing returns unit
36 native GetBuilding takes player p returns unit
37 native GetEnemyPower takes nothing returns integer
38 native SetAllianceTarget takes unit id returns nothing
39 native GetAllianceTarget takes nothing returns unit
40
41 native SetProduce takes integer qty, integer id, integer town returns boolean
42 native Unsummon takes unit unitid returns nothing
43 native SetExpansion takes unit peon, integer id returns boolean
44 native SetUpgrade takes integer id returns boolean
45 native SetHeroLevels takes code func returns nothing
46 native SetNewHeroes takes boolean state returns nothing
47 native PurchaseZeppelin takes nothing returns nothing
48
49 native MergeUnits takes integer qty, integer a, integer b, integer make returns boolean
50 native ConvertUnits takes integer qty, integer id returns boolean
51
52 native SetCampaignAI takes nothing returns nothing
53 native SetMeleeAI takes nothing returns nothing
54 native SetTargetHeroes takes boolean state returns nothing
55 native SetPeonsRepair takes boolean state returns nothing
56 native SetRandomPaths takes boolean state returns nothing
57 native SetDefendPlayer takes boolean state returns nothing
58 native SetHeroesFlee takes boolean state returns nothing
59 native SetHeroesBuyItems takes boolean state returns nothing
60 native SetWatchMegaTargets takes boolean state returns nothing
61 native SetIgnoreInjured takes boolean state returns nothing
62 native SetHeroesTakeItems takes boolean state returns nothing
63 native SetUnitsFlee takes boolean state returns nothing
64 native SetGroupsFlee takes boolean state returns nothing
65 native SetSlowChopping takes boolean state returns nothing
66 native SetCaptainChanges takes boolean allow returns nothing
67 native SetSmartArtillery takes boolean state returns nothing
68 native SetReplacementCount takes integer qty returns nothing
69 native GroupTimedLife takes boolean allow returns nothing
70 native RemoveInjuries takes nothing returns nothing
71 native RemoveSiege takes nothing returns nothing
72
73 native InitAssault takes nothing returns nothing
74 native AddAssault takes integer qty, integer id returns boolean
75 native AddDefenders takes integer qty, integer id returns boolean
76
77 native GetCreepCamp takes integer min, integer max, boolean flyers_ok returns unit
78
79 native StartGetEnemyBase takes nothing returns nothing
80 native WaitGetEnemyBase takes nothing returns boolean
81 native GetEnemyBase takes nothing returns unit
82 native GetExpansionFoe takes nothing returns unit
83 native GetEnemyExpansion takes nothing returns unit
84 native GetExpansionX takes nothing returns integer
85 native GetExpansionY takes nothing returns integer
86 native SetStagePoint takes real x, real y returns nothing
87 native AttackMoveKill takes unit target returns nothing
88 native AttackMoveXY takes integer x, integer y returns nothing
89 native LoadZepWave takes integer x, integer y returns nothing
90 native SuicidePlayer takes player id, boolean check_full returns boolean
91 native SuicidePlayerUnits takes player id, boolean check_full returns boolean
92 native CaptainInCombat takes boolean attack_captain returns boolean
93 native IsTowered takes unit target returns boolean
94
95 native ClearHarvestAI takes nothing returns nothing
96 native HarvestGold takes integer town, integer peons returns nothing
97 native HarvestWood takes integer town, integer peons returns nothing
98 native GetExpansionPeon takes nothing returns unit
99
100 native StopGathering takes nothing returns nothing
101 native AddGuardPost takes integer id, real x, real y returns nothing
102 native FillGuardPosts takes nothing returns nothing
103 native ReturnGuardPosts takes nothing returns nothing
104 native CreateCaptains takes nothing returns nothing
105 native SetCaptainHome takes integer which, real x, real y returns nothing
106 native ResetCaptainLocs takes nothing returns nothing
107 native ShiftTownSpot takes real x, real y returns nothing
108 native TeleportCaptain takes real x, real y returns nothing
109 native ClearCaptainTargets takes nothing returns nothing
110 native CaptainAttack takes real x, real y returns nothing
111 native CaptainVsUnits takes player id returns nothing
112 native CaptainVsPlayer takes player id returns nothing
113 native CaptainGoHome takes nothing returns nothing
114 native CaptainIsHome takes nothing returns boolean
115 native CaptainIsFull takes nothing returns boolean
116 native CaptainIsEmpty takes nothing returns boolean
117 native CaptainGroupSize takes nothing returns integer
118 native CaptainReadiness takes nothing returns integer
119 native CaptainRetreating takes nothing returns boolean
120 native CaptainReadinessHP takes nothing returns integer
121 native CaptainReadinessMa takes nothing returns integer
122 native CaptainAtGoal takes nothing returns boolean
123 native CreepsOnMap takes nothing returns boolean
124 native SuicideUnit takes integer count, integer unitid returns nothing
125 native SuicideUnitEx takes integer ct, integer uid, integer pid returns nothing
126 native StartThread takes code func returns nothing
127 native Sleep takes real seconds returns nothing
128 native UnitAlive takes unit id returns boolean
129 native UnitInvis takes unit id returns boolean
130 native IgnoredUnits takes integer unitid returns integer
131 native TownThreatened takes nothing returns boolean
132 native DisablePathing takes nothing returns nothing
133 native SetAmphibious takes nothing returns nothing
134
135 native CommandsWaiting takes nothing returns integer
136 native GetLastCommand takes nothing returns integer
137 native GetLastData takes nothing returns integer
138 native PopLastCommand takes nothing returns nothing
139 native MeleeDifficulty takes nothing returns integer
140
141 //============================================================================
142 // Globals for all AI scripts
143 //============================================================================
144 globals
145
146 //--------------------------------------------------------------------
147 // HUMANS
148 //--------------------------------------------------------------------
149
150 // human heroes
151 constant integer ARCHMAGE = 'Hamg'
152 constant integer PALADIN = 'Hpal'
153 constant integer MTN_KING = 'Hmkg'
154 constant integer BLOOD_MAGE = 'Hblm'
155
156 // human hero abilities
157 constant integer AVATAR = 'AHav'
158 constant integer BASH = 'AHbh'
159 constant integer THUNDER_BOLT = 'AHtb'
160 constant integer THUNDER_CLAP = 'AHtc'
161
162 constant integer DEVOTION_AURA = 'AHad'
163 constant integer DIVINE_SHIELD = 'AHds'
164 constant integer HOLY_BOLT = 'AHhb'
165 constant integer RESURRECTION = 'AHre'
166
167 constant integer BLIZZARD = 'AHbz'
168 constant integer BRILLIANCE_AURA = 'AHab'
169 constant integer MASS_TELEPORT = 'AHmt'
170 constant integer WATER_ELEMENTAL = 'AHwe'
171
172 constant integer BANISH = 'AHbn'
173 constant integer FLAME_STRIKE = 'AHfs'
174 constant integer SUMMON_PHOENIX = 'AHpx'
175 constant integer SIPHON_MANA = 'AHdr'
176
177 // special human heroes
178 constant integer JAINA = 'Hjai'
179 constant integer MURADIN = 'Hmbr'
180 constant integer GARITHOS = 'Hlgr'
181 constant integer KAEL = 'Hkal'
182
183 // human units
184 constant integer COPTER = 'hgyr'
185 constant integer GYRO = COPTER
186 constant integer ELEMENTAL = 'hwat'
187 constant integer FOOTMAN = 'hfoo'
188 constant integer FOOTMEN = FOOTMAN
189 constant integer GRYPHON = 'hgry'
190 constant integer KNIGHT = 'hkni'
191 constant integer MORTAR = 'hmtm'
192 constant integer PEASANT = 'hpea'
193 constant integer PRIEST = 'hmpr'
194 constant integer RIFLEMAN = 'hrif'
195 constant integer RIFLEMEN = RIFLEMAN
196 constant integer SORCERESS = 'hsor'
197 constant integer TANK = 'hmtt'
198 constant integer STEAM_TANK = TANK
199 constant integer ROCKET_TANK = 'hrtt'
200 constant integer MILITIA = 'hmil'
201 constant integer SPELL_BREAKER = 'hspt'
202 constant integer HUMAN_DRAGON_HAWK = 'hdhw'
203
204 // special human units
205 constant integer BLOOD_PRIEST = 'hbep'
206 constant integer BLOOD_SORCERESS = 'hbes'
207 constant integer BLOOD_PEASANT = 'nhew'
208
209 // human buildings
210 constant integer AVIARY = 'hgra'
211 constant integer BARRACKS = 'hbar'
212 constant integer BLACKSMITH = 'hbla'
213 constant integer CANNON_TOWER = 'hctw'
214 constant integer CASTLE = 'hcas'
215 constant integer CHURCH = 'htws'
216 constant integer MAGE_TOWER = CHURCH
217 constant integer GUARD_TOWER = 'hgtw'
218 constant integer HOUSE = 'hhou'
219 constant integer HUMAN_ALTAR = 'halt'
220 constant integer KEEP = 'hkee'
221 constant integer LUMBER_MILL = 'hlum'
222 constant integer SANCTUM = 'hars'
223 constant integer ARCANE_SANCTUM = SANCTUM
224 constant integer TOWN_HALL = 'htow'
225 constant integer WATCH_TOWER = 'hwtw'
226 constant integer WORKSHOP = 'harm'
227 constant integer ARCANE_VAULT = 'hvlt'
228 constant integer ARCANE_TOWER = 'hatw'
229
230 // human upgrades
231 constant integer UPG_MELEE = 'Rhme'
232 constant integer UPG_RANGED = 'Rhra'
233 constant integer UPG_ARTILLERY = 'Rhaa'
234 constant integer UPG_ARMOR = 'Rhar'
235 constant integer UPG_GOLD = 'Rhmi'
236 constant integer UPG_MASONRY = 'Rhac'
237 constant integer UPG_SIGHT = 'Rhss'
238 constant integer UPG_DEFEND = 'Rhde'
239 constant integer UPG_BREEDING = 'Rhan'
240 constant integer UPG_PRAYING = 'Rhpt'
241 constant integer UPG_SORCERY = 'Rhst'
242 constant integer UPG_LEATHER = 'Rhla'
243 constant integer UPG_GUN_RANGE = 'Rhri'
244 constant integer UPG_WOOD = 'Rhlh'
245 constant integer UPG_SENTINEL = 'Rhse'
246 constant integer UPG_SCATTER = 'Rhsr'
247 constant integer UPG_BOMBS = 'Rhgb'
248 constant integer UPG_HAMMERS = 'Rhhb'
249 constant integer UPG_CONT_MAGIC = 'Rhss'
250 constant integer UPG_FRAGS = 'Rhfs'
251 constant integer UPG_TANK = 'Rhrt'
252 constant integer UPG_FLAK = 'Rhfc'
253 constant integer UPG_CLOUD = 'Rhcd'
254
255 //--------------------------------------------------------------------
256 // ORCS
257 //--------------------------------------------------------------------
258
259 // orc heroes
260 constant integer BLADE_MASTER = 'Obla'
261 constant integer FAR_SEER = 'Ofar'
262 constant integer TAUREN_CHIEF = 'Otch'
263 constant integer SHADOW_HUNTER = 'Oshd'
264
265 // special orc heroes
266 constant integer GROM = 'Ogrh'
267 constant integer THRALL = 'Othr'
268
269 // orc hero abilities
270 constant integer CRITICAL_STRIKE = 'AOcr'
271 constant integer MIRROR_IMAGE = 'AOmi'
272 constant integer BLADE_STORM = 'AOww'
273 constant integer WIND_WALK = 'AOwk'
274
275 constant integer CHAIN_LIGHTNING = 'AOcl'
276 constant integer EARTHQUAKE = 'AOeq'
277 constant integer FAR_SIGHT = 'AOfs'
278 constant integer SPIRIT_WOLF = 'AOsf'
279
280 constant integer ENDURANE_AURA = 'AOae'
281 constant integer REINCARNATION = 'AOre'
282 constant integer SHOCKWAVE = 'AOsh'
283 constant integer WAR_STOMP = 'AOws'
284
285 constant integer HEALING_WAVE = 'AOhw'
286 constant integer HEX = 'AOhx'
287 constant integer SERPENT_WARD = 'AOsw'
288 constant integer VOODOO = 'AOvd'
289
290 // orc units
291 constant integer GUARDIAN = 'oang'
292 constant integer CATAPULT = 'ocat'
293 constant integer WITCH_DOCTOR = 'odoc'
294 constant integer GRUNT = 'ogru'
295 constant integer HEAD_HUNTER = 'ohun'
296 constant integer BERSERKER = 'otbk'
297 constant integer KODO_BEAST = 'okod'
298 constant integer PEON = 'opeo'
299 constant integer RAIDER = 'orai'
300 constant integer SHAMAN = 'oshm'
301 constant integer TAUREN = 'otau'
302 constant integer WYVERN = 'owyv'
303 constant integer BATRIDER = 'otbr'
304 constant integer SPIRIT_WALKER = 'ospw'
305 constant integer SPIRIT_WALKER_M = 'ospm'
306
307 // orc buildings
308 constant integer ORC_ALTAR = 'oalt'
309 constant integer ORC_BARRACKS = 'obar'
310 constant integer BESTIARY = 'obea'
311 constant integer FORGE = 'ofor'
312 constant integer FORTRESS = 'ofrt'
313 constant integer GREAT_HALL = 'ogre'
314 constant integer LODGE = 'osld'
315 constant integer STRONGHOLD = 'ostr'
316 constant integer BURROW = 'otrb'
317 constant integer TOTEM = 'otto'
318 constant integer ORC_WATCH_TOWER = 'owtw'
319 constant integer VOODOO_LOUNGE = 'ovln'
320
321 // orc upgrades
322 constant integer UPG_ORC_MELEE = 'Rome'
323 constant integer UPG_ORC_RANGED = 'Rora'
324 constant integer UPG_ORC_ARTILLERY = 'Roaa'
325 constant integer UPG_ORC_ARMOR = 'Roar'
326 constant integer UPG_ORC_WAR_DRUMS = 'Rwdm'
327 constant integer UPG_ORC_PILLAGE = 'Ropg'
328 constant integer UPG_ORC_BERSERK = 'Robs'
329 constant integer UPG_ORC_PULVERIZE = 'Rows'
330 constant integer UPG_ORC_ENSNARE = 'Roen'
331 constant integer UPG_ORC_VENOM = 'Rovs'
332 constant integer UPG_ORC_DOCS = 'Rowd'
333 constant integer UPG_ORC_SHAMAN = 'Rost'
334 constant integer UPG_ORC_SPIKES = 'Rosp'
335 constant integer UPG_ORC_BURROWS = 'Rorb'
336 constant integer UPG_ORC_REGEN = 'Rotr'
337 constant integer UPG_ORC_FIRE = 'Rolf'
338 constant integer UPG_ORC_SWALKER = 'Rowt'
339 constant integer UPG_ORC_BERSERKER = 'Robk'
340 constant integer UPG_ORC_NAPTHA = 'Robf'
341 constant integer UPG_ORC_CHAOS = 'Roch'
342
343 // Warcraft 2 orc units
344 constant integer OGRE_MAGI = 'nomg'
345 constant integer ORC_DRAGON = 'nrwm'
346 constant integer SAPPER = 'ngsp'
347 constant integer ZEPPLIN = 'nzep'
348 constant integer ZEPPELIN = ZEPPLIN
349 constant integer W2_WARLOCK = 'nw2w'
350 constant integer PIG_FARM = 'npgf'
351
352 // special orc units
353 constant integer CHAOS_GRUNT = 'nchg'
354 constant integer CHAOS_WARLOCK = 'nchw'
355 constant integer CHAOS_RAIDER = 'nchr'
356 constant integer CHAOS_PEON = 'ncpn'
357 constant integer CHAOS_KODO = 'nckb'
358 constant integer CHAOS_GROM = 'Opgh'
359 constant integer CHAOS_BLADEMASTER = 'Nbbc'
360 constant integer CHAOS_BURROW = 'ocbw'
361
362 //--------------------------------------------------------------------
363 // UNDEAD
364 //--------------------------------------------------------------------
365
366 // undead heroes
367 constant integer DEATH_KNIGHT = 'Udea'
368 constant integer DREAD_LORD = 'Udre'
369 constant integer LICH = 'Ulic'
370 constant integer CRYPT_LORD = 'Ucrl'
371
372 // special undead heroes
373 constant integer MALGANIS = 'Umal'
374 constant integer TICHONDRIUS = 'Utic'
375 constant integer PIT_LORD = 'Npld'
376 constant integer DETHEROC = 'Udth'
377
378 // undead hero abilities
379 constant integer SLEEP = 'AUsl'
380 constant integer VAMP_AURA = 'AUav'
381 constant integer CARRION_SWARM = 'AUcs'
382 constant integer INFERNO = 'AUin'
383
384 constant integer DARK_RITUAL = 'AUdr'
385 constant integer DEATH_DECAY = 'AUdd'
386 constant integer FROST_ARMOR = 'AUfu'
387 constant integer FROST_NOVA = 'AUfn'
388
389 constant integer ANIM_DEAD = 'AUan'
390 constant integer DEATH_COIL = 'AUdc'
391 constant integer DEATH_PACT = 'AUdp'
392 constant integer UNHOLY_AURA = 'AUau'
393
394 constant integer CARRION_SCARAB = 'AUcb'
395 constant integer IMPALE = 'AUim'
396 constant integer LOCUST_SWARM = 'AUls'
397 constant integer THORNY_SHIELD = 'AUts'
398
399 // undead units
400 constant integer ABOMINATION = 'uabo'
401 constant integer ACOLYTE = 'uaco'
402 constant integer BANSHEE = 'uban'
403 constant integer PIT_FIEND = 'ucry'
404 constant integer CRYPT_FIEND = PIT_FIEND
405 constant integer FROST_WYRM = 'ufro'
406 constant integer GARGOYLE = 'ugar'
407 constant integer GARGOYLE_MORPH = 'ugrm'
408 constant integer GHOUL = 'ugho'
409 constant integer MEAT_WAGON = 'umtw'
410 constant integer NECRO = 'unec'
411 constant integer SKEL_WARRIOR = 'uske'
412 constant integer SHADE = 'ushd'
413 constant integer UNDEAD_BARGE = 'uarb'
414 constant integer OBSIDIAN_STATUE = 'uobs'
415 constant integer OBS_STATUE = OBSIDIAN_STATUE
416 constant integer BLK_SPHINX = 'ubsp'
417
418 // undead buildings
419 constant integer UNDEAD_MINE = 'ugol'
420 constant integer UNDEAD_ALTAR = 'uaod'
421 constant integer BONEYARD = 'ubon'
422 constant integer GARG_SPIRE = 'ugsp'
423 constant integer NECROPOLIS_1 = 'unpl' // normal
424 constant integer NECROPOLIS_2 = 'unp1' // upgraded once
425 constant integer NECROPOLIS_3 = 'unp2' // full upgrade
426 constant integer SAC_PIT = 'usap'
427 constant integer CRYPT = 'usep'
428 constant integer SLAUGHTERHOUSE = 'uslh'
429 constant integer DAMNED_TEMPLE = 'utod'
430 constant integer ZIGGURAT_1 = 'uzig' // normal
431 constant integer ZIGGURAT_2 = 'uzg1' // upgraded
432 constant integer ZIGGURAT_FROST = 'uzg2' // frost tower
433 constant integer GRAVEYARD = 'ugrv'
434 constant integer TOMB_OF_RELICS = 'utom'
435
436 // undead upgrades
437 constant integer UPG_UNHOLY_STR = 'Rume'
438 constant integer UPG_CR_ATTACK = 'Rura'
439 constant integer UPG_UNHOLY_ARMOR = 'Ruar'
440 constant integer UPG_CANNIBALIZE = 'Ruac'
441 constant integer UPG_GHOUL_FRENZY = 'Rugf'
442 constant integer UPG_FIEND_WEB = 'Ruwb'
443 constant integer UPG_ABOM = 'Ruab'
444 constant integer UPG_STONE_FORM = 'Rusf'
445 constant integer UPG_NECROS = 'Rune'
446 constant integer UPG_BANSHEE = 'Ruba'
447 constant integer UPG_MEAT_WAGON = 'Rump'
448 constant integer UPG_WYRM_BREATH = 'Rufb'
449 constant integer UPG_SKEL_LIFE = 'Rusl'
450 constant integer UPG_SKEL_MASTERY = 'Rusm'
451 constant integer UPG_EXHUME = 'Ruex'
452 constant integer UPG_SACRIFICE = 'Rurs'
453 constant integer UPG_ABOM_EXPL = 'Ruax'
454 constant integer UPG_CR_ARMOR = 'Rucr'
455 constant integer UPG_PLAGUE = 'Rupc'
456 constant integer UPG_BLK_SPHINX = 'Rusp'
457 constant integer UPG_BURROWING = 'Rubu'
458
459 //--------------------------------------------------------------------
460 // ELVES
461 //--------------------------------------------------------------------
462
463 // elf heroes
464 constant integer DEMON_HUNTER = 'Edem'
465 constant integer DEMON_HUNTER_M = 'Edmm'
466 constant integer KEEPER = 'Ekee'
467 constant integer MOON_CHICK = 'Emoo'
468 constant integer MOON_BABE = MOON_CHICK
469 constant integer MOON_HONEY = MOON_CHICK
470 constant integer WARDEN = 'Ewar'
471
472 // special elf heroes
473 constant integer SYLVANUS = 'Hvwd'
474 constant integer CENARIUS = 'Ecen'
475 constant integer ILLIDAN = 'Eevi'
476 constant integer ILLIDAN_DEMON = 'Eevm'
477 constant integer MAIEV = 'Ewrd'
478
479 // elf hero abilities
480 constant integer FORCE_NATURE = 'AEfn'
481 constant integer ENT_ROOTS = 'AEer'
482 constant integer THORNS_AURA = 'AEah'
483 constant integer TRANQUILITY = 'AEtq'
484
485 constant integer EVASION = 'AEev'
486 constant integer IMMOLATION = 'AEim'
487 constant integer MANA_BURN = 'AEmb'
488 constant integer METAMORPHOSIS = 'AEme'
489
490 constant integer SEARING_ARROWS = 'AHfa'
491 constant integer SCOUT = 'AEst'
492 constant integer STARFALL = 'AEsf'
493 constant integer TRUESHOT = 'AEar'
494
495 constant integer BLINK = 'AEbl'
496 constant integer FAN_KNIVES = 'AEfk'
497 constant integer SHADOW_TOUCH = 'AEsh'
498 constant integer VENGEANCE = 'AEsv'
499
500 // elf units
501 constant integer WISP = 'ewsp'
502 constant integer ARCHER = 'earc'
503 constant integer DRUID_TALON = 'edot'
504 constant integer DRUID_TALON_M = 'edtm'
505 constant integer BALLISTA = 'ebal'
506 constant integer DRUID_CLAW = 'edoc'
507 constant integer DRUID_CLAW_M = 'edcm'
508 constant integer DRYAD = 'edry'
509 constant integer HIPPO = 'ehip'
510 constant integer HIPPO_RIDER = 'ehpr'
511 constant integer HUNTRESS = 'esen'
512 constant integer CHIMAERA = 'echm'
513 constant integer ENT = 'efon'
514 constant integer MOUNTAIN_GIANT = 'emtg'
515 constant integer FAERIE_DRAGON = 'efdr'
516
517 // special elf units
518 constant integer HIGH_ARCHER = 'nhea'
519 constant integer HIGH_FOOTMAN = 'hcth'
520 constant integer HIGH_FOOTMEN = HIGH_FOOTMAN
521 constant integer HIGH_SWORDMAN = 'hhes'
522 constant integer DRAGON_HAWK = 'nws1'
523 constant integer CORRUPT_TREANT = 'nenc'
524 constant integer POISON_TREANT = 'nenp'
525 constant integer PLAGUE_TREANT = 'nepl'
526 constant integer SHANDRIS = 'eshd'
527
528 // elf buildings
529 constant integer ANCIENT_LORE = 'eaoe'
530 constant integer ANCIENT_WAR = 'eaom'
531 constant integer ANCIENT_WIND = 'eaow'
532 constant integer TREE_AGES = 'etoa'
533 constant integer TREE_ETERNITY = 'etoe'
534 constant integer TREE_LIFE = 'etol'
535 constant integer ANCIENT_PROTECT = 'etrp'
536 constant integer ELF_ALTAR = 'eate'
537 constant integer BEAR_DEN = 'edol'
538 constant integer CHIMAERA_ROOST = 'edos'
539 constant integer HUNTERS_HALL = 'edob'
540 constant integer MOON_WELL = 'emow'
541 constant integer ELF_MINE = 'egol'
542 constant integer DEN_OF_WONDERS = 'eden'
543
544 // special elf buildings
545 constant integer ELF_FARM = 'nefm'
546 constant integer ELF_GUARD_TOWER = 'negt'
547 constant integer HIGH_SKY = 'negm'
548 constant integer HIGH_EARTH = 'negf'
549 constant integer HIGH_TOWER = 'negt'
550 constant integer ELF_HIGH_BARRACKS = 'nheb'
551 constant integer CORRUPT_LIFE = 'nctl'
552 constant integer CORRUPT_WELL = 'ncmw'
553 constant integer CORRUPT_PROTECTOR = 'ncap'
554 constant integer CORRUPT_WAR = 'ncaw'
555
556 // elf upgrades
557 constant integer UPG_STR_MOON = 'Resm'
558 constant integer UPG_STR_WILD = 'Resw'
559 constant integer UPG_MOON_ARMOR = 'Rema'
560 constant integer UPG_HIDES = 'Rerh'
561 constant integer UPG_ULTRAVISION = 'Reuv'
562 constant integer UPG_BLESSING = 'Renb'
563 constant integer UPG_SCOUT = 'Resc'
564 constant integer UPG_GLAIVE = 'Remg'
565 constant integer UPG_BOWS = 'Reib'
566 constant integer UPG_MARKSMAN = 'Remk'
567 constant integer UPG_DRUID_TALON = 'Redt'
568 constant integer UPG_DRUID_CLAW = 'Redc'
569 constant integer UPG_ABOLISH = 'Resi'
570 constant integer UPG_CHIM_ACID = 'Recb'
571 constant integer UPG_HIPPO_TAME = 'Reht'
572 constant integer UPG_BOLT = 'Repd'
573 constant integer UPG_MARK_CLAW = 'Reeb'
574 constant integer UPG_MARK_TALON = 'Reec'
575 constant integer UPG_HARD_SKIN = 'Rehs'
576 constant integer UPG_RESIST_SKIN = 'Rers'
577 constant integer UPG_WELL_SPRING = 'Rews'
578
579 //--------------------------------------------------------------------
580 // Neutral
581 //--------------------------------------------------------------------
582 constant integer DEMON_GATE = 'ndmg'
583 constant integer FELLHOUND = 'nfel'
584 constant integer INFERNAL = 'ninf'
585 constant integer DOOMGUARD = 'nbal'
586 constant integer SATYR = 'nsty'
587 constant integer TRICKSTER = 'nsat'
588 constant integer SHADOWDANCER = 'nsts'
589 constant integer SOULSTEALER = 'nstl'
590 constant integer HELLCALLER = 'nsth'
591 constant integer SKEL_ARCHER = 'nska'
592 constant integer SKEL_MARKSMAN = 'nskm'
593 constant integer SKEL_BURNING = 'nskf'
594 constant integer SKEL_GIANT = 'nskg'
595 constant integer FURBOLG = 'nfrl'
596 constant integer FURBOLG_TRACKER = 'nfrb'
597 constant integer FURBOLG_SHAMAN = 'nfrs'
598 constant integer FURBOLG_CHAMP = 'nfrg'
599 constant integer FURBOLG_ELDER = 'nfre'
600
601 //--------------------------------------------------------------------
602 // NAGA
603 //--------------------------------------------------------------------
604
605 // naga heroes
606 constant integer NAGA_SORCERESS = 'Nngs'
607 constant integer NAGA_VASHJ = 'Hvsh'
608
609 // naga units
610 constant integer NAGA_DRAGON = 'nsnp' // old names
611 constant integer NAGA_WITCH = 'nnsw'
612 constant integer NAGA_SERPENT = 'nwgs'
613 constant integer NAGA_HYDRA = 'nhyc'
614
615 constant integer NAGA_SLAVE = 'nmpe' // peon
616 constant integer NAGA_SNAP_DRAGON = NAGA_DRAGON // weak ranged
617 constant integer NAGA_COUATL = NAGA_SERPENT // weak air
618 constant integer NAGA_SIREN = NAGA_WITCH // caster
619 constant integer NAGA_MYRMIDON = 'nmyr' // knight
620 constant integer NAGA_REAVER = 'nnmg' // footman
621 constant integer NAGA_TURTLE = NAGA_HYDRA // siege
622 constant integer NAGA_ROYAL = 'nnrg' // royal guard
623
624 // naga buildings
625 constant integer NAGA_TEMPLE = 'nntt' // town hall
626 constant integer NAGA_CORAL = 'nnfm' // farm
627 constant integer NAGA_SHRINE = 'nnsa' // sirens & couatls
628 constant integer NAGA_SPAWNING = 'nnsg' // myrm, snap dragon, hydra
629 constant integer NAGA_GUARDIAN = 'nntg' // tower
630 constant integer NAGA_ALTAR = 'nnad' // altar
631
632 // naga upgrades
633 constant integer UPG_NAGA_ARMOR = 'Rnam'
634 constant integer UPG_NAGA_ATTACK = 'Rnat'
635 constant integer UPG_NAGA_ABOLISH = 'Rnsi'
636 constant integer UPG_SIREN = 'Rnsw'
637 constant integer UPG_NAGA_ENSNARE = 'Rnen'
638
639
640 //--------------------------------------------------------------------
641 constant integer M1 = 60
642 constant integer M2 = 2*60
643 constant integer M3 = 3*60
644 constant integer M4 = 4*60
645 constant integer M5 = 5*60
646 constant integer M6 = 6*60
647 constant integer M7 = 7*60
648 constant integer M8 = 8*60
649 constant integer M9 = 9*60
650 constant integer M10 = 10*60
651 constant integer M11 = 11*60
652 constant integer M12 = 12*60
653 constant integer M13 = 13*60
654 constant integer M14 = 14*60
655 constant integer M15 = 15*60
656
657 constant integer EASY = 1
658 constant integer NORMAL = 2
659 constant integer HARD = 3
660 constant integer INSANE = 4 // not used
661
662 constant integer MELEE_NEWBIE = 1
663 constant integer MELEE_NORMAL = 2
664 constant integer MELEE_INSANE = 3
665
666 constant integer ATTACK_CAPTAIN = 1
667 constant integer DEFENSE_CAPTAIN = 2
668 constant integer BOTH_CAPTAINS = 3
669
670 constant integer BUILD_UNIT = 1
671 constant integer BUILD_UPGRADE = 2
672 constant integer BUILD_EXPAND = 3
673
674 constant integer UPKEEP_TIER1 = 50
675 constant integer UPKEEP_TIER2 = 80
676
677 //--------------------------------------------------------------------
678
679 player ai_player
680
681 integer sleep_seconds
682 integer total_gold = 0
683 integer total_wood = 0
684 integer gold_buffer = 0 // usually for potion money
685 integer difficulty = NORMAL
686 integer exp_seen = 0
687 integer racial_farm = 'hhou'
688 integer hero_id = 'Hamg'
689 integer hero_id2 = 'Hmkg'
690 integer hero_id3 = 'Hpal'
691 integer array skill
692 integer array skills1
693 integer array skills2
694 integer array skills3
695 integer max_hero_level = 0
696
697 integer array harass_qty
698 integer array harass_max
699 integer array harass_units
700 integer harass_length = 0
701
702 integer array defense_qty
703 integer array defense_units
704 integer defense_length = 0
705
706 integer array build_qty
707 integer array build_type
708 integer array build_item
709 integer array build_town
710 integer build_length = 0
711
712 integer campaign_gold_peons = 5
713 integer campaign_wood_peons = 3
714 integer campaign_basics_speed = 5
715
716 integer min_creeps = -1
717 integer max_creeps = -1
718
719 boolean harvest_town1 = true
720 boolean harvest_town2 = true
721 boolean harvest_town3 = true
722 boolean do_campaign_farms = true
723 boolean two_heroes = false
724 boolean allow_air_creeps = false
725 boolean take_exp = false
726 boolean allow_signal_abort = false
727 boolean ready_for_zeppelin = true
728 boolean get_zeppelin = false
729
730 boolean build_campaign_attackers = true
731
732 boolean do_debug_cheats = false
733 boolean trace_on = true
734 boolean zep_next_wave = false
735 boolean form_group_timeouts = true
736 endglobals
737
738 //============================================================================
739 function PlayerEx takes integer slot returns player
740 return Player(slot-1)
741 endfunction
742
743 //============================================================================
744 function Trace takes string message returns nothing
745 if trace_on then
746 call DisplayText(GetAiPlayer(),message)
747 endif
748 endfunction
749
750 //============================================================================
751 function TraceI takes string message, integer val returns nothing
752 if trace_on then
753 call DisplayTextI(GetAiPlayer(),message,val)
754 endif
755 endfunction
756
757 //============================================================================
758 function TraceII takes string message, integer v1, integer v2 returns nothing
759 if trace_on then
760 call DisplayTextII(GetAiPlayer(),message,v1,v2)
761 endif
762 endfunction
763
764 //============================================================================
765 function TraceIII takes string message, integer v1, integer v2, integer v3 returns nothing
766 if trace_on then
767 call DisplayTextIII(GetAiPlayer(),message,v1,v2,v3)
768 endif
769 endfunction
770
771 //============================================================================
772 function InitAI takes nothing returns nothing
773 set ai_player = Player(GetAiPlayer())
774 set sleep_seconds = 0
775 call StopGathering()
776 endfunction
777
778 //============================================================================
779 function StandardAI takes code heroes, code peons, code attacks returns nothing
780
781 local boolean isNewbie = (MeleeDifficulty() == MELEE_NEWBIE)
782
783 call InitAI()
784
785 call SetMeleeAI()
786
787 call SetDefendPlayer(true)
788 call SetGroupsFlee(not isNewbie)
789 call SetHeroesBuyItems(not isNewbie)
790 call SetHeroesFlee(true)
791 call SetHeroesTakeItems(true)
792 call SetIgnoreInjured(true)
793 call SetPeonsRepair(true)
794 call SetSmartArtillery(not isNewbie)
795 call SetTargetHeroes(not isNewbie)
796 call SetUnitsFlee(not isNewbie)
797 call SetWatchMegaTargets(true)
798
799 call CreateCaptains()
800
801 call SetHeroLevels(heroes)
802
803 call Sleep(0.1)
804 call StartThread(peons)
805 call StartThread(attacks)
806 endfunction
807
808 //============================================================================
809 // Utility Functions
810 //============================================================================
811 function Min takes integer A, integer B returns integer
812 if A < B then
813 return A
814 else
815 return B
816 endif
817 endfunction
818
819 function Max takes integer A, integer B returns integer
820 if A > B then
821 return A
822 else
823 return B
824 endif
825 endfunction
826
827 function SetZepNextWave takes nothing returns nothing
828 set zep_next_wave = true
829 endfunction
830
831 function SuicideSleep takes integer seconds returns nothing
832 set sleep_seconds = sleep_seconds - seconds
833 loop
834 exitwhen seconds <= 0
835 exitwhen allow_signal_abort and CommandsWaiting() != 0
836
837 if seconds >= 5 then
838 call Sleep(5)
839 set seconds = seconds - 5
840 else
841 call Sleep(seconds)
842 set seconds = 0
843 endif
844 endloop
845 endfunction
846
847 //============================================================================
848 function WaitForSignal takes nothing returns integer
849 local integer cmd
850 local boolean display = false //xxx
851 loop
852 exitwhen CommandsWaiting() != 0
853
854 //xxx
855 call Trace("waiting for a signal to begin AI script...\n")
856 set display = true
857 call Sleep(2)
858 exitwhen CommandsWaiting() != 0
859 call Sleep(2)
860 exitwhen CommandsWaiting() != 0
861 call Sleep(2)
862 exitwhen CommandsWaiting() != 0
863 call Sleep(2)
864 exitwhen CommandsWaiting() != 0
865 call Sleep(2)
866 //xxx
867
868 endloop
869
870 //xxx
871 if display then
872 call Trace("signal received, beginning AI script\n")
873 endif
874 //xxx
875
876 set cmd = GetLastCommand()
877 call PopLastCommand()
878 return cmd
879 endfunction
880
881 //============================================================================
882 function SetWoodPeons takes integer count returns nothing
883 set campaign_wood_peons = count
884 endfunction
885
886 //============================================================================
887 function SetGoldPeons takes integer count returns nothing
888 set campaign_gold_peons = count
889 endfunction
890
891 //============================================================================
892 function SetHarvestLumber takes boolean harvest returns nothing
893 if harvest then
894 set campaign_wood_peons = 3
895 else
896 set campaign_wood_peons = 0
897 endif
898 endfunction
899
900 //============================================================================
901 function SetFormGroupTimeouts takes boolean state returns nothing
902 set form_group_timeouts = state
903 endfunction
904
905 //============================================================================
906 function DoCampaignFarms takes boolean state returns nothing
907 set do_campaign_farms = state
908 endfunction
909
910 //============================================================================
911 function GetMinorCreep takes nothing returns unit
912 return GetCreepCamp(0,9,false)
913 endfunction
914
915 //============================================================================
916 function GetMajorCreep takes nothing returns unit
917 return GetCreepCamp(10,100,allow_air_creeps)
918 endfunction
919
920 //============================================================================
921 function GetGold takes nothing returns integer
922 return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_GOLD)
923 endfunction
924
925 //============================================================================
926 function GetWood takes nothing returns integer
927 return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_LUMBER)
928 endfunction
929
930 //============================================================================
931 function InitBuildArray takes nothing returns nothing
932 set build_length = 0
933 endfunction
934
935 //============================================================================
936 function InitAssaultGroup takes nothing returns nothing
937 set harass_length = 0
938 endfunction
939
940 //============================================================================
941 function InitDefenseGroup takes nothing returns nothing
942 set defense_length = 0
943 endfunction
944
945 //============================================================================
946 function InitMeleeGroup takes nothing returns nothing
947 call InitAssaultGroup()
948 call RemoveInjuries()
949 call RemoveSiege()
950 endfunction
951
952 //============================================================================
953 function PrepFullSuicide takes nothing returns nothing
954 call InitAssaultGroup()
955 call InitDefenseGroup()
956 set campaign_gold_peons = 0
957 set campaign_wood_peons = 0
958 endfunction
959
960 //============================================================================
961 function SetReplacements takes integer easy, integer med, integer hard returns nothing
962 if difficulty == EASY then
963 call SetReplacementCount(easy)
964 elseif difficulty == NORMAL then
965 call SetReplacementCount(med)
966 else
967 call SetReplacementCount(hard)
968 endif
969 endfunction
970
971 //============================================================================
972 function StartTownBuilder takes code func returns nothing
973 call StartThread(func)
974 endfunction
975
976 //============================================================================
977 function SetBuildAll takes integer t, integer qty, integer unitid, integer town returns nothing
978 if qty > 0 then
979 set build_qty[build_length] = qty
980 set build_type[build_length] = t
981 set build_item[build_length] = unitid
982 set build_town[build_length] = town
983 set build_length = build_length + 1
984 endif
985 endfunction
986
987 //============================================================================
988 function SetBuildUnit takes integer qty, integer unitid returns nothing
989 call SetBuildAll(BUILD_UNIT,qty,unitid,-1)
990 endfunction
991
992 //============================================================================
993 function SetBuildNext takes integer qty, integer unitid returns nothing
994 local integer has = GetUnitCount(unitid)
995 if has >= qty then
996 return
997 endif
998 call SetBuildAll(BUILD_UNIT,GetUnitCountDone(unitid)+1,unitid,-1)
999 endfunction
1000
1001 //============================================================================
1002 function SetBuildUnitEx takes integer easy, integer med, integer hard, integer unitid returns nothing
1003 if difficulty == EASY then
1004 call SetBuildAll(BUILD_UNIT,easy,unitid,-1)
1005 elseif difficulty == NORMAL then
1006 call SetBuildAll(BUILD_UNIT,med,unitid,-1)
1007 else
1008 call SetBuildAll(BUILD_UNIT,hard,unitid,-1)
1009 endif
1010 endfunction
1011
1012 //============================================================================
1013 function SecondaryTown takes integer town, integer qty, integer unitid returns nothing
1014 call SetBuildAll(BUILD_UNIT,qty,unitid,town)
1015 endfunction
1016
1017 //============================================================================
1018 function SecTown takes integer town, integer qty, integer unitid returns nothing
1019 call SetBuildAll(BUILD_UNIT,qty,unitid,town)
1020 endfunction
1021
1022 //============================================================================
1023 function SetBuildUpgr takes integer qty, integer unitid returns nothing
1024 if MeleeDifficulty() != MELEE_NEWBIE or qty == 1 then
1025 call SetBuildAll(BUILD_UPGRADE,qty,unitid,-1)
1026 endif
1027 endfunction
1028
1029 //============================================================================
1030 function SetBuildUpgrEx takes integer easy, integer med, integer hard, integer unitid returns nothing
1031 if difficulty == EASY then
1032 call SetBuildAll(BUILD_UPGRADE,easy,unitid,-1)
1033 elseif difficulty == NORMAL then
1034 call SetBuildAll(BUILD_UPGRADE,med,unitid,-1)
1035 else
1036 call SetBuildAll(BUILD_UPGRADE,hard,unitid,-1)
1037 endif
1038 endfunction
1039
1040 //============================================================================
1041 function SetBuildExpa takes integer qty, integer unitid returns nothing
1042 call SetBuildAll(BUILD_EXPAND,qty,unitid,-1)
1043 endfunction
1044
1045 //============================================================================
1046 function StartUpgrade takes integer level, integer upgid returns boolean
1047 local integer gold_cost
1048 local integer wood_cost
1049
1050 if GetUpgradeLevel(upgid) >= level then
1051 return true
1052 endif
1053
1054 set gold_cost = GetUpgradeGoldCost(upgid)
1055 if total_gold < gold_cost then
1056 return false
1057 endif
1058
1059 set wood_cost = GetUpgradeWoodCost(upgid)
1060 if total_wood < wood_cost then
1061 return false
1062 endif
1063
1064 return SetUpgrade(upgid)
1065 endfunction
1066
1067 //============================================================================
1068 function BuildFactory takes integer unitid returns nothing
1069 if GetGold() > 1000 and GetWood() > 500 then
1070 call SetBuildUnit( 2, unitid )
1071 else
1072 call SetBuildUnit( 1, unitid )
1073 endif
1074 endfunction
1075
1076 //============================================================================
1077 function HallsCompleted takes integer unitid returns boolean
1078 return GetUnitCount(unitid) == GetUnitCountDone(unitid)
1079 endfunction
1080
1081 //============================================================================
1082 function GuardSecondary takes integer townid, integer qty, integer unitid returns nothing
1083 if TownHasHall(townid) and TownHasMine(townid) then
1084 call SecondaryTown( townid, qty, unitid )
1085 endif
1086 endfunction
1087
1088 //============================================================================
1089 function GetUnitCountEx takes integer unitid, boolean only_done, integer townid returns integer
1090 if townid == -1 then
1091 if only_done then
1092 return GetUnitCountDone(unitid)
1093 else
1094 return GetUnitCount(unitid)
1095 endif
1096 else
1097 return GetTownUnitCount(unitid,townid,only_done)
1098 endif
1099 endfunction
1100
1101 //============================================================================
1102 function TownCountEx takes integer unitid, boolean only_done, integer townid returns integer
1103
1104 local integer have_qty = GetUnitCountEx(unitid,only_done,townid)
1105
1106 if unitid == TOWN_HALL then
1107 set have_qty = have_qty + GetUnitCountEx(KEEP,false,townid) + GetUnitCountEx(CASTLE,false,townid)
1108 elseif unitid == KEEP then
1109 set have_qty = have_qty + GetUnitCountEx(CASTLE,false,townid)
1110
1111 elseif unitid == WATCH_TOWER then
1112 set have_qty = have_qty + GetUnitCountEx(GUARD_TOWER,false,townid) + GetUnitCountEx(CANNON_TOWER,false,townid) + GetUnitCountEx(ARCANE_TOWER,false,townid)
1113
1114 elseif unitid == PEASANT then
1115 set have_qty = have_qty + GetUnitCountEx(MILITIA,false,townid)
1116
1117 elseif unitid == GREAT_HALL then
1118 set have_qty = have_qty + GetUnitCountEx(STRONGHOLD,false,townid) + GetUnitCountEx(FORTRESS,false,townid)
1119 elseif unitid == STRONGHOLD then
1120 set have_qty = have_qty + GetUnitCountEx(FORTRESS,false,townid)
1121
1122 elseif unitid == HEAD_HUNTER then
1123 set have_qty = have_qty + GetUnitCountEx(BERSERKER,false,townid)
1124
1125 elseif unitid == SPIRIT_WALKER then
1126 set have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER_M,false,townid)
1127 elseif unitid == SPIRIT_WALKER_M then
1128 set have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER,only_done,townid)
1129
1130 elseif unitid == NECROPOLIS_1 then
1131 set have_qty = have_qty + GetUnitCountEx(NECROPOLIS_2,false,townid) + GetUnitCountEx(NECROPOLIS_3,false,townid)
1132 elseif unitid == NECROPOLIS_2 then
1133 set have_qty = have_qty + GetUnitCountEx(NECROPOLIS_3,false,townid)
1134
1135 elseif unitid == ZIGGURAT_1 then
1136 set have_qty = have_qty + GetUnitCountEx(ZIGGURAT_2,false,townid) + GetUnitCountEx(ZIGGURAT_FROST,false,townid)
1137
1138 elseif unitid == GARGOYLE then
1139 set have_qty = have_qty + GetUnitCountEx(GARGOYLE_MORPH,false,townid)
1140
1141 elseif unitid == TREE_LIFE then
1142 set have_qty = have_qty + GetUnitCountEx(TREE_AGES,false,townid) + GetUnitCountEx(TREE_ETERNITY,false,townid)
1143 elseif unitid == TREE_AGES then
1144 set have_qty = have_qty + GetUnitCountEx(TREE_ETERNITY,false,townid)
1145
1146 elseif unitid == DRUID_TALON then
1147 set have_qty = have_qty + GetUnitCountEx(DRUID_TALON_M,false,townid)
1148 elseif unitid == DRUID_TALON_M then
1149 set have_qty = have_qty + GetUnitCountEx(DRUID_TALON,only_done,townid)
1150
1151 elseif unitid == DRUID_CLAW then
1152 set have_qty = have_qty + GetUnitCountEx(DRUID_CLAW_M,false,townid)
1153 elseif unitid == DRUID_CLAW_M then
1154 set have_qty = have_qty + GetUnitCountEx(DRUID_CLAW,only_done,townid)
1155
1156 elseif unitid == ILLIDAN then
1157 set have_qty = have_qty + GetUnitCountEx(ILLIDAN_DEMON,false,townid)
1158
1159 endif
1160 return have_qty
1161 endfunction
1162
1163 //============================================================================
1164 function TownCountDone takes integer base returns integer
1165 return TownCountEx(base,true,-1)
1166 endfunction
1167
1168 //============================================================================
1169 function TownCount takes integer base returns integer
1170 return TownCountEx(base,false,-1)
1171 endfunction
1172
1173 //============================================================================
1174 function BasicExpansion takes boolean build_it, integer unitid returns nothing
1175 if build_it and HallsCompleted(unitid) then
1176 call SetBuildExpa( TownCount(unitid)+1, unitid )
1177 endif
1178 endfunction
1179
1180 //============================================================================
1181 function UpgradeAll takes integer baseid, integer newid returns nothing
1182 call SetBuildUnit( TownCountDone(baseid), newid )
1183 endfunction
1184
1185 //============================================================================
1186 function TownCountTown takes integer base, integer townid returns integer
1187 return TownCountEx(base,false,townid)
1188 endfunction
1189
1190 //============================================================================
1191 // FoodPool
1192 //============================================================================
1193 function FoodPool takes integer food, boolean weak, integer id1, integer use1, boolean strong, integer id2, integer use2 returns nothing
1194 if strong then
1195 call SetBuildUnit( (food - use1 * TownCount(id1)) / use2, id2 )
1196 elseif weak then
1197 call SetBuildUnit( (food - use2 * TownCount(id2)) / use1, id1 )
1198 endif
1199 endfunction
1200
1201 //============================================================================
1202 // MeleeTownHall
1203 //============================================================================
1204 function MeleeTownHall takes integer townid, integer unitid returns nothing
1205 if TownHasMine(townid) and not TownHasHall(townid) then
1206 call SecondaryTown ( townid, 1, unitid )
1207 endif
1208 endfunction
1209
1210 //============================================================================
1211 function WaitForUnits takes integer unitid, integer qty returns nothing
1212 loop
1213 exitwhen TownCountDone(unitid) == qty
1214 call Sleep(2)
1215 endloop
1216 endfunction
1217
1218 //============================================================================
1219 function StartUnit takes integer ask_qty, integer unitid, integer town returns boolean
1220 local integer have_qty
1221 local integer need_qty
1222 local integer afford_gold
1223 local integer afford_wood
1224 local integer afford_qty
1225 local integer gold_cost
1226 local integer wood_cost
1227
1228 //------------------------------------------------------------------------
1229 // if we have all we're asking for then make nothing
1230 //
1231 if town == -1 then
1232 set have_qty = TownCount(unitid)
1233 else
1234 set have_qty = TownCountTown(unitid,town)
1235 endif
1236
1237 if have_qty >= ask_qty then
1238 return true
1239 endif
1240 set need_qty = ask_qty - have_qty
1241
1242 //------------------------------------------------------------------------
1243 // limit the qty we're requesting to the amount of resources available
1244 //
1245 set gold_cost = GetUnitGoldCost(unitid)
1246 set wood_cost = GetUnitWoodCost(unitid)
1247
1248 if gold_cost == 0 then
1249 set afford_gold = need_qty
1250 else
1251 set afford_gold = total_gold / gold_cost
1252 endif
1253 if afford_gold < need_qty then
1254 set afford_qty = afford_gold
1255 else
1256 set afford_qty = need_qty
1257 endif
1258
1259 if wood_cost == 0 then
1260 set afford_wood = need_qty
1261 else
1262 set afford_wood = total_wood / wood_cost
1263 endif
1264 if afford_wood < afford_qty then
1265 set afford_qty = afford_wood
1266 endif
1267
1268 // if we're waiting on gold/wood; pause build orders
1269 if afford_qty < 1 then
1270 return false
1271 endif
1272
1273 //------------------------------------------------------------------------
1274 // whether we make right now what we're requesting or not, assume we will
1275 // and deduct the cost of the units from our fake gold total right away
1276 //
1277 set total_gold = total_gold - gold_cost * need_qty
1278 set total_wood = total_wood - wood_cost * need_qty
1279
1280 if total_gold < 0 then
1281 set total_gold = 0
1282 endif
1283 if total_wood < 0 then
1284 set total_wood = 0
1285 endif
1286
1287 //------------------------------------------------------------------------
1288 // give the AI a chance to make the units (it may not be able to right now
1289 // but that doesn't stop us from trying other units after this as long
1290 // as we have enough money to make this AND the needed, unbuilt ones)
1291 //
1292 return SetProduce(afford_qty,unitid,town)
1293 endfunction
1294
1295 //============================================================================
1296 function WaitForTown takes integer towns, integer townid returns nothing
1297 local integer i = 0
1298 loop
1299 call Sleep(10)
1300 exitwhen TownCount(townid) >= towns
1301 set i = i + 1
1302 exitwhen i == 12
1303 endloop
1304 endfunction
1305
1306 //============================================================================
1307 function StartExpansion takes integer qty, integer hall returns boolean
1308 local integer count
1309 local integer town
1310 local unit peon
1311 local integer gold_cost
1312
1313 set count = TownCount(hall)
1314 if count >= qty then
1315 return true
1316 endif
1317
1318 set town = GetNextExpansion()
1319 if town == -1 then
1320 return true
1321 endif
1322
1323 set take_exp = true
1324
1325 set gold_cost = GetUnitGoldCost(hall)
1326 if gold_cost > total_gold then
1327 return false
1328 endif
1329 set total_gold = total_gold - gold_cost
1330
1331 if GetExpansionFoe() != null then
1332 return true
1333 endif
1334
1335 set peon = GetExpansionPeon()
1336 if peon != null then
1337 return SetExpansion(peon,hall)
1338 endif
1339
1340 return true
1341 endfunction
1342
1343 //============================================================================
1344 function OneBuildLoop takes nothing returns nothing
1345 local integer index = 0
1346 local integer qty
1347 local integer id
1348 local integer tp
1349
1350 set total_gold = GetGold() - gold_buffer
1351 set total_wood = GetWood()
1352
1353 loop
1354 exitwhen index == build_length
1355
1356 set qty = build_qty [index]
1357 set id = build_item[index]
1358 set tp = build_type[index]
1359
1360 //--------------------------------------------------------------------
1361 if tp == BUILD_UNIT then
1362 if not StartUnit(qty,id,build_town[index]) then
1363 return
1364 endif
1365
1366 //--------------------------------------------------------------------
1367 elseif tp == BUILD_UPGRADE then
1368 call StartUpgrade(qty,id)
1369
1370 //--------------------------------------------------------------------
1371 else // tp == BUILD_EXPAND
1372 if not StartExpansion(qty,id) then
1373 return
1374 endif
1375 endif
1376
1377 set index = index + 1
1378 endloop
1379 endfunction
1380
1381 //============================================================================
1382 function StaggerSleep takes real base, real spread returns nothing
1383 call Sleep(base + spread * I2R(GetAiPlayer()) / I2R(GetPlayers()))
1384 endfunction
1385
1386 //============================================================================
1387 function BuildLoop takes nothing returns nothing
1388 call OneBuildLoop()
1389 call StaggerSleep(1,2)
1390 loop
1391 call OneBuildLoop()
1392 call Sleep(2)
1393 endloop
1394 endfunction
1395
1396 //============================================================================
1397 function StartBuildLoop takes nothing returns nothing
1398 call StartThread(function BuildLoop)
1399 endfunction
1400
1401 //============================================================================
1402 function SetInitialWave takes integer seconds returns nothing
1403 set sleep_seconds = seconds
1404 endfunction
1405
1406 //============================================================================
1407 function AddSleepSeconds takes integer seconds returns nothing
1408 set sleep_seconds = sleep_seconds + seconds
1409 endfunction
1410
1411 //============================================================================
1412 function SleepForever takes nothing returns nothing
1413 call Trace("going to sleep forever\n") //xxx
1414 loop
1415 call Sleep(100)
1416 endloop
1417 endfunction
1418
1419 //============================================================================
1420 function PlayGame takes nothing returns nothing
1421 call StartBuildLoop()
1422 call SleepForever()
1423 endfunction
1424
1425 //============================================================================
1426 function ConvertNeeds takes integer unitid returns nothing
1427 if GetUnitCount(unitid) < 1 then
1428 call StartUnit(1,unitid,-1)
1429 endif
1430 endfunction
1431
1432 //============================================================================
1433 function Conversions takes integer desire, integer unitid returns nothing
1434
1435 if GetUnitCount(unitid) >= desire then
1436 return
1437 endif
1438
1439 if unitid == HIPPO_RIDER then
1440 call ConvertNeeds(ARCHER)
1441 call ConvertNeeds(HIPPO)
1442 call MergeUnits(desire,ARCHER,HIPPO,HIPPO_RIDER)
1443
1444 elseif unitid == BLK_SPHINX then
1445 call ConvertNeeds(OBS_STATUE)
1446 call ConvertUnits(desire,OBS_STATUE)
1447 endif
1448 endfunction
1449
1450 //============================================================================
1451 function SetAssaultGroup takes integer qty, integer max, integer unitid returns nothing
1452 call Conversions(max,unitid)
1453
1454 if qty <= 0 and TownCountDone(unitid) == 0 then
1455 return
1456 endif
1457 set harass_qty[harass_length] = qty
1458 set harass_max[harass_length] = max
1459 set harass_units[harass_length] = unitid
1460 set harass_length = harass_length + 1
1461 endfunction
1462
1463 //============================================================================
1464 function Interleave3 takes integer e1, integer m1, integer h1, integer u1, integer e2, integer m2, integer h2, integer u2, integer e3, integer m3, integer h3, integer u3 returns nothing
1465 local integer i1 = 1
1466 local integer i2 = 1
1467 local integer i3 = 1
1468 local integer q1
1469 local integer q2
1470 local integer q3
1471
1472 if difficulty == EASY then
1473 set q1 = e1
1474 set q2 = e2
1475 set q3 = e3
1476 elseif difficulty == NORMAL then
1477 set q1 = m1
1478 set q2 = m2
1479 set q3 = m3
1480 else // difficulty == HARD
1481 set q1 = h1
1482 set q2 = h2
1483 set q3 = h3
1484 endif
1485
1486 loop
1487 exitwhen q1<=0 and q2<=0 and q3<=0
1488
1489 if q1 > 0 then
1490 call SetAssaultGroup(i1,i1,u1)
1491 set q1 = q1 - 1
1492 set i1 = i1 + 1
1493 endif
1494
1495 if q2 > 0 then
1496 call SetAssaultGroup(i2,i2,u2)
1497 set q2 = q2 - 1
1498 set i2 = i2 + 1
1499 endif
1500
1501 if q3 > 0 then
1502 call SetAssaultGroup(i3,i3,u3)
1503 set q3 = q3 - 1
1504 set i3 = i3 + 1
1505 endif
1506 endloop
1507 endfunction
1508
1509 //============================================================================
1510 function SetMeleeGroup takes integer unitid returns nothing
1511 if unitid == hero_id then
1512 call SetAssaultGroup(1,9,unitid)
1513 else
1514 call SetAssaultGroup((TownCountDone(unitid)*3)/4,20,unitid)
1515 endif
1516 endfunction
1517
1518 //============================================================================
1519 function CampaignDefender takes integer level, integer qty, integer unitid returns nothing
1520 if qty > 0 and difficulty >= level then
1521 set defense_qty[defense_length] = qty
1522 set defense_units[defense_length] = unitid
1523 set defense_length = defense_length + 1
1524 call Conversions(qty,unitid)
1525 call SetBuildUnit(qty,unitid)
1526 endif
1527 endfunction
1528
1529 //============================================================================
1530 function CampaignDefenderEx takes integer easy, integer med, integer hard, integer unitid returns nothing
1531 if difficulty == EASY then
1532 call CampaignDefender(EASY,easy,unitid)
1533 elseif difficulty == NORMAL then
1534 call CampaignDefender(NORMAL,med,unitid)
1535 else
1536 call CampaignDefender(HARD,hard,unitid)
1537 endif
1538 endfunction
1539
1540 //============================================================================
1541 function CampaignAttacker takes integer level, integer qty, integer unitid returns nothing
1542 if qty > 0 and difficulty >= level then
1543 call SetAssaultGroup(qty,qty,unitid)
1544 endif
1545 endfunction
1546
1547 //============================================================================
1548 function CampaignAttackerEx takes integer easy, integer med, integer hard, integer unitid returns nothing
1549 if difficulty == EASY then
1550 call CampaignAttacker(EASY,easy,unitid)
1551 elseif difficulty == NORMAL then
1552 call CampaignAttacker(NORMAL,med,unitid)
1553 else
1554 call CampaignAttacker(HARD,hard,unitid)
1555 endif
1556 endfunction
1557
1558 //============================================================================
1559 function FormGroup takes integer seconds, boolean testReady returns nothing
1560 local integer index
1561 local integer count
1562 local integer unitid
1563 local integer desire
1564 local integer readyPercent
1565
1566 // normally test for CaptainReadiness() of 50%
1567 if testReady == true then
1568 set readyPercent = 50
1569 call Trace("forming group, requiring healthy guys\n") //xxx
1570 else
1571 set readyPercent = 0
1572 call Trace("forming group, unit health not important\n") //xxx
1573 endif
1574
1575 call Trace("trying to gather forces\n") //xxx
1576
1577 loop
1578 call SuicideSleep(seconds)
1579 call InitAssault()
1580
1581 set index = 0
1582 loop
1583 exitwhen index == harass_length
1584
1585 set unitid = harass_units[index]
1586 set desire = harass_max[index]
1587 set count = TownCountDone(unitid)
1588
1589 call Conversions(desire,unitid)
1590
1591 if count >= desire then
1592 call AddAssault(desire,unitid)
1593 else
1594 set desire = harass_qty[index]
1595
1596 if count < desire then
1597 call AddAssault(desire,unitid)
1598 else
1599 call AddAssault(count,unitid)
1600 endif
1601 endif
1602
1603 set index = index + 1
1604 endloop
1605
1606 //xxx
1607 if form_group_timeouts and (sleep_seconds < -60) then
1608 call Trace("exit form group -- timeout\n")
1609 elseif CaptainInCombat(true) then
1610 call Trace("exit form group -- can't form while already in combat\n")
1611 elseif CaptainIsFull() and CaptainReadiness() >= readyPercent then
1612 call Trace("exit form group -- ready\n")
1613 endif
1614 //xxx
1615
1616 // time out and send group anyway if time has already expired
1617 exitwhen form_group_timeouts and (sleep_seconds < -60)
1618 exitwhen CaptainInCombat(true)
1619 exitwhen CaptainIsFull() and CaptainReadiness() >= readyPercent
1620 endloop
1621 endfunction
1622
1623 //============================================================================
1624 function WavePrepare takes integer unitid returns integer
1625 return GetUnitBuildTime(unitid)
1626 endfunction
1627
1628 //============================================================================
1629 function PrepTime takes nothing returns integer
1630 local integer unitid
1631 local integer missing
1632 local integer prep
1633 local integer count
1634 local integer largest = 30
1635 local integer index = 0
1636
1637 loop
1638 exitwhen index == harass_length
1639
1640 set unitid = harass_units[index]
1641 set missing = harass_qty[index] + IgnoredUnits(unitid) - TownCount(unitid)
1642 set prep = WavePrepare(unitid) * missing
1643
1644 if prep > largest then
1645 set largest = prep
1646 endif
1647
1648 set index = index + 1
1649 endloop
1650 call TraceI("next wave will require around %d seconds to build and gather\n",largest) //xxx
1651
1652 return largest
1653 endfunction
1654
1655 //============================================================================
1656 function PrepSuicideOnPlayer takes integer seconds returns boolean
1657 local integer wave_prep = PrepTime()
1658 local integer save_length
1659
1660 set save_length = harass_length
1661 set harass_length = 0
1662
1663 call AddSleepSeconds(seconds)
1664 if sleep_seconds-wave_prep > 0 then
1665 call TraceI("going to sleep for %d seconds before gathering next attack wave\n",sleep_seconds-wave_prep) //xxx
1666 call SuicideSleep(sleep_seconds-wave_prep)
1667 endif
1668
1669 call Trace("preparing suicide attack wave\n") //xxx
1670
1671 set harass_length = save_length
1672 if harass_length < 1 then
1673 call Trace("ERROR - no units specificed, exiting early\n") //xxx
1674 return false
1675 endif
1676
1677 return true
1678 endfunction
1679
1680 //============================================================================
1681 function SleepUntilAtGoal takes nothing returns nothing
1682 loop
1683 exitwhen CaptainRetreating()
1684 exitwhen CaptainAtGoal() // reached goal
1685 exitwhen CaptainIsHome() // failed to path and returned home
1686 exitwhen CaptainIsEmpty() // all units died
1687 call SuicideSleep(3)
1688 endloop
1689 endfunction
1690
1691 //============================================================================
1692 function SleepInCombat takes nothing returns nothing
1693 local integer count = 0
1694 debug call Trace("SleepInCombat\n")
1695 loop
1696 loop
1697 exitwhen not CaptainInCombat(true) // goal is cleared
1698 exitwhen CaptainIsEmpty() // duh
1699 call SuicideSleep(1)
1700 endloop
1701
1702 set count = count + 1
1703 exitwhen count >= 8
1704
1705 //xxx this is what it should have been; do this for next patch?
1706 //call SuicideSleep(1)
1707 endloop
1708 debug call Trace("exit SleepInCombat\n")
1709 endfunction
1710
1711 //============================================================================
1712 function AttackMoveXYA takes integer x, integer y returns nothing
1713
1714 if zep_next_wave then
1715 call LoadZepWave(x,y)
1716 set zep_next_wave = false
1717 endif
1718
1719 call AttackMoveXY(x,y)
1720 call SleepUntilAtGoal()
1721 call SleepInCombat()
1722 endfunction
1723
1724 //============================================================================
1725 function SuicideOnPlayerWave takes nothing returns nothing
1726 call Trace("waiting for attack wave to enter combat\n") //xxx
1727 loop
1728 //xxx
1729 if allow_signal_abort and CommandsWaiting() != 0 then
1730 call Trace("ABORT -- attack wave override\n")
1731 endif
1732
1733 if CaptainInCombat(true) then
1734 call Trace("done - captain has entered combat\n")
1735 endif
1736
1737 if CaptainIsEmpty() then
1738 call Trace("done - all units are dead\n")
1739 endif
1740
1741 if sleep_seconds < -300 then
1742 call Trace("done - timeout, took too long to reach engage the enemy\n")
1743 endif
1744 //xxx
1745
1746 exitwhen allow_signal_abort and CommandsWaiting() != 0
1747
1748 exitwhen CaptainInCombat(true)
1749 exitwhen CaptainIsEmpty()
1750 call SuicideSleep(10)
1751 exitwhen sleep_seconds < -300
1752 endloop
1753
1754 call Trace("waiting for attack wave to die\n") //xxx
1755 loop
1756 //xxx
1757 if allow_signal_abort and CommandsWaiting() != 0 then
1758 call Trace("ABORT - attack wave override\n")
1759 endif
1760
1761 if CaptainIsEmpty() then
1762 call Trace("done - all units are dead\n")
1763 endif
1764
1765 if sleep_seconds < -300 then
1766 call Trace("done - timeout, took too long to reach engage the enemy\n")
1767 endif
1768 //xxx
1769
1770 exitwhen allow_signal_abort and CommandsWaiting() != 0
1771
1772 exitwhen CaptainIsEmpty()
1773 call SuicideSleep(10)
1774 exitwhen sleep_seconds < -300
1775 endloop
1776 endfunction
1777
1778 //--------------------------------------------------------------------------------------------------
1779 function CommonSuicideOnPlayer takes boolean standard, boolean bldgs, integer seconds, player p, integer x, integer y returns nothing
1780 local integer save_peons
1781
1782 if not PrepSuicideOnPlayer(seconds) then
1783 return
1784 endif
1785
1786 set save_peons = campaign_wood_peons
1787 set campaign_wood_peons = 0
1788
1789 loop
1790 //xxx
1791 if allow_signal_abort and CommandsWaiting() != 0 then
1792 call Trace("ABORT -- attack wave override\n")
1793 endif
1794 //xxx
1795
1796 exitwhen allow_signal_abort and CommandsWaiting() != 0
1797
1798 loop
1799 exitwhen allow_signal_abort and CommandsWaiting() != 0
1800
1801 call FormGroup(5,true)
1802 exitwhen sleep_seconds <= 0
1803 call TraceI("waiting %d seconds before suicide\n",sleep_seconds) //xxx
1804 endloop
1805
1806 if standard then
1807 if bldgs then
1808 exitwhen SuicidePlayer(p,sleep_seconds >= -60)
1809 else
1810 exitwhen SuicidePlayerUnits(p,sleep_seconds >= -60)
1811 endif
1812 else
1813 call AttackMoveXYA(x,y)
1814 endif
1815
1816 call TraceI("waiting %d seconds before timeout\n",60+sleep_seconds) //xxx
1817 call SuicideSleep(5)
1818 endloop
1819
1820 set campaign_wood_peons = save_peons
1821 set harass_length = 0
1822
1823 call SuicideOnPlayerWave()
1824 endfunction
1825
1826 //--------------------------------------------------------------------------------------------------
1827 function SuicideOnPlayer takes integer seconds, player p returns nothing
1828 call CommonSuicideOnPlayer(true,true,seconds,p,0,0)
1829 endfunction
1830
1831 //--------------------------------------------------------------------------------------------------
1832 function SuicideOnUnits takes integer seconds, player p returns nothing
1833 call CommonSuicideOnPlayer(true,false,seconds,p,0,0)
1834 endfunction
1835
1836 //--------------------------------------------------------------------------------------------------
1837 function SuicideOnPoint takes integer seconds, player p, integer x, integer y returns nothing
1838 call CommonSuicideOnPlayer(false,false,seconds,p,x,y)
1839 endfunction
1840
1841 //============================================================================
1842 function SuicideUntilSignal takes integer seconds, player p returns nothing
1843 local integer save
1844 local integer wave_prep = PrepTime()
1845
1846 loop
1847 call AddSleepSeconds(seconds)
1848 if sleep_seconds-wave_prep > 0 then
1849 call SuicideSleep(sleep_seconds-wave_prep)
1850 endif
1851
1852 set save = campaign_wood_peons
1853 set campaign_wood_peons = 0
1854 loop
1855 loop
1856 call FormGroup(5, true)
1857 exitwhen sleep_seconds <= 0
1858 exitwhen CommandsWaiting() != 0
1859 endloop
1860 exitwhen SuicidePlayer(p,sleep_seconds >= -60)
1861 exitwhen CommandsWaiting() != 0
1862 call SuicideSleep(3)
1863 endloop
1864 set campaign_wood_peons = save
1865
1866 loop
1867 exitwhen CaptainIsEmpty()
1868 exitwhen CommandsWaiting() != 0
1869 call SuicideSleep(5)
1870 endloop
1871 exitwhen CommandsWaiting() != 0
1872 endloop
1873 endfunction
1874
1875 //--------------------------------------------------------------------------------------------------
1876 function SuicideOnce takes integer easy, integer med, integer hard, integer unitid returns nothing
1877 if difficulty == EASY then
1878 call SuicideUnit(easy,unitid)
1879 elseif difficulty == NORMAL then
1880 call SuicideUnit(med,unitid)
1881 else
1882 call SuicideUnit(hard,unitid)
1883 endif
1884 endfunction
1885
1886 //--------------------------------------------------------------------------------------------------
1887 function SuicideUnitA takes integer unitid returns nothing
1888 if unitid != 0 then
1889 call SuicideUnit(1,unitid)
1890 endif
1891 call Sleep(0.1)
1892 endfunction
1893
1894 //--------------------------------------------------------------------------------------------------
1895 function SuicideUnitB takes integer unitid, integer playerid returns nothing
1896 if unitid != 0 then
1897 call SuicideUnitEx(1,unitid,playerid)
1898 endif
1899 call Sleep(0.1)
1900 endfunction
1901
1902 //--------------------------------------------------------------------------------------------------
1903 function SuicideUnits takes integer u1, integer u2, integer u3, integer u4, integer u5, integer u6, integer u7, integer u8, integer u9, integer uA returns nothing
1904 call Trace("MASS SUICIDE - this script is now technically done\n") //xxx
1905
1906 call PrepFullSuicide()
1907 loop
1908 call SuicideUnitA(u1)
1909 call SuicideUnitA(u2)
1910 call SuicideUnitA(u3)
1911 call SuicideUnitA(u4)
1912 call SuicideUnitA(u5)
1913 call SuicideUnitA(u6)
1914 call SuicideUnitA(u7)
1915 call SuicideUnitA(u8)
1916 call SuicideUnitA(u9)
1917 call SuicideUnitA(uA)
1918 endloop
1919 endfunction
1920
1921 //--------------------------------------------------------------------------------------------------
1922 function SuicideUnitsEx takes integer playerid, integer u1, integer u2, integer u3, integer u4, integer u5, integer u6, integer u7, integer u8, integer u9, integer uA returns nothing
1923 call Trace("MASS SUICIDE - this script is now technically done\n") //xxx
1924
1925 call PrepFullSuicide()
1926 loop
1927 call SuicideUnitB(u1,playerid)
1928 call SuicideUnitB(u2,playerid)
1929 call SuicideUnitB(u3,playerid)
1930 call SuicideUnitB(u4,playerid)
1931 call SuicideUnitB(u5,playerid)
1932 call SuicideUnitB(u6,playerid)
1933 call SuicideUnitB(u7,playerid)
1934 call SuicideUnitB(u8,playerid)
1935 call SuicideUnitB(u9,playerid)
1936 call SuicideUnitB(uA,playerid)
1937 endloop
1938 endfunction
1939
1940 //--------------------------------------------------------------------------------------------------
1941 function SuicideOnPlayerEx takes integer easy, integer med, integer hard, player p returns nothing
1942 if difficulty == EASY then
1943 call SuicideOnPlayer(easy,p)
1944 elseif difficulty == NORMAL then
1945 call SuicideOnPlayer(med,p)
1946 else
1947 call SuicideOnPlayer(hard,p)
1948 endif
1949 endfunction
1950
1951 //--------------------------------------------------------------------------------------------------
1952 function SuicideOnUnitsEx takes integer easy, integer med, integer hard, player p returns nothing
1953 if difficulty == EASY then
1954 call SuicideOnUnits(easy,p)
1955 elseif difficulty == NORMAL then
1956 call SuicideOnUnits(med,p)
1957 else
1958 call SuicideOnUnits(hard,p)
1959 endif
1960 endfunction
1961
1962 //--------------------------------------------------------------------------------------------------
1963 function SuicideOnPointEx takes integer easy, integer med, integer hard, player p, integer x, integer y returns nothing
1964 if difficulty == EASY then
1965 call SuicideOnPoint(easy,p,x,y)
1966 elseif difficulty == NORMAL then
1967 call SuicideOnPoint(med,p,x,y)
1968 else
1969 call SuicideOnPoint(hard,p,x,y)
1970 endif
1971 endfunction
1972
1973 //============================================================================
1974 function ForeverSuicideOnPlayer takes integer seconds, player p returns nothing
1975 local integer length = harass_length
1976 loop
1977 exitwhen allow_signal_abort and CommandsWaiting() != 0
1978 call SuicideOnPlayer(seconds,p)
1979 set harass_length = length
1980 endloop
1981 endfunction
1982
1983 //============================================================================
1984 function CommonSleepUntilTargetDead takes unit target, boolean reform returns nothing
1985 loop
1986 exitwhen CaptainRetreating()
1987 exitwhen CaptainReadinessHP() <= 40
1988
1989 exitwhen not UnitAlive(target)
1990 exitwhen UnitInvis(target) and not IsUnitDetected(target,ai_player)
1991
1992 if not TownThreatened() then
1993 call AttackMoveKill(target)
1994 endif
1995
1996 call SuicideSleep(3)
1997
1998 if reform and sleep_seconds < -40 then
1999 if CaptainInCombat(true) then
2000 set sleep_seconds = sleep_seconds + 5
2001 else
2002 set sleep_seconds = 0
2003 call FormGroup(1,false)
2004 endif
2005 endif
2006 endloop
2007 endfunction
2008
2009 //============================================================================
2010 function SleepUntilTargetDead takes unit target returns nothing
2011 call CommonSleepUntilTargetDead(target,false)
2012 endfunction
2013
2014 //============================================================================
2015 function ReformUntilTargetDead takes unit target returns nothing
2016 debug call Trace("ReformUntilTargetDead\n")
2017 call CommonSleepUntilTargetDead(target,true)
2018 endfunction
2019
2020 //============================================================================
2021 function AttackMoveKillA takes unit target returns nothing
2022 if target == null then
2023 call SuicideSleep(3)
2024 return
2025 endif
2026
2027 debug call Trace("AttackMoveKillA\n")
2028 call AttackMoveKill(target)
2029 call ReformUntilTargetDead(target)
2030 call SleepInCombat()
2031 endfunction
2032
2033 //============================================================================
2034 function MinorCreepAttack takes nothing returns nothing
2035 local unit target = GetMinorCreep()
2036 call SetAllianceTarget(target)
2037 call FormGroup(3, true)
2038 call AttackMoveKillA(target)
2039 endfunction
2040
2041 //============================================================================
2042 function MajorCreepAttack takes nothing returns nothing
2043 local unit target = GetMajorCreep()
2044 call SetAllianceTarget(target)
2045 call FormGroup(3,true)
2046 call AttackMoveKillA(target)
2047 endfunction
2048
2049 //============================================================================
2050 function CreepAttackEx takes nothing returns nothing
2051 local unit target = GetCreepCamp(min_creeps,max_creeps,allow_air_creeps)
2052 call SetAllianceTarget(target)
2053 call FormGroup(3,true)
2054 call AttackMoveKillA(target)
2055 endfunction
2056
2057 //============================================================================
2058 function AnyPlayerAttack takes nothing returns nothing
2059 local unit hall
2060
2061 set hall = GetEnemyExpansion()
2062 if hall == null then
2063 call StartGetEnemyBase()
2064 loop
2065 exitwhen not WaitGetEnemyBase()
2066 call SuicideSleep(1)
2067 endloop
2068 set hall = GetEnemyBase()
2069 endif
2070
2071 call SetAllianceTarget(hall)
2072 call FormGroup(3,true)
2073 call AttackMoveKillA(hall)
2074 endfunction
2075
2076 //============================================================================
2077 function ExpansionAttack takes nothing returns nothing
2078 local unit creep = GetExpansionFoe()
2079 local integer x
2080
2081 call FormGroup(3, true)
2082 if creep == null then
2083 set x = GetExpansionX()
2084 if x != -1 then
2085 call AttackMoveXYA(x,GetExpansionY())
2086 endif
2087 else
2088 call AttackMoveKillA(creep)
2089 endif
2090 endfunction
2091
2092 //============================================================================
2093 // AddSiege
2094 //============================================================================
2095 function AddSiege takes nothing returns nothing
2096 call SetAssaultGroup( 0, 9, SHADE )
2097 call SetAssaultGroup( 0, 9, MEAT_WAGON )
2098 call SetAssaultGroup( 0, 9, MORTAR )
2099 call SetAssaultGroup( 0, 9, TANK )
2100 call SetAssaultGroup( 0, 9, BALLISTA )
2101 call SetAssaultGroup( 0, 9, CATAPULT )
2102 endfunction
2103
2104 //===========================================================================
2105 // GetAllyCount
2106 //============================================================================
2107 function GetAllyCount takes player whichPlayer returns integer
2108 local integer playerIndex = 0
2109 local integer count = 0
2110 local player indexPlayer
2111
2112 loop
2113 set indexPlayer = Player(playerIndex)
2114
2115 if whichPlayer != indexPlayer then
2116 if GetPlayerAlliance(whichPlayer,indexPlayer,ALLIANCE_PASSIVE) then
2117 if GetPlayerAlliance(indexPlayer,whichPlayer,ALLIANCE_PASSIVE) then
2118 if GetPlayerStructureCount(indexPlayer,true) > 0 then
2119 set count = count + 1
2120 endif
2121 endif
2122 endif
2123 endif
2124
2125 set playerIndex = playerIndex + 1
2126 exitwhen playerIndex == 12
2127 endloop
2128
2129 return count
2130 endfunction
2131
2132 //============================================================================
2133 // SingleMeleeAttack
2134 //============================================================================
2135 function SingleMeleeAttack takes boolean needs_exp, boolean has_siege, boolean major_ok, boolean air_units returns nothing
2136 local boolean can_siege
2137 local real daytime
2138 local unit hall
2139 local unit mega
2140 local unit creep
2141 local unit common
2142 local integer minimum
2143 local boolean allies
2144
2145 call Trace("===SingleMeleeAttack===\n") //xxx
2146
2147 if TownThreatened() then
2148 call Trace("sleep 2, town threatened\n") //xxx
2149 call Sleep(2)
2150 return
2151 endif
2152
2153 // purchase zeppelins
2154 //
2155 if get_zeppelin and GetGold() > 300 and GetWood() > 100 then
2156 call Trace("purchase zep\n") //xxx
2157 call PurchaseZeppelin()
2158 set get_zeppelin = false
2159 set ready_for_zeppelin = false
2160 return
2161 endif
2162 set ready_for_zeppelin = true
2163
2164 // coordinate with allies
2165 //
2166 set allies = GetAllyCount(ai_player) > 0
2167 if allies and MeleeDifficulty() != MELEE_NEWBIE then
2168 set common = GetAllianceTarget()
2169 if common != null then
2170 call Trace("join ally force\n") //xxx
2171 if GetMegaTarget() != null then
2172 call AddSiege()
2173 endif
2174 call FormGroup(3,true)
2175 call AttackMoveKillA(common)
2176 call SetAllianceTarget(null)
2177 return
2178 endif
2179 endif
2180
2181 // take expansions as needed
2182 //
2183 if needs_exp then
2184 call Trace("needs exp\n") //xxx
2185 set creep = GetExpansionFoe()
2186 if creep != null then
2187 call Trace("attack exp\n") //xxx
2188 call SetAllianceTarget(creep)
2189 call FormGroup(3,true)
2190 call AttackMoveKillA(creep)
2191 call Sleep(20)
2192 set take_exp = false
2193 return
2194 endif
2195 endif
2196
2197 // all-out attack if the player is weak
2198 //
2199 if MeleeDifficulty() != MELEE_NEWBIE then
2200 set mega = GetMegaTarget()
2201 if mega != null then
2202 call Trace("MEGA TARGET!!!\n") //xxx
2203 call AddSiege()
2204 call FormGroup(3,true)
2205 call AttackMoveKillA(mega)
2206 return
2207 endif
2208 endif
2209
2210 // deny player an expansion
2211 //
2212 set hall = GetEnemyExpansion()
2213 set daytime = GetFloatGameState(GAME_STATE_TIME_OF_DAY)
2214 set can_siege = has_siege and (air_units or (daytime>=4 and daytime<=12))
2215
2216 if hall!=null and (can_siege or not IsTowered(hall)) then
2217
2218 call Trace("test player town attack\n") //xxx
2219
2220 if MeleeDifficulty() == MELEE_NEWBIE then
2221 set minimum = 3
2222 elseif allies and MeleeDifficulty() == MELEE_NORMAL then
2223 set minimum = 1
2224 else
2225 set minimum = 0 // HARD, INSANE, and NORMAL with no allies
2226 endif
2227
2228 if exp_seen >= minimum then
2229 call Trace("do player town attack\n") //xxx
2230 set exp_seen = 0
2231 call AddSiege()
2232 call SetAllianceTarget(hall)
2233 call FormGroup(3,true)
2234 call AttackMoveKillA(hall)
2235 return
2236 endif
2237
2238 set exp_seen = exp_seen + 1
2239 endif
2240
2241 // attack player's main base when siege is available
2242 //
2243 if can_siege then
2244 call Trace("attack player's town\n") //xxx
2245 call AddSiege()
2246 call AnyPlayerAttack()
2247 return
2248 endif
2249
2250 // extended, more specific method of determining creep levels
2251 //
2252 if min_creeps != -1 then
2253 call TraceI("custom creep attack %d\n",max_creeps) //xxx
2254 call CreepAttackEx()
2255 return
2256 endif
2257
2258 // nothing better to do, so kill a creep camp
2259 //
2260 if major_ok then
2261 call Trace("major creep attack\n") //xxx
2262 call MajorCreepAttack()
2263 return
2264 endif
2265
2266 call Trace("minor creep attack\n") //xxx
2267 call MinorCreepAttack()
2268 endfunction
2269
2270 //============================================================================
2271 function GetZeppelin takes nothing returns nothing
2272 if ready_for_zeppelin then
2273 set get_zeppelin = true
2274 endif
2275 endfunction
2276
2277 //============================================================================
2278 function FoodUsed takes nothing returns integer
2279 return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_FOOD_USED)
2280 endfunction
2281
2282 //============================================================================
2283 function FoodCap takes nothing returns integer
2284 return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_FOOD_CAP)
2285 endfunction
2286
2287 //============================================================================
2288 function FoodSpace takes nothing returns integer
2289 return FoodCap() - FoodUsed()
2290 endfunction
2291
2292 //============================================================================
2293 function FoodAvail takes integer base returns integer
2294 return GetFoodMade(racial_farm) * TownCount(racial_farm) + GetFoodMade(base) * TownCount(base)
2295 endfunction
2296
2297 //============================================================================
2298 function BuildAttackers takes nothing returns nothing
2299 local integer index = 0
2300 local integer unitid
2301 local integer desire
2302 local integer count
2303
2304 loop
2305 exitwhen index == harass_length
2306
2307 set unitid = harass_units[index]
2308 set desire = harass_qty[index] + IgnoredUnits(unitid)
2309 set count = TownCount(unitid)
2310
2311 if count != desire then
2312 if not StartUnit(desire,unitid,-1) then
2313 return
2314 endif
2315 endif
2316
2317 set index = index + 1
2318 endloop
2319 endfunction
2320
2321 //============================================================================
2322 function BuildDefenders takes nothing returns nothing
2323 local integer index = 0
2324 local integer unitid
2325 local integer qty
2326 loop
2327 exitwhen index == defense_length
2328
2329 set unitid = defense_units[index]
2330 set qty = defense_qty[index]
2331
2332 call Conversions(qty,unitid)
2333 call AddDefenders(qty,unitid)
2334
2335 set index = index + 1
2336 endloop
2337 endfunction
2338
2339 //============================================================================
2340 function CampaignBasicsA takes nothing returns nothing
2341 local integer food_each = GetFoodMade(racial_farm)
2342 local integer on_wood
2343
2344 call ClearHarvestAI()
2345
2346 if CaptainInCombat(false) then
2347 set on_wood = 0
2348 else
2349 set on_wood = campaign_wood_peons
2350 endif
2351
2352 call HarvestGold(0,campaign_gold_peons)
2353 call HarvestWood(0,on_wood)
2354
2355 if harvest_town1 then
2356 call HarvestGold(1,campaign_gold_peons)
2357 call HarvestWood(1,on_wood)
2358 endif
2359
2360 if harvest_town2 then
2361 call HarvestGold(2,campaign_gold_peons)
2362 call HarvestWood(2,on_wood)
2363 endif
2364
2365 if harvest_town3 then
2366 call HarvestGold(3,campaign_gold_peons)
2367 call HarvestWood(3,on_wood)
2368 endif
2369
2370 if do_campaign_farms and FoodUsed()+food_each-1 > food_each*(TownCount(racial_farm)+1) then
2371 call StartUnit(TownCount(racial_farm)+1,racial_farm,-1)
2372 endif
2373
2374 if build_campaign_attackers then
2375 call BuildAttackers()
2376 endif
2377
2378 if not CaptainInCombat(false) then
2379 call BuildDefenders()
2380 endif
2381
2382 call FillGuardPosts()
2383 call ReturnGuardPosts()
2384 endfunction
2385
2386 //============================================================================
2387 function CampaignBasics takes nothing returns nothing
2388 call Sleep(1)
2389 call CampaignBasicsA()
2390 call StaggerSleep(1,5)
2391 loop
2392 call CampaignBasicsA()
2393 call Sleep(campaign_basics_speed)
2394 endloop
2395 endfunction
2396
2397 //============================================================================
2398 function CampaignAI takes integer farms, code heroes returns nothing
2399 if GetGameDifficulty() == MAP_DIFFICULTY_EASY then
2400 set difficulty = EASY
2401
2402 call SetTargetHeroes(false)
2403 call SetUnitsFlee(false)
2404
2405 elseif GetGameDifficulty() == MAP_DIFFICULTY_NORMAL then
2406 set difficulty = NORMAL
2407
2408 call SetTargetHeroes(false)
2409 call SetUnitsFlee(false)
2410
2411 elseif GetGameDifficulty() == MAP_DIFFICULTY_HARD then
2412 set difficulty = HARD
2413
2414 call SetPeonsRepair(true)
2415 else
2416 set difficulty = INSANE
2417 endif
2418
2419 call InitAI()
2420 call InitBuildArray()
2421 call InitAssaultGroup()
2422 call CreateCaptains()
2423
2424 call SetNewHeroes(false)
2425 if heroes != null then
2426 call SetHeroLevels(heroes)
2427 endif
2428
2429 call SetHeroesFlee(false)
2430 call SetGroupsFlee(false)
2431 call SetSlowChopping(true)
2432 call GroupTimedLife(false)
2433 call SetCampaignAI()
2434 call Sleep(0.1)
2435
2436 set racial_farm = farms
2437 call StartThread(function CampaignBasics)
2438 call StartBuildLoop()
2439 endfunction
2440
2441 //============================================================================
2442 function UnsummonAll takes nothing returns nothing
2443 local unit bldg
2444 loop
2445 set bldg = GetBuilding(ai_player)
2446 exitwhen bldg==null
2447 call Unsummon(bldg)
2448 call Sleep(2)
2449 endloop
2450 endfunction
2451
2452 //============================================================================
2453 // SkillArrays
2454 //============================================================================
2455 function SkillArrays takes nothing returns integer
2456 local integer level = GetHeroLevelAI()
2457
2458 if level > max_hero_level then
2459 set max_hero_level = level
2460 endif
2461
2462 if GetHeroId() == hero_id then
2463 return skills1[level]
2464 elseif GetHeroId() == hero_id2 then
2465 return skills2[level]
2466 else
2467 return skills3[level]
2468 endif
2469 endfunction
2470
2471 //--------------------------------------------------------------------------------------------------
2472 // SetSkillArray
2473 //--------------------------------------------------------------------------------------------------
2474 function SetSkillArray takes integer index, integer id returns nothing
2475 local integer i = 1
2476
2477 if index == 1 then
2478 if hero_id != id then
2479 return
2480 endif
2481 loop
2482 set skills1[i] = skill[i]
2483 exitwhen i == 10
2484 set i = i + 1
2485 endloop
2486 elseif index == 2 then
2487 if hero_id2 != id then
2488 return
2489 endif
2490 loop
2491 set skills2[i] = skill[i]
2492 exitwhen i == 10
2493 set i = i + 1
2494 endloop
2495 else
2496 if hero_id3 != id then
2497 return
2498 endif
2499 loop
2500 set skills3[i] = skill[i]
2501 exitwhen i == 10
2502 set i = i + 1
2503 endloop
2504 endif
2505 endfunction
2506
2507 //============================================================================
2508 // AwaitMeleeHeroes
2509 //============================================================================
2510 function AwaitMeleeHeroes takes nothing returns nothing
2511 if GetUnitCountDone(hero_id2) > 0 then
2512 set two_heroes = true
2513 endif
2514 loop
2515 exitwhen GetUnitCountDone(hero_id)>0 and (take_exp or (not two_heroes or GetUnitCountDone(hero_id2)>0))
2516 call Sleep(1)
2517 endloop
2518 endfunction
2519
2520 //============================================================================
2521 // PickMeleeHero
2522 //============================================================================
2523 function PickMeleeHero takes race raceid returns integer
2524 local integer first
2525 local integer second
2526 local integer third
2527 local integer last
2528 local integer array heroes
2529
2530 //------------------------------------------------------------------------
2531 if raceid == RACE_HUMAN then
2532 //------------------------------------------------------------------------
2533 set heroes[1] = ARCHMAGE
2534 set heroes[2] = MTN_KING
2535 set heroes[3] = PALADIN
2536 set heroes[4] = BLOOD_MAGE
2537
2538 //------------------------------------------------------------------------
2539 elseif raceid == RACE_ORC then
2540 //------------------------------------------------------------------------
2541 set heroes[1] = BLADE_MASTER
2542 set heroes[2] = FAR_SEER
2543 set heroes[3] = TAUREN_CHIEF
2544 set heroes[4] = SHADOW_HUNTER
2545
2546 //------------------------------------------------------------------------
2547 elseif raceid == RACE_NIGHTELF then
2548 //------------------------------------------------------------------------
2549 set heroes[1] = DEMON_HUNTER
2550 set heroes[2] = KEEPER
2551 set heroes[3] = MOON_BABE
2552 set heroes[4] = WARDEN
2553
2554 //------------------------------------------------------------------------
2555 elseif raceid == RACE_UNDEAD then
2556 //------------------------------------------------------------------------
2557 set heroes[1] = DEATH_KNIGHT
2558 set heroes[2] = DREAD_LORD
2559 set heroes[3] = LICH
2560 set heroes[4] = CRYPT_LORD
2561 else
2562 set hero_id = 0
2563 endif
2564
2565 if VersionCompatible(VERSION_FROZEN_THRONE) then
2566 set last = 4
2567 else
2568 set last = 3
2569 endif
2570
2571 set first = GetRandomInt(1,last)
2572 set second = GetRandomInt(1,last-1)
2573 set third = GetRandomInt(1,last-2)
2574
2575 set hero_id = heroes[first]
2576 set heroes[first] = heroes[last]
2577 set hero_id2 = heroes[second]
2578 set heroes[second] = heroes[last-1]
2579 set hero_id3 = heroes[third]
2580
2581 return hero_id
2582 endfunction
File etc/common.j added (mode: 100644) (index 0000000..df6c15f)
1 //============================================================================
2 // Native types. All native functions take extended handle types when
3 // possible to help prevent passing bad values to native functions
4 //
5 type agent extends handle // all reference counted objects
6 type event extends agent // a reference to an event registration
7 type player extends agent // a single player reference
8 type widget extends agent // an interactive game object with life
9 type unit extends widget // a single unit reference
10 type destructable extends widget
11 type item extends widget
12 type ability extends agent
13 type buff extends ability
14 type force extends agent
15 type group extends agent
16 type trigger extends agent
17 type triggercondition extends agent
18 type triggeraction extends handle
19 type timer extends agent
20 type location extends agent
21 type region extends agent
22 type rect extends agent
23 type boolexpr extends agent
24 type sound extends agent
25 type conditionfunc extends boolexpr
26 type filterfunc extends boolexpr
27 type unitpool extends handle
28 type itempool extends handle
29 type race extends handle
30 type alliancetype extends handle
31 type racepreference extends handle
32 type gamestate extends handle
33 type igamestate extends gamestate
34 type fgamestate extends gamestate
35 type playerstate extends handle
36 type playerscore extends handle
37 type playergameresult extends handle
38 type unitstate extends handle
39 type aidifficulty extends handle
40
41 type eventid extends handle
42 type gameevent extends eventid
43 type playerevent extends eventid
44 type playerunitevent extends eventid
45 type unitevent extends eventid
46 type limitop extends eventid
47 type widgetevent extends eventid
48 type dialogevent extends eventid
49 type unittype extends handle
50
51 type gamespeed extends handle
52 type gamedifficulty extends handle
53 type gametype extends handle
54 type mapflag extends handle
55 type mapvisibility extends handle
56 type mapsetting extends handle
57 type mapdensity extends handle
58 type mapcontrol extends handle
59 type playerslotstate extends handle
60 type volumegroup extends handle
61 type camerafield extends handle
62 type camerasetup extends handle
63 type playercolor extends handle
64 type placement extends handle
65 type startlocprio extends handle
66 type raritycontrol extends handle
67 type blendmode extends handle
68 type texmapflags extends handle
69 type effect extends agent
70 type effecttype extends handle
71 type weathereffect extends handle
72 type terraindeformation extends handle
73 type fogstate extends handle
74 type fogmodifier extends agent
75 type dialog extends agent
76 type button extends agent
77 type quest extends agent
78 type questitem extends agent
79 type defeatcondition extends agent
80 type timerdialog extends agent
81 type leaderboard extends agent
82 type multiboard extends agent
83 type multiboarditem extends agent
84 type trackable extends agent
85 type gamecache extends agent
86 type version extends handle
87 type itemtype extends handle
88 type texttag extends handle
89 type attacktype extends handle
90 type damagetype extends handle
91 type weapontype extends handle
92 type soundtype extends handle
93 type lightning extends handle
94 type pathingtype extends handle
95 type image extends handle
96 type ubersplat extends handle
97 type hashtable extends agent
98
99 constant native ConvertRace takes integer i returns race
100 constant native ConvertAllianceType takes integer i returns alliancetype
101 constant native ConvertRacePref takes integer i returns racepreference
102 constant native ConvertIGameState takes integer i returns igamestate
103 constant native ConvertFGameState takes integer i returns fgamestate
104 constant native ConvertPlayerState takes integer i returns playerstate
105 constant native ConvertPlayerScore takes integer i returns playerscore
106 constant native ConvertPlayerGameResult takes integer i returns playergameresult
107 constant native ConvertUnitState takes integer i returns unitstate
108 constant native ConvertAIDifficulty takes integer i returns aidifficulty
109 constant native ConvertGameEvent takes integer i returns gameevent
110 constant native ConvertPlayerEvent takes integer i returns playerevent
111 constant native ConvertPlayerUnitEvent takes integer i returns playerunitevent
112 constant native ConvertWidgetEvent takes integer i returns widgetevent
113 constant native ConvertDialogEvent takes integer i returns dialogevent
114 constant native ConvertUnitEvent takes integer i returns unitevent
115 constant native ConvertLimitOp takes integer i returns limitop
116 constant native ConvertUnitType takes integer i returns unittype
117 constant native ConvertGameSpeed takes integer i returns gamespeed
118 constant native ConvertPlacement takes integer i returns placement
119 constant native ConvertStartLocPrio takes integer i returns startlocprio
120 constant native ConvertGameDifficulty takes integer i returns gamedifficulty
121 constant native ConvertGameType takes integer i returns gametype
122 constant native ConvertMapFlag takes integer i returns mapflag
123 constant native ConvertMapVisibility takes integer i returns mapvisibility
124 constant native ConvertMapSetting takes integer i returns mapsetting
125 constant native ConvertMapDensity takes integer i returns mapdensity
126 constant native ConvertMapControl takes integer i returns mapcontrol
127 constant native ConvertPlayerColor takes integer i returns playercolor
128 constant native ConvertPlayerSlotState takes integer i returns playerslotstate
129 constant native ConvertVolumeGroup takes integer i returns volumegroup
130 constant native ConvertCameraField takes integer i returns camerafield
131 constant native ConvertBlendMode takes integer i returns blendmode
132 constant native ConvertRarityControl takes integer i returns raritycontrol
133 constant native ConvertTexMapFlags takes integer i returns texmapflags
134 constant native ConvertFogState takes integer i returns fogstate
135 constant native ConvertEffectType takes integer i returns effecttype
136 constant native ConvertVersion takes integer i returns version
137 constant native ConvertItemType takes integer i returns itemtype
138 constant native ConvertAttackType takes integer i returns attacktype
139 constant native ConvertDamageType takes integer i returns damagetype
140 constant native ConvertWeaponType takes integer i returns weapontype
141 constant native ConvertSoundType takes integer i returns soundtype
142 constant native ConvertPathingType takes integer i returns pathingtype
143
144 constant native OrderId takes string orderIdString returns integer
145 constant native OrderId2String takes integer orderId returns string
146 constant native UnitId takes string unitIdString returns integer
147 constant native UnitId2String takes integer unitId returns string
148
149 // Not currently working correctly...
150 constant native AbilityId takes string abilityIdString returns integer
151 constant native AbilityId2String takes integer abilityId returns string
152
153 // Looks up the "name" field for any object (unit, item, ability)
154 constant native GetObjectName takes integer objectId returns string
155
156 globals
157
158 //===================================================
159 // Game Constants
160 //===================================================
161
162 // pfff
163 constant boolean FALSE = false
164 constant boolean TRUE = true
165 constant integer JASS_MAX_ARRAY_SIZE = 8192
166
167 constant integer PLAYER_NEUTRAL_PASSIVE = 15
168 constant integer PLAYER_NEUTRAL_AGGRESSIVE = 12
169
170 constant playercolor PLAYER_COLOR_RED = ConvertPlayerColor(0)
171 constant playercolor PLAYER_COLOR_BLUE = ConvertPlayerColor(1)
172 constant playercolor PLAYER_COLOR_CYAN = ConvertPlayerColor(2)
173 constant playercolor PLAYER_COLOR_PURPLE = ConvertPlayerColor(3)
174 constant playercolor PLAYER_COLOR_YELLOW = ConvertPlayerColor(4)
175 constant playercolor PLAYER_COLOR_ORANGE = ConvertPlayerColor(5)
176 constant playercolor PLAYER_COLOR_GREEN = ConvertPlayerColor(6)
177 constant playercolor PLAYER_COLOR_PINK = ConvertPlayerColor(7)
178 constant playercolor PLAYER_COLOR_LIGHT_GRAY = ConvertPlayerColor(8)
179 constant playercolor PLAYER_COLOR_LIGHT_BLUE = ConvertPlayerColor(9)
180 constant playercolor PLAYER_COLOR_AQUA = ConvertPlayerColor(10)
181 constant playercolor PLAYER_COLOR_BROWN = ConvertPlayerColor(11)
182
183 constant race RACE_HUMAN = ConvertRace(1)
184 constant race RACE_ORC = ConvertRace(2)
185 constant race RACE_UNDEAD = ConvertRace(3)
186 constant race RACE_NIGHTELF = ConvertRace(4)
187 constant race RACE_DEMON = ConvertRace(5)
188 constant race RACE_OTHER = ConvertRace(7)
189
190 constant playergameresult PLAYER_GAME_RESULT_VICTORY = ConvertPlayerGameResult(0)
191 constant playergameresult PLAYER_GAME_RESULT_DEFEAT = ConvertPlayerGameResult(1)
192 constant playergameresult PLAYER_GAME_RESULT_TIE = ConvertPlayerGameResult(2)
193 constant playergameresult PLAYER_GAME_RESULT_NEUTRAL = ConvertPlayerGameResult(3)
194
195 constant alliancetype ALLIANCE_PASSIVE = ConvertAllianceType(0)
196 constant alliancetype ALLIANCE_HELP_REQUEST = ConvertAllianceType(1)
197 constant alliancetype ALLIANCE_HELP_RESPONSE = ConvertAllianceType(2)
198 constant alliancetype ALLIANCE_SHARED_XP = ConvertAllianceType(3)
199 constant alliancetype ALLIANCE_SHARED_SPELLS = ConvertAllianceType(4)
200 constant alliancetype ALLIANCE_SHARED_VISION = ConvertAllianceType(5)
201 constant alliancetype ALLIANCE_SHARED_CONTROL = ConvertAllianceType(6)
202 constant alliancetype ALLIANCE_SHARED_ADVANCED_CONTROL= ConvertAllianceType(7)
203 constant alliancetype ALLIANCE_RESCUABLE = ConvertAllianceType(8)
204 constant alliancetype ALLIANCE_SHARED_VISION_FORCED = ConvertAllianceType(9)
205
206 constant version VERSION_REIGN_OF_CHAOS = ConvertVersion(0)
207 constant version VERSION_FROZEN_THRONE = ConvertVersion(1)
208
209 constant attacktype ATTACK_TYPE_NORMAL = ConvertAttackType(0)
210 constant attacktype ATTACK_TYPE_MELEE = ConvertAttackType(1)
211 constant attacktype ATTACK_TYPE_PIERCE = ConvertAttackType(2)
212 constant attacktype ATTACK_TYPE_SIEGE = ConvertAttackType(3)
213 constant attacktype ATTACK_TYPE_MAGIC = ConvertAttackType(4)
214 constant attacktype ATTACK_TYPE_CHAOS = ConvertAttackType(5)
215 constant attacktype ATTACK_TYPE_HERO = ConvertAttackType(6)
216
217 constant damagetype DAMAGE_TYPE_UNKNOWN = ConvertDamageType(0)
218 constant damagetype DAMAGE_TYPE_NORMAL = ConvertDamageType(4)
219 constant damagetype DAMAGE_TYPE_ENHANCED = ConvertDamageType(5)
220 constant damagetype DAMAGE_TYPE_FIRE = ConvertDamageType(8)
221 constant damagetype DAMAGE_TYPE_COLD = ConvertDamageType(9)
222 constant damagetype DAMAGE_TYPE_LIGHTNING = ConvertDamageType(10)
223 constant damagetype DAMAGE_TYPE_POISON = ConvertDamageType(11)
224 constant damagetype DAMAGE_TYPE_DISEASE = ConvertDamageType(12)
225 constant damagetype DAMAGE_TYPE_DIVINE = ConvertDamageType(13)
226 constant damagetype DAMAGE_TYPE_MAGIC = ConvertDamageType(14)
227 constant damagetype DAMAGE_TYPE_SONIC = ConvertDamageType(15)
228 constant damagetype DAMAGE_TYPE_ACID = ConvertDamageType(16)
229 constant damagetype DAMAGE_TYPE_FORCE = ConvertDamageType(17)
230 constant damagetype DAMAGE_TYPE_DEATH = ConvertDamageType(18)
231 constant damagetype DAMAGE_TYPE_MIND = ConvertDamageType(19)
232 constant damagetype DAMAGE_TYPE_PLANT = ConvertDamageType(20)
233 constant damagetype DAMAGE_TYPE_DEFENSIVE = ConvertDamageType(21)
234 constant damagetype DAMAGE_TYPE_DEMOLITION = ConvertDamageType(22)
235 constant damagetype DAMAGE_TYPE_SLOW_POISON = ConvertDamageType(23)
236 constant damagetype DAMAGE_TYPE_SPIRIT_LINK = ConvertDamageType(24)
237 constant damagetype DAMAGE_TYPE_SHADOW_STRIKE = ConvertDamageType(25)
238 constant damagetype DAMAGE_TYPE_UNIVERSAL = ConvertDamageType(26)
239
240 constant weapontype WEAPON_TYPE_WHOKNOWS = ConvertWeaponType(0)
241 constant weapontype WEAPON_TYPE_METAL_LIGHT_CHOP = ConvertWeaponType(1)
242 constant weapontype WEAPON_TYPE_METAL_MEDIUM_CHOP = ConvertWeaponType(2)
243 constant weapontype WEAPON_TYPE_METAL_HEAVY_CHOP = ConvertWeaponType(3)
244 constant weapontype WEAPON_TYPE_METAL_LIGHT_SLICE = ConvertWeaponType(4)
245 constant weapontype WEAPON_TYPE_METAL_MEDIUM_SLICE = ConvertWeaponType(5)
246 constant weapontype WEAPON_TYPE_METAL_HEAVY_SLICE = ConvertWeaponType(6)
247 constant weapontype WEAPON_TYPE_METAL_MEDIUM_BASH = ConvertWeaponType(7)
248 constant weapontype WEAPON_TYPE_METAL_HEAVY_BASH = ConvertWeaponType(8)
249 constant weapontype WEAPON_TYPE_METAL_MEDIUM_STAB = ConvertWeaponType(9)
250 constant weapontype WEAPON_TYPE_METAL_HEAVY_STAB = ConvertWeaponType(10)
251 constant weapontype WEAPON_TYPE_WOOD_LIGHT_SLICE = ConvertWeaponType(11)
252 constant weapontype WEAPON_TYPE_WOOD_MEDIUM_SLICE = ConvertWeaponType(12)
253 constant weapontype WEAPON_TYPE_WOOD_HEAVY_SLICE = ConvertWeaponType(13)
254 constant weapontype WEAPON_TYPE_WOOD_LIGHT_BASH = ConvertWeaponType(14)
255 constant weapontype WEAPON_TYPE_WOOD_MEDIUM_BASH = ConvertWeaponType(15)
256 constant weapontype WEAPON_TYPE_WOOD_HEAVY_BASH = ConvertWeaponType(16)
257 constant weapontype WEAPON_TYPE_WOOD_LIGHT_STAB = ConvertWeaponType(17)
258 constant weapontype WEAPON_TYPE_WOOD_MEDIUM_STAB = ConvertWeaponType(18)
259 constant weapontype WEAPON_TYPE_CLAW_LIGHT_SLICE = ConvertWeaponType(19)
260 constant weapontype WEAPON_TYPE_CLAW_MEDIUM_SLICE = ConvertWeaponType(20)
261 constant weapontype WEAPON_TYPE_CLAW_HEAVY_SLICE = ConvertWeaponType(21)
262 constant weapontype WEAPON_TYPE_AXE_MEDIUM_CHOP = ConvertWeaponType(22)
263 constant weapontype WEAPON_TYPE_ROCK_HEAVY_BASH = ConvertWeaponType(23)
264
265 constant pathingtype PATHING_TYPE_ANY = ConvertPathingType(0)
266 constant pathingtype PATHING_TYPE_WALKABILITY = ConvertPathingType(1)
267 constant pathingtype PATHING_TYPE_FLYABILITY = ConvertPathingType(2)
268 constant pathingtype PATHING_TYPE_BUILDABILITY = ConvertPathingType(3)
269 constant pathingtype PATHING_TYPE_PEONHARVESTPATHING = ConvertPathingType(4)
270 constant pathingtype PATHING_TYPE_BLIGHTPATHING = ConvertPathingType(5)
271 constant pathingtype PATHING_TYPE_FLOATABILITY = ConvertPathingType(6)
272 constant pathingtype PATHING_TYPE_AMPHIBIOUSPATHING = ConvertPathingType(7)
273
274 //===================================================
275 // Map Setup Constants
276 //===================================================
277
278 constant racepreference RACE_PREF_HUMAN = ConvertRacePref(1)
279 constant racepreference RACE_PREF_ORC = ConvertRacePref(2)
280 constant racepreference RACE_PREF_NIGHTELF = ConvertRacePref(4)
281 constant racepreference RACE_PREF_UNDEAD = ConvertRacePref(8)
282 constant racepreference RACE_PREF_DEMON = ConvertRacePref(16)
283 constant racepreference RACE_PREF_RANDOM = ConvertRacePref(32)
284 constant racepreference RACE_PREF_USER_SELECTABLE = ConvertRacePref(64)
285
286 constant mapcontrol MAP_CONTROL_USER = ConvertMapControl(0)
287 constant mapcontrol MAP_CONTROL_COMPUTER = ConvertMapControl(1)
288 constant mapcontrol MAP_CONTROL_RESCUABLE = ConvertMapControl(2)
289 constant mapcontrol MAP_CONTROL_NEUTRAL = ConvertMapControl(3)
290 constant mapcontrol MAP_CONTROL_CREEP = ConvertMapControl(4)
291 constant mapcontrol MAP_CONTROL_NONE = ConvertMapControl(5)
292
293 constant gametype GAME_TYPE_MELEE = ConvertGameType(1)
294 constant gametype GAME_TYPE_FFA = ConvertGameType(2)
295 constant gametype GAME_TYPE_USE_MAP_SETTINGS = ConvertGameType(4)
296 constant gametype GAME_TYPE_BLIZ = ConvertGameType(8)
297 constant gametype GAME_TYPE_ONE_ON_ONE = ConvertGameType(16)
298 constant gametype GAME_TYPE_TWO_TEAM_PLAY = ConvertGameType(32)
299 constant gametype GAME_TYPE_THREE_TEAM_PLAY = ConvertGameType(64)
300 constant gametype GAME_TYPE_FOUR_TEAM_PLAY = ConvertGameType(128)
301
302 constant mapflag MAP_FOG_HIDE_TERRAIN = ConvertMapFlag(1)
303 constant mapflag MAP_FOG_MAP_EXPLORED = ConvertMapFlag(2)
304 constant mapflag MAP_FOG_ALWAYS_VISIBLE = ConvertMapFlag(4)
305
306 constant mapflag MAP_USE_HANDICAPS = ConvertMapFlag(8)
307 constant mapflag MAP_OBSERVERS = ConvertMapFlag(16)
308 constant mapflag MAP_OBSERVERS_ON_DEATH = ConvertMapFlag(32)
309
310 constant mapflag MAP_FIXED_COLORS = ConvertMapFlag(128)
311
312 constant mapflag MAP_LOCK_RESOURCE_TRADING = ConvertMapFlag(256)
313 constant mapflag MAP_RESOURCE_TRADING_ALLIES_ONLY = ConvertMapFlag(512)
314
315 constant mapflag MAP_LOCK_ALLIANCE_CHANGES = ConvertMapFlag(1024)
316 constant mapflag MAP_ALLIANCE_CHANGES_HIDDEN = ConvertMapFlag(2048)
317
318 constant mapflag MAP_CHEATS = ConvertMapFlag(4096)
319 constant mapflag MAP_CHEATS_HIDDEN = ConvertMapFlag(8192)
320
321 constant mapflag MAP_LOCK_SPEED = ConvertMapFlag(8192*2)
322 constant mapflag MAP_LOCK_RANDOM_SEED = ConvertMapFlag(8192*4)
323 constant mapflag MAP_SHARED_ADVANCED_CONTROL = ConvertMapFlag(8192*8)
324 constant mapflag MAP_RANDOM_HERO = ConvertMapFlag(8192*16)
325 constant mapflag MAP_RANDOM_RACES = ConvertMapFlag(8192*32)
326 constant mapflag MAP_RELOADED = ConvertMapFlag(8192*64)
327
328 constant placement MAP_PLACEMENT_RANDOM = ConvertPlacement(0) // random among all slots
329 constant placement MAP_PLACEMENT_FIXED = ConvertPlacement(1) // player 0 in start loc 0...
330 constant placement MAP_PLACEMENT_USE_MAP_SETTINGS = ConvertPlacement(2) // whatever was specified by the script
331 constant placement MAP_PLACEMENT_TEAMS_TOGETHER = ConvertPlacement(3) // random with allies next to each other
332
333 constant startlocprio MAP_LOC_PRIO_LOW = ConvertStartLocPrio(0)
334 constant startlocprio MAP_LOC_PRIO_HIGH = ConvertStartLocPrio(1)
335 constant startlocprio MAP_LOC_PRIO_NOT = ConvertStartLocPrio(2)
336
337 constant mapdensity MAP_DENSITY_NONE = ConvertMapDensity(0)
338 constant mapdensity MAP_DENSITY_LIGHT = ConvertMapDensity(1)
339 constant mapdensity MAP_DENSITY_MEDIUM = ConvertMapDensity(2)
340 constant mapdensity MAP_DENSITY_HEAVY = ConvertMapDensity(3)
341
342 constant gamedifficulty MAP_DIFFICULTY_EASY = ConvertGameDifficulty(0)
343 constant gamedifficulty MAP_DIFFICULTY_NORMAL = ConvertGameDifficulty(1)
344 constant gamedifficulty MAP_DIFFICULTY_HARD = ConvertGameDifficulty(2)
345 constant gamedifficulty MAP_DIFFICULTY_INSANE = ConvertGameDifficulty(3)
346
347 constant gamespeed MAP_SPEED_SLOWEST = ConvertGameSpeed(0)
348 constant gamespeed MAP_SPEED_SLOW = ConvertGameSpeed(1)
349 constant gamespeed MAP_SPEED_NORMAL = ConvertGameSpeed(2)
350 constant gamespeed MAP_SPEED_FAST = ConvertGameSpeed(3)
351 constant gamespeed MAP_SPEED_FASTEST = ConvertGameSpeed(4)
352
353 constant playerslotstate PLAYER_SLOT_STATE_EMPTY = ConvertPlayerSlotState(0)
354 constant playerslotstate PLAYER_SLOT_STATE_PLAYING = ConvertPlayerSlotState(1)
355 constant playerslotstate PLAYER_SLOT_STATE_LEFT = ConvertPlayerSlotState(2)
356
357 //===================================================
358 // Sound Constants
359 //===================================================
360 constant volumegroup SOUND_VOLUMEGROUP_UNITMOVEMENT = ConvertVolumeGroup(0)
361 constant volumegroup SOUND_VOLUMEGROUP_UNITSOUNDS = ConvertVolumeGroup(1)
362 constant volumegroup SOUND_VOLUMEGROUP_COMBAT = ConvertVolumeGroup(2)
363 constant volumegroup SOUND_VOLUMEGROUP_SPELLS = ConvertVolumeGroup(3)
364 constant volumegroup SOUND_VOLUMEGROUP_UI = ConvertVolumeGroup(4)
365 constant volumegroup SOUND_VOLUMEGROUP_MUSIC = ConvertVolumeGroup(5)
366 constant volumegroup SOUND_VOLUMEGROUP_AMBIENTSOUNDS = ConvertVolumeGroup(6)
367 constant volumegroup SOUND_VOLUMEGROUP_FIRE = ConvertVolumeGroup(7)
368
369
370 //===================================================
371 // Game, Player, and Unit States
372 //
373 // For use with TriggerRegister<X>StateEvent
374 //
375 //===================================================
376
377 constant igamestate GAME_STATE_DIVINE_INTERVENTION = ConvertIGameState(0)
378 constant igamestate GAME_STATE_DISCONNECTED = ConvertIGameState(1)
379 constant fgamestate GAME_STATE_TIME_OF_DAY = ConvertFGameState(2)
380
381 constant playerstate PLAYER_STATE_GAME_RESULT = ConvertPlayerState(0)
382
383 // current resource levels
384 //
385 constant playerstate PLAYER_STATE_RESOURCE_GOLD = ConvertPlayerState(1)
386 constant playerstate PLAYER_STATE_RESOURCE_LUMBER = ConvertPlayerState(2)
387 constant playerstate PLAYER_STATE_RESOURCE_HERO_TOKENS = ConvertPlayerState(3)
388 constant playerstate PLAYER_STATE_RESOURCE_FOOD_CAP = ConvertPlayerState(4)
389 constant playerstate PLAYER_STATE_RESOURCE_FOOD_USED = ConvertPlayerState(5)
390 constant playerstate PLAYER_STATE_FOOD_CAP_CEILING = ConvertPlayerState(6)
391
392 constant playerstate PLAYER_STATE_GIVES_BOUNTY = ConvertPlayerState(7)
393 constant playerstate PLAYER_STATE_ALLIED_VICTORY = ConvertPlayerState(8)
394 constant playerstate PLAYER_STATE_PLACED = ConvertPlayerState(9)
395 constant playerstate PLAYER_STATE_OBSERVER_ON_DEATH = ConvertPlayerState(10)
396 constant playerstate PLAYER_STATE_OBSERVER = ConvertPlayerState(11)
397 constant playerstate PLAYER_STATE_UNFOLLOWABLE = ConvertPlayerState(12)
398
399 // taxation rate for each resource
400 //
401 constant playerstate PLAYER_STATE_GOLD_UPKEEP_RATE = ConvertPlayerState(13)
402 constant playerstate PLAYER_STATE_LUMBER_UPKEEP_RATE = ConvertPlayerState(14)
403
404 // cumulative resources collected by the player during the mission
405 //
406 constant playerstate PLAYER_STATE_GOLD_GATHERED = ConvertPlayerState(15)
407 constant playerstate PLAYER_STATE_LUMBER_GATHERED = ConvertPlayerState(16)
408
409 constant playerstate PLAYER_STATE_NO_CREEP_SLEEP = ConvertPlayerState(25)
410
411 constant unitstate UNIT_STATE_LIFE = ConvertUnitState(0)
412 constant unitstate UNIT_STATE_MAX_LIFE = ConvertUnitState(1)
413 constant unitstate UNIT_STATE_MANA = ConvertUnitState(2)
414 constant unitstate UNIT_STATE_MAX_MANA = ConvertUnitState(3)
415
416 constant aidifficulty AI_DIFFICULTY_NEWBIE = ConvertAIDifficulty(0)
417 constant aidifficulty AI_DIFFICULTY_NORMAL = ConvertAIDifficulty(1)
418 constant aidifficulty AI_DIFFICULTY_INSANE = ConvertAIDifficulty(2)
419
420 // player score values
421 constant playerscore PLAYER_SCORE_UNITS_TRAINED = ConvertPlayerScore(0)
422 constant playerscore PLAYER_SCORE_UNITS_KILLED = ConvertPlayerScore(1)
423 constant playerscore PLAYER_SCORE_STRUCT_BUILT = ConvertPlayerScore(2)
424 constant playerscore PLAYER_SCORE_STRUCT_RAZED = ConvertPlayerScore(3)
425 constant playerscore PLAYER_SCORE_TECH_PERCENT = ConvertPlayerScore(4)
426 constant playerscore PLAYER_SCORE_FOOD_MAXPROD = ConvertPlayerScore(5)
427 constant playerscore PLAYER_SCORE_FOOD_MAXUSED = ConvertPlayerScore(6)
428 constant playerscore PLAYER_SCORE_HEROES_KILLED = ConvertPlayerScore(7)
429 constant playerscore PLAYER_SCORE_ITEMS_GAINED = ConvertPlayerScore(8)
430 constant playerscore PLAYER_SCORE_MERCS_HIRED = ConvertPlayerScore(9)
431 constant playerscore PLAYER_SCORE_GOLD_MINED_TOTAL = ConvertPlayerScore(10)
432 constant playerscore PLAYER_SCORE_GOLD_MINED_UPKEEP = ConvertPlayerScore(11)
433 constant playerscore PLAYER_SCORE_GOLD_LOST_UPKEEP = ConvertPlayerScore(12)
434 constant playerscore PLAYER_SCORE_GOLD_LOST_TAX = ConvertPlayerScore(13)
435 constant playerscore PLAYER_SCORE_GOLD_GIVEN = ConvertPlayerScore(14)
436 constant playerscore PLAYER_SCORE_GOLD_RECEIVED = ConvertPlayerScore(15)
437 constant playerscore PLAYER_SCORE_LUMBER_TOTAL = ConvertPlayerScore(16)
438 constant playerscore PLAYER_SCORE_LUMBER_LOST_UPKEEP = ConvertPlayerScore(17)
439 constant playerscore PLAYER_SCORE_LUMBER_LOST_TAX = ConvertPlayerScore(18)
440 constant playerscore PLAYER_SCORE_LUMBER_GIVEN = ConvertPlayerScore(19)
441 constant playerscore PLAYER_SCORE_LUMBER_RECEIVED = ConvertPlayerScore(20)
442 constant playerscore PLAYER_SCORE_UNIT_TOTAL = ConvertPlayerScore(21)
443 constant playerscore PLAYER_SCORE_HERO_TOTAL = ConvertPlayerScore(22)
444 constant playerscore PLAYER_SCORE_RESOURCE_TOTAL = ConvertPlayerScore(23)
445 constant playerscore PLAYER_SCORE_TOTAL = ConvertPlayerScore(24)
446
447 //===================================================
448 // Game, Player and Unit Events
449 //
450 // When an event causes a trigger to fire these
451 // values allow the action code to determine which
452 // event was dispatched and therefore which set of
453 // native functions should be used to get information
454 // about the event.
455 //
456 // Do NOT change the order or value of these constants
457 // without insuring that the JASS_GAME_EVENTS_WAR3 enum
458 // is changed to match.
459 //
460 //===================================================
461
462 //===================================================
463 // For use with TriggerRegisterGameEvent
464 //===================================================
465
466 constant gameevent EVENT_GAME_VICTORY = ConvertGameEvent(0)
467 constant gameevent EVENT_GAME_END_LEVEL = ConvertGameEvent(1)
468
469 constant gameevent EVENT_GAME_VARIABLE_LIMIT = ConvertGameEvent(2)
470 constant gameevent EVENT_GAME_STATE_LIMIT = ConvertGameEvent(3)
471
472 constant gameevent EVENT_GAME_TIMER_EXPIRED = ConvertGameEvent(4)
473
474 constant gameevent EVENT_GAME_ENTER_REGION = ConvertGameEvent(5)
475 constant gameevent EVENT_GAME_LEAVE_REGION = ConvertGameEvent(6)
476
477 constant gameevent EVENT_GAME_TRACKABLE_HIT = ConvertGameEvent(7)
478 constant gameevent EVENT_GAME_TRACKABLE_TRACK = ConvertGameEvent(8)
479
480 constant gameevent EVENT_GAME_SHOW_SKILL = ConvertGameEvent(9)
481 constant gameevent EVENT_GAME_BUILD_SUBMENU = ConvertGameEvent(10)
482
483 //===================================================
484 // For use with TriggerRegisterPlayerEvent
485 //===================================================
486 constant playerevent EVENT_PLAYER_STATE_LIMIT = ConvertPlayerEvent(11)
487 constant playerevent EVENT_PLAYER_ALLIANCE_CHANGED = ConvertPlayerEvent(12)
488
489 constant playerevent EVENT_PLAYER_DEFEAT = ConvertPlayerEvent(13)
490 constant playerevent EVENT_PLAYER_VICTORY = ConvertPlayerEvent(14)
491 constant playerevent EVENT_PLAYER_LEAVE = ConvertPlayerEvent(15)
492 constant playerevent EVENT_PLAYER_CHAT = ConvertPlayerEvent(16)
493 constant playerevent EVENT_PLAYER_END_CINEMATIC = ConvertPlayerEvent(17)
494
495 //===================================================
496 // For use with TriggerRegisterPlayerUnitEvent
497 //===================================================
498
499 constant playerunitevent EVENT_PLAYER_UNIT_ATTACKED = ConvertPlayerUnitEvent(18)
500 constant playerunitevent EVENT_PLAYER_UNIT_RESCUED = ConvertPlayerUnitEvent(19)
501
502 constant playerunitevent EVENT_PLAYER_UNIT_DEATH = ConvertPlayerUnitEvent(20)
503 constant playerunitevent EVENT_PLAYER_UNIT_DECAY = ConvertPlayerUnitEvent(21)
504
505 constant playerunitevent EVENT_PLAYER_UNIT_DETECTED = ConvertPlayerUnitEvent(22)
506 constant playerunitevent EVENT_PLAYER_UNIT_HIDDEN = ConvertPlayerUnitEvent(23)
507
508 constant playerunitevent EVENT_PLAYER_UNIT_SELECTED = ConvertPlayerUnitEvent(24)
509 constant playerunitevent EVENT_PLAYER_UNIT_DESELECTED = ConvertPlayerUnitEvent(25)
510
511 constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_START = ConvertPlayerUnitEvent(26)
512 constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL = ConvertPlayerUnitEvent(27)
513 constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_FINISH = ConvertPlayerUnitEvent(28)
514
515 constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_START = ConvertPlayerUnitEvent(29)
516 constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_CANCEL = ConvertPlayerUnitEvent(30)
517 constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_FINISH = ConvertPlayerUnitEvent(31)
518
519 constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_START = ConvertPlayerUnitEvent(32)
520 constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_CANCEL = ConvertPlayerUnitEvent(33)
521 constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_FINISH = ConvertPlayerUnitEvent(34)
522
523 constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_START = ConvertPlayerUnitEvent(35)
524 constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_CANCEL = ConvertPlayerUnitEvent(36)
525 constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_FINISH = ConvertPlayerUnitEvent(37)
526 constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_ORDER = ConvertPlayerUnitEvent(38)
527 constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER = ConvertPlayerUnitEvent(39)
528 constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER = ConvertPlayerUnitEvent(40)
529 constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER = ConvertPlayerUnitEvent(40) // for compat
530
531 constant playerunitevent EVENT_PLAYER_HERO_LEVEL = ConvertPlayerUnitEvent(41)
532 constant playerunitevent EVENT_PLAYER_HERO_SKILL = ConvertPlayerUnitEvent(42)
533
534 constant playerunitevent EVENT_PLAYER_HERO_REVIVABLE = ConvertPlayerUnitEvent(43)
535
536 constant playerunitevent EVENT_PLAYER_HERO_REVIVE_START = ConvertPlayerUnitEvent(44)
537 constant playerunitevent EVENT_PLAYER_HERO_REVIVE_CANCEL = ConvertPlayerUnitEvent(45)
538 constant playerunitevent EVENT_PLAYER_HERO_REVIVE_FINISH = ConvertPlayerUnitEvent(46)
539 constant playerunitevent EVENT_PLAYER_UNIT_SUMMON = ConvertPlayerUnitEvent(47)
540 constant playerunitevent EVENT_PLAYER_UNIT_DROP_ITEM = ConvertPlayerUnitEvent(48)
541 constant playerunitevent EVENT_PLAYER_UNIT_PICKUP_ITEM = ConvertPlayerUnitEvent(49)
542 constant playerunitevent EVENT_PLAYER_UNIT_USE_ITEM = ConvertPlayerUnitEvent(50)
543
544 constant playerunitevent EVENT_PLAYER_UNIT_LOADED = ConvertPlayerUnitEvent(51)
545
546 //===================================================
547 // For use with TriggerRegisterUnitEvent
548 //===================================================
549
550 constant unitevent EVENT_UNIT_DAMAGED = ConvertUnitEvent(52)
551 constant unitevent EVENT_UNIT_DEATH = ConvertUnitEvent(53)
552 constant unitevent EVENT_UNIT_DECAY = ConvertUnitEvent(54)
553 constant unitevent EVENT_UNIT_DETECTED = ConvertUnitEvent(55)
554 constant unitevent EVENT_UNIT_HIDDEN = ConvertUnitEvent(56)
555 constant unitevent EVENT_UNIT_SELECTED = ConvertUnitEvent(57)
556 constant unitevent EVENT_UNIT_DESELECTED = ConvertUnitEvent(58)
557
558 constant unitevent EVENT_UNIT_STATE_LIMIT = ConvertUnitEvent(59)
559
560 // Events which may have a filter for the "other unit"
561 //
562 constant unitevent EVENT_UNIT_ACQUIRED_TARGET = ConvertUnitEvent(60)
563 constant unitevent EVENT_UNIT_TARGET_IN_RANGE = ConvertUnitEvent(61)
564 constant unitevent EVENT_UNIT_ATTACKED = ConvertUnitEvent(62)
565 constant unitevent EVENT_UNIT_RESCUED = ConvertUnitEvent(63)
566
567 constant unitevent EVENT_UNIT_CONSTRUCT_CANCEL = ConvertUnitEvent(64)
568 constant unitevent EVENT_UNIT_CONSTRUCT_FINISH = ConvertUnitEvent(65)
569
570 constant unitevent EVENT_UNIT_UPGRADE_START = ConvertUnitEvent(66)
571 constant unitevent EVENT_UNIT_UPGRADE_CANCEL = ConvertUnitEvent(67)
572 constant unitevent EVENT_UNIT_UPGRADE_FINISH = ConvertUnitEvent(68)
573
574 // Events which involve the specified unit performing
575 // training of other units
576 //
577 constant unitevent EVENT_UNIT_TRAIN_START = ConvertUnitEvent(69)
578 constant unitevent EVENT_UNIT_TRAIN_CANCEL = ConvertUnitEvent(70)
579 constant unitevent EVENT_UNIT_TRAIN_FINISH = ConvertUnitEvent(71)
580
581 constant unitevent EVENT_UNIT_RESEARCH_START = ConvertUnitEvent(72)
582 constant unitevent EVENT_UNIT_RESEARCH_CANCEL = ConvertUnitEvent(73)
583 constant unitevent EVENT_UNIT_RESEARCH_FINISH = ConvertUnitEvent(74)
584
585 constant unitevent EVENT_UNIT_ISSUED_ORDER = ConvertUnitEvent(75)
586 constant unitevent EVENT_UNIT_ISSUED_POINT_ORDER = ConvertUnitEvent(76)
587 constant unitevent EVENT_UNIT_ISSUED_TARGET_ORDER = ConvertUnitEvent(77)
588
589 constant unitevent EVENT_UNIT_HERO_LEVEL = ConvertUnitEvent(78)
590 constant unitevent EVENT_UNIT_HERO_SKILL = ConvertUnitEvent(79)
591
592 constant unitevent EVENT_UNIT_HERO_REVIVABLE = ConvertUnitEvent(80)
593 constant unitevent EVENT_UNIT_HERO_REVIVE_START = ConvertUnitEvent(81)
594 constant unitevent EVENT_UNIT_HERO_REVIVE_CANCEL = ConvertUnitEvent(82)
595 constant unitevent EVENT_UNIT_HERO_REVIVE_FINISH = ConvertUnitEvent(83)
596
597 constant unitevent EVENT_UNIT_SUMMON = ConvertUnitEvent(84)
598
599 constant unitevent EVENT_UNIT_DROP_ITEM = ConvertUnitEvent(85)
600 constant unitevent EVENT_UNIT_PICKUP_ITEM = ConvertUnitEvent(86)
601 constant unitevent EVENT_UNIT_USE_ITEM = ConvertUnitEvent(87)
602
603 constant unitevent EVENT_UNIT_LOADED = ConvertUnitEvent(88)
604
605 constant widgetevent EVENT_WIDGET_DEATH = ConvertWidgetEvent(89)
606
607 constant dialogevent EVENT_DIALOG_BUTTON_CLICK = ConvertDialogEvent(90)
608 constant dialogevent EVENT_DIALOG_CLICK = ConvertDialogEvent(91)
609
610 //===================================================
611 // Frozen Throne Expansion Events
612 // Need to be added here to preserve compat
613 //===================================================
614
615 //===================================================
616 // For use with TriggerRegisterGameEvent
617 //===================================================
618
619 constant gameevent EVENT_GAME_LOADED = ConvertGameEvent(256)
620 constant gameevent EVENT_GAME_TOURNAMENT_FINISH_SOON = ConvertGameEvent(257)
621 constant gameevent EVENT_GAME_TOURNAMENT_FINISH_NOW = ConvertGameEvent(258)
622 constant gameevent EVENT_GAME_SAVE = ConvertGameEvent(259)
623
624 //===================================================
625 // For use with TriggerRegisterPlayerEvent
626 //===================================================
627
628 constant playerevent EVENT_PLAYER_ARROW_LEFT_DOWN = ConvertPlayerEvent(261)
629 constant playerevent EVENT_PLAYER_ARROW_LEFT_UP = ConvertPlayerEvent(262)
630 constant playerevent EVENT_PLAYER_ARROW_RIGHT_DOWN = ConvertPlayerEvent(263)
631 constant playerevent EVENT_PLAYER_ARROW_RIGHT_UP = ConvertPlayerEvent(264)
632 constant playerevent EVENT_PLAYER_ARROW_DOWN_DOWN = ConvertPlayerEvent(265)
633 constant playerevent EVENT_PLAYER_ARROW_DOWN_UP = ConvertPlayerEvent(266)
634 constant playerevent EVENT_PLAYER_ARROW_UP_DOWN = ConvertPlayerEvent(267)
635 constant playerevent EVENT_PLAYER_ARROW_UP_UP = ConvertPlayerEvent(268)
636
637 //===================================================
638 // For use with TriggerRegisterPlayerUnitEvent
639 //===================================================
640
641 constant playerunitevent EVENT_PLAYER_UNIT_SELL = ConvertPlayerUnitEvent(269)
642 constant playerunitevent EVENT_PLAYER_UNIT_CHANGE_OWNER = ConvertPlayerUnitEvent(270)
643 constant playerunitevent EVENT_PLAYER_UNIT_SELL_ITEM = ConvertPlayerUnitEvent(271)
644 constant playerunitevent EVENT_PLAYER_UNIT_SPELL_CHANNEL = ConvertPlayerUnitEvent(272)
645 constant playerunitevent EVENT_PLAYER_UNIT_SPELL_CAST = ConvertPlayerUnitEvent(273)
646 constant playerunitevent EVENT_PLAYER_UNIT_SPELL_EFFECT = ConvertPlayerUnitEvent(274)
647 constant playerunitevent EVENT_PLAYER_UNIT_SPELL_FINISH = ConvertPlayerUnitEvent(275)
648 constant playerunitevent EVENT_PLAYER_UNIT_SPELL_ENDCAST = ConvertPlayerUnitEvent(276)
649 constant playerunitevent EVENT_PLAYER_UNIT_PAWN_ITEM = ConvertPlayerUnitEvent(277)
650
651 //===================================================
652 // For use with TriggerRegisterUnitEvent
653 //===================================================
654
655 constant unitevent EVENT_UNIT_SELL = ConvertUnitEvent(286)
656 constant unitevent EVENT_UNIT_CHANGE_OWNER = ConvertUnitEvent(287)
657 constant unitevent EVENT_UNIT_SELL_ITEM = ConvertUnitEvent(288)
658 constant unitevent EVENT_UNIT_SPELL_CHANNEL = ConvertUnitEvent(289)
659 constant unitevent EVENT_UNIT_SPELL_CAST = ConvertUnitEvent(290)
660 constant unitevent EVENT_UNIT_SPELL_EFFECT = ConvertUnitEvent(291)
661 constant unitevent EVENT_UNIT_SPELL_FINISH = ConvertUnitEvent(292)
662 constant unitevent EVENT_UNIT_SPELL_ENDCAST = ConvertUnitEvent(293)
663 constant unitevent EVENT_UNIT_PAWN_ITEM = ConvertUnitEvent(294)
664
665 //===================================================
666 // Limit Event API constants
667 // variable, player state, game state, and unit state events
668 // ( do NOT change the order of these... )
669 //===================================================
670 constant limitop LESS_THAN = ConvertLimitOp(0)
671 constant limitop LESS_THAN_OR_EQUAL = ConvertLimitOp(1)
672 constant limitop EQUAL = ConvertLimitOp(2)
673 constant limitop GREATER_THAN_OR_EQUAL = ConvertLimitOp(3)
674 constant limitop GREATER_THAN = ConvertLimitOp(4)
675 constant limitop NOT_EQUAL = ConvertLimitOp(5)
676
677 //===================================================
678 // Unit Type Constants for use with IsUnitType()
679 //===================================================
680
681 constant unittype UNIT_TYPE_HERO = ConvertUnitType(0)
682 constant unittype UNIT_TYPE_DEAD = ConvertUnitType(1)
683 constant unittype UNIT_TYPE_STRUCTURE = ConvertUnitType(2)
684
685 constant unittype UNIT_TYPE_FLYING = ConvertUnitType(3)
686 constant unittype UNIT_TYPE_GROUND = ConvertUnitType(4)
687
688 constant unittype UNIT_TYPE_ATTACKS_FLYING = ConvertUnitType(5)
689 constant unittype UNIT_TYPE_ATTACKS_GROUND = ConvertUnitType(6)
690
691 constant unittype UNIT_TYPE_MELEE_ATTACKER = ConvertUnitType(7)
692 constant unittype UNIT_TYPE_RANGED_ATTACKER = ConvertUnitType(8)
693
694 constant unittype UNIT_TYPE_GIANT = ConvertUnitType(9)
695 constant unittype UNIT_TYPE_SUMMONED = ConvertUnitType(10)
696 constant unittype UNIT_TYPE_STUNNED = ConvertUnitType(11)
697 constant unittype UNIT_TYPE_PLAGUED = ConvertUnitType(12)
698 constant unittype UNIT_TYPE_SNARED = ConvertUnitType(13)
699
700 constant unittype UNIT_TYPE_UNDEAD = ConvertUnitType(14)
701 constant unittype UNIT_TYPE_MECHANICAL = ConvertUnitType(15)
702 constant unittype UNIT_TYPE_PEON = ConvertUnitType(16)
703 constant unittype UNIT_TYPE_SAPPER = ConvertUnitType(17)
704 constant unittype UNIT_TYPE_TOWNHALL = ConvertUnitType(18)
705 constant unittype UNIT_TYPE_ANCIENT = ConvertUnitType(19)
706
707 constant unittype UNIT_TYPE_TAUREN = ConvertUnitType(20)
708 constant unittype UNIT_TYPE_POISONED = ConvertUnitType(21)
709 constant unittype UNIT_TYPE_POLYMORPHED = ConvertUnitType(22)
710 constant unittype UNIT_TYPE_SLEEPING = ConvertUnitType(23)
711 constant unittype UNIT_TYPE_RESISTANT = ConvertUnitType(24)
712 constant unittype UNIT_TYPE_ETHEREAL = ConvertUnitType(25)
713 constant unittype UNIT_TYPE_MAGIC_IMMUNE = ConvertUnitType(26)
714
715 //===================================================
716 // Unit Type Constants for use with ChooseRandomItemEx()
717 //===================================================
718
719 constant itemtype ITEM_TYPE_PERMANENT = ConvertItemType(0)
720 constant itemtype ITEM_TYPE_CHARGED = ConvertItemType(1)
721 constant itemtype ITEM_TYPE_POWERUP = ConvertItemType(2)
722 constant itemtype ITEM_TYPE_ARTIFACT = ConvertItemType(3)
723 constant itemtype ITEM_TYPE_PURCHASABLE = ConvertItemType(4)
724 constant itemtype ITEM_TYPE_CAMPAIGN = ConvertItemType(5)
725 constant itemtype ITEM_TYPE_MISCELLANEOUS = ConvertItemType(6)
726 constant itemtype ITEM_TYPE_UNKNOWN = ConvertItemType(7)
727 constant itemtype ITEM_TYPE_ANY = ConvertItemType(8)
728
729 // Deprecated, should use ITEM_TYPE_POWERUP
730 constant itemtype ITEM_TYPE_TOME = ConvertItemType(2)
731
732 //===================================================
733 // Animatable Camera Fields
734 //===================================================
735
736 constant camerafield CAMERA_FIELD_TARGET_DISTANCE = ConvertCameraField(0)
737 constant camerafield CAMERA_FIELD_FARZ = ConvertCameraField(1)
738 constant camerafield CAMERA_FIELD_ANGLE_OF_ATTACK = ConvertCameraField(2)
739 constant camerafield CAMERA_FIELD_FIELD_OF_VIEW = ConvertCameraField(3)
740 constant camerafield CAMERA_FIELD_ROLL = ConvertCameraField(4)
741 constant camerafield CAMERA_FIELD_ROTATION = ConvertCameraField(5)
742 constant camerafield CAMERA_FIELD_ZOFFSET = ConvertCameraField(6)
743
744 constant blendmode BLEND_MODE_NONE = ConvertBlendMode(0)
745 constant blendmode BLEND_MODE_DONT_CARE = ConvertBlendMode(0)
746 constant blendmode BLEND_MODE_KEYALPHA = ConvertBlendMode(1)
747 constant blendmode BLEND_MODE_BLEND = ConvertBlendMode(2)
748 constant blendmode BLEND_MODE_ADDITIVE = ConvertBlendMode(3)
749 constant blendmode BLEND_MODE_MODULATE = ConvertBlendMode(4)
750 constant blendmode BLEND_MODE_MODULATE_2X = ConvertBlendMode(5)
751
752 constant raritycontrol RARITY_FREQUENT = ConvertRarityControl(0)
753 constant raritycontrol RARITY_RARE = ConvertRarityControl(1)
754
755 constant texmapflags TEXMAP_FLAG_NONE = ConvertTexMapFlags(0)
756 constant texmapflags TEXMAP_FLAG_WRAP_U = ConvertTexMapFlags(1)
757 constant texmapflags TEXMAP_FLAG_WRAP_V = ConvertTexMapFlags(2)
758 constant texmapflags TEXMAP_FLAG_WRAP_UV = ConvertTexMapFlags(3)
759
760 constant fogstate FOG_OF_WAR_MASKED = ConvertFogState(1)
761 constant fogstate FOG_OF_WAR_FOGGED = ConvertFogState(2)
762 constant fogstate FOG_OF_WAR_VISIBLE = ConvertFogState(4)
763
764 //===================================================
765 // Camera Margin constants for use with GetCameraMargin
766 //===================================================
767
768 constant integer CAMERA_MARGIN_LEFT = 0
769 constant integer CAMERA_MARGIN_RIGHT = 1
770 constant integer CAMERA_MARGIN_TOP = 2
771 constant integer CAMERA_MARGIN_BOTTOM = 3
772
773 //===================================================
774 // Effect API constants
775 //===================================================
776
777 constant effecttype EFFECT_TYPE_EFFECT = ConvertEffectType(0)
778 constant effecttype EFFECT_TYPE_TARGET = ConvertEffectType(1)
779 constant effecttype EFFECT_TYPE_CASTER = ConvertEffectType(2)
780 constant effecttype EFFECT_TYPE_SPECIAL = ConvertEffectType(3)
781 constant effecttype EFFECT_TYPE_AREA_EFFECT = ConvertEffectType(4)
782 constant effecttype EFFECT_TYPE_MISSILE = ConvertEffectType(5)
783 constant effecttype EFFECT_TYPE_LIGHTNING = ConvertEffectType(6)
784
785 constant soundtype SOUND_TYPE_EFFECT = ConvertSoundType(0)
786 constant soundtype SOUND_TYPE_EFFECT_LOOPED = ConvertSoundType(1)
787
788 endglobals
789
790 //============================================================================
791 // MathAPI
792 native Deg2Rad takes real degrees returns real
793 native Rad2Deg takes real radians returns real
794
795 native Sin takes real radians returns real
796 native Cos takes real radians returns real
797 native Tan takes real radians returns real
798
799 // Expect values between -1 and 1...returns 0 for invalid input
800 native Asin takes real y returns real
801 native Acos takes real x returns real
802
803 native Atan takes real x returns real
804
805 // Returns 0 if x and y are both 0
806 native Atan2 takes real y, real x returns real
807
808 // Returns 0 if x <= 0
809 native SquareRoot takes real x returns real
810
811 // computes x to the y power
812 // y == 0.0 => 1
813 // x ==0.0 and y < 0 => 0
814 //
815 native Pow takes real x, real power returns real
816
817 //============================================================================
818 // String Utility API
819 native I2R takes integer i returns real
820 native R2I takes real r returns integer
821 native I2S takes integer i returns string
822 native R2S takes real r returns string
823 native R2SW takes real r, integer width, integer precision returns string
824 native S2I takes string s returns integer
825 native S2R takes string s returns real
826 native GetHandleId takes handle h returns integer
827 native SubString takes string source, integer start, integer end returns string
828 native StringLength takes string s returns integer
829 native StringCase takes string source, boolean upper returns string
830 native StringHash takes string s returns integer
831
832 native GetLocalizedString takes string source returns string
833 native GetLocalizedHotkey takes string source returns integer
834
835 //============================================================================
836 // Map Setup API
837 //
838 // These are native functions for describing the map configuration
839 // these funcs should only be used in the "config" function of
840 // a map script. The functions should also be called in this order
841 // ( i.e. call SetPlayers before SetPlayerColor...
842 //
843
844 native SetMapName takes string name returns nothing
845 native SetMapDescription takes string description returns nothing
846
847 native SetTeams takes integer teamcount returns nothing
848 native SetPlayers takes integer playercount returns nothing
849
850 native DefineStartLocation takes integer whichStartLoc, real x, real y returns nothing
851 native DefineStartLocationLoc takes integer whichStartLoc, location whichLocation returns nothing
852 native SetStartLocPrioCount takes integer whichStartLoc, integer prioSlotCount returns nothing
853 native SetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex, integer otherStartLocIndex, startlocprio priority returns nothing
854 native GetStartLocPrioSlot takes integer whichStartLoc, integer prioSlotIndex returns integer
855 native GetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex returns startlocprio
856
857 native SetGameTypeSupported takes gametype whichGameType, boolean value returns nothing
858 native SetMapFlag takes mapflag whichMapFlag, boolean value returns nothing
859 native SetGamePlacement takes placement whichPlacementType returns nothing
860 native SetGameSpeed takes gamespeed whichspeed returns nothing
861 native SetGameDifficulty takes gamedifficulty whichdifficulty returns nothing
862 native SetResourceDensity takes mapdensity whichdensity returns nothing
863 native SetCreatureDensity takes mapdensity whichdensity returns nothing
864
865 native GetTeams takes nothing returns integer
866 native GetPlayers takes nothing returns integer
867
868 native IsGameTypeSupported takes gametype whichGameType returns boolean
869 native GetGameTypeSelected takes nothing returns gametype
870 native IsMapFlagSet takes mapflag whichMapFlag returns boolean
871
872 constant native GetGamePlacement takes nothing returns placement
873 constant native GetGameSpeed takes nothing returns gamespeed
874 constant native GetGameDifficulty takes nothing returns gamedifficulty
875 constant native GetResourceDensity takes nothing returns mapdensity
876 constant native GetCreatureDensity takes nothing returns mapdensity
877 constant native GetStartLocationX takes integer whichStartLocation returns real
878 constant native GetStartLocationY takes integer whichStartLocation returns real
879 constant native GetStartLocationLoc takes integer whichStartLocation returns location
880
881
882 native SetPlayerTeam takes player whichPlayer, integer whichTeam returns nothing
883 native SetPlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing
884 // forces player to have the specified start loc and marks the start loc as occupied
885 // which removes it from consideration for subsequently placed players
886 // ( i.e. you can use this to put people in a fixed loc and then
887 // use random placement for any unplaced players etc )
888 native ForcePlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing
889 native SetPlayerColor takes player whichPlayer, playercolor color returns nothing
890 native SetPlayerAlliance takes player sourcePlayer, player otherPlayer, alliancetype whichAllianceSetting, boolean value returns nothing
891 native SetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource, integer rate returns nothing
892 native SetPlayerRacePreference takes player whichPlayer, racepreference whichRacePreference returns nothing
893 native SetPlayerRaceSelectable takes player whichPlayer, boolean value returns nothing
894 native SetPlayerController takes player whichPlayer, mapcontrol controlType returns nothing
895 native SetPlayerName takes player whichPlayer, string name returns nothing
896
897 native SetPlayerOnScoreScreen takes player whichPlayer, boolean flag returns nothing
898
899 native GetPlayerTeam takes player whichPlayer returns integer
900 native GetPlayerStartLocation takes player whichPlayer returns integer
901 native GetPlayerColor takes player whichPlayer returns playercolor
902 native GetPlayerSelectable takes player whichPlayer returns boolean
903 native GetPlayerController takes player whichPlayer returns mapcontrol
904 native GetPlayerSlotState takes player whichPlayer returns playerslotstate
905 native GetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource returns integer
906 native IsPlayerRacePrefSet takes player whichPlayer, racepreference pref returns boolean
907 native GetPlayerName takes player whichPlayer returns string
908
909 //============================================================================
910 // Timer API
911 //
912 native CreateTimer takes nothing returns timer
913 native DestroyTimer takes timer whichTimer returns nothing
914 native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing
915 native TimerGetElapsed takes timer whichTimer returns real
916 native TimerGetRemaining takes timer whichTimer returns real
917 native TimerGetTimeout takes timer whichTimer returns real
918 native PauseTimer takes timer whichTimer returns nothing
919 native ResumeTimer takes timer whichTimer returns nothing
920 native GetExpiredTimer takes nothing returns timer
921
922 //============================================================================
923 // Group API
924 //
925 native CreateGroup takes nothing returns group
926 native DestroyGroup takes group whichGroup returns nothing
927 native GroupAddUnit takes group whichGroup, unit whichUnit returns nothing
928 native GroupRemoveUnit takes group whichGroup, unit whichUnit returns nothing
929 native GroupClear takes group whichGroup returns nothing
930 native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing
931 native GroupEnumUnitsOfPlayer takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
932 native GroupEnumUnitsOfTypeCounted takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing
933 native GroupEnumUnitsInRect takes group whichGroup, rect r, boolexpr filter returns nothing
934 native GroupEnumUnitsInRectCounted takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing
935 native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing
936 native GroupEnumUnitsInRangeOfLoc takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing
937 native GroupEnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing
938 native GroupEnumUnitsInRangeOfLocCounted takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing
939 native GroupEnumUnitsSelected takes group whichGroup, player whichPlayer, boolexpr filter returns nothing
940
941 native GroupImmediateOrder takes group whichGroup, string order returns boolean
942 native GroupImmediateOrderById takes group whichGroup, integer order returns boolean
943 native GroupPointOrder takes group whichGroup, string order, real x, real y returns boolean
944 native GroupPointOrderLoc takes group whichGroup, string order, location whichLocation returns boolean
945 native GroupPointOrderById takes group whichGroup, integer order, real x, real y returns boolean
946 native GroupPointOrderByIdLoc takes group whichGroup, integer order, location whichLocation returns boolean
947 native GroupTargetOrder takes group whichGroup, string order, widget targetWidget returns boolean
948 native GroupTargetOrderById takes group whichGroup, integer order, widget targetWidget returns boolean
949
950 // This will be difficult to support with potentially disjoint, cell-based regions
951 // as it would involve enumerating all the cells that are covered by a particularregion
952 // a better implementation would be a trigger that adds relevant units as they enter
953 // and removes them if they leave...
954 native ForGroup takes group whichGroup, code callback returns nothing
955 native FirstOfGroup takes group whichGroup returns unit
956
957 //============================================================================
958 // Force API
959 //
960 native CreateForce takes nothing returns force
961 native DestroyForce takes force whichForce returns nothing
962 native ForceAddPlayer takes force whichForce, player whichPlayer returns nothing
963 native ForceRemovePlayer takes force whichForce, player whichPlayer returns nothing
964 native ForceClear takes force whichForce returns nothing
965 native ForceEnumPlayers takes force whichForce, boolexpr filter returns nothing
966 native ForceEnumPlayersCounted takes force whichForce, boolexpr filter, integer countLimit returns nothing
967 native ForceEnumAllies takes force whichForce, player whichPlayer, boolexpr filter returns nothing
968 native ForceEnumEnemies takes force whichForce, player whichPlayer, boolexpr filter returns nothing
969 native ForForce takes force whichForce, code callback returns nothing
970
971 //============================================================================
972 // Region and Location API
973 //
974 native Rect takes real minx, real miny, real maxx, real maxy returns rect
975 native RectFromLoc takes location min, location max returns rect
976 native RemoveRect takes rect whichRect returns nothing
977 native SetRect takes rect whichRect, real minx, real miny, real maxx, real maxy returns nothing
978 native SetRectFromLoc takes rect whichRect, location min, location max returns nothing
979 native MoveRectTo takes rect whichRect, real newCenterX, real newCenterY returns nothing
980 native MoveRectToLoc takes rect whichRect, location newCenterLoc returns nothing
981
982 native GetRectCenterX takes rect whichRect returns real
983 native GetRectCenterY takes rect whichRect returns real
984 native GetRectMinX takes rect whichRect returns real
985 native GetRectMinY takes rect whichRect returns real
986 native GetRectMaxX takes rect whichRect returns real
987 native GetRectMaxY takes rect whichRect returns real
988
989 native CreateRegion takes nothing returns region
990 native RemoveRegion takes region whichRegion returns nothing
991
992 native RegionAddRect takes region whichRegion, rect r returns nothing
993 native RegionClearRect takes region whichRegion, rect r returns nothing
994
995 native RegionAddCell takes region whichRegion, real x, real y returns nothing
996 native RegionAddCellAtLoc takes region whichRegion, location whichLocation returns nothing
997 native RegionClearCell takes region whichRegion, real x, real y returns nothing
998 native RegionClearCellAtLoc takes region whichRegion, location whichLocation returns nothing
999
1000 native Location takes real x, real y returns location
1001 native RemoveLocation takes location whichLocation returns nothing
1002 native MoveLocation takes location whichLocation, real newX, real newY returns nothing
1003 native GetLocationX takes location whichLocation returns real
1004 native GetLocationY takes location whichLocation returns real
1005
1006 // This function is asynchronous. The values it returns are not guaranteed synchronous between each player.
1007 // If you attempt to use it in a synchronous manner, it may cause a desync.
1008 native GetLocationZ takes location whichLocation returns real
1009
1010 native IsUnitInRegion takes region whichRegion, unit whichUnit returns boolean
1011 native IsPointInRegion takes region whichRegion, real x, real y returns boolean
1012 native IsLocationInRegion takes region whichRegion, location whichLocation returns boolean
1013
1014 // Returns full map bounds, including unplayable borders, in world coordinates
1015 native GetWorldBounds takes nothing returns rect
1016
1017 //============================================================================
1018 // Native trigger interface
1019 //
1020 native CreateTrigger takes nothing returns trigger
1021 native DestroyTrigger takes trigger whichTrigger returns nothing
1022 native ResetTrigger takes trigger whichTrigger returns nothing
1023 native EnableTrigger takes trigger whichTrigger returns nothing
1024 native DisableTrigger takes trigger whichTrigger returns nothing
1025 native IsTriggerEnabled takes trigger whichTrigger returns boolean
1026
1027 native TriggerWaitOnSleeps takes trigger whichTrigger, boolean flag returns nothing
1028 native IsTriggerWaitOnSleeps takes trigger whichTrigger returns boolean
1029
1030 constant native GetFilterUnit takes nothing returns unit
1031 constant native GetEnumUnit takes nothing returns unit
1032
1033 constant native GetFilterDestructable takes nothing returns destructable
1034 constant native GetEnumDestructable takes nothing returns destructable
1035
1036 constant native GetFilterItem takes nothing returns item
1037 constant native GetEnumItem takes nothing returns item
1038
1039 constant native GetFilterPlayer takes nothing returns player
1040 constant native GetEnumPlayer takes nothing returns player
1041
1042 constant native GetTriggeringTrigger takes nothing returns trigger
1043 constant native GetTriggerEventId takes nothing returns eventid
1044 constant native GetTriggerEvalCount takes trigger whichTrigger returns integer
1045 constant native GetTriggerExecCount takes trigger whichTrigger returns integer
1046
1047 native ExecuteFunc takes string funcName returns nothing
1048
1049 //============================================================================
1050 // Boolean Expr API ( for compositing trigger conditions and unit filter funcs...)
1051 //============================================================================
1052 native And takes boolexpr operandA, boolexpr operandB returns boolexpr
1053 native Or takes boolexpr operandA, boolexpr operandB returns boolexpr
1054 native Not takes boolexpr operand returns boolexpr
1055 native Condition takes code func returns conditionfunc
1056 native DestroyCondition takes conditionfunc c returns nothing
1057 native Filter takes code func returns filterfunc
1058 native DestroyFilter takes filterfunc f returns nothing
1059 native DestroyBoolExpr takes boolexpr e returns nothing
1060
1061 //============================================================================
1062 // Trigger Game Event API
1063 //============================================================================
1064
1065 native TriggerRegisterVariableEvent takes trigger whichTrigger, string varName, limitop opcode, real limitval returns event
1066
1067 // EVENT_GAME_VARIABLE_LIMIT
1068 //constant native string GetTriggeringVariableName takes nothing returns string
1069
1070 // Creates it's own timer and triggers when it expires
1071 native TriggerRegisterTimerEvent takes trigger whichTrigger, real timeout, boolean periodic returns event
1072
1073 // Triggers when the timer you tell it about expires
1074 native TriggerRegisterTimerExpireEvent takes trigger whichTrigger, timer t returns event
1075
1076 native TriggerRegisterGameStateEvent takes trigger whichTrigger, gamestate whichState, limitop opcode, real limitval returns event
1077
1078 native TriggerRegisterDialogEvent takes trigger whichTrigger, dialog whichDialog returns event
1079 native TriggerRegisterDialogButtonEvent takes trigger whichTrigger, button whichButton returns event
1080
1081 // EVENT_GAME_STATE_LIMIT
1082 constant native GetEventGameState takes nothing returns gamestate
1083
1084 native TriggerRegisterGameEvent takes trigger whichTrigger, gameevent whichGameEvent returns event
1085
1086 // EVENT_GAME_VICTORY
1087 constant native GetWinningPlayer takes nothing returns player
1088
1089
1090 native TriggerRegisterEnterRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event
1091
1092 // EVENT_GAME_ENTER_REGION
1093 constant native GetTriggeringRegion takes nothing returns region
1094 constant native GetEnteringUnit takes nothing returns unit
1095
1096 // EVENT_GAME_LEAVE_REGION
1097
1098 native TriggerRegisterLeaveRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event
1099 constant native GetLeavingUnit takes nothing returns unit
1100
1101 native TriggerRegisterTrackableHitEvent takes trigger whichTrigger, trackable t returns event
1102 native TriggerRegisterTrackableTrackEvent takes trigger whichTrigger, trackable t returns event
1103
1104 // EVENT_GAME_TRACKABLE_HIT
1105 // EVENT_GAME_TRACKABLE_TRACK
1106 constant native GetTriggeringTrackable takes nothing returns trackable
1107
1108 // EVENT_DIALOG_BUTTON_CLICK
1109 constant native GetClickedButton takes nothing returns button
1110 constant native GetClickedDialog takes nothing returns dialog
1111
1112 // EVENT_GAME_TOURNAMENT_FINISH_SOON
1113 constant native GetTournamentFinishSoonTimeRemaining takes nothing returns real
1114 constant native GetTournamentFinishNowRule takes nothing returns integer
1115 constant native GetTournamentFinishNowPlayer takes nothing returns player
1116 constant native GetTournamentScore takes player whichPlayer returns integer
1117
1118 // EVENT_GAME_SAVE
1119 constant native GetSaveBasicFilename takes nothing returns string
1120
1121 //============================================================================
1122 // Trigger Player Based Event API
1123 //============================================================================
1124
1125 native TriggerRegisterPlayerEvent takes trigger whichTrigger, player whichPlayer, playerevent whichPlayerEvent returns event
1126
1127 // EVENT_PLAYER_DEFEAT
1128 // EVENT_PLAYER_VICTORY
1129 constant native GetTriggerPlayer takes nothing returns player
1130
1131 native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event
1132
1133 // EVENT_PLAYER_HERO_LEVEL
1134 // EVENT_UNIT_HERO_LEVEL
1135 constant native GetLevelingUnit takes nothing returns unit
1136
1137 // EVENT_PLAYER_HERO_SKILL
1138 // EVENT_UNIT_HERO_SKILL
1139 constant native GetLearningUnit takes nothing returns unit
1140 constant native GetLearnedSkill takes nothing returns integer
1141 constant native GetLearnedSkillLevel takes nothing returns integer
1142
1143 // EVENT_PLAYER_HERO_REVIVABLE
1144 constant native GetRevivableUnit takes nothing returns unit
1145
1146 // EVENT_PLAYER_HERO_REVIVE_START
1147 // EVENT_PLAYER_HERO_REVIVE_CANCEL
1148 // EVENT_PLAYER_HERO_REVIVE_FINISH
1149 // EVENT_UNIT_HERO_REVIVE_START
1150 // EVENT_UNIT_HERO_REVIVE_CANCEL
1151 // EVENT_UNIT_HERO_REVIVE_FINISH
1152 constant native GetRevivingUnit takes nothing returns unit
1153
1154 // EVENT_PLAYER_UNIT_ATTACKED
1155 constant native GetAttacker takes nothing returns unit
1156
1157 // EVENT_PLAYER_UNIT_RESCUED
1158 constant native GetRescuer takes nothing returns unit
1159
1160 // EVENT_PLAYER_UNIT_DEATH
1161 constant native GetDyingUnit takes nothing returns unit
1162 constant native GetKillingUnit takes nothing returns unit
1163
1164 // EVENT_PLAYER_UNIT_DECAY
1165 constant native GetDecayingUnit takes nothing returns unit
1166
1167 // EVENT_PLAYER_UNIT_SELECTED
1168 //constant native GetSelectedUnit takes nothing returns unit
1169
1170 // EVENT_PLAYER_UNIT_CONSTRUCT_START
1171 constant native GetConstructingStructure takes nothing returns unit
1172
1173 // EVENT_PLAYER_UNIT_CONSTRUCT_FINISH
1174 // EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL
1175 constant native GetCancelledStructure takes nothing returns unit
1176 constant native GetConstructedStructure takes nothing returns unit
1177
1178 // EVENT_PLAYER_UNIT_RESEARCH_START
1179 // EVENT_PLAYER_UNIT_RESEARCH_CANCEL
1180 // EVENT_PLAYER_UNIT_RESEARCH_FINISH
1181 constant native GetResearchingUnit takes nothing returns unit
1182 constant native GetResearched takes nothing returns integer
1183
1184 // EVENT_PLAYER_UNIT_TRAIN_START
1185 // EVENT_PLAYER_UNIT_TRAIN_CANCEL
1186 constant native GetTrainedUnitType takes nothing returns integer
1187
1188 // EVENT_PLAYER_UNIT_TRAIN_FINISH
1189 constant native GetTrainedUnit takes nothing returns unit
1190
1191 // EVENT_PLAYER_UNIT_DETECTED
1192 constant native GetDetectedUnit takes nothing returns unit
1193
1194 // EVENT_PLAYER_UNIT_SUMMONED
1195 constant native GetSummoningUnit takes nothing returns unit
1196 constant native GetSummonedUnit takes nothing returns unit
1197
1198 // EVENT_PLAYER_UNIT_LOADED
1199 constant native GetTransportUnit takes nothing returns unit
1200 constant native GetLoadedUnit takes nothing returns unit
1201
1202 // EVENT_PLAYER_UNIT_SELL
1203 constant native GetSellingUnit takes nothing returns unit
1204 constant native GetSoldUnit takes nothing returns unit
1205 constant native GetBuyingUnit takes nothing returns unit
1206
1207 // EVENT_PLAYER_UNIT_SELL_ITEM
1208 constant native GetSoldItem takes nothing returns item
1209
1210 // EVENT_PLAYER_UNIT_CHANGE_OWNER
1211 constant native GetChangingUnit takes nothing returns unit
1212 constant native GetChangingUnitPrevOwner takes nothing returns player
1213
1214 // EVENT_PLAYER_UNIT_DROP_ITEM
1215 // EVENT_PLAYER_UNIT_PICKUP_ITEM
1216 // EVENT_PLAYER_UNIT_USE_ITEM
1217 constant native GetManipulatingUnit takes nothing returns unit
1218 constant native GetManipulatedItem takes nothing returns item
1219
1220 // EVENT_PLAYER_UNIT_ISSUED_ORDER
1221 constant native GetOrderedUnit takes nothing returns unit
1222 constant native GetIssuedOrderId takes nothing returns integer
1223
1224 // EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER
1225 constant native GetOrderPointX takes nothing returns real
1226 constant native GetOrderPointY takes nothing returns real
1227 constant native GetOrderPointLoc takes nothing returns location
1228
1229 // EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER
1230 constant native GetOrderTarget takes nothing returns widget
1231 constant native GetOrderTargetDestructable takes nothing returns destructable
1232 constant native GetOrderTargetItem takes nothing returns item
1233 constant native GetOrderTargetUnit takes nothing returns unit
1234
1235 // EVENT_UNIT_SPELL_CHANNEL
1236 // EVENT_UNIT_SPELL_CAST
1237 // EVENT_UNIT_SPELL_EFFECT
1238 // EVENT_UNIT_SPELL_FINISH
1239 // EVENT_UNIT_SPELL_ENDCAST
1240 // EVENT_PLAYER_UNIT_SPELL_CHANNEL
1241 // EVENT_PLAYER_UNIT_SPELL_CAST
1242 // EVENT_PLAYER_UNIT_SPELL_EFFECT
1243 // EVENT_PLAYER_UNIT_SPELL_FINISH
1244 // EVENT_PLAYER_UNIT_SPELL_ENDCAST
1245 constant native GetSpellAbilityUnit takes nothing returns unit
1246 constant native GetSpellAbilityId takes nothing returns integer
1247 constant native GetSpellAbility takes nothing returns ability
1248 constant native GetSpellTargetLoc takes nothing returns location
1249 constant native GetSpellTargetX takes nothing returns real
1250 constant native GetSpellTargetY takes nothing returns real
1251 constant native GetSpellTargetDestructable takes nothing returns destructable
1252 constant native GetSpellTargetItem takes nothing returns item
1253 constant native GetSpellTargetUnit takes nothing returns unit
1254
1255 native TriggerRegisterPlayerAllianceChange takes trigger whichTrigger, player whichPlayer, alliancetype whichAlliance returns event
1256 native TriggerRegisterPlayerStateEvent takes trigger whichTrigger, player whichPlayer, playerstate whichState, limitop opcode, real limitval returns event
1257
1258 // EVENT_PLAYER_STATE_LIMIT
1259 constant native GetEventPlayerState takes nothing returns playerstate
1260
1261 native TriggerRegisterPlayerChatEvent takes trigger whichTrigger, player whichPlayer, string chatMessageToDetect, boolean exactMatchOnly returns event
1262
1263 // EVENT_PLAYER_CHAT
1264
1265 // returns the actual string they typed in ( same as what you registered for
1266 // if you required exact match )
1267 constant native GetEventPlayerChatString takes nothing returns string
1268
1269 // returns the string that you registered for
1270 constant native GetEventPlayerChatStringMatched takes nothing returns string
1271
1272 native TriggerRegisterDeathEvent takes trigger whichTrigger, widget whichWidget returns event
1273
1274 //============================================================================
1275 // Trigger Unit Based Event API
1276 //============================================================================
1277
1278 // returns handle to unit which triggered the most recent event when called from
1279 // within a trigger action function...returns null handle when used incorrectly
1280
1281 constant native GetTriggerUnit takes nothing returns unit
1282
1283 native TriggerRegisterUnitStateEvent takes trigger whichTrigger, unit whichUnit, unitstate whichState, limitop opcode, real limitval returns event
1284
1285 // EVENT_UNIT_STATE_LIMIT
1286 constant native GetEventUnitState takes nothing returns unitstate
1287
1288 native TriggerRegisterUnitEvent takes trigger whichTrigger, unit whichUnit, unitevent whichEvent returns event
1289
1290 // EVENT_UNIT_DAMAGED
1291 constant native GetEventDamage takes nothing returns real
1292 constant native GetEventDamageSource takes nothing returns unit
1293
1294 // EVENT_UNIT_DEATH
1295 // EVENT_UNIT_DECAY
1296 // Use the GetDyingUnit and GetDecayingUnit funcs above
1297
1298 // EVENT_UNIT_DETECTED
1299 constant native GetEventDetectingPlayer takes nothing returns player
1300
1301 native TriggerRegisterFilterUnitEvent takes trigger whichTrigger, unit whichUnit, unitevent whichEvent, boolexpr filter returns event
1302
1303 // EVENT_UNIT_ACQUIRED_TARGET
1304 // EVENT_UNIT_TARGET_IN_RANGE
1305 constant native GetEventTargetUnit takes nothing returns unit
1306
1307 // EVENT_UNIT_ATTACKED
1308 // Use GetAttacker from the Player Unit Event API Below...
1309
1310 // EVENT_UNIT_RESCUEDED
1311 // Use GetRescuer from the Player Unit Event API Below...
1312
1313 // EVENT_UNIT_CONSTRUCT_CANCEL
1314 // EVENT_UNIT_CONSTRUCT_FINISH
1315
1316 // See the Player Unit Construction Event API above for event info funcs
1317
1318 // EVENT_UNIT_TRAIN_START
1319 // EVENT_UNIT_TRAIN_CANCELLED
1320 // EVENT_UNIT_TRAIN_FINISH
1321
1322 // See the Player Unit Training Event API above for event info funcs
1323
1324 // EVENT_UNIT_SELL
1325
1326 // See the Player Unit Sell Event API above for event info funcs
1327
1328 // EVENT_UNIT_DROP_ITEM
1329 // EVENT_UNIT_PICKUP_ITEM
1330 // EVENT_UNIT_USE_ITEM
1331 // See the Player Unit/Item manipulation Event API above for event info funcs
1332
1333 // EVENT_UNIT_ISSUED_ORDER
1334 // EVENT_UNIT_ISSUED_POINT_ORDER
1335 // EVENT_UNIT_ISSUED_TARGET_ORDER
1336
1337 // See the Player Unit Order Event API above for event info funcs
1338
1339 native TriggerRegisterUnitInRange takes trigger whichTrigger, unit whichUnit, real range, boolexpr filter returns event
1340
1341 native TriggerAddCondition takes trigger whichTrigger, boolexpr condition returns triggercondition
1342 native TriggerRemoveCondition takes trigger whichTrigger, triggercondition whichCondition returns nothing
1343 native TriggerClearConditions takes trigger whichTrigger returns nothing
1344
1345 native TriggerAddAction takes trigger whichTrigger, code actionFunc returns triggeraction
1346 native TriggerRemoveAction takes trigger whichTrigger, triggeraction whichAction returns nothing
1347 native TriggerClearActions takes trigger whichTrigger returns nothing
1348 native TriggerSleepAction takes real timeout returns nothing
1349 native TriggerWaitForSound takes sound s, real offset returns nothing
1350 native TriggerEvaluate takes trigger whichTrigger returns boolean
1351 native TriggerExecute takes trigger whichTrigger returns nothing
1352 native TriggerExecuteWait takes trigger whichTrigger returns nothing
1353 native TriggerSyncStart takes nothing returns nothing
1354 native TriggerSyncReady takes nothing returns nothing
1355
1356 //============================================================================
1357 // Widget API
1358 native GetWidgetLife takes widget whichWidget returns real
1359 native SetWidgetLife takes widget whichWidget, real newLife returns nothing
1360 native GetWidgetX takes widget whichWidget returns real
1361 native GetWidgetY takes widget whichWidget returns real
1362 constant native GetTriggerWidget takes nothing returns widget
1363
1364 //============================================================================
1365 // Destructable Object API
1366 // Facing arguments are specified in degrees
1367 native CreateDestructable takes integer objectid, real x, real y, real face, real scale, integer variation returns destructable
1368 native CreateDestructableZ takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns destructable
1369 native CreateDeadDestructable takes integer objectid, real x, real y, real face, real scale, integer variation returns destructable
1370 native CreateDeadDestructableZ takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns destructable
1371 native RemoveDestructable takes destructable d returns nothing
1372 native KillDestructable takes destructable d returns nothing
1373 native SetDestructableInvulnerable takes destructable d, boolean flag returns nothing
1374 native IsDestructableInvulnerable takes destructable d returns boolean
1375 native EnumDestructablesInRect takes rect r, boolexpr filter, code actionFunc returns nothing
1376 native GetDestructableTypeId takes destructable d returns integer
1377 native GetDestructableX takes destructable d returns real
1378 native GetDestructableY takes destructable d returns real
1379 native SetDestructableLife takes destructable d, real life returns nothing
1380 native GetDestructableLife takes destructable d returns real
1381 native SetDestructableMaxLife takes destructable d, real max returns nothing
1382 native GetDestructableMaxLife takes destructable d returns real
1383 native DestructableRestoreLife takes destructable d, real life, boolean birth returns nothing
1384 native QueueDestructableAnimation takes destructable d, string whichAnimation returns nothing
1385 native SetDestructableAnimation takes destructable d, string whichAnimation returns nothing
1386 native SetDestructableAnimationSpeed takes destructable d, real speedFactor returns nothing
1387 native ShowDestructable takes destructable d, boolean flag returns nothing
1388 native GetDestructableOccluderHeight takes destructable d returns real
1389 native SetDestructableOccluderHeight takes destructable d, real height returns nothing
1390 native GetDestructableName takes destructable d returns string
1391 constant native GetTriggerDestructable takes nothing returns destructable
1392
1393 //============================================================================
1394 // Item API
1395 native CreateItem takes integer itemid, real x, real y returns item
1396 native RemoveItem takes item whichItem returns nothing
1397 native GetItemPlayer takes item whichItem returns player
1398 native GetItemTypeId takes item i returns integer
1399 native GetItemX takes item i returns real
1400 native GetItemY takes item i returns real
1401 native SetItemPosition takes item i, real x, real y returns nothing
1402 native SetItemDropOnDeath takes item whichItem, boolean flag returns nothing
1403 native SetItemDroppable takes item i, boolean flag returns nothing
1404 native SetItemPawnable takes item i, boolean flag returns nothing
1405 native SetItemPlayer takes item whichItem, player whichPlayer, boolean changeColor returns nothing
1406 native SetItemInvulnerable takes item whichItem, boolean flag returns nothing
1407 native IsItemInvulnerable takes item whichItem returns boolean
1408 native SetItemVisible takes item whichItem, boolean show returns nothing
1409 native IsItemVisible takes item whichItem returns boolean
1410 native IsItemOwned takes item whichItem returns boolean
1411 native IsItemPowerup takes item whichItem returns boolean
1412 native IsItemSellable takes item whichItem returns boolean
1413 native IsItemPawnable takes item whichItem returns boolean
1414 native IsItemIdPowerup takes integer itemId returns boolean
1415 native IsItemIdSellable takes integer itemId returns boolean
1416 native IsItemIdPawnable takes integer itemId returns boolean
1417 native EnumItemsInRect takes rect r, boolexpr filter, code actionFunc returns nothing
1418 native GetItemLevel takes item whichItem returns integer
1419 native GetItemType takes item whichItem returns itemtype
1420 native SetItemDropID takes item whichItem, integer unitId returns nothing
1421 constant native GetItemName takes item whichItem returns string
1422 native GetItemCharges takes item whichItem returns integer
1423 native SetItemCharges takes item whichItem, integer charges returns nothing
1424 native GetItemUserData takes item whichItem returns integer
1425 native SetItemUserData takes item whichItem, integer data returns nothing
1426
1427 //============================================================================
1428 // Unit API
1429 // Facing arguments are specified in degrees
1430 native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
1431 native CreateUnitByName takes player whichPlayer, string unitname, real x, real y, real face returns unit
1432 native CreateUnitAtLoc takes player id, integer unitid, location whichLocation, real face returns unit
1433 native CreateUnitAtLocByName takes player id, string unitname, location whichLocation, real face returns unit
1434 native CreateCorpse takes player whichPlayer, integer unitid, real x, real y, real face returns unit
1435
1436 native KillUnit takes unit whichUnit returns nothing
1437 native RemoveUnit takes unit whichUnit returns nothing
1438 native ShowUnit takes unit whichUnit, boolean show returns nothing
1439
1440 native SetUnitState takes unit whichUnit, unitstate whichUnitState, real newVal returns nothing
1441 native SetUnitX takes unit whichUnit, real newX returns nothing
1442 native SetUnitY takes unit whichUnit, real newY returns nothing
1443 native SetUnitPosition takes unit whichUnit, real newX, real newY returns nothing
1444 native SetUnitPositionLoc takes unit whichUnit, location whichLocation returns nothing
1445 native SetUnitFacing takes unit whichUnit, real facingAngle returns nothing
1446 native SetUnitFacingTimed takes unit whichUnit, real facingAngle, real duration returns nothing
1447 native SetUnitMoveSpeed takes unit whichUnit, real newSpeed returns nothing
1448 native SetUnitFlyHeight takes unit whichUnit, real newHeight, real rate returns nothing
1449 native SetUnitTurnSpeed takes unit whichUnit, real newTurnSpeed returns nothing
1450 native SetUnitPropWindow takes unit whichUnit, real newPropWindowAngle returns nothing
1451 native SetUnitAcquireRange takes unit whichUnit, real newAcquireRange returns nothing
1452 native SetUnitCreepGuard takes unit whichUnit, boolean creepGuard returns nothing
1453
1454 native GetUnitAcquireRange takes unit whichUnit returns real
1455 native GetUnitTurnSpeed takes unit whichUnit returns real
1456 native GetUnitPropWindow takes unit whichUnit returns real
1457 native GetUnitFlyHeight takes unit whichUnit returns real
1458
1459 native GetUnitDefaultAcquireRange takes unit whichUnit returns real
1460 native GetUnitDefaultTurnSpeed takes unit whichUnit returns real
1461 native GetUnitDefaultPropWindow takes unit whichUnit returns real
1462 native GetUnitDefaultFlyHeight takes unit whichUnit returns real
1463
1464 native SetUnitOwner takes unit whichUnit, player whichPlayer, boolean changeColor returns nothing
1465 native SetUnitColor takes unit whichUnit, playercolor whichColor returns nothing
1466
1467 native SetUnitScale takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing
1468 native SetUnitTimeScale takes unit whichUnit, real timeScale returns nothing
1469 native SetUnitBlendTime takes unit whichUnit, real blendTime returns nothing
1470 native SetUnitVertexColor takes unit whichUnit, integer red, integer green, integer blue, integer alpha returns nothing
1471
1472 native QueueUnitAnimation takes unit whichUnit, string whichAnimation returns nothing
1473 native SetUnitAnimation takes unit whichUnit, string whichAnimation returns nothing
1474 native SetUnitAnimationByIndex takes unit whichUnit, integer whichAnimation returns nothing
1475 native SetUnitAnimationWithRarity takes unit whichUnit, string whichAnimation, raritycontrol rarity returns nothing
1476 native AddUnitAnimationProperties takes unit whichUnit, string animProperties, boolean add returns nothing
1477
1478 native SetUnitLookAt takes unit whichUnit, string whichBone, unit lookAtTarget, real offsetX, real offsetY, real offsetZ returns nothing
1479 native ResetUnitLookAt takes unit whichUnit returns nothing
1480
1481 native SetUnitRescuable takes unit whichUnit, player byWhichPlayer, boolean flag returns nothing
1482 native SetUnitRescueRange takes unit whichUnit, real range returns nothing
1483
1484 native SetHeroStr takes unit whichHero, integer newStr, boolean permanent returns nothing
1485 native SetHeroAgi takes unit whichHero, integer newAgi, boolean permanent returns nothing
1486 native SetHeroInt takes unit whichHero, integer newInt, boolean permanent returns nothing
1487
1488 native GetHeroStr takes unit whichHero, boolean includeBonuses returns integer
1489 native GetHeroAgi takes unit whichHero, boolean includeBonuses returns integer
1490 native GetHeroInt takes unit whichHero, boolean includeBonuses returns integer
1491
1492 native UnitStripHeroLevel takes unit whichHero, integer howManyLevels returns boolean
1493
1494 native GetHeroXP takes unit whichHero returns integer
1495 native SetHeroXP takes unit whichHero, integer newXpVal, boolean showEyeCandy returns nothing
1496
1497 native GetHeroSkillPoints takes unit whichHero returns integer
1498 native UnitModifySkillPoints takes unit whichHero, integer skillPointDelta returns boolean
1499
1500 native AddHeroXP takes unit whichHero, integer xpToAdd, boolean showEyeCandy returns nothing
1501 native SetHeroLevel takes unit whichHero, integer level, boolean showEyeCandy returns nothing
1502 constant native GetHeroLevel takes unit whichHero returns integer
1503 constant native GetUnitLevel takes unit whichUnit returns integer
1504 native GetHeroProperName takes unit whichHero returns string
1505 native SuspendHeroXP takes unit whichHero, boolean flag returns nothing
1506 native IsSuspendedXP takes unit whichHero returns boolean
1507 native SelectHeroSkill takes unit whichHero, integer abilcode returns nothing
1508 native GetUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer
1509 native DecUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer
1510 native IncUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer
1511 native SetUnitAbilityLevel takes unit whichUnit, integer abilcode, integer level returns integer
1512 native ReviveHero takes unit whichHero, real x, real y, boolean doEyecandy returns boolean
1513 native ReviveHeroLoc takes unit whichHero, location loc, boolean doEyecandy returns boolean
1514 native SetUnitExploded takes unit whichUnit, boolean exploded returns nothing
1515 native SetUnitInvulnerable takes unit whichUnit, boolean flag returns nothing
1516 native PauseUnit takes unit whichUnit, boolean flag returns nothing
1517 native IsUnitPaused takes unit whichHero returns boolean
1518 native SetUnitPathing takes unit whichUnit, boolean flag returns nothing
1519
1520 native ClearSelection takes nothing returns nothing
1521 native SelectUnit takes unit whichUnit, boolean flag returns nothing
1522
1523 native GetUnitPointValue takes unit whichUnit returns integer
1524 native GetUnitPointValueByType takes integer unitType returns integer
1525 //native SetUnitPointValueByType takes integer unitType, integer newPointValue returns nothing
1526
1527 native UnitAddItem takes unit whichUnit, item whichItem returns boolean
1528 native UnitAddItemById takes unit whichUnit, integer itemId returns item
1529 native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean
1530 native UnitRemoveItem takes unit whichUnit, item whichItem returns nothing
1531 native UnitRemoveItemFromSlot takes unit whichUnit, integer itemSlot returns item
1532 native UnitHasItem takes unit whichUnit, item whichItem returns boolean
1533 native UnitItemInSlot takes unit whichUnit, integer itemSlot returns item
1534 native UnitInventorySize takes unit whichUnit returns integer
1535
1536 native UnitDropItemPoint takes unit whichUnit, item whichItem, real x, real y returns boolean
1537 native UnitDropItemSlot takes unit whichUnit, item whichItem, integer slot returns boolean
1538 native UnitDropItemTarget takes unit whichUnit, item whichItem, widget target returns boolean
1539
1540 native UnitUseItem takes unit whichUnit, item whichItem returns boolean
1541 native UnitUseItemPoint takes unit whichUnit, item whichItem, real x, real y returns boolean
1542 native UnitUseItemTarget takes unit whichUnit, item whichItem, widget target returns boolean
1543
1544 constant native GetUnitX takes unit whichUnit returns real
1545 constant native GetUnitY takes unit whichUnit returns real
1546 constant native GetUnitLoc takes unit whichUnit returns location
1547 constant native GetUnitFacing takes unit whichUnit returns real
1548 constant native GetUnitMoveSpeed takes unit whichUnit returns real
1549 constant native GetUnitDefaultMoveSpeed takes unit whichUnit returns real
1550 constant native GetUnitState takes unit whichUnit, unitstate whichUnitState returns real
1551 constant native GetOwningPlayer takes unit whichUnit returns player
1552 constant native GetUnitTypeId takes unit whichUnit returns integer
1553 constant native GetUnitRace takes unit whichUnit returns race
1554 constant native GetUnitName takes unit whichUnit returns string
1555 constant native GetUnitFoodUsed takes unit whichUnit returns integer
1556 constant native GetUnitFoodMade takes unit whichUnit returns integer
1557 constant native GetFoodMade takes integer unitId returns integer
1558 constant native GetFoodUsed takes integer unitId returns integer
1559 native SetUnitUseFood takes unit whichUnit, boolean useFood returns nothing
1560
1561 constant native GetUnitRallyPoint takes unit whichUnit returns location
1562 constant native GetUnitRallyUnit takes unit whichUnit returns unit
1563 constant native GetUnitRallyDestructable takes unit whichUnit returns destructable
1564
1565 constant native IsUnitInGroup takes unit whichUnit, group whichGroup returns boolean
1566 constant native IsUnitInForce takes unit whichUnit, force whichForce returns boolean
1567 constant native IsUnitOwnedByPlayer takes unit whichUnit, player whichPlayer returns boolean
1568 constant native IsUnitAlly takes unit whichUnit, player whichPlayer returns boolean
1569 constant native IsUnitEnemy takes unit whichUnit, player whichPlayer returns boolean
1570 constant native IsUnitVisible takes unit whichUnit, player whichPlayer returns boolean
1571 constant native IsUnitDetected takes unit whichUnit, player whichPlayer returns boolean
1572 constant native IsUnitInvisible takes unit whichUnit, player whichPlayer returns boolean
1573 constant native IsUnitFogged takes unit whichUnit, player whichPlayer returns boolean
1574 constant native IsUnitMasked takes unit whichUnit, player whichPlayer returns boolean
1575 constant native IsUnitSelected takes unit whichUnit, player whichPlayer returns boolean
1576 constant native IsUnitRace takes unit whichUnit, race whichRace returns boolean
1577 constant native IsUnitType takes unit whichUnit, unittype whichUnitType returns boolean
1578 constant native IsUnit takes unit whichUnit, unit whichSpecifiedUnit returns boolean
1579 constant native IsUnitInRange takes unit whichUnit, unit otherUnit, real distance returns boolean
1580 constant native IsUnitInRangeXY takes unit whichUnit, real x, real y, real distance returns boolean
1581 constant native IsUnitInRangeLoc takes unit whichUnit, location whichLocation, real distance returns boolean
1582 constant native IsUnitHidden takes unit whichUnit returns boolean
1583 constant native IsUnitIllusion takes unit whichUnit returns boolean
1584
1585 constant native IsUnitInTransport takes unit whichUnit, unit whichTransport returns boolean
1586 constant native IsUnitLoaded takes unit whichUnit returns boolean
1587
1588 constant native IsHeroUnitId takes integer unitId returns boolean
1589 constant native IsUnitIdType takes integer unitId, unittype whichUnitType returns boolean
1590
1591 native UnitShareVision takes unit whichUnit, player whichPlayer, boolean share returns nothing
1592 native UnitSuspendDecay takes unit whichUnit, boolean suspend returns nothing
1593 native UnitAddType takes unit whichUnit, unittype whichUnitType returns boolean
1594 native UnitRemoveType takes unit whichUnit, unittype whichUnitType returns boolean
1595
1596 native UnitAddAbility takes unit whichUnit, integer abilityId returns boolean
1597 native UnitRemoveAbility takes unit whichUnit, integer abilityId returns boolean
1598 native UnitMakeAbilityPermanent takes unit whichUnit, boolean permanent, integer abilityId returns boolean
1599 native UnitRemoveBuffs takes unit whichUnit, boolean removePositive, boolean removeNegative returns nothing
1600 native UnitRemoveBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns nothing
1601 native UnitHasBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns boolean
1602 native UnitCountBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns integer
1603 native UnitAddSleep takes unit whichUnit, boolean add returns nothing
1604 native UnitCanSleep takes unit whichUnit returns boolean
1605 native UnitAddSleepPerm takes unit whichUnit, boolean add returns nothing
1606 native UnitCanSleepPerm takes unit whichUnit returns boolean
1607 native UnitIsSleeping takes unit whichUnit returns boolean
1608 native UnitWakeUp takes unit whichUnit returns nothing
1609 native UnitApplyTimedLife takes unit whichUnit, integer buffId, real duration returns nothing
1610 native UnitIgnoreAlarm takes unit whichUnit, boolean flag returns boolean
1611 native UnitIgnoreAlarmToggled takes unit whichUnit returns boolean
1612 native UnitResetCooldown takes unit whichUnit returns nothing
1613 native UnitSetConstructionProgress takes unit whichUnit, integer constructionPercentage returns nothing
1614 native UnitSetUpgradeProgress takes unit whichUnit, integer upgradePercentage returns nothing
1615 native UnitPauseTimedLife takes unit whichUnit, boolean flag returns nothing
1616 native UnitSetUsesAltIcon takes unit whichUnit, boolean flag returns nothing
1617
1618 native UnitDamagePoint takes unit whichUnit, real delay, real radius, real x, real y, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
1619 native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean
1620
1621 native IssueImmediateOrder takes unit whichUnit, string order returns boolean
1622 native IssueImmediateOrderById takes unit whichUnit, integer order returns boolean
1623 native IssuePointOrder takes unit whichUnit, string order, real x, real y returns boolean
1624 native IssuePointOrderLoc takes unit whichUnit, string order, location whichLocation returns boolean
1625 native IssuePointOrderById takes unit whichUnit, integer order, real x, real y returns boolean
1626 native IssuePointOrderByIdLoc takes unit whichUnit, integer order, location whichLocation returns boolean
1627 native IssueTargetOrder takes unit whichUnit, string order, widget targetWidget returns boolean
1628 native IssueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean
1629 native IssueInstantPointOrder takes unit whichUnit, string order, real x, real y, widget instantTargetWidget returns boolean
1630 native IssueInstantPointOrderById takes unit whichUnit, integer order, real x, real y, widget instantTargetWidget returns boolean
1631 native IssueInstantTargetOrder takes unit whichUnit, string order, widget targetWidget, widget instantTargetWidget returns boolean
1632 native IssueInstantTargetOrderById takes unit whichUnit, integer order, widget targetWidget, widget instantTargetWidget returns boolean
1633 native IssueBuildOrder takes unit whichPeon, string unitToBuild, real x, real y returns boolean
1634 native IssueBuildOrderById takes unit whichPeon, integer unitId, real x, real y returns boolean
1635
1636 native IssueNeutralImmediateOrder takes player forWhichPlayer, unit neutralStructure, string unitToBuild returns boolean
1637 native IssueNeutralImmediateOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId returns boolean
1638 native IssueNeutralPointOrder takes player forWhichPlayer,unit neutralStructure, string unitToBuild, real x, real y returns boolean
1639 native IssueNeutralPointOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, real x, real y returns boolean
1640 native IssueNeutralTargetOrder takes player forWhichPlayer,unit neutralStructure, string unitToBuild, widget target returns boolean
1641 native IssueNeutralTargetOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, widget target returns boolean
1642
1643 native GetUnitCurrentOrder takes unit whichUnit returns integer
1644
1645 native SetResourceAmount takes unit whichUnit, integer amount returns nothing
1646 native AddResourceAmount takes unit whichUnit, integer amount returns nothing
1647 native GetResourceAmount takes unit whichUnit returns integer
1648
1649 native WaygateGetDestinationX takes unit waygate returns real
1650 native WaygateGetDestinationY takes unit waygate returns real
1651 native WaygateSetDestination takes unit waygate, real x, real y returns nothing
1652 native WaygateActivate takes unit waygate, boolean activate returns nothing
1653 native WaygateIsActive takes unit waygate returns boolean
1654
1655 native AddItemToAllStock takes integer itemId, integer currentStock, integer stockMax returns nothing
1656 native AddItemToStock takes unit whichUnit, integer itemId, integer currentStock, integer stockMax returns nothing
1657 native AddUnitToAllStock takes integer unitId, integer currentStock, integer stockMax returns nothing
1658 native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing
1659
1660 native RemoveItemFromAllStock takes integer itemId returns nothing
1661 native RemoveItemFromStock takes unit whichUnit, integer itemId returns nothing
1662 native RemoveUnitFromAllStock takes integer unitId returns nothing
1663 native RemoveUnitFromStock takes unit whichUnit, integer unitId returns nothing
1664
1665 native SetAllItemTypeSlots takes integer slots returns nothing
1666 native SetAllUnitTypeSlots takes integer slots returns nothing
1667 native SetItemTypeSlots takes unit whichUnit, integer slots returns nothing
1668 native SetUnitTypeSlots takes unit whichUnit, integer slots returns nothing
1669
1670 native GetUnitUserData takes unit whichUnit returns integer
1671 native SetUnitUserData takes unit whichUnit, integer data returns nothing
1672
1673 //============================================================================
1674 // Player API
1675 constant native Player takes integer number returns player
1676 constant native GetLocalPlayer takes nothing returns player
1677 constant native IsPlayerAlly takes player whichPlayer, player otherPlayer returns boolean
1678 constant native IsPlayerEnemy takes player whichPlayer, player otherPlayer returns boolean
1679 constant native IsPlayerInForce takes player whichPlayer, force whichForce returns boolean
1680 constant native IsPlayerObserver takes player whichPlayer returns boolean
1681 constant native IsVisibleToPlayer takes real x, real y, player whichPlayer returns boolean
1682 constant native IsLocationVisibleToPlayer takes location whichLocation, player whichPlayer returns boolean
1683 constant native IsFoggedToPlayer takes real x, real y, player whichPlayer returns boolean
1684 constant native IsLocationFoggedToPlayer takes location whichLocation, player whichPlayer returns boolean
1685 constant native IsMaskedToPlayer takes real x, real y, player whichPlayer returns boolean
1686 constant native IsLocationMaskedToPlayer takes location whichLocation, player whichPlayer returns boolean
1687
1688 constant native GetPlayerRace takes player whichPlayer returns race
1689 constant native GetPlayerId takes player whichPlayer returns integer
1690 constant native GetPlayerUnitCount takes player whichPlayer, boolean includeIncomplete returns integer
1691 constant native GetPlayerTypedUnitCount takes player whichPlayer, string unitName, boolean includeIncomplete, boolean includeUpgrades returns integer
1692 constant native GetPlayerStructureCount takes player whichPlayer, boolean includeIncomplete returns integer
1693 constant native GetPlayerState takes player whichPlayer, playerstate whichPlayerState returns integer
1694 constant native GetPlayerScore takes player whichPlayer, playerscore whichPlayerScore returns integer
1695 constant native GetPlayerAlliance takes player sourcePlayer, player otherPlayer, alliancetype whichAllianceSetting returns boolean
1696
1697 constant native GetPlayerHandicap takes player whichPlayer returns real
1698 constant native GetPlayerHandicapXP takes player whichPlayer returns real
1699 constant native SetPlayerHandicap takes player whichPlayer, real handicap returns nothing
1700 constant native SetPlayerHandicapXP takes player whichPlayer, real handicap returns nothing
1701
1702 constant native SetPlayerTechMaxAllowed takes player whichPlayer, integer techid, integer maximum returns nothing
1703 constant native GetPlayerTechMaxAllowed takes player whichPlayer, integer techid returns integer
1704 constant native AddPlayerTechResearched takes player whichPlayer, integer techid, integer levels returns nothing
1705 constant native SetPlayerTechResearched takes player whichPlayer, integer techid, integer setToLevel returns nothing
1706 constant native GetPlayerTechResearched takes player whichPlayer, integer techid, boolean specificonly returns boolean
1707 constant native GetPlayerTechCount takes player whichPlayer, integer techid, boolean specificonly returns integer
1708
1709 native SetPlayerUnitsOwner takes player whichPlayer, integer newOwner returns nothing
1710 native CripplePlayer takes player whichPlayer, force toWhichPlayers, boolean flag returns nothing
1711
1712 native SetPlayerAbilityAvailable takes player whichPlayer, integer abilid, boolean avail returns nothing
1713
1714 native SetPlayerState takes player whichPlayer, playerstate whichPlayerState, integer value returns nothing
1715 native RemovePlayer takes player whichPlayer, playergameresult gameResult returns nothing
1716
1717 // Used to store hero level data for the scorescreen
1718 // before units are moved to neutral passive in melee games
1719 //
1720 native CachePlayerHeroData takes player whichPlayer returns nothing
1721
1722 //============================================================================
1723 // Fog of War API
1724 native SetFogStateRect takes player forWhichPlayer, fogstate whichState, rect where, boolean useSharedVision returns nothing
1725 native SetFogStateRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision returns nothing
1726 native SetFogStateRadiusLoc takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision returns nothing
1727 native FogMaskEnable takes boolean enable returns nothing
1728 native IsFogMaskEnabled takes nothing returns boolean
1729 native FogEnable takes boolean enable returns nothing
1730 native IsFogEnabled takes nothing returns boolean
1731
1732 native CreateFogModifierRect takes player forWhichPlayer, fogstate whichState, rect where, boolean useSharedVision, boolean afterUnits returns fogmodifier
1733 native CreateFogModifierRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision, boolean afterUnits returns fogmodifier
1734 native CreateFogModifierRadiusLoc takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision, boolean afterUnits returns fogmodifier
1735 native DestroyFogModifier takes fogmodifier whichFogModifier returns nothing
1736 native FogModifierStart takes fogmodifier whichFogModifier returns nothing
1737 native FogModifierStop takes fogmodifier whichFogModifier returns nothing
1738
1739 //============================================================================
1740 // Game API
1741 native VersionGet takes nothing returns version
1742 native VersionCompatible takes version whichVersion returns boolean
1743 native VersionSupported takes version whichVersion returns boolean
1744
1745 native EndGame takes boolean doScoreScreen returns nothing
1746
1747 // Async only!
1748 native ChangeLevel takes string newLevel, boolean doScoreScreen returns nothing
1749 native RestartGame takes boolean doScoreScreen returns nothing
1750 native ReloadGame takes nothing returns nothing
1751 // %%% SetCampaignMenuRace is deprecated. It must remain to support
1752 // old maps which use it, but all new maps should use SetCampaignMenuRaceEx
1753 native SetCampaignMenuRace takes race r returns nothing
1754 native SetCampaignMenuRaceEx takes integer campaignIndex returns nothing
1755 native ForceCampaignSelectScreen takes nothing returns nothing
1756
1757 native LoadGame takes string saveFileName, boolean doScoreScreen returns nothing
1758 native SaveGame takes string saveFileName returns nothing
1759 native RenameSaveDirectory takes string sourceDirName, string destDirName returns boolean
1760 native RemoveSaveDirectory takes string sourceDirName returns boolean
1761 native CopySaveGame takes string sourceSaveName, string destSaveName returns boolean
1762 native SaveGameExists takes string saveName returns boolean
1763 native SyncSelections takes nothing returns nothing
1764 native SetFloatGameState takes fgamestate whichFloatGameState, real value returns nothing
1765 constant native GetFloatGameState takes fgamestate whichFloatGameState returns real
1766 native SetIntegerGameState takes igamestate whichIntegerGameState, integer value returns nothing
1767 constant native GetIntegerGameState takes igamestate whichIntegerGameState returns integer
1768
1769
1770 //============================================================================
1771 // Campaign API
1772 native SetTutorialCleared takes boolean cleared returns nothing
1773 native SetMissionAvailable takes integer campaignNumber, integer missionNumber, boolean available returns nothing
1774 native SetCampaignAvailable takes integer campaignNumber, boolean available returns nothing
1775 native SetOpCinematicAvailable takes integer campaignNumber, boolean available returns nothing
1776 native SetEdCinematicAvailable takes integer campaignNumber, boolean available returns nothing
1777 native GetDefaultDifficulty takes nothing returns gamedifficulty
1778 native SetDefaultDifficulty takes gamedifficulty g returns nothing
1779 native SetCustomCampaignButtonVisible takes integer whichButton, boolean visible returns nothing
1780 native GetCustomCampaignButtonVisible takes integer whichButton returns boolean
1781 native DoNotSaveReplay takes nothing returns nothing
1782
1783 //============================================================================
1784 // Dialog API
1785 native DialogCreate takes nothing returns dialog
1786 native DialogDestroy takes dialog whichDialog returns nothing
1787 native DialogClear takes dialog whichDialog returns nothing
1788 native DialogSetMessage takes dialog whichDialog, string messageText returns nothing
1789 native DialogAddButton takes dialog whichDialog, string buttonText, integer hotkey returns button
1790 native DialogAddQuitButton takes dialog whichDialog, boolean doScoreScreen, string buttonText, integer hotkey returns button
1791 native DialogDisplay takes player whichPlayer, dialog whichDialog, boolean flag returns nothing
1792
1793 // Creates a new or reads in an existing game cache file stored
1794 // in the current campaign profile dir
1795 //
1796 native ReloadGameCachesFromDisk takes nothing returns boolean
1797
1798 native InitGameCache takes string campaignFile returns gamecache
1799 native SaveGameCache takes gamecache whichCache returns boolean
1800
1801 native StoreInteger takes gamecache cache, string missionKey, string key, integer value returns nothing
1802 native StoreReal takes gamecache cache, string missionKey, string key, real value returns nothing
1803 native StoreBoolean takes gamecache cache, string missionKey, string key, boolean value returns nothing
1804 native StoreUnit takes gamecache cache, string missionKey, string key, unit whichUnit returns boolean
1805 native StoreString takes gamecache cache, string missionKey, string key, string value returns boolean
1806
1807 native SyncStoredInteger takes gamecache cache, string missionKey, string key returns nothing
1808 native SyncStoredReal takes gamecache cache, string missionKey, string key returns nothing
1809 native SyncStoredBoolean takes gamecache cache, string missionKey, string key returns nothing
1810 native SyncStoredUnit takes gamecache cache, string missionKey, string key returns nothing
1811 native SyncStoredString takes gamecache cache, string missionKey, string key returns nothing
1812
1813 native HaveStoredInteger takes gamecache cache, string missionKey, string key returns boolean
1814 native HaveStoredReal takes gamecache cache, string missionKey, string key returns boolean
1815 native HaveStoredBoolean takes gamecache cache, string missionKey, string key returns boolean
1816 native HaveStoredUnit takes gamecache cache, string missionKey, string key returns boolean
1817 native HaveStoredString takes gamecache cache, string missionKey, string key returns boolean
1818
1819 native FlushGameCache takes gamecache cache returns nothing
1820 native FlushStoredMission takes gamecache cache, string missionKey returns nothing
1821 native FlushStoredInteger takes gamecache cache, string missionKey, string key returns nothing
1822 native FlushStoredReal takes gamecache cache, string missionKey, string key returns nothing
1823 native FlushStoredBoolean takes gamecache cache, string missionKey, string key returns nothing
1824 native FlushStoredUnit takes gamecache cache, string missionKey, string key returns nothing
1825 native FlushStoredString takes gamecache cache, string missionKey, string key returns nothing
1826
1827 // Will return 0 if the specified value's data is not found in the cache
1828 native GetStoredInteger takes gamecache cache, string missionKey, string key returns integer
1829 native GetStoredReal takes gamecache cache, string missionKey, string key returns real
1830 native GetStoredBoolean takes gamecache cache, string missionKey, string key returns boolean
1831 native GetStoredString takes gamecache cache, string missionKey, string key returns string
1832 native RestoreUnit takes gamecache cache, string missionKey, string key, player forWhichPlayer, real x, real y, real facing returns unit
1833
1834
1835 native InitHashtable takes nothing returns hashtable
1836
1837 native SaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing
1838 native SaveReal takes hashtable table, integer parentKey, integer childKey, real value returns nothing
1839 native SaveBoolean takes hashtable table, integer parentKey, integer childKey, boolean value returns nothing
1840 native SaveStr takes hashtable table, integer parentKey, integer childKey, string value returns boolean
1841 native SavePlayerHandle takes hashtable table, integer parentKey, integer childKey, player whichPlayer returns boolean
1842 native SaveWidgetHandle takes hashtable table, integer parentKey, integer childKey, widget whichWidget returns boolean
1843 native SaveDestructableHandle takes hashtable table, integer parentKey, integer childKey, destructable whichDestructable returns boolean
1844 native SaveItemHandle takes hashtable table, integer parentKey, integer childKey, item whichItem returns boolean
1845 native SaveUnitHandle takes hashtable table, integer parentKey, integer childKey, unit whichUnit returns boolean
1846 native SaveAbilityHandle takes hashtable table, integer parentKey, integer childKey, ability whichAbility returns boolean
1847 native SaveTimerHandle takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean
1848 native SaveTriggerHandle takes hashtable table, integer parentKey, integer childKey, trigger whichTrigger returns boolean
1849 native SaveTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey, triggercondition whichTriggercondition returns boolean
1850 native SaveTriggerActionHandle takes hashtable table, integer parentKey, integer childKey, triggeraction whichTriggeraction returns boolean
1851 native SaveTriggerEventHandle takes hashtable table, integer parentKey, integer childKey, event whichEvent returns boolean
1852 native SaveForceHandle takes hashtable table, integer parentKey, integer childKey, force whichForce returns boolean
1853 native SaveGroupHandle takes hashtable table, integer parentKey, integer childKey, group whichGroup returns boolean
1854 native SaveLocationHandle takes hashtable table, integer parentKey, integer childKey, location whichLocation returns boolean
1855 native SaveRectHandle takes hashtable table, integer parentKey, integer childKey, rect whichRect returns boolean
1856 native SaveBooleanExprHandle takes hashtable table, integer parentKey, integer childKey, boolexpr whichBoolexpr returns boolean
1857 native SaveSoundHandle takes hashtable table, integer parentKey, integer childKey, sound whichSound returns boolean
1858 native SaveEffectHandle takes hashtable table, integer parentKey, integer childKey, effect whichEffect returns boolean
1859 native SaveUnitPoolHandle takes hashtable table, integer parentKey, integer childKey, unitpool whichUnitpool returns boolean
1860 native SaveItemPoolHandle takes hashtable table, integer parentKey, integer childKey, itempool whichItempool returns boolean
1861 native SaveQuestHandle takes hashtable table, integer parentKey, integer childKey, quest whichQuest returns boolean
1862 native SaveQuestItemHandle takes hashtable table, integer parentKey, integer childKey, questitem whichQuestitem returns boolean
1863 native SaveDefeatConditionHandle takes hashtable table, integer parentKey, integer childKey, defeatcondition whichDefeatcondition returns boolean
1864 native SaveTimerDialogHandle takes hashtable table, integer parentKey, integer childKey, timerdialog whichTimerdialog returns boolean
1865 native SaveLeaderboardHandle takes hashtable table, integer parentKey, integer childKey, leaderboard whichLeaderboard returns boolean
1866 native SaveMultiboardHandle takes hashtable table, integer parentKey, integer childKey, multiboard whichMultiboard returns boolean
1867 native SaveMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey, multiboarditem whichMultiboarditem returns boolean
1868 native SaveTrackableHandle takes hashtable table, integer parentKey, integer childKey, trackable whichTrackable returns boolean
1869 native SaveDialogHandle takes hashtable table, integer parentKey, integer childKey, dialog whichDialog returns boolean
1870 native SaveButtonHandle takes hashtable table, integer parentKey, integer childKey, button whichButton returns boolean
1871 native SaveTextTagHandle takes hashtable table, integer parentKey, integer childKey, texttag whichTexttag returns boolean
1872 native SaveLightningHandle takes hashtable table, integer parentKey, integer childKey, lightning whichLightning returns boolean
1873 native SaveImageHandle takes hashtable table, integer parentKey, integer childKey, image whichImage returns boolean
1874 native SaveUbersplatHandle takes hashtable table, integer parentKey, integer childKey, ubersplat whichUbersplat returns boolean
1875 native SaveRegionHandle takes hashtable table, integer parentKey, integer childKey, region whichRegion returns boolean
1876 native SaveFogStateHandle takes hashtable table, integer parentKey, integer childKey, fogstate whichFogState returns boolean
1877 native SaveFogModifierHandle takes hashtable table, integer parentKey, integer childKey, fogmodifier whichFogModifier returns boolean
1878 native SaveAgentHandle takes hashtable table, integer parentKey, integer childKey, agent whichAgent returns boolean
1879 native SaveHashtableHandle takes hashtable table, integer parentKey, integer childKey, hashtable whichHashtable returns boolean
1880
1881
1882 native LoadInteger takes hashtable table, integer parentKey, integer childKey returns integer
1883 native LoadReal takes hashtable table, integer parentKey, integer childKey returns real
1884 native LoadBoolean takes hashtable table, integer parentKey, integer childKey returns boolean
1885 native LoadStr takes hashtable table, integer parentKey, integer childKey returns string
1886 native LoadPlayerHandle takes hashtable table, integer parentKey, integer childKey returns player
1887 native LoadWidgetHandle takes hashtable table, integer parentKey, integer childKey returns widget
1888 native LoadDestructableHandle takes hashtable table, integer parentKey, integer childKey returns destructable
1889 native LoadItemHandle takes hashtable table, integer parentKey, integer childKey returns item
1890 native LoadUnitHandle takes hashtable table, integer parentKey, integer childKey returns unit
1891 native LoadAbilityHandle takes hashtable table, integer parentKey, integer childKey returns ability
1892 native LoadTimerHandle takes hashtable table, integer parentKey, integer childKey returns timer
1893 native LoadTriggerHandle takes hashtable table, integer parentKey, integer childKey returns trigger
1894 native LoadTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey returns triggercondition
1895 native LoadTriggerActionHandle takes hashtable table, integer parentKey, integer childKey returns triggeraction
1896 native LoadTriggerEventHandle takes hashtable table, integer parentKey, integer childKey returns event
1897 native LoadForceHandle takes hashtable table, integer parentKey, integer childKey returns force
1898 native LoadGroupHandle takes hashtable table, integer parentKey, integer childKey returns group
1899 native LoadLocationHandle takes hashtable table, integer parentKey, integer childKey returns location
1900 native LoadRectHandle takes hashtable table, integer parentKey, integer childKey returns rect
1901 native LoadBooleanExprHandle takes hashtable table, integer parentKey, integer childKey returns boolexpr
1902 native LoadSoundHandle takes hashtable table, integer parentKey, integer childKey returns sound
1903 native LoadEffectHandle takes hashtable table, integer parentKey, integer childKey returns effect
1904 native LoadUnitPoolHandle takes hashtable table, integer parentKey, integer childKey returns unitpool
1905 native LoadItemPoolHandle takes hashtable table, integer parentKey, integer childKey returns itempool
1906 native LoadQuestHandle takes hashtable table, integer parentKey, integer childKey returns quest
1907 native LoadQuestItemHandle takes hashtable table, integer parentKey, integer childKey returns questitem
1908 native LoadDefeatConditionHandle takes hashtable table, integer parentKey, integer childKey returns defeatcondition
1909 native LoadTimerDialogHandle takes hashtable table, integer parentKey, integer childKey returns timerdialog
1910 native LoadLeaderboardHandle takes hashtable table, integer parentKey, integer childKey returns leaderboard
1911 native LoadMultiboardHandle takes hashtable table, integer parentKey, integer childKey returns multiboard
1912 native LoadMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey returns multiboarditem
1913 native LoadTrackableHandle takes hashtable table, integer parentKey, integer childKey returns trackable
1914 native LoadDialogHandle takes hashtable table, integer parentKey, integer childKey returns dialog
1915 native LoadButtonHandle takes hashtable table, integer parentKey, integer childKey returns button
1916 native LoadTextTagHandle takes hashtable table, integer parentKey, integer childKey returns texttag
1917 native LoadLightningHandle takes hashtable table, integer parentKey, integer childKey returns lightning
1918 native LoadImageHandle takes hashtable table, integer parentKey, integer childKey returns image
1919 native LoadUbersplatHandle takes hashtable table, integer parentKey, integer childKey returns ubersplat
1920 native LoadRegionHandle takes hashtable table, integer parentKey, integer childKey returns region
1921 native LoadFogStateHandle takes hashtable table, integer parentKey, integer childKey returns fogstate
1922 native LoadFogModifierHandle takes hashtable table, integer parentKey, integer childKey returns fogmodifier
1923 native LoadHashtableHandle takes hashtable table, integer parentKey, integer childKey returns hashtable
1924
1925 native HaveSavedInteger takes hashtable table, integer parentKey, integer childKey returns boolean
1926 native HaveSavedReal takes hashtable table, integer parentKey, integer childKey returns boolean
1927 native HaveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns boolean
1928 native HaveSavedString takes hashtable table, integer parentKey, integer childKey returns boolean
1929 native HaveSavedHandle takes hashtable table, integer parentKey, integer childKey returns boolean
1930
1931 native RemoveSavedInteger takes hashtable table, integer parentKey, integer childKey returns nothing
1932 native RemoveSavedReal takes hashtable table, integer parentKey, integer childKey returns nothing
1933 native RemoveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns nothing
1934 native RemoveSavedString takes hashtable table, integer parentKey, integer childKey returns nothing
1935 native RemoveSavedHandle takes hashtable table, integer parentKey, integer childKey returns nothing
1936
1937 native FlushParentHashtable takes hashtable table returns nothing
1938 native FlushChildHashtable takes hashtable table, integer parentKey returns nothing
1939
1940
1941 //============================================================================
1942 // Randomization API
1943 native GetRandomInt takes integer lowBound, integer highBound returns integer
1944 native GetRandomReal takes real lowBound, real highBound returns real
1945
1946 native CreateUnitPool takes nothing returns unitpool
1947 native DestroyUnitPool takes unitpool whichPool returns nothing
1948 native UnitPoolAddUnitType takes unitpool whichPool, integer unitId, real weight returns nothing
1949 native UnitPoolRemoveUnitType takes unitpool whichPool, integer unitId returns nothing
1950 native PlaceRandomUnit takes unitpool whichPool, player forWhichPlayer, real x, real y, real facing returns unit
1951
1952 native CreateItemPool takes nothing returns itempool
1953 native DestroyItemPool takes itempool whichItemPool returns nothing
1954 native ItemPoolAddItemType takes itempool whichItemPool, integer itemId, real weight returns nothing
1955 native ItemPoolRemoveItemType takes itempool whichItemPool, integer itemId returns nothing
1956 native PlaceRandomItem takes itempool whichItemPool, real x, real y returns item
1957
1958 // Choose any random unit/item. (NP means Neutral Passive)
1959 native ChooseRandomCreep takes integer level returns integer
1960 native ChooseRandomNPBuilding takes nothing returns integer
1961 native ChooseRandomItem takes integer level returns integer
1962 native ChooseRandomItemEx takes itemtype whichType, integer level returns integer
1963 native SetRandomSeed takes integer seed returns nothing
1964
1965 //============================================================================
1966 // Visual API
1967 native SetTerrainFog takes real a, real b, real c, real d, real e returns nothing
1968 native ResetTerrainFog takes nothing returns nothing
1969
1970 native SetUnitFog takes real a, real b, real c, real d, real e returns nothing
1971 native SetTerrainFogEx takes integer style, real zstart, real zend, real density, real red, real green, real blue returns nothing
1972 native DisplayTextToPlayer takes player toPlayer, real x, real y, string message returns nothing
1973 native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
1974 native DisplayTimedTextFromPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing
1975 native ClearTextMessages takes nothing returns nothing
1976 native SetDayNightModels takes string terrainDNCFile, string unitDNCFile returns nothing
1977 native SetSkyModel takes string skyModelFile returns nothing
1978 native EnableUserControl takes boolean b returns nothing
1979 native EnableUserUI takes boolean b returns nothing
1980 native SuspendTimeOfDay takes boolean b returns nothing
1981 native SetTimeOfDayScale takes real r returns nothing
1982 native GetTimeOfDayScale takes nothing returns real
1983 native ShowInterface takes boolean flag, real fadeDuration returns nothing
1984 native PauseGame takes boolean flag returns nothing
1985 native UnitAddIndicator takes unit whichUnit, integer red, integer green, integer blue, integer alpha returns nothing
1986 native AddIndicator takes widget whichWidget, integer red, integer green, integer blue, integer alpha returns nothing
1987 native PingMinimap takes real x, real y, real duration returns nothing
1988 native PingMinimapEx takes real x, real y, real duration, integer red, integer green, integer blue, boolean extraEffects returns nothing
1989 native EnableOcclusion takes boolean flag returns nothing
1990 native SetIntroShotText takes string introText returns nothing
1991 native SetIntroShotModel takes string introModelPath returns nothing
1992 native EnableWorldFogBoundary takes boolean b returns nothing
1993 native PlayModelCinematic takes string modelName returns nothing
1994 native PlayCinematic takes string movieName returns nothing
1995 native ForceUIKey takes string key returns nothing
1996 native ForceUICancel takes nothing returns nothing
1997 native DisplayLoadDialog takes nothing returns nothing
1998 native SetAltMinimapIcon takes string iconPath returns nothing
1999 native DisableRestartMission takes boolean flag returns nothing
2000
2001 native CreateTextTag takes nothing returns texttag
2002 native DestroyTextTag takes texttag t returns nothing
2003 native SetTextTagText takes texttag t, string s, real height returns nothing
2004 native SetTextTagPos takes texttag t, real x, real y, real heightOffset returns nothing
2005 native SetTextTagPosUnit takes texttag t, unit whichUnit, real heightOffset returns nothing
2006 native SetTextTagColor takes texttag t, integer red, integer green, integer blue, integer alpha returns nothing
2007 native SetTextTagVelocity takes texttag t, real xvel, real yvel returns nothing
2008 native SetTextTagVisibility takes texttag t, boolean flag returns nothing
2009 native SetTextTagSuspended takes texttag t, boolean flag returns nothing
2010 native SetTextTagPermanent takes texttag t, boolean flag returns nothing
2011 native SetTextTagAge takes texttag t, real age returns nothing
2012 native SetTextTagLifespan takes texttag t, real lifespan returns nothing
2013 native SetTextTagFadepoint takes texttag t, real fadepoint returns nothing
2014
2015 native SetReservedLocalHeroButtons takes integer reserved returns nothing
2016 native GetAllyColorFilterState takes nothing returns integer
2017 native SetAllyColorFilterState takes integer state returns nothing
2018 native GetCreepCampFilterState takes nothing returns boolean
2019 native SetCreepCampFilterState takes boolean state returns nothing
2020 native EnableMinimapFilterButtons takes boolean enableAlly, boolean enableCreep returns nothing
2021 native EnableDragSelect takes boolean state, boolean ui returns nothing
2022 native EnablePreSelect takes boolean state, boolean ui returns nothing
2023 native EnableSelect takes boolean state, boolean ui returns nothing
2024
2025 //============================================================================
2026 // Trackable API
2027 native CreateTrackable takes string trackableModelPath, real x, real y, real facing returns trackable
2028
2029 //============================================================================
2030 // Quest API
2031 native CreateQuest takes nothing returns quest
2032 native DestroyQuest takes quest whichQuest returns nothing
2033 native QuestSetTitle takes quest whichQuest, string title returns nothing
2034 native QuestSetDescription takes quest whichQuest, string description returns nothing
2035 native QuestSetIconPath takes quest whichQuest, string iconPath returns nothing
2036
2037 native QuestSetRequired takes quest whichQuest, boolean required returns nothing
2038 native QuestSetCompleted takes quest whichQuest, boolean completed returns nothing
2039 native QuestSetDiscovered takes quest whichQuest, boolean discovered returns nothing
2040 native QuestSetFailed takes quest whichQuest, boolean failed returns nothing
2041 native QuestSetEnabled takes quest whichQuest, boolean enabled returns nothing
2042
2043 native IsQuestRequired takes quest whichQuest returns boolean
2044 native IsQuestCompleted takes quest whichQuest returns boolean
2045 native IsQuestDiscovered takes quest whichQuest returns boolean
2046 native IsQuestFailed takes quest whichQuest returns boolean
2047 native IsQuestEnabled takes quest whichQuest returns boolean
2048
2049 native QuestCreateItem takes quest whichQuest returns questitem
2050 native QuestItemSetDescription takes questitem whichQuestItem, string description returns nothing
2051 native QuestItemSetCompleted takes questitem whichQuestItem, boolean completed returns nothing
2052
2053 native IsQuestItemCompleted takes questitem whichQuestItem returns boolean
2054
2055 native CreateDefeatCondition takes nothing returns defeatcondition
2056 native DestroyDefeatCondition takes defeatcondition whichCondition returns nothing
2057 native DefeatConditionSetDescription takes defeatcondition whichCondition, string description returns nothing
2058
2059 native FlashQuestDialogButton takes nothing returns nothing
2060 native ForceQuestDialogUpdate takes nothing returns nothing
2061
2062 //============================================================================
2063 // Timer Dialog API
2064 native CreateTimerDialog takes timer t returns timerdialog
2065 native DestroyTimerDialog takes timerdialog whichDialog returns nothing
2066 native TimerDialogSetTitle takes timerdialog whichDialog, string title returns nothing
2067 native TimerDialogSetTitleColor takes timerdialog whichDialog, integer red, integer green, integer blue, integer alpha returns nothing
2068 native TimerDialogSetTimeColor takes timerdialog whichDialog, integer red, integer green, integer blue, integer alpha returns nothing
2069 native TimerDialogSetSpeed takes timerdialog whichDialog, real speedMultFactor returns nothing
2070 native TimerDialogDisplay takes timerdialog whichDialog, boolean display returns nothing
2071 native IsTimerDialogDisplayed takes timerdialog whichDialog returns boolean
2072 native TimerDialogSetRealTimeRemaining takes timerdialog whichDialog, real timeRemaining returns nothing
2073
2074 //============================================================================
2075 // Leaderboard API
2076
2077 // Create a leaderboard object
2078 native CreateLeaderboard takes nothing returns leaderboard
2079 native DestroyLeaderboard takes leaderboard lb returns nothing
2080
2081 native LeaderboardDisplay takes leaderboard lb, boolean show returns nothing
2082 native IsLeaderboardDisplayed takes leaderboard lb returns boolean
2083
2084 native LeaderboardGetItemCount takes leaderboard lb returns integer
2085
2086 native LeaderboardSetSizeByItemCount takes leaderboard lb, integer count returns nothing
2087 native LeaderboardAddItem takes leaderboard lb, string label, integer value, player p returns nothing
2088 native LeaderboardRemoveItem takes leaderboard lb, integer index returns nothing
2089 native LeaderboardRemovePlayerItem takes leaderboard lb, player p returns nothing
2090 native LeaderboardClear takes leaderboard lb returns nothing
2091
2092 native LeaderboardSortItemsByValue takes leaderboard lb, boolean ascending returns nothing
2093 native LeaderboardSortItemsByPlayer takes leaderboard lb, boolean ascending returns nothing
2094 native LeaderboardSortItemsByLabel takes leaderboard lb, boolean ascending returns nothing
2095
2096 native LeaderboardHasPlayerItem takes leaderboard lb, player p returns boolean
2097 native LeaderboardGetPlayerIndex takes leaderboard lb, player p returns integer
2098 native LeaderboardSetLabel takes leaderboard lb, string label returns nothing
2099 native LeaderboardGetLabelText takes leaderboard lb returns string
2100
2101 native PlayerSetLeaderboard takes player toPlayer, leaderboard lb returns nothing
2102 native PlayerGetLeaderboard takes player toPlayer returns leaderboard
2103
2104 native LeaderboardSetLabelColor takes leaderboard lb, integer red, integer green, integer blue, integer alpha returns nothing
2105 native LeaderboardSetValueColor takes leaderboard lb, integer red, integer green, integer blue, integer alpha returns nothing
2106 native LeaderboardSetStyle takes leaderboard lb, boolean showLabel, boolean showNames, boolean showValues, boolean showIcons returns nothing
2107
2108 native LeaderboardSetItemValue takes leaderboard lb, integer whichItem, integer val returns nothing
2109 native LeaderboardSetItemLabel takes leaderboard lb, integer whichItem, string val returns nothing
2110 native LeaderboardSetItemStyle takes leaderboard lb, integer whichItem, boolean showLabel, boolean showValue, boolean showIcon returns nothing
2111 native LeaderboardSetItemLabelColor takes leaderboard lb, integer whichItem, integer red, integer green, integer blue, integer alpha returns nothing
2112 native LeaderboardSetItemValueColor takes leaderboard lb, integer whichItem, integer red, integer green, integer blue, integer alpha returns nothing
2113
2114 //============================================================================
2115 // Multiboard API
2116 //============================================================================
2117
2118 // Create a multiboard object
2119 native CreateMultiboard takes nothing returns multiboard
2120 native DestroyMultiboard takes multiboard lb returns nothing
2121
2122 native MultiboardDisplay takes multiboard lb, boolean show returns nothing
2123 native IsMultiboardDisplayed takes multiboard lb returns boolean
2124
2125 native MultiboardMinimize takes multiboard lb, boolean minimize returns nothing
2126 native IsMultiboardMinimized takes multiboard lb returns boolean
2127 native MultiboardClear takes multiboard lb returns nothing
2128
2129 native MultiboardSetTitleText takes multiboard lb, string label returns nothing
2130 native MultiboardGetTitleText takes multiboard lb returns string
2131 native MultiboardSetTitleTextColor takes multiboard lb, integer red, integer green, integer blue, integer alpha returns nothing
2132
2133 native MultiboardGetRowCount takes multiboard lb returns integer
2134 native MultiboardGetColumnCount takes multiboard lb returns integer
2135
2136 native MultiboardSetColumnCount takes multiboard lb, integer count returns nothing
2137 native MultiboardSetRowCount takes multiboard lb, integer count returns nothing
2138
2139 // broadcast settings to all items
2140 native MultiboardSetItemsStyle takes multiboard lb, boolean showValues, boolean showIcons returns nothing
2141 native MultiboardSetItemsValue takes multiboard lb, string value returns nothing
2142 native MultiboardSetItemsValueColor takes multiboard lb, integer red, integer green, integer blue, integer alpha returns nothing
2143 native MultiboardSetItemsWidth takes multiboard lb, real width returns nothing
2144 native MultiboardSetItemsIcon takes multiboard lb, string iconPath returns nothing
2145
2146
2147 // funcs for modifying individual items
2148 native MultiboardGetItem takes multiboard lb, integer row, integer column returns multiboarditem
2149 native MultiboardReleaseItem takes multiboarditem mbi returns nothing
2150
2151 native MultiboardSetItemStyle takes multiboarditem mbi, boolean showValue, boolean showIcon returns nothing
2152 native MultiboardSetItemValue takes multiboarditem mbi, string val returns nothing
2153 native MultiboardSetItemValueColor takes multiboarditem mbi, integer red, integer green, integer blue, integer alpha returns nothing
2154 native MultiboardSetItemWidth takes multiboarditem mbi, real width returns nothing
2155 native MultiboardSetItemIcon takes multiboarditem mbi, string iconFileName returns nothing
2156
2157 // meant to unequivocally suspend display of existing and
2158 // subsequently displayed multiboards
2159 //
2160 native MultiboardSuppressDisplay takes boolean flag returns nothing
2161
2162 //============================================================================
2163 // Camera API
2164 native SetCameraPosition takes real x, real y returns nothing
2165 native SetCameraQuickPosition takes real x, real y returns nothing
2166 native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing
2167 native StopCamera takes nothing returns nothing
2168 native ResetToGameCamera takes real duration returns nothing
2169 native PanCameraTo takes real x, real y returns nothing
2170 native PanCameraToTimed takes real x, real y, real duration returns nothing
2171 native PanCameraToWithZ takes real x, real y, real zOffsetDest returns nothing
2172 native PanCameraToTimedWithZ takes real x, real y, real zOffsetDest, real duration returns nothing
2173 native SetCinematicCamera takes string cameraModelFile returns nothing
2174 native SetCameraRotateMode takes real x, real y, real radiansToSweep, real duration returns nothing
2175 native SetCameraField takes camerafield whichField, real value, real duration returns nothing
2176 native AdjustCameraField takes camerafield whichField, real offset, real duration returns nothing
2177 native SetCameraTargetController takes unit whichUnit, real xoffset, real yoffset, boolean inheritOrientation returns nothing
2178 native SetCameraOrientController takes unit whichUnit, real xoffset, real yoffset returns nothing
2179
2180 native CreateCameraSetup takes nothing returns camerasetup
2181 native CameraSetupSetField takes camerasetup whichSetup, camerafield whichField, real value, real duration returns nothing
2182 native CameraSetupGetField takes camerasetup whichSetup, camerafield whichField returns real
2183 native CameraSetupSetDestPosition takes camerasetup whichSetup, real x, real y, real duration returns nothing
2184 native CameraSetupGetDestPositionLoc takes camerasetup whichSetup returns location
2185 native CameraSetupGetDestPositionX takes camerasetup whichSetup returns real
2186 native CameraSetupGetDestPositionY takes camerasetup whichSetup returns real
2187 native CameraSetupApply takes camerasetup whichSetup, boolean doPan, boolean panTimed returns nothing
2188 native CameraSetupApplyWithZ takes camerasetup whichSetup, real zDestOffset returns nothing
2189 native CameraSetupApplyForceDuration takes camerasetup whichSetup, boolean doPan, real forceDuration returns nothing
2190 native CameraSetupApplyForceDurationWithZ takes camerasetup whichSetup, real zDestOffset, real forceDuration returns nothing
2191
2192 native CameraSetTargetNoise takes real mag, real velocity returns nothing
2193 native CameraSetSourceNoise takes real mag, real velocity returns nothing
2194
2195 native CameraSetTargetNoiseEx takes real mag, real velocity, boolean vertOnly returns nothing
2196 native CameraSetSourceNoiseEx takes real mag, real velocity, boolean vertOnly returns nothing
2197
2198 native CameraSetSmoothingFactor takes real factor returns nothing
2199
2200 native SetCineFilterTexture takes string filename returns nothing
2201 native SetCineFilterBlendMode takes blendmode whichMode returns nothing
2202 native SetCineFilterTexMapFlags takes texmapflags whichFlags returns nothing
2203 native SetCineFilterStartUV takes real minu, real minv, real maxu, real maxv returns nothing
2204 native SetCineFilterEndUV takes real minu, real minv, real maxu, real maxv returns nothing
2205 native SetCineFilterStartColor takes integer red, integer green, integer blue, integer alpha returns nothing
2206 native SetCineFilterEndColor takes integer red, integer green, integer blue, integer alpha returns nothing
2207 native SetCineFilterDuration takes real duration returns nothing
2208 native DisplayCineFilter takes boolean flag returns nothing
2209 native IsCineFilterDisplayed takes nothing returns boolean
2210
2211 native SetCinematicScene takes integer portraitUnitId, playercolor color, string speakerTitle, string text, real sceneDuration, real voiceoverDuration returns nothing
2212 native EndCinematicScene takes nothing returns nothing
2213 native ForceCinematicSubtitles takes boolean flag returns nothing
2214
2215 native GetCameraMargin takes integer whichMargin returns real
2216
2217 // These return values for the local players camera only...
2218 constant native GetCameraBoundMinX takes nothing returns real
2219 constant native GetCameraBoundMinY takes nothing returns real
2220 constant native GetCameraBoundMaxX takes nothing returns real
2221 constant native GetCameraBoundMaxY takes nothing returns real
2222 constant native GetCameraField takes camerafield whichField returns real
2223 constant native GetCameraTargetPositionX takes nothing returns real
2224 constant native GetCameraTargetPositionY takes nothing returns real
2225 constant native GetCameraTargetPositionZ takes nothing returns real
2226 constant native GetCameraTargetPositionLoc takes nothing returns location
2227 constant native GetCameraEyePositionX takes nothing returns real
2228 constant native GetCameraEyePositionY takes nothing returns real
2229 constant native GetCameraEyePositionZ takes nothing returns real
2230 constant native GetCameraEyePositionLoc takes nothing returns location
2231
2232 //============================================================================
2233 // Sound API
2234 //
2235 native NewSoundEnvironment takes string environmentName returns nothing
2236
2237 native CreateSound takes string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string eaxSetting returns sound
2238 native CreateSoundFilenameWithLabel takes string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string SLKEntryName returns sound
2239 native CreateSoundFromLabel takes string soundLabel, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate returns sound
2240 native CreateMIDISound takes string soundLabel, integer fadeInRate, integer fadeOutRate returns sound
2241
2242 native SetSoundParamsFromLabel takes sound soundHandle, string soundLabel returns nothing
2243 native SetSoundDistanceCutoff takes sound soundHandle, real cutoff returns nothing
2244 native SetSoundChannel takes sound soundHandle, integer channel returns nothing
2245 native SetSoundVolume takes sound soundHandle, integer volume returns nothing
2246 native SetSoundPitch takes sound soundHandle, real pitch returns nothing
2247
2248 // the following method must be called immediately after calling "StartSound"
2249 native SetSoundPlayPosition takes sound soundHandle, integer millisecs returns nothing
2250
2251 // these calls are only valid if the sound was created with 3d enabled
2252 native SetSoundDistances takes sound soundHandle, real minDist, real maxDist returns nothing
2253 native SetSoundConeAngles takes sound soundHandle, real inside, real outside, integer outsideVolume returns nothing
2254 native SetSoundConeOrientation takes sound soundHandle, real x, real y, real z returns nothing
2255 native SetSoundPosition takes sound soundHandle, real x, real y, real z returns nothing
2256 native SetSoundVelocity takes sound soundHandle, real x, real y, real z returns nothing
2257 native AttachSoundToUnit takes sound soundHandle, unit whichUnit returns nothing
2258
2259 native StartSound takes sound soundHandle returns nothing
2260 native StopSound takes sound soundHandle, boolean killWhenDone, boolean fadeOut returns nothing
2261 native KillSoundWhenDone takes sound soundHandle returns nothing
2262
2263 // Music Interface. Note that if music is disabled, these calls do nothing
2264 native SetMapMusic takes string musicName, boolean random, integer index returns nothing
2265 native ClearMapMusic takes nothing returns nothing
2266
2267 native PlayMusic takes string musicName returns nothing
2268 native PlayMusicEx takes string musicName, integer frommsecs, integer fadeinmsecs returns nothing
2269 native StopMusic takes boolean fadeOut returns nothing
2270 native ResumeMusic takes nothing returns nothing
2271
2272 native PlayThematicMusic takes string musicFileName returns nothing
2273 native PlayThematicMusicEx takes string musicFileName, integer frommsecs returns nothing
2274 native EndThematicMusic takes nothing returns nothing
2275
2276 native SetMusicVolume takes integer volume returns nothing
2277 native SetMusicPlayPosition takes integer millisecs returns nothing
2278 native SetThematicMusicPlayPosition takes integer millisecs returns nothing
2279
2280 // other music and sound calls
2281 native SetSoundDuration takes sound soundHandle, integer duration returns nothing
2282 native GetSoundDuration takes sound soundHandle returns integer
2283 native GetSoundFileDuration takes string musicFileName returns integer
2284
2285 native VolumeGroupSetVolume takes volumegroup vgroup, real scale returns nothing
2286 native VolumeGroupReset takes nothing returns nothing
2287
2288 native GetSoundIsPlaying takes sound soundHandle returns boolean
2289 native GetSoundIsLoading takes sound soundHandle returns boolean
2290
2291 native RegisterStackedSound takes sound soundHandle, boolean byPosition, real rectwidth, real rectheight returns nothing
2292 native UnregisterStackedSound takes sound soundHandle, boolean byPosition, real rectwidth, real rectheight returns nothing
2293
2294 //============================================================================
2295 // Effects API
2296 //
2297 native AddWeatherEffect takes rect where, integer effectID returns weathereffect
2298 native RemoveWeatherEffect takes weathereffect whichEffect returns nothing
2299 native EnableWeatherEffect takes weathereffect whichEffect, boolean enable returns nothing
2300
2301 native TerrainDeformCrater takes real x, real y, real radius, real depth, integer duration, boolean permanent returns terraindeformation
2302 native TerrainDeformRipple takes real x, real y, real radius, real depth, integer duration, integer count, real spaceWaves, real timeWaves, real radiusStartPct, boolean limitNeg returns terraindeformation
2303 native TerrainDeformWave takes real x, real y, real dirX, real dirY, real distance, real speed, real radius, real depth, integer trailTime, integer count returns terraindeformation
2304 native TerrainDeformRandom takes real x, real y, real radius, real minDelta, real maxDelta, integer duration, integer updateInterval returns terraindeformation
2305 native TerrainDeformStop takes terraindeformation deformation, integer duration returns nothing
2306 native TerrainDeformStopAll takes nothing returns nothing
2307
2308 native AddSpecialEffect takes string modelName, real x, real y returns effect
2309 native AddSpecialEffectLoc takes string modelName, location where returns effect
2310 native AddSpecialEffectTarget takes string modelName, widget targetWidget, string attachPointName returns effect
2311 native DestroyEffect takes effect whichEffect returns nothing
2312
2313 native AddSpellEffect takes string abilityString, effecttype t, real x, real y returns effect
2314 native AddSpellEffectLoc takes string abilityString, effecttype t,location where returns effect
2315 native AddSpellEffectById takes integer abilityId, effecttype t,real x, real y returns effect
2316 native AddSpellEffectByIdLoc takes integer abilityId, effecttype t,location where returns effect
2317 native AddSpellEffectTarget takes string modelName, effecttype t, widget targetWidget, string attachPoint returns effect
2318 native AddSpellEffectTargetById takes integer abilityId, effecttype t, widget targetWidget, string attachPoint returns effect
2319
2320 native AddLightning takes string codeName, boolean checkVisibility, real x1, real y1, real x2, real y2 returns lightning
2321 native AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning
2322 native DestroyLightning takes lightning whichBolt returns boolean
2323 native MoveLightning takes lightning whichBolt, boolean checkVisibility, real x1, real y1, real x2, real y2 returns boolean
2324 native MoveLightningEx takes lightning whichBolt, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns boolean
2325 native GetLightningColorA takes lightning whichBolt returns real
2326 native GetLightningColorR takes lightning whichBolt returns real
2327 native GetLightningColorG takes lightning whichBolt returns real
2328 native GetLightningColorB takes lightning whichBolt returns real
2329 native SetLightningColor takes lightning whichBolt, real r, real g, real b, real a returns boolean
2330
2331 native GetAbilityEffect takes string abilityString, effecttype t, integer index returns string
2332 native GetAbilityEffectById takes integer abilityId, effecttype t, integer index returns string
2333 native GetAbilitySound takes string abilityString, soundtype t returns string
2334 native GetAbilitySoundById takes integer abilityId, soundtype t returns string
2335
2336 //============================================================================
2337 // Terrain API
2338 //
2339 native GetTerrainCliffLevel takes real x, real y returns integer
2340 native SetWaterBaseColor takes integer red, integer green, integer blue, integer alpha returns nothing
2341 native SetWaterDeforms takes boolean val returns nothing
2342 native GetTerrainType takes real x, real y returns integer
2343 native GetTerrainVariance takes real x, real y returns integer
2344 native SetTerrainType takes real x, real y, integer terrainType, integer variation, integer area, integer shape returns nothing
2345 native IsTerrainPathable takes real x, real y, pathingtype t returns boolean
2346 native SetTerrainPathable takes real x, real y, pathingtype t, boolean flag returns nothing
2347
2348 //============================================================================
2349 // Image API
2350 //
2351 native CreateImage takes string file, real sizeX, real sizeY, real sizeZ, real posX, real posY, real posZ, real originX, real originY, real originZ, integer imageType returns image
2352 native DestroyImage takes image whichImage returns nothing
2353 native ShowImage takes image whichImage, boolean flag returns nothing
2354 native SetImageConstantHeight takes image whichImage, boolean flag, real height returns nothing
2355 native SetImagePosition takes image whichImage, real x, real y, real z returns nothing
2356 native SetImageColor takes image whichImage, integer red, integer green, integer blue, integer alpha returns nothing
2357 native SetImageRender takes image whichImage, boolean flag returns nothing
2358 native SetImageRenderAlways takes image whichImage, boolean flag returns nothing
2359 native SetImageAboveWater takes image whichImage, boolean flag, boolean useWaterAlpha returns nothing
2360 native SetImageType takes image whichImage, integer imageType returns nothing
2361
2362 //============================================================================
2363 // Ubersplat API
2364 //
2365 native CreateUbersplat takes real x, real y, string name, integer red, integer green, integer blue, integer alpha, boolean forcePaused, boolean noBirthTime returns ubersplat
2366 native DestroyUbersplat takes ubersplat whichSplat returns nothing
2367 native ResetUbersplat takes ubersplat whichSplat returns nothing
2368 native FinishUbersplat takes ubersplat whichSplat returns nothing
2369 native ShowUbersplat takes ubersplat whichSplat, boolean flag returns nothing
2370 native SetUbersplatRender takes ubersplat whichSplat, boolean flag returns nothing
2371 native SetUbersplatRenderAlways takes ubersplat whichSplat, boolean flag returns nothing
2372
2373 //============================================================================
2374 // Blight API
2375 //
2376 native SetBlight takes player whichPlayer, real x, real y, real radius, boolean addBlight returns nothing
2377 native SetBlightRect takes player whichPlayer, rect r, boolean addBlight returns nothing
2378 native SetBlightPoint takes player whichPlayer, real x, real y, boolean addBlight returns nothing
2379 native SetBlightLoc takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing
2380 native CreateBlightedGoldmine takes player id, real x, real y, real face returns unit
2381 native IsPointBlighted takes real x, real y returns boolean
2382
2383 //============================================================================
2384 // Doodad API
2385 //
2386 native SetDoodadAnimation takes real x, real y, real radius, integer doodadID, boolean nearestOnly, string animName, boolean animRandom returns nothing
2387 native SetDoodadAnimationRect takes rect r, integer doodadID, string animName, boolean animRandom returns nothing
2388
2389 //============================================================================
2390 // Computer AI interface
2391 //
2392 native StartMeleeAI takes player num, string script returns nothing
2393 native StartCampaignAI takes player num, string script returns nothing
2394 native CommandAI takes player num, integer command, integer data returns nothing
2395 native PauseCompAI takes player p, boolean pause returns nothing
2396 native GetAIDifficulty takes player num returns aidifficulty
2397
2398 native RemoveGuardPosition takes unit hUnit returns nothing
2399 native RecycleGuardPosition takes unit hUnit returns nothing
2400 native RemoveAllGuardPositions takes player num returns nothing
2401
2402 //============================================================================
2403 native Cheat takes string cheatStr returns nothing
2404 native IsNoVictoryCheat takes nothing returns boolean
2405 native IsNoDefeatCheat takes nothing returns boolean
2406
2407 native Preload takes string filename returns nothing
2408 native PreloadEnd takes real timeout returns nothing
2409
2410 native PreloadStart takes nothing returns nothing
2411 native PreloadRefresh takes nothing returns nothing
2412 native PreloadEndEx takes nothing returns nothing
2413
2414 native PreloadGenClear takes nothing returns nothing
2415 native PreloadGenStart takes nothing returns nothing
2416 native PreloadGenEnd takes string filename returns nothing
2417 native Preloader takes string filename returns nothing
File honeydew-0_0WIP-1_27-en.w3x added (mode: 100644) (index 0000000..40bcdcf)
File src/config.j added (mode: 100644) (index 0000000..3339546)
1 globals
2 constant integer TEAM_ENEMY = 1
3 constant integer TEAM_USER = 0
4 constant integer USER_QUANTITY_MAX = 3
5 constant player PLAYER_DEMON = Player(3)
6 constant player USER0 = Player(0)
7 constant player USER1 = Player(1)
8 constant player USER2 = Player(2)
9 endglobals
10
11 function config_slot_user takes integer n returns nothing
12 local integer i = 0
13 local player p = null
14 local player e = null
15
16 if not (n >= 0 and n < bj_MAX_PLAYER_SLOTS) then
17 return
18 endif
19
20 set p = Player(n)
21
22 call SetPlayerStartLocation(p, n)
23 call SetPlayerColor(p, ConvertPlayerColor(n))
24 call SetPlayerRacePreference(p, RACE_PREF_HUMAN)
25 call SetPlayerRaceSelectable(p, true)
26 call SetPlayerController(p, MAP_CONTROL_USER)
27 call SetPlayerTeam(p, TEAM_USER)
28
29 set i = 0
30 loop
31 exitwhen i >= USER_QUANTITY_MAX
32
33 set e = Player(i)
34 call SetPlayerAlliance(p, e, ALLIANCE_PASSIVE, true)
35 call SetPlayerAlliance(p, e, ALLIANCE_HELP_REQUEST, true)
36 call SetPlayerAlliance(p, e, ALLIANCE_HELP_RESPONSE, true)
37 call SetPlayerAlliance(p, e, ALLIANCE_SHARED_XP, true)
38 call SetPlayerAlliance(p, e, ALLIANCE_SHARED_VISION, true)
39 set i = i + 1
40 endloop
41
42 call SetPlayerOnScoreScreen(p, true)
43 endfunction
44
45 function config_slot_computer takes integer n returns nothing
46 local player p = null
47
48 if not (n >= 0 and n < bj_MAX_PLAYER_SLOTS) then
49 return
50 endif
51
52 set p = Player(n)
53
54 call SetPlayerStartLocation(p, n)
55 call SetPlayerColor(p, PLAYER_COLOR_BLUE)
56 call SetPlayerRacePreference(p, RACE_PREF_UNDEAD)
57 call SetPlayerRaceSelectable(p, false)
58 call SetPlayerController(p, MAP_CONTROL_COMPUTER)
59 call SetPlayerTeam(p, TEAM_ENEMY)
60 endfunction
61
62 function config_every_start takes nothing returns nothing
63 local location origin_loc = null
64 local location loc = null
65 local integer i = 0
66 local real x = 0.0
67 local real y = 0.0
68
69 set origin_loc = Location(0.0, 0.0)
70
71 set i = 0
72 loop
73 exitwhen i >= USER_QUANTITY_MAX
74 set x = GetLocationX(origin_loc) + 128.0 * (i + 1)
75 set y = GetLocationY(origin_loc) - 128.0
76 set loc = Location(x, y)
77 call DefineStartLocationLoc(i, loc)
78 call RemoveLocation(loc)
79 set i = i + 1
80 endloop
81
82 call DefineStartLocationLoc(3, origin_loc)
83
84 call RemoveLocation(origin_loc)
85 endfunction
86
87 function config_every_slot takes nothing returns nothing
88 local integer i = 0
89
90 loop
91 exitwhen i >= USER_QUANTITY_MAX
92 call config_slot_user(i)
93 set i = i + 1
94 endloop
95
96 call config_slot_computer(3)
97 endfunction
98
99 function config takes nothing returns nothing
100 call SetMapName( "TRIGSTR_001" )
101 call SetMapDescription( "TRIGSTR_003" )
102 call SetTeams(1)
103 call SetPlayers(USER_QUANTITY_MAX)
104 call SetGamePlacement(MAP_PLACEMENT_USE_MAP_SETTINGS)
105
106 call SetGameTypeSupported(GAME_TYPE_USE_MAP_SETTINGS, true)
107
108 call SetMapFlag(MAP_LOCK_ALLIANCE_CHANGES, true)
109 call SetMapFlag(MAP_RESOURCE_TRADING_ALLIES_ONLY, true)
110 call SetGamePlacement(MAP_PLACEMENT_FIXED)
111
112 call config_every_start()
113 call config_every_slot()
114 endfunction
115
File src/main.j added (mode: 100644) (index 0000000..b0b672a)
1 //***************************************************************************
2 //*
3 //* Global Variables
4 //*
5 //***************************************************************************
6
7 globals
8 // Generated
9 trigger gg_trg_Melee_Initialization = null
10 endglobals
11
12 function InitGlobals takes nothing returns nothing
13 endfunction
14
15 //***************************************************************************
16 //*
17 //* Triggers
18 //*
19 //***************************************************************************
20
21 //===========================================================================
22 // Trigger: Melee Initialization
23 //===========================================================================
24 function Trig_Melee_Initialization_Actions takes nothing returns nothing
25 endfunction
26
27 //===========================================================================
28 function InitTrig_Melee_Initialization takes nothing returns nothing
29 set gg_trg_Melee_Initialization = CreateTrigger( )
30 call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
31 endfunction
32
33 //===========================================================================
34 function InitCustomTriggers takes nothing returns nothing
35 call InitTrig_Melee_Initialization( )
36 endfunction
37
38 //===========================================================================
39 function RunInitializationTriggers takes nothing returns nothing
40 call ConditionalTriggerExecute( gg_trg_Melee_Initialization )
41 endfunction
42
43 function main takes nothing returns nothing
44 call SetCameraBounds( -7424.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), -7680.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM), 7424.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), 7168.0 - GetCameraMargin(CAMERA_MARGIN_TOP), -7424.0 + GetCameraMargin(CAMERA_MARGIN_LEFT), 7168.0 - GetCameraMargin(CAMERA_MARGIN_TOP), 7424.0 - GetCameraMargin(CAMERA_MARGIN_RIGHT), -7680.0 + GetCameraMargin(CAMERA_MARGIN_BOTTOM) )
45 call SetDayNightModels( "Environment\\DNC\\DNCLordaeron\\DNCLordaeronTerrain\\DNCLordaeronTerrain.mdl", "Environment\\DNC\\DNCLordaeron\\DNCLordaeronUnit\\DNCLordaeronUnit.mdl" )
46 call NewSoundEnvironment( "Default" )
47 call SetAmbientDaySound( "LordaeronWinterDay" )
48 call SetAmbientNightSound( "LordaeronWinterNight" )
49 call SetMapMusic( "Music", true, 0 )
50 call InitBlizzard( )
51 call InitGlobals( )
52 call InitCustomTriggers( )
53 call RunInitializationTriggers( )
54 endfunction
File src/war3map.m4 added (mode: 100644) (index 0000000..0118ad7)
1 define(globals, `divert(0)divert(1)')dnl # Cut and paste 'globals' blocks
2 define(endglobals, `divert(0)divert(2)')dnl
3 divert(2)dnl
4 dnl # WARNING: included files must never contain the tilde glyph,
5 dnl # otherwise this m4 script produces malformed *.j snippet
6 include(`src/main.j')dnl
7 include(`src/config.j')dnl
8 divert(0)dnl
9 undefine(`globals')dnl # Leave 'globals' token as it is
10 undefine(`endglobals')dnl # Leave 'endglobals' token as it is
11
12 globals
13 undivert(1)
14 endglobals
15
16 undivert(2)
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/vrtc/honeydew

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/vrtc/honeydew

Clone this repository using git:
git clone git://git.rocketgit.com/user/vrtc/honeydew

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main