diff --git a/AGENTS.md b/AGENTS.md index b3390ea..76bdda9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -19,14 +19,14 @@ This repo builds the Grill CLI and project setup tooling. The generated map-proj ## WC3 Patch And Core JASS -- `CoreJassProvider.DEFAULT_PATCH` is `v2.0`. +- `CoreJassProvider.DEFAULT_PATCH` is `v3.0`. - Core JASS is fetched from `wurstscript/jass-history`. - Friendly patch targets must resolve through the shared parser / `Wc3PatchTarget` style rules: - below `1.29` => pre-1.29 behavior and stdlib - `1.29` through `1.31` => classic - - `1.32+`, `1.36`, `2.0`, and `Reforged-*` => Reforged + - `1.32+`, `2.0`, `3.0`, and `Reforged-*` => Reforged - Do not add alias hacks for broken jass-history folder names. Fix `wurstscript/jass-history` instead. -- Bundled core JASS fallbacks are patch-specific. Do not silently use the old `reforged` bundle as the `v2.0` fallback. +- Bundled core JASS fallbacks are patch-specific. Never reuse another patch's bundle for a new default alias. - Keep provenance in `_build/core-jass.properties`; mismatched cached `common.j` / `blizzard.j` should be refreshed. ## Generate Workflow diff --git a/src/main/kotlin/file/CoreJassProvider.kt b/src/main/kotlin/file/CoreJassProvider.kt index 3680a31..793717f 100644 --- a/src/main/kotlin/file/CoreJassProvider.kt +++ b/src/main/kotlin/file/CoreJassProvider.kt @@ -10,7 +10,7 @@ import java.nio.file.StandardCopyOption import java.util.jar.JarFile object CoreJassProvider { - const val DEFAULT_PATCH = "v2.0" + const val DEFAULT_PATCH = "v3.0" const val PRE_129_PATCH = "v1.28" private const val JASS_HISTORY_RAW = "https://raw.githubusercontent.com/wurstscript/jass-history" @@ -19,6 +19,7 @@ object CoreJassProvider { private val log = KotlinLogging.logger {} private val PATCH_TO_JASS_HISTORY_FOLDER = linkedMapOf( + "v3.0" to "Reforged-v3.0.0.24268-w3-3a9d8f2", "v2.0" to "Reforged-v2.0.4.23745", "v1.36" to "Reforged-v1.36.1.20719-w3-51d40ee", "v1.35" to "Reforged-v1.35.0.20093-w3-5ec1b77", @@ -77,7 +78,7 @@ object CoreJassProvider { val supportedPatches: List = PATCH_TO_JASS_HISTORY_FOLDER.keys.toList() private val BUNDLED_CORE_JASS_PATCH_FOLDERS = mapOf( - DEFAULT_PATCH to "v2.0", + DEFAULT_PATCH to "v3.0", "v1.36" to "reforged", PRE_129_PATCH to "pre1.29" ) @@ -87,7 +88,7 @@ object CoreJassProvider { fun describePatch(patch: String): String { val normalizedPatch = normalizePatchInput(patch) val label = when (normalizedPatch) { - DEFAULT_PATCH -> "latest Reforged / WC3 2.x core JASS" + DEFAULT_PATCH -> "latest Reforged / WC3 3.x core JASS" "v1.31" -> "latest classic TFT" PRE_129_PATCH -> "legacy pre-1.29" else -> { diff --git a/src/main/resources/core-jass/v3.0/blizzard.j b/src/main/resources/core-jass/v3.0/blizzard.j new file mode 100644 index 0000000..9ca0d8f --- /dev/null +++ b/src/main/resources/core-jass/v3.0/blizzard.j @@ -0,0 +1,11383 @@ +//=========================================================================== +// Blizzard.j ( define Jass2 functions that need to be in every map script ) +//=========================================================================== + + +globals + //----------------------------------------------------------------------- + // Constants + // + + // Misc constants + constant real bj_PI = 3.14159 + constant real bj_E = 2.71828 + constant real bj_CELLWIDTH = 128.0 + constant real bj_CLIFFHEIGHT = 128.0 + constant real bj_UNIT_FACING = 270.0 + constant real bj_RADTODEG = 180.0/bj_PI + constant real bj_DEGTORAD = bj_PI/180.0 + constant real bj_TEXT_DELAY_QUEST = 20.00 + constant real bj_TEXT_DELAY_QUESTUPDATE = 20.00 + constant real bj_TEXT_DELAY_QUESTDONE = 20.00 + constant real bj_TEXT_DELAY_QUESTFAILED = 20.00 + constant real bj_TEXT_DELAY_QUESTREQUIREMENT = 20.00 + constant real bj_TEXT_DELAY_MISSIONFAILED = 20.00 + constant real bj_TEXT_DELAY_ALWAYSHINT = 12.00 + constant real bj_TEXT_DELAY_HINT = 12.00 + constant real bj_TEXT_DELAY_SECRET = 10.00 + constant real bj_TEXT_DELAY_UNITACQUIRED = 15.00 + constant real bj_TEXT_DELAY_UNITAVAILABLE = 10.00 + constant real bj_TEXT_DELAY_ITEMACQUIRED = 10.00 + constant real bj_TEXT_DELAY_WARNING = 12.00 + constant real bj_QUEUE_DELAY_QUEST = 5.00 + constant real bj_QUEUE_DELAY_HINT = 5.00 + constant real bj_QUEUE_DELAY_SECRET = 3.00 + constant real bj_HANDICAP_EASY = 60.00 + constant real bj_HANDICAP_NORMAL = 90.00 + constant real bj_HANDICAPDAMAGE_EASY = 50.00 + constant real bj_HANDICAPDAMAGE_NORMAL = 90.00 + constant real bj_HANDICAPREVIVE_NOTHARD = 50.00 + constant real bj_GAME_STARTED_THRESHOLD = 0.01 + constant real bj_WAIT_FOR_COND_MIN_INTERVAL = 0.10 + constant real bj_POLLED_WAIT_INTERVAL = 0.10 + constant real bj_POLLED_WAIT_SKIP_THRESHOLD = 2.00 + + // Game constants + constant integer bj_MAX_INVENTORY = 6 + constant integer bj_MAX_EXTENDED_INVENTORY = 30 + constant integer bj_MAX_EQUIPMENT_INVENTORY = 9 + constant integer bj_MAX_PLAYERS = GetBJMaxPlayers() + constant integer bj_PLAYER_NEUTRAL_VICTIM = GetBJPlayerNeutralVictim() + constant integer bj_PLAYER_NEUTRAL_EXTRA = GetBJPlayerNeutralExtra() + constant integer bj_MAX_PLAYER_SLOTS = GetBJMaxPlayerSlots() + constant integer bj_MAX_SKELETONS = 25 + constant integer bj_MAX_STOCK_ITEM_SLOTS = 11 + constant integer bj_MAX_STOCK_UNIT_SLOTS = 11 + constant integer bj_MAX_ITEM_LEVEL = 10 + + // Auto Save constants + constant integer bj_MAX_CHECKPOINTS = 5 + + // Ideally these would be looked up from Units/MiscData.txt, + // but there is currently no script functionality exposed to do that + constant real bj_TOD_DAWN = 6.00 + constant real bj_TOD_DUSK = 18.00 + + // Melee game settings: + // - Starting Time of Day (TOD) + // - Starting Gold + // - Starting Lumber + // - Starting Hero Tokens (free heroes) + // - Max heroes allowed per player + // - Max heroes allowed per hero type + // - Distance from start loc to search for nearby mines + // + constant real bj_MELEE_STARTING_TOD = 8.00 + constant integer bj_MELEE_STARTING_GOLD_V0 = 750 + constant integer bj_MELEE_STARTING_GOLD_V1 = 500 + constant integer bj_MELEE_STARTING_LUMBER_V0 = 200 + constant integer bj_MELEE_STARTING_LUMBER_V1 = 150 + constant integer bj_MELEE_STARTING_HERO_TOKENS = 1 + constant integer bj_MELEE_HERO_LIMIT = 3 + constant integer bj_MELEE_HERO_TYPE_LIMIT = 1 + constant real bj_MELEE_MINE_SEARCH_RADIUS = 2000 + constant real bj_MELEE_CLEAR_UNITS_RADIUS = 1500 + constant real bj_MELEE_CRIPPLE_TIMEOUT = 120.00 + constant real bj_MELEE_CRIPPLE_MSG_DURATION = 20.00 + constant integer bj_MELEE_MAX_TWINKED_HEROES_V0 = 3 + constant integer bj_MELEE_MAX_TWINKED_HEROES_V1 = 1 + + // Delay between a creep's death and the time it may drop an item. + constant real bj_CREEP_ITEM_DELAY = 0.50 + + // Timing settings for Marketplace inventories. + constant real bj_STOCK_RESTOCK_INITIAL_DELAY = 120 + constant real bj_STOCK_RESTOCK_INTERVAL = 30 + constant integer bj_STOCK_MAX_ITERATIONS = 20 + + // Max events registered by a single "dest dies in region" event. + constant integer bj_MAX_DEST_IN_REGION_EVENTS = 64 + + // Camera settings + constant integer bj_CAMERA_MIN_FARZ = 100 + constant integer bj_CAMERA_DEFAULT_DISTANCE = 1650 + constant integer bj_CAMERA_DEFAULT_FARZ = 5000 + constant integer bj_CAMERA_DEFAULT_AOA = 304 + constant integer bj_CAMERA_DEFAULT_FOV = 70 + constant integer bj_CAMERA_DEFAULT_ROLL = 0 + constant integer bj_CAMERA_DEFAULT_ROTATION = 90 + + // Rescue + constant real bj_RESCUE_PING_TIME = 2.00 + + // Transmission behavior settings + constant real bj_NOTHING_SOUND_DURATION = 5.00 + constant real bj_TRANSMISSION_PING_TIME = 1.00 + constant integer bj_TRANSMISSION_IND_RED = 255 + constant integer bj_TRANSMISSION_IND_BLUE = 255 + constant integer bj_TRANSMISSION_IND_GREEN = 255 + constant integer bj_TRANSMISSION_IND_ALPHA = 255 + constant real bj_TRANSMISSION_PORT_HANGTIME = 1.50 + + // Cinematic mode settings + constant real bj_CINEMODE_INTERFACEFADE = 0.50 + constant gamespeed bj_CINEMODE_GAMESPEED = MAP_SPEED_NORMAL + + // Cinematic mode volume levels + constant real bj_CINEMODE_VOLUME_UNITMOVEMENT = 0.40 + constant real bj_CINEMODE_VOLUME_UNITSOUNDS = 0.00 + constant real bj_CINEMODE_VOLUME_COMBAT = 0.40 + constant real bj_CINEMODE_VOLUME_SPELLS = 0.40 + constant real bj_CINEMODE_VOLUME_UI = 0.00 + constant real bj_CINEMODE_VOLUME_MUSIC = 0.55 + constant real bj_CINEMODE_VOLUME_AMBIENTSOUNDS = 1.00 + constant real bj_CINEMODE_VOLUME_FIRE = 0.60 + + // Speech mode volume levels + constant real bj_SPEECH_VOLUME_UNITMOVEMENT = 0.25 + constant real bj_SPEECH_VOLUME_UNITSOUNDS = 0.00 + constant real bj_SPEECH_VOLUME_COMBAT = 0.25 + constant real bj_SPEECH_VOLUME_SPELLS = 0.25 + constant real bj_SPEECH_VOLUME_UI = 0.00 + constant real bj_SPEECH_VOLUME_MUSIC = 0.55 + constant real bj_SPEECH_VOLUME_AMBIENTSOUNDS = 1.00 + constant real bj_SPEECH_VOLUME_FIRE = 0.60 + + // Smart pan settings + constant real bj_SMARTPAN_TRESHOLD_PAN = 500 + constant real bj_SMARTPAN_TRESHOLD_SNAP = 3500 + + // QueuedTriggerExecute settings + constant integer bj_MAX_QUEUED_TRIGGERS = 100 + constant real bj_QUEUED_TRIGGER_TIMEOUT = 180.00 + + // Campaign indexing constants + constant integer bj_CAMPAIGN_INDEX_T = 0 + constant integer bj_CAMPAIGN_INDEX_H = 1 + constant integer bj_CAMPAIGN_INDEX_U = 2 + constant integer bj_CAMPAIGN_INDEX_O = 3 + constant integer bj_CAMPAIGN_INDEX_N = 4 + constant integer bj_CAMPAIGN_INDEX_XN = 5 + constant integer bj_CAMPAIGN_INDEX_XH = 6 + constant integer bj_CAMPAIGN_INDEX_XU = 7 + constant integer bj_CAMPAIGN_INDEX_XO = 8 + constant integer bj_CAMPAIGN_INDEX_RH = 9 + constant integer bj_CAMPAIGN_INDEX_RU = 10 + + // Campaign offset constants (for mission indexing) + constant integer bj_CAMPAIGN_OFFSET_T = 0 + constant integer bj_CAMPAIGN_OFFSET_H = 1 + constant integer bj_CAMPAIGN_OFFSET_U = 2 + constant integer bj_CAMPAIGN_OFFSET_O = 3 + constant integer bj_CAMPAIGN_OFFSET_N = 4 + constant integer bj_CAMPAIGN_OFFSET_XN = 5 + constant integer bj_CAMPAIGN_OFFSET_XH = 6 + constant integer bj_CAMPAIGN_OFFSET_XU = 7 + constant integer bj_CAMPAIGN_OFFSET_XO = 8 + constant integer bj_CAMPAIGN_OFFSET_RH = 0 + constant integer bj_CAMPAIGN_OFFSET_RU = 1 + + // Mission indexing constants + // Tutorial + constant integer bj_MISSION_INDEX_T00 = bj_CAMPAIGN_OFFSET_T * 1000 + 0 + constant integer bj_MISSION_INDEX_T01 = bj_CAMPAIGN_OFFSET_T * 1000 + 1 + constant integer bj_MISSION_INDEX_T02 = bj_CAMPAIGN_OFFSET_T * 1000 + 2 + constant integer bj_MISSION_INDEX_T03 = bj_CAMPAIGN_OFFSET_T * 1000 + 3 + constant integer bj_MISSION_INDEX_T04 = bj_CAMPAIGN_OFFSET_T * 1000 + 4 + // Human + constant integer bj_MISSION_INDEX_H00 = bj_CAMPAIGN_OFFSET_H * 1000 + 0 + constant integer bj_MISSION_INDEX_H01 = bj_CAMPAIGN_OFFSET_H * 1000 + 1 + constant integer bj_MISSION_INDEX_H02 = bj_CAMPAIGN_OFFSET_H * 1000 + 2 + constant integer bj_MISSION_INDEX_H03 = bj_CAMPAIGN_OFFSET_H * 1000 + 3 + constant integer bj_MISSION_INDEX_H04 = bj_CAMPAIGN_OFFSET_H * 1000 + 4 + constant integer bj_MISSION_INDEX_H05 = bj_CAMPAIGN_OFFSET_H * 1000 + 5 + constant integer bj_MISSION_INDEX_H06 = bj_CAMPAIGN_OFFSET_H * 1000 + 6 + constant integer bj_MISSION_INDEX_H07 = bj_CAMPAIGN_OFFSET_H * 1000 + 7 + constant integer bj_MISSION_INDEX_H08 = bj_CAMPAIGN_OFFSET_H * 1000 + 8 + constant integer bj_MISSION_INDEX_H09 = bj_CAMPAIGN_OFFSET_H * 1000 + 9 + constant integer bj_MISSION_INDEX_H10 = bj_CAMPAIGN_OFFSET_H * 1000 + 10 + constant integer bj_MISSION_INDEX_H11 = bj_CAMPAIGN_OFFSET_H * 1000 + 11 + // Undead + constant integer bj_MISSION_INDEX_U00 = bj_CAMPAIGN_OFFSET_U * 1000 + 0 + constant integer bj_MISSION_INDEX_U01 = bj_CAMPAIGN_OFFSET_U * 1000 + 1 + constant integer bj_MISSION_INDEX_U02 = bj_CAMPAIGN_OFFSET_U * 1000 + 2 + constant integer bj_MISSION_INDEX_U03 = bj_CAMPAIGN_OFFSET_U * 1000 + 3 + constant integer bj_MISSION_INDEX_U05 = bj_CAMPAIGN_OFFSET_U * 1000 + 4 + constant integer bj_MISSION_INDEX_U07 = bj_CAMPAIGN_OFFSET_U * 1000 + 5 + constant integer bj_MISSION_INDEX_U08 = bj_CAMPAIGN_OFFSET_U * 1000 + 6 + constant integer bj_MISSION_INDEX_U09 = bj_CAMPAIGN_OFFSET_U * 1000 + 7 + constant integer bj_MISSION_INDEX_U10 = bj_CAMPAIGN_OFFSET_U * 1000 + 8 + constant integer bj_MISSION_INDEX_U11 = bj_CAMPAIGN_OFFSET_U * 1000 + 9 + // Orc + constant integer bj_MISSION_INDEX_O00 = bj_CAMPAIGN_OFFSET_O * 1000 + 0 + constant integer bj_MISSION_INDEX_O01 = bj_CAMPAIGN_OFFSET_O * 1000 + 1 + constant integer bj_MISSION_INDEX_O02 = bj_CAMPAIGN_OFFSET_O * 1000 + 2 + constant integer bj_MISSION_INDEX_O03 = bj_CAMPAIGN_OFFSET_O * 1000 + 3 + constant integer bj_MISSION_INDEX_O04 = bj_CAMPAIGN_OFFSET_O * 1000 + 4 + constant integer bj_MISSION_INDEX_O05 = bj_CAMPAIGN_OFFSET_O * 1000 + 5 + constant integer bj_MISSION_INDEX_O06 = bj_CAMPAIGN_OFFSET_O * 1000 + 6 + constant integer bj_MISSION_INDEX_O07 = bj_CAMPAIGN_OFFSET_O * 1000 + 7 + constant integer bj_MISSION_INDEX_O08 = bj_CAMPAIGN_OFFSET_O * 1000 + 8 + constant integer bj_MISSION_INDEX_O09 = bj_CAMPAIGN_OFFSET_O * 1000 + 9 + constant integer bj_MISSION_INDEX_O10 = bj_CAMPAIGN_OFFSET_O * 1000 + 10 + // Night Elf + constant integer bj_MISSION_INDEX_N00 = bj_CAMPAIGN_OFFSET_N * 1000 + 0 + constant integer bj_MISSION_INDEX_N01 = bj_CAMPAIGN_OFFSET_N * 1000 + 1 + constant integer bj_MISSION_INDEX_N02 = bj_CAMPAIGN_OFFSET_N * 1000 + 2 + constant integer bj_MISSION_INDEX_N03 = bj_CAMPAIGN_OFFSET_N * 1000 + 3 + constant integer bj_MISSION_INDEX_N04 = bj_CAMPAIGN_OFFSET_N * 1000 + 4 + constant integer bj_MISSION_INDEX_N05 = bj_CAMPAIGN_OFFSET_N * 1000 + 5 + constant integer bj_MISSION_INDEX_N06 = bj_CAMPAIGN_OFFSET_N * 1000 + 6 + constant integer bj_MISSION_INDEX_N07 = bj_CAMPAIGN_OFFSET_N * 1000 + 7 + constant integer bj_MISSION_INDEX_N08 = bj_CAMPAIGN_OFFSET_N * 1000 + 8 + constant integer bj_MISSION_INDEX_N09 = bj_CAMPAIGN_OFFSET_N * 1000 + 9 + // Expansion Night Elf + constant integer bj_MISSION_INDEX_XN00 = bj_CAMPAIGN_OFFSET_XN * 1000 + 0 + constant integer bj_MISSION_INDEX_XN01 = bj_CAMPAIGN_OFFSET_XN * 1000 + 1 + constant integer bj_MISSION_INDEX_XN02 = bj_CAMPAIGN_OFFSET_XN * 1000 + 2 + constant integer bj_MISSION_INDEX_XN03 = bj_CAMPAIGN_OFFSET_XN * 1000 + 3 + constant integer bj_MISSION_INDEX_XN04 = bj_CAMPAIGN_OFFSET_XN * 1000 + 4 + constant integer bj_MISSION_INDEX_XN05 = bj_CAMPAIGN_OFFSET_XN * 1000 + 5 + constant integer bj_MISSION_INDEX_XN06 = bj_CAMPAIGN_OFFSET_XN * 1000 + 6 + constant integer bj_MISSION_INDEX_XN07 = bj_CAMPAIGN_OFFSET_XN * 1000 + 7 + constant integer bj_MISSION_INDEX_XN08 = bj_CAMPAIGN_OFFSET_XN * 1000 + 8 + constant integer bj_MISSION_INDEX_XN09 = bj_CAMPAIGN_OFFSET_XN * 1000 + 9 + constant integer bj_MISSION_INDEX_XN10 = bj_CAMPAIGN_OFFSET_XN * 1000 + 10 + // Expansion Human + constant integer bj_MISSION_INDEX_XH00 = bj_CAMPAIGN_OFFSET_XH * 1000 + 0 + constant integer bj_MISSION_INDEX_XH01 = bj_CAMPAIGN_OFFSET_XH * 1000 + 1 + constant integer bj_MISSION_INDEX_XH02 = bj_CAMPAIGN_OFFSET_XH * 1000 + 2 + constant integer bj_MISSION_INDEX_XH03 = bj_CAMPAIGN_OFFSET_XH * 1000 + 3 + constant integer bj_MISSION_INDEX_XH04 = bj_CAMPAIGN_OFFSET_XH * 1000 + 4 + constant integer bj_MISSION_INDEX_XH05 = bj_CAMPAIGN_OFFSET_XH * 1000 + 5 + constant integer bj_MISSION_INDEX_XH06 = bj_CAMPAIGN_OFFSET_XH * 1000 + 6 + constant integer bj_MISSION_INDEX_XH07 = bj_CAMPAIGN_OFFSET_XH * 1000 + 7 + constant integer bj_MISSION_INDEX_XH08 = bj_CAMPAIGN_OFFSET_XH * 1000 + 8 + constant integer bj_MISSION_INDEX_XH09 = bj_CAMPAIGN_OFFSET_XH * 1000 + 9 + // Expansion Undead + constant integer bj_MISSION_INDEX_XU00 = bj_CAMPAIGN_OFFSET_XU * 1000 + 0 + constant integer bj_MISSION_INDEX_XU01 = bj_CAMPAIGN_OFFSET_XU * 1000 + 1 + constant integer bj_MISSION_INDEX_XU02 = bj_CAMPAIGN_OFFSET_XU * 1000 + 2 + constant integer bj_MISSION_INDEX_XU03 = bj_CAMPAIGN_OFFSET_XU * 1000 + 3 + constant integer bj_MISSION_INDEX_XU04 = bj_CAMPAIGN_OFFSET_XU * 1000 + 4 + constant integer bj_MISSION_INDEX_XU05 = bj_CAMPAIGN_OFFSET_XU * 1000 + 5 + constant integer bj_MISSION_INDEX_XU06 = bj_CAMPAIGN_OFFSET_XU * 1000 + 6 + constant integer bj_MISSION_INDEX_XU07 = bj_CAMPAIGN_OFFSET_XU * 1000 + 7 + constant integer bj_MISSION_INDEX_XU08 = bj_CAMPAIGN_OFFSET_XU * 1000 + 8 + constant integer bj_MISSION_INDEX_XU09 = bj_CAMPAIGN_OFFSET_XU * 1000 + 9 + constant integer bj_MISSION_INDEX_XU10 = bj_CAMPAIGN_OFFSET_XU * 1000 + 10 + constant integer bj_MISSION_INDEX_XU11 = bj_CAMPAIGN_OFFSET_XU * 1000 + 11 + constant integer bj_MISSION_INDEX_XU12 = bj_CAMPAIGN_OFFSET_XU * 1000 + 12 + constant integer bj_MISSION_INDEX_XU13 = bj_CAMPAIGN_OFFSET_XU * 1000 + 13 + // Expansion Orc + constant integer bj_MISSION_INDEX_XO00 = bj_CAMPAIGN_OFFSET_XO * 1000 + 0 + constant integer bj_MISSION_INDEX_XO01 = bj_CAMPAIGN_OFFSET_XO * 1000 + 1 + constant integer bj_MISSION_INDEX_XO02 = bj_CAMPAIGN_OFFSET_XO * 1000 + 2 + constant integer bj_MISSION_INDEX_XO03 = bj_CAMPAIGN_OFFSET_XO * 1000 + 3 + // Rebirth Human + constant integer bj_MISSION_INDEX_RH00 = bj_CAMPAIGN_OFFSET_RH * 1000 + 0 + constant integer bj_MISSION_INDEX_RH01 = bj_CAMPAIGN_OFFSET_RH * 1000 + 1 + constant integer bj_MISSION_INDEX_RH02 = bj_CAMPAIGN_OFFSET_RH * 1000 + 2 + constant integer bj_MISSION_INDEX_RH03 = bj_CAMPAIGN_OFFSET_RH * 1000 + 3 + constant integer bj_MISSION_INDEX_RH04 = bj_CAMPAIGN_OFFSET_RH * 1000 + 4 + // Rebirth Undead + constant integer bj_MISSION_INDEX_RU00 = bj_CAMPAIGN_OFFSET_RU * 1000 + 0 + constant integer bj_MISSION_INDEX_RU01 = bj_CAMPAIGN_OFFSET_RU * 1000 + 1 + constant integer bj_MISSION_INDEX_RU02 = bj_CAMPAIGN_OFFSET_RU * 1000 + 2 + constant integer bj_MISSION_INDEX_RU03 = bj_CAMPAIGN_OFFSET_RU * 1000 + 3 + // Cinematic indexing constants + constant integer bj_CINEMATICINDEX_TOP = 0 + constant integer bj_CINEMATICINDEX_HOP = 1 + constant integer bj_CINEMATICINDEX_HED = 2 + constant integer bj_CINEMATICINDEX_OOP = 3 + constant integer bj_CINEMATICINDEX_OED = 4 + constant integer bj_CINEMATICINDEX_UOP = 5 + constant integer bj_CINEMATICINDEX_UED = 6 + constant integer bj_CINEMATICINDEX_NOP = 7 + constant integer bj_CINEMATICINDEX_NED = 8 + constant integer bj_CINEMATICINDEX_XOP = 9 + constant integer bj_CINEMATICINDEX_XED = 10 + constant integer bj_CINEMATICINDEX_HFO = 11 + constant integer bj_CINEMATICINDEX_UFE = 12 + + // Alliance settings + constant integer bj_ALLIANCE_UNALLIED = 0 + constant integer bj_ALLIANCE_UNALLIED_VISION = 1 + constant integer bj_ALLIANCE_ALLIED = 2 + constant integer bj_ALLIANCE_ALLIED_VISION = 3 + constant integer bj_ALLIANCE_ALLIED_UNITS = 4 + constant integer bj_ALLIANCE_ALLIED_ADVUNITS = 5 + constant integer bj_ALLIANCE_NEUTRAL = 6 + constant integer bj_ALLIANCE_NEUTRAL_VISION = 7 + + // Keyboard Event Types + constant integer bj_KEYEVENTTYPE_DEPRESS = 0 + constant integer bj_KEYEVENTTYPE_RELEASE = 1 + + // Keyboard Event Keys + constant integer bj_KEYEVENTKEY_LEFT = 0 + constant integer bj_KEYEVENTKEY_RIGHT = 1 + constant integer bj_KEYEVENTKEY_DOWN = 2 + constant integer bj_KEYEVENTKEY_UP = 3 + constant integer bj_KEYEVENTKEY_A = 4 + + // Mouse Event Types + constant integer bj_MOUSEEVENTTYPE_DOWN = 0 + constant integer bj_MOUSEEVENTTYPE_UP = 1 + constant integer bj_MOUSEEVENTTYPE_MOVE = 2 + + // Transmission timing methods + constant integer bj_TIMETYPE_ADD = 0 + constant integer bj_TIMETYPE_SET = 1 + constant integer bj_TIMETYPE_SUB = 2 + + // Camera bounds adjustment methods + constant integer bj_CAMERABOUNDS_ADJUST_ADD = 0 + constant integer bj_CAMERABOUNDS_ADJUST_SUB = 1 + + // Quest creation states + constant integer bj_QUESTTYPE_REQ_DISCOVERED = 0 + constant integer bj_QUESTTYPE_REQ_UNDISCOVERED = 1 + constant integer bj_QUESTTYPE_OPT_DISCOVERED = 2 + constant integer bj_QUESTTYPE_OPT_UNDISCOVERED = 3 + + // Quest message types + constant integer bj_QUESTMESSAGE_DISCOVERED = 0 + constant integer bj_QUESTMESSAGE_UPDATED = 1 + constant integer bj_QUESTMESSAGE_COMPLETED = 2 + constant integer bj_QUESTMESSAGE_FAILED = 3 + constant integer bj_QUESTMESSAGE_REQUIREMENT = 4 + constant integer bj_QUESTMESSAGE_MISSIONFAILED = 5 + constant integer bj_QUESTMESSAGE_ALWAYSHINT = 6 + constant integer bj_QUESTMESSAGE_HINT = 7 + constant integer bj_QUESTMESSAGE_SECRET = 8 + constant integer bj_QUESTMESSAGE_UNITACQUIRED = 9 + constant integer bj_QUESTMESSAGE_UNITAVAILABLE = 10 + constant integer bj_QUESTMESSAGE_ITEMACQUIRED = 11 + constant integer bj_QUESTMESSAGE_WARNING = 12 + + // Leaderboard sorting methods + constant integer bj_SORTTYPE_SORTBYVALUE = 0 + constant integer bj_SORTTYPE_SORTBYPLAYER = 1 + constant integer bj_SORTTYPE_SORTBYLABEL = 2 + + // Cinematic fade filter methods + constant integer bj_CINEFADETYPE_FADEIN = 0 + constant integer bj_CINEFADETYPE_FADEOUT = 1 + constant integer bj_CINEFADETYPE_FADEOUTIN = 2 + + // Buff removal methods + constant integer bj_REMOVEBUFFS_POSITIVE = 0 + constant integer bj_REMOVEBUFFS_NEGATIVE = 1 + constant integer bj_REMOVEBUFFS_ALL = 2 + constant integer bj_REMOVEBUFFS_NONTLIFE = 3 + + // Buff properties - polarity + constant integer bj_BUFF_POLARITY_POSITIVE = 0 + constant integer bj_BUFF_POLARITY_NEGATIVE = 1 + constant integer bj_BUFF_POLARITY_EITHER = 2 + + // Buff properties - resist type + constant integer bj_BUFF_RESIST_MAGIC = 0 + constant integer bj_BUFF_RESIST_PHYSICAL = 1 + constant integer bj_BUFF_RESIST_EITHER = 2 + constant integer bj_BUFF_RESIST_BOTH = 3 + + // Hero stats + constant integer bj_HEROSTAT_STR = 0 + constant integer bj_HEROSTAT_AGI = 1 + constant integer bj_HEROSTAT_INT = 2 + + // Hero skill point modification methods + constant integer bj_MODIFYMETHOD_ADD = 0 + constant integer bj_MODIFYMETHOD_SUB = 1 + constant integer bj_MODIFYMETHOD_SET = 2 + + // Unit state adjustment methods (for replaced units) + constant integer bj_UNIT_STATE_METHOD_ABSOLUTE = 0 + constant integer bj_UNIT_STATE_METHOD_RELATIVE = 1 + constant integer bj_UNIT_STATE_METHOD_DEFAULTS = 2 + constant integer bj_UNIT_STATE_METHOD_MAXIMUM = 3 + + // Gate operations + constant integer bj_GATEOPERATION_CLOSE = 0 + constant integer bj_GATEOPERATION_OPEN = 1 + constant integer bj_GATEOPERATION_DESTROY = 2 + + // Game cache value types + constant integer bj_GAMECACHE_BOOLEAN = 0 + constant integer bj_GAMECACHE_INTEGER = 1 + constant integer bj_GAMECACHE_REAL = 2 + constant integer bj_GAMECACHE_UNIT = 3 + constant integer bj_GAMECACHE_STRING = 4 + + // Hashtable value types + constant integer bj_HASHTABLE_BOOLEAN = 0 + constant integer bj_HASHTABLE_INTEGER = 1 + constant integer bj_HASHTABLE_REAL = 2 + constant integer bj_HASHTABLE_STRING = 3 + constant integer bj_HASHTABLE_HANDLE = 4 + + // Item status types + constant integer bj_ITEM_STATUS_HIDDEN = 0 + constant integer bj_ITEM_STATUS_OWNED = 1 + constant integer bj_ITEM_STATUS_INVULNERABLE = 2 + constant integer bj_ITEM_STATUS_POWERUP = 3 + constant integer bj_ITEM_STATUS_SELLABLE = 4 + constant integer bj_ITEM_STATUS_PAWNABLE = 5 + + // Itemcode status types + constant integer bj_ITEMCODE_STATUS_POWERUP = 0 + constant integer bj_ITEMCODE_STATUS_SELLABLE = 1 + constant integer bj_ITEMCODE_STATUS_PAWNABLE = 2 + + // Minimap ping styles + constant integer bj_MINIMAPPINGSTYLE_SIMPLE = 0 + constant integer bj_MINIMAPPINGSTYLE_FLASHY = 1 + constant integer bj_MINIMAPPINGSTYLE_ATTACK = 2 + + // Campaign Minimap icon styles + constant integer bj_CAMPPINGSTYLE_PRIMARY = 0 + constant integer bj_CAMPPINGSTYLE_PRIMARY_GREEN = 1 + constant integer bj_CAMPPINGSTYLE_PRIMARY_RED = 2 + constant integer bj_CAMPPINGSTYLE_BONUS = 3 + constant integer bj_CAMPPINGSTYLE_TURNIN = 4 + constant integer bj_CAMPPINGSTYLE_BOSS = 5 + constant integer bj_CAMPPINGSTYLE_CONTROL_ALLY = 6 + constant integer bj_CAMPPINGSTYLE_CONTROL_NEUTRAL = 7 + constant integer bj_CAMPPINGSTYLE_CONTROL_ENEMY = 8 + + // Corpse creation settings + constant real bj_CORPSE_MAX_DEATH_TIME = 8.00 + + // Corpse creation styles + constant integer bj_CORPSETYPE_FLESH = 0 + constant integer bj_CORPSETYPE_BONE = 1 + + // Elevator pathing-blocker destructable code + constant integer bj_ELEVATOR_BLOCKER_CODE = 'DTep' + constant integer bj_ELEVATOR_CODE01 = 'DTrf' + constant integer bj_ELEVATOR_CODE02 = 'DTrx' + + // Elevator wall codes + constant integer bj_ELEVATOR_WALL_TYPE_ALL = 0 + constant integer bj_ELEVATOR_WALL_TYPE_EAST = 1 + constant integer bj_ELEVATOR_WALL_TYPE_NORTH = 2 + constant integer bj_ELEVATOR_WALL_TYPE_SOUTH = 3 + constant integer bj_ELEVATOR_WALL_TYPE_WEST = 4 + + //----------------------------------------------------------------------- + // Variables + // + + // Force predefs + force bj_FORCE_ALL_PLAYERS = null + force array bj_FORCE_PLAYER + + integer bj_MELEE_MAX_TWINKED_HEROES = 0 + + // Map area rects + rect bj_mapInitialPlayableArea = null + rect bj_mapInitialCameraBounds = null + + // Utility function vars + integer bj_forLoopAIndex = 0 + integer bj_forLoopBIndex = 0 + integer bj_forLoopAIndexEnd = 0 + integer bj_forLoopBIndexEnd = 0 + + boolean bj_slotControlReady = false + boolean array bj_slotControlUsed + mapcontrol array bj_slotControl + + // Game started detection vars + timer bj_gameStartedTimer = null + boolean bj_gameStarted = false + timer bj_volumeGroupsTimer = CreateTimer() + + // Singleplayer check + boolean bj_isSinglePlayer = false + + // Day/Night Cycle vars + trigger bj_dncSoundsDay = null + trigger bj_dncSoundsNight = null + sound bj_dayAmbientSound = null + sound bj_nightAmbientSound = null + trigger bj_dncSoundsDawn = null + trigger bj_dncSoundsDusk = null + sound bj_dawnSound = null + sound bj_duskSound = null + boolean bj_useDawnDuskSounds = true + boolean bj_dncIsDaytime = false + + // Triggered sounds + //sound bj_pingMinimapSound = null + sound bj_rescueSound = null + sound bj_questDiscoveredSound = null + sound bj_questUpdatedSound = null + sound bj_questCompletedSound = null + sound bj_questFailedSound = null + sound bj_questHintSound = null + sound bj_questSecretSound = null + sound bj_questItemAcquiredSound = null + sound bj_questWarningSound = null + sound bj_victoryDialogSound = null + sound bj_defeatDialogSound = null + + // Marketplace vars + trigger bj_stockItemPurchased = null + timer bj_stockUpdateTimer = null + boolean array bj_stockAllowedPermanent + boolean array bj_stockAllowedCharged + boolean array bj_stockAllowedArtifact + integer bj_stockPickedItemLevel = 0 + itemtype bj_stockPickedItemType + + // Melee vars + trigger bj_meleeVisibilityTrained = null + boolean bj_meleeVisibilityIsDay = true + boolean bj_meleeGrantHeroItems = false + location bj_meleeNearestMineToLoc = null + unit bj_meleeNearestMine = null + real bj_meleeNearestMineDist = 0.00 + boolean bj_meleeGameOver = false + boolean array bj_meleeDefeated + boolean array bj_meleeVictoried + unit array bj_ghoul + timer array bj_crippledTimer + timerdialog array bj_crippledTimerWindows + boolean array bj_playerIsCrippled + boolean array bj_playerIsExposed + boolean bj_finishSoonAllExposed = false + timerdialog bj_finishSoonTimerDialog = null + integer array bj_meleeTwinkedHeroes + + // Rescue behavior vars + trigger bj_rescueUnitBehavior = null + boolean bj_rescueChangeColorUnit = true + boolean bj_rescueChangeColorBldg = true + + // Transmission vars + timer bj_cineSceneEndingTimer = null + sound bj_cineSceneLastSound = null + trigger bj_cineSceneBeingSkipped = null + + // Cinematic mode vars + gamespeed bj_cineModePriorSpeed = MAP_SPEED_NORMAL + boolean bj_cineModePriorFogSetting = false + boolean bj_cineModePriorMaskSetting = false + boolean bj_cineModeAlreadyIn = false + boolean bj_cineModePriorDawnDusk = false + integer bj_cineModeSavedSeed = 0 + + // Cinematic fade vars + timer bj_cineFadeFinishTimer = null + timer bj_cineFadeContinueTimer = null + real bj_cineFadeContinueRed = 0 + real bj_cineFadeContinueGreen = 0 + real bj_cineFadeContinueBlue = 0 + real bj_cineFadeContinueTrans = 0 + real bj_cineFadeContinueDuration = 0 + string bj_cineFadeContinueTex = "" + + // QueuedTriggerExecute vars + integer bj_queuedExecTotal = 0 + trigger array bj_queuedExecTriggers + boolean array bj_queuedExecUseConds + timer bj_queuedExecTimeoutTimer = CreateTimer() + trigger bj_queuedExecTimeout = null + + // Helper vars (for Filter and Enum funcs) + integer bj_destInRegionDiesCount = 0 + trigger bj_destInRegionDiesTrig = null + integer bj_groupCountUnits = 0 + integer bj_forceCountPlayers = 0 + integer bj_groupEnumTypeId = 0 + player bj_groupEnumOwningPlayer = null + group bj_groupAddGroupDest = null + group bj_groupRemoveGroupDest = null + integer bj_groupRandomConsidered = 0 + unit bj_groupRandomCurrentPick = null + group bj_groupLastCreatedDest = null + group bj_randomSubGroupGroup = null + integer bj_randomSubGroupWant = 0 + integer bj_randomSubGroupTotal = 0 + real bj_randomSubGroupChance = 0 + integer bj_destRandomConsidered = 0 + destructable bj_destRandomCurrentPick = null + destructable bj_elevatorWallBlocker = null + destructable bj_elevatorNeighbor = null + integer bj_itemRandomConsidered = 0 + item bj_itemRandomCurrentPick = null + integer bj_forceRandomConsidered = 0 + player bj_forceRandomCurrentPick = null + unit bj_makeUnitRescuableUnit = null + boolean bj_makeUnitRescuableFlag = true + boolean bj_pauseAllUnitsFlag = true + location bj_enumDestructableCenter = null + real bj_enumDestructableRadius = 0 + playercolor bj_setPlayerTargetColor = null + boolean bj_isUnitGroupDeadResult = true + boolean bj_isUnitGroupEmptyResult = true + boolean bj_isUnitGroupInRectResult = true + rect bj_isUnitGroupInRectRect = null + boolean bj_changeLevelShowScores = false + string bj_changeLevelMapName = null + group bj_suspendDecayFleshGroup = CreateGroup() + group bj_suspendDecayBoneGroup = CreateGroup() + timer bj_delayedSuspendDecayTimer = CreateTimer() + trigger bj_delayedSuspendDecayTrig = null + integer bj_livingPlayerUnitsTypeId = 0 + widget bj_lastDyingWidget = null + boolean bj_HeroGlowAllUnitsFlag = true + boolean bj_enableAurasAllUnits = true + boolean bj_affectsUIAurasAllUnits = true + + // Random distribution vars + integer bj_randDistCount = 0 + integer array bj_randDistID + integer array bj_randDistChance + + // Last X'd vars + unit bj_lastCreatedUnit = null + item bj_lastCreatedItem = null + item bj_lastRemovedItem = null + unit bj_lastHauntedGoldMine = null + destructable bj_lastCreatedDestructable = null + group bj_lastCreatedGroup = CreateGroup() + fogmodifier bj_lastCreatedFogModifier = null + effect bj_lastCreatedEffect = null + weathereffect bj_lastCreatedWeatherEffect = null + terraindeformation bj_lastCreatedTerrainDeformation = null + quest bj_lastCreatedQuest = null + questitem bj_lastCreatedQuestItem = null + defeatcondition bj_lastCreatedDefeatCondition = null + timer bj_lastStartedTimer = CreateTimer() + timerdialog bj_lastCreatedTimerDialog = null + leaderboard bj_lastCreatedLeaderboard = null + multiboard bj_lastCreatedMultiboard = null + sound bj_lastPlayedSound = null + string bj_lastPlayedMusic = "" + real bj_lastTransmissionDuration = 0 + gamecache bj_lastCreatedGameCache = null + hashtable bj_lastCreatedHashtable = null + unit bj_lastLoadedUnit = null + button bj_lastCreatedButton = null + unit bj_lastReplacedUnit = null + texttag bj_lastCreatedTextTag = null + lightning bj_lastCreatedLightning = null + image bj_lastCreatedImage = null + ubersplat bj_lastCreatedUbersplat = null + minimapicon bj_lastCreatedMinimapIcon = null + commandbuttoneffect bj_lastCreatedCommandButtonEffect = null + item bj_lastEquippedItem = null + item bj_lastUnequippedItem = null + + // Filter function vars + boolexpr filterIssueHauntOrderAtLocBJ = null + boolexpr filterEnumDestructablesInCircleBJ = null + boolexpr filterGetUnitsInRectOfPlayer = null + boolexpr filterGetUnitsOfTypeIdAll = null + boolexpr filterGetUnitsOfPlayerAndTypeId = null + boolexpr filterMeleeTrainedUnitIsHeroBJ = null + boolexpr filterLivingPlayerUnitsOfTypeId = null + + // Memory cleanup vars + boolean bj_wantDestroyGroup = false + effect bj_destroyEffectAsyncEffect = null + real bj_destroyEffectAsyncTime = 0 + + // Instanced Operation Results + boolean bj_lastInstObjFuncSuccessful = true +endglobals + + + +//*************************************************************************** +//* +//* Debugging Functions +//* +//*************************************************************************** + +//=========================================================================== +function BJDebugMsg takes string msg returns nothing + local integer i = 0 + loop + call DisplayTimedTextToPlayer(Player(i),0,0,60,msg) + set i = i + 1 + exitwhen i == bj_MAX_PLAYERS + endloop +endfunction + +//*************************************************************************** +//* +//* Memory Cleanup Functions +//* +//*************************************************************************** + +function SetWantDestroyGroupBJ takes nothing returns nothing + set bj_wantDestroyGroup = true +endfunction + +function ClearWantDestroyGroupBJ takes nothing returns nothing + set bj_wantDestroyGroup = false +endfunction + +function GetWantDestroyGroupBJ takes nothing returns boolean + return bj_wantDestroyGroup +endfunction + +//*************************************************************************** +//* +//* Math Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function RMinBJ takes real a, real b returns real + if (a < b) then + return a + else + return b + endif +endfunction + +//=========================================================================== +function RMaxBJ takes real a, real b returns real + if (a < b) then + return b + else + return a + endif +endfunction + +//=========================================================================== +function RAbsBJ takes real a returns real + if (a >= 0) then + return a + else + return -a + endif +endfunction + +//=========================================================================== +function RSignBJ takes real a returns real + if (a >= 0.0) then + return 1.0 + else + return -1.0 + endif +endfunction + +//=========================================================================== +function IMinBJ takes integer a, integer b returns integer + if (a < b) then + return a + else + return b + endif +endfunction + +//=========================================================================== +function IMaxBJ takes integer a, integer b returns integer + if (a < b) then + return b + else + return a + endif +endfunction + +//=========================================================================== +function IAbsBJ takes integer a returns integer + if (a >= 0) then + return a + else + return -a + endif +endfunction + +//=========================================================================== +function ISignBJ takes integer a returns integer + if (a >= 0) then + return 1 + else + return -1 + endif +endfunction + +//=========================================================================== +function SinBJ takes real degrees returns real + return Sin(degrees * bj_DEGTORAD) +endfunction + +//=========================================================================== +function CosBJ takes real degrees returns real + return Cos(degrees * bj_DEGTORAD) +endfunction + +//=========================================================================== +function TanBJ takes real degrees returns real + return Tan(degrees * bj_DEGTORAD) +endfunction + +//=========================================================================== +function AsinBJ takes real degrees returns real + return Asin(degrees) * bj_RADTODEG +endfunction + +//=========================================================================== +function AcosBJ takes real degrees returns real + return Acos(degrees) * bj_RADTODEG +endfunction + +//=========================================================================== +function AtanBJ takes real degrees returns real + return Atan(degrees) * bj_RADTODEG +endfunction + +//=========================================================================== +function Atan2BJ takes real y, real x returns real + return Atan2(y, x) * bj_RADTODEG +endfunction + +//=========================================================================== +function AngleBetweenPoints takes location locA, location locB returns real + return bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA)) +endfunction + +//=========================================================================== +function DistanceBetweenPoints takes location locA, location locB returns real + local real dx = GetLocationX(locB) - GetLocationX(locA) + local real dy = GetLocationY(locB) - GetLocationY(locA) + return SquareRoot(dx * dx + dy * dy) +endfunction + +//=========================================================================== +function PolarProjectionBJ takes location source, real dist, real angle returns location + local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD) + local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD) + return Location(x, y) +endfunction + +//=========================================================================== +function GetRandomDirectionDeg takes nothing returns real + return GetRandomReal(0, 360) +endfunction + +//=========================================================================== +function GetRandomPercentageBJ takes nothing returns real + return GetRandomReal(0, 100) +endfunction + +//=========================================================================== +function GetRandomLocInRect takes rect whichRect returns location + return Location(GetRandomReal(GetRectMinX(whichRect), GetRectMaxX(whichRect)), GetRandomReal(GetRectMinY(whichRect), GetRectMaxY(whichRect))) +endfunction + +//=========================================================================== +// Calculate the modulus/remainder of (dividend) divided by (divisor). +// Examples: 18 mod 5 = 3. 15 mod 5 = 0. -8 mod 5 = 2. +// +function ModuloInteger takes integer dividend, integer divisor returns integer + local integer modulus = dividend - (dividend / divisor) * divisor + + // If the dividend was negative, the above modulus calculation will + // be negative, but within (-divisor..0). We can add (divisor) to + // shift this result into the desired range of (0..divisor). + if (modulus < 0) then + set modulus = modulus + divisor + endif + + return modulus +endfunction + +//=========================================================================== +// Calculate the modulus/remainder of (dividend) divided by (divisor). +// Examples: 13.000 mod 2.500 = 0.500. -6.000 mod 2.500 = 1.500. +// +function ModuloReal takes real dividend, real divisor returns real + local real modulus = dividend - I2R(R2I(dividend / divisor)) * divisor + + // If the dividend was negative, the above modulus calculation will + // be negative, but within (-divisor..0). We can add (divisor) to + // shift this result into the desired range of (0..divisor). + if (modulus < 0) then + set modulus = modulus + divisor + endif + + return modulus +endfunction + +//=========================================================================== +function OffsetLocation takes location loc, real dx, real dy returns location + return Location(GetLocationX(loc) + dx, GetLocationY(loc) + dy) +endfunction + +//=========================================================================== +function OffsetRectBJ takes rect r, real dx, real dy returns rect + return Rect( GetRectMinX(r) + dx, GetRectMinY(r) + dy, GetRectMaxX(r) + dx, GetRectMaxY(r) + dy ) +endfunction + +//=========================================================================== +function RectFromCenterSizeBJ takes location center, real width, real height returns rect + local real x = GetLocationX( center ) + local real y = GetLocationY( center ) + return Rect( x - width*0.5, y - height*0.5, x + width*0.5, y + height*0.5 ) +endfunction + +//=========================================================================== +function RectContainsCoords takes rect r, real x, real y returns boolean + return (GetRectMinX(r) <= x) and (x <= GetRectMaxX(r)) and (GetRectMinY(r) <= y) and (y <= GetRectMaxY(r)) +endfunction + +//=========================================================================== +function RectContainsLoc takes rect r, location loc returns boolean + return RectContainsCoords(r, GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +function RectContainsUnit takes rect r, unit whichUnit returns boolean + return RectContainsCoords(r, GetUnitX(whichUnit), GetUnitY(whichUnit)) +endfunction + +//=========================================================================== +function RectContainsItem takes item whichItem, rect r returns boolean + if (whichItem == null) then + return false + endif + + if (IsItemOwned(whichItem)) then + return false + endif + + return RectContainsCoords(r, GetItemX(whichItem), GetItemY(whichItem)) +endfunction + + + +//*************************************************************************** +//* +//* Utility Constructs +//* +//*************************************************************************** + +//=========================================================================== +// Runs the trigger's actions if the trigger's conditions evaluate to true. +// +function ConditionalTriggerExecute takes trigger trig returns nothing + if TriggerEvaluate(trig) then + call TriggerExecute(trig) + endif +endfunction + +//=========================================================================== +// Runs the trigger's actions if the trigger's conditions evaluate to true. +// +function TriggerExecuteBJ takes trigger trig, boolean checkConditions returns boolean + if checkConditions then + if not (TriggerEvaluate(trig)) then + return false + endif + endif + call TriggerExecute(trig) + return true +endfunction + +//=========================================================================== +// Arranges for a trigger to fire almost immediately, except that the calling +// trigger is not interrupted as is the case with a TriggerExecute call. +// Since the trigger executes normally, its conditions are still evaluated. +// +function PostTriggerExecuteBJ takes trigger trig, boolean checkConditions returns boolean + if checkConditions then + if not (TriggerEvaluate(trig)) then + return false + endif + endif + call TriggerRegisterTimerEvent(trig, 0, false) + return true +endfunction + +//=========================================================================== +// Debug - Display the contents of the trigger queue (as either null or "x" +// for each entry). +function QueuedTriggerCheck takes nothing returns nothing + local string s = "TrigQueue Check " + local integer i + + set i = 0 + loop + exitwhen i >= bj_queuedExecTotal + set s = s + "q[" + I2S(i) + "]=" + if (bj_queuedExecTriggers[i] == null) then + set s = s + "null " + else + set s = s + "x " + endif + set i = i + 1 + endloop + set s = s + "(" + I2S(bj_queuedExecTotal) + " total)" + call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,600,s) +endfunction + +//=========================================================================== +// Searches the queue for a given trigger, returning the index of the +// trigger within the queue if it is found, or -1 if it is not found. +// +function QueuedTriggerGetIndex takes trigger trig returns integer + // Determine which, if any, of the queued triggers is being removed. + local integer index = 0 + loop + exitwhen index >= bj_queuedExecTotal + if (bj_queuedExecTriggers[index] == trig) then + return index + endif + set index = index + 1 + endloop + return -1 +endfunction + +//=========================================================================== +// Removes a trigger from the trigger queue, shifting other triggers down +// to fill the unused space. If the currently running trigger is removed +// in this manner, this function does NOT attempt to run the next trigger. +// +function QueuedTriggerRemoveByIndex takes integer trigIndex returns boolean + local integer index + + // If the to-be-removed index is out of range, fail. + if (trigIndex >= bj_queuedExecTotal) then + return false + endif + + // Shift all queue entries down to fill in the gap. + set bj_queuedExecTotal = bj_queuedExecTotal - 1 + set index = trigIndex + loop + exitwhen index >= bj_queuedExecTotal + set bj_queuedExecTriggers[index] = bj_queuedExecTriggers[index + 1] + set bj_queuedExecUseConds[index] = bj_queuedExecUseConds[index + 1] + set index = index + 1 + endloop + return true +endfunction + +//=========================================================================== +// Attempt to execute the first trigger in the queue. If it fails, remove +// it and execute the next one. Continue this cycle until a trigger runs, +// or until the queue is empty. +// +function QueuedTriggerAttemptExec takes nothing returns boolean + loop + exitwhen bj_queuedExecTotal == 0 + + if TriggerExecuteBJ(bj_queuedExecTriggers[0], bj_queuedExecUseConds[0]) then + // Timeout the queue if it sits at the front of the queue for too long. + call TimerStart(bj_queuedExecTimeoutTimer, bj_QUEUED_TRIGGER_TIMEOUT, false, null) + return true + endif + + call QueuedTriggerRemoveByIndex(0) + endloop + return false +endfunction + +//=========================================================================== +// Queues a trigger to be executed, assuring that such triggers are not +// executed at the same time. +// +function QueuedTriggerAddBJ takes trigger trig, boolean checkConditions returns boolean + // Make sure our queue isn't full. If it is, return failure. + if (bj_queuedExecTotal >= bj_MAX_QUEUED_TRIGGERS) then + return false + endif + + // Add the trigger to an array of to-be-executed triggers. + set bj_queuedExecTriggers[bj_queuedExecTotal] = trig + set bj_queuedExecUseConds[bj_queuedExecTotal] = checkConditions + set bj_queuedExecTotal = bj_queuedExecTotal + 1 + + // If this is the only trigger in the queue, run it. + if (bj_queuedExecTotal == 1) then + call QueuedTriggerAttemptExec() + endif + return true +endfunction + +//=========================================================================== +// Denotes the end of a queued trigger. Be sure to call this only once per +// queued trigger, or risk stepping on the toes of other queued triggers. +// +function QueuedTriggerRemoveBJ takes trigger trig returns nothing + local integer index + local integer trigIndex + local boolean trigExecuted + + // Find the trigger's index. + set trigIndex = QueuedTriggerGetIndex(trig) + if (trigIndex == -1) then + return + endif + + // Shuffle the other trigger entries down to fill in the gap. + call QueuedTriggerRemoveByIndex(trigIndex) + + // If we just axed the currently running trigger, run the next one. + if (trigIndex == 0) then + call PauseTimer(bj_queuedExecTimeoutTimer) + call QueuedTriggerAttemptExec() + endif +endfunction + +//=========================================================================== +// Denotes the end of a queued trigger. Be sure to call this only once per +// queued trigger, lest you step on the toes of other queued triggers. +// +function QueuedTriggerDoneBJ takes nothing returns nothing + local integer index + + // Make sure there's something on the queue to remove. + if (bj_queuedExecTotal <= 0) then + return + endif + + // Remove the currently running trigger from the array. + call QueuedTriggerRemoveByIndex(0) + + // If other triggers are waiting to run, run one of them. + call PauseTimer(bj_queuedExecTimeoutTimer) + call QueuedTriggerAttemptExec() +endfunction + +//=========================================================================== +// Empty the trigger queue. +// +function QueuedTriggerClearBJ takes nothing returns nothing + call PauseTimer(bj_queuedExecTimeoutTimer) + set bj_queuedExecTotal = 0 +endfunction + +//=========================================================================== +// Remove all but the currently executing trigger from the trigger queue. +// +function QueuedTriggerClearInactiveBJ takes nothing returns nothing + set bj_queuedExecTotal = IMinBJ(bj_queuedExecTotal, 1) +endfunction + +//=========================================================================== +function QueuedTriggerCountBJ takes nothing returns integer + return bj_queuedExecTotal +endfunction + +//=========================================================================== +function IsTriggerQueueEmptyBJ takes nothing returns boolean + return bj_queuedExecTotal <= 0 +endfunction + +//=========================================================================== +function IsTriggerQueuedBJ takes trigger trig returns boolean + return QueuedTriggerGetIndex(trig) != -1 +endfunction + +//=========================================================================== +function GetForLoopIndexA takes nothing returns integer + return bj_forLoopAIndex +endfunction + +//=========================================================================== +function SetForLoopIndexA takes integer newIndex returns nothing + set bj_forLoopAIndex = newIndex +endfunction + +//=========================================================================== +function GetForLoopIndexB takes nothing returns integer + return bj_forLoopBIndex +endfunction + +//=========================================================================== +function SetForLoopIndexB takes integer newIndex returns nothing + set bj_forLoopBIndex = newIndex +endfunction + +//=========================================================================== +// We can't do game-time waits, so this simulates one by starting a timer +// and polling until the timer expires. +function PolledWait takes real duration returns nothing + local timer t + local real timeRemaining + + if (duration > 0) then + set t = CreateTimer() + call TimerStart(t, duration, false, null) + loop + set timeRemaining = TimerGetRemaining(t) + exitwhen timeRemaining <= 0 + + // If we have a bit of time left, skip past 10% of the remaining + // duration instead of checking every interval, to minimize the + // polling on long waits. + if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then + call TriggerSleepAction(0.1 * timeRemaining) + else + call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL) + endif + endloop + call DestroyTimer(t) + endif +endfunction + +//=========================================================================== +function IntegerTertiaryOp takes boolean flag, integer valueA, integer valueB returns integer + if flag then + return valueA + else + return valueB + endif +endfunction + + +//*************************************************************************** +//* +//* General Utility Functions +//* These functions exist purely to make the trigger dialogs cleaner and +//* more comprehensible. +//* +//*************************************************************************** + +//=========================================================================== +function DoNothing takes nothing returns nothing +endfunction + +//=========================================================================== +// This function does nothing. WorldEdit should should eventually ignore +// CommentString triggers during script generation, but until such a time, +// this function will serve as a stub. +// +function CommentString takes string commentString returns nothing +endfunction + +//=========================================================================== +// This function returns the input string, converting it from the localized text, if necessary +// +function StringIdentity takes string theString returns string + return GetLocalizedString(theString) +endfunction + +//=========================================================================== +function GetBooleanAnd takes boolean valueA, boolean valueB returns boolean + return valueA and valueB +endfunction + +//=========================================================================== +function GetBooleanOr takes boolean valueA, boolean valueB returns boolean + return valueA or valueB +endfunction + +//=========================================================================== +// Converts a percentage (real, 0..100) into a scaled integer (0..max), +// clipping the result to 0..max in case the input is invalid. +// +function PercentToInt takes real percentage, integer max returns integer + local real realpercent = percentage * I2R(max) * 0.01 + local integer result = MathRound(realpercent) + + if (result < 0) then + set result = 0 + elseif (result > max) then + set result = max + endif + + return result +endfunction + +//=========================================================================== +function PercentTo255 takes real percentage returns integer + return PercentToInt(percentage, 255) +endfunction + +//=========================================================================== +function GetTimeOfDay takes nothing returns real + return GetFloatGameState(GAME_STATE_TIME_OF_DAY) +endfunction + +//=========================================================================== +function SetTimeOfDay takes real whatTime returns nothing + call SetFloatGameState(GAME_STATE_TIME_OF_DAY, whatTime) +endfunction + +//=========================================================================== +function SetTimeOfDayScalePercentBJ takes real scalePercent returns nothing + call SetTimeOfDayScale(scalePercent * 0.01) +endfunction + +//=========================================================================== +function GetTimeOfDayScalePercentBJ takes nothing returns real + return GetTimeOfDayScale() * 100 +endfunction + +//=========================================================================== +function PlaySound takes string soundName returns nothing + local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "") + call StartSound(soundHandle) + call KillSoundWhenDone(soundHandle) +endfunction + +//=========================================================================== +function CompareLocationsBJ takes location A, location B returns boolean + return GetLocationX(A) == GetLocationX(B) and GetLocationY(A) == GetLocationY(B) +endfunction + +//=========================================================================== +function CompareRectsBJ takes rect A, rect B returns boolean + return GetRectMinX(A) == GetRectMinX(B) and GetRectMinY(A) == GetRectMinY(B) and GetRectMaxX(A) == GetRectMaxX(B) and GetRectMaxY(A) == GetRectMaxY(B) +endfunction + +//=========================================================================== +// Returns a square rect that exactly encompasses the specified circle. +// +function GetRectFromCircleBJ takes location center, real radius returns rect + local real centerX = GetLocationX(center) + local real centerY = GetLocationY(center) + return Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius) +endfunction + + + +//*************************************************************************** +//* +//* Camera Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function GetCurrentCameraSetup takes nothing returns camerasetup + local camerasetup theCam = CreateCameraSetup() + local real duration = 0 + call CameraSetupSetField(theCam, CAMERA_FIELD_TARGET_DISTANCE, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_FARZ, GetCameraField(CAMERA_FIELD_FARZ), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_ANGLE_OF_ATTACK, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_FIELD_OF_VIEW, bj_RADTODEG * GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_ROLL, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROLL), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_ROTATION, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROTATION), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_PITCH, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_PITCH), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_YAW, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_YAW), duration) + call CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_ROLL, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_ROLL), duration) + call CameraSetupSetDestPosition(theCam, GetCameraTargetPositionX(), GetCameraTargetPositionY(), duration) + return theCam +endfunction + +//=========================================================================== +function CameraSetupApplyForPlayer takes boolean doPan, camerasetup whichSetup, player whichPlayer, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call CameraSetupApplyForceDuration(whichSetup, doPan, duration) + endif +endfunction + +//=========================================================================== +function CameraSetupApplyForPlayerSmooth takes boolean doPan, camerasetup whichSetup, player whichPlayer, real forcedDuration, real easeInDuration, real easeOutDuration, real smoothFactor returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call BlzCameraSetupApplyForceDurationSmooth(whichSetup, doPan, forcedDuration, easeInDuration, easeOutDuration, smoothFactor) + endif +endfunction + +//=========================================================================== +function CameraSetupGetFieldSwap takes camerafield whichField, camerasetup whichSetup returns real + return CameraSetupGetField(whichSetup, whichField) +endfunction + +//=========================================================================== +function SetCameraFieldForPlayer takes player whichPlayer, camerafield whichField, real value, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraField(whichField, value, duration) + endif +endfunction + +//=========================================================================== +function SetCameraFieldControlledByInputForPlayer takes player whichPlayer, camerafield whichField, boolean controlled returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraFieldControlledByInput(whichField, controlled) + endif +endfunction + +//=========================================================================== +function SetCameraTargetControllerNoZForPlayer takes player whichPlayer, unit whichUnit, real xoffset, real yoffset, boolean inheritOrientation returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraTargetController(whichUnit, xoffset, yoffset, inheritOrientation) + endif +endfunction + +//=========================================================================== +function SetCameraPositionForPlayer takes player whichPlayer, real x, real y returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraPosition(x, y) + endif +endfunction + +//=========================================================================== +function SetCameraPositionLocForPlayer takes player whichPlayer, location loc returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraPosition(GetLocationX(loc), GetLocationY(loc)) + endif +endfunction + +//=========================================================================== +function RotateCameraAroundLocBJ takes real degrees, location loc, player whichPlayer, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraRotateMode(GetLocationX(loc), GetLocationY(loc), bj_DEGTORAD * degrees, duration) + endif +endfunction + +//=========================================================================== +function PanCameraToForPlayer takes player whichPlayer, real x, real y returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PanCameraTo(x, y) + endif +endfunction + +//=========================================================================== +function PanCameraToLocForPlayer takes player whichPlayer, location loc returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PanCameraTo(GetLocationX(loc), GetLocationY(loc)) + endif +endfunction + +//=========================================================================== +function PanCameraToTimedForPlayer takes player whichPlayer, real x, real y, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PanCameraToTimed(x, y, duration) + endif +endfunction + +//=========================================================================== +function PanCameraToTimedLocForPlayer takes player whichPlayer, location loc, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration) + endif +endfunction + +//=========================================================================== +function PanCameraToTimedLocWithZForPlayer takes player whichPlayer, location loc, real zOffset, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PanCameraToTimedWithZ(GetLocationX(loc), GetLocationY(loc), zOffset, duration) + endif +endfunction + +//=========================================================================== +function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing + local real dist + local location cameraLoc = GetCameraTargetPositionLoc() + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + set dist = DistanceBetweenPoints(loc, cameraLoc) + if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then + // If the user is too far away, snap the camera. + call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0) + elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then + // If the user is moderately close, pan the camera. + call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration) + else + // User is close enough, so don't touch the camera. + endif + endif + call RemoveLocation(cameraLoc) +endfunction + +//=========================================================================== +function SetCinematicCameraForPlayer takes player whichPlayer, string cameraModelFile returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCinematicCamera(cameraModelFile) + endif +endfunction + +//=========================================================================== +function ResetToGameCameraForPlayer takes player whichPlayer, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ResetToGameCamera(duration) + endif +endfunction + +//=========================================================================== +function CameraSetSourceNoiseForPlayer takes player whichPlayer, real magnitude, real velocity returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call CameraSetSourceNoise(magnitude, velocity) + endif +endfunction + +//=========================================================================== +function CameraSetTargetNoiseForPlayer takes player whichPlayer, real magnitude, real velocity returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call CameraSetTargetNoise(magnitude, velocity) + endif +endfunction + +//=========================================================================== +function CameraSetEQNoiseForPlayer takes player whichPlayer, real magnitude returns nothing + local real richter = magnitude + if (richter > 5.0) then + set richter = 5.0 + endif + if (richter < 2.0) then + set richter = 2.0 + endif + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call CameraSetTargetNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true) + call CameraSetSourceNoiseEx(magnitude*2.0, magnitude*Pow(10,richter),true) + endif +endfunction + +//=========================================================================== +function CameraClearNoiseForPlayer takes player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call CameraSetSourceNoise(0, 0) + call CameraSetTargetNoise(0, 0) + endif +endfunction + +//=========================================================================== +// Query the current camera bounds. +// +function GetCurrentCameraBoundsMapRectBJ takes nothing returns rect + return Rect(GetCameraBoundMinX(), GetCameraBoundMinY(), GetCameraBoundMaxX(), GetCameraBoundMaxY()) +endfunction + +//=========================================================================== +// Query the initial camera bounds, as defined at map init. +// +function GetCameraBoundsMapRect takes nothing returns rect + return bj_mapInitialCameraBounds +endfunction + +//=========================================================================== +// Query the playable map area, as defined at map init. +// +function GetPlayableMapRect takes nothing returns rect + return bj_mapInitialPlayableArea +endfunction + +//=========================================================================== +// Query the entire map area, as defined at map init. +// +function GetEntireMapRect takes nothing returns rect + return GetWorldBounds() +endfunction + +//=========================================================================== +function SetCameraBoundsToRect takes rect r returns nothing + local real minX = GetRectMinX(r) + local real minY = GetRectMinY(r) + local real maxX = GetRectMaxX(r) + local real maxY = GetRectMaxY(r) + call SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY) +endfunction + +//=========================================================================== +function SetCameraBoundsToRectForPlayerBJ takes player whichPlayer, rect r returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraBoundsToRect(r) + endif +endfunction + +//=========================================================================== +function AdjustCameraBoundsBJ takes integer adjustMethod, real dxWest, real dxEast, real dyNorth, real dySouth returns nothing + local real minX = 0 + local real minY = 0 + local real maxX = 0 + local real maxY = 0 + local real scale = 0 + + if (adjustMethod == bj_CAMERABOUNDS_ADJUST_ADD) then + set scale = 1 + elseif (adjustMethod == bj_CAMERABOUNDS_ADJUST_SUB) then + set scale = -1 + else + // Unrecognized adjustment method - ignore the request. + return + endif + + // Adjust the actual camera values + set minX = GetCameraBoundMinX() - scale * dxWest + set maxX = GetCameraBoundMaxX() + scale * dxEast + set minY = GetCameraBoundMinY() - scale * dySouth + set maxY = GetCameraBoundMaxY() + scale * dyNorth + + // Make sure the camera bounds are still valid. + if (maxX < minX) then + set minX = (minX + maxX) * 0.5 + set maxX = minX + endif + if (maxY < minY) then + set minY = (minY + maxY) * 0.5 + set maxY = minY + endif + + // Apply the new camera values. + call SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY) +endfunction + +//=========================================================================== +function AdjustCameraBoundsForPlayerBJ takes integer adjustMethod, player whichPlayer, real dxWest, real dxEast, real dyNorth, real dySouth returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call AdjustCameraBoundsBJ(adjustMethod, dxWest, dxEast, dyNorth, dySouth) + endif +endfunction + +//=========================================================================== +function SetCameraQuickPositionForPlayer takes player whichPlayer, real x, real y returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraQuickPosition(x, y) + endif +endfunction + +//=========================================================================== +function SetCameraQuickPositionLocForPlayer takes player whichPlayer, location loc returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraQuickPosition(GetLocationX(loc), GetLocationY(loc)) + endif +endfunction + +//=========================================================================== +function SetCameraQuickPositionLoc takes location loc returns nothing + call SetCameraQuickPosition(GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +function StopCameraForPlayerBJ takes player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call StopCamera() + endif +endfunction + +//=========================================================================== +function SetCameraOrientControllerForPlayerBJ takes player whichPlayer, unit whichUnit, real xoffset, real yoffset returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetCameraOrientController(whichUnit, xoffset, yoffset) + endif +endfunction + +//=========================================================================== +function CameraSetSmoothingFactorBJ takes real factor returns nothing + call CameraSetSmoothingFactor(factor) +endfunction + +//=========================================================================== +function CameraResetSmoothingFactorBJ takes nothing returns nothing + call CameraSetSmoothingFactor(0) +endfunction + + + +//*************************************************************************** +//* +//* Text Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function DisplayTextToForce takes force toForce, string message returns nothing + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call DisplayTextToPlayer(GetLocalPlayer(), 0, 0, message) + endif +endfunction + +//=========================================================================== +function DisplayTimedTextToForce takes force toForce, real duration, string message returns nothing + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message) + endif +endfunction + +//=========================================================================== +function ClearTextMessagesBJ takes force toForce returns nothing + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ClearTextMessages() + endif +endfunction + +//=========================================================================== +// The parameters for the API Substring function are unintuitive, so this +// merely performs a translation for the starting index. +// +function SubStringBJ takes string source, integer start, integer end returns string + return SubString(source, start-1, end) +endfunction + +function GetHandleIdBJ takes handle h returns integer + return GetHandleId(h) +endfunction + +function StringHashBJ takes string s returns integer + return StringHash(s) +endfunction + + + +//*************************************************************************** +//* +//* Event Registration Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function TriggerRegisterTimerEventPeriodic takes trigger trig, real timeout returns event + return TriggerRegisterTimerEvent(trig, timeout, true) +endfunction + +//=========================================================================== +function TriggerRegisterTimerEventSingle takes trigger trig, real timeout returns event + return TriggerRegisterTimerEvent(trig, timeout, false) +endfunction + +//=========================================================================== +function TriggerRegisterTimerExpireEventBJ takes trigger trig, timer t returns event + return TriggerRegisterTimerExpireEvent(trig, t) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerUnitEventSimple takes trigger trig, player whichPlayer, playerunitevent whichEvent returns event + return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, whichEvent, null) +endfunction + +//=========================================================================== +function TriggerRegisterAnyUnitEventBJ takes trigger trig, playerunitevent whichEvent returns nothing + local integer index + + set index = 0 + loop + call TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, null) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop +endfunction + +//=========================================================================== +function TriggerRegisterPlayerSelectionEventBJ takes trigger trig, player whichPlayer, boolean selected returns event + if selected then + return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, EVENT_PLAYER_UNIT_SELECTED, null) + else + return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, EVENT_PLAYER_UNIT_DESELECTED, null) + endif +endfunction + +//=========================================================================== +function TriggerRegisterPlayerKeyEventBJ takes trigger trig, player whichPlayer, integer keType, integer keKey returns event + if (keType == bj_KEYEVENTTYPE_DEPRESS) then + // Depress event - find out what key + if (keKey == bj_KEYEVENTKEY_LEFT) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_DOWN) + elseif (keKey == bj_KEYEVENTKEY_RIGHT) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_DOWN) + elseif (keKey == bj_KEYEVENTKEY_DOWN) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_DOWN) + elseif (keKey == bj_KEYEVENTKEY_UP) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_DOWN) + else + // Unrecognized key - ignore the request and return failure. + return null + endif + elseif (keType == bj_KEYEVENTTYPE_RELEASE) then + // Release event - find out what key + if (keKey == bj_KEYEVENTKEY_LEFT) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_UP) + elseif (keKey == bj_KEYEVENTKEY_RIGHT) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_UP) + elseif (keKey == bj_KEYEVENTKEY_DOWN) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_UP) + elseif (keKey == bj_KEYEVENTKEY_UP) then + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_UP) + else + // Unrecognized key - ignore the request and return failure. + return null + endif + else + // Unrecognized type - ignore the request and return failure. + return null + endif +endfunction + +//=========================================================================== +function TriggerRegisterPlayerMouseEventBJ takes trigger trig, player whichPlayer, integer meType returns event + if (meType == bj_MOUSEEVENTTYPE_DOWN) then + // Mouse down event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_DOWN) + elseif (meType == bj_MOUSEEVENTTYPE_UP) then + // Mouse up event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_UP) + elseif (meType == bj_MOUSEEVENTTYPE_MOVE) then + // Mouse move event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_MOVE) + else + // Unrecognized type - ignore the request and return failure. + return null + endif +endfunction + +//=========================================================================== +function IsMouseButtonPressedBJ takes mousebuttontype mouseButtonType returns boolean + return BlzIsMouseButtonPressed(mouseButtonType) +endfunction + +//=========================================================================== +function IsMetaKeyPressedBJ takes integer metakey returns boolean + return BlzIsMetaKeyPressed(metakey) +endfunction + +//=========================================================================== +function IsKeyPressedBJ takes oskeytype key returns boolean + return BlzIsKeyPressed(key) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerEventVictory takes trigger trig, player whichPlayer returns event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_VICTORY) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerEventDefeat takes trigger trig, player whichPlayer returns event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_DEFEAT) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerEventLeave takes trigger trig, player whichPlayer returns event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_LEAVE) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerEventAllianceChanged takes trigger trig, player whichPlayer returns event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ALLIANCE_CHANGED) +endfunction + +//=========================================================================== +function TriggerRegisterPlayerEventEndCinematic takes trigger trig, player whichPlayer returns event + return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_END_CINEMATIC) +endfunction + +//=========================================================================== +function TriggerRegisterGameStateEventTimeOfDay takes trigger trig, limitop opcode, real limitval returns event + return TriggerRegisterGameStateEvent(trig, GAME_STATE_TIME_OF_DAY, opcode, limitval) +endfunction + +//=========================================================================== +function TriggerRegisterEnterRegionSimple takes trigger trig, region whichRegion returns event + return TriggerRegisterEnterRegion(trig, whichRegion, null) +endfunction + +//=========================================================================== +function TriggerRegisterLeaveRegionSimple takes trigger trig, region whichRegion returns event + return TriggerRegisterLeaveRegion(trig, whichRegion, null) +endfunction + +//=========================================================================== +function TriggerRegisterEnterRectSimple takes trigger trig, rect r returns event + local region rectRegion = CreateRegion() + call RegionAddRect(rectRegion, r) + return TriggerRegisterEnterRegion(trig, rectRegion, null) +endfunction + +//=========================================================================== +function TriggerRegisterLeaveRectSimple takes trigger trig, rect r returns event + local region rectRegion = CreateRegion() + call RegionAddRect(rectRegion, r) + return TriggerRegisterLeaveRegion(trig, rectRegion, null) +endfunction + +//=========================================================================== +function TriggerRegisterDistanceBetweenUnits takes trigger trig, unit whichUnit, boolexpr condition, real range returns event + return TriggerRegisterUnitInRange(trig, whichUnit, range, condition) +endfunction + +//=========================================================================== +function TriggerRegisterUnitInRangeSimple takes trigger trig, real range, unit whichUnit returns event + return TriggerRegisterUnitInRange(trig, whichUnit, range, null) +endfunction + +//=========================================================================== +function TriggerRegisterUnitLifeEvent takes trigger trig, unit whichUnit, limitop opcode, real limitval returns event + return TriggerRegisterUnitStateEvent(trig, whichUnit, UNIT_STATE_LIFE, opcode, limitval) +endfunction + +//=========================================================================== +function TriggerRegisterUnitManaEvent takes trigger trig, unit whichUnit, limitop opcode, real limitval returns event + return TriggerRegisterUnitStateEvent(trig, whichUnit, UNIT_STATE_MANA, opcode, limitval) +endfunction + +//=========================================================================== +function TriggerRegisterDialogEventBJ takes trigger trig, dialog whichDialog returns event + return TriggerRegisterDialogEvent(trig, whichDialog) +endfunction + +//=========================================================================== +function TriggerRegisterShowSkillEventBJ takes trigger trig returns event + return TriggerRegisterGameEvent(trig, EVENT_GAME_SHOW_SKILL) +endfunction + +//=========================================================================== +function TriggerRegisterBuildSubmenuEventBJ takes trigger trig returns event + return TriggerRegisterGameEvent(trig, EVENT_GAME_BUILD_SUBMENU) +endfunction + +//=========================================================================== +function TriggerRegisterBuildCommandEventBJ takes trigger trig, integer unitId returns event + call TriggerRegisterCommandEvent(trig, 'ANbu', UnitId2String(unitId)) + call TriggerRegisterCommandEvent(trig, 'AHbu', UnitId2String(unitId)) + call TriggerRegisterCommandEvent(trig, 'AEbu', UnitId2String(unitId)) + call TriggerRegisterCommandEvent(trig, 'AObu', UnitId2String(unitId)) + call TriggerRegisterCommandEvent(trig, 'AUbu', UnitId2String(unitId)) + return TriggerRegisterCommandEvent(trig, 'AGbu', UnitId2String(unitId)) +endfunction + +//=========================================================================== +function TriggerRegisterTrainCommandEventBJ takes trigger trig, integer unitId returns event + return TriggerRegisterCommandEvent(trig, 'Aque', UnitId2String(unitId)) +endfunction + +//=========================================================================== +function TriggerRegisterUpgradeCommandEventBJ takes trigger trig, integer techId returns event + return TriggerRegisterUpgradeCommandEvent(trig, techId) +endfunction + +//=========================================================================== +function TriggerRegisterCommonCommandEventBJ takes trigger trig, string order returns event + return TriggerRegisterCommandEvent(trig, 0, order) +endfunction + +//=========================================================================== +function TriggerRegisterGameLoadedEventBJ takes trigger trig returns event + return TriggerRegisterGameEvent(trig, EVENT_GAME_LOADED) +endfunction + +//=========================================================================== +function TriggerRegisterGameSavedEventBJ takes trigger trig returns event + return TriggerRegisterGameEvent(trig, EVENT_GAME_SAVE) +endfunction + +//=========================================================================== +function RegisterDestDeathInRegionEnum takes nothing returns nothing + set bj_destInRegionDiesCount = bj_destInRegionDiesCount + 1 + if (bj_destInRegionDiesCount <= bj_MAX_DEST_IN_REGION_EVENTS) then + call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable()) + endif +endfunction + +//=========================================================================== +function TriggerRegisterDestDeathInRegionEvent takes trigger trig, rect r returns nothing + set bj_destInRegionDiesTrig = trig + set bj_destInRegionDiesCount = 0 + call EnumDestructablesInRect(r, null, function RegisterDestDeathInRegionEnum) +endfunction + + + +//*************************************************************************** +//* +//* Environment Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function AddWeatherEffectSaveLast takes rect where, integer effectID returns weathereffect + set bj_lastCreatedWeatherEffect = AddWeatherEffect(where, effectID) + return bj_lastCreatedWeatherEffect +endfunction + +//=========================================================================== +function GetLastCreatedWeatherEffect takes nothing returns weathereffect + return bj_lastCreatedWeatherEffect +endfunction + +//=========================================================================== +function RemoveWeatherEffectBJ takes weathereffect whichWeatherEffect returns nothing + call RemoveWeatherEffect(whichWeatherEffect) +endfunction + +//=========================================================================== +function TerrainDeformationCraterBJ takes real duration, boolean permanent, location where, real radius, real depth returns terraindeformation + set bj_lastCreatedTerrainDeformation = TerrainDeformCrater(GetLocationX(where), GetLocationY(where), radius, depth, R2I(duration * 1000), permanent) + return bj_lastCreatedTerrainDeformation +endfunction + +//=========================================================================== +function TerrainDeformationRippleBJ takes real duration, boolean limitNeg, location where, real startRadius, real endRadius, real depth, real wavePeriod, real waveWidth returns terraindeformation + local real spaceWave + local real timeWave + local real radiusRatio + + if (endRadius <= 0 or waveWidth <= 0 or wavePeriod <= 0) then + return null + endif + + set timeWave = 2.0 * duration / wavePeriod + set spaceWave = 2.0 * endRadius / waveWidth + set radiusRatio = startRadius / endRadius + + set bj_lastCreatedTerrainDeformation = TerrainDeformRipple(GetLocationX(where), GetLocationY(where), endRadius, depth, R2I(duration * 1000), 1, spaceWave, timeWave, radiusRatio, limitNeg) + return bj_lastCreatedTerrainDeformation +endfunction + +//=========================================================================== +function TerrainDeformationWaveBJ takes real duration, location source, location target, real radius, real depth, real trailDelay returns terraindeformation + local real distance + local real dirX + local real dirY + local real speed + + set distance = DistanceBetweenPoints(source, target) + if (distance == 0 or duration <= 0) then + return null + endif + + set dirX = (GetLocationX(target) - GetLocationX(source)) / distance + set dirY = (GetLocationY(target) - GetLocationY(source)) / distance + set speed = distance / duration + + set bj_lastCreatedTerrainDeformation = TerrainDeformWave(GetLocationX(source), GetLocationY(source), dirX, dirY, distance, speed, radius, depth, R2I(trailDelay * 1000), 1) + return bj_lastCreatedTerrainDeformation +endfunction + +//=========================================================================== +function TerrainDeformationRandomBJ takes real duration, location where, real radius, real minDelta, real maxDelta, real updateInterval returns terraindeformation + set bj_lastCreatedTerrainDeformation = TerrainDeformRandom(GetLocationX(where), GetLocationY(where), radius, minDelta, maxDelta, R2I(duration * 1000), R2I(updateInterval * 1000)) + return bj_lastCreatedTerrainDeformation +endfunction + +//=========================================================================== +function TerrainDeformationStopBJ takes terraindeformation deformation, real duration returns nothing + call TerrainDeformStop(deformation, R2I(duration * 1000)) +endfunction + +//=========================================================================== +function GetLastCreatedTerrainDeformation takes nothing returns terraindeformation + return bj_lastCreatedTerrainDeformation +endfunction + +//=========================================================================== +function AddLightningLoc takes string codeName, location where1, location where2 returns lightning + set bj_lastCreatedLightning = AddLightningEx(codeName, true, GetLocationX(where1), GetLocationY(where1), GetLocationZ(where1), GetLocationX(where2), GetLocationY(where2), GetLocationZ(where2)) + return bj_lastCreatedLightning +endfunction + +//=========================================================================== +function DestroyLightningBJ takes lightning whichBolt returns boolean + return DestroyLightning(whichBolt) +endfunction + +//=========================================================================== +function MoveLightningLoc takes lightning whichBolt, location where1, location where2 returns boolean + return MoveLightningEx(whichBolt, true, GetLocationX(where1), GetLocationY(where1), GetLocationZ(where1), GetLocationX(where2), GetLocationY(where2), GetLocationZ(where2)) +endfunction + +//=========================================================================== +function GetLightningColorABJ takes lightning whichBolt returns real + return GetLightningColorA(whichBolt) +endfunction + +//=========================================================================== +function GetLightningColorRBJ takes lightning whichBolt returns real + return GetLightningColorR(whichBolt) +endfunction + +//=========================================================================== +function GetLightningColorGBJ takes lightning whichBolt returns real + return GetLightningColorG(whichBolt) +endfunction + +//=========================================================================== +function GetLightningColorBBJ takes lightning whichBolt returns real + return GetLightningColorB(whichBolt) +endfunction + +//=========================================================================== +function SetLightningColorBJ takes lightning whichBolt, real r, real g, real b, real a returns boolean + return SetLightningColor(whichBolt, r, g, b, a) +endfunction + +//=========================================================================== +function GetLastCreatedLightningBJ takes nothing returns lightning + return bj_lastCreatedLightning +endfunction + +//=========================================================================== +function GetAbilityEffectBJ takes integer abilcode, effecttype t, integer index returns string + return GetAbilityEffectById(abilcode, t, index) +endfunction + +//=========================================================================== +function GetAbilitySoundBJ takes integer abilcode, soundtype t returns string + return GetAbilitySoundById(abilcode, t) +endfunction + + +//=========================================================================== +function GetTerrainCliffLevelBJ takes location where returns integer + return GetTerrainCliffLevel(GetLocationX(where), GetLocationY(where)) +endfunction + +//=========================================================================== +function GetTerrainTypeBJ takes location where returns integer + return GetTerrainType(GetLocationX(where), GetLocationY(where)) +endfunction + +//=========================================================================== +function GetTerrainVarianceBJ takes location where returns integer + return GetTerrainVariance(GetLocationX(where), GetLocationY(where)) +endfunction + +//=========================================================================== +function SetTerrainTypeBJ takes location where, integer terrainType, integer variation, integer area, integer shape returns nothing + call SetTerrainType(GetLocationX(where), GetLocationY(where), terrainType, variation, area, shape) +endfunction + +//=========================================================================== +function IsTerrainPathableBJ takes location where, pathingtype t returns boolean + return IsTerrainPathable(GetLocationX(where), GetLocationY(where), t) +endfunction + +//=========================================================================== +function SetTerrainPathableBJ takes location where, pathingtype t, boolean flag returns nothing + call SetTerrainPathable(GetLocationX(where), GetLocationY(where), t, flag) +endfunction + +//=========================================================================== +function SetWaterBaseColorBJ takes real red, real green, real blue, real transparency returns nothing + call SetWaterBaseColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function SetHDWaterParamsExBJ takes real red, real green, real blue, boolean override, integer vertexDisplacement, integer minOpacity, integer maxOpacity, integer reflectivity, integer emissivity, integer edgeSoftness, integer waveStrength, integer envMapStrength returns nothing + call SetHDWaterParamsEx (PercentTo255(red), PercentTo255(green), PercentTo255(blue), override, vertexDisplacement, minOpacity, maxOpacity, reflectivity, emissivity, edgeSoftness, waveStrength, envMapStrength) +endfunction + +//=========================================================================== +function BlzSetHDWaterColorBJ takes real red, real green, real blue returns nothing + call BlzSetHDWaterColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue)) + call BlzSetHDWaterColorOverride(true) +endfunction + +//=========================================================================== +function BlzSetHDWaterColorOverrideBJ takes nothing returns nothing + call BlzSetHDWaterColorOverride(true) +endfunction + +//=========================================================================== +function BlzClearHDWaterColorOverrideBJ takes nothing returns nothing + call BlzSetHDWaterColorOverride(false) +endfunction + +//=========================================================================== +function BlzSetHDWaterVertexDisplacementBJ takes integer vertexDisplacement returns nothing + call BlzSetHDWaterVertexDisplacement(vertexDisplacement) +endfunction + +//=========================================================================== +function BlzSetHDWaterMinOpacityBJ takes integer minOpacity returns nothing + call BlzSetHDWaterMinOpacity(minOpacity) +endfunction + +//=========================================================================== +function BlzSetHDWaterMaxOpacityBJ takes integer maxOpacity returns nothing + call BlzSetHDWaterMaxOpacity(maxOpacity) +endfunction + +//=========================================================================== +function BlzSetHDWaterReflectivityBJ takes integer reflectivity returns nothing + call BlzSetHDWaterReflectivity(reflectivity) +endfunction + +//=========================================================================== +function BlzSetHDWaterEmissivityBJ takes integer emissivity returns nothing + call BlzSetHDWaterEmissivity(emissivity) +endfunction + +//=========================================================================== +function BlzSetHDWaterEdgeSoftnessBJ takes integer edgeSoftness returns nothing + call BlzSetHDWaterEdgeSoftness(edgeSoftness) +endfunction + +//=========================================================================== +function BlzSetHDWaterWaveStrengthBJ takes integer waveStrength returns nothing + call BlzSetHDWaterWaveStrength(waveStrength) +endfunction + +//=========================================================================== +function BlzSetHDWaterEnvMapStrengthBJ takes integer envMapStrengthy returns nothing + call BlzSetHDWaterEnvMapStrength(envMapStrengthy) +endfunction + +//=========================================================================== +function CreateFogModifierRectSimple takes player whichPlayer, fogstate whichFogState, rect r, boolean afterUnits returns fogmodifier + set bj_lastCreatedFogModifier = CreateFogModifierRect(whichPlayer, whichFogState, r, true, afterUnits) + return bj_lastCreatedFogModifier +endfunction + +//=========================================================================== +function CreateFogModifierRadiusLocSimple takes player whichPlayer, fogstate whichFogState, location center, real radius, boolean afterUnits returns fogmodifier + set bj_lastCreatedFogModifier = CreateFogModifierRadiusLoc(whichPlayer, whichFogState, center, radius, true, afterUnits) + return bj_lastCreatedFogModifier +endfunction + +//=========================================================================== +// Version of CreateFogModifierRect that assumes use of sharedVision and +// gives the option of immediately enabling the modifier, so that triggers +// can default to modifiers that are immediately enabled. +// +function CreateFogModifierRectBJ takes boolean enabled, player whichPlayer, fogstate whichFogState, rect r returns fogmodifier + set bj_lastCreatedFogModifier = CreateFogModifierRect(whichPlayer, whichFogState, r, true, false) + if enabled then + call FogModifierStart(bj_lastCreatedFogModifier) + endif + return bj_lastCreatedFogModifier +endfunction + +//=========================================================================== +// Version of CreateFogModifierRadius that assumes use of sharedVision and +// gives the option of immediately enabling the modifier, so that triggers +// can default to modifiers that are immediately enabled. +// +function CreateFogModifierRadiusLocBJ takes boolean enabled, player whichPlayer, fogstate whichFogState, location center, real radius returns fogmodifier + set bj_lastCreatedFogModifier = CreateFogModifierRadiusLoc(whichPlayer, whichFogState, center, radius, true, false) + if enabled then + call FogModifierStart(bj_lastCreatedFogModifier) + endif + return bj_lastCreatedFogModifier +endfunction + +//=========================================================================== +function GetLastCreatedFogModifier takes nothing returns fogmodifier + return bj_lastCreatedFogModifier +endfunction + +//=========================================================================== +function FogEnableOn takes nothing returns nothing + call FogEnable(true) +endfunction + +//=========================================================================== +function FogEnableOff takes nothing returns nothing + call FogEnable(false) +endfunction + +//=========================================================================== +function FogMaskEnableOn takes nothing returns nothing + call FogMaskEnable(true) +endfunction + +//=========================================================================== +function FogMaskEnableOff takes nothing returns nothing + call FogMaskEnable(false) +endfunction + +//=========================================================================== +function UseTimeOfDayBJ takes boolean flag returns nothing + call SuspendTimeOfDay(not flag) +endfunction + +//=========================================================================== +function SetTerrainFogExBJ takes integer style, real zstart, real zend, real density, real red, real green, real blue returns nothing + call SetTerrainFogEx(style, zstart, zend, density, red * 0.01, green * 0.01, blue * 0.01) +endfunction + +//=========================================================================== +function SetTerrainFogExVBJ takes integer style, real zstart, real zend, real density, real heightStart, real heightEnd, real linearStart, real linearEnd, real red, real green, real blue returns nothing + call SetTerrainFogExV(style, zstart, zend, density, heightStart, heightEnd, linearStart, linearEnd, red * 0.01, green * 0.01, blue * 0.01) +endfunction + +//=========================================================================== +function BlzSetTerrainFogStyleBJ takes fogstyle style returns nothing + call BlzSetTerrainFogStyle(style) +endfunction + +//=========================================================================== +function BlzSetTerrainFogZStartBJ takes real zStart returns nothing + call BlzSetTerrainFogZStart(zStart) +endfunction + +//=========================================================================== +function BlzSetTerrainFogZEndBJ takes real zEnd returns nothing + call BlzSetTerrainFogZEnd(zEnd) +endfunction + +//=========================================================================== +function BlzSetTerrainFogDensityBJ takes real density returns nothing + call BlzSetTerrainFogDensity(density) +endfunction + +//=========================================================================== +function BlzSetTerrainFogHeightStartBJ takes real heightStart returns nothing + call BlzSetTerrainFogHeightStart(heightStart) +endfunction + +//=========================================================================== +function BlzSetTerrainFogHeightEndBJ takes real heightEnd returns nothing + call BlzSetTerrainFogHeightEnd(heightEnd) +endfunction + +//=========================================================================== +function BlzSetTerrainFogLinearStartBJ takes real linearStart returns nothing + call BlzSetTerrainFogLinearStart(linearStart) +endfunction + +//=========================================================================== +function BlzSetTerrainFogLinearEndBJ takes real linearEnd returns nothing + call BlzSetTerrainFogLinearEnd(linearEnd) +endfunction + +//=========================================================================== +// It refers to max opacity +function BlzSetTerrainFogMaxLinearDensityBJ takes real maxLinearDensity returns nothing + call BlzSetTerrainFogMaxLinearDensity(maxLinearDensity) +endfunction + +//=========================================================================== +function BlzSetTerrainFogDrawOverSkyBJ takes boolean drawOverSky returns nothing + call BlzSetTerrainFogDrawOverSky(drawOverSky) +endfunction + +//=========================================================================== +function BlzSetTerrainFogColorBJ takes real red, real green, real blue returns nothing + call BlzSetTerrainFogColor(red * 0.01, green * 0.01, blue * 0.01) +endfunction + +//=========================================================================== +function ResetTerrainFogBJ takes nothing returns nothing + call ResetTerrainFog() +endfunction + +//=========================================================================== +function SetDoodadAnimationBJ takes string animName, integer doodadID, real radius, location center returns nothing + call SetDoodadAnimation(GetLocationX(center), GetLocationY(center), radius, doodadID, false, animName, false) +endfunction + +//=========================================================================== +function SetDoodadAnimationRectBJ takes string animName, integer doodadID, rect r returns nothing + call SetDoodadAnimationRect(r, doodadID, animName, false) +endfunction + +//=========================================================================== +function BlzSetSingleDoodadAnimationBJ takes string animName, integer index returns nothing + call BlzSetSingleDoodadAnimation(index, animName, false) +endfunction + +//=========================================================================== +function AddUnitAnimationPropertiesBJ takes boolean add, string animProperties, unit whichUnit returns nothing + call AddUnitAnimationProperties(whichUnit, animProperties, add) +endfunction + +//=========================================================================== +function SetDoodadColorBJ takes playercolor color, integer doodadID, real radius, location center returns nothing + call SetDoodadColor(GetLocationX(center), GetLocationY(center), radius, doodadID, false, color) +endfunction + +//=========================================================================== +function SetDoodadColorRectBJ takes playercolor color, integer doodadID, rect r returns nothing + call SetDoodadColorRect(r, doodadID, color) +endfunction + +//=========================================================================== +function BlzSetSingleDoodadColorBJ takes playercolor color, integer index returns nothing + call BlzSetSingleDoodadColor(index, color) +endfunction + +//=========================================================================== +function AllowHeroGlowOnUnitBJ takes unit whichUnit returns nothing + call AllowHeroGlowOnUnit(whichUnit) +endfunction + +//=========================================================================== +function DisallowHeroGlowOnUnitBJ takes unit whichUnit returns nothing + call DisallowHeroGlowOnUnit(whichUnit) +endfunction + +//=========================================================================== +function ToggleHeroGlowOnAllUnitsBJEnum takes nothing returns nothing + if bj_HeroGlowAllUnitsFlag then + call AllowHeroGlowOnUnit(GetEnumUnit()) + else + call DisallowHeroGlowOnUnit(GetEnumUnit()) + endif +endfunction + +//=========================================================================== +function ToggleHeroGlowOnAllUnitsBJ takes boolean allow returns nothing + local integer index + local player indexPlayer + local group g + + set bj_HeroGlowAllUnitsFlag = allow + set g = CreateGroup() + set index = 0 + loop + set indexPlayer = Player( index ) + + // Enumerate and allow/disallow glow on every unit owned by the player. + call GroupEnumUnitsOfPlayer( g, indexPlayer, null ) + call ForGroup( g, function ToggleHeroGlowOnAllUnitsBJEnum ) + call GroupClear( g ) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + call DestroyGroup(g) +endfunction + +//=========================================================================== +function AllowHeroGlowOnAllUnitsBJ takes nothing returns nothing + call ToggleHeroGlowOnAllUnitsBJ(true) +endfunction + +//=========================================================================== +function DisallowHeroGlowOnAllUnitsBJ takes nothing returns nothing + call ToggleHeroGlowOnAllUnitsBJ(false) +endfunction + +//=========================================================================== +function HeroGlowIsAllowedOnUnitBJ takes unit whichUnit returns boolean + return HeroGlowIsAllowedOnUnit(whichUnit) +endfunction + + +//============================================================================ +function CreateImageBJ takes string file, real size, location where, real zOffset, integer imageType returns image + set bj_lastCreatedImage = CreateImage(file, size, size, size, GetLocationX(where), GetLocationY(where), zOffset, 0, 0, 0, imageType) + return bj_lastCreatedImage +endfunction + +//============================================================================ +function ShowImageBJ takes boolean flag, image whichImage returns nothing + call ShowImage(whichImage, flag) +endfunction + +//============================================================================ +function SetImagePositionBJ takes image whichImage, location where, real zOffset returns nothing + call SetImagePosition(whichImage, GetLocationX(where), GetLocationY(where), zOffset) +endfunction + +//============================================================================ +function SetImageColorBJ takes image whichImage, real red, real green, real blue, real alpha returns nothing + call SetImageColor(whichImage, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-alpha)) +endfunction + +//============================================================================ +function GetLastCreatedImage takes nothing returns image + return bj_lastCreatedImage +endfunction + +//============================================================================ +function CreateUbersplatBJ takes location where, string name, real red, real green, real blue, real alpha, boolean forcePaused, boolean noBirthTime returns ubersplat + set bj_lastCreatedUbersplat = CreateUbersplat(GetLocationX(where), GetLocationY(where), name, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-alpha), forcePaused, noBirthTime) + return bj_lastCreatedUbersplat +endfunction + +//============================================================================ +function ShowUbersplatBJ takes boolean flag, ubersplat whichSplat returns nothing + call ShowUbersplat(whichSplat, flag) +endfunction + +//============================================================================ +function GetLastCreatedUbersplat takes nothing returns ubersplat + return bj_lastCreatedUbersplat +endfunction + +//============================================================================ +function GetLastCreatedMinimapIcon takes nothing returns minimapicon + return bj_lastCreatedMinimapIcon +endfunction + +//============================================================================ +function CreateMinimapIconOnUnitBJ takes unit whichUnit, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon + set bj_lastCreatedMinimapIcon = CreateMinimapIconOnUnit(whichUnit, red, green, blue, pingPath, fogVisibility) + return bj_lastCreatedMinimapIcon +endfunction + +//============================================================================ +function CreateMinimapIconAtLocBJ takes location where, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon + set bj_lastCreatedMinimapIcon = CreateMinimapIconAtLoc(where, red, green, blue, pingPath, fogVisibility) + return bj_lastCreatedMinimapIcon +endfunction + +//============================================================================ +function CreateMinimapIconBJ takes real x, real y, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon + set bj_lastCreatedMinimapIcon = CreateMinimapIcon(x, y, red, green, blue, pingPath, fogVisibility) + return bj_lastCreatedMinimapIcon +endfunction + +//============================================================================ +function CampaignMinimapIconUnitBJ takes unit whichUnit, integer style returns nothing + local integer red + local integer green + local integer blue + local string path + if ( style == bj_CAMPPINGSTYLE_PRIMARY ) then + // green + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_PRIMARY_GREEN ) then + // green + set red = 0 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_PRIMARY_RED ) then + // green + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_BONUS ) then + // yellow + set red = 255 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectiveBonus" ) + elseif ( style == bj_CAMPPINGSTYLE_TURNIN ) then + // yellow + set red = 255 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestTurnIn" ) + elseif ( style == bj_CAMPPINGSTYLE_BOSS ) then + // red + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestBoss" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_ALLY ) then + // green + set red = 0 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_NEUTRAL ) then + // white + set red = 255 + set green = 255 + set blue = 255 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_ENEMY ) then + // red + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + endif + call CreateMinimapIconOnUnitBJ( whichUnit, red, green, blue, path, FOG_OF_WAR_MASKED ) + call SetMinimapIconOrphanDestroy( bj_lastCreatedMinimapIcon, true ) +endfunction + + +//============================================================================ +function CampaignMinimapIconLocBJ takes location where, integer style returns nothing + local integer red + local integer green + local integer blue + local string path + if ( style == bj_CAMPPINGSTYLE_PRIMARY ) then + // green (different from the unit version) + set red = 0 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_PRIMARY_GREEN ) then + // green (different from the unit version) + set red = 0 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_PRIMARY_RED ) then + // green (different from the unit version) + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectivePrimary" ) + elseif ( style == bj_CAMPPINGSTYLE_BONUS ) then + // yellow + set red = 255 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestObjectiveBonus" ) + elseif ( style == bj_CAMPPINGSTYLE_TURNIN ) then + // yellow + set red = 255 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestTurnIn" ) + elseif ( style == bj_CAMPPINGSTYLE_BOSS ) then + // red + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestBoss" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_ALLY ) then + // green + set red = 0 + set green = 255 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_NEUTRAL ) then + // white + set red = 255 + set green = 255 + set blue = 255 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + elseif ( style == bj_CAMPPINGSTYLE_CONTROL_ENEMY ) then + // red + set red = 255 + set green = 0 + set blue = 0 + set path = SkinManagerGetLocalPath( "MinimapQuestControlPoint" ) + endif + call CreateMinimapIconAtLocBJ( where, red, green, blue, path, FOG_OF_WAR_MASKED ) +endfunction + + +//*************************************************************************** +//* +//* Sound Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function PlaySoundBJ takes sound soundHandle returns nothing + set bj_lastPlayedSound = soundHandle + if (soundHandle != null) then + call StartSound(soundHandle) + endif +endfunction + +//=========================================================================== +function StopSoundBJ takes sound soundHandle, boolean fadeOut returns nothing + call StopSound(soundHandle, false, fadeOut) +endfunction + +//=========================================================================== +function SetSoundVolumeBJ takes sound soundHandle, real volumePercent returns nothing + call SetSoundVolume(soundHandle, PercentToInt(volumePercent, 127)) +endfunction + +//=========================================================================== +function SetSoundOffsetBJ takes real newOffset, sound soundHandle returns nothing + call SetSoundPlayPosition(soundHandle, R2I(newOffset * 1000)) +endfunction + +//=========================================================================== +function SetSoundDistanceCutoffBJ takes sound soundHandle, real cutoff returns nothing + call SetSoundDistanceCutoff(soundHandle, cutoff) +endfunction + +//=========================================================================== +function SetSoundPitchBJ takes sound soundHandle, real pitch returns nothing + call SetSoundPitch(soundHandle, pitch) +endfunction + +//=========================================================================== +function SetSoundPositionLocBJ takes sound soundHandle, location loc, real z returns nothing + call SetSoundPosition(soundHandle, GetLocationX(loc), GetLocationY(loc), z) +endfunction + +//=========================================================================== +function AttachSoundToUnitBJ takes sound soundHandle, unit whichUnit returns nothing + call AttachSoundToUnit(soundHandle, whichUnit) +endfunction + +//=========================================================================== +function SetSoundConeAnglesBJ takes sound soundHandle, real inside, real outside, real outsideVolumePercent returns nothing + call SetSoundConeAngles(soundHandle, inside, outside, PercentToInt(outsideVolumePercent, 127)) +endfunction + +//=========================================================================== +function KillSoundWhenDoneBJ takes sound soundHandle returns nothing + call KillSoundWhenDone(soundHandle) +endfunction + +//=========================================================================== +function PlaySoundAtPointBJ takes sound soundHandle, real volumePercent, location loc, real z returns nothing + call SetSoundPositionLocBJ(soundHandle, loc, z) + call SetSoundVolumeBJ(soundHandle, volumePercent) + call PlaySoundBJ(soundHandle) +endfunction + +//=========================================================================== +function PlaySoundOnUnitBJ takes sound soundHandle, real volumePercent, unit whichUnit returns nothing + call AttachSoundToUnitBJ(soundHandle, whichUnit) + call SetSoundVolumeBJ(soundHandle, volumePercent) + call PlaySoundBJ(soundHandle) +endfunction + +//=========================================================================== +function PlaySoundFromOffsetBJ takes sound soundHandle, real volumePercent, real startingOffset returns nothing + call SetSoundVolumeBJ(soundHandle, volumePercent) + call PlaySoundBJ(soundHandle) + call SetSoundOffsetBJ(startingOffset, soundHandle) +endfunction + +//=========================================================================== +function PlayMusicBJ takes string musicFileName returns nothing + set bj_lastPlayedMusic = musicFileName + call PlayMusic(musicFileName) +endfunction + +//=========================================================================== +function PlayMusicExBJ takes string musicFileName, real startingOffset, real fadeInTime returns nothing + set bj_lastPlayedMusic = musicFileName + call PlayMusicEx(musicFileName, R2I(startingOffset * 1000), R2I(fadeInTime * 1000)) +endfunction + +//=========================================================================== +function SetMusicOffsetBJ takes real newOffset returns nothing + call SetMusicPlayPosition(R2I(newOffset * 1000)) +endfunction + +//=========================================================================== +function PlayThematicMusicBJ takes string musicName returns nothing + call PlayThematicMusic(musicName) +endfunction + +//=========================================================================== +function PlayThematicMusicExBJ takes string musicName, real startingOffset returns nothing + call PlayThematicMusicEx(musicName, R2I(startingOffset * 1000)) +endfunction + +//=========================================================================== +function SetThematicMusicOffsetBJ takes real newOffset returns nothing + call SetThematicMusicPlayPosition(R2I(newOffset * 1000)) +endfunction + +//=========================================================================== +function EndThematicMusicBJ takes nothing returns nothing + call EndThematicMusic() +endfunction + +//=========================================================================== +function StopMusicBJ takes boolean fadeOut returns nothing + call StopMusic(fadeOut) +endfunction + +//=========================================================================== +function ResumeMusicBJ takes nothing returns nothing + call ResumeMusic() +endfunction + +//=========================================================================== +function SetMusicVolumeBJ takes real volumePercent returns nothing + call SetMusicVolume(PercentToInt(volumePercent, 127)) +endfunction + +//=========================================================================== +function SetThematicMusicVolumeBJ takes real volumePercent returns nothing + call SetThematicMusicVolume(PercentToInt(volumePercent, 127)) +endfunction + +//=========================================================================== +function GetSoundDurationBJ takes sound soundHandle returns real + if (soundHandle == null) then + return bj_NOTHING_SOUND_DURATION + else + return I2R(GetSoundDuration(soundHandle)) * 0.001 + endif +endfunction + +//=========================================================================== +function GetSoundFileDurationBJ takes string musicFileName returns real + return I2R(GetSoundFileDuration(musicFileName)) * 0.001 +endfunction + +//=========================================================================== +function GetLastPlayedSound takes nothing returns sound + return bj_lastPlayedSound +endfunction + +//=========================================================================== +function GetLastPlayedMusic takes nothing returns string + return bj_lastPlayedMusic +endfunction + +//=========================================================================== +function VolumeGroupSetVolumeBJ takes volumegroup vgroup, real percent returns nothing + call VolumeGroupSetVolume(vgroup, percent * 0.01) +endfunction + +//=========================================================================== +function SetCineModeVolumeGroupsImmediateBJ takes nothing returns nothing + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITMOVEMENT, bj_CINEMODE_VOLUME_UNITMOVEMENT) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITSOUNDS, bj_CINEMODE_VOLUME_UNITSOUNDS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_COMBAT, bj_CINEMODE_VOLUME_COMBAT) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_SPELLS, bj_CINEMODE_VOLUME_SPELLS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UI, bj_CINEMODE_VOLUME_UI) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_MUSIC, bj_CINEMODE_VOLUME_MUSIC) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_AMBIENTSOUNDS, bj_CINEMODE_VOLUME_AMBIENTSOUNDS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_FIRE, bj_CINEMODE_VOLUME_FIRE) +endfunction + +//=========================================================================== +function SetCineModeVolumeGroupsBJ takes nothing returns nothing + // Delay the request if it occurs at map init. + if bj_gameStarted then + call SetCineModeVolumeGroupsImmediateBJ() + else + call TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, function SetCineModeVolumeGroupsImmediateBJ) + endif +endfunction + +//=========================================================================== +function SetSpeechVolumeGroupsImmediateBJ takes nothing returns nothing + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITMOVEMENT, bj_SPEECH_VOLUME_UNITMOVEMENT) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITSOUNDS, bj_SPEECH_VOLUME_UNITSOUNDS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_COMBAT, bj_SPEECH_VOLUME_COMBAT) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_SPELLS, bj_SPEECH_VOLUME_SPELLS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UI, bj_SPEECH_VOLUME_UI) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_MUSIC, bj_SPEECH_VOLUME_MUSIC) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_AMBIENTSOUNDS, bj_SPEECH_VOLUME_AMBIENTSOUNDS) + call VolumeGroupSetVolume(SOUND_VOLUMEGROUP_FIRE, bj_SPEECH_VOLUME_FIRE) +endfunction + +//=========================================================================== +function SetSpeechVolumeGroupsBJ takes nothing returns nothing + // Delay the request if it occurs at map init. + if bj_gameStarted then + call SetSpeechVolumeGroupsImmediateBJ() + else + call TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, function SetSpeechVolumeGroupsImmediateBJ) + endif +endfunction + +//=========================================================================== +function VolumeGroupResetImmediateBJ takes nothing returns nothing + call VolumeGroupReset() +endfunction + +//=========================================================================== +function VolumeGroupResetBJ takes nothing returns nothing + // Delay the request if it occurs at map init. + if bj_gameStarted then + call VolumeGroupResetImmediateBJ() + else + call TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, function VolumeGroupResetImmediateBJ) + endif +endfunction + +//=========================================================================== +function GetSoundIsPlayingBJ takes sound soundHandle returns boolean + return GetSoundIsLoading(soundHandle) or GetSoundIsPlaying(soundHandle) +endfunction + +//=========================================================================== +function WaitForSoundBJ takes sound soundHandle, real offset returns nothing + call TriggerWaitForSound( soundHandle, offset ) +endfunction + +//=========================================================================== +function SetMapMusicIndexedBJ takes string musicName, integer index returns nothing + call SetMapMusic(musicName, false, index) +endfunction + +//=========================================================================== +function SetMapMusicRandomBJ takes string musicName returns nothing + call SetMapMusic(musicName, true, 0) +endfunction + +//=========================================================================== +function ClearMapMusicBJ takes nothing returns nothing + call ClearMapMusic() +endfunction + +//=========================================================================== +function SetStackedSoundBJ takes boolean add, sound soundHandle, rect r returns nothing + local real width = GetRectMaxX(r) - GetRectMinX(r) + local real height = GetRectMaxY(r) - GetRectMinY(r) + + call SetSoundPosition(soundHandle, GetRectCenterX(r), GetRectCenterY(r), 0) + if add then + call RegisterStackedSound(soundHandle, true, width, height) + else + call UnregisterStackedSound(soundHandle, true, width, height) + endif +endfunction + +//=========================================================================== +function StartSoundForPlayerBJ takes player whichPlayer, sound soundHandle returns nothing + if (whichPlayer == GetLocalPlayer()) then + call StartSound(soundHandle) + endif +endfunction + +//=========================================================================== +function VolumeGroupSetVolumeForPlayerBJ takes player whichPlayer, volumegroup vgroup, real scale returns nothing + if (GetLocalPlayer() == whichPlayer) then + call VolumeGroupSetVolume(vgroup, scale) + endif +endfunction + +//=========================================================================== +function EnableDawnDusk takes boolean flag returns nothing + set bj_useDawnDuskSounds = flag +endfunction + +//=========================================================================== +function IsDawnDuskEnabled takes nothing returns boolean + return bj_useDawnDuskSounds +endfunction + + + +//*************************************************************************** +//* +//* Day/Night ambient sounds +//* +//*************************************************************************** + +//=========================================================================== +function SetAmbientDaySound takes string inLabel returns nothing + local real ToD + + // Stop old sound, if necessary + if (bj_dayAmbientSound != null) then + call StopSound(bj_dayAmbientSound, true, true) + endif + + // Create new sound + set bj_dayAmbientSound = CreateMIDISound(inLabel, 20, 20) + + // Start the sound if necessary, based on current time + set ToD = GetTimeOfDay() + if (ToD >= bj_TOD_DAWN and ToD < bj_TOD_DUSK) then + call StartSound(bj_dayAmbientSound) + endif +endfunction + +//=========================================================================== +function SetAmbientNightSound takes string inLabel returns nothing + local real ToD + + // Stop old sound, if necessary + if (bj_nightAmbientSound != null) then + call StopSound(bj_nightAmbientSound, true, true) + endif + + // Create new sound + set bj_nightAmbientSound = CreateMIDISound(inLabel, 20, 20) + + // Start the sound if necessary, based on current time + set ToD = GetTimeOfDay() + if (ToD < bj_TOD_DAWN or ToD >= bj_TOD_DUSK) then + call StartSound(bj_nightAmbientSound) + endif +endfunction + + + +//*************************************************************************** +//* +//* Special Effect Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function AddSpecialEffectLocBJ takes location where, string modelName returns effect + set bj_lastCreatedEffect = AddSpecialEffectLoc(modelName, where) + return bj_lastCreatedEffect +endfunction + +//=========================================================================== +function AddSpecialEffectTargetUnitBJ takes string attachPointName, widget targetWidget, string modelName returns effect + set bj_lastCreatedEffect = AddSpecialEffectTarget(modelName, targetWidget, attachPointName) + return bj_lastCreatedEffect +endfunction + +//=========================================================================== +// Two distinct trigger actions can't share the same function name, so this +// dummy function simply mimics the behavior of an existing call. +// +// Commented out - Destructibles have no attachment points. +// +//function AddSpecialEffectTargetDestructableBJ takes string attachPointName, widget targetWidget, string modelName returns effect +// return AddSpecialEffectTargetUnitBJ(attachPointName, targetWidget, modelName) +//endfunction + +//=========================================================================== +// Two distinct trigger actions can't share the same function name, so this +// dummy function simply mimics the behavior of an existing call. +// +// Commented out - Items have no attachment points. +// +//function AddSpecialEffectTargetItemBJ takes string attachPointName, widget targetWidget, string modelName returns effect +// return AddSpecialEffectTargetUnitBJ(attachPointName, targetWidget, modelName) +//endfunction + +//=========================================================================== +function DestroyEffectBJ takes effect whichEffect returns nothing + call DestroyEffect(whichEffect) +endfunction + +//=========================================================================== +function GetLastCreatedEffectBJ takes nothing returns effect + return bj_lastCreatedEffect +endfunction + +//=========================================================================== +// Note: this function should be used in conjunction with the one below, which is the only one that is really exposed in GUI +function DestroyEffectAsyncBJ takes nothing returns nothing + local effect localEffect = bj_destroyEffectAsyncEffect + local real localTime = bj_destroyEffectAsyncTime + + call TriggerSleepAction(localTime) + call DestroyEffect(localEffect) +endfunction + +function DestroyEffectAfterTimeBJ takes effect whichEffect, real time returns nothing + // Save arguments to globals + set bj_destroyEffectAsyncEffect = whichEffect + set bj_destroyEffectAsyncTime = time + + // Externalize to an async thread + call ExecuteFunc("DestroyEffectAsyncBJ") +endfunction + + +//*************************************************************************** +//* +//* Command Button Effect Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function CreateCommandButtonEffectBJ takes integer abilityId, string order returns commandbuttoneffect + set bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(abilityId, order) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function CreateTrainCommandButtonEffectBJ takes integer unitId returns commandbuttoneffect + set bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect('Aque', UnitId2String(unitId)) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function CreateUpgradeCommandButtonEffectBJ takes integer techId returns commandbuttoneffect + set bj_lastCreatedCommandButtonEffect = CreateUpgradeCommandButtonEffect(techId) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function CreateCommonCommandButtonEffectBJ takes string order returns commandbuttoneffect + set bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(0, order) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function CreateLearnCommandButtonEffectBJ takes integer abilityId returns commandbuttoneffect + set bj_lastCreatedCommandButtonEffect = CreateLearnCommandButtonEffect(abilityId) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function CreateBuildCommandButtonEffectBJ takes integer unitId returns commandbuttoneffect + local race r = GetPlayerRace(GetLocalPlayer()) + local integer abilityId + if (r == RACE_HUMAN) then + set abilityId = 'AHbu' + elseif (r == RACE_ORC) then + set abilityId = 'AObu' + elseif (r == RACE_UNDEAD) then + set abilityId = 'AUbu' + elseif (r == RACE_NIGHTELF) then + set abilityId = 'AEbu' + else + set abilityId = 'ANbu' + endif + set bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(abilityId, UnitId2String(unitId)) + return bj_lastCreatedCommandButtonEffect +endfunction + +//=========================================================================== +function GetLastCreatedCommandButtonEffectBJ takes nothing returns commandbuttoneffect + return bj_lastCreatedCommandButtonEffect +endfunction + + +//*************************************************************************** +//* +//* Hero and Item Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function GetItemLoc takes item whichItem returns location + return Location(GetItemX(whichItem), GetItemY(whichItem)) +endfunction + +//=========================================================================== +function GetItemLifeBJ takes widget whichWidget returns real + return GetWidgetLife(whichWidget) +endfunction + +//=========================================================================== +function SetItemLifeBJ takes widget whichWidget, real life returns nothing + call SetWidgetLife(whichWidget, life) +endfunction + +//=========================================================================== +function AddHeroXPSwapped takes integer xpToAdd, unit whichHero, boolean showEyeCandy returns nothing + call AddHeroXP(whichHero, xpToAdd, showEyeCandy) +endfunction + +//=========================================================================== +function SetHeroLevelBJ takes unit whichHero, integer newLevel, boolean showEyeCandy returns nothing + local integer oldLevel = GetHeroLevel(whichHero) + + if (newLevel > oldLevel) then + call SetHeroLevel(whichHero, newLevel, showEyeCandy) + elseif (newLevel < oldLevel) then + call UnitStripHeroLevel(whichHero, oldLevel - newLevel) + else + // No change in level - ignore the request. + endif +endfunction + +//=========================================================================== +function DecUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer + return DecUnitAbilityLevel(whichUnit, abilcode) +endfunction + +//=========================================================================== +function IncUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer + return IncUnitAbilityLevel(whichUnit, abilcode) +endfunction + +//=========================================================================== +function SetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit, integer level returns integer + return SetUnitAbilityLevel(whichUnit, abilcode, level) +endfunction + +//=========================================================================== +function GetUnitAbilityLevelSwapped takes integer abilcode, unit whichUnit returns integer + return GetUnitAbilityLevel(whichUnit, abilcode) +endfunction + +//=========================================================================== +function UnitHasBuffBJ takes unit whichUnit, integer buffcode returns boolean + return (GetUnitAbilityLevel(whichUnit, buffcode) > 0) +endfunction + +//=========================================================================== +function UnitRemoveBuffBJ takes integer buffcode, unit whichUnit returns boolean + return UnitRemoveAbility(whichUnit, buffcode) +endfunction + +//=========================================================================== +function UnitAddItemSwapped takes item whichItem, unit whichHero returns boolean + return UnitAddItem(whichHero, whichItem) +endfunction + +//=========================================================================== +function UnitAddItemByIdSwapped takes integer itemId, unit whichHero returns item + // Create the item at the hero's feet first, and then give it to him. + // This is to ensure that the item will be left at the hero's feet if + // his inventory is full. + set bj_lastCreatedItem = CreateItem(itemId, GetUnitX(whichHero), GetUnitY(whichHero)) + call UnitAddItem(whichHero, bj_lastCreatedItem) + return bj_lastCreatedItem +endfunction + +//=========================================================================== +function UnitRemoveItemSwapped takes item whichItem, unit whichHero returns nothing + set bj_lastRemovedItem = whichItem + call UnitRemoveItem(whichHero, whichItem) +endfunction + +//=========================================================================== +function UnitEquipItemSwapped takes item whichItem, unit whichHero returns boolean + local boolean success = UnitEquipItem(whichHero, whichItem) + if (success) then + set bj_lastEquippedItem = whichItem + endif + + return success +endfunction + +//=========================================================================== +function UnitEquipItemByIdSwapped takes integer itemId, unit whichHero returns item + // Create the item at the hero's feet first, and then give it to him. + // This is to ensure that the item will be left at the hero's feet if + // his inventory is full. + local boolean success + + set bj_lastCreatedItem = CreateItem(itemId, GetUnitX(whichHero), GetUnitY(whichHero)) + set success = UnitEquipItem(whichHero, bj_lastCreatedItem) + + if (success) then + set bj_lastEquippedItem = bj_lastCreatedItem + endif + + return bj_lastCreatedItem +endfunction + +//=========================================================================== +// Translates 0-based slot indices to 1-based slot indices. +// +function UnitRemoveItemFromSlotSwapped takes integer itemSlot, unit whichHero returns item + set bj_lastRemovedItem = UnitRemoveItemFromSlot(whichHero, itemSlot-1) + return bj_lastRemovedItem +endfunction + +function UnitUnequipItemSwapped takes unit whichHero, item whichItem returns nothing + set bj_lastUnequippedItem = whichItem + call UnitUnequipItem(whichHero, whichItem) +endfunction + +function UnitUnequipItemFromSlotSwapped takes unit whichHero, loadoutslot slot returns item + set bj_lastUnequippedItem = UnitUnequipItemFromSlot(whichHero, slot) + return bj_lastUnequippedItem +endfunction + +//=========================================================================== +function CreateItemLoc takes integer itemId, location loc returns item + set bj_lastCreatedItem = CreateItem(itemId, GetLocationX(loc), GetLocationY(loc)) + return bj_lastCreatedItem +endfunction + +//=========================================================================== +function GetLastCreatedItem takes nothing returns item + return bj_lastCreatedItem +endfunction + +//=========================================================================== +function GetLastRemovedItem takes nothing returns item + return bj_lastRemovedItem +endfunction + +//=========================================================================== +function GetLastEquippedItem takes nothing returns item + return bj_lastEquippedItem +endfunction + +//=========================================================================== +function GetLastUnequippedItem takes nothing returns item + return bj_lastUnequippedItem +endfunction + +//=========================================================================== +function SetItemPositionLoc takes item whichItem, location loc returns nothing + call SetItemPosition(whichItem, GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +function GetLearnedSkillBJ takes nothing returns integer + return GetLearnedSkill() +endfunction + +//=========================================================================== +function SuspendHeroXPBJ takes boolean flag, unit whichHero returns nothing + call SuspendHeroXP(whichHero, not flag) +endfunction + +//=========================================================================== +function SetPlayerHandicapDamageBJ takes player whichPlayer, real handicapPercent returns nothing + call SetPlayerHandicapDamage(whichPlayer, handicapPercent * 0.01) +endfunction + +//=========================================================================== +function GetPlayerHandicapDamageBJ takes player whichPlayer returns real + return GetPlayerHandicapDamage(whichPlayer) * 100 +endfunction + +//=========================================================================== +function SetPlayerHandicapReviveTimeBJ takes player whichPlayer, real handicapPercent returns nothing + call SetPlayerHandicapReviveTime(whichPlayer, handicapPercent * 0.01) +endfunction + +//=========================================================================== +function GetPlayerHandicapReviveTimeBJ takes player whichPlayer returns real + return GetPlayerHandicapReviveTime(whichPlayer) * 100 +endfunction + +//=========================================================================== +function SetPlayerHandicapXPBJ takes player whichPlayer, real handicapPercent returns nothing + call SetPlayerHandicapXP(whichPlayer, handicapPercent * 0.01) +endfunction + +//=========================================================================== +function GetPlayerHandicapXPBJ takes player whichPlayer returns real + return GetPlayerHandicapXP(whichPlayer) * 100 +endfunction + +//=========================================================================== +function SetPlayerHandicapBJ takes player whichPlayer, real handicapPercent returns nothing + call SetPlayerHandicap(whichPlayer, handicapPercent * 0.01) +endfunction + +//=========================================================================== +function GetPlayerHandicapBJ takes player whichPlayer returns real + return GetPlayerHandicap(whichPlayer) * 100 +endfunction + +//=========================================================================== +function GetHeroStatBJ takes integer whichStat, unit whichHero, boolean includeBonuses returns integer + if (whichStat == bj_HEROSTAT_STR) then + return GetHeroStr(whichHero, includeBonuses) + elseif (whichStat == bj_HEROSTAT_AGI) then + return GetHeroAgi(whichHero, includeBonuses) + elseif (whichStat == bj_HEROSTAT_INT) then + return GetHeroInt(whichHero, includeBonuses) + else + // Unrecognized hero stat - return 0 + return 0 + endif +endfunction + +//=========================================================================== +function SetHeroStat takes unit whichHero, integer whichStat, integer value returns nothing + // Ignore requests for negative hero stats. + if (value <= 0) then + return + endif + + if (whichStat == bj_HEROSTAT_STR) then + call SetHeroStr(whichHero, value, true) + elseif (whichStat == bj_HEROSTAT_AGI) then + call SetHeroAgi(whichHero, value, true) + elseif (whichStat == bj_HEROSTAT_INT) then + call SetHeroInt(whichHero, value, true) + else + // Unrecognized hero stat - ignore the request. + endif +endfunction + +//=========================================================================== +function ModifyHeroStat takes integer whichStat, unit whichHero, integer modifyMethod, integer value returns nothing + if (modifyMethod == bj_MODIFYMETHOD_ADD) then + call SetHeroStat(whichHero, whichStat, GetHeroStatBJ(whichStat, whichHero, false) + value) + elseif (modifyMethod == bj_MODIFYMETHOD_SUB) then + call SetHeroStat(whichHero, whichStat, GetHeroStatBJ(whichStat, whichHero, false) - value) + elseif (modifyMethod == bj_MODIFYMETHOD_SET) then + call SetHeroStat(whichHero, whichStat, value) + else + // Unrecognized modification method - ignore the request. + endif +endfunction + +//=========================================================================== +function ModifyHeroSkillPoints takes unit whichHero, integer modifyMethod, integer value returns boolean + if (modifyMethod == bj_MODIFYMETHOD_ADD) then + return UnitModifySkillPoints(whichHero, value) + elseif (modifyMethod == bj_MODIFYMETHOD_SUB) then + return UnitModifySkillPoints(whichHero, -value) + elseif (modifyMethod == bj_MODIFYMETHOD_SET) then + return UnitModifySkillPoints(whichHero, value - GetHeroSkillPoints(whichHero)) + else + // Unrecognized modification method - ignore the request and return failure. + return false + endif +endfunction + +//=========================================================================== +function UnitDropItemPointBJ takes unit whichUnit, item whichItem, real x, real y returns boolean + return UnitDropItemPoint(whichUnit, whichItem, x, y) +endfunction + +//=========================================================================== +function UnitDropItemPointLoc takes unit whichUnit, item whichItem, location loc returns boolean + return UnitDropItemPoint(whichUnit, whichItem, GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +function UnitDropItemSlotBJ takes unit whichUnit, item whichItem, integer slot returns boolean + return UnitDropItemSlot(whichUnit, whichItem, slot-1) +endfunction + +//=========================================================================== +function UnitDropItemTargetBJ takes unit whichUnit, item whichItem, widget target returns boolean + return UnitDropItemTarget(whichUnit, whichItem, target) +endfunction + +//=========================================================================== +// Two distinct trigger actions can't share the same function name, so this +// dummy function simply mimics the behavior of an existing call. +// +function UnitUseItemDestructable takes unit whichUnit, item whichItem, widget target returns boolean + return UnitUseItemTarget(whichUnit, whichItem, target) +endfunction + +//=========================================================================== +function UnitUseItemPointLoc takes unit whichUnit, item whichItem, location loc returns boolean + return UnitUseItemPoint(whichUnit, whichItem, GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +// Translates 0-based slot indices to 1-based slot indices. +// +function UnitItemInSlotBJ takes unit whichUnit, integer itemSlot returns item + return UnitItemInSlot(whichUnit, itemSlot-1) +endfunction + +function UnitItemInBagSlotBJ takes unit whichUnit, integer itemSlot returns item + return UnitItemInBagSlot(whichUnit, itemSlot-1) +endfunction + +function UnitItemInEquipmentSlotBJ takes unit whichUnit, loadoutslot slot returns item + return UnitItemInEquipmentSlot(whichUnit, slot) +endfunction + +//=========================================================================== +// Translates 0-based slot indices to 1-based slot indices. +// +function GetInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer + local integer index + local item indexItem + + set index = 0 + loop + set indexItem = UnitItemInSlot(whichUnit, index) + if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then + return index + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_INVENTORY + endloop + return 0 +endfunction + +//=========================================================================== +function GetItemOfTypeFromUnitBJ takes unit whichUnit, integer itemId returns item + local integer index = GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) + + if (index == 0) then + return null + else + return UnitItemInSlot(whichUnit, index - 1) + endif +endfunction + +//=========================================================================== +function UnitHasItemOfTypeBJ takes unit whichUnit, integer itemId returns boolean + return GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) > 0 +endfunction + +//=========================================================================== +function GetInventoryBagIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer + local integer index + local item indexItem + + set index = 0 + loop + set indexItem = UnitItemInBagSlot(whichUnit, index) + if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then + return index + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EXTENDED_INVENTORY + endloop + return 0 +endfunction + +//=========================================================================== +function GetItemOfTypeFromUnitBagBJ takes unit whichUnit, integer itemId returns item + local integer index = GetInventoryBagIndexOfItemTypeBJ(whichUnit, itemId) + + if (index == 0) then + return null + else + return UnitItemInBagSlot(whichUnit, index - 1) + endif +endfunction + +//=========================================================================== +function UnitHasItemOfTypeBaggedBJ takes unit whichUnit, integer itemId returns boolean + return GetInventoryBagIndexOfItemTypeBJ(whichUnit, itemId) > 0 +endfunction + +//=========================================================================== +function GetInventoryBagIndexOfEquipmentTypeBJ takes unit whichUnit, equipmentType whichEquipmentType returns integer + local integer index + local item indexItem + + set index = 0 + loop + set indexItem = UnitItemInBagSlot(whichUnit, index) + if (indexItem != null) and (GetItemEquipmentType(indexItem) == whichEquipmentType) then + return index + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EXTENDED_INVENTORY + endloop + return 0 +endfunction + +//=========================================================================== +function GetItemOfEquipmentTypeFromUnitBagBJ takes unit whichUnit, equipmentType whichEquipmentType returns item + local integer index = GetInventoryBagIndexOfEquipmentTypeBJ(whichUnit, whichEquipmentType) + + if (index == 0) then + return null + else + return UnitItemInBagSlot(whichUnit, index - 1) + endif +endfunction + +//=========================================================================== +function GetEquipmentInventoryIndexOfItemTypeBJ takes unit whichUnit, integer itemId returns integer + local integer index + local item indexItem + + set index = 0 + loop + set indexItem = UnitItemInEquipmentSlot(whichUnit, ConvertLoadoutSlot(index)) + if (indexItem != null) and (GetItemTypeId(indexItem) == itemId) then + return index + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EQUIPMENT_INVENTORY + endloop + return 0 +endfunction + +//=========================================================================== +function GetEquipmentInventoryIndexOfEquipmentTypeBJ takes unit whichUnit, equipmentType whichEquipmentType returns integer + local integer index + local item indexItem + + set index = 0 + loop + set indexItem = UnitItemInEquipmentSlot(whichUnit, ConvertLoadoutSlot(index)) + if (indexItem != null) and (GetItemEquipmentType(indexItem) == whichEquipmentType) then + return index + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EQUIPMENT_INVENTORY + endloop + return 0 +endfunction + +//=========================================================================== +function GetItemEquippedByHeroOfTypeBJ takes unit whichUnit, integer itemId returns item + local integer index = GetEquipmentInventoryIndexOfItemTypeBJ(whichUnit, itemId) + + if (index == 0) then + return null + else + return UnitItemInEquipmentSlot(whichUnit, ConvertLoadoutSlot(index - 1)) + endif +endfunction + +//=========================================================================== +function GetItemEquippedByHeroOfEquipmentTypeBJ takes unit whichUnit, equipmentType whichEquipmentType returns item + local integer index = GetEquipmentInventoryIndexOfEquipmentTypeBJ(whichUnit, whichEquipmentType) + + if (index == 0) then + return null + else + return UnitItemInEquipmentSlot(whichUnit, ConvertLoadoutSlot(index - 1)) + endif +endfunction + +//=========================================================================== +function UnitHasItemOfTypeEquippedBJ takes unit whichUnit, integer itemId returns boolean + return GetEquipmentInventoryIndexOfItemTypeBJ(whichUnit, itemId) > 0 +endfunction + +//=========================================================================== +function UnitInventoryCount takes unit whichUnit returns integer + local integer index = 0 + local integer count = 0 + + loop + if (UnitItemInSlot(whichUnit, index) != null) then + set count = count + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_INVENTORY + endloop + + return count +endfunction + +//=========================================================================== +function UnitInventorySizeBJ takes unit whichUnit returns integer + return UnitInventorySize(whichUnit) +endfunction + +//=========================================================================== +function UnitExtendedInventoryCount takes unit whichUnit returns integer + local integer index = 0 + local integer count = 0 + + loop + if (UnitItemInBagSlot(whichUnit, index) != null) then + set count = count + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EXTENDED_INVENTORY + endloop + + return count +endfunction + +//=========================================================================== +function UnitExtendedInventorySizeBJ takes unit whichUnit returns integer + return UnitExtendedInventorySize(whichUnit) +endfunction + +//=========================================================================== +function UnitEquipmentCount takes unit whichUnit returns integer + local integer index = 0 + local integer count = 0 + + loop + if (UnitItemInEquipmentSlot(whichUnit, ConvertLoadoutSlot(index)) != null) then + set count = count + 1 + endif + + set index = index + 1 + exitwhen index >= bj_MAX_EQUIPMENT_INVENTORY + endloop + + return count +endfunction + +//=========================================================================== +function SetItemInvulnerableBJ takes item whichItem, boolean flag returns nothing + call SetItemInvulnerable(whichItem, flag) +endfunction + +//=========================================================================== +function SetItemDropOnDeathBJ takes item whichItem, boolean flag returns nothing + call SetItemDropOnDeath(whichItem, flag) +endfunction + +//=========================================================================== +function SetItemDroppableBJ takes item whichItem, boolean flag returns nothing + call SetItemDroppable(whichItem, flag) +endfunction + +//=========================================================================== +function SetItemPlayerBJ takes item whichItem, player whichPlayer, boolean changeColor returns nothing + call SetItemPlayer(whichItem, whichPlayer, changeColor) +endfunction + +//=========================================================================== +function SetItemVisibleBJ takes boolean show, item whichItem returns nothing + call SetItemVisible(whichItem, show) +endfunction + +//=========================================================================== +function IsItemHiddenBJ takes item whichItem returns boolean + return not IsItemVisible(whichItem) +endfunction + +//=========================================================================== +function ChooseRandomItemBJ takes integer level returns integer + return ChooseRandomItem(level) +endfunction + +//=========================================================================== +function ChooseRandomItemExBJ takes integer level, itemtype whichType returns integer + return ChooseRandomItemEx(whichType, level) +endfunction + +//=========================================================================== +function ChooseRandomItemExWithFilterBJ takes integer level, itemtype whichType, equipmentType whichEquipmentType, itemTag whichTag returns integer + return ChooseRandomItemExWithFilter(whichType, level, whichEquipmentType, whichTag) +endfunction + +//=========================================================================== +function ChooseRandomNPBuildingBJ takes nothing returns integer + return ChooseRandomNPBuilding() +endfunction + +//=========================================================================== +function ChooseRandomCreepBJ takes integer level returns integer + return ChooseRandomCreep(level) +endfunction + +//=========================================================================== +function EnumItemsInRectBJ takes rect r, code actionFunc returns nothing + call EnumItemsInRect(r, null, actionFunc) +endfunction + +//=========================================================================== +// See GroupPickRandomUnitEnum for the details of this algorithm. +// +function RandomItemInRectBJEnum takes nothing returns nothing + set bj_itemRandomConsidered = bj_itemRandomConsidered + 1 + if (GetRandomInt(1, bj_itemRandomConsidered) == 1) then + set bj_itemRandomCurrentPick = GetEnumItem() + endif +endfunction + +//=========================================================================== +// Picks a random item from within a rect, matching a condition +// +function RandomItemInRectBJ takes rect r, boolexpr filter returns item + set bj_itemRandomConsidered = 0 + set bj_itemRandomCurrentPick = null + call EnumItemsInRect(r, filter, function RandomItemInRectBJEnum) + call DestroyBoolExpr(filter) + return bj_itemRandomCurrentPick +endfunction + +//=========================================================================== +// Picks a random item from within a rect +// +function RandomItemInRectSimpleBJ takes rect r returns item + return RandomItemInRectBJ(r, null) +endfunction + +//=========================================================================== +function CheckItemStatus takes item whichItem, integer status returns boolean + if (status == bj_ITEM_STATUS_HIDDEN) then + return not IsItemVisible(whichItem) + elseif (status == bj_ITEM_STATUS_OWNED) then + return IsItemOwned(whichItem) + elseif (status == bj_ITEM_STATUS_INVULNERABLE) then + return IsItemInvulnerable(whichItem) + elseif (status == bj_ITEM_STATUS_POWERUP) then + return IsItemPowerup(whichItem) + elseif (status == bj_ITEM_STATUS_SELLABLE) then + return IsItemSellable(whichItem) + elseif (status == bj_ITEM_STATUS_PAWNABLE) then + return IsItemPawnable(whichItem) + else + // Unrecognized status - return false + return false + endif +endfunction + +//=========================================================================== +function CheckItemcodeStatus takes integer itemId, integer status returns boolean + if (status == bj_ITEMCODE_STATUS_POWERUP) then + return IsItemIdPowerup(itemId) + elseif (status == bj_ITEMCODE_STATUS_SELLABLE) then + return IsItemIdSellable(itemId) + elseif (status == bj_ITEMCODE_STATUS_PAWNABLE) then + return IsItemIdPawnable(itemId) + else + // Unrecognized status - return false + return false + endif +endfunction + + + +//*************************************************************************** +//* +//* Unit Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function UnitId2OrderIdBJ takes integer unitId returns integer + return unitId +endfunction + +//=========================================================================== +function String2UnitIdBJ takes string unitIdString returns integer + return UnitId(unitIdString) +endfunction + +//=========================================================================== +function UnitId2StringBJ takes integer unitId returns string + local string unitString = UnitId2String(unitId) + + if (unitString != null) then + return unitString + endif + + // The unitId was not recognized - return an empty string. + return "" +endfunction + +//=========================================================================== +function String2OrderIdBJ takes string orderIdString returns integer + local integer orderId + + // Check to see if it's a generic order. + set orderId = OrderId(orderIdString) + if (orderId != 0) then + return orderId + endif + + // Check to see if it's a (train) unit order. + set orderId = UnitId(orderIdString) + if (orderId != 0) then + return orderId + endif + + // Unrecognized - return 0 + return 0 +endfunction + +//=========================================================================== +function OrderId2StringBJ takes integer orderId returns string + local string orderString + + // Check to see if it's a generic order. + set orderString = OrderId2String(orderId) + if (orderString != null) then + return orderString + endif + + // Check to see if it's a (train) unit order. + set orderString = UnitId2String(orderId) + if (orderString != null) then + return orderString + endif + + // Unrecognized - return an empty string. + return "" +endfunction + +//=========================================================================== +function GetIssuedOrderIdBJ takes nothing returns integer + return GetIssuedOrderId() +endfunction + +//=========================================================================== +function GetKillingUnitBJ takes nothing returns unit + return GetKillingUnit() +endfunction + +//=========================================================================== +function CreateUnitAtLocSaveLast takes player id, integer unitid, location loc, real face returns unit + if (unitid == 'ugol') then + set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face) + else + set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face) + endif + + return bj_lastCreatedUnit +endfunction + +//=========================================================================== +function GetLastCreatedUnit takes nothing returns unit + return bj_lastCreatedUnit +endfunction + +//=========================================================================== +function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group + call GroupClear(bj_lastCreatedGroup) + loop + set count = count - 1 + exitwhen count < 0 + call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face) + call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit) + endloop + return bj_lastCreatedGroup +endfunction + +//=========================================================================== +function CreateNUnitsAtLocFacingLocBJ takes integer count, integer unitId, player whichPlayer, location loc, location lookAt returns group + return CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, AngleBetweenPoints(loc, lookAt)) +endfunction + +//=========================================================================== +function GetLastCreatedGroupEnum takes nothing returns nothing + call GroupAddUnit(bj_groupLastCreatedDest, GetEnumUnit()) +endfunction + +//=========================================================================== +function GetLastCreatedGroup takes nothing returns group + set bj_groupLastCreatedDest = CreateGroup() + call ForGroup(bj_lastCreatedGroup, function GetLastCreatedGroupEnum) + return bj_groupLastCreatedDest +endfunction + +//=========================================================================== +function CreateCorpseLocBJ takes integer unitid, player whichPlayer, location loc returns unit + set bj_lastCreatedUnit = CreateCorpse(whichPlayer, unitid, GetLocationX(loc), GetLocationY(loc), GetRandomReal(0, 360)) + return bj_lastCreatedUnit +endfunction + +//=========================================================================== +function UnitSuspendDecayBJ takes boolean suspend, unit whichUnit returns nothing + call UnitSuspendDecay(whichUnit, suspend) +endfunction + +//=========================================================================== +function DelayedSuspendDecayStopAnimEnum takes nothing returns nothing + local unit enumUnit = GetEnumUnit() + + if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then + call SetUnitTimeScale(enumUnit, 0.0001) + endif +endfunction + +//=========================================================================== +function DelayedSuspendDecayBoneEnum takes nothing returns nothing + local unit enumUnit = GetEnumUnit() + + if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then + call UnitSuspendDecay(enumUnit, true) + call SetUnitTimeScale(enumUnit, 0.0001) + endif +endfunction + +//=========================================================================== +// Game code explicitly sets the animation back to "decay bone" after the +// initial corpse fades away, so we reset it now. It's best not to show +// off corpses thus created until after this grace period has passed. +// +function DelayedSuspendDecayFleshEnum takes nothing returns nothing + local unit enumUnit = GetEnumUnit() + + if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then + call UnitSuspendDecay(enumUnit, true) + call SetUnitTimeScale(enumUnit, 10.0) + call SetUnitAnimation(enumUnit, "decay flesh") + endif +endfunction + +//=========================================================================== +// Waits a short period of time to ensure that the corpse is decaying, and +// then suspend the animation and corpse decay. +// +function DelayedSuspendDecay takes nothing returns nothing + local group boneGroup + local group fleshGroup + + // Switch the global unit groups over to local variables and recreate + // the global versions, so that this function can handle overlapping + // calls. + set boneGroup = bj_suspendDecayBoneGroup + set fleshGroup = bj_suspendDecayFleshGroup + set bj_suspendDecayBoneGroup = CreateGroup() + set bj_suspendDecayFleshGroup = CreateGroup() + + call ForGroup(fleshGroup, function DelayedSuspendDecayStopAnimEnum) + call ForGroup(boneGroup, function DelayedSuspendDecayStopAnimEnum) + + call TriggerSleepAction(bj_CORPSE_MAX_DEATH_TIME) + call ForGroup(fleshGroup, function DelayedSuspendDecayFleshEnum) + call ForGroup(boneGroup, function DelayedSuspendDecayBoneEnum) + + call TriggerSleepAction(0.05) + call ForGroup(fleshGroup, function DelayedSuspendDecayStopAnimEnum) + + call DestroyGroup(boneGroup) + call DestroyGroup(fleshGroup) +endfunction + +//=========================================================================== +function DelayedSuspendDecayCreate takes nothing returns nothing + set bj_delayedSuspendDecayTrig = CreateTrigger() + call TriggerRegisterTimerExpireEvent(bj_delayedSuspendDecayTrig, bj_delayedSuspendDecayTimer) + call TriggerAddAction(bj_delayedSuspendDecayTrig, function DelayedSuspendDecay) +endfunction + +//=========================================================================== +function CreatePermanentCorpseLocBJ takes integer style, integer unitid, player whichPlayer, location loc, real facing returns unit + set bj_lastCreatedUnit = CreateCorpse(whichPlayer, unitid, GetLocationX(loc), GetLocationY(loc), facing) + call SetUnitBlendTime(bj_lastCreatedUnit, 0) + + if (style == bj_CORPSETYPE_FLESH) then + call SetUnitAnimation(bj_lastCreatedUnit, "decay flesh") + call GroupAddUnit(bj_suspendDecayFleshGroup, bj_lastCreatedUnit) + elseif (style == bj_CORPSETYPE_BONE) then + call SetUnitAnimation(bj_lastCreatedUnit, "decay bone") + call GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit) + else + // Unknown decay style - treat as skeletal. + call SetUnitAnimation(bj_lastCreatedUnit, "decay bone") + call GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit) + endif + + call TimerStart(bj_delayedSuspendDecayTimer, 0.05, false, null) + return bj_lastCreatedUnit +endfunction + +//=========================================================================== +function GetUnitStateSwap takes unitstate whichState, unit whichUnit returns real + return GetUnitState(whichUnit, whichState) +endfunction + +//=========================================================================== +function GetUnitStatePercent takes unit whichUnit, unitstate whichState, unitstate whichMaxState returns real + local real value = GetUnitState(whichUnit, whichState) + local real maxValue = GetUnitState(whichUnit, whichMaxState) + + // Return 0 for null units. + if (whichUnit == null) or (maxValue == 0) then + return 0.0 + endif + + return value / maxValue * 100.0 +endfunction + +//=========================================================================== +function GetUnitLifePercent takes unit whichUnit returns real + return GetUnitStatePercent(whichUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE) +endfunction + +//=========================================================================== +function GetUnitManaPercent takes unit whichUnit returns real + return GetUnitStatePercent(whichUnit, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA) +endfunction + +//=========================================================================== +function SelectUnitSingle takes unit whichUnit returns nothing + call ClearSelection() + call SelectUnit(whichUnit, true) +endfunction + +//=========================================================================== +function SelectGroupBJEnum takes nothing returns nothing + call SelectUnit( GetEnumUnit(), true ) +endfunction + +//=========================================================================== +function SelectGroupBJ takes group g returns nothing + call ClearSelection() + call ForGroup( g, function SelectGroupBJEnum ) +endfunction + +//=========================================================================== +function SelectUnitAdd takes unit whichUnit returns nothing + call SelectUnit(whichUnit, true) +endfunction + +//=========================================================================== +function SelectUnitRemove takes unit whichUnit returns nothing + call SelectUnit(whichUnit, false) +endfunction + +//=========================================================================== +function ClearSelectionForPlayer takes player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ClearSelection() + endif +endfunction + +//=========================================================================== +function SelectUnitForPlayerSingle takes unit whichUnit, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ClearSelection() + call SelectUnit(whichUnit, true) + endif +endfunction + +//=========================================================================== +function SelectGroupForPlayerBJ takes group g, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ClearSelection() + call ForGroup( g, function SelectGroupBJEnum ) + endif +endfunction + +//=========================================================================== +function SelectUnitAddForPlayer takes unit whichUnit, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SelectUnit(whichUnit, true) + endif +endfunction + +//=========================================================================== +function SelectUnitRemoveForPlayer takes unit whichUnit, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SelectUnit(whichUnit, false) + endif +endfunction + +//=========================================================================== +function SetUnitLifeBJ takes unit whichUnit, real newValue returns nothing + call SetUnitState(whichUnit, UNIT_STATE_LIFE, RMaxBJ(0,newValue)) +endfunction + +//=========================================================================== +function SetUnitManaBJ takes unit whichUnit, real newValue returns nothing + call SetUnitState(whichUnit, UNIT_STATE_MANA, RMaxBJ(0,newValue)) +endfunction + +//=========================================================================== +function SetUnitLifePercentBJ takes unit whichUnit, real percent returns nothing + call SetUnitState(whichUnit, UNIT_STATE_LIFE, GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE) * RMaxBJ(0,percent) * 0.01) +endfunction + +//=========================================================================== +function SetUnitManaPercentBJ takes unit whichUnit, real percent returns nothing + call SetUnitState(whichUnit, UNIT_STATE_MANA, GetUnitState(whichUnit, UNIT_STATE_MAX_MANA) * RMaxBJ(0,percent) * 0.01) +endfunction + +//=========================================================================== +function IsUnitDeadBJ takes unit whichUnit returns boolean + return GetUnitState(whichUnit, UNIT_STATE_LIFE) <= 0 +endfunction + +//=========================================================================== +function IsUnitAliveBJ takes unit whichUnit returns boolean + return not IsUnitDeadBJ(whichUnit) +endfunction + +//=========================================================================== +function IsUnitGroupDeadBJEnum takes nothing returns nothing + if not IsUnitDeadBJ(GetEnumUnit()) then + set bj_isUnitGroupDeadResult = false + endif +endfunction + +//=========================================================================== +// Returns true if every unit of the group is dead. +// +function IsUnitGroupDeadBJ takes group g returns boolean + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_isUnitGroupDeadResult = true + call ForGroup(g, function IsUnitGroupDeadBJEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(g) + endif + return bj_isUnitGroupDeadResult +endfunction + +//=========================================================================== +function IsUnitGroupEmptyBJEnum takes nothing returns nothing + set bj_isUnitGroupEmptyResult = false +endfunction + +//=========================================================================== +// Returns true if the group contains no units. +// +function IsUnitGroupEmptyBJ takes group g returns boolean + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_isUnitGroupEmptyResult = true + call ForGroup(g, function IsUnitGroupEmptyBJEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(g) + endif + return bj_isUnitGroupEmptyResult +endfunction + +//=========================================================================== +function IsUnitGroupInRectBJEnum takes nothing returns nothing + if not RectContainsUnit(bj_isUnitGroupInRectRect, GetEnumUnit()) then + set bj_isUnitGroupInRectResult = false + endif +endfunction + +//=========================================================================== +// Returns true if every unit of the group is within the given rect. +// +function IsUnitGroupInRectBJ takes group g, rect r returns boolean + set bj_isUnitGroupInRectResult = true + set bj_isUnitGroupInRectRect = r + call ForGroup(g, function IsUnitGroupInRectBJEnum) + return bj_isUnitGroupInRectResult +endfunction + +//=========================================================================== +function IsUnitHiddenBJ takes unit whichUnit returns boolean + return IsUnitHidden(whichUnit) +endfunction + +//=========================================================================== +function ShowUnitHide takes unit whichUnit returns nothing + call ShowUnit(whichUnit, false) +endfunction + +//=========================================================================== +function ShowUnitShow takes unit whichUnit returns nothing + // Prevent dead heroes from being unhidden. + if (IsUnitType(whichUnit, UNIT_TYPE_HERO) and IsUnitDeadBJ(whichUnit)) then + return + endif + + call ShowUnit(whichUnit, true) +endfunction + +//=========================================================================== +function IssueHauntOrderAtLocBJFilter takes nothing returns boolean + return GetUnitTypeId(GetFilterUnit()) == 'ngol' +endfunction + +//=========================================================================== +function IssueHauntOrderAtLocBJ takes unit whichPeon, location loc returns boolean + local group g = null + local unit goldMine = null + + // Search for a gold mine within a 1-cell radius of the specified location. + set g = CreateGroup() + call GroupEnumUnitsInRangeOfLoc(g, loc, 2*bj_CELLWIDTH, filterIssueHauntOrderAtLocBJ) + set goldMine = FirstOfGroup(g) + call DestroyGroup(g) + + // If no mine was found, abort the request. + if (goldMine == null) then + return false + endif + + // Issue the Haunt Gold Mine order. + return IssueTargetOrderById(whichPeon, 'ugol', goldMine) +endfunction + +//=========================================================================== +function IssueBuildOrderByIdLocBJ takes unit whichPeon, integer unitId, location loc returns boolean + if (unitId == 'ugol') then + return IssueHauntOrderAtLocBJ(whichPeon, loc) + else + return IssueBuildOrderById(whichPeon, unitId, GetLocationX(loc), GetLocationY(loc)) + endif +endfunction + +//=========================================================================== +function IssueTrainOrderByIdBJ takes unit whichUnit, integer unitId returns boolean + return IssueImmediateOrderById(whichUnit, unitId) +endfunction + +//=========================================================================== +function GroupTrainOrderByIdBJ takes group g, integer unitId returns boolean + return GroupImmediateOrderById(g, unitId) +endfunction + +//=========================================================================== +function IssueUpgradeOrderByIdBJ takes unit whichUnit, integer techId returns boolean + return IssueImmediateOrderById(whichUnit, techId) +endfunction + +//=========================================================================== +function GetAttackedUnitBJ takes nothing returns unit + return GetTriggerUnit() +endfunction + +//=========================================================================== +function SetUnitFlyHeightBJ takes unit whichUnit, real newHeight, real rate returns nothing + call SetUnitFlyHeight(whichUnit, newHeight, rate) +endfunction + +//=========================================================================== +function SetUnitTurnSpeedBJ takes unit whichUnit, real turnSpeed returns nothing + call SetUnitTurnSpeed(whichUnit, turnSpeed) +endfunction + +//=========================================================================== +function SetUnitPropWindowBJ takes unit whichUnit, real propWindow returns nothing + local real angle = propWindow + if (angle <= 0) then + set angle = 1 + elseif (angle >= 360) then + set angle = 359 + endif + set angle = angle * bj_DEGTORAD + + call SetUnitPropWindow(whichUnit, angle) +endfunction + +//=========================================================================== +function GetUnitPropWindowBJ takes unit whichUnit returns real + return GetUnitPropWindow(whichUnit) * bj_RADTODEG +endfunction + +//=========================================================================== +function GetUnitDefaultPropWindowBJ takes unit whichUnit returns real + return GetUnitDefaultPropWindow(whichUnit) +endfunction + +//=========================================================================== +function SetUnitBlendTimeBJ takes unit whichUnit, real blendTime returns nothing + call SetUnitBlendTime(whichUnit, blendTime) +endfunction + +//=========================================================================== +function SetUnitAcquireRangeBJ takes unit whichUnit, real acquireRange returns nothing + call SetUnitAcquireRange(whichUnit, acquireRange) +endfunction + +//=========================================================================== +function UnitSetCanSleepBJ takes unit whichUnit, boolean canSleep returns nothing + call UnitAddSleep(whichUnit, canSleep) +endfunction + +//=========================================================================== +function UnitCanSleepBJ takes unit whichUnit returns boolean + return UnitCanSleep(whichUnit) +endfunction + +//=========================================================================== +function UnitWakeUpBJ takes unit whichUnit returns nothing + call UnitWakeUp(whichUnit) +endfunction + +//=========================================================================== +function UnitIsSleepingBJ takes unit whichUnit returns boolean + return UnitIsSleeping(whichUnit) +endfunction + +//=========================================================================== +function WakePlayerUnitsEnum takes nothing returns nothing + call UnitWakeUp(GetEnumUnit()) +endfunction + +//=========================================================================== +function WakePlayerUnits takes player whichPlayer returns nothing + local group g = CreateGroup() + call GroupEnumUnitsOfPlayer(g, whichPlayer, null) + call ForGroup(g, function WakePlayerUnitsEnum) + call DestroyGroup(g) +endfunction + +//=========================================================================== +function EnableCreepSleepBJ takes boolean enable returns nothing + call SetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_NO_CREEP_SLEEP, IntegerTertiaryOp(enable, 0, 1)) + + // If we're disabling, attempt to wake any already-sleeping creeps. + if (not enable) then + call WakePlayerUnits(Player(PLAYER_NEUTRAL_AGGRESSIVE)) + endif +endfunction + +//=========================================================================== +function UnitGenerateAlarms takes unit whichUnit, boolean generate returns boolean + return UnitIgnoreAlarm(whichUnit, not generate) +endfunction + +//=========================================================================== +function DoesUnitGenerateAlarms takes unit whichUnit returns boolean + return not UnitIgnoreAlarmToggled(whichUnit) +endfunction + +//=========================================================================== +function PauseAllUnitsBJEnum takes nothing returns nothing + call PauseUnit( GetEnumUnit(), bj_pauseAllUnitsFlag ) +endfunction + +//=========================================================================== +// Pause all units +function PauseAllUnitsBJ takes boolean pause returns nothing + local integer index + local player indexPlayer + local group g + + set bj_pauseAllUnitsFlag = pause + set g = CreateGroup() + set index = 0 + loop + set indexPlayer = Player( index ) + + // If this is a computer slot, pause/resume the AI. + if (GetPlayerController( indexPlayer ) == MAP_CONTROL_COMPUTER) then + call PauseCompAI( indexPlayer, pause ) + endif + + // Enumerate and unpause every unit owned by the player. + call GroupEnumUnitsOfPlayer( g, indexPlayer, null ) + call ForGroup( g, function PauseAllUnitsBJEnum ) + call GroupClear( g ) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + call DestroyGroup(g) +endfunction + +//=========================================================================== +function PauseUnitBJ takes boolean pause, unit whichUnit returns nothing + call PauseUnit(whichUnit, pause) +endfunction + +//=========================================================================== +function IsUnitPausedBJ takes unit whichUnit returns boolean + return IsUnitPaused(whichUnit) +endfunction + +//=========================================================================== +function BlzAllUnitsEnableAurasBJEnum takes nothing returns nothing + call BlzUnitEnableAuras( GetEnumUnit(), bj_enableAurasAllUnits, bj_affectsUIAurasAllUnits ) +endfunction + +//=========================================================================== +function BlzAllUnitsEnableAurasBJ takes boolean enable, boolean affectsUI returns nothing + local integer index + local player indexPlayer + local group g + + set bj_enableAurasAllUnits = enable + set bj_affectsUIAurasAllUnits = affectsUI + set g = CreateGroup() + set index = 0 + loop + set indexPlayer = Player( index ) + + // Enumerate and enable/disable auras on every unit owned by the player. + call GroupEnumUnitsOfPlayer( g, indexPlayer, null ) + call ForGroup( g, function BlzAllUnitsEnableAurasBJEnum ) + call GroupClear( g ) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + call DestroyGroup(g) +endfunction + +//=========================================================================== +function UnitPauseTimedLifeBJ takes boolean flag, unit whichUnit returns nothing + call UnitPauseTimedLife(whichUnit, flag) +endfunction + +//=========================================================================== +function UnitApplyTimedLifeBJ takes real duration, integer buffId, unit whichUnit returns nothing + call UnitApplyTimedLife(whichUnit, buffId, duration) +endfunction + +//=========================================================================== +function UnitShareVisionBJ takes boolean share, unit whichUnit, player whichPlayer returns nothing + call UnitShareVision(whichUnit, whichPlayer, share) +endfunction + +//=========================================================================== +function UnitRemoveBuffsBJ takes integer buffType, unit whichUnit returns nothing + if (buffType == bj_REMOVEBUFFS_POSITIVE) then + call UnitRemoveBuffs(whichUnit, true, false) + elseif (buffType == bj_REMOVEBUFFS_NEGATIVE) then + call UnitRemoveBuffs(whichUnit, false, true) + elseif (buffType == bj_REMOVEBUFFS_ALL) then + call UnitRemoveBuffs(whichUnit, true, true) + elseif (buffType == bj_REMOVEBUFFS_NONTLIFE) then + call UnitRemoveBuffsEx(whichUnit, true, true, false, false, false, true, false) + else + // Unrecognized dispel type - ignore the request. + endif +endfunction + +//=========================================================================== +function UnitRemoveBuffsExBJ takes integer polarity, integer resist, unit whichUnit, boolean bTLife, boolean bAura returns nothing + local boolean bPos = (polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_POSITIVE) + local boolean bNeg = (polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_NEGATIVE) + local boolean bMagic = (resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_MAGIC) + local boolean bPhys = (resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_PHYSICAL) + + call UnitRemoveBuffsEx(whichUnit, bPos, bNeg, bMagic, bPhys, bTLife, bAura, false) +endfunction + +//=========================================================================== +function UnitCountBuffsExBJ takes integer polarity, integer resist, unit whichUnit, boolean bTLife, boolean bAura returns integer + local boolean bPos = (polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_POSITIVE) + local boolean bNeg = (polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_NEGATIVE) + local boolean bMagic = (resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_MAGIC) + local boolean bPhys = (resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_PHYSICAL) + + return UnitCountBuffsEx(whichUnit, bPos, bNeg, bMagic, bPhys, bTLife, bAura, false) +endfunction + +//=========================================================================== +function UnitRemoveAbilityBJ takes integer abilityId, unit whichUnit returns boolean + return UnitRemoveAbility(whichUnit, abilityId) +endfunction + +//=========================================================================== +function UnitAddAbilityBJ takes integer abilityId, unit whichUnit returns boolean + return UnitAddAbility(whichUnit, abilityId) +endfunction + +//=========================================================================== +function UnitRemoveTypeBJ takes unittype whichType, unit whichUnit returns boolean + return UnitRemoveType(whichUnit, whichType) +endfunction + +//=========================================================================== +function UnitAddTypeBJ takes unittype whichType, unit whichUnit returns boolean + return UnitAddType(whichUnit, whichType) +endfunction + +//=========================================================================== +function UnitMakeAbilityPermanentBJ takes boolean permanent, integer abilityId, unit whichUnit returns boolean + return UnitMakeAbilityPermanent(whichUnit, permanent, abilityId) +endfunction + +//=========================================================================== +function SetUnitExplodedBJ takes unit whichUnit, boolean exploded returns nothing + call SetUnitExploded(whichUnit, exploded) +endfunction + +//=========================================================================== +function ExplodeUnitBJ takes unit whichUnit returns nothing + call SetUnitExploded(whichUnit, true) + call KillUnit(whichUnit) +endfunction + +//=========================================================================== +function GetTransportUnitBJ takes nothing returns unit + return GetTransportUnit() +endfunction + +//=========================================================================== +function GetLoadedUnitBJ takes nothing returns unit + return GetLoadedUnit() +endfunction + +//=========================================================================== +function IsUnitInTransportBJ takes unit whichUnit, unit whichTransport returns boolean + return IsUnitInTransport(whichUnit, whichTransport) +endfunction + +//=========================================================================== +function IsUnitLoadedBJ takes unit whichUnit returns boolean + return IsUnitLoaded(whichUnit) +endfunction + +//=========================================================================== +function IsUnitIllusionBJ takes unit whichUnit returns boolean + return IsUnitIllusion(whichUnit) +endfunction + +//=========================================================================== +// This attempts to replace a unit with a new unit type by creating a new +// unit of the desired type using the old unit's location, facing, etc. +// +function ReplaceUnitBJ takes unit whichUnit, integer newUnitId, integer unitStateMethod returns unit + local unit oldUnit = whichUnit + local unit newUnit + local boolean wasHidden + local integer index + local item indexItem + local real oldRatio + + // If we have bogus data, don't attempt the replace. + if (oldUnit == null) then + set bj_lastReplacedUnit = oldUnit + return oldUnit + endif + + // Hide the original unit. + set wasHidden = IsUnitHidden(oldUnit) + call ShowUnit(oldUnit, false) + + // Create the replacement unit. + if (newUnitId == 'ugol') then + set newUnit = CreateBlightedGoldmine(GetOwningPlayer(oldUnit), GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit)) + else + set newUnit = CreateUnit(GetOwningPlayer(oldUnit), newUnitId, GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit)) + endif + + // Set the unit's life and mana according to the requested method. + if (unitStateMethod == bj_UNIT_STATE_METHOD_RELATIVE) then + // Set the replacement's current/max life ratio to that of the old unit. + // If both units have mana, do the same for mana. + if (GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE) > 0) then + set oldRatio = GetUnitState(oldUnit, UNIT_STATE_LIFE) / GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE) + call SetUnitState(newUnit, UNIT_STATE_LIFE, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_LIFE)) + endif + + if (GetUnitState(oldUnit, UNIT_STATE_MAX_MANA) > 0) and (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) > 0) then + set oldRatio = GetUnitState(oldUnit, UNIT_STATE_MANA) / GetUnitState(oldUnit, UNIT_STATE_MAX_MANA) + call SetUnitState(newUnit, UNIT_STATE_MANA, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_MANA)) + endif + elseif (unitStateMethod == bj_UNIT_STATE_METHOD_ABSOLUTE) then + // Set the replacement's current life to that of the old unit. + // If the new unit has mana, do the same for mana. + call SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(oldUnit, UNIT_STATE_LIFE)) + if (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) > 0) then + call SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(oldUnit, UNIT_STATE_MANA)) + endif + elseif (unitStateMethod == bj_UNIT_STATE_METHOD_DEFAULTS) then + // The newly created unit should already have default life and mana. + elseif (unitStateMethod == bj_UNIT_STATE_METHOD_MAXIMUM) then + // Use max life and mana. + call SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(newUnit, UNIT_STATE_MAX_LIFE)) + call SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(newUnit, UNIT_STATE_MAX_MANA)) + else + // Unrecognized unit state method - ignore the request. + endif + + // Mirror properties of the old unit onto the new unit. + //call PauseUnit(newUnit, IsUnitPaused(oldUnit)) + call SetResourceAmount(newUnit, GetResourceAmount(oldUnit)) + + // If both the old and new units are heroes, handle their hero info. + if (IsUnitType(oldUnit, UNIT_TYPE_HERO) and IsUnitType(newUnit, UNIT_TYPE_HERO)) then + call SetHeroXP(newUnit, GetHeroXP(oldUnit), false) + + set index = 0 + loop + set indexItem = UnitItemInSlot(oldUnit, index) + if (indexItem != null) then + call UnitRemoveItem(oldUnit, indexItem) + call UnitAddItem(newUnit, indexItem) + endif + + set index = index + 1 + exitwhen index >= bj_MAX_INVENTORY + endloop + endif + + // Remove or kill the original unit. It is sometimes unsafe to remove + // hidden units, so kill the original unit if it was previously hidden. + if wasHidden then + call KillUnit(oldUnit) + call RemoveUnit(oldUnit) + else + call RemoveUnit(oldUnit) + endif + + set bj_lastReplacedUnit = newUnit + return newUnit +endfunction + +//=========================================================================== +function GetLastReplacedUnitBJ takes nothing returns unit + return bj_lastReplacedUnit +endfunction + +//=========================================================================== +function SetUnitPositionLocFacingBJ takes unit whichUnit, location loc, real facing returns nothing + call SetUnitPositionLoc(whichUnit, loc) + call SetUnitFacing(whichUnit, facing) +endfunction + +//=========================================================================== +function SetUnitPositionLocFacingLocBJ takes unit whichUnit, location loc, location lookAt returns nothing + call SetUnitPositionLoc(whichUnit, loc) + call SetUnitFacing(whichUnit, AngleBetweenPoints(loc, lookAt)) +endfunction + +//=========================================================================== +function AddItemToStockBJ takes integer itemId, unit whichUnit, integer currentStock, integer stockMax returns nothing + call AddItemToStock(whichUnit, itemId, currentStock, stockMax) +endfunction + +//=========================================================================== +function AddUnitToStockBJ takes integer unitId, unit whichUnit, integer currentStock, integer stockMax returns nothing + call AddUnitToStock(whichUnit, unitId, currentStock, stockMax) +endfunction + +//=========================================================================== +function RemoveItemFromStockBJ takes integer itemId, unit whichUnit returns nothing + call RemoveItemFromStock(whichUnit, itemId) +endfunction + +//=========================================================================== +function RemoveUnitFromStockBJ takes integer unitId, unit whichUnit returns nothing + call RemoveUnitFromStock(whichUnit, unitId) +endfunction + +//=========================================================================== +function SetUnitUseFoodBJ takes boolean enable, unit whichUnit returns nothing + call SetUnitUseFood(whichUnit, enable) +endfunction + +//=========================================================================== +function UnitDamagePointLoc takes unit whichUnit, real delay, real radius, location loc, real amount, attacktype whichAttack, damagetype whichDamage returns boolean + return UnitDamagePoint(whichUnit, delay, radius, GetLocationX(loc), GetLocationY(loc), amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS) +endfunction + +//=========================================================================== +function UnitDamageTargetBJ takes unit whichUnit, unit target, real amount, attacktype whichAttack, damagetype whichDamage returns boolean + return UnitDamageTarget(whichUnit, target, amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS) +endfunction + + + +//*************************************************************************** +//* +//* Destructable Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function CreateDestructableLoc takes integer objectid, location loc, real facing, real scale, integer variation returns destructable + set bj_lastCreatedDestructable = CreateDestructable(objectid, GetLocationX(loc), GetLocationY(loc), facing, scale, variation) + return bj_lastCreatedDestructable +endfunction + +//=========================================================================== +function CreateDeadDestructableLocBJ takes integer objectid, location loc, real facing, real scale, integer variation returns destructable + set bj_lastCreatedDestructable = CreateDeadDestructable(objectid, GetLocationX(loc), GetLocationY(loc), facing, scale, variation) + return bj_lastCreatedDestructable +endfunction + +//=========================================================================== +function GetLastCreatedDestructable takes nothing returns destructable + return bj_lastCreatedDestructable +endfunction + +//=========================================================================== +function ShowDestructableBJ takes boolean flag, destructable d returns nothing + call ShowDestructable(d, flag) +endfunction + +//=========================================================================== +function SetDestructableInvulnerableBJ takes destructable d, boolean flag returns nothing + call SetDestructableInvulnerable(d, flag) +endfunction + +//=========================================================================== +function IsDestructableInvulnerableBJ takes destructable d returns boolean + return IsDestructableInvulnerable(d) +endfunction + +//=========================================================================== +function GetDestructableLoc takes destructable whichDestructable returns location + return Location(GetDestructableX(whichDestructable), GetDestructableY(whichDestructable)) +endfunction + +//=========================================================================== +function EnumDestructablesInRectAll takes rect r, code actionFunc returns nothing + call EnumDestructablesInRect(r, null, actionFunc) +endfunction + +//=========================================================================== +function EnumDestructablesInCircleBJFilter takes nothing returns boolean + local location destLoc = GetDestructableLoc(GetFilterDestructable()) + local boolean result + + set result = DistanceBetweenPoints(destLoc, bj_enumDestructableCenter) <= bj_enumDestructableRadius + call RemoveLocation(destLoc) + return result +endfunction + +//=========================================================================== +function IsDestructableDeadBJ takes destructable d returns boolean + return GetDestructableLife(d) <= 0 +endfunction + +//=========================================================================== +function IsDestructableAliveBJ takes destructable d returns boolean + return not IsDestructableDeadBJ(d) +endfunction + +//=========================================================================== +// See GroupPickRandomUnitEnum for the details of this algorithm. +// +function RandomDestructableInRectBJEnum takes nothing returns nothing + set bj_destRandomConsidered = bj_destRandomConsidered + 1 + if (GetRandomInt(1,bj_destRandomConsidered) == 1) then + set bj_destRandomCurrentPick = GetEnumDestructable() + endif +endfunction + +//=========================================================================== +// Picks a random destructable from within a rect, matching a condition +// +function RandomDestructableInRectBJ takes rect r, boolexpr filter returns destructable + set bj_destRandomConsidered = 0 + set bj_destRandomCurrentPick = null + call EnumDestructablesInRect(r, filter, function RandomDestructableInRectBJEnum) + call DestroyBoolExpr(filter) + return bj_destRandomCurrentPick +endfunction + +//=========================================================================== +// Picks a random destructable from within a rect +// +function RandomDestructableInRectSimpleBJ takes rect r returns destructable + return RandomDestructableInRectBJ(r, null) +endfunction + +//=========================================================================== +// Enumerates within a rect, with a filter to narrow the enumeration down +// objects within a circular area. +// +function EnumDestructablesInCircleBJ takes real radius, location loc, code actionFunc returns nothing + local rect r + + if (radius >= 0) then + set bj_enumDestructableCenter = loc + set bj_enumDestructableRadius = radius + set r = GetRectFromCircleBJ(loc, radius) + call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, actionFunc) + call RemoveRect(r) + endif +endfunction + +//=========================================================================== +function SetDestructableLifePercentBJ takes destructable d, real percent returns nothing + call SetDestructableLife(d, GetDestructableMaxLife(d) * percent * 0.01) +endfunction + +//=========================================================================== +function SetDestructableMaxLifeBJ takes destructable d, real max returns nothing + call SetDestructableMaxLife(d, max) +endfunction + +//=========================================================================== +function ModifyGateBJ takes integer gateOperation, destructable d returns nothing + if (gateOperation == bj_GATEOPERATION_CLOSE) then + if (GetDestructableLife(d) <= 0) then + call DestructableRestoreLife(d, GetDestructableMaxLife(d), true) + endif + call SetDestructableAnimation(d, "stand") + elseif (gateOperation == bj_GATEOPERATION_OPEN) then + if (GetDestructableLife(d) > 0) then + call KillDestructable(d) + endif + call SetDestructableAnimation(d, "death alternate") + elseif (gateOperation == bj_GATEOPERATION_DESTROY) then + if (GetDestructableLife(d) > 0) then + call KillDestructable(d) + endif + call SetDestructableAnimation(d, "death") + else + // Unrecognized gate state - ignore the request. + endif +endfunction + +//=========================================================================== +// Determine the elevator's height from its occlusion height. +// +function GetElevatorHeight takes destructable d returns integer + local integer height + + set height = 1 + R2I(GetDestructableOccluderHeight(d) / bj_CLIFFHEIGHT) + if (height < 1) or (height > 3) then + set height = 1 + endif + return height +endfunction + +//=========================================================================== +// To properly animate an elevator, we must know not only what height we +// want to change to, but also what height we are currently at. This code +// determines the elevator's current height from its occlusion height. +// Arbitrarily changing an elevator's occlusion height is thus inadvisable. +// +function ChangeElevatorHeight takes destructable d, integer newHeight returns nothing + local integer oldHeight + + // Cap the new height within the supported range. + set newHeight = IMaxBJ(1, newHeight) + set newHeight = IMinBJ(3, newHeight) + + // Find out what height the elevator is already at. + set oldHeight = GetElevatorHeight(d) + + // Set the elevator's occlusion height. + call SetDestructableOccluderHeight(d, bj_CLIFFHEIGHT*(newHeight-1)) + + if (newHeight == 1) then + if (oldHeight == 2) then + call SetDestructableAnimation(d, "birth") + call QueueDestructableAnimation(d, "stand") + elseif (oldHeight == 3) then + call SetDestructableAnimation(d, "birth third") + call QueueDestructableAnimation(d, "stand") + else + // Unrecognized old height - snap to new height. + call SetDestructableAnimation(d, "stand") + endif + elseif (newHeight == 2) then + if (oldHeight == 1) then + call SetDestructableAnimation(d, "death") + call QueueDestructableAnimation(d, "stand second") + elseif (oldHeight == 3) then + call SetDestructableAnimation(d, "birth second") + call QueueDestructableAnimation(d, "stand second") + else + // Unrecognized old height - snap to new height. + call SetDestructableAnimation(d, "stand second") + endif + elseif (newHeight == 3) then + if (oldHeight == 1) then + call SetDestructableAnimation(d, "death third") + call QueueDestructableAnimation(d, "stand third") + elseif (oldHeight == 2) then + call SetDestructableAnimation(d, "death second") + call QueueDestructableAnimation(d, "stand third") + else + // Unrecognized old height - snap to new height. + call SetDestructableAnimation(d, "stand third") + endif + else + // Unrecognized new height - ignore the request. + endif +endfunction + +//=========================================================================== +// Grab the unit and throw his own coords in his face, forcing him to push +// and shove until he finds a spot where noone will bother him. +// +function NudgeUnitsInRectEnum takes nothing returns nothing + local unit nudgee = GetEnumUnit() + + call SetUnitPosition(nudgee, GetUnitX(nudgee), GetUnitY(nudgee)) +endfunction + +//=========================================================================== +function NudgeItemsInRectEnum takes nothing returns nothing + local item nudgee = GetEnumItem() + + call SetItemPosition(nudgee, GetItemX(nudgee), GetItemY(nudgee)) +endfunction + +//=========================================================================== +// Nudge the items and units within a given rect ever so gently, so as to +// encourage them to find locations where they can peacefully coexist with +// pathing restrictions and live happy, fruitful lives. +// +function NudgeObjectsInRect takes rect nudgeArea returns nothing + local group g + + set g = CreateGroup() + call GroupEnumUnitsInRect(g, nudgeArea, null) + call ForGroup(g, function NudgeUnitsInRectEnum) + call DestroyGroup(g) + + call EnumItemsInRect(nudgeArea, null, function NudgeItemsInRectEnum) +endfunction + +//=========================================================================== +function NearbyElevatorExistsEnum takes nothing returns nothing + local destructable d = GetEnumDestructable() + local integer dType = GetDestructableTypeId(d) + + if (dType == bj_ELEVATOR_CODE01) or (dType == bj_ELEVATOR_CODE02) then + set bj_elevatorNeighbor = d + endif +endfunction + +//=========================================================================== +function NearbyElevatorExists takes real x, real y returns boolean + local real findThreshold = 32 + local rect r + + // If another elevator is overlapping this one, ignore the wall. + set r = Rect(x - findThreshold, y - findThreshold, x + findThreshold, y + findThreshold) + set bj_elevatorNeighbor = null + call EnumDestructablesInRect(r, null, function NearbyElevatorExistsEnum) + call RemoveRect(r) + + return bj_elevatorNeighbor != null +endfunction + +//=========================================================================== +function FindElevatorWallBlockerEnum takes nothing returns nothing + set bj_elevatorWallBlocker = GetEnumDestructable() +endfunction + +//=========================================================================== +// This toggles pathing on or off for one wall of an elevator by killing +// or reviving a pathing blocker at the appropriate location (and creating +// the pathing blocker in the first place, if it does not yet exist). +// +function ChangeElevatorWallBlocker takes real x, real y, real facing, boolean open returns nothing + local destructable blocker = null + local real findThreshold = 32 + local real nudgeLength = 4.25 * bj_CELLWIDTH + local real nudgeWidth = 1.25 * bj_CELLWIDTH + local rect r + + // Search for the pathing blocker within the general area. + set r = Rect(x - findThreshold, y - findThreshold, x + findThreshold, y + findThreshold) + set bj_elevatorWallBlocker = null + call EnumDestructablesInRect(r, null, function FindElevatorWallBlockerEnum) + call RemoveRect(r) + set blocker = bj_elevatorWallBlocker + + // Ensure that the blocker exists. + if (blocker == null) then + set blocker = CreateDeadDestructable(bj_ELEVATOR_BLOCKER_CODE, x, y, facing, 1, 0) + elseif (GetDestructableTypeId(blocker) != bj_ELEVATOR_BLOCKER_CODE) then + // If a different destructible exists in the blocker's spot, ignore + // the request. (Two destructibles cannot occupy the same location + // on the map, so we cannot create an elevator blocker here.) + return + endif + + if (open) then + // Ensure that the blocker is dead. + if (GetDestructableLife(blocker) > 0) then + call KillDestructable(blocker) + endif + else + // Ensure that the blocker is alive. + if (GetDestructableLife(blocker) <= 0) then + call DestructableRestoreLife(blocker, GetDestructableMaxLife(blocker), false) + endif + + // Nudge any objects standing in the blocker's way. + if (facing == 0) then + set r = Rect(x - nudgeWidth/2, y - nudgeLength/2, x + nudgeWidth/2, y + nudgeLength/2) + call NudgeObjectsInRect(r) + call RemoveRect(r) + elseif (facing == 90) then + set r = Rect(x - nudgeLength/2, y - nudgeWidth/2, x + nudgeLength/2, y + nudgeWidth/2) + call NudgeObjectsInRect(r) + call RemoveRect(r) + else + // Unrecognized blocker angle - don't nudge anything. + endif + endif +endfunction + +//=========================================================================== +function ChangeElevatorWalls takes boolean open, integer walls, destructable d returns nothing + local real x = GetDestructableX(d) + local real y = GetDestructableY(d) + local real distToBlocker = 192 + local real distToNeighbor = 256 + + if (walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_EAST) then + if (not NearbyElevatorExists(x + distToNeighbor, y)) then + call ChangeElevatorWallBlocker(x + distToBlocker, y, 0, open) + endif + endif + + if (walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_NORTH) then + if (not NearbyElevatorExists(x, y + distToNeighbor)) then + call ChangeElevatorWallBlocker(x, y + distToBlocker, 90, open) + endif + endif + + if (walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_SOUTH) then + if (not NearbyElevatorExists(x, y - distToNeighbor)) then + call ChangeElevatorWallBlocker(x, y - distToBlocker, 90, open) + endif + endif + + if (walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_WEST) then + if (not NearbyElevatorExists(x - distToNeighbor, y)) then + call ChangeElevatorWallBlocker(x - distToBlocker, y, 0, open) + endif + endif +endfunction + + + +//*************************************************************************** +//* +//* Neutral Building Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function WaygateActivateBJ takes boolean activate, unit waygate returns nothing + call WaygateActivate(waygate, activate) +endfunction + +//=========================================================================== +function WaygateIsActiveBJ takes unit waygate returns boolean + return WaygateIsActive(waygate) +endfunction + +//=========================================================================== +function WaygateSetDestinationLocBJ takes unit waygate, location loc returns nothing + call WaygateSetDestination(waygate, GetLocationX(loc), GetLocationY(loc)) +endfunction + +//=========================================================================== +function WaygateGetDestinationLocBJ takes unit waygate returns location + return Location(WaygateGetDestinationX(waygate), WaygateGetDestinationY(waygate)) +endfunction + +//=========================================================================== +function UnitSetUsesAltIconBJ takes boolean flag, unit whichUnit returns nothing + call UnitSetUsesAltIcon(whichUnit, flag) +endfunction + + + +//*************************************************************************** +//* +//* UI Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function ForceUIKeyBJ takes player whichPlayer, string key returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ForceUIKey(key) + endif +endfunction + +//=========================================================================== +function ForceUICancelBJ takes player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ForceUICancel() + endif +endfunction + + + +//*************************************************************************** +//* +//* Group and Force Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function ForGroupBJ takes group whichGroup, code callback returns nothing + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + call ForGroup(whichGroup, callback) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(whichGroup) + endif +endfunction + +//=========================================================================== +function GroupAddUnitSimple takes unit whichUnit, group whichGroup returns nothing + call GroupAddUnit(whichGroup, whichUnit) +endfunction + +//=========================================================================== +function GroupRemoveUnitSimple takes unit whichUnit, group whichGroup returns nothing + call GroupRemoveUnit(whichGroup, whichUnit) +endfunction + +//=========================================================================== +function GroupAddGroupEnum takes nothing returns nothing + call GroupAddUnit(bj_groupAddGroupDest, GetEnumUnit()) +endfunction + +//=========================================================================== +function GroupAddGroup takes group sourceGroup, group destGroup returns nothing + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_groupAddGroupDest = destGroup + call ForGroup(sourceGroup, function GroupAddGroupEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(sourceGroup) + endif +endfunction + +//=========================================================================== +function GroupRemoveGroupEnum takes nothing returns nothing + call GroupRemoveUnit(bj_groupRemoveGroupDest, GetEnumUnit()) +endfunction + +//=========================================================================== +function GroupRemoveGroup takes group sourceGroup, group destGroup returns nothing + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_groupRemoveGroupDest = destGroup + call ForGroup(sourceGroup, function GroupRemoveGroupEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(sourceGroup) + endif +endfunction + +//=========================================================================== +function ForceAddPlayerSimple takes player whichPlayer, force whichForce returns nothing + call ForceAddPlayer(whichForce, whichPlayer) +endfunction + +//=========================================================================== +function ForceRemovePlayerSimple takes player whichPlayer, force whichForce returns nothing + call ForceRemovePlayer(whichForce, whichPlayer) +endfunction + +//=========================================================================== +// Consider each unit, one at a time, keeping a "current pick". Once all units +// are considered, this "current pick" will be the resulting random unit. +// +// The chance of picking a given unit over the "current pick" is 1/N, where N is +// the number of units considered thusfar (including the current consideration). +// +function GroupPickRandomUnitEnum takes nothing returns nothing + set bj_groupRandomConsidered = bj_groupRandomConsidered + 1 + if (GetRandomInt(1,bj_groupRandomConsidered) == 1) then + set bj_groupRandomCurrentPick = GetEnumUnit() + endif +endfunction + +//=========================================================================== +// Picks a random unit from a group. +// +function GroupPickRandomUnit takes group whichGroup returns unit + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_groupRandomConsidered = 0 + set bj_groupRandomCurrentPick = null + call ForGroup(whichGroup, function GroupPickRandomUnitEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(whichGroup) + endif + return bj_groupRandomCurrentPick +endfunction + +//=========================================================================== +// See GroupPickRandomUnitEnum for the details of this algorithm. +// +function ForcePickRandomPlayerEnum takes nothing returns nothing + set bj_forceRandomConsidered = bj_forceRandomConsidered + 1 + if (GetRandomInt(1,bj_forceRandomConsidered) == 1) then + set bj_forceRandomCurrentPick = GetEnumPlayer() + endif +endfunction + +//=========================================================================== +// Picks a random player from a force. +// +function ForcePickRandomPlayer takes force whichForce returns player + set bj_forceRandomConsidered = 0 + set bj_forceRandomCurrentPick = null + call ForForce(whichForce, function ForcePickRandomPlayerEnum) + return bj_forceRandomCurrentPick +endfunction + +//=========================================================================== +function EnumUnitsSelected takes player whichPlayer, boolexpr enumFilter, code enumAction returns nothing + local group g = CreateGroup() + call SyncSelections() + call GroupEnumUnitsSelected(g, whichPlayer, enumFilter) + call DestroyBoolExpr(enumFilter) + call ForGroup(g, enumAction) + call DestroyGroup(g) +endfunction + +//=========================================================================== +function GetUnitsInRectMatching takes rect r, boolexpr filter returns group + local group g = CreateGroup() + call GroupEnumUnitsInRect(g, r, filter) + call DestroyBoolExpr(filter) + return g +endfunction + +//=========================================================================== +function GetUnitsInRectAll takes rect r returns group + return GetUnitsInRectMatching(r, null) +endfunction + +//=========================================================================== +function GetUnitsInRectOfPlayerFilter takes nothing returns boolean + return GetOwningPlayer(GetFilterUnit()) == bj_groupEnumOwningPlayer +endfunction + +//=========================================================================== +function GetUnitsInRectOfPlayer takes rect r, player whichPlayer returns group + local group g = CreateGroup() + set bj_groupEnumOwningPlayer = whichPlayer + call GroupEnumUnitsInRect(g, r, filterGetUnitsInRectOfPlayer) + return g +endfunction + +//=========================================================================== +function GetUnitsInRangeOfLocMatching takes real radius, location whichLocation, boolexpr filter returns group + local group g = CreateGroup() + call GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter) + call DestroyBoolExpr(filter) + return g +endfunction + +//=========================================================================== +function GetUnitsInRangeOfLocAll takes real radius, location whichLocation returns group + return GetUnitsInRangeOfLocMatching(radius, whichLocation, null) +endfunction + +//=========================================================================== +function GetUnitsOfTypeIdAllFilter takes nothing returns boolean + return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId +endfunction + +//=========================================================================== +function GetUnitsOfTypeIdAll takes integer unitid returns group + local group result = CreateGroup() + local group g = CreateGroup() + local integer index + + set index = 0 + loop + set bj_groupEnumTypeId = unitid + call GroupClear(g) + call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll) + call GroupAddGroup(g, result) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + call DestroyGroup(g) + + return result +endfunction + +//=========================================================================== +function GetUnitsOfPlayerMatching takes player whichPlayer, boolexpr filter returns group + local group g = CreateGroup() + call GroupEnumUnitsOfPlayer(g, whichPlayer, filter) + call DestroyBoolExpr(filter) + return g +endfunction + +//=========================================================================== +function GetUnitsOfPlayerAll takes player whichPlayer returns group + return GetUnitsOfPlayerMatching(whichPlayer, null) +endfunction + +//=========================================================================== +function GetUnitsOfPlayerAndTypeIdFilter takes nothing returns boolean + return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId +endfunction + +//=========================================================================== +function GetUnitsOfPlayerAndTypeId takes player whichPlayer, integer unitid returns group + local group g = CreateGroup() + set bj_groupEnumTypeId = unitid + call GroupEnumUnitsOfPlayer(g, whichPlayer, filterGetUnitsOfPlayerAndTypeId) + return g +endfunction + +//=========================================================================== +function GetUnitsSelectedAll takes player whichPlayer returns group + local group g = CreateGroup() + call SyncSelections() + call GroupEnumUnitsSelected(g, whichPlayer, null) + return g +endfunction + +//=========================================================================== +function GetForceOfPlayer takes player whichPlayer returns force + local force f = CreateForce() + call ForceAddPlayer(f, whichPlayer) + return f +endfunction + +//=========================================================================== +function GetPlayersAll takes nothing returns force + return bj_FORCE_ALL_PLAYERS +endfunction + +//=========================================================================== +function GetPlayersByMapControl takes mapcontrol whichControl returns force + local force f = CreateForce() + local integer playerIndex + local player indexPlayer + + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if GetPlayerController(indexPlayer) == whichControl then + call ForceAddPlayer(f, indexPlayer) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYER_SLOTS + endloop + + return f +endfunction + +//=========================================================================== +function GetPlayersAllies takes player whichPlayer returns force + local force f = CreateForce() + call ForceEnumAllies(f, whichPlayer, null) + return f +endfunction + +//=========================================================================== +function GetPlayersEnemies takes player whichPlayer returns force + local force f = CreateForce() + call ForceEnumEnemies(f, whichPlayer, null) + return f +endfunction + +//=========================================================================== +function GetPlayersMatching takes boolexpr filter returns force + local force f = CreateForce() + call ForceEnumPlayers(f, filter) + call DestroyBoolExpr(filter) + return f +endfunction + +//=========================================================================== +function CountUnitsInGroupEnum takes nothing returns nothing + set bj_groupCountUnits = bj_groupCountUnits + 1 +endfunction + +//=========================================================================== +function CountUnitsInGroup takes group g returns integer + // If the user wants the group destroyed, remember that fact and clear + // the flag, in case it is used again in the callback. + local boolean wantDestroy = bj_wantDestroyGroup + set bj_wantDestroyGroup = false + + set bj_groupCountUnits = 0 + call ForGroup(g, function CountUnitsInGroupEnum) + + // If the user wants the group destroyed, do so now. + if (wantDestroy) then + call DestroyGroup(g) + endif + return bj_groupCountUnits +endfunction + +//=========================================================================== +function CountPlayersInForceEnum takes nothing returns nothing + set bj_forceCountPlayers = bj_forceCountPlayers + 1 +endfunction + +//=========================================================================== +function CountPlayersInForceBJ takes force f returns integer + set bj_forceCountPlayers = 0 + call ForForce(f, function CountPlayersInForceEnum) + return bj_forceCountPlayers +endfunction + +//=========================================================================== +function GetRandomSubGroupEnum takes nothing returns nothing + if (bj_randomSubGroupWant > 0) then + if (bj_randomSubGroupWant >= bj_randomSubGroupTotal) or (GetRandomReal(0,1) < bj_randomSubGroupChance) then + // We either need every remaining unit, or the unit passed its chance check. + call GroupAddUnit(bj_randomSubGroupGroup, GetEnumUnit()) + set bj_randomSubGroupWant = bj_randomSubGroupWant - 1 + endif + endif + set bj_randomSubGroupTotal = bj_randomSubGroupTotal - 1 +endfunction + +//=========================================================================== +function GetRandomSubGroup takes integer count, group sourceGroup returns group + local group g = CreateGroup() + + set bj_randomSubGroupGroup = g + set bj_randomSubGroupWant = count + set bj_randomSubGroupTotal = CountUnitsInGroup(sourceGroup) + + if (bj_randomSubGroupWant <= 0 or bj_randomSubGroupTotal <= 0) then + return g + endif + + set bj_randomSubGroupChance = I2R(bj_randomSubGroupWant) / I2R(bj_randomSubGroupTotal) + call ForGroup(sourceGroup, function GetRandomSubGroupEnum) + return g +endfunction + +//=========================================================================== +function LivingPlayerUnitsOfTypeIdFilter takes nothing returns boolean + local unit filterUnit = GetFilterUnit() + return IsUnitAliveBJ(filterUnit) and GetUnitTypeId(filterUnit) == bj_livingPlayerUnitsTypeId +endfunction + +//=========================================================================== +function CountLivingPlayerUnitsOfTypeId takes integer unitId, player whichPlayer returns integer + local group g + local integer matchedCount + + set g = CreateGroup() + set bj_livingPlayerUnitsTypeId = unitId + call GroupEnumUnitsOfPlayer(g, whichPlayer, filterLivingPlayerUnitsOfTypeId) + set matchedCount = CountUnitsInGroup(g) + call DestroyGroup(g) + + return matchedCount +endfunction + + + +//*************************************************************************** +//* +//* Animation Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function ResetUnitAnimation takes unit whichUnit returns nothing + call SetUnitAnimation(whichUnit, "stand") +endfunction + +//=========================================================================== +function SetUnitTimeScalePercent takes unit whichUnit, real percentScale returns nothing + call SetUnitTimeScale(whichUnit, percentScale * 0.01) +endfunction + +//=========================================================================== +function SetUnitScalePercent takes unit whichUnit, real percentScaleX, real percentScaleY, real percentScaleZ returns nothing + call SetUnitScale(whichUnit, percentScaleX * 0.01, percentScaleY * 0.01, percentScaleZ * 0.01) +endfunction + +//=========================================================================== +// This version differs from the common.j interface in that the alpha value +// is reversed so as to be displayed as transparency, and all four parameters +// are treated as percentages rather than bytes. +// +function SetUnitVertexColorBJ takes unit whichUnit, real red, real green, real blue, real transparency returns nothing + call SetUnitVertexColor(whichUnit, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function UnitAddIndicatorBJ takes unit whichUnit, real red, real green, real blue, real transparency returns nothing + call AddIndicator(whichUnit, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function DestructableAddIndicatorBJ takes destructable whichDestructable, real red, real green, real blue, real transparency returns nothing + call AddIndicator(whichDestructable, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function ItemAddIndicatorBJ takes item whichItem, real red, real green, real blue, real transparency returns nothing + call AddIndicator(whichItem, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +// Sets a unit's facing to point directly at a location. +// +function SetUnitFacingToFaceLocTimed takes unit whichUnit, location target, real duration returns nothing + local location unitLoc = GetUnitLoc(whichUnit) + + call SetUnitFacingTimed(whichUnit, AngleBetweenPoints(unitLoc, target), duration) + call RemoveLocation(unitLoc) +endfunction + +//=========================================================================== +// Sets a unit's facing to point directly at another unit. +// +function SetUnitFacingToFaceUnitTimed takes unit whichUnit, unit target, real duration returns nothing + local location unitLoc = GetUnitLoc(target) + + call SetUnitFacingToFaceLocTimed(whichUnit, unitLoc, duration) + call RemoveLocation(unitLoc) +endfunction + +//=========================================================================== +function QueueUnitAnimationBJ takes unit whichUnit, string whichAnimation returns nothing + call QueueUnitAnimation(whichUnit, whichAnimation) +endfunction + +//=========================================================================== +// This version differs from the common.j interface in that the alpha value +// is reversed so as to be displayed as transparency, and all four parameters +// are treated as percentages rather than bytes. +// +function SetDestructableVertexColorBJ takes destructable whichDestructable, real red, real green, real blue, real transparency returns nothing + call SetDestructableVertexColor(whichDestructable, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function SetDestructableAnimationBJ takes destructable d, string whichAnimation returns nothing + call SetDestructableAnimation(d, whichAnimation) +endfunction + +//=========================================================================== +function QueueDestructableAnimationBJ takes destructable d, string whichAnimation returns nothing + call QueueDestructableAnimation(d, whichAnimation) +endfunction + +//=========================================================================== +function SetDestAnimationSpeedPercent takes destructable d, real percentScale returns nothing + call SetDestructableAnimationSpeed(d, percentScale * 0.01) +endfunction + + + +//*************************************************************************** +//* +//* Dialog Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function DialogDisplayBJ takes boolean flag, dialog whichDialog, player whichPlayer returns nothing + call DialogDisplay(whichPlayer, whichDialog, flag) +endfunction + +//=========================================================================== +function DialogSetMessageBJ takes dialog whichDialog, string message returns nothing + call DialogSetMessage(whichDialog, message) +endfunction + +//=========================================================================== +function DialogAddButtonBJ takes dialog whichDialog, string buttonText returns button + set bj_lastCreatedButton = DialogAddButton(whichDialog, buttonText,0) + return bj_lastCreatedButton +endfunction + +//=========================================================================== +function DialogAddButtonWithHotkeyBJ takes dialog whichDialog, string buttonText, integer hotkey returns button + set bj_lastCreatedButton = DialogAddButton(whichDialog, buttonText,hotkey) + return bj_lastCreatedButton +endfunction + +//=========================================================================== +function DialogClearBJ takes dialog whichDialog returns nothing + call DialogClear(whichDialog) +endfunction + +//=========================================================================== +function GetLastCreatedButtonBJ takes nothing returns button + return bj_lastCreatedButton +endfunction + +//=========================================================================== +function GetClickedButtonBJ takes nothing returns button + return GetClickedButton() +endfunction + +//=========================================================================== +function GetClickedDialogBJ takes nothing returns dialog + return GetClickedDialog() +endfunction + + + +//*************************************************************************** +//* +//* Alliance Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function SetPlayerAllianceBJ takes player sourcePlayer, alliancetype whichAllianceSetting, boolean value, player otherPlayer returns nothing + // Prevent players from attempting to ally with themselves. + if (sourcePlayer == otherPlayer) then + return + endif + + call SetPlayerAlliance(sourcePlayer, otherPlayer, whichAllianceSetting, value) +endfunction + +//=========================================================================== +// Set all flags used by the in-game "Ally" checkbox. +// +function SetPlayerAllianceStateAllyBJ takes player sourcePlayer, player otherPlayer, boolean flag returns nothing + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, flag) + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_REQUEST, flag) + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_RESPONSE, flag) + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_XP, flag) + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_SPELLS, flag) +endfunction + +//=========================================================================== +// Set all flags used by the in-game "Shared Vision" checkbox. +// +function SetPlayerAllianceStateVisionBJ takes player sourcePlayer, player otherPlayer, boolean flag returns nothing + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_VISION, flag) +endfunction + +//=========================================================================== +// Set all flags used by the in-game "Shared Units" checkbox. +// +function SetPlayerAllianceStateControlBJ takes player sourcePlayer, player otherPlayer, boolean flag returns nothing + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_CONTROL, flag) +endfunction + +//=========================================================================== +// Set all flags used by the in-game "Shared Units" checkbox with the Full +// Shared Unit Control feature enabled. +// +function SetPlayerAllianceStateFullControlBJ takes player sourcePlayer, player otherPlayer, boolean flag returns nothing + call SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, flag) +endfunction + +//=========================================================================== +function SetPlayerAllianceStateBJ takes player sourcePlayer, player otherPlayer, integer allianceState returns nothing + // Prevent players from attempting to ally with themselves. + if (sourcePlayer == otherPlayer) then + return + endif + + if allianceState == bj_ALLIANCE_UNALLIED then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + elseif allianceState == bj_ALLIANCE_UNALLIED_VISION then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + elseif allianceState == bj_ALLIANCE_ALLIED then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + elseif allianceState == bj_ALLIANCE_ALLIED_VISION then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + elseif allianceState == bj_ALLIANCE_ALLIED_UNITS then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + elseif allianceState == bj_ALLIANCE_ALLIED_ADVUNITS then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, true ) + elseif allianceState == bj_ALLIANCE_NEUTRAL then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAlliance( sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, true ) + elseif allianceState == bj_ALLIANCE_NEUTRAL_VISION then + call SetPlayerAllianceStateAllyBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateVisionBJ( sourcePlayer, otherPlayer, true ) + call SetPlayerAllianceStateControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAllianceStateFullControlBJ( sourcePlayer, otherPlayer, false ) + call SetPlayerAlliance( sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, true ) + else + // Unrecognized alliance state - ignore the request. + endif +endfunction + +//=========================================================================== +// Set the alliance states for an entire force towards another force. +// +function SetForceAllianceStateBJ takes force sourceForce, force targetForce, integer allianceState returns nothing + local integer sourceIndex + local integer targetIndex + + set sourceIndex = 0 + loop + + if (sourceForce==bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(sourceIndex), sourceForce)) then + set targetIndex = 0 + loop + if (targetForce==bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(targetIndex), targetForce)) then + call SetPlayerAllianceStateBJ(Player(sourceIndex), Player(targetIndex), allianceState) + endif + + set targetIndex = targetIndex + 1 + exitwhen targetIndex == bj_MAX_PLAYER_SLOTS + endloop + endif + + set sourceIndex = sourceIndex + 1 + exitwhen sourceIndex == bj_MAX_PLAYER_SLOTS + endloop +endfunction + +//=========================================================================== +// Test to see if two players are co-allied (allied with each other). +// +function PlayersAreCoAllied takes player playerA, player playerB returns boolean + // Players are considered to be allied with themselves. + if (playerA == playerB) then + return true + endif + + // Co-allies are both allied with each other. + if GetPlayerAlliance(playerA, playerB, ALLIANCE_PASSIVE) then + if GetPlayerAlliance(playerB, playerA, ALLIANCE_PASSIVE) then + return true + endif + endif + return false +endfunction + +//=========================================================================== +// Force (whichPlayer) AI player to share vision and advanced unit control +// with all AI players of its allies. +// +function ShareEverythingWithTeamAI takes player whichPlayer returns nothing + local integer playerIndex + local player indexPlayer + + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if (PlayersAreCoAllied(whichPlayer, indexPlayer) and whichPlayer != indexPlayer) then + if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_VISION, true) + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_CONTROL, true) + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true) + endif + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Force (whichPlayer) to share vision and advanced unit control with all of his/her allies. +// +function ShareEverythingWithTeam takes player whichPlayer returns nothing + local integer playerIndex + local player indexPlayer + + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if (PlayersAreCoAllied(whichPlayer, indexPlayer) and whichPlayer != indexPlayer) then + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_VISION, true) + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_CONTROL, true) + call SetPlayerAlliance(indexPlayer, whichPlayer, ALLIANCE_SHARED_CONTROL, true) + call SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Creates a 'Neutral Victim' player slot. This slot is passive towards all +// other players, but all other players are aggressive towards him/her. +// +function ConfigureNeutralVictim takes nothing returns nothing + local integer index + local player indexPlayer + local player neutralVictim = Player(bj_PLAYER_NEUTRAL_VICTIM) + + set index = 0 + loop + set indexPlayer = Player(index) + + call SetPlayerAlliance(neutralVictim, indexPlayer, ALLIANCE_PASSIVE, true) + call SetPlayerAlliance(indexPlayer, neutralVictim, ALLIANCE_PASSIVE, false) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + // Neutral Victim and Neutral Aggressive should not fight each other. + set indexPlayer = Player(PLAYER_NEUTRAL_AGGRESSIVE) + call SetPlayerAlliance(neutralVictim, indexPlayer, ALLIANCE_PASSIVE, true) + call SetPlayerAlliance(indexPlayer, neutralVictim, ALLIANCE_PASSIVE, true) + + // Neutral Victim does not give bounties. + call SetPlayerState(neutralVictim, PLAYER_STATE_GIVES_BOUNTY, 0) +endfunction + +//=========================================================================== +function MakeUnitsPassiveForPlayerEnum takes nothing returns nothing + call SetUnitOwner(GetEnumUnit(), Player(bj_PLAYER_NEUTRAL_VICTIM), false) +endfunction + +//=========================================================================== +// Change ownership for every unit of (whichPlayer)'s team to neutral passive. +// +function MakeUnitsPassiveForPlayer takes player whichPlayer returns nothing + local group playerUnits = CreateGroup() + call CachePlayerHeroData(whichPlayer) + call GroupEnumUnitsOfPlayer(playerUnits, whichPlayer, null) + call ForGroup(playerUnits, function MakeUnitsPassiveForPlayerEnum) + call DestroyGroup(playerUnits) +endfunction + +//=========================================================================== +// Change ownership for every unit of (whichPlayer)'s team to neutral passive. +// +function MakeUnitsPassiveForTeam takes player whichPlayer returns nothing + local integer playerIndex + local player indexPlayer + + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if PlayersAreCoAllied(whichPlayer, indexPlayer) then + call MakeUnitsPassiveForPlayer(indexPlayer) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Determine whether or not victory/defeat is disabled via cheat codes. +// +function AllowVictoryDefeat takes playergameresult gameResult returns boolean + if (gameResult == PLAYER_GAME_RESULT_VICTORY) then + return not IsNoVictoryCheat() + endif + if (gameResult == PLAYER_GAME_RESULT_DEFEAT) then + return not IsNoDefeatCheat() + endif + if (gameResult == PLAYER_GAME_RESULT_NEUTRAL) then + return (not IsNoVictoryCheat()) and (not IsNoDefeatCheat()) + endif + return true +endfunction + +//=========================================================================== +function EndGameBJ takes nothing returns nothing + call EndGame( true ) +endfunction + +//=========================================================================== +function MeleeVictoryDialogBJ takes player whichPlayer, boolean leftGame returns nothing + local trigger t = CreateTrigger() + local dialog d = DialogCreate() + local string formatString + + // Display "player was victorious" or "player has left the game" message + if (leftGame) then + set formatString = GetLocalizedString( "PLAYER_LEFT_GAME" ) + else + set formatString = GetLocalizedString( "PLAYER_VICTORIOUS" ) + endif + + call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString) + + call DialogSetMessage( d, GetLocalizedString( "GAMEOVER_VICTORY_MSG" ) ) + call DialogAddButton( d, GetLocalizedString( "GAMEOVER_CONTINUE_GAME" ), GetLocalizedHotkey("GAMEOVER_CONTINUE_GAME") ) + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddQuitButton( d, true, GetLocalizedString( "GAMEOVER_QUIT_GAME" ), GetLocalizedHotkey("GAMEOVER_QUIT_GAME") ) ) + + call DialogDisplay( whichPlayer, d, true ) + call StartSoundForPlayerBJ( whichPlayer, bj_victoryDialogSound ) +endfunction + +//=========================================================================== +function MeleeDefeatDialogBJ takes player whichPlayer, boolean leftGame returns nothing + local trigger t = CreateTrigger() + local dialog d = DialogCreate() + local string formatString + + // Display "player was defeated" or "player has left the game" message + if (leftGame) then + set formatString = GetLocalizedString( "PLAYER_LEFT_GAME" ) + else + set formatString = GetLocalizedString( "PLAYER_DEFEATED" ) + endif + + call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString) + + call DialogSetMessage( d, GetLocalizedString( "GAMEOVER_DEFEAT_MSG" ) ) + + // Only show the continue button if the game is not over and observers on death are allowed + if (not bj_meleeGameOver and IsMapFlagSet(MAP_OBSERVERS_ON_DEATH)) then + call DialogAddButton( d, GetLocalizedString( "GAMEOVER_CONTINUE_OBSERVING" ), GetLocalizedHotkey("GAMEOVER_CONTINUE_OBSERVING") ) + endif + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddQuitButton( d, true, GetLocalizedString( "GAMEOVER_QUIT_GAME" ), GetLocalizedHotkey("GAMEOVER_QUIT_GAME") ) ) + + call DialogDisplay( whichPlayer, d, true ) + call StartSoundForPlayerBJ( whichPlayer, bj_defeatDialogSound ) +endfunction + +//=========================================================================== +function GameOverDialogBJ takes player whichPlayer, boolean leftGame returns nothing + local trigger t = CreateTrigger() + local dialog d = DialogCreate() + local string s + + // Display "player left the game" message + call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString( "PLAYER_LEFT_GAME" )) + + if (GetIntegerGameState(GAME_STATE_DISCONNECTED) != 0) then + set s = GetLocalizedString( "GAMEOVER_DISCONNECTED" ) + else + set s = GetLocalizedString( "GAMEOVER_GAME_OVER" ) + endif + + call DialogSetMessage( d, s ) + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddQuitButton( d, true, GetLocalizedString( "GAMEOVER_OK" ), GetLocalizedHotkey("GAMEOVER_OK") ) ) + + call DialogDisplay( whichPlayer, d, true ) + call StartSoundForPlayerBJ( whichPlayer, bj_defeatDialogSound ) +endfunction + +//=========================================================================== +function RemovePlayerPreserveUnitsBJ takes player whichPlayer, playergameresult gameResult, boolean leftGame returns nothing + if AllowVictoryDefeat(gameResult) then + + call RemovePlayer(whichPlayer, gameResult) + + if( gameResult == PLAYER_GAME_RESULT_VICTORY ) then + call MeleeVictoryDialogBJ( whichPlayer, leftGame ) + return + elseif( gameResult == PLAYER_GAME_RESULT_DEFEAT ) then + call MeleeDefeatDialogBJ( whichPlayer, leftGame ) + else + call GameOverDialogBJ( whichPlayer, leftGame ) + endif + + endif +endfunction + +//=========================================================================== +function CustomVictoryOkBJ takes nothing returns nothing + if bj_isSinglePlayer then + call PauseGame( false ) + // Bump the difficulty back up to the default. + call SetGameDifficulty(GetDefaultDifficulty()) + endif + + if (bj_changeLevelMapName == null) then + call EndGame( bj_changeLevelShowScores ) + else + call ChangeLevel( bj_changeLevelMapName, bj_changeLevelShowScores ) + endif +endfunction + +//=========================================================================== +function CustomVictoryQuitBJ takes nothing returns nothing + if bj_isSinglePlayer then + call PauseGame( false ) + // Bump the difficulty back up to the default. + call SetGameDifficulty(GetDefaultDifficulty()) + endif + + call EndGame( bj_changeLevelShowScores ) +endfunction + +//=========================================================================== +function CustomVictoryDialogBJ takes player whichPlayer returns nothing + local trigger t = CreateTrigger() + local dialog d = DialogCreate() + + call DialogSetMessage( d, GetLocalizedString( "GAMEOVER_VICTORY_MSG" ) ) + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_CONTINUE" ), GetLocalizedHotkey("GAMEOVER_CONTINUE") ) ) + call TriggerAddAction( t, function CustomVictoryOkBJ ) + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_QUIT_MISSION" ), GetLocalizedHotkey("GAMEOVER_QUIT_MISSION") ) ) + call TriggerAddAction( t, function CustomVictoryQuitBJ ) + + if (GetLocalPlayer() == whichPlayer) then + call EnableUserControl( true ) + if bj_isSinglePlayer then + call PauseGame( true ) + endif + call EnableUserUI(false) + endif + + call DialogDisplay( whichPlayer, d, true ) + call VolumeGroupSetVolumeForPlayerBJ( whichPlayer, SOUND_VOLUMEGROUP_UI, 1.0 ) + call StartSoundForPlayerBJ( whichPlayer, bj_victoryDialogSound ) +endfunction + +//=========================================================================== +function CustomVictorySkipBJ takes player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + if bj_isSinglePlayer then + // Bump the difficulty back up to the default. + call SetGameDifficulty(GetDefaultDifficulty()) + endif + + if (bj_changeLevelMapName == null) then + call EndGame( bj_changeLevelShowScores ) + else + call ChangeLevel( bj_changeLevelMapName, bj_changeLevelShowScores ) + endif + endif +endfunction + +//=========================================================================== +function CustomVictoryBJ takes player whichPlayer, boolean showDialog, boolean showScores returns nothing + if AllowVictoryDefeat( PLAYER_GAME_RESULT_VICTORY ) then + call RemovePlayer( whichPlayer, PLAYER_GAME_RESULT_VICTORY ) + + if not bj_isSinglePlayer then + call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString( "PLAYER_VICTORIOUS" ) ) + endif + + // UI only needs to be displayed to users. + if (GetPlayerController(whichPlayer) == MAP_CONTROL_USER) then + set bj_changeLevelShowScores = showScores + if showDialog then + call CustomVictoryDialogBJ( whichPlayer ) + else + call CustomVictorySkipBJ( whichPlayer ) + endif + endif + endif +endfunction + +//=========================================================================== +function CustomDefeatRestartBJ takes nothing returns nothing + call PauseGame( false ) + call RestartGame( true ) +endfunction + +//=========================================================================== +function CustomDefeatReduceDifficultyBJ takes nothing returns nothing + local gamedifficulty diff = GetGameDifficulty() + + call PauseGame( false ) + + // Knock the difficulty down, if possible. + if (diff == MAP_DIFFICULTY_EASY) then + // Sorry, but it doesn't get any easier than this. + elseif (diff == MAP_DIFFICULTY_NORMAL) then + call SetGameDifficulty(MAP_DIFFICULTY_EASY) + elseif (diff == MAP_DIFFICULTY_HARD) then + call SetGameDifficulty(MAP_DIFFICULTY_NORMAL) + else + // Unrecognized difficulty + endif + + call RestartGame( true ) +endfunction + +//=========================================================================== +function CustomDefeatLoadBJ takes nothing returns nothing + call PauseGame( false ) + call DisplayLoadDialog() +endfunction + +//=========================================================================== +function CustomDefeatQuitBJ takes nothing returns nothing + if bj_isSinglePlayer then + call PauseGame( false ) + endif + + // Bump the difficulty back up to the default. + call SetGameDifficulty(GetDefaultDifficulty()) + call EndGame( true ) +endfunction + +//=========================================================================== +function CustomDefeatDialogBJ takes player whichPlayer, string message returns nothing + local trigger t = CreateTrigger() + local dialog d = DialogCreate() + + call DialogSetMessage( d, message ) + + if bj_isSinglePlayer then + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_LOAD" ), GetLocalizedHotkey("GAMEOVER_LOAD") ) ) + call TriggerAddAction( t, function CustomDefeatLoadBJ ) + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_RESTART" ), GetLocalizedHotkey("GAMEOVER_RESTART") ) ) + call TriggerAddAction( t, function CustomDefeatRestartBJ ) + + if (GetGameDifficulty() != MAP_DIFFICULTY_EASY) then + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_REDUCE_DIFFICULTY" ), GetLocalizedHotkey("GAMEOVER_REDUCE_DIFFICULTY") ) ) + call TriggerAddAction( t, function CustomDefeatReduceDifficultyBJ ) + endif + endif + + set t = CreateTrigger() + call TriggerRegisterDialogButtonEvent( t, DialogAddButton( d, GetLocalizedString( "GAMEOVER_QUIT_MISSION" ), GetLocalizedHotkey("GAMEOVER_QUIT_MISSION") ) ) + call TriggerAddAction( t, function CustomDefeatQuitBJ ) + + if (GetLocalPlayer() == whichPlayer) then + call EnableUserControl( true ) + if bj_isSinglePlayer then + call PauseGame( true ) + endif + call EnableUserUI(false) + endif + + call DialogDisplay( whichPlayer, d, true ) + call VolumeGroupSetVolumeForPlayerBJ( whichPlayer, SOUND_VOLUMEGROUP_UI, 1.0 ) + call StartSoundForPlayerBJ( whichPlayer, bj_defeatDialogSound ) +endfunction + +//=========================================================================== +function CustomDefeatBJ takes player whichPlayer, string message returns nothing + if AllowVictoryDefeat( PLAYER_GAME_RESULT_DEFEAT ) then + call RemovePlayer( whichPlayer, PLAYER_GAME_RESULT_DEFEAT ) + + if not bj_isSinglePlayer then + call DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString( "PLAYER_DEFEATED" ) ) + endif + + // UI only needs to be displayed to users. + if (GetPlayerController(whichPlayer) == MAP_CONTROL_USER) then + call CustomDefeatDialogBJ( whichPlayer, message ) + endif + endif +endfunction + +//=========================================================================== +function SetNextLevelBJ takes string nextLevel returns nothing + if (nextLevel == "") then + set bj_changeLevelMapName = null + else + set bj_changeLevelMapName = nextLevel + endif +endfunction + +//=========================================================================== +function SetPlayerOnScoreScreenBJ takes boolean flag, player whichPlayer returns nothing + call SetPlayerOnScoreScreen(whichPlayer, flag) +endfunction + + + +//*************************************************************************** +//* +//* Quest Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function CreateQuestBJ takes integer questType, string title, string description, string iconPath returns quest + local boolean required = (questType == bj_QUESTTYPE_REQ_DISCOVERED) or (questType == bj_QUESTTYPE_REQ_UNDISCOVERED) + local boolean discovered = (questType == bj_QUESTTYPE_REQ_DISCOVERED) or (questType == bj_QUESTTYPE_OPT_DISCOVERED) + + set bj_lastCreatedQuest = CreateQuest() + call QuestSetTitle(bj_lastCreatedQuest, title) + call QuestSetDescription(bj_lastCreatedQuest, description) + call QuestSetIconPath(bj_lastCreatedQuest, iconPath) + call QuestSetRequired(bj_lastCreatedQuest, required) + call QuestSetDiscovered(bj_lastCreatedQuest, discovered) + call QuestSetCompleted(bj_lastCreatedQuest, false) + return bj_lastCreatedQuest +endfunction + +//=========================================================================== +function DestroyQuestBJ takes quest whichQuest returns nothing + call DestroyQuest(whichQuest) +endfunction + +//=========================================================================== +function QuestSetEnabledBJ takes boolean enabled, quest whichQuest returns nothing + call QuestSetEnabled(whichQuest, enabled) +endfunction + +//=========================================================================== +function QuestSetTitleBJ takes quest whichQuest, string title returns nothing + call QuestSetTitle(whichQuest, title) +endfunction + +//=========================================================================== +function QuestSetDescriptionBJ takes quest whichQuest, string description returns nothing + call QuestSetDescription(whichQuest, description) +endfunction + +//=========================================================================== +function QuestSetCompletedBJ takes quest whichQuest, boolean completed returns nothing + call QuestSetCompleted(whichQuest, completed) +endfunction + +//=========================================================================== +function QuestSetFailedBJ takes quest whichQuest, boolean failed returns nothing + call QuestSetFailed(whichQuest, failed) +endfunction + +//=========================================================================== +function QuestSetDiscoveredBJ takes quest whichQuest, boolean discovered returns nothing + call QuestSetDiscovered(whichQuest, discovered) +endfunction + +//=========================================================================== +function GetLastCreatedQuestBJ takes nothing returns quest + return bj_lastCreatedQuest +endfunction + +//=========================================================================== +function CreateQuestItemBJ takes quest whichQuest, string description returns questitem + set bj_lastCreatedQuestItem = QuestCreateItem(whichQuest) + call QuestItemSetDescription(bj_lastCreatedQuestItem, description) + call QuestItemSetCompleted(bj_lastCreatedQuestItem, false) + return bj_lastCreatedQuestItem +endfunction + +//=========================================================================== +function QuestItemSetDescriptionBJ takes questitem whichQuestItem, string description returns nothing + call QuestItemSetDescription(whichQuestItem, description) +endfunction + +//=========================================================================== +function QuestItemSetCompletedBJ takes questitem whichQuestItem, boolean completed returns nothing + call QuestItemSetCompleted(whichQuestItem, completed) +endfunction + +//=========================================================================== +function GetLastCreatedQuestItemBJ takes nothing returns questitem + return bj_lastCreatedQuestItem +endfunction + +//=========================================================================== +function CreateDefeatConditionBJ takes string description returns defeatcondition + set bj_lastCreatedDefeatCondition = CreateDefeatCondition() + call DefeatConditionSetDescription(bj_lastCreatedDefeatCondition, description) + return bj_lastCreatedDefeatCondition +endfunction + +//=========================================================================== +function DestroyDefeatConditionBJ takes defeatcondition whichCondition returns nothing + call DestroyDefeatCondition(whichCondition) +endfunction + +//=========================================================================== +function DefeatConditionSetDescriptionBJ takes defeatcondition whichCondition, string description returns nothing + call DefeatConditionSetDescription(whichCondition, description) +endfunction + +//=========================================================================== +function GetLastCreatedDefeatConditionBJ takes nothing returns defeatcondition + return bj_lastCreatedDefeatCondition +endfunction + +//=========================================================================== +function FlashQuestDialogButtonBJ takes nothing returns nothing + call FlashQuestDialogButton() +endfunction + +//=========================================================================== +function QuestMessageBJ takes force f, integer messageType, string message returns nothing + if (IsPlayerInForce(GetLocalPlayer(), f)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + if (messageType == bj_QUESTMESSAGE_DISCOVERED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUEST, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUEST, message) + call StartSound(bj_questDiscoveredSound) + call FlashQuestDialogButton() + + elseif (messageType == bj_QUESTMESSAGE_UPDATED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTUPDATE, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTUPDATE, message) + call StartSound(bj_questUpdatedSound) + call FlashQuestDialogButton() + + elseif (messageType == bj_QUESTMESSAGE_COMPLETED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTDONE, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTDONE, message) + call StartSound(bj_questCompletedSound) + call FlashQuestDialogButton() + + elseif (messageType == bj_QUESTMESSAGE_FAILED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTFAILED, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTFAILED, message) + call StartSound(bj_questFailedSound) + call FlashQuestDialogButton() + + elseif (messageType == bj_QUESTMESSAGE_REQUIREMENT) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTREQUIREMENT, message) + + elseif (messageType == bj_QUESTMESSAGE_MISSIONFAILED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_MISSIONFAILED, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_MISSIONFAILED, message) + call StartSound(bj_questFailedSound) + + elseif (messageType == bj_QUESTMESSAGE_HINT) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_HINT, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_HINT, message) + call StartSound(bj_questHintSound) + + elseif (messageType == bj_QUESTMESSAGE_ALWAYSHINT) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ALWAYSHINT, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ALWAYSHINT, message) + call StartSound(bj_questHintSound) + + elseif (messageType == bj_QUESTMESSAGE_SECRET) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, message) + call StartSound(bj_questSecretSound) + + elseif (messageType == bj_QUESTMESSAGE_UNITACQUIRED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITACQUIRED, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITACQUIRED, message) + call StartSound(bj_questHintSound) + + elseif (messageType == bj_QUESTMESSAGE_UNITAVAILABLE) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITAVAILABLE, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITAVAILABLE, message) + call StartSound(bj_questHintSound) + + elseif (messageType == bj_QUESTMESSAGE_ITEMACQUIRED) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ITEMACQUIRED, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ITEMACQUIRED, message) + call StartSound(bj_questItemAcquiredSound) + + elseif (messageType == bj_QUESTMESSAGE_WARNING) then + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_WARNING, " ") + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_WARNING, message) + call StartSound(bj_questWarningSound) + + else + // Unrecognized message type - ignore the request. + endif + endif +endfunction + + + +//*************************************************************************** +//* +//* Timer Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function StartTimerBJ takes timer t, boolean periodic, real timeout returns timer + set bj_lastStartedTimer = t + call TimerStart(t, timeout, periodic, null) + return bj_lastStartedTimer +endfunction + +//=========================================================================== +function CreateTimerBJ takes boolean periodic, real timeout returns timer + set bj_lastStartedTimer = CreateTimer() + call TimerStart(bj_lastStartedTimer, timeout, periodic, null) + return bj_lastStartedTimer +endfunction + +//=========================================================================== +function DestroyTimerBJ takes timer whichTimer returns nothing + call DestroyTimer(whichTimer) +endfunction + +//=========================================================================== +function PauseTimerBJ takes boolean pause, timer whichTimer returns nothing + if pause then + call PauseTimer(whichTimer) + else + call ResumeTimer(whichTimer) + endif +endfunction + +//=========================================================================== +function GetLastCreatedTimerBJ takes nothing returns timer + return bj_lastStartedTimer +endfunction + +//=========================================================================== +function CreateTimerDialogBJ takes timer t, string title returns timerdialog + set bj_lastCreatedTimerDialog = CreateTimerDialog(t) + call TimerDialogSetTitle(bj_lastCreatedTimerDialog, title) + call TimerDialogDisplay(bj_lastCreatedTimerDialog, true) + return bj_lastCreatedTimerDialog +endfunction + +//=========================================================================== +function DestroyTimerDialogBJ takes timerdialog td returns nothing + call DestroyTimerDialog(td) +endfunction + +//=========================================================================== +function TimerDialogSetTitleBJ takes timerdialog td, string title returns nothing + call TimerDialogSetTitle(td, title) +endfunction + +//=========================================================================== +function TimerDialogSetTitleColorBJ takes timerdialog td, real red, real green, real blue, real transparency returns nothing + call TimerDialogSetTitleColor(td, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function TimerDialogSetTimeColorBJ takes timerdialog td, real red, real green, real blue, real transparency returns nothing + call TimerDialogSetTimeColor(td, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function TimerDialogSetSpeedBJ takes timerdialog td, real speedMultFactor returns nothing + call TimerDialogSetSpeed(td, speedMultFactor) +endfunction + +//=========================================================================== +function TimerDialogDisplayForPlayerBJ takes boolean show, timerdialog td, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call TimerDialogDisplay(td, show) + endif +endfunction + +//=========================================================================== +function TimerDialogDisplayBJ takes boolean show, timerdialog td returns nothing + call TimerDialogDisplay(td, show) +endfunction + +//=========================================================================== +function GetLastCreatedTimerDialogBJ takes nothing returns timerdialog + return bj_lastCreatedTimerDialog +endfunction + + + +//*************************************************************************** +//* +//* Leaderboard Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function LeaderboardResizeBJ takes leaderboard lb returns nothing + local integer size = LeaderboardGetItemCount(lb) + + if (LeaderboardGetLabelText(lb) == "") then + set size = size - 1 + endif + call LeaderboardSetSizeByItemCount(lb, size) +endfunction + +//=========================================================================== +function LeaderboardSetPlayerItemValueBJ takes player whichPlayer, leaderboard lb, integer val returns nothing + call LeaderboardSetItemValue(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), val) +endfunction + +//=========================================================================== +function LeaderboardSetPlayerItemLabelBJ takes player whichPlayer, leaderboard lb, string val returns nothing + call LeaderboardSetItemLabel(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), val) +endfunction + +//=========================================================================== +function LeaderboardSetPlayerItemStyleBJ takes player whichPlayer, leaderboard lb, boolean showLabel, boolean showValue, boolean showIcon returns nothing + call LeaderboardSetItemStyle(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), showLabel, showValue, showIcon) +endfunction + +//=========================================================================== +function LeaderboardSetPlayerItemLabelColorBJ takes player whichPlayer, leaderboard lb, real red, real green, real blue, real transparency returns nothing + call LeaderboardSetItemLabelColor(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function LeaderboardSetPlayerItemValueColorBJ takes player whichPlayer, leaderboard lb, real red, real green, real blue, real transparency returns nothing + call LeaderboardSetItemValueColor(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function LeaderboardSetLabelColorBJ takes leaderboard lb, real red, real green, real blue, real transparency returns nothing + call LeaderboardSetLabelColor(lb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function LeaderboardSetValueColorBJ takes leaderboard lb, real red, real green, real blue, real transparency returns nothing + call LeaderboardSetValueColor(lb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function LeaderboardSetLabelBJ takes leaderboard lb, string label returns nothing + call LeaderboardSetLabel(lb, label) + call LeaderboardResizeBJ(lb) +endfunction + +//=========================================================================== +function LeaderboardSetStyleBJ takes leaderboard lb, boolean showLabel, boolean showNames, boolean showValues, boolean showIcons returns nothing + call LeaderboardSetStyle(lb, showLabel, showNames, showValues, showIcons) +endfunction + +//=========================================================================== +function LeaderboardGetItemCountBJ takes leaderboard lb returns integer + return LeaderboardGetItemCount(lb) +endfunction + +//=========================================================================== +function LeaderboardHasPlayerItemBJ takes leaderboard lb, player whichPlayer returns boolean + return LeaderboardHasPlayerItem(lb, whichPlayer) +endfunction + +//=========================================================================== +function ForceSetLeaderboardBJ takes leaderboard lb, force toForce returns nothing + local integer index + local player indexPlayer + + set index = 0 + loop + set indexPlayer = Player(index) + if IsPlayerInForce(indexPlayer, toForce) then + call PlayerSetLeaderboard(indexPlayer, lb) + endif + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +function CreateLeaderboardBJ takes force toForce, string label returns leaderboard + set bj_lastCreatedLeaderboard = CreateLeaderboard() + call LeaderboardSetLabel(bj_lastCreatedLeaderboard, label) + call ForceSetLeaderboardBJ(bj_lastCreatedLeaderboard, toForce) + call LeaderboardDisplay(bj_lastCreatedLeaderboard, true) + return bj_lastCreatedLeaderboard +endfunction + +//=========================================================================== +function DestroyLeaderboardBJ takes leaderboard lb returns nothing + call DestroyLeaderboard(lb) +endfunction + +//=========================================================================== +function LeaderboardDisplayBJ takes boolean show, leaderboard lb returns nothing + call LeaderboardDisplay(lb, show) +endfunction + +//=========================================================================== +function LeaderboardAddItemBJ takes player whichPlayer, leaderboard lb, string label, integer value returns nothing + if (LeaderboardHasPlayerItem(lb, whichPlayer)) then + call LeaderboardRemovePlayerItem(lb, whichPlayer) + endif + call LeaderboardAddItem(lb, label, value, whichPlayer) + call LeaderboardResizeBJ(lb) + //call LeaderboardSetSizeByItemCount(lb, LeaderboardGetItemCount(lb)) +endfunction + +//=========================================================================== +function LeaderboardRemovePlayerItemBJ takes player whichPlayer, leaderboard lb returns nothing + call LeaderboardRemovePlayerItem(lb, whichPlayer) + call LeaderboardResizeBJ(lb) +endfunction + +//=========================================================================== +function LeaderboardSortItemsBJ takes leaderboard lb, integer sortType, boolean ascending returns nothing + if (sortType == bj_SORTTYPE_SORTBYVALUE) then + call LeaderboardSortItemsByValue(lb, ascending) + elseif (sortType == bj_SORTTYPE_SORTBYPLAYER) then + call LeaderboardSortItemsByPlayer(lb, ascending) + elseif (sortType == bj_SORTTYPE_SORTBYLABEL) then + call LeaderboardSortItemsByLabel(lb, ascending) + else + // Unrecognized sort type - ignore the request. + endif +endfunction + +//=========================================================================== +function LeaderboardSortItemsByPlayerBJ takes leaderboard lb, boolean ascending returns nothing + call LeaderboardSortItemsByPlayer(lb, ascending) +endfunction + +//=========================================================================== +function LeaderboardSortItemsByLabelBJ takes leaderboard lb, boolean ascending returns nothing + call LeaderboardSortItemsByLabel(lb, ascending) +endfunction + +//=========================================================================== +function LeaderboardGetPlayerIndexBJ takes player whichPlayer, leaderboard lb returns integer + return LeaderboardGetPlayerIndex(lb, whichPlayer) + 1 +endfunction + +//=========================================================================== +// Returns the player who is occupying a specified position in a leaderboard. +// The position parameter is expected in the range of 1..16. +// +function LeaderboardGetIndexedPlayerBJ takes integer position, leaderboard lb returns player + local integer index + local player indexPlayer + + set index = 0 + loop + set indexPlayer = Player(index) + if (LeaderboardGetPlayerIndex(lb, indexPlayer) == position - 1) then + return indexPlayer + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + return Player(PLAYER_NEUTRAL_PASSIVE) +endfunction + +//=========================================================================== +function PlayerGetLeaderboardBJ takes player whichPlayer returns leaderboard + return PlayerGetLeaderboard(whichPlayer) +endfunction + +//=========================================================================== +function GetLastCreatedLeaderboard takes nothing returns leaderboard + return bj_lastCreatedLeaderboard +endfunction + +//*************************************************************************** +//* +//* Multiboard Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function CreateMultiboardBJ takes integer cols, integer rows, string title returns multiboard + set bj_lastCreatedMultiboard = CreateMultiboard() + call MultiboardSetRowCount(bj_lastCreatedMultiboard, rows) + call MultiboardSetColumnCount(bj_lastCreatedMultiboard, cols) + call MultiboardSetTitleText(bj_lastCreatedMultiboard, title) + call MultiboardDisplay(bj_lastCreatedMultiboard, true) + return bj_lastCreatedMultiboard +endfunction + +//=========================================================================== +function DestroyMultiboardBJ takes multiboard mb returns nothing + call DestroyMultiboard(mb) +endfunction + +//=========================================================================== +function GetLastCreatedMultiboard takes nothing returns multiboard + return bj_lastCreatedMultiboard +endfunction + +//=========================================================================== +function MultiboardDisplayBJ takes boolean show, multiboard mb returns nothing + call MultiboardDisplay(mb, show) +endfunction + +//=========================================================================== +function MultiboardMinimizeBJ takes boolean minimize, multiboard mb returns nothing + call MultiboardMinimize(mb, minimize) +endfunction + +//=========================================================================== +function MultiboardSetTitleTextColorBJ takes multiboard mb, real red, real green, real blue, real transparency returns nothing + call MultiboardSetTitleTextColor(mb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function MultiboardAllowDisplayBJ takes boolean flag returns nothing + call MultiboardSuppressDisplay(not flag) +endfunction + +//=========================================================================== +function MultiboardSetItemStyleBJ takes multiboard mb, integer col, integer row, boolean showValue, boolean showIcon returns nothing + local integer curRow = 0 + local integer curCol = 0 + local integer numRows = MultiboardGetRowCount(mb) + local integer numCols = MultiboardGetColumnCount(mb) + local multiboarditem mbitem = null + + // Loop over rows, using 1-based index + loop + set curRow = curRow + 1 + exitwhen curRow > numRows + + // Apply setting to the requested row, or all rows (if row is 0) + if (row == 0 or row == curRow) then + // Loop over columns, using 1-based index + set curCol = 0 + loop + set curCol = curCol + 1 + exitwhen curCol > numCols + + // Apply setting to the requested column, or all columns (if col is 0) + if (col == 0 or col == curCol) then + set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1) + call MultiboardSetItemStyle(mbitem, showValue, showIcon) + call MultiboardReleaseItem(mbitem) + endif + endloop + endif + endloop +endfunction + +//=========================================================================== +function MultiboardSetItemValueBJ takes multiboard mb, integer col, integer row, string val returns nothing + local integer curRow = 0 + local integer curCol = 0 + local integer numRows = MultiboardGetRowCount(mb) + local integer numCols = MultiboardGetColumnCount(mb) + local multiboarditem mbitem = null + + // Loop over rows, using 1-based index + loop + set curRow = curRow + 1 + exitwhen curRow > numRows + + // Apply setting to the requested row, or all rows (if row is 0) + if (row == 0 or row == curRow) then + // Loop over columns, using 1-based index + set curCol = 0 + loop + set curCol = curCol + 1 + exitwhen curCol > numCols + + // Apply setting to the requested column, or all columns (if col is 0) + if (col == 0 or col == curCol) then + set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1) + call MultiboardSetItemValue(mbitem, val) + call MultiboardReleaseItem(mbitem) + endif + endloop + endif + endloop +endfunction + +//=========================================================================== +function MultiboardSetItemColorBJ takes multiboard mb, integer col, integer row, real red, real green, real blue, real transparency returns nothing + local integer curRow = 0 + local integer curCol = 0 + local integer numRows = MultiboardGetRowCount(mb) + local integer numCols = MultiboardGetColumnCount(mb) + local multiboarditem mbitem = null + + // Loop over rows, using 1-based index + loop + set curRow = curRow + 1 + exitwhen curRow > numRows + + // Apply setting to the requested row, or all rows (if row is 0) + if (row == 0 or row == curRow) then + // Loop over columns, using 1-based index + set curCol = 0 + loop + set curCol = curCol + 1 + exitwhen curCol > numCols + + // Apply setting to the requested column, or all columns (if col is 0) + if (col == 0 or col == curCol) then + set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1) + call MultiboardSetItemValueColor(mbitem, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) + call MultiboardReleaseItem(mbitem) + endif + endloop + endif + endloop +endfunction + +//=========================================================================== +function MultiboardSetItemWidthBJ takes multiboard mb, integer col, integer row, real width returns nothing + local integer curRow = 0 + local integer curCol = 0 + local integer numRows = MultiboardGetRowCount(mb) + local integer numCols = MultiboardGetColumnCount(mb) + local multiboarditem mbitem = null + + // Loop over rows, using 1-based index + loop + set curRow = curRow + 1 + exitwhen curRow > numRows + + // Apply setting to the requested row, or all rows (if row is 0) + if (row == 0 or row == curRow) then + // Loop over columns, using 1-based index + set curCol = 0 + loop + set curCol = curCol + 1 + exitwhen curCol > numCols + + // Apply setting to the requested column, or all columns (if col is 0) + if (col == 0 or col == curCol) then + set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1) + call MultiboardSetItemWidth(mbitem, width/100.0) + call MultiboardReleaseItem(mbitem) + endif + endloop + endif + endloop +endfunction + +//=========================================================================== +function MultiboardSetItemIconBJ takes multiboard mb, integer col, integer row, string iconFileName returns nothing + local integer curRow = 0 + local integer curCol = 0 + local integer numRows = MultiboardGetRowCount(mb) + local integer numCols = MultiboardGetColumnCount(mb) + local multiboarditem mbitem = null + + // Loop over rows, using 1-based index + loop + set curRow = curRow + 1 + exitwhen curRow > numRows + + // Apply setting to the requested row, or all rows (if row is 0) + if (row == 0 or row == curRow) then + // Loop over columns, using 1-based index + set curCol = 0 + loop + set curCol = curCol + 1 + exitwhen curCol > numCols + + // Apply setting to the requested column, or all columns (if col is 0) + if (col == 0 or col == curCol) then + set mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1) + call MultiboardSetItemIcon(mbitem, iconFileName) + call MultiboardReleaseItem(mbitem) + endif + endloop + endif + endloop +endfunction + + + +//*************************************************************************** +//* +//* Text Tag Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +// Scale the font size linearly such that size 10 equates to height 0.023. +// Screen-relative font heights are harder to grasp and than font sizes. +// +function TextTagSize2Height takes real size returns real + return size * 0.023 / 10 +endfunction + +//=========================================================================== +// Scale the speed linearly such that speed 128 equates to 0.071. +// Screen-relative speeds are hard to grasp. +// +function TextTagSpeed2Velocity takes real speed returns real + return speed * 0.071 / 128 +endfunction + +//=========================================================================== +function SetTextTagColorBJ takes texttag tt, real red, real green, real blue, real transparency returns nothing + call SetTextTagColor(tt, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-transparency)) +endfunction + +//=========================================================================== +function SetTextTagVelocityBJ takes texttag tt, real speed, real angle returns nothing + local real vel = TextTagSpeed2Velocity(speed) + local real xvel = vel * Cos(angle * bj_DEGTORAD) + local real yvel = vel * Sin(angle * bj_DEGTORAD) + + call SetTextTagVelocity(tt, xvel, yvel) +endfunction + +//=========================================================================== +function SetTextTagTextBJ takes texttag tt, string s, real size returns nothing + local real textHeight = TextTagSize2Height(size) + + call SetTextTagText(tt, s, textHeight) +endfunction + +//=========================================================================== +function SetTextTagPosBJ takes texttag tt, location loc, real zOffset returns nothing + call SetTextTagPos(tt, GetLocationX(loc), GetLocationY(loc), zOffset) +endfunction + +//=========================================================================== +function SetTextTagPosUnitBJ takes texttag tt, unit whichUnit, real zOffset returns nothing + call SetTextTagPosUnit(tt, whichUnit, zOffset) +endfunction + +//=========================================================================== +function SetTextTagSuspendedBJ takes texttag tt, boolean flag returns nothing + call SetTextTagSuspended(tt, flag) +endfunction + +//=========================================================================== +function SetTextTagPermanentBJ takes texttag tt, boolean flag returns nothing + call SetTextTagPermanent(tt, flag) +endfunction + +//=========================================================================== +function SetTextTagAgeBJ takes texttag tt, real age returns nothing + call SetTextTagAge(tt, age) +endfunction + +//=========================================================================== +function SetTextTagLifespanBJ takes texttag tt, real lifespan returns nothing + call SetTextTagLifespan(tt, lifespan) +endfunction + +//=========================================================================== +function SetTextTagFadepointBJ takes texttag tt, real fadepoint returns nothing + call SetTextTagFadepoint(tt, fadepoint) +endfunction + +//=========================================================================== +function CreateTextTagLocBJ takes string s, location loc, real zOffset, real size, real red, real green, real blue, real transparency returns texttag + set bj_lastCreatedTextTag = CreateTextTag() + call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size) + call SetTextTagPosBJ(bj_lastCreatedTextTag, loc, zOffset) + call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency) + + return bj_lastCreatedTextTag +endfunction + +//=========================================================================== +function CreateTextTagUnitBJ takes string s, unit whichUnit, real zOffset, real size, real red, real green, real blue, real transparency returns texttag + set bj_lastCreatedTextTag = CreateTextTag() + call SetTextTagTextBJ(bj_lastCreatedTextTag, s, size) + call SetTextTagPosUnitBJ(bj_lastCreatedTextTag, whichUnit, zOffset) + call SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency) + + return bj_lastCreatedTextTag +endfunction + +//=========================================================================== +function DestroyTextTagBJ takes texttag tt returns nothing + call DestroyTextTag(tt) +endfunction + +//=========================================================================== +function ShowTextTagForceBJ takes boolean show, texttag tt, force whichForce returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call SetTextTagVisibility(tt, show) + endif +endfunction + +//=========================================================================== +function GetLastCreatedTextTag takes nothing returns texttag + return bj_lastCreatedTextTag +endfunction + + + +//*************************************************************************** +//* +//* Cinematic Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function PauseGameOn takes nothing returns nothing + call PauseGame(true) +endfunction + +//=========================================================================== +function PauseGameOff takes nothing returns nothing + call PauseGame(false) +endfunction + +//=========================================================================== +function SetUserControlForceOn takes force whichForce returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call EnableUserControl(true) + endif +endfunction + +//=========================================================================== +function SetUserControlForceOff takes force whichForce returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call EnableUserControl(false) + endif +endfunction + +//=========================================================================== +function ShowInterfaceForceOn takes force whichForce, real fadeDuration returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ShowInterface(true, fadeDuration) + endif +endfunction + +//=========================================================================== +function ShowInterfaceForceOff takes force whichForce, real fadeDuration returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ShowInterface(false, fadeDuration) + endif +endfunction + +//=========================================================================== +function PingMinimapForForce takes force whichForce, real x, real y, real duration returns nothing + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PingMinimap(x, y, duration) + //call StartSound(bj_pingMinimapSound) + endif +endfunction + +//=========================================================================== +function PingMinimapLocForForce takes force whichForce, location loc, real duration returns nothing + call PingMinimapForForce(whichForce, GetLocationX(loc), GetLocationY(loc), duration) +endfunction + +//=========================================================================== +function PingMinimapForPlayer takes player whichPlayer, real x, real y, real duration returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call PingMinimap(x, y, duration) + //call StartSound(bj_pingMinimapSound) + endif +endfunction + +//=========================================================================== +function PingMinimapLocForPlayer takes player whichPlayer, location loc, real duration returns nothing + call PingMinimapForPlayer(whichPlayer, GetLocationX(loc), GetLocationY(loc), duration) +endfunction + +//=========================================================================== +function PingMinimapForForceEx takes force whichForce, real x, real y, real duration, integer style, real red, real green, real blue returns nothing + local integer red255 = PercentTo255(red) + local integer green255 = PercentTo255(green) + local integer blue255 = PercentTo255(blue) + + if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + // Prevent 100% red simple and flashy pings, as they become "attack" pings. + if (red255 == 255) and (green255 == 0) and (blue255 == 0) then + set red255 = 254 + endif + + if (style == bj_MINIMAPPINGSTYLE_SIMPLE) then + call PingMinimapEx(x, y, duration, red255, green255, blue255, false) + elseif (style == bj_MINIMAPPINGSTYLE_FLASHY) then + call PingMinimapEx(x, y, duration, red255, green255, blue255, true) + elseif (style == bj_MINIMAPPINGSTYLE_ATTACK) then + call PingMinimapEx(x, y, duration, 255, 0, 0, false) + else + // Unrecognized ping style - ignore the request. + endif + + //call StartSound(bj_pingMinimapSound) + endif +endfunction + +//=========================================================================== +function PingMinimapLocForForceEx takes force whichForce, location loc, real duration, integer style, real red, real green, real blue returns nothing + call PingMinimapForForceEx(whichForce, GetLocationX(loc), GetLocationY(loc), duration, style, red, green, blue) +endfunction + +//=========================================================================== +function EnableWorldFogBoundaryBJ takes boolean enable, force f returns nothing + if (IsPlayerInForce(GetLocalPlayer(), f)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call EnableWorldFogBoundary(enable) + endif +endfunction + +//=========================================================================== +function EnableOcclusionBJ takes boolean enable, force f returns nothing + if (IsPlayerInForce(GetLocalPlayer(), f)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call EnableOcclusion(enable) + endif +endfunction + + + +//*************************************************************************** +//* +//* Cinematic Transmission Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +// If cancelled, stop the sound and end the cinematic scene. +// +function CancelCineSceneBJ takes nothing returns nothing + call StopSoundBJ(bj_cineSceneLastSound, true) + call EndCinematicScene() +endfunction + +//=========================================================================== +// Init a trigger to listen for END_CINEMATIC events and respond to them if +// a cinematic scene is in progress. For performance reasons, this should +// only be called once a cinematic scene has been started, so that maps +// lacking such scenes do not bother to register for these events. +// +function TryInitCinematicBehaviorBJ takes nothing returns nothing + local integer index + + if (bj_cineSceneBeingSkipped == null) then + set bj_cineSceneBeingSkipped = CreateTrigger() + set index = 0 + loop + call TriggerRegisterPlayerEvent(bj_cineSceneBeingSkipped, Player(index), EVENT_PLAYER_END_CINEMATIC) + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + call TriggerAddAction(bj_cineSceneBeingSkipped, function CancelCineSceneBJ) + endif +endfunction + +//=========================================================================== +function SetCinematicSceneBJ takes sound soundHandle, integer portraitUnitId, playercolor color, string speakerTitle, string text, real sceneDuration, real voiceoverDuration returns nothing + set bj_cineSceneLastSound = soundHandle + call SetCinematicScene(portraitUnitId, color, speakerTitle, text, sceneDuration, voiceoverDuration) + call PlaySoundBJ(soundHandle) +endfunction + +//=========================================================================== +function GetTransmissionDuration takes sound soundHandle, integer timeType, real timeVal returns real + local real duration + + if (timeType == bj_TIMETYPE_ADD) then + set duration = GetSoundDurationBJ(soundHandle) + timeVal + elseif (timeType == bj_TIMETYPE_SET) then + set duration = timeVal + elseif (timeType == bj_TIMETYPE_SUB) then + set duration = GetSoundDurationBJ(soundHandle) - timeVal + else + // Unrecognized timeType - ignore timeVal. + set duration = GetSoundDurationBJ(soundHandle) + endif + + // Make sure we have a non-negative duration. + if (duration < 0) then + set duration = 0 + endif + return duration +endfunction + +//=========================================================================== +function WaitTransmissionDuration takes sound soundHandle, integer timeType, real timeVal returns nothing + if (timeType == bj_TIMETYPE_SET) then + // If we have a static duration wait, just perform the wait. + call TriggerSleepAction(timeVal) + + elseif (soundHandle == null) then + // If the sound does not exist, perform a default length wait. + call TriggerSleepAction(bj_NOTHING_SOUND_DURATION) + + elseif (timeType == bj_TIMETYPE_SUB) then + // If the transmission is cutting off the sound, wait for the sound + // to be mostly finished. + call WaitForSoundBJ(soundHandle, timeVal) + + elseif (timeType == bj_TIMETYPE_ADD) then + // If the transmission is extending beyond the sound's length, wait + // for it to finish, and then wait the additional time. + call WaitForSoundBJ(soundHandle, 0) + call TriggerSleepAction(timeVal) + + else + // Unrecognized timeType - ignore. + endif +endfunction + +//=========================================================================== +function DoTransmissionBasicsXYBJ takes integer unitId, playercolor color, real x, real y, sound soundHandle, string unitName, string message, real duration returns nothing + call SetCinematicSceneBJ(soundHandle, unitId, color, unitName, message, duration + bj_TRANSMISSION_PORT_HANGTIME, duration) + + if (unitId != 0) then + call PingMinimap(x, y, bj_TRANSMISSION_PING_TIME) + //call SetCameraQuickPosition(x, y) + endif +endfunction + +//=========================================================================== +// Display a text message to a Player Group with an accompanying sound, +// portrait, speech indicator, and all that good stuff. +// - Query duration of sound +// - Play sound +// - Display text message for duration +// - Display animating portrait for duration +// - Display a speech indicator for the unit +// - Ping the minimap +// +function TransmissionFromUnitWithNameBJ takes force toForce, unit whichUnit, string unitName, sound soundHandle, string message, integer timeType, real timeVal, boolean wait returns nothing + call TryInitCinematicBehaviorBJ() + + call AttachSoundToUnit(soundHandle, whichUnit) + + // Ensure that the time value is non-negative. + set timeVal = RMaxBJ(timeVal, 0) + + set bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal) + set bj_lastPlayedSound = soundHandle + + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + if (whichUnit == null) then + // If the unit reference is invalid, send the transmission from the center of the map with no portrait. + call DoTransmissionBasicsXYBJ(0, PLAYER_COLOR_RED, 0, 0, soundHandle, unitName, message, bj_lastTransmissionDuration) + else + call DoTransmissionBasicsXYBJ(GetUnitTypeId(whichUnit), GetPlayerColor(GetOwningPlayer(whichUnit)), GetUnitX(whichUnit), GetUnitY(whichUnit), soundHandle, unitName, message, bj_lastTransmissionDuration) + if (not IsUnitHidden(whichUnit)) then + call UnitAddIndicator(whichUnit, bj_TRANSMISSION_IND_RED, bj_TRANSMISSION_IND_BLUE, bj_TRANSMISSION_IND_GREEN, bj_TRANSMISSION_IND_ALPHA) + endif + endif + endif + + if wait and (bj_lastTransmissionDuration > 0) then + // call TriggerSleepAction(bj_lastTransmissionDuration) + call WaitTransmissionDuration(soundHandle, timeType, timeVal) + endif + +endfunction + +//=========================================================================== +function PlayDialogueFromSpeakerEx takes force toForce, unit speaker, integer speakerType, sound soundHandle, integer timeType, real timeVal, boolean wait returns boolean + //Make sure that the runtime unit type and the parameter are the same, + //otherwise the offline animations will not match and will fail + if GetUnitTypeId(speaker) != speakerType then + debug call BJDebugMsg(("Attempted to play FacialAnimation with the wrong speaker UnitType - Param: " + I2S(speakerType) + " Runtime: " + I2S(GetUnitTypeId(speaker)))) + //return false + endif + + call TryInitCinematicBehaviorBJ() + + call AttachSoundToUnit(soundHandle, speaker) + + // Ensure that the time value is non-negative. + set timeVal = RMaxBJ(timeVal, 0) + + set bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal) + set bj_lastPlayedSound = soundHandle + + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + call SetCinematicSceneBJ(soundHandle, speakerType, GetPlayerColor(GetOwningPlayer(speaker)), GetLocalizedString(GetDialogueSpeakerNameKey(soundHandle)), GetLocalizedString(GetDialogueTextKey(soundHandle)), bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration) + endif + + if wait and (bj_lastTransmissionDuration > 0) then + // call TriggerSleepAction(bj_lastTransmissionDuration) + call WaitTransmissionDuration(soundHandle, timeType, timeVal) + endif + + return true +endfunction + +//=========================================================================== +function PlayDialogueFromSpeakerTypeEx takes force toForce, player fromPlayer, integer speakerType, location loc, sound soundHandle, integer timeType, real timeVal, boolean wait returns boolean + call TryInitCinematicBehaviorBJ() + + // Ensure that the time value is non-negative. + set timeVal = RMaxBJ(timeVal, 0) + + set bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal) + set bj_lastPlayedSound = soundHandle + + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + call SetCinematicSceneBJ(soundHandle, speakerType, GetPlayerColor(fromPlayer), GetLocalizedString(GetDialogueSpeakerNameKey(soundHandle)), GetLocalizedString(GetDialogueTextKey(soundHandle)), bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration) + if(speakerType != 0) then + call PingMinimap(GetLocationX(loc), GetLocationY(loc), bj_TRANSMISSION_PING_TIME) + endif + endif + + if wait and (bj_lastTransmissionDuration > 0) then + // call TriggerSleepAction(bj_lastTransmissionDuration) + call WaitTransmissionDuration(soundHandle, timeType, timeVal) + endif + + return true +endfunction + +//=========================================================================== +// This operates like TransmissionFromUnitWithNameBJ, but for a unit type +// rather than a unit instance. As such, no speech indicator is employed. +// +function TransmissionFromUnitTypeWithNameBJ takes force toForce, player fromPlayer, integer unitId, string unitName, location loc, sound soundHandle, string message, integer timeType, real timeVal, boolean wait returns nothing + call TryInitCinematicBehaviorBJ() + + // Ensure that the time value is non-negative. + set timeVal = RMaxBJ(timeVal, 0) + + set bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal) + set bj_lastPlayedSound = soundHandle + + if (IsPlayerInForce(GetLocalPlayer(), toForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + call DoTransmissionBasicsXYBJ(unitId, GetPlayerColor(fromPlayer), GetLocationX(loc), GetLocationY(loc), soundHandle, unitName, message, bj_lastTransmissionDuration) + endif + + if wait and (bj_lastTransmissionDuration > 0) then + // call TriggerSleepAction(bj_lastTransmissionDuration) + call WaitTransmissionDuration(soundHandle, timeType, timeVal) + endif + +endfunction + +//=========================================================================== +function GetLastTransmissionDurationBJ takes nothing returns real + return bj_lastTransmissionDuration +endfunction + +//=========================================================================== +function SetCameraBlockerForPlayerBJ takes rect r, boolean flag, player whichPlayer returns nothing + if (GetLocalPlayer() == whichPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call EnableCameraBlocker(r,flag) + endif +endfunction + +//=========================================================================== +function ForceCinematicSubtitlesBJ takes boolean flag returns nothing + call ForceCinematicSubtitles(flag) +endfunction + + +//*************************************************************************** +//* +//* Cinematic Mode Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +// Makes many common UI settings changes at once, for use when beginning and +// ending cinematic sequences. Note that some affects apply to all players, +// such as game speed. This is unavoidable. +// - Clear the screen of text messages +// - Hide interface UI (letterbox mode) +// - Hide game messages (ally under attack, etc.) +// - Disable user control +// - Disable occlusion +// - Set game speed (for all players) +// - Lock game speed (for all players) +// - Disable black mask (for all players) +// - Disable fog of war (for all players) +// - Disable world boundary fog (for all players) +// - Dim non-speech sound channels +// - End any outstanding music themes +// - Fix the random seed to a set value +// - Reset the camera smoothing factor +// +function CinematicModeExBJ takes boolean cineMode, force forForce, real interfaceFadeTime returns nothing + // If the game hasn't started yet, perform interface fades immediately + if (not bj_gameStarted) then + set interfaceFadeTime = 0 + endif + + if (cineMode) then + // Save the UI state so that we can restore it later. + if (not bj_cineModeAlreadyIn) then + call SetCinematicAudio(true) + set bj_cineModeAlreadyIn = true + set bj_cineModePriorSpeed = GetGameSpeed() + set bj_cineModePriorFogSetting = IsFogEnabled() + set bj_cineModePriorMaskSetting = IsFogMaskEnabled() + set bj_cineModePriorDawnDusk = IsDawnDuskEnabled() + set bj_cineModeSavedSeed = GetRandomInt(0, 1000000) + endif + + // Perform local changes + if (IsPlayerInForce(GetLocalPlayer(), forForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ClearTextMessages() + call ShowInterface(false, interfaceFadeTime) + call EnableUserControl(false) + call EnableOcclusion(false) + call SetCineModeVolumeGroupsBJ() + endif + + // Perform global changes + call SetGameSpeed(bj_CINEMODE_GAMESPEED) + call SetMapFlag(MAP_LOCK_SPEED, true) + call FogMaskEnable(false) + call FogEnable(false) + call EnableWorldFogBoundary(false) + call EnableDawnDusk(false) + + // Use a fixed random seed, so that cinematics play consistently. + call SetRandomSeed(0) + else + set bj_cineModeAlreadyIn = false + call SetCinematicAudio(false) + + // Perform local changes + if (IsPlayerInForce(GetLocalPlayer(), forForce)) then + // Use only local code (no net traffic) within this block to avoid desyncs. + call ShowInterface(true, interfaceFadeTime) + call EnableUserControl(true) + call EnableOcclusion(true) + call VolumeGroupReset() + call EndThematicMusic() + call CameraResetSmoothingFactorBJ() + endif + + // Perform global changes + call SetMapFlag(MAP_LOCK_SPEED, false) + call SetGameSpeed(bj_cineModePriorSpeed) + call FogMaskEnable(bj_cineModePriorMaskSetting) + call FogEnable(bj_cineModePriorFogSetting) + call EnableWorldFogBoundary(true) + call EnableDawnDusk(bj_cineModePriorDawnDusk) + call SetRandomSeed(bj_cineModeSavedSeed) + endif +endfunction + +//=========================================================================== +function CinematicModeBJ takes boolean cineMode, force forForce returns nothing + call CinematicModeExBJ(cineMode, forForce, bj_CINEMODE_INTERFACEFADE) +endfunction + + + +//*************************************************************************** +//* +//* Cinematic Filter Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function DisplayCineFilterBJ takes boolean flag returns nothing + call DisplayCineFilter(flag) +endfunction + +//=========================================================================== +function CinematicFadeCommonBJ takes real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing + if (duration == 0) then + // If the fade is instant, use the same starting and ending values, + // so that we effectively do a set rather than a fade. + set startTrans = endTrans + endif + call EnableUserUI(false) + call SetCineFilterTexture(tex) + call SetCineFilterBlendMode(BLEND_MODE_BLEND) + call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE) + call SetCineFilterStartUV(0, 0, 1, 1) + call SetCineFilterEndUV(0, 0, 1, 1) + call SetCineFilterStartColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-startTrans)) + call SetCineFilterEndColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0-endTrans)) + call SetCineFilterDuration(duration) + call DisplayCineFilter(true) +endfunction + +//=========================================================================== +function FinishCinematicFadeBJ takes nothing returns nothing + call DestroyTimer(bj_cineFadeFinishTimer) + set bj_cineFadeFinishTimer = null + call DisplayCineFilter(false) + call EnableUserUI(true) +endfunction + +//=========================================================================== +function FinishCinematicFadeAfterBJ takes real duration returns nothing + // Create a timer to end the cinematic fade. + set bj_cineFadeFinishTimer = CreateTimer() + call TimerStart(bj_cineFadeFinishTimer, duration, false, function FinishCinematicFadeBJ) +endfunction + +//=========================================================================== +function ContinueCinematicFadeBJ takes nothing returns nothing + call DestroyTimer(bj_cineFadeContinueTimer) + set bj_cineFadeContinueTimer = null + call CinematicFadeCommonBJ(bj_cineFadeContinueRed, bj_cineFadeContinueGreen, bj_cineFadeContinueBlue, bj_cineFadeContinueDuration, bj_cineFadeContinueTex, bj_cineFadeContinueTrans, 100) +endfunction + +//=========================================================================== +function ContinueCinematicFadeAfterBJ takes real duration, real red, real green, real blue, real trans, string tex returns nothing + set bj_cineFadeContinueRed = red + set bj_cineFadeContinueGreen = green + set bj_cineFadeContinueBlue = blue + set bj_cineFadeContinueTrans = trans + set bj_cineFadeContinueDuration = duration + set bj_cineFadeContinueTex = tex + + // Create a timer to continue the cinematic fade. + set bj_cineFadeContinueTimer = CreateTimer() + call TimerStart(bj_cineFadeContinueTimer, duration, false, function ContinueCinematicFadeBJ) +endfunction + +//=========================================================================== +function AbortCinematicFadeBJ takes nothing returns nothing + if (bj_cineFadeContinueTimer != null) then + call DestroyTimer(bj_cineFadeContinueTimer) + endif + + if (bj_cineFadeFinishTimer != null) then + call DestroyTimer(bj_cineFadeFinishTimer) + endif +endfunction + +//=========================================================================== +function CinematicFadeBJ takes integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing + if (fadetype == bj_CINEFADETYPE_FADEOUT) then + // Fade out to the requested color. + call AbortCinematicFadeBJ() + call CinematicFadeCommonBJ(red, green, blue, duration, tex, 100, trans) + elseif (fadetype == bj_CINEFADETYPE_FADEIN) then + // Fade in from the requested color. + call AbortCinematicFadeBJ() + call CinematicFadeCommonBJ(red, green, blue, duration, tex, trans, 100) + call FinishCinematicFadeAfterBJ(duration) + elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then + // Fade out to the requested color, and then fade back in from it. + if (duration > 0) then + call AbortCinematicFadeBJ() + call CinematicFadeCommonBJ(red, green, blue, duration * 0.5, tex, 100, trans) + call ContinueCinematicFadeAfterBJ(duration * 0.5, red, green, blue, trans, tex) + call FinishCinematicFadeAfterBJ(duration) + endif + else + // Unrecognized fadetype - ignore the request. + endif +endfunction + +//=========================================================================== +function CinematicFilterGenericBJ takes real duration, blendmode bmode, string tex, real red0, real green0, real blue0, real trans0, real red1, real green1, real blue1, real trans1 returns nothing + call AbortCinematicFadeBJ() + call SetCineFilterTexture(tex) + call SetCineFilterBlendMode(bmode) + call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE) + call SetCineFilterStartUV(0, 0, 1, 1) + call SetCineFilterEndUV(0, 0, 1, 1) + call SetCineFilterStartColor(PercentTo255(red0), PercentTo255(green0), PercentTo255(blue0), PercentTo255(100.0-trans0)) + call SetCineFilterEndColor(PercentTo255(red1), PercentTo255(green1), PercentTo255(blue1), PercentTo255(100.0-trans1)) + call SetCineFilterDuration(duration) + call DisplayCineFilter(true) +endfunction + + + +//*************************************************************************** +//* +//* Rescuable Unit Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +// Rescues a unit for a player. This performs the default rescue behavior, +// including a rescue sound, flashing selection circle, ownership change, +// and optionally a unit color change. +// +function RescueUnitBJ takes unit whichUnit, player rescuer, boolean changeColor returns nothing + if IsUnitDeadBJ(whichUnit) or (GetOwningPlayer(whichUnit) == rescuer) then + return + endif + + call StartSound(bj_rescueSound) + call SetUnitOwner(whichUnit, rescuer, changeColor) + call UnitAddIndicator(whichUnit, 0, 255, 0, 255) + call PingMinimapForPlayer(rescuer, GetUnitX(whichUnit), GetUnitY(whichUnit), bj_RESCUE_PING_TIME) +endfunction + +//=========================================================================== +function TriggerActionUnitRescuedBJ takes nothing returns nothing + local unit theUnit = GetTriggerUnit() + + if IsUnitType(theUnit, UNIT_TYPE_STRUCTURE) then + call RescueUnitBJ(theUnit, GetOwningPlayer(GetRescuer()), bj_rescueChangeColorBldg) + else + call RescueUnitBJ(theUnit, GetOwningPlayer(GetRescuer()), bj_rescueChangeColorUnit) + endif +endfunction + +//=========================================================================== +// Attempt to init triggers for default rescue behavior. For performance +// reasons, this should only be attempted if a player is set to Rescuable, +// or if a specific unit is thus flagged. +// +function TryInitRescuableTriggersBJ takes nothing returns nothing + local integer index + + if (bj_rescueUnitBehavior == null) then + set bj_rescueUnitBehavior = CreateTrigger() + set index = 0 + loop + call TriggerRegisterPlayerUnitEvent(bj_rescueUnitBehavior, Player(index), EVENT_PLAYER_UNIT_RESCUED, null) + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + call TriggerAddAction(bj_rescueUnitBehavior, function TriggerActionUnitRescuedBJ) + endif +endfunction + +//=========================================================================== +// Determines whether or not rescued units automatically change color upon +// being rescued. +// +function SetRescueUnitColorChangeBJ takes boolean changeColor returns nothing + set bj_rescueChangeColorUnit = changeColor +endfunction + +//=========================================================================== +// Determines whether or not rescued buildings automatically change color +// upon being rescued. +// +function SetRescueBuildingColorChangeBJ takes boolean changeColor returns nothing + set bj_rescueChangeColorBldg = changeColor +endfunction + +//=========================================================================== +function MakeUnitRescuableToForceBJEnum takes nothing returns nothing + call TryInitRescuableTriggersBJ() + call SetUnitRescuable(bj_makeUnitRescuableUnit, GetEnumPlayer(), bj_makeUnitRescuableFlag) +endfunction + +//=========================================================================== +function MakeUnitRescuableToForceBJ takes unit whichUnit, boolean isRescuable, force whichForce returns nothing + // Flag the unit as rescuable/unrescuable for the appropriate players. + set bj_makeUnitRescuableUnit = whichUnit + set bj_makeUnitRescuableFlag = isRescuable + call ForForce(whichForce, function MakeUnitRescuableToForceBJEnum) +endfunction + +//=========================================================================== +function InitRescuableBehaviorBJ takes nothing returns nothing + local integer index + + set index = 0 + loop + // If at least one player slot is "Rescuable"-controlled, init the + // rescue behavior triggers. + if (GetPlayerController(Player(index)) == MAP_CONTROL_RESCUABLE) then + call TryInitRescuableTriggersBJ() + return + endif + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + + + +//*************************************************************************** +//* +//* Research and Upgrade Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function SetPlayerTechResearchedSwap takes integer techid, integer levels, player whichPlayer returns nothing + call SetPlayerTechResearched(whichPlayer, techid, levels) +endfunction + +//=========================================================================== +function SetPlayerTechMaxAllowedSwap takes integer techid, integer maximum, player whichPlayer returns nothing + call SetPlayerTechMaxAllowed(whichPlayer, techid, maximum) +endfunction + +//=========================================================================== +function SetPlayerMaxHeroesAllowed takes integer maximum, player whichPlayer returns nothing + call SetPlayerTechMaxAllowed(whichPlayer, 'HERO', maximum) +endfunction + +//=========================================================================== +function GetPlayerTechCountSimple takes integer techid, player whichPlayer returns integer + return GetPlayerTechCount(whichPlayer, techid, true) +endfunction + +//=========================================================================== +function GetPlayerTechMaxAllowedSwap takes integer techid, player whichPlayer returns integer + return GetPlayerTechMaxAllowed(whichPlayer, techid) +endfunction + +//=========================================================================== +function SetPlayerAbilityAvailableBJ takes boolean avail, integer abilid, player whichPlayer returns nothing + call SetPlayerAbilityAvailable(whichPlayer, abilid, avail) +endfunction + + + +//*************************************************************************** +//* +//* Campaign Utility Functions +//* +//*************************************************************************** + +function SetCampaignMenuRaceBJ takes integer campaignNumber returns nothing + if (campaignNumber == bj_CAMPAIGN_INDEX_T) then + call SetCampaignMenuRace(RACE_OTHER) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_H) then + call SetCampaignMenuRace(RACE_HUMAN) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_U) then + call SetCampaignMenuRace(RACE_UNDEAD) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_O) then + call SetCampaignMenuRace(RACE_ORC) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_N) then + call SetCampaignMenuRace(RACE_NIGHTELF) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XN) then + call SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XN) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XH) then + call SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XH) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XU) then + call SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XU) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XO) then + call SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XO) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_RH) then + call SetCampaignMenuRace(RACE_HUMAN) + elseif (campaignNumber == bj_CAMPAIGN_INDEX_RU) then + call SetCampaignMenuRace(RACE_UNDEAD) + else + // Unrecognized campaign - ignore the request + endif +endfunction + +//=========================================================================== +// Converts a single campaign mission designation into campaign and mission +// numbers. The 1000's digit is considered the campaign index, and the 1's +// digit is considered the mission index within that campaign. This is done +// so that the trigger for this can use a single drop-down to list all of +// the campaign missions. +// +function SetMissionAvailableBJ takes boolean available, integer missionIndex returns nothing + local integer campaignNumber = missionIndex / 1000 + local integer missionNumber = missionIndex - campaignNumber * 1000 + + call SetMissionAvailable(campaignNumber, missionNumber, available) +endfunction + +//=========================================================================== +function SetCampaignAvailableBJ takes boolean available, integer campaignNumber returns nothing + local integer campaignOffset + + if (campaignNumber == bj_CAMPAIGN_INDEX_H) then + call SetTutorialCleared(true) + endif + + if (campaignNumber == bj_CAMPAIGN_INDEX_XN) then + set campaignOffset = bj_CAMPAIGN_OFFSET_XN + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XH) then + set campaignOffset = bj_CAMPAIGN_OFFSET_XH + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XU) then + set campaignOffset = bj_CAMPAIGN_OFFSET_XU + elseif (campaignNumber == bj_CAMPAIGN_INDEX_XO) then + set campaignOffset = bj_CAMPAIGN_OFFSET_XO + elseif (campaignNumber == bj_CAMPAIGN_INDEX_RH) then + set campaignOffset = bj_CAMPAIGN_OFFSET_RH + elseif (campaignNumber == bj_CAMPAIGN_INDEX_RU) then + set campaignOffset = bj_CAMPAIGN_OFFSET_RU + else + set campaignOffset = campaignNumber + endif + + call SetCampaignAvailable(campaignOffset, available) + call SetCampaignMenuRaceBJ(campaignNumber) + call ForceCampaignSelectScreen() +endfunction + +//=========================================================================== +function SetCinematicAvailableBJ takes boolean available, integer cinematicIndex returns nothing + if ( cinematicIndex == bj_CINEMATICINDEX_TOP ) then + call SetOpCinematicAvailable( bj_CAMPAIGN_INDEX_T, available ) + call PlayCinematic( "TutorialOp" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_HOP) then + call SetOpCinematicAvailable( bj_CAMPAIGN_INDEX_H, available ) + call PlayCinematic( "HumanOp" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_HED) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_H, available ) + call PlayCinematic( "HumanEd" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_OOP) then + call SetOpCinematicAvailable( bj_CAMPAIGN_INDEX_O, available ) + call PlayCinematic( "OrcOp" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_OED) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_O, available ) + call PlayCinematic( "OrcEd" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_UOP) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_U, available ) + call PlayCinematic( "UndeadOp" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_UED) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_U, available ) + call PlayCinematic( "UndeadEd" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_NOP) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_N, available ) + call PlayCinematic( "NightElfOp" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_NED) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_N, available ) + call PlayCinematic( "NightElfEd" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_XOP) then + call SetOpCinematicAvailable( bj_CAMPAIGN_OFFSET_XN, available ) + // call PlayCinematic( "IntroX" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_XED) then + call SetEdCinematicAvailable( bj_CAMPAIGN_OFFSET_XU, available ) + call PlayCinematic( "OutroX" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_HFO) then + call SetOpCinematicAvailable( bj_CAMPAIGN_OFFSET_RH, available ) + call PlayCinematic( "IntroRE" ) + elseif (cinematicIndex == bj_CINEMATICINDEX_UFE) then + call SetEdCinematicAvailable( bj_CAMPAIGN_INDEX_RU, available ) + call PlayCinematic( "OutroRE" ) + else + // Unrecognized cinematic - ignore the request. + endif +endfunction + +//=========================================================================== +function InitGameCacheBJ takes string campaignFile returns gamecache + set bj_lastCreatedGameCache = InitGameCache(campaignFile) + return bj_lastCreatedGameCache +endfunction + +//=========================================================================== +function SaveGameCacheBJ takes gamecache cache returns boolean + return SaveGameCache(cache) +endfunction + +//=========================================================================== +function GetLastCreatedGameCacheBJ takes nothing returns gamecache + return bj_lastCreatedGameCache +endfunction + +//=========================================================================== +function InitHashtableBJ takes nothing returns hashtable + set bj_lastCreatedHashtable = InitHashtable() + return bj_lastCreatedHashtable +endfunction + +//=========================================================================== +function GetLastCreatedHashtableBJ takes nothing returns hashtable + return bj_lastCreatedHashtable +endfunction + +//=========================================================================== +function StoreRealBJ takes real value, string key, string missionKey, gamecache cache returns nothing + call StoreReal(cache, missionKey, key, value) +endfunction + +//=========================================================================== +function StoreIntegerBJ takes integer value, string key, string missionKey, gamecache cache returns nothing + call StoreInteger(cache, missionKey, key, value) +endfunction + +//=========================================================================== +function StoreBooleanBJ takes boolean value, string key, string missionKey, gamecache cache returns nothing + call StoreBoolean(cache, missionKey, key, value) +endfunction + +//=========================================================================== +function StoreStringBJ takes string value, string key, string missionKey, gamecache cache returns boolean + return StoreString(cache, missionKey, key, value) +endfunction + +//=========================================================================== +function StoreUnitBJ takes unit whichUnit, string key, string missionKey, gamecache cache returns boolean + return StoreUnit(cache, missionKey, key, whichUnit) +endfunction + +//=========================================================================== +function SaveRealBJ takes real value, integer key, integer missionKey, hashtable table returns nothing + call SaveReal(table, missionKey, key, value) +endfunction + +//=========================================================================== +function SaveIntegerBJ takes integer value, integer key, integer missionKey, hashtable table returns nothing + call SaveInteger(table, missionKey, key, value) +endfunction + +//=========================================================================== +function SaveBooleanBJ takes boolean value, integer key, integer missionKey, hashtable table returns nothing + call SaveBoolean(table, missionKey, key, value) +endfunction + +//=========================================================================== +function SaveStringBJ takes string value, integer key, integer missionKey, hashtable table returns boolean + return SaveStr(table, missionKey, key, value) +endfunction + +//=========================================================================== +function SavePlayerHandleBJ takes player whichPlayer, integer key, integer missionKey, hashtable table returns boolean + return SavePlayerHandle(table, missionKey, key, whichPlayer) +endfunction + +//=========================================================================== +function SaveWidgetHandleBJ takes widget whichWidget, integer key, integer missionKey, hashtable table returns boolean + return SaveWidgetHandle(table, missionKey, key, whichWidget) +endfunction + +//=========================================================================== +function SaveDestructableHandleBJ takes destructable whichDestructable, integer key, integer missionKey, hashtable table returns boolean + return SaveDestructableHandle(table, missionKey, key, whichDestructable) +endfunction + +//=========================================================================== +function SaveItemHandleBJ takes item whichItem, integer key, integer missionKey, hashtable table returns boolean + return SaveItemHandle(table, missionKey, key, whichItem) +endfunction + +//=========================================================================== +function SaveUnitHandleBJ takes unit whichUnit, integer key, integer missionKey, hashtable table returns boolean + return SaveUnitHandle(table, missionKey, key, whichUnit) +endfunction + +//=========================================================================== +function SaveAbilityHandleBJ takes ability whichAbility, integer key, integer missionKey, hashtable table returns boolean + return SaveAbilityHandle(table, missionKey, key, whichAbility) +endfunction + +//=========================================================================== +function SaveTimerHandleBJ takes timer whichTimer, integer key, integer missionKey, hashtable table returns boolean + return SaveTimerHandle(table, missionKey, key, whichTimer) +endfunction + +//=========================================================================== +function SaveTriggerHandleBJ takes trigger whichTrigger, integer key, integer missionKey, hashtable table returns boolean + return SaveTriggerHandle(table, missionKey, key, whichTrigger) +endfunction + +//=========================================================================== +function SaveTriggerConditionHandleBJ takes triggercondition whichTriggercondition, integer key, integer missionKey, hashtable table returns boolean + return SaveTriggerConditionHandle(table, missionKey, key, whichTriggercondition) +endfunction + +//=========================================================================== +function SaveTriggerActionHandleBJ takes triggeraction whichTriggeraction, integer key, integer missionKey, hashtable table returns boolean + return SaveTriggerActionHandle(table, missionKey, key, whichTriggeraction) +endfunction + +//=========================================================================== +function SaveTriggerEventHandleBJ takes event whichEvent, integer key, integer missionKey, hashtable table returns boolean + return SaveTriggerEventHandle(table, missionKey, key, whichEvent) +endfunction + +//=========================================================================== +function SaveForceHandleBJ takes force whichForce, integer key, integer missionKey, hashtable table returns boolean + return SaveForceHandle(table, missionKey, key, whichForce) +endfunction + +//=========================================================================== +function SaveGroupHandleBJ takes group whichGroup, integer key, integer missionKey, hashtable table returns boolean + return SaveGroupHandle(table, missionKey, key, whichGroup) +endfunction + +//=========================================================================== +function SaveLocationHandleBJ takes location whichLocation, integer key, integer missionKey, hashtable table returns boolean + return SaveLocationHandle(table, missionKey, key, whichLocation) +endfunction + +//=========================================================================== +function SaveRectHandleBJ takes rect whichRect, integer key, integer missionKey, hashtable table returns boolean + return SaveRectHandle(table, missionKey, key, whichRect) +endfunction + +//=========================================================================== +function SaveBooleanExprHandleBJ takes boolexpr whichBoolexpr, integer key, integer missionKey, hashtable table returns boolean + return SaveBooleanExprHandle(table, missionKey, key, whichBoolexpr) +endfunction + +//=========================================================================== +function SaveSoundHandleBJ takes sound whichSound, integer key, integer missionKey, hashtable table returns boolean + return SaveSoundHandle(table, missionKey, key, whichSound) +endfunction + +//=========================================================================== +function SaveEffectHandleBJ takes effect whichEffect, integer key, integer missionKey, hashtable table returns boolean + return SaveEffectHandle(table, missionKey, key, whichEffect) +endfunction + +//=========================================================================== +function SaveUnitPoolHandleBJ takes unitpool whichUnitpool, integer key, integer missionKey, hashtable table returns boolean + return SaveUnitPoolHandle(table, missionKey, key, whichUnitpool) +endfunction + +//=========================================================================== +function SaveItemPoolHandleBJ takes itempool whichItempool, integer key, integer missionKey, hashtable table returns boolean + return SaveItemPoolHandle(table, missionKey, key, whichItempool) +endfunction + +//=========================================================================== +function SaveQuestHandleBJ takes quest whichQuest, integer key, integer missionKey, hashtable table returns boolean + return SaveQuestHandle(table, missionKey, key, whichQuest) +endfunction + +//=========================================================================== +function SaveQuestItemHandleBJ takes questitem whichQuestitem, integer key, integer missionKey, hashtable table returns boolean + return SaveQuestItemHandle(table, missionKey, key, whichQuestitem) +endfunction + +//=========================================================================== +function SaveDefeatConditionHandleBJ takes defeatcondition whichDefeatcondition, integer key, integer missionKey, hashtable table returns boolean + return SaveDefeatConditionHandle(table, missionKey, key, whichDefeatcondition) +endfunction + +//=========================================================================== +function SaveTimerDialogHandleBJ takes timerdialog whichTimerdialog, integer key, integer missionKey, hashtable table returns boolean + return SaveTimerDialogHandle(table, missionKey, key, whichTimerdialog) +endfunction + +//=========================================================================== +function SaveLeaderboardHandleBJ takes leaderboard whichLeaderboard, integer key, integer missionKey, hashtable table returns boolean + return SaveLeaderboardHandle(table, missionKey, key, whichLeaderboard) +endfunction + +//=========================================================================== +function SaveMultiboardHandleBJ takes multiboard whichMultiboard, integer key, integer missionKey, hashtable table returns boolean + return SaveMultiboardHandle(table, missionKey, key, whichMultiboard) +endfunction + +//=========================================================================== +function SaveMultiboardItemHandleBJ takes multiboarditem whichMultiboarditem, integer key, integer missionKey, hashtable table returns boolean + return SaveMultiboardItemHandle(table, missionKey, key, whichMultiboarditem) +endfunction + +//=========================================================================== +function SaveTrackableHandleBJ takes trackable whichTrackable, integer key, integer missionKey, hashtable table returns boolean + return SaveTrackableHandle(table, missionKey, key, whichTrackable) +endfunction + +//=========================================================================== +function SaveDialogHandleBJ takes dialog whichDialog, integer key, integer missionKey, hashtable table returns boolean + return SaveDialogHandle(table, missionKey, key, whichDialog) +endfunction + +//=========================================================================== +function SaveButtonHandleBJ takes button whichButton, integer key, integer missionKey, hashtable table returns boolean + return SaveButtonHandle(table, missionKey, key, whichButton) +endfunction + +//=========================================================================== +function SaveTextTagHandleBJ takes texttag whichTexttag, integer key, integer missionKey, hashtable table returns boolean + return SaveTextTagHandle(table, missionKey, key, whichTexttag) +endfunction + +//=========================================================================== +function SaveLightningHandleBJ takes lightning whichLightning, integer key, integer missionKey, hashtable table returns boolean + return SaveLightningHandle(table, missionKey, key, whichLightning) +endfunction + +//=========================================================================== +function SaveImageHandleBJ takes image whichImage, integer key, integer missionKey, hashtable table returns boolean + return SaveImageHandle(table, missionKey, key, whichImage) +endfunction + +//=========================================================================== +function SaveUbersplatHandleBJ takes ubersplat whichUbersplat, integer key, integer missionKey, hashtable table returns boolean + return SaveUbersplatHandle(table, missionKey, key, whichUbersplat) +endfunction + +//=========================================================================== +function SaveRegionHandleBJ takes region whichRegion, integer key, integer missionKey, hashtable table returns boolean + return SaveRegionHandle(table, missionKey, key, whichRegion) +endfunction + +//=========================================================================== +function SaveFogStateHandleBJ takes fogstate whichFogState, integer key, integer missionKey, hashtable table returns boolean + return SaveFogStateHandle(table, missionKey, key, whichFogState) +endfunction + +//=========================================================================== +function SaveFogModifierHandleBJ takes fogmodifier whichFogModifier, integer key, integer missionKey, hashtable table returns boolean + return SaveFogModifierHandle(table, missionKey, key, whichFogModifier) +endfunction + +//=========================================================================== +function SaveAgentHandleBJ takes agent whichAgent, integer key, integer missionKey, hashtable table returns boolean + return SaveAgentHandle(table, missionKey, key, whichAgent) +endfunction + +//=========================================================================== +function SaveHashtableHandleBJ takes hashtable whichHashtable, integer key, integer missionKey, hashtable table returns boolean + return SaveHashtableHandle(table, missionKey, key, whichHashtable) +endfunction + +//=========================================================================== +function GetStoredRealBJ takes string key, string missionKey, gamecache cache returns real + //call SyncStoredReal(cache, missionKey, key) + return GetStoredReal(cache, missionKey, key) +endfunction + +//=========================================================================== +function GetStoredIntegerBJ takes string key, string missionKey, gamecache cache returns integer + //call SyncStoredInteger(cache, missionKey, key) + return GetStoredInteger(cache, missionKey, key) +endfunction + +//=========================================================================== +function GetStoredBooleanBJ takes string key, string missionKey, gamecache cache returns boolean + //call SyncStoredBoolean(cache, missionKey, key) + return GetStoredBoolean(cache, missionKey, key) +endfunction + +//=========================================================================== +function GetStoredStringBJ takes string key, string missionKey, gamecache cache returns string + local string s + + //call SyncStoredString(cache, missionKey, key) + set s = GetStoredString(cache, missionKey, key) + if (s == null) then + return "" + else + return s + endif +endfunction + +//=========================================================================== +function LoadRealBJ takes integer key, integer missionKey, hashtable table returns real + //call SyncStoredReal(table, missionKey, key) + return LoadReal(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadIntegerBJ takes integer key, integer missionKey, hashtable table returns integer + //call SyncStoredInteger(table, missionKey, key) + return LoadInteger(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadBooleanBJ takes integer key, integer missionKey, hashtable table returns boolean + //call SyncStoredBoolean(table, missionKey, key) + return LoadBoolean(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadStringBJ takes integer key, integer missionKey, hashtable table returns string + local string s + + //call SyncStoredString(table, missionKey, key) + set s = LoadStr(table, missionKey, key) + if (s == null) then + return "" + else + return s + endif +endfunction + +//=========================================================================== +function LoadPlayerHandleBJ takes integer key, integer missionKey, hashtable table returns player + return LoadPlayerHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadWidgetHandleBJ takes integer key, integer missionKey, hashtable table returns widget + return LoadWidgetHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadDestructableHandleBJ takes integer key, integer missionKey, hashtable table returns destructable + return LoadDestructableHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadItemHandleBJ takes integer key, integer missionKey, hashtable table returns item + return LoadItemHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadUnitHandleBJ takes integer key, integer missionKey, hashtable table returns unit + return LoadUnitHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadAbilityHandleBJ takes integer key, integer missionKey, hashtable table returns ability + return LoadAbilityHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTimerHandleBJ takes integer key, integer missionKey, hashtable table returns timer + return LoadTimerHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTriggerHandleBJ takes integer key, integer missionKey, hashtable table returns trigger + return LoadTriggerHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTriggerConditionHandleBJ takes integer key, integer missionKey, hashtable table returns triggercondition + return LoadTriggerConditionHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTriggerActionHandleBJ takes integer key, integer missionKey, hashtable table returns triggeraction + return LoadTriggerActionHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTriggerEventHandleBJ takes integer key, integer missionKey, hashtable table returns event + return LoadTriggerEventHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadForceHandleBJ takes integer key, integer missionKey, hashtable table returns force + return LoadForceHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadGroupHandleBJ takes integer key, integer missionKey, hashtable table returns group + return LoadGroupHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadLocationHandleBJ takes integer key, integer missionKey, hashtable table returns location + return LoadLocationHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadRectHandleBJ takes integer key, integer missionKey, hashtable table returns rect + return LoadRectHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadBooleanExprHandleBJ takes integer key, integer missionKey, hashtable table returns boolexpr + return LoadBooleanExprHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadSoundHandleBJ takes integer key, integer missionKey, hashtable table returns sound + return LoadSoundHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadEffectHandleBJ takes integer key, integer missionKey, hashtable table returns effect + return LoadEffectHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadUnitPoolHandleBJ takes integer key, integer missionKey, hashtable table returns unitpool + return LoadUnitPoolHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadItemPoolHandleBJ takes integer key, integer missionKey, hashtable table returns itempool + return LoadItemPoolHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadQuestHandleBJ takes integer key, integer missionKey, hashtable table returns quest + return LoadQuestHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadQuestItemHandleBJ takes integer key, integer missionKey, hashtable table returns questitem + return LoadQuestItemHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadDefeatConditionHandleBJ takes integer key, integer missionKey, hashtable table returns defeatcondition + return LoadDefeatConditionHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTimerDialogHandleBJ takes integer key, integer missionKey, hashtable table returns timerdialog + return LoadTimerDialogHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadLeaderboardHandleBJ takes integer key, integer missionKey, hashtable table returns leaderboard + return LoadLeaderboardHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadMultiboardHandleBJ takes integer key, integer missionKey, hashtable table returns multiboard + return LoadMultiboardHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadMultiboardItemHandleBJ takes integer key, integer missionKey, hashtable table returns multiboarditem + return LoadMultiboardItemHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTrackableHandleBJ takes integer key, integer missionKey, hashtable table returns trackable + return LoadTrackableHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadDialogHandleBJ takes integer key, integer missionKey, hashtable table returns dialog + return LoadDialogHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadButtonHandleBJ takes integer key, integer missionKey, hashtable table returns button + return LoadButtonHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadTextTagHandleBJ takes integer key, integer missionKey, hashtable table returns texttag + return LoadTextTagHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadLightningHandleBJ takes integer key, integer missionKey, hashtable table returns lightning + return LoadLightningHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadImageHandleBJ takes integer key, integer missionKey, hashtable table returns image + return LoadImageHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadUbersplatHandleBJ takes integer key, integer missionKey, hashtable table returns ubersplat + return LoadUbersplatHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadRegionHandleBJ takes integer key, integer missionKey, hashtable table returns region + return LoadRegionHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadFogStateHandleBJ takes integer key, integer missionKey, hashtable table returns fogstate + return LoadFogStateHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadFogModifierHandleBJ takes integer key, integer missionKey, hashtable table returns fogmodifier + return LoadFogModifierHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function LoadHashtableHandleBJ takes integer key, integer missionKey, hashtable table returns hashtable + return LoadHashtableHandle(table, missionKey, key) +endfunction + +//=========================================================================== +function RestoreUnitLocFacingAngleBJ takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, real facing returns unit + //call SyncStoredUnit(cache, missionKey, key) + set bj_lastLoadedUnit = RestoreUnit(cache, missionKey, key, forWhichPlayer, GetLocationX(loc), GetLocationY(loc), facing) + return bj_lastLoadedUnit +endfunction + +//=========================================================================== +function RestoreUnitLocFacingPointBJ takes string key, string missionKey, gamecache cache, player forWhichPlayer, location loc, location lookAt returns unit + //call SyncStoredUnit(cache, missionKey, key) + return RestoreUnitLocFacingAngleBJ(key, missionKey, cache, forWhichPlayer, loc, AngleBetweenPoints(loc, lookAt)) +endfunction + +//=========================================================================== +function GetLastRestoredUnitBJ takes nothing returns unit + return bj_lastLoadedUnit +endfunction + +//=========================================================================== +function FlushGameCacheBJ takes gamecache cache returns nothing + call FlushGameCache(cache) +endfunction + +//=========================================================================== +function FlushStoredMissionBJ takes string missionKey, gamecache cache returns nothing + call FlushStoredMission(cache, missionKey) +endfunction + +//=========================================================================== +function FlushParentHashtableBJ takes hashtable table returns nothing + call FlushParentHashtable(table) +endfunction + +//=========================================================================== +function FlushChildHashtableBJ takes integer missionKey, hashtable table returns nothing + call FlushChildHashtable(table, missionKey) +endfunction + +//=========================================================================== +function HaveStoredValue takes string key, integer valueType, string missionKey, gamecache cache returns boolean + if (valueType == bj_GAMECACHE_BOOLEAN) then + return HaveStoredBoolean(cache, missionKey, key) + elseif (valueType == bj_GAMECACHE_INTEGER) then + return HaveStoredInteger(cache, missionKey, key) + elseif (valueType == bj_GAMECACHE_REAL) then + return HaveStoredReal(cache, missionKey, key) + elseif (valueType == bj_GAMECACHE_UNIT) then + return HaveStoredUnit(cache, missionKey, key) + elseif (valueType == bj_GAMECACHE_STRING) then + return HaveStoredString(cache, missionKey, key) + else + // Unrecognized value type - ignore the request. + return false + endif +endfunction + +//=========================================================================== +function HaveSavedValue takes integer key, integer valueType, integer missionKey, hashtable table returns boolean + if (valueType == bj_HASHTABLE_BOOLEAN) then + return HaveSavedBoolean(table, missionKey, key) + elseif (valueType == bj_HASHTABLE_INTEGER) then + return HaveSavedInteger(table, missionKey, key) + elseif (valueType == bj_HASHTABLE_REAL) then + return HaveSavedReal(table, missionKey, key) + elseif (valueType == bj_HASHTABLE_STRING) then + return HaveSavedString(table, missionKey, key) + elseif (valueType == bj_HASHTABLE_HANDLE) then + return HaveSavedHandle(table, missionKey, key) + else + // Unrecognized value type - ignore the request. + return false + endif +endfunction + +//=========================================================================== +function ShowCustomCampaignButton takes boolean show, integer whichButton returns nothing + call SetCustomCampaignButtonVisible(whichButton - 1, show) +endfunction + +//=========================================================================== +function IsCustomCampaignButtonVisibile takes integer whichButton returns boolean + return GetCustomCampaignButtonVisible(whichButton - 1) +endfunction + +//=========================================================================== +// Placeholder function for auto save feature +//=========================================================================== +function SaveGameCheckPointBJ takes string mapSaveName, boolean doCheckpointHint returns nothing + call SaveGameCheckpoint(mapSaveName, doCheckpointHint) +endfunction + +//=========================================================================== +function LoadGameBJ takes string loadFileName, boolean doScoreScreen returns nothing + call LoadGame(loadFileName, doScoreScreen) +endfunction + +//=========================================================================== +function SaveAndChangeLevelBJ takes string saveFileName, string newLevel, boolean doScoreScreen returns nothing + call SaveGame(saveFileName) + call ChangeLevel(newLevel, doScoreScreen) +endfunction + +//=========================================================================== +function SaveAndLoadGameBJ takes string saveFileName, string loadFileName, boolean doScoreScreen returns nothing + call SaveGame(saveFileName) + call LoadGame(loadFileName, doScoreScreen) +endfunction + +//=========================================================================== +function RenameSaveDirectoryBJ takes string sourceDirName, string destDirName returns boolean + return RenameSaveDirectory(sourceDirName, destDirName) +endfunction + +//=========================================================================== +function RemoveSaveDirectoryBJ takes string sourceDirName returns boolean + return RemoveSaveDirectory(sourceDirName) +endfunction + +//=========================================================================== +function CopySaveGameBJ takes string sourceSaveName, string destSaveName returns boolean + return CopySaveGame(sourceSaveName, destSaveName) +endfunction + + + +//*************************************************************************** +//* +//* Miscellaneous Utility Functions +//* +//*************************************************************************** + +//=========================================================================== +function GetPlayerStartLocationX takes player whichPlayer returns real + return GetStartLocationX(GetPlayerStartLocation(whichPlayer)) +endfunction + +//=========================================================================== +function GetPlayerStartLocationY takes player whichPlayer returns real + return GetStartLocationY(GetPlayerStartLocation(whichPlayer)) +endfunction + +//=========================================================================== +function GetPlayerStartLocationLoc takes player whichPlayer returns location + return GetStartLocationLoc(GetPlayerStartLocation(whichPlayer)) +endfunction + +//=========================================================================== +function GetRectCenter takes rect whichRect returns location + return Location(GetRectCenterX(whichRect), GetRectCenterY(whichRect)) +endfunction + +//=========================================================================== +function IsPlayerSlotState takes player whichPlayer, playerslotstate whichState returns boolean + return GetPlayerSlotState(whichPlayer) == whichState +endfunction + +//=========================================================================== +function GetFadeFromSeconds takes real seconds returns integer + if (seconds != 0) then + return 128 / R2I(seconds) + endif + return 10000 +endfunction + +//=========================================================================== +function GetFadeFromSecondsAsReal takes real seconds returns real + if (seconds != 0) then + return 128.00 / seconds + endif + return 10000.00 +endfunction + +//=========================================================================== +function AdjustPlayerStateSimpleBJ takes player whichPlayer, playerstate whichPlayerState, integer delta returns nothing + call SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta) +endfunction + +//=========================================================================== +function AdjustPlayerStateBJ takes integer delta, player whichPlayer, playerstate whichPlayerState returns nothing + // If the change was positive, apply the difference to the player's + // gathered resources property as well. + if (delta > 0) then + if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then + call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_GOLD_GATHERED, delta) + elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then + call AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_LUMBER_GATHERED, delta) + endif + endif + + call AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta) +endfunction + +//=========================================================================== +function SetPlayerStateBJ takes player whichPlayer, playerstate whichPlayerState, integer value returns nothing + local integer oldValue = GetPlayerState(whichPlayer, whichPlayerState) + call AdjustPlayerStateBJ(value - oldValue, whichPlayer, whichPlayerState) +endfunction + +//=========================================================================== +function SetPlayerFlagBJ takes playerstate whichPlayerFlag, boolean flag, player whichPlayer returns nothing + call SetPlayerState(whichPlayer, whichPlayerFlag, IntegerTertiaryOp(flag, 1, 0)) +endfunction + +//=========================================================================== +function SetPlayerTaxRateBJ takes integer rate, playerstate whichResource, player sourcePlayer, player otherPlayer returns nothing + call SetPlayerTaxRate(sourcePlayer, otherPlayer, whichResource, rate) +endfunction + +//=========================================================================== +function GetPlayerTaxRateBJ takes playerstate whichResource, player sourcePlayer, player otherPlayer returns integer + return GetPlayerTaxRate(sourcePlayer, otherPlayer, whichResource) +endfunction + +//=========================================================================== +function IsPlayerFlagSetBJ takes playerstate whichPlayerFlag, player whichPlayer returns boolean + return GetPlayerState(whichPlayer, whichPlayerFlag) == 1 +endfunction + +//=========================================================================== +function AddResourceAmountBJ takes integer delta, unit whichUnit returns nothing + call AddResourceAmount(whichUnit, delta) +endfunction + +//=========================================================================== +function GetConvertedPlayerId takes player whichPlayer returns integer + return GetPlayerId(whichPlayer) + 1 +endfunction + +//=========================================================================== +function ConvertedPlayer takes integer convertedPlayerId returns player + return Player(convertedPlayerId - 1) +endfunction + +//=========================================================================== +function GetRectWidthBJ takes rect r returns real + return GetRectMaxX(r) - GetRectMinX(r) +endfunction + +//=========================================================================== +function GetRectHeightBJ takes rect r returns real + return GetRectMaxY(r) - GetRectMinY(r) +endfunction + +//=========================================================================== +// Replaces a gold mine with a blighted gold mine for the given player. +// +function BlightGoldMineForPlayerBJ takes unit goldMine, player whichPlayer returns unit + local real mineX + local real mineY + local integer mineGold + local unit newMine + + // Make sure we're replacing a Gold Mine and not some other type of unit. + if GetUnitTypeId(goldMine) != 'ngol' then + return null + endif + + // Save the Gold Mine's properties and remove it. + set mineX = GetUnitX(goldMine) + set mineY = GetUnitY(goldMine) + set mineGold = GetResourceAmount(goldMine) + call RemoveUnit(goldMine) + + // Create a Haunted Gold Mine to replace the Gold Mine. + set newMine = CreateBlightedGoldmine(whichPlayer, mineX, mineY, bj_UNIT_FACING) + call SetResourceAmount(newMine, mineGold) + return newMine +endfunction + +//=========================================================================== +function BlightGoldMineForPlayer takes unit goldMine, player whichPlayer returns unit + set bj_lastHauntedGoldMine = BlightGoldMineForPlayerBJ(goldMine, whichPlayer) + return bj_lastHauntedGoldMine +endfunction + +//=========================================================================== +function GetLastHauntedGoldMine takes nothing returns unit + return bj_lastHauntedGoldMine +endfunction + +//=========================================================================== +function IsPointBlightedBJ takes location where returns boolean + return IsPointBlighted(GetLocationX(where), GetLocationY(where)) +endfunction + +//=========================================================================== +function SetPlayerColorBJEnum takes nothing returns nothing + call SetUnitColor(GetEnumUnit(), bj_setPlayerTargetColor) +endfunction + +//=========================================================================== +function SetPlayerColorBJ takes player whichPlayer, playercolor color, boolean changeExisting returns nothing + local group g + + call SetPlayerColor(whichPlayer, color) + if changeExisting then + set bj_setPlayerTargetColor = color + set g = CreateGroup() + call GroupEnumUnitsOfPlayer(g, whichPlayer, null) + call ForGroup(g, function SetPlayerColorBJEnum) + call DestroyGroup(g) + endif +endfunction + +//=========================================================================== +function SetPlayerUnitAvailableBJ takes integer unitId, boolean allowed, player whichPlayer returns nothing + if allowed then + call SetPlayerTechMaxAllowed(whichPlayer, unitId, -1) + else + call SetPlayerTechMaxAllowed(whichPlayer, unitId, 0) + endif +endfunction + +//=========================================================================== +function LockGameSpeedBJ takes nothing returns nothing + call SetMapFlag(MAP_LOCK_SPEED, true) +endfunction + +//=========================================================================== +function UnlockGameSpeedBJ takes nothing returns nothing + call SetMapFlag(MAP_LOCK_SPEED, false) +endfunction + +//=========================================================================== +function IssueTargetOrderBJ takes unit whichUnit, string order, widget targetWidget returns boolean + return IssueTargetOrder( whichUnit, order, targetWidget ) +endfunction + +//=========================================================================== +function IssuePointOrderLocBJ takes unit whichUnit, string order, location whichLocation returns boolean + return IssuePointOrderLoc( whichUnit, order, whichLocation ) +endfunction + +//=========================================================================== +// Two distinct trigger actions can't share the same function name, so this +// dummy function simply mimics the behavior of an existing call. +// +function IssueTargetDestructableOrder takes unit whichUnit, string order, widget targetWidget returns boolean + return IssueTargetOrder( whichUnit, order, targetWidget ) +endfunction + +function IssueTargetItemOrder takes unit whichUnit, string order, widget targetWidget returns boolean + return IssueTargetOrder( whichUnit, order, targetWidget ) +endfunction + +//=========================================================================== +function IssueImmediateOrderBJ takes unit whichUnit, string order returns boolean + return IssueImmediateOrder( whichUnit, order ) +endfunction + +//=========================================================================== +function GroupTargetOrderBJ takes group whichGroup, string order, widget targetWidget returns boolean + return GroupTargetOrder( whichGroup, order, targetWidget ) +endfunction + +//=========================================================================== +function GroupPointOrderLocBJ takes group whichGroup, string order, location whichLocation returns boolean + return GroupPointOrderLoc( whichGroup, order, whichLocation ) +endfunction + +//=========================================================================== +function GroupImmediateOrderBJ takes group whichGroup, string order returns boolean + return GroupImmediateOrder( whichGroup, order ) +endfunction + +//=========================================================================== +// Two distinct trigger actions can't share the same function name, so this +// dummy function simply mimics the behavior of an existing call. +// +function GroupTargetDestructableOrder takes group whichGroup, string order, widget targetWidget returns boolean + return GroupTargetOrder( whichGroup, order, targetWidget ) +endfunction + +function GroupTargetItemOrder takes group whichGroup, string order, widget targetWidget returns boolean + return GroupTargetOrder( whichGroup, order, targetWidget ) +endfunction + +//=========================================================================== +function GetDyingDestructable takes nothing returns destructable + return GetTriggerDestructable() +endfunction + +//=========================================================================== +// Rally point setting +// +function SetUnitRallyPoint takes unit whichUnit, location targPos returns nothing + call IssuePointOrderLocBJ(whichUnit, "setrally", targPos) +endfunction + +//=========================================================================== +function SetUnitRallyUnit takes unit whichUnit, unit targUnit returns nothing + call IssueTargetOrder(whichUnit, "setrally", targUnit) +endfunction + +//=========================================================================== +function SetUnitRallyDestructable takes unit whichUnit, destructable targDest returns nothing + call IssueTargetOrder(whichUnit, "setrally", targDest) +endfunction + +//=========================================================================== +// Utility function for use by editor-generated item drop table triggers. +// This function is added as an action to all destructable drop triggers, +// so that a widget drop may be differentiated from a unit drop. +// +function SaveDyingWidget takes nothing returns nothing + set bj_lastDyingWidget = GetTriggerWidget() +endfunction + +//=========================================================================== +function SetBlightRectBJ takes boolean addBlight, player whichPlayer, rect r returns nothing + call SetBlightRect(whichPlayer, r, addBlight) +endfunction + +//=========================================================================== +function SetBlightRadiusLocBJ takes boolean addBlight, player whichPlayer, location loc, real radius returns nothing + call SetBlightLoc(whichPlayer, loc, radius, addBlight) +endfunction + +//=========================================================================== +function GetAbilityName takes integer abilcode returns string + return GetObjectName(abilcode) +endfunction + + +//*************************************************************************** +//* +//* Melee Template Visibility Settings +//* +//*************************************************************************** + +//=========================================================================== +function MeleeStartingVisibility takes nothing returns nothing + // Start by setting the ToD. + call SetFloatGameState(GAME_STATE_TIME_OF_DAY, bj_MELEE_STARTING_TOD) + + // call FogMaskEnable(true) + // call FogEnable(true) +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Starting Resources +//* +//*************************************************************************** + +//=========================================================================== +function MeleeStartingResources takes nothing returns nothing + local integer index + local player indexPlayer + local version v + local integer startingGold + local integer startingLumber + + set v = VersionGet() + if (v == VERSION_REIGN_OF_CHAOS) then + set startingGold = bj_MELEE_STARTING_GOLD_V0 + set startingLumber = bj_MELEE_STARTING_LUMBER_V0 + else + set startingGold = bj_MELEE_STARTING_GOLD_V1 + set startingLumber = bj_MELEE_STARTING_LUMBER_V1 + endif + + // Set each player's starting resources. + set index = 0 + loop + set indexPlayer = Player(index) + if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then + call SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_GOLD, startingGold) + call SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_LUMBER, startingLumber) + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Hero Limit +//* +//*************************************************************************** + +//=========================================================================== +function ReducePlayerTechMaxAllowed takes player whichPlayer, integer techId, integer limit returns nothing + local integer oldMax = GetPlayerTechMaxAllowed(whichPlayer, techId) + + // A value of -1 is used to indicate no limit, so check for that as well. + if (oldMax < 0 or oldMax > limit) then + call SetPlayerTechMaxAllowed(whichPlayer, techId, limit) + endif +endfunction + +//=========================================================================== +function MeleeStartingHeroLimit takes nothing returns nothing + local integer index + + set index = 0 + loop + // max heroes per player + call SetPlayerMaxHeroesAllowed(bj_MELEE_HERO_LIMIT, Player(index)) + + // each player is restricted to a limit per hero type as well + call ReducePlayerTechMaxAllowed(Player(index), 'Hamg', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Hmkg', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Hpal', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Hblm', bj_MELEE_HERO_TYPE_LIMIT) + + call ReducePlayerTechMaxAllowed(Player(index), 'Obla', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ofar', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Otch', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Oshd', bj_MELEE_HERO_TYPE_LIMIT) + + call ReducePlayerTechMaxAllowed(Player(index), 'Edem', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ekee', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Emoo', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ewar', bj_MELEE_HERO_TYPE_LIMIT) + + call ReducePlayerTechMaxAllowed(Player(index), 'Udea', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Udre', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ulic', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ucrl', bj_MELEE_HERO_TYPE_LIMIT) + + call ReducePlayerTechMaxAllowed(Player(index), 'Npbm', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nbrn', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nngs', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nplh', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nbst', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nalc', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Ntin', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Nfir', bj_MELEE_HERO_TYPE_LIMIT) + call ReducePlayerTechMaxAllowed(Player(index), 'Npal', bj_MELEE_HERO_TYPE_LIMIT) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Granted Hero Items +//* +//*************************************************************************** + +//=========================================================================== +function MeleeTrainedUnitIsHeroBJFilter takes nothing returns boolean + return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO) +endfunction + +//=========================================================================== +// The first N heroes trained or hired for each player start off with a +// standard set of items. This is currently: +// - 1x Scroll of Town Portal +// +function MeleeGrantItemsToHero takes unit whichUnit returns nothing + local integer owner = GetPlayerId(GetOwningPlayer(whichUnit)) + + // If we haven't twinked N heroes for this player yet, twink away. + if (bj_meleeTwinkedHeroes[owner] < bj_MELEE_MAX_TWINKED_HEROES) then + call UnitAddItemById(whichUnit, 'stwp') + set bj_meleeTwinkedHeroes[owner] = bj_meleeTwinkedHeroes[owner] + 1 + endif +endfunction + +//=========================================================================== +function MeleeGrantItemsToTrainedHero takes nothing returns nothing + call MeleeGrantItemsToHero(GetTrainedUnit()) +endfunction + +//=========================================================================== +function MeleeGrantItemsToHiredHero takes nothing returns nothing + call MeleeGrantItemsToHero(GetSoldUnit()) +endfunction + +//=========================================================================== +function MeleeGrantHeroItems takes nothing returns nothing + local integer index + local trigger trig + + // Initialize the twinked hero counts. + set index = 0 + loop + set bj_meleeTwinkedHeroes[index] = 0 + + set index = index + 1 + exitwhen index == bj_MAX_PLAYER_SLOTS + endloop + + // Register for an event whenever a hero is trained, so that we can give + // him/her their starting items. + set index = 0 + loop + set trig = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_TRAIN_FINISH, filterMeleeTrainedUnitIsHeroBJ) + call TriggerAddAction(trig, function MeleeGrantItemsToTrainedHero) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + // Register for an event whenever a neutral hero is hired, so that we + // can give him/her their starting items. + set trig = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(trig, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_SELL, filterMeleeTrainedUnitIsHeroBJ) + call TriggerAddAction(trig, function MeleeGrantItemsToHiredHero) + + // Flag that we are giving starting items to heroes, so that the melee + // starting units code can create them as necessary. + set bj_meleeGrantHeroItems = true +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Clear Start Locations +//* +//*************************************************************************** + +//=========================================================================== +function MeleeClearExcessUnit takes nothing returns nothing + local unit theUnit = GetEnumUnit() + local integer owner = GetPlayerId(GetOwningPlayer(theUnit)) + + if (owner == PLAYER_NEUTRAL_AGGRESSIVE) then + // Remove any Neutral Hostile units from the area. + call RemoveUnit(GetEnumUnit()) + elseif (owner == PLAYER_NEUTRAL_PASSIVE) then + // Remove non-structure Neutral Passive units from the area. + if not IsUnitType(theUnit, UNIT_TYPE_STRUCTURE) then + call RemoveUnit(GetEnumUnit()) + endif + endif +endfunction + +//=========================================================================== +function MeleeClearNearbyUnits takes real x, real y, real range returns nothing + local group nearbyUnits + + set nearbyUnits = CreateGroup() + call GroupEnumUnitsInRange(nearbyUnits, x, y, range, null) + call ForGroup(nearbyUnits, function MeleeClearExcessUnit) + call DestroyGroup(nearbyUnits) +endfunction + +//=========================================================================== +function MeleeClearExcessUnits takes nothing returns nothing + local integer index + local real locX + local real locY + local player indexPlayer + + set index = 0 + loop + set indexPlayer = Player(index) + + // If the player slot is being used, clear any nearby creeps. + if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then + set locX = GetStartLocationX(GetPlayerStartLocation(indexPlayer)) + set locY = GetStartLocationY(GetPlayerStartLocation(indexPlayer)) + + call MeleeClearNearbyUnits(locX, locY, bj_MELEE_CLEAR_UNITS_RADIUS) + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Starting Units +//* +//*************************************************************************** + +//=========================================================================== +function MeleeEnumFindNearestMine takes nothing returns nothing + local unit enumUnit = GetEnumUnit() + local real dist + local location unitLoc + + if (GetUnitTypeId(enumUnit) == 'ngol') then + set unitLoc = GetUnitLoc(enumUnit) + set dist = DistanceBetweenPoints(unitLoc, bj_meleeNearestMineToLoc) + call RemoveLocation(unitLoc) + + // If this is our first mine, or the closest thusfar, use it instead. + if (bj_meleeNearestMineDist < 0) or (dist < bj_meleeNearestMineDist) then + set bj_meleeNearestMine = enumUnit + set bj_meleeNearestMineDist = dist + endif + endif +endfunction + +//=========================================================================== +function MeleeFindNearestMine takes location src, real range returns unit + local group nearbyMines + + set bj_meleeNearestMine = null + set bj_meleeNearestMineDist = -1 + set bj_meleeNearestMineToLoc = src + + set nearbyMines = CreateGroup() + call GroupEnumUnitsInRangeOfLoc(nearbyMines, src, range, null) + call ForGroup(nearbyMines, function MeleeEnumFindNearestMine) + call DestroyGroup(nearbyMines) + + return bj_meleeNearestMine +endfunction + +//=========================================================================== +function MeleeRandomHeroLoc takes player p, integer id1, integer id2, integer id3, integer id4, location loc returns unit + local unit hero = null + local integer roll + local integer pick + local version v + + // The selection of heroes is dependant on the game version. + set v = VersionGet() + if (v == VERSION_REIGN_OF_CHAOS) then + set roll = GetRandomInt(1,3) + else + set roll = GetRandomInt(1,4) + endif + + // Translate the roll into a unitid. + if roll == 1 then + set pick = id1 + elseif roll == 2 then + set pick = id2 + elseif roll == 3 then + set pick = id3 + elseif roll == 4 then + set pick = id4 + else + // Unrecognized id index - pick the first hero in the list. + set pick = id1 + endif + + // Create the hero. + set hero = CreateUnitAtLoc(p, pick, loc, bj_UNIT_FACING) + if bj_meleeGrantHeroItems then + call MeleeGrantItemsToHero(hero) + endif + return hero +endfunction + +//=========================================================================== +// Returns a location which is (distance) away from (src) in the direction of (targ). +// +function MeleeGetProjectedLoc takes location src, location targ, real distance, real deltaAngle returns location + local real srcX = GetLocationX(src) + local real srcY = GetLocationY(src) + local real direction = Atan2(GetLocationY(targ) - srcY, GetLocationX(targ) - srcX) + deltaAngle + return Location(srcX + distance * Cos(direction), srcY + distance * Sin(direction)) +endfunction + +//=========================================================================== +function MeleeGetNearestValueWithin takes real val, real minVal, real maxVal returns real + if (val < minVal) then + return minVal + elseif (val > maxVal) then + return maxVal + else + return val + endif +endfunction + +//=========================================================================== +function MeleeGetLocWithinRect takes location src, rect r returns location + local real withinX = MeleeGetNearestValueWithin(GetLocationX(src), GetRectMinX(r), GetRectMaxX(r)) + local real withinY = MeleeGetNearestValueWithin(GetLocationY(src), GetRectMinY(r), GetRectMaxY(r)) + return Location(withinX, withinY) +endfunction + +//=========================================================================== +// Starting Units for Human Players +// - 1 Town Hall, placed at start location +// - 5 Peasants, placed between start location and nearest gold mine +// +function MeleeStartingUnitsHuman takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing + local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO) + local real unitSpacing = 64.00 + local unit nearestMine + local location nearMineLoc + local location heroLoc + local real peonX + local real peonY + local unit townHall = null + + if (doPreload) then + call Preloader( "scripts\\HumanMelee.pld" ) + endif + + set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS) + if (nearestMine != null) then + // Spawn Town Hall at the start location. + set townHall = CreateUnitAtLoc(whichPlayer, 'htow', startLoc, bj_UNIT_FACING) + + // Spawn Peasants near the mine. + set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0) + set peonX = GetLocationX(nearMineLoc) + set peonY = GetLocationY(nearMineLoc) + call CreateUnit(whichPlayer, 'hpea', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be off to the side of the start location. + set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45) + else + // Spawn Town Hall at the start location. + set townHall = CreateUnitAtLoc(whichPlayer, 'htow', startLoc, bj_UNIT_FACING) + + // Spawn Peasants directly south of the town hall. + set peonX = GetLocationX(startLoc) + set peonY = GetLocationY(startLoc) - 224.00 + call CreateUnit(whichPlayer, 'hpea', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'hpea', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be just south of the start location. + set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing) + endif + + if (townHall != null) then + call UnitAddAbilityBJ('Amic', townHall) + call UnitMakeAbilityPermanentBJ(true, 'Amic', townHall) + endif + + if (doHeroes) then + // If the "Random Hero" option is set, start the player with a random hero. + // Otherwise, give them a "free hero" token. + if useRandomHero then + call MeleeRandomHeroLoc(whichPlayer, 'Hamg', 'Hmkg', 'Hpal', 'Hblm', heroLoc) + else + call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS) + endif + endif + + if (doCamera) then + // Center the camera on the initial Peasants. + call SetCameraPositionForPlayer(whichPlayer, peonX, peonY) + call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY) + endif +endfunction + +//=========================================================================== +// Starting Units for Orc Players +// - 1 Great Hall, placed at start location +// - 5 Peons, placed between start location and nearest gold mine +// +function MeleeStartingUnitsOrc takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing + local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO) + local real unitSpacing = 64.00 + local unit nearestMine + local location nearMineLoc + local location heroLoc + local real peonX + local real peonY + + if (doPreload) then + call Preloader( "scripts\\OrcMelee.pld" ) + endif + + set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS) + if (nearestMine != null) then + // Spawn Great Hall at the start location. + call CreateUnitAtLoc(whichPlayer, 'ogre', startLoc, bj_UNIT_FACING) + + // Spawn Peons near the mine. + set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0) + set peonX = GetLocationX(nearMineLoc) + set peonY = GetLocationY(nearMineLoc) + call CreateUnit(whichPlayer, 'opeo', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be off to the side of the start location. + set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45) + else + // Spawn Great Hall at the start location. + call CreateUnitAtLoc(whichPlayer, 'ogre', startLoc, bj_UNIT_FACING) + + // Spawn Peons directly south of the town hall. + set peonX = GetLocationX(startLoc) + set peonY = GetLocationY(startLoc) - 224.00 + call CreateUnit(whichPlayer, 'opeo', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'opeo', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be just south of the start location. + set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing) + endif + + if (doHeroes) then + // If the "Random Hero" option is set, start the player with a random hero. + // Otherwise, give them a "free hero" token. + if useRandomHero then + call MeleeRandomHeroLoc(whichPlayer, 'Obla', 'Ofar', 'Otch', 'Oshd', heroLoc) + else + call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS) + endif + endif + + if (doCamera) then + // Center the camera on the initial Peons. + call SetCameraPositionForPlayer(whichPlayer, peonX, peonY) + call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY) + endif +endfunction + +//=========================================================================== +// Starting Units for Undead Players +// - 1 Necropolis, placed at start location +// - 1 Haunted Gold Mine, placed on nearest gold mine +// - 3 Acolytes, placed between start location and nearest gold mine +// - 1 Ghoul, placed between start location and nearest gold mine +// - Blight, centered on nearest gold mine, spread across a "large area" +// +function MeleeStartingUnitsUndead takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing + local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO) + local real unitSpacing = 64.00 + local unit nearestMine + local location nearMineLoc + local location nearTownLoc + local location heroLoc + local real peonX + local real peonY + local real ghoulX + local real ghoulY + + if (doPreload) then + call Preloader( "scripts\\UndeadMelee.pld" ) + endif + + set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS) + if (nearestMine != null) then + // Spawn Necropolis at the start location. + call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING) + + // Replace the nearest gold mine with a blighted version. + set nearestMine = BlightGoldMineForPlayerBJ(nearestMine, whichPlayer) + + // Spawn Ghoul near the Necropolis. + set nearTownLoc = MeleeGetProjectedLoc(startLoc, GetUnitLoc(nearestMine), 288, 0) + set ghoulX = GetLocationX(nearTownLoc) + set ghoulY = GetLocationY(nearTownLoc) + set bj_ghoul[GetPlayerId(whichPlayer)] = CreateUnit(whichPlayer, 'ugho', ghoulX + 0.00 * unitSpacing, ghoulY + 0.00 * unitSpacing, bj_UNIT_FACING) + + // Spawn Acolytes near the mine. + set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0) + set peonX = GetLocationX(nearMineLoc) + set peonY = GetLocationY(nearMineLoc) + call CreateUnit(whichPlayer, 'uaco', peonX + 0.00 * unitSpacing, peonY + 0.50 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'uaco', peonX + 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'uaco', peonX - 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING) + + // Create a patch of blight around the gold mine. + call SetBlightLoc(whichPlayer,nearMineLoc, 768, true) + + // Set random hero spawn point to be off to the side of the start location. + set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45) + else + // Spawn Necropolis at the start location. + call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING) + + // Spawn Acolytes and Ghoul directly south of the Necropolis. + set peonX = GetLocationX(startLoc) + set peonY = GetLocationY(startLoc) - 224.00 + call CreateUnit(whichPlayer, 'uaco', peonX - 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'uaco', peonX - 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'uaco', peonX + 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ugho', peonX + 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + + // Create a patch of blight around the start location. + call SetBlightLoc(whichPlayer,startLoc, 768, true) + + // Set random hero spawn point to be just south of the start location. + set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing) + endif + + if (doHeroes) then + // If the "Random Hero" option is set, start the player with a random hero. + // Otherwise, give them a "free hero" token. + if useRandomHero then + call MeleeRandomHeroLoc(whichPlayer, 'Udea', 'Udre', 'Ulic', 'Ucrl', heroLoc) + else + call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS) + endif + endif + + if (doCamera) then + // Center the camera on the initial Acolytes. + call SetCameraPositionForPlayer(whichPlayer, peonX, peonY) + call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY) + endif +endfunction + +//=========================================================================== +// Starting Units for Night Elf Players +// - 1 Tree of Life, placed by nearest gold mine, already entangled +// - 5 Wisps, placed between Tree of Life and nearest gold mine +// +function MeleeStartingUnitsNightElf takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing + local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO) + local real unitSpacing = 64.00 + local real minTreeDist = 3.50 * bj_CELLWIDTH + local real minWispDist = 1.75 * bj_CELLWIDTH + local unit nearestMine + local location nearMineLoc + local location wispLoc + local location heroLoc + local real peonX + local real peonY + local unit tree + + if (doPreload) then + call Preloader( "scripts\\NightElfMelee.pld" ) + endif + + set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS) + if (nearestMine != null) then + // Spawn Tree of Life near the mine and have it entangle the mine. + // Project the Tree's coordinates from the gold mine, and then snap + // the X and Y values to within minTreeDist of the Gold Mine. + set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 650, 0) + set nearMineLoc = MeleeGetLocWithinRect(nearMineLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minTreeDist)) + set tree = CreateUnitAtLoc(whichPlayer, 'etol', nearMineLoc, bj_UNIT_FACING) + call IssueTargetOrder(tree, "entangleinstant", nearestMine) + + // Spawn Wisps at the start location. + set wispLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0) + set wispLoc = MeleeGetLocWithinRect(wispLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minWispDist)) + set peonX = GetLocationX(wispLoc) + set peonY = GetLocationY(wispLoc) + call CreateUnit(whichPlayer, 'ewsp', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX + 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX - 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be off to the side of the start location. + set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45) + else + // Spawn Tree of Life at the start location. + call CreateUnitAtLoc(whichPlayer, 'etol', startLoc, bj_UNIT_FACING) + + // Spawn Wisps directly south of the town hall. + set peonX = GetLocationX(startLoc) + set peonY = GetLocationY(startLoc) - 224.00 + call CreateUnit(whichPlayer, 'ewsp', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + call CreateUnit(whichPlayer, 'ewsp', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING) + + // Set random hero spawn point to be just south of the start location. + set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing) + endif + + if (doHeroes) then + // If the "Random Hero" option is set, start the player with a random hero. + // Otherwise, give them a "free hero" token. + if useRandomHero then + call MeleeRandomHeroLoc(whichPlayer, 'Edem', 'Ekee', 'Emoo', 'Ewar', heroLoc) + else + call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS) + endif + endif + + if (doCamera) then + // Center the camera on the initial Wisps. + call SetCameraPositionForPlayer(whichPlayer, peonX, peonY) + call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY) + endif +endfunction + +//=========================================================================== +// Starting Units for Players Whose Race is Unknown +// - 12 Sheep, placed randomly around the start location +// +function MeleeStartingUnitsUnknownRace takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing + local integer index + + if (doPreload) then + endif + + set index = 0 + loop + call CreateUnit(whichPlayer, 'nshe', GetLocationX(startLoc) + GetRandomReal(-256, 256), GetLocationY(startLoc) + GetRandomReal(-256, 256), GetRandomReal(0, 360)) + set index = index + 1 + exitwhen index == 12 + endloop + + if (doHeroes) then + // Give them a "free hero" token, out of pity. + call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS) + endif + + if (doCamera) then + // Center the camera on the initial sheep. + call SetCameraPositionLocForPlayer(whichPlayer, startLoc) + call SetCameraQuickPositionLocForPlayer(whichPlayer, startLoc) + endif +endfunction + +//=========================================================================== +function MeleeStartingUnits takes nothing returns nothing + local integer index + local player indexPlayer + local location indexStartLoc + local race indexRace + + call Preloader( "scripts\\SharedMelee.pld" ) + + set index = 0 + loop + set indexPlayer = Player(index) + if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then + set indexStartLoc = GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)) + set indexRace = GetPlayerRace(indexPlayer) + + // Create initial race-specific starting units + if (indexRace == RACE_HUMAN) then + call MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true) + elseif (indexRace == RACE_ORC) then + call MeleeStartingUnitsOrc(indexPlayer, indexStartLoc, true, true, true) + elseif (indexRace == RACE_UNDEAD) then + call MeleeStartingUnitsUndead(indexPlayer, indexStartLoc, true, true, true) + elseif (indexRace == RACE_NIGHTELF) then + call MeleeStartingUnitsNightElf(indexPlayer, indexStartLoc, true, true, true) + else + call MeleeStartingUnitsUnknownRace(indexPlayer, indexStartLoc, true, true, true) + endif + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + +endfunction + +//=========================================================================== +function MeleeStartingUnitsForPlayer takes race whichRace, player whichPlayer, location loc, boolean doHeroes returns nothing + // Create initial race-specific starting units + if (whichRace == RACE_HUMAN) then + call MeleeStartingUnitsHuman(whichPlayer, loc, doHeroes, false, false) + elseif (whichRace == RACE_ORC) then + call MeleeStartingUnitsOrc(whichPlayer, loc, doHeroes, false, false) + elseif (whichRace == RACE_UNDEAD) then + call MeleeStartingUnitsUndead(whichPlayer, loc, doHeroes, false, false) + elseif (whichRace == RACE_NIGHTELF) then + call MeleeStartingUnitsNightElf(whichPlayer, loc, doHeroes, false, false) + else + // Unrecognized race - ignore the request. + endif +endfunction + + + +//*************************************************************************** +//* +//* Melee Template Starting AI Scripts +//* +//*************************************************************************** + +//=========================================================================== +function PickMeleeAI takes player num, string s1, string s2, string s3 returns nothing + local integer pick + + // easy difficulty never uses any custom AI scripts + // that are designed to be a bit more challenging + // + if GetAIDifficulty(num) == AI_DIFFICULTY_NEWBIE then + call StartMeleeAI(num,s1) + return + endif + + if s2 == null then + set pick = 1 + elseif s3 == null then + set pick = GetRandomInt(1,2) + else + set pick = GetRandomInt(1,3) + endif + + if pick == 1 then + call StartMeleeAI(num,s1) + elseif pick == 2 then + call StartMeleeAI(num,s2) + else + call StartMeleeAI(num,s3) + endif +endfunction + +//=========================================================================== +function MeleeStartingAI takes nothing returns nothing + local integer index + local player indexPlayer + local race indexRace + + set index = 0 + loop + set indexPlayer = Player(index) + if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then + set indexRace = GetPlayerRace(indexPlayer) + if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then + // Run a race-specific melee AI script. + if (indexRace == RACE_HUMAN) then + call PickMeleeAI(indexPlayer, "human.ai", null, null) + elseif (indexRace == RACE_ORC) then + call PickMeleeAI(indexPlayer, "orc.ai", null, null) + elseif (indexRace == RACE_UNDEAD) then + call PickMeleeAI(indexPlayer, "undead.ai", null, null) + call RecycleGuardPosition(bj_ghoul[index]) + elseif (indexRace == RACE_NIGHTELF) then + call PickMeleeAI(indexPlayer, "elf.ai", null, null) + else + // Unrecognized race. + endif + call ShareEverythingWithTeamAI(indexPlayer) + endif + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + +function LockGuardPosition takes unit targ returns nothing + call SetUnitCreepGuard(targ,true) +endfunction + + +//*************************************************************************** +//* +//* Melee Template Victory / Defeat Conditions +//* +//*************************************************************************** + +//=========================================================================== +function MeleePlayerIsOpponent takes integer playerIndex, integer opponentIndex returns boolean + local player thePlayer = Player(playerIndex) + local player theOpponent = Player(opponentIndex) + + // The player himself is not an opponent. + if (playerIndex == opponentIndex) then + return false + endif + + // Unused player slots are not opponents. + if (GetPlayerSlotState(theOpponent) != PLAYER_SLOT_STATE_PLAYING) then + return false + endif + + // Players who are already defeated are not opponents. + if (bj_meleeDefeated[opponentIndex]) then + return false + endif + + // Allied players with allied victory set are not opponents. + if GetPlayerAlliance(thePlayer, theOpponent, ALLIANCE_PASSIVE) then + if GetPlayerAlliance(theOpponent, thePlayer, ALLIANCE_PASSIVE) then + if (GetPlayerState(thePlayer, PLAYER_STATE_ALLIED_VICTORY) == 1) then + if (GetPlayerState(theOpponent, PLAYER_STATE_ALLIED_VICTORY) == 1) then + return false + endif + endif + endif + endif + + return true +endfunction + +//=========================================================================== +// Count buildings currently owned by all allies, including the player themself. +// +function MeleeGetAllyStructureCount takes player whichPlayer returns integer + local integer playerIndex + local integer buildingCount + local player indexPlayer + + // Count the number of buildings controlled by all not-yet-defeated co-allies. + set buildingCount = 0 + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + + // uncomment to cause defeat even if you have control of ally structures, but yours have been nixed + //if (PlayersAreCoAllied(whichPlayer, indexPlayer) and not bj_meleeDefeated[playerIndex]) then + if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then + set buildingCount = buildingCount + GetPlayerStructureCount(indexPlayer, true) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + return buildingCount +endfunction + +//=========================================================================== +// Count allies, excluding dead players and the player themself. +// +function MeleeGetAllyCount takes player whichPlayer returns integer + local integer playerIndex + local integer playerCount + local player indexPlayer + + // Count the number of not-yet-defeated co-allies. + set playerCount = 0 + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if PlayersAreCoAllied(whichPlayer, indexPlayer) and not bj_meleeDefeated[playerIndex] and (whichPlayer != indexPlayer) then + set playerCount = playerCount + 1 + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + return playerCount +endfunction + +//=========================================================================== +// Counts key structures owned by a player and his or her allies, including +// structures currently upgrading or under construction. +// +// Key structures: Town Hall, Great Hall, Tree of Life, Necropolis +// +function MeleeGetAllyKeyStructureCount takes player whichPlayer returns integer + local integer playerIndex + local player indexPlayer + local integer keyStructs + + // Count the number of buildings controlled by all not-yet-defeated co-allies. + set keyStructs = 0 + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then + set keyStructs = keyStructs + BlzGetPlayerTownHallCount(indexPlayer) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + return keyStructs +endfunction + +//=========================================================================== +// Enum: Draw out a specific player. +// +function MeleeDoDrawEnum takes nothing returns nothing + local player thePlayer = GetEnumPlayer() + + call CachePlayerHeroData(thePlayer) + call RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_TIE, false) +endfunction + +//=========================================================================== +// Enum: Victory out a specific player. +// +function MeleeDoVictoryEnum takes nothing returns nothing + local player thePlayer = GetEnumPlayer() + local integer playerIndex = GetPlayerId(thePlayer) + + if (not bj_meleeVictoried[playerIndex]) then + set bj_meleeVictoried[playerIndex] = true + call CachePlayerHeroData(thePlayer) + call RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_VICTORY, false) + endif +endfunction + +//=========================================================================== +// Defeat out a specific player. +// +function MeleeDoDefeat takes player whichPlayer returns nothing + set bj_meleeDefeated[GetPlayerId(whichPlayer)] = true + call RemovePlayerPreserveUnitsBJ(whichPlayer, PLAYER_GAME_RESULT_DEFEAT, false) +endfunction + +//=========================================================================== +// Enum: Defeat out a specific player. +// +function MeleeDoDefeatEnum takes nothing returns nothing + local player thePlayer = GetEnumPlayer() + + // needs to happen before ownership change + call CachePlayerHeroData(thePlayer) + call MakeUnitsPassiveForTeam(thePlayer) + call MeleeDoDefeat(thePlayer) +endfunction + +//=========================================================================== +// A specific player left the game. +// +function MeleeDoLeave takes player whichPlayer returns nothing + if (GetIntegerGameState(GAME_STATE_DISCONNECTED) != 0) then + call GameOverDialogBJ( whichPlayer, true ) + else + set bj_meleeDefeated[GetPlayerId(whichPlayer)] = true + call RemovePlayerPreserveUnitsBJ(whichPlayer, PLAYER_GAME_RESULT_DEFEAT, true) + endif +endfunction + +//=========================================================================== +// Remove all observers +// +function MeleeRemoveObservers takes nothing returns nothing + local integer playerIndex + local player indexPlayer + + // Give all observers the game over dialog + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + + if (IsPlayerObserver(indexPlayer)) then + call RemovePlayerPreserveUnitsBJ(indexPlayer, PLAYER_GAME_RESULT_NEUTRAL, false) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Test all players to determine if a team has won. For a team to win, all +// remaining (read: undefeated) players need to be co-allied with all other +// remaining players. If even one player is not allied towards another, +// everyone must be denied victory. +// +function MeleeCheckForVictors takes nothing returns force + local integer playerIndex + local integer opponentIndex + local force opponentlessPlayers = CreateForce() + local boolean gameOver = false + + // Check to see if any players have opponents remaining. + set playerIndex = 0 + loop + if (not bj_meleeDefeated[playerIndex]) then + // Determine whether or not this player has any remaining opponents. + set opponentIndex = 0 + loop + // If anyone has an opponent, noone can be victorious yet. + if MeleePlayerIsOpponent(playerIndex, opponentIndex) then + return CreateForce() + endif + + set opponentIndex = opponentIndex + 1 + exitwhen opponentIndex == bj_MAX_PLAYERS + endloop + + // Keep track of each opponentless player so that we can give + // them a victory later. + call ForceAddPlayer(opponentlessPlayers, Player(playerIndex)) + set gameOver = true + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + // Set the game over global flag + set bj_meleeGameOver = gameOver + + return opponentlessPlayers +endfunction + +//=========================================================================== +// Test each player to determine if anyone has been defeated. +// +function MeleeCheckForLosersAndVictors takes nothing returns nothing + local integer playerIndex + local player indexPlayer + local force defeatedPlayers = CreateForce() + local force victoriousPlayers + local boolean gameOver = false + + // If the game is already over, do nothing + if (bj_meleeGameOver) then + return + endif + + // If the game was disconnected then it is over, in this case we + // don't want to report results for anyone as they will most likely + // conflict with the actual game results + if (GetIntegerGameState(GAME_STATE_DISCONNECTED) != 0) then + set bj_meleeGameOver = true + return + endif + + // Check each player to see if he or she has been defeated yet. + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + + if (not bj_meleeDefeated[playerIndex] and not bj_meleeVictoried[playerIndex]) then + //call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "Player"+I2S(playerIndex)+" has "+I2S(MeleeGetAllyStructureCount(indexPlayer))+" ally buildings.") + if (MeleeGetAllyStructureCount(indexPlayer) <= 0) then + + // Keep track of each defeated player so that we can give + // them a defeat later. + call ForceAddPlayer(defeatedPlayers, Player(playerIndex)) + + // Set their defeated flag now so MeleeCheckForVictors + // can detect victors. + set bj_meleeDefeated[playerIndex] = true + endif + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + // Now that the defeated flags are set, check if there are any victors + set victoriousPlayers = MeleeCheckForVictors() + + // Defeat all defeated players + call ForForce(defeatedPlayers, function MeleeDoDefeatEnum) + + // Give victory to all victorious players + call ForForce(victoriousPlayers, function MeleeDoVictoryEnum) + + // If the game is over we should remove all observers + if (bj_meleeGameOver) then + call MeleeRemoveObservers() + endif +endfunction + +//=========================================================================== +// Returns a race-specific "build X or be revealed" message. +// +function MeleeGetCrippledWarningMessage takes player whichPlayer returns string + local race r = GetPlayerRace(whichPlayer) + + if (r == RACE_HUMAN) then + return GetLocalizedString("CRIPPLE_WARNING_HUMAN") + elseif (r == RACE_ORC) then + return GetLocalizedString("CRIPPLE_WARNING_ORC") + elseif (r == RACE_NIGHTELF) then + return GetLocalizedString("CRIPPLE_WARNING_NIGHTELF") + elseif (r == RACE_UNDEAD) then + return GetLocalizedString("CRIPPLE_WARNING_UNDEAD") + else + // Unrecognized Race + return "" + endif +endfunction + +//=========================================================================== +// Returns a race-specific "build X" label for cripple timers. +// +function MeleeGetCrippledTimerMessage takes player whichPlayer returns string + local race r = GetPlayerRace(whichPlayer) + + if (r == RACE_HUMAN) then + return GetLocalizedString("CRIPPLE_TIMER_HUMAN") + elseif (r == RACE_ORC) then + return GetLocalizedString("CRIPPLE_TIMER_ORC") + elseif (r == RACE_NIGHTELF) then + return GetLocalizedString("CRIPPLE_TIMER_NIGHTELF") + elseif (r == RACE_UNDEAD) then + return GetLocalizedString("CRIPPLE_TIMER_UNDEAD") + else + // Unrecognized Race + return "" + endif +endfunction + +//=========================================================================== +// Returns a race-specific "build X" label for cripple timers. +// +function MeleeGetCrippledRevealedMessage takes player whichPlayer returns string + return GetLocalizedString("CRIPPLE_REVEALING_PREFIX") + GetPlayerName(whichPlayer) + GetLocalizedString("CRIPPLE_REVEALING_POSTFIX") +endfunction + +//=========================================================================== +function MeleeExposePlayer takes player whichPlayer, boolean expose returns nothing + local integer playerIndex + local player indexPlayer + local force toExposeTo = CreateForce() + + call CripplePlayer( whichPlayer, toExposeTo, false ) + + set bj_playerIsExposed[GetPlayerId(whichPlayer)] = expose + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if (not PlayersAreCoAllied(whichPlayer, indexPlayer)) then + call ForceAddPlayer( toExposeTo, indexPlayer ) + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + call CripplePlayer( whichPlayer, toExposeTo, expose ) + call DestroyForce(toExposeTo) +endfunction + +//=========================================================================== +function MeleeExposeAllPlayers takes nothing returns nothing + local integer playerIndex + local player indexPlayer + local integer playerIndex2 + local player indexPlayer2 + local force toExposeTo = CreateForce() + + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + + call ForceClear( toExposeTo ) + call CripplePlayer( indexPlayer, toExposeTo, false ) + + set playerIndex2 = 0 + loop + set indexPlayer2 = Player(playerIndex2) + + if playerIndex != playerIndex2 then + if (not PlayersAreCoAllied(indexPlayer, indexPlayer2)) then + call ForceAddPlayer( toExposeTo, indexPlayer2 ) + endif + endif + + set playerIndex2 = playerIndex2 + 1 + exitwhen playerIndex2 == bj_MAX_PLAYERS + endloop + + call CripplePlayer( indexPlayer, toExposeTo, true ) + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + call DestroyForce( toExposeTo ) +endfunction + +//=========================================================================== +function MeleeCrippledPlayerTimeout takes nothing returns nothing + local timer expiredTimer = GetExpiredTimer() + local integer playerIndex + local player exposedPlayer + + // Determine which player's timer expired. + set playerIndex = 0 + loop + if (bj_crippledTimer[playerIndex] == expiredTimer) then + exitwhen true + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + if (playerIndex == bj_MAX_PLAYERS) then + return + endif + set exposedPlayer = Player(playerIndex) + + if (GetLocalPlayer() == exposedPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + // Hide the timer window for this player. + call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false) + endif + + // Display a text message to all players, explaining the exposure. + call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, MeleeGetCrippledRevealedMessage(exposedPlayer)) + + // Expose the player. + call MeleeExposePlayer(exposedPlayer, true) +endfunction + +//=========================================================================== +function MeleePlayerIsCrippled takes player whichPlayer returns boolean + local integer playerStructures = GetPlayerStructureCount(whichPlayer, true) + local integer playerKeyStructures = BlzGetPlayerTownHallCount(whichPlayer) + + // Dead players are not considered to be crippled. + return (playerStructures > 0) and (playerKeyStructures <= 0) +endfunction + +//=========================================================================== +// Test each player to determine if anyone has become crippled. +// +function MeleeCheckForCrippledPlayers takes nothing returns nothing + local integer playerIndex + local player indexPlayer + local force crippledPlayers = CreateForce() + local boolean isNowCrippled + local race indexRace + + // The "finish soon" exposure of all players overrides any "crippled" exposure + if bj_finishSoonAllExposed then + return + endif + + // Check each player to see if he or she has been crippled or uncrippled. + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + set isNowCrippled = MeleePlayerIsCrippled(indexPlayer) + + if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then + + // Player became crippled; start their cripple timer. + set bj_playerIsCrippled[playerIndex] = true + call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout) + + if (GetLocalPlayer() == indexPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + // Show the timer window. + call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true) + + // Display a warning message. + call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, MeleeGetCrippledWarningMessage(indexPlayer)) + endif + + elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then + + // Player became uncrippled; stop their cripple timer. + set bj_playerIsCrippled[playerIndex] = false + call PauseTimer(bj_crippledTimer[playerIndex]) + + if (GetLocalPlayer() == indexPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + // Hide the timer window for this player. + call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false) + + // Display a confirmation message if the player's team is still alive. + if (MeleeGetAllyStructureCount(indexPlayer) > 0) then + if (bj_playerIsExposed[playerIndex]) then + call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED")) + else + call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED")) + endif + endif + endif + + // If the player granted shared vision, deny that vision now. + call MeleeExposePlayer(indexPlayer, false) + + endif + + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Determine if the lost unit should result in any defeats or victories. +// +function MeleeCheckLostUnit takes unit lostUnit returns nothing + local player lostUnitOwner = GetOwningPlayer(lostUnit) + + // We only need to check for mortality if this was the last building. + if (GetPlayerStructureCount(lostUnitOwner, true) <= 0) then + call MeleeCheckForLosersAndVictors() + endif + + // Check if the lost unit has crippled or uncrippled the player. + // (A team with 0 units is dead, and thus considered uncrippled.) + call MeleeCheckForCrippledPlayers() +endfunction + +//=========================================================================== +// Determine if the gained unit should result in any defeats, victories, +// or cripple-status changes. +// +function MeleeCheckAddedUnit takes unit addedUnit returns nothing + local player addedUnitOwner = GetOwningPlayer(addedUnit) + + // If the player was crippled, this unit may have uncrippled him/her. + if (bj_playerIsCrippled[GetPlayerId(addedUnitOwner)]) then + call MeleeCheckForCrippledPlayers() + endif +endfunction + +//=========================================================================== +function MeleeTriggerActionConstructCancel takes nothing returns nothing + call MeleeCheckLostUnit(GetCancelledStructure()) +endfunction + +//=========================================================================== +function MeleeTriggerActionUnitDeath takes nothing returns nothing + if (IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE)) then + call MeleeCheckLostUnit(GetDyingUnit()) + endif +endfunction + +//=========================================================================== +function MeleeTriggerActionUnitConstructionStart takes nothing returns nothing + call MeleeCheckAddedUnit(GetConstructingStructure()) +endfunction + +//=========================================================================== +function MeleeTriggerActionPlayerDefeated takes nothing returns nothing + local player thePlayer = GetTriggerPlayer() + call CachePlayerHeroData(thePlayer) + + if (MeleeGetAllyCount(thePlayer) > 0) then + // If at least one ally is still alive and kicking, share units with + // them and proceed with death. + call ShareEverythingWithTeam(thePlayer) + if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then + call MeleeDoDefeat(thePlayer) + endif + else + // If no living allies remain, swap all units and buildings over to + // neutral_passive and proceed with death. + call MakeUnitsPassiveForTeam(thePlayer) + if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then + call MeleeDoDefeat(thePlayer) + endif + endif + call MeleeCheckForLosersAndVictors() +endfunction + +//=========================================================================== +function MeleeTriggerActionPlayerLeft takes nothing returns nothing + local player thePlayer = GetTriggerPlayer() + + // Just show game over for observers when they leave + if (IsPlayerObserver(thePlayer)) then + call RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_NEUTRAL, false) + return + endif + + call CachePlayerHeroData(thePlayer) + + // This is the same as defeat except the player generates the message + // "player left the game" as opposed to "player was defeated". + + if (MeleeGetAllyCount(thePlayer) > 0) then + // If at least one ally is still alive and kicking, share units with + // them and proceed with death. + call ShareEverythingWithTeam(thePlayer) + call MeleeDoLeave(thePlayer) + else + // If no living allies remain, swap all units and buildings over to + // neutral_passive and proceed with death. + call MakeUnitsPassiveForTeam(thePlayer) + call MeleeDoLeave(thePlayer) + endif + call MeleeCheckForLosersAndVictors() +endfunction + +//=========================================================================== +function MeleeTriggerActionAllianceChange takes nothing returns nothing + call MeleeCheckForLosersAndVictors() + call MeleeCheckForCrippledPlayers() +endfunction + +//=========================================================================== +function MeleeTriggerTournamentFinishSoon takes nothing returns nothing + // Note: We may get this trigger multiple times + local integer playerIndex + local player indexPlayer + local real timeRemaining = GetTournamentFinishSoonTimeRemaining() + + if not bj_finishSoonAllExposed then + set bj_finishSoonAllExposed = true + + // Reset all crippled players and their timers, and hide the local crippled timer dialog + set playerIndex = 0 + loop + set indexPlayer = Player(playerIndex) + if bj_playerIsCrippled[playerIndex] then + // Uncripple the player + set bj_playerIsCrippled[playerIndex] = false + call PauseTimer(bj_crippledTimer[playerIndex]) + + if (GetLocalPlayer() == indexPlayer) then + // Use only local code (no net traffic) within this block to avoid desyncs. + + // Hide the timer window. + call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false) + endif + + endif + set playerIndex = playerIndex + 1 + exitwhen playerIndex == bj_MAX_PLAYERS + endloop + + // Expose all players + call MeleeExposeAllPlayers() + endif + + // Show the "finish soon" timer dialog and set the real time remaining + call TimerDialogDisplay(bj_finishSoonTimerDialog, true) + call TimerDialogSetRealTimeRemaining(bj_finishSoonTimerDialog, timeRemaining) +endfunction + + +//=========================================================================== +function MeleeWasUserPlayer takes player whichPlayer returns boolean + local playerslotstate slotState + + if (GetPlayerController(whichPlayer) != MAP_CONTROL_USER) then + return false + endif + + set slotState = GetPlayerSlotState(whichPlayer) + + return (slotState == PLAYER_SLOT_STATE_PLAYING or slotState == PLAYER_SLOT_STATE_LEFT) +endfunction + +//=========================================================================== +function MeleeTournamentFinishNowRuleA takes integer multiplier returns nothing + local integer array playerScore + local integer array teamScore + local force array teamForce + local integer teamCount + local integer index + local player indexPlayer + local integer index2 + local player indexPlayer2 + local integer bestTeam + local integer bestScore + local boolean draw + + // Compute individual player scores + set index = 0 + loop + set indexPlayer = Player(index) + if MeleeWasUserPlayer(indexPlayer) then + set playerScore[index] = GetTournamentScore(indexPlayer) + if playerScore[index] <= 0 then + set playerScore[index] = 1 + endif + else + set playerScore[index] = 0 + endif + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + // Compute team scores and team forces + set teamCount = 0 + set index = 0 + loop + if playerScore[index] != 0 then + set indexPlayer = Player(index) + + set teamScore[teamCount] = 0 + set teamForce[teamCount] = CreateForce() + + set index2 = index + loop + if playerScore[index2] != 0 then + set indexPlayer2 = Player(index2) + + if PlayersAreCoAllied(indexPlayer, indexPlayer2) then + set teamScore[teamCount] = teamScore[teamCount] + playerScore[index2] + call ForceAddPlayer(teamForce[teamCount], indexPlayer2) + set playerScore[index2] = 0 + endif + endif + + set index2 = index2 + 1 + exitwhen index2 == bj_MAX_PLAYERS + endloop + + set teamCount = teamCount + 1 + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + // The game is now over + set bj_meleeGameOver = true + + // There should always be at least one team, but continue to work if not + if teamCount != 0 then + + // Find best team score + set bestTeam = -1 + set bestScore = -1 + set index = 0 + loop + if teamScore[index] > bestScore then + set bestTeam = index + set bestScore = teamScore[index] + endif + + set index = index + 1 + exitwhen index == teamCount + endloop + + // Check whether the best team's score is 'multiplier' times better than + // every other team. In the case of multiplier == 1 and exactly equal team + // scores, the first team (which was randomly chosen by the server) will win. + set draw = false + set index = 0 + loop + if index != bestTeam then + if bestScore < (multiplier * teamScore[index]) then + set draw = true + endif + endif + + set index = index + 1 + exitwhen index == teamCount + endloop + + if draw then + // Give draw to all players on all teams + set index = 0 + loop + call ForForce(teamForce[index], function MeleeDoDrawEnum) + + set index = index + 1 + exitwhen index == teamCount + endloop + else + // Give defeat to all players on teams other than the best team + set index = 0 + loop + if index != bestTeam then + call ForForce(teamForce[index], function MeleeDoDefeatEnum) + endif + + set index = index + 1 + exitwhen index == teamCount + endloop + + // Give victory to all players on the best team + call ForForce(teamForce[bestTeam], function MeleeDoVictoryEnum) + endif + endif + +endfunction + +//=========================================================================== +function MeleeTriggerTournamentFinishNow takes nothing returns nothing + local integer rule = GetTournamentFinishNowRule() + + // If the game is already over, do nothing + if bj_meleeGameOver then + return + endif + + if (rule == 1) then + // Finals games + call MeleeTournamentFinishNowRuleA(1) + else + // Preliminary games + call MeleeTournamentFinishNowRuleA(3) + endif + + // Since the game is over we should remove all observers + call MeleeRemoveObservers() + +endfunction + +//=========================================================================== +function MeleeInitVictoryDefeat takes nothing returns nothing + local trigger trig + local integer index + local player indexPlayer + + // Create a timer window for the "finish soon" timeout period, it has no timer + // because it is driven by real time (outside of the game state to avoid desyncs) + set bj_finishSoonTimerDialog = CreateTimerDialog(null) + + // Set a trigger to fire when we receive a "finish soon" game event + set trig = CreateTrigger() + call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_SOON) + call TriggerAddAction(trig, function MeleeTriggerTournamentFinishSoon) + + // Set a trigger to fire when we receive a "finish now" game event + set trig = CreateTrigger() + call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_NOW) + call TriggerAddAction(trig, function MeleeTriggerTournamentFinishNow) + + // Set up each player's mortality code. + set index = 0 + loop + set indexPlayer = Player(index) + + // Make sure this player slot is playing. + if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then + set bj_meleeDefeated[index] = false + set bj_meleeVictoried[index] = false + + // Create a timer and timer window in case the player is crippled. + set bj_playerIsCrippled[index] = false + set bj_playerIsExposed[index] = false + set bj_crippledTimer[index] = CreateTimer() + set bj_crippledTimerWindows[index] = CreateTimerDialog(bj_crippledTimer[index]) + call TimerDialogSetTitle(bj_crippledTimerWindows[index], MeleeGetCrippledTimerMessage(indexPlayer)) + + // Set a trigger to fire whenever a building is cancelled for this player. + set trig = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL, null) + call TriggerAddAction(trig, function MeleeTriggerActionConstructCancel) + + // Set a trigger to fire whenever a unit dies for this player. + set trig = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_DEATH, null) + call TriggerAddAction(trig, function MeleeTriggerActionUnitDeath) + + // Set a trigger to fire whenever a unit begins construction for this player + set trig = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_START, null) + call TriggerAddAction(trig, function MeleeTriggerActionUnitConstructionStart) + + // Set a trigger to fire whenever this player defeats-out + set trig = CreateTrigger() + call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_DEFEAT) + call TriggerAddAction(trig, function MeleeTriggerActionPlayerDefeated) + + // Set a trigger to fire whenever this player leaves + set trig = CreateTrigger() + call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE) + call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft) + + // Set a trigger to fire whenever this player changes his/her alliances. + set trig = CreateTrigger() + call TriggerRegisterPlayerAllianceChange(trig, indexPlayer, ALLIANCE_PASSIVE) + call TriggerRegisterPlayerStateEvent(trig, indexPlayer, PLAYER_STATE_ALLIED_VICTORY, EQUAL, 1) + call TriggerAddAction(trig, function MeleeTriggerActionAllianceChange) + else + set bj_meleeDefeated[index] = true + set bj_meleeVictoried[index] = false + + // Handle leave events for observers + if (IsPlayerObserver(indexPlayer)) then + // Set a trigger to fire whenever this player leaves + set trig = CreateTrigger() + call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE) + call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft) + endif + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + + // Test for victory / defeat at startup, in case the user has already won / lost. + // Allow for a short time to pass first, so that the map can finish loading. + call TimerStart(CreateTimer(), 2.0, false, function MeleeTriggerActionAllianceChange) +endfunction + + + +//*************************************************************************** +//* +//* Player Slot Availability +//* +//*************************************************************************** + +//=========================================================================== +function CheckInitPlayerSlotAvailability takes nothing returns nothing + local integer index + + if (not bj_slotControlReady) then + set index = 0 + loop + set bj_slotControlUsed[index] = false + set bj_slotControl[index] = MAP_CONTROL_USER + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop + set bj_slotControlReady = true + endif +endfunction + +//=========================================================================== +function SetPlayerSlotAvailable takes player whichPlayer, mapcontrol control returns nothing + local integer playerIndex = GetPlayerId(whichPlayer) + + call CheckInitPlayerSlotAvailability() + set bj_slotControlUsed[playerIndex] = true + set bj_slotControl[playerIndex] = control +endfunction + + + +//*************************************************************************** +//* +//* Generic Template Player-slot Initialization +//* +//*************************************************************************** + +//=========================================================================== +function TeamInitPlayerSlots takes integer teamCount returns nothing + local integer index + local player indexPlayer + local integer team + + call SetTeams(teamCount) + + call CheckInitPlayerSlotAvailability() + set index = 0 + set team = 0 + loop + if (bj_slotControlUsed[index]) then + set indexPlayer = Player(index) + call SetPlayerTeam( indexPlayer, team ) + set team = team + 1 + if (team >= teamCount) then + set team = 0 + endif + endif + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +function MeleeInitPlayerSlots takes nothing returns nothing + call TeamInitPlayerSlots(bj_MAX_PLAYERS) +endfunction + +//=========================================================================== +function FFAInitPlayerSlots takes nothing returns nothing + call TeamInitPlayerSlots(bj_MAX_PLAYERS) +endfunction + +//=========================================================================== +function OneOnOneInitPlayerSlots takes nothing returns nothing + // Limit the game to 2 players. + call SetTeams(2) + call SetPlayers(2) + call TeamInitPlayerSlots(2) +endfunction + +//=========================================================================== +function InitGenericPlayerSlots takes nothing returns nothing + local gametype gType = GetGameTypeSelected() + + if (gType == GAME_TYPE_MELEE) then + call MeleeInitPlayerSlots() + elseif (gType == GAME_TYPE_FFA) then + call FFAInitPlayerSlots() + elseif (gType == GAME_TYPE_USE_MAP_SETTINGS) then + // Do nothing; the map-specific script handles this. + elseif (gType == GAME_TYPE_ONE_ON_ONE) then + call OneOnOneInitPlayerSlots() + elseif (gType == GAME_TYPE_TWO_TEAM_PLAY) then + call TeamInitPlayerSlots(2) + elseif (gType == GAME_TYPE_THREE_TEAM_PLAY) then + call TeamInitPlayerSlots(3) + elseif (gType == GAME_TYPE_FOUR_TEAM_PLAY) then + call TeamInitPlayerSlots(4) + else + // Unrecognized Game Type + endif +endfunction + + + +//*************************************************************************** +//* +//* Blizzard.j Initialization +//* +//*************************************************************************** + +//=========================================================================== +function SetDNCSoundsDawn takes nothing returns nothing + if bj_useDawnDuskSounds then + call StartSound(bj_dawnSound) + endif +endfunction + +//=========================================================================== +function SetDNCSoundsDusk takes nothing returns nothing + if bj_useDawnDuskSounds then + call StartSound(bj_duskSound) + endif +endfunction + +//=========================================================================== +function SetDNCSoundsDay takes nothing returns nothing + local real ToD = GetTimeOfDay() + + if (ToD >= bj_TOD_DAWN and ToD < bj_TOD_DUSK) and not bj_dncIsDaytime then + set bj_dncIsDaytime = true + + // change ambient sounds + call StopSound(bj_nightAmbientSound, false, true) + call StartSound(bj_dayAmbientSound) + endif +endfunction + +//=========================================================================== +function SetDNCSoundsNight takes nothing returns nothing + local real ToD = GetTimeOfDay() + + if (ToD < bj_TOD_DAWN or ToD >= bj_TOD_DUSK) and bj_dncIsDaytime then + set bj_dncIsDaytime = false + + // change ambient sounds + call StopSound(bj_dayAmbientSound, false, true) + call StartSound(bj_nightAmbientSound) + endif +endfunction + +//=========================================================================== +function InitDNCSounds takes nothing returns nothing + // Create sounds to be played at dawn and dusk. + set bj_dawnSound = CreateSoundFromLabel("RoosterSound", false, false, false, 10000, 10000) + set bj_duskSound = CreateSoundFromLabel("WolfSound", false, false, false, 10000, 10000) + + // Set up triggers to respond to dawn and dusk. + set bj_dncSoundsDawn = CreateTrigger() + call TriggerRegisterGameStateEvent(bj_dncSoundsDawn, GAME_STATE_TIME_OF_DAY, EQUAL, bj_TOD_DAWN) + call TriggerAddAction(bj_dncSoundsDawn, function SetDNCSoundsDawn) + + set bj_dncSoundsDusk = CreateTrigger() + call TriggerRegisterGameStateEvent(bj_dncSoundsDusk, GAME_STATE_TIME_OF_DAY, EQUAL, bj_TOD_DUSK) + call TriggerAddAction(bj_dncSoundsDusk, function SetDNCSoundsDusk) + + // Set up triggers to respond to changes from day to night or vice-versa. + set bj_dncSoundsDay = CreateTrigger() + call TriggerRegisterGameStateEvent(bj_dncSoundsDay, GAME_STATE_TIME_OF_DAY, GREATER_THAN_OR_EQUAL, bj_TOD_DAWN) + call TriggerRegisterGameStateEvent(bj_dncSoundsDay, GAME_STATE_TIME_OF_DAY, LESS_THAN, bj_TOD_DUSK) + call TriggerAddAction(bj_dncSoundsDay, function SetDNCSoundsDay) + + set bj_dncSoundsNight = CreateTrigger() + call TriggerRegisterGameStateEvent(bj_dncSoundsNight, GAME_STATE_TIME_OF_DAY, LESS_THAN, bj_TOD_DAWN) + call TriggerRegisterGameStateEvent(bj_dncSoundsNight, GAME_STATE_TIME_OF_DAY, GREATER_THAN_OR_EQUAL, bj_TOD_DUSK) + call TriggerAddAction(bj_dncSoundsNight, function SetDNCSoundsNight) +endfunction + +//=========================================================================== +function InitBlizzardGlobals takes nothing returns nothing + local integer index + local integer userControlledPlayers + local version v + + // Init filter function vars + set filterIssueHauntOrderAtLocBJ = Filter(function IssueHauntOrderAtLocBJFilter) + set filterEnumDestructablesInCircleBJ = Filter(function EnumDestructablesInCircleBJFilter) + set filterGetUnitsInRectOfPlayer = Filter(function GetUnitsInRectOfPlayerFilter) + set filterGetUnitsOfTypeIdAll = Filter(function GetUnitsOfTypeIdAllFilter) + set filterGetUnitsOfPlayerAndTypeId = Filter(function GetUnitsOfPlayerAndTypeIdFilter) + set filterMeleeTrainedUnitIsHeroBJ = Filter(function MeleeTrainedUnitIsHeroBJFilter) + set filterLivingPlayerUnitsOfTypeId = Filter(function LivingPlayerUnitsOfTypeIdFilter) + + // Init force presets + set index = 0 + loop + exitwhen index == bj_MAX_PLAYER_SLOTS + set bj_FORCE_PLAYER[index] = CreateForce() + call ForceAddPlayer(bj_FORCE_PLAYER[index], Player(index)) + set index = index + 1 + endloop + + set bj_FORCE_ALL_PLAYERS = CreateForce() + call ForceEnumPlayers(bj_FORCE_ALL_PLAYERS, null) + + // Init Cinematic Mode history + set bj_cineModePriorSpeed = GetGameSpeed() + set bj_cineModePriorFogSetting = IsFogEnabled() + set bj_cineModePriorMaskSetting = IsFogMaskEnabled() + + // Init Trigger Queue + set index = 0 + loop + exitwhen index >= bj_MAX_QUEUED_TRIGGERS + set bj_queuedExecTriggers[index] = null + set bj_queuedExecUseConds[index] = false + set index = index + 1 + endloop + + // Init singleplayer check + set bj_isSinglePlayer = false + set userControlledPlayers = 0 + set index = 0 + loop + exitwhen index >= bj_MAX_PLAYERS + if (GetPlayerController(Player(index)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(index)) == PLAYER_SLOT_STATE_PLAYING) then + set userControlledPlayers = userControlledPlayers + 1 + endif + set index = index + 1 + endloop + set bj_isSinglePlayer = (userControlledPlayers == 1) + + // Init sounds + //set bj_pingMinimapSound = CreateSoundFromLabel("AutoCastButtonClick", false, false, false, 10000, 10000) + set bj_rescueSound = CreateSoundFromLabel("Rescue", false, false, false, 10000, 10000) + set bj_questDiscoveredSound = CreateSoundFromLabel("QuestNew", false, false, false, 10000, 10000) + set bj_questUpdatedSound = CreateSoundFromLabel("QuestUpdate", false, false, false, 10000, 10000) + set bj_questCompletedSound = CreateSoundFromLabel("QuestCompleted", false, false, false, 10000, 10000) + set bj_questFailedSound = CreateSoundFromLabel("QuestFailed", false, false, false, 10000, 10000) + set bj_questHintSound = CreateSoundFromLabel("Hint", false, false, false, 10000, 10000) + set bj_questSecretSound = CreateSoundFromLabel("SecretFound", false, false, false, 10000, 10000) + set bj_questItemAcquiredSound = CreateSoundFromLabel("ItemReward", false, false, false, 10000, 10000) + set bj_questWarningSound = CreateSoundFromLabel("Warning", false, false, false, 10000, 10000) + set bj_victoryDialogSound = CreateSoundFromLabel("QuestCompleted", false, false, false, 10000, 10000) + set bj_defeatDialogSound = CreateSoundFromLabel("QuestFailed", false, false, false, 10000, 10000) + + // Init corpse creation triggers. + call DelayedSuspendDecayCreate() + + // Init version-specific data + set v = VersionGet() + if (v == VERSION_REIGN_OF_CHAOS) then + set bj_MELEE_MAX_TWINKED_HEROES = bj_MELEE_MAX_TWINKED_HEROES_V0 + else + set bj_MELEE_MAX_TWINKED_HEROES = bj_MELEE_MAX_TWINKED_HEROES_V1 + endif +endfunction + +//=========================================================================== +function InitQueuedTriggers takes nothing returns nothing + set bj_queuedExecTimeout = CreateTrigger() + call TriggerRegisterTimerExpireEvent(bj_queuedExecTimeout, bj_queuedExecTimeoutTimer) + call TriggerAddAction(bj_queuedExecTimeout, function QueuedTriggerDoneBJ) +endfunction + +//=========================================================================== +function InitMapRects takes nothing returns nothing + set bj_mapInitialPlayableArea = Rect(GetCameraBoundMinX()-GetCameraMargin(CAMERA_MARGIN_LEFT), GetCameraBoundMinY()-GetCameraMargin(CAMERA_MARGIN_BOTTOM), GetCameraBoundMaxX()+GetCameraMargin(CAMERA_MARGIN_RIGHT), GetCameraBoundMaxY()+GetCameraMargin(CAMERA_MARGIN_TOP)) + set bj_mapInitialCameraBounds = GetCurrentCameraBoundsMapRectBJ() +endfunction + +//=========================================================================== +function InitSummonableCaps takes nothing returns nothing + local integer index + + set index = 0 + loop + // upgraded units + // Note: Only do this if the corresponding upgrade is not yet researched + // Barrage - Siege Engines + if (not GetPlayerTechResearched(Player(index), 'Rhrt', true)) then + call SetPlayerTechMaxAllowed(Player(index), 'hrtt', 0) + endif + + // Berserker Upgrade - Troll Berserkers + if (not GetPlayerTechResearched(Player(index), 'Robk', true)) then + call SetPlayerTechMaxAllowed(Player(index), 'otbk', 0) + endif + + // max skeletons per player + call SetPlayerTechMaxAllowed(Player(index), 'uske', bj_MAX_SKELETONS) + + set index = index + 1 + exitwhen index == bj_MAX_PLAYERS + endloop +endfunction + +//=========================================================================== +// Update the per-class stock limits. +// +function UpdateStockAvailability takes item whichItem returns nothing + local itemtype iType = GetItemType(whichItem) + local integer iLevel = GetItemLevel(whichItem) + + // Update allowed type/level combinations. + if (iType == ITEM_TYPE_PERMANENT) then + set bj_stockAllowedPermanent[iLevel] = true + elseif (iType == ITEM_TYPE_CHARGED) then + set bj_stockAllowedCharged[iLevel] = true + elseif (iType == ITEM_TYPE_ARTIFACT) then + set bj_stockAllowedArtifact[iLevel] = true + else + // Not interested in this item type - ignore the item. + endif +endfunction + +//=========================================================================== +// Find a sellable item of the given type and level, and then add it. +// +function UpdateEachStockBuildingEnum takes nothing returns nothing + local integer iteration = 0 + local integer pickedItemId + + loop + set pickedItemId = ChooseRandomItemEx(bj_stockPickedItemType, bj_stockPickedItemLevel) + exitwhen IsItemIdSellable(pickedItemId) + + // If we get hung up on an entire class/level combo of unsellable + // items, or a very unlucky series of random numbers, give up. + set iteration = iteration + 1 + if (iteration > bj_STOCK_MAX_ITERATIONS) then + return + endif + endloop + call AddItemToStock(GetEnumUnit(), pickedItemId, 1, 1) +endfunction + +//=========================================================================== +function UpdateEachStockBuilding takes itemtype iType, integer iLevel returns nothing + local group g + + set bj_stockPickedItemType = iType + set bj_stockPickedItemLevel = iLevel + + set g = CreateGroup() + call GroupEnumUnitsOfType(g, "marketplace", null) + call ForGroup(g, function UpdateEachStockBuildingEnum) + call DestroyGroup(g) +endfunction + +//=========================================================================== +// Update stock inventory. +// +function PerformStockUpdates takes nothing returns nothing + local integer pickedItemId + local itemtype pickedItemType + local integer pickedItemLevel = 0 + local integer allowedCombinations = 0 + local integer iLevel + + // Give each type/level combination a chance of being picked. + set iLevel = 1 + loop + if (bj_stockAllowedPermanent[iLevel]) then + set allowedCombinations = allowedCombinations + 1 + if (GetRandomInt(1, allowedCombinations) == 1) then + set pickedItemType = ITEM_TYPE_PERMANENT + set pickedItemLevel = iLevel + endif + endif + if (bj_stockAllowedCharged[iLevel]) then + set allowedCombinations = allowedCombinations + 1 + if (GetRandomInt(1, allowedCombinations) == 1) then + set pickedItemType = ITEM_TYPE_CHARGED + set pickedItemLevel = iLevel + endif + endif + if (bj_stockAllowedArtifact[iLevel]) then + set allowedCombinations = allowedCombinations + 1 + if (GetRandomInt(1, allowedCombinations) == 1) then + set pickedItemType = ITEM_TYPE_ARTIFACT + set pickedItemLevel = iLevel + endif + endif + + set iLevel = iLevel + 1 + exitwhen iLevel > bj_MAX_ITEM_LEVEL + endloop + + // Make sure we found a valid item type to add. + if (allowedCombinations == 0) then + return + endif + + call UpdateEachStockBuilding(pickedItemType, pickedItemLevel) +endfunction + +//=========================================================================== +// Perform the first update, and then arrange future updates. +// +function StartStockUpdates takes nothing returns nothing + call PerformStockUpdates() + call TimerStart(bj_stockUpdateTimer, bj_STOCK_RESTOCK_INTERVAL, true, function PerformStockUpdates) +endfunction + +//=========================================================================== +function RemovePurchasedItem takes nothing returns nothing + call RemoveItemFromStock(GetSellingUnit(), GetItemTypeId(GetSoldItem())) +endfunction + +//=========================================================================== +function InitNeutralBuildings takes nothing returns nothing + local integer iLevel + + // Chart of allowed stock items. + set iLevel = 0 + loop + set bj_stockAllowedPermanent[iLevel] = false + set bj_stockAllowedCharged[iLevel] = false + set bj_stockAllowedArtifact[iLevel] = false + set iLevel = iLevel + 1 + exitwhen iLevel > bj_MAX_ITEM_LEVEL + endloop + + // Limit stock inventory slots. + call SetAllItemTypeSlots(bj_MAX_STOCK_ITEM_SLOTS) + call SetAllUnitTypeSlots(bj_MAX_STOCK_UNIT_SLOTS) + + // Arrange the first update. + set bj_stockUpdateTimer = CreateTimer() + call TimerStart(bj_stockUpdateTimer, bj_STOCK_RESTOCK_INITIAL_DELAY, false, function StartStockUpdates) + + // Set up a trigger to fire whenever an item is sold. + set bj_stockItemPurchased = CreateTrigger() + call TriggerRegisterPlayerUnitEvent(bj_stockItemPurchased, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_SELL_ITEM, null) + call TriggerAddAction(bj_stockItemPurchased, function RemovePurchasedItem) +endfunction + +//=========================================================================== +function MarkGameStarted takes nothing returns nothing + set bj_gameStarted = true + call DestroyTimer(bj_gameStartedTimer) +endfunction + +//=========================================================================== +function DetectGameStarted takes nothing returns nothing + set bj_gameStartedTimer = CreateTimer() + call TimerStart(bj_gameStartedTimer, bj_GAME_STARTED_THRESHOLD, false, function MarkGameStarted) +endfunction + +//=========================================================================== +function InitBlizzard takes nothing returns nothing + // Set up the Neutral Victim player slot, to torture the abandoned units + // of defeated players. Since some triggers expect this player slot to + // exist, this is performed for all maps. + call ConfigureNeutralVictim() + + call InitBlizzardGlobals() + call InitQueuedTriggers() + call InitRescuableBehaviorBJ() + call InitDNCSounds() + call InitMapRects() + call InitSummonableCaps() + call InitNeutralBuildings() + call DetectGameStarted() +endfunction + + + +//*************************************************************************** +//* +//* Random distribution +//* +//* Used to select a random object from a given distribution of chances +//* +//* - RandomDistReset clears the distribution list +//* +//* - RandomDistAddItem adds a new object to the distribution list +//* with a given identifier and an integer chance to be chosen +//* +//* - RandomDistChoose will use the current distribution list to choose +//* one of the objects randomly based on the chance distribution +//* +//* Note that the chances are effectively normalized by their sum, +//* so only the relative values of each chance are important +//* +//*************************************************************************** + +//=========================================================================== +function RandomDistReset takes nothing returns nothing + set bj_randDistCount = 0 +endfunction + +//=========================================================================== +function RandomDistAddItem takes integer inID, integer inChance returns nothing + set bj_randDistID[bj_randDistCount] = inID + set bj_randDistChance[bj_randDistCount] = inChance + set bj_randDistCount = bj_randDistCount + 1 +endfunction + +//=========================================================================== +function RandomDistChoose takes nothing returns integer + local integer sum = 0 + local integer chance = 0 + local integer index + local integer foundID = -1 + local boolean done + + // No items? + if (bj_randDistCount == 0) then + return -1 + endif + + // Find sum of all chances + set index = 0 + loop + set sum = sum + bj_randDistChance[index] + + set index = index + 1 + exitwhen index == bj_randDistCount + endloop + + // Choose random number within the total range + set chance = GetRandomInt(1, sum) + + // Find ID which corresponds to this chance + set index = 0 + set sum = 0 + set done = false + loop + set sum = sum + bj_randDistChance[index] + + if (chance <= sum) then + set foundID = bj_randDistID[index] + set done = true + endif + + set index = index + 1 + if (index == bj_randDistCount) then + set done = true + endif + + exitwhen done == true + endloop + + return foundID +endfunction + + + +//*************************************************************************** +//* +//* Drop item +//* +//* Makes the given unit drop the given item +//* +//* Note: This could potentially cause problems if the unit is standing +//* right on the edge of an unpathable area and happens to drop the +//* item into the unpathable area where nobody can get it... +//* +//*************************************************************************** + +function UnitDropItem takes unit inUnit, integer inItemID returns item + local real x + local real y + local real radius = 32 + local real unitX + local real unitY + local item droppedItem + + if (inItemID == -1) then + return null + endif + + set unitX = GetUnitX(inUnit) + set unitY = GetUnitY(inUnit) + + set x = GetRandomReal(unitX - radius, unitX + radius) + set y = GetRandomReal(unitY - radius, unitY + radius) + + set droppedItem = CreateItem(inItemID, x, y) + + call SetItemDropID(droppedItem, GetUnitTypeId(inUnit)) + call UpdateStockAvailability(droppedItem) + + return droppedItem +endfunction + +//=========================================================================== +function WidgetDropItem takes widget inWidget, integer inItemID returns item + local real x + local real y + local real radius = 32 + local real widgetX + local real widgetY + + if (inItemID == -1) then + return null + endif + + set widgetX = GetWidgetX(inWidget) + set widgetY = GetWidgetY(inWidget) + + set x = GetRandomReal(widgetX - radius, widgetX + radius) + set y = GetRandomReal(widgetY - radius, widgetY + radius) + + return CreateItem(inItemID, x, y) +endfunction + + +//*************************************************************************** +//* +//* Instanced Object Operation Functions +//* +//* Get/Set specific fields for single unit/item/ability instance +//* +//*************************************************************************** + +//=========================================================================== +function BlzIsLastInstanceObjectFunctionSuccessful takes nothing returns boolean + return bj_lastInstObjFuncSuccessful +endfunction + +// Ability +//=========================================================================== +function BlzSetAbilityBooleanFieldBJ takes ability whichAbility, abilitybooleanfield whichField, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanField(whichAbility, whichField, value) +endfunction + +//=========================================================================== +function BlzSetAbilityIntegerFieldBJ takes ability whichAbility, abilityintegerfield whichField, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerField(whichAbility, whichField, value) +endfunction + +//=========================================================================== +function BlzSetAbilityRealFieldBJ takes ability whichAbility, abilityrealfield whichField, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityRealField(whichAbility, whichField, value) +endfunction + +//=========================================================================== +function BlzSetAbilityStringFieldBJ takes ability whichAbility, abilitystringfield whichField, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityStringField(whichAbility, whichField, value) +endfunction + +//=========================================================================== +function BlzSetAbilityBooleanLevelFieldBJ takes ability whichAbility, abilitybooleanlevelfield whichField, integer level, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanLevelField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzSetAbilityIntegerLevelFieldBJ takes ability whichAbility, abilityintegerlevelfield whichField, integer level, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerLevelField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzSetAbilityRealLevelFieldBJ takes ability whichAbility, abilityreallevelfield whichField, integer level, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityRealLevelField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzSetAbilityStringLevelFieldBJ takes ability whichAbility, abilitystringlevelfield whichField, integer level, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityStringLevelField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzSetAbilityBooleanLevelArrayFieldBJ takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, integer index, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanLevelArrayField(whichAbility, whichField, level, index, value) +endfunction + +//=========================================================================== +function BlzSetAbilityIntegerLevelArrayFieldBJ takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer index, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerLevelArrayField(whichAbility, whichField, level, index, value) +endfunction + +//=========================================================================== +function BlzSetAbilityRealLevelArrayFieldBJ takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, integer index, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityRealLevelArrayField(whichAbility, whichField, level, index, value) +endfunction + +//=========================================================================== +function BlzSetAbilityStringLevelArrayFieldBJ takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, integer index, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetAbilityStringLevelArrayField(whichAbility, whichField, level, index, value) +endfunction + +//=========================================================================== +function BlzAddAbilityBooleanLevelArrayFieldBJ takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzAddAbilityBooleanLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzAddAbilityIntegerLevelArrayFieldBJ takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzAddAbilityIntegerLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzAddAbilityRealLevelArrayFieldBJ takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzAddAbilityRealLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzAddAbilityStringLevelArrayFieldBJ takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzAddAbilityStringLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzRemoveAbilityBooleanLevelArrayFieldBJ takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzRemoveAbilityBooleanLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzRemoveAbilityIntegerLevelArrayFieldBJ takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzRemoveAbilityIntegerLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzRemoveAbilityRealLevelArrayFieldBJ takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzRemoveAbilityRealLevelArrayField(whichAbility, whichField, level, value) +endfunction + +//=========================================================================== +function BlzRemoveAbilityStringLevelArrayFieldBJ takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzRemoveAbilityStringLevelArrayField(whichAbility, whichField, level, value) +endfunction + +// Item +//============================================================= +function BlzItemAddAbilityBJ takes item whichItem, integer abilCode returns nothing + set bj_lastInstObjFuncSuccessful = BlzItemAddAbility(whichItem, abilCode) +endfunction + +//=========================================================================== +function BlzItemRemoveAbilityBJ takes item whichItem, integer abilCode returns nothing + set bj_lastInstObjFuncSuccessful = BlzItemRemoveAbility(whichItem, abilCode) +endfunction + +//=========================================================================== +function BlzSetItemBooleanFieldBJ takes item whichItem, itembooleanfield whichField, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetItemBooleanField(whichItem, whichField, value) +endfunction + +//=========================================================================== +function BlzSetItemIntegerFieldBJ takes item whichItem, itemintegerfield whichField, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetItemIntegerField(whichItem, whichField, value) +endfunction + +//=========================================================================== +function BlzSetItemRealFieldBJ takes item whichItem, itemrealfield whichField, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetItemRealField(whichItem, whichField, value) +endfunction + +//=========================================================================== +function BlzSetItemStringFieldBJ takes item whichItem, itemstringfield whichField, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetItemStringField(whichItem, whichField, value) +endfunction + + +// Unit +//=========================================================================== +function BlzSetUnitBooleanFieldBJ takes unit whichUnit, unitbooleanfield whichField, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitBooleanField(whichUnit, whichField, value) +endfunction + +//=========================================================================== +function BlzSetUnitIntegerFieldBJ takes unit whichUnit, unitintegerfield whichField, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitIntegerField(whichUnit, whichField, value) +endfunction + +//=========================================================================== +function BlzSetUnitRealFieldBJ takes unit whichUnit, unitrealfield whichField, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitRealField(whichUnit, whichField, value) +endfunction + +//=========================================================================== +function BlzSetUnitStringFieldBJ takes unit whichUnit, unitstringfield whichField, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitStringField(whichUnit, whichField, value) +endfunction + +// Unit Weapon +//=========================================================================== +function BlzSetUnitWeaponBooleanFieldBJ takes unit whichUnit, unitweaponbooleanfield whichField, integer index, boolean value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponBooleanField(whichUnit, whichField, index, value) +endfunction + +//=========================================================================== +function BlzSetUnitWeaponIntegerFieldBJ takes unit whichUnit, unitweaponintegerfield whichField, integer index, integer value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponIntegerField(whichUnit, whichField, index, value) +endfunction + +//=========================================================================== +function BlzSetUnitWeaponRealFieldBJ takes unit whichUnit, unitweaponrealfield whichField, integer index, real value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponRealField(whichUnit, whichField, index, value) +endfunction + +//=========================================================================== +function BlzSetUnitWeaponStringFieldBJ takes unit whichUnit, unitweaponstringfield whichField, integer index, string value returns nothing + set bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponStringField(whichUnit, whichField, index, value) +endfunction + +//=========================================================================== +function BlzEnableAuras takes unit whichUnit, boolean enable returns nothing + call BlzUnitEnableAuras(whichUnit, enable, false) +endfunction diff --git a/src/main/resources/core-jass/v3.0/common.j b/src/main/resources/core-jass/v3.0/common.j new file mode 100644 index 0000000..7d49d86 --- /dev/null +++ b/src/main/resources/core-jass/v3.0/common.j @@ -0,0 +1,4443 @@ +//============================================================================ +// Native types. All native functions take extended handle types when +// possible to help prevent passing bad values to native functions +// +type agent extends handle // all reference counted objects +type event extends agent // a reference to an event registration +type player extends agent // a single player reference +type widget extends agent // an interactive game object with life +type unit extends widget // a single unit reference +type destructable extends widget +type item extends widget +type ability extends agent +type buff extends ability +type force extends agent +type group extends agent +type trigger extends agent +type triggercondition extends agent +type triggeraction extends handle +type timer extends agent +type location extends agent +type region extends agent +type rect extends agent +type boolexpr extends agent +type sound extends agent +type conditionfunc extends boolexpr +type filterfunc extends boolexpr +type unitpool extends handle +type itempool extends handle +type race extends handle +type alliancetype extends handle +type racepreference extends handle +type gamestate extends handle +type igamestate extends gamestate +type fgamestate extends gamestate +type playerstate extends handle +type playerscore extends handle +type playergameresult extends handle +type unitstate extends handle +type aidifficulty extends handle + +type eventid extends handle +type gameevent extends eventid +type playerevent extends eventid +type playerunitevent extends eventid +type unitevent extends eventid +type limitop extends eventid +type widgetevent extends eventid +type dialogevent extends eventid +type unittype extends handle + +type gamespeed extends handle +type gamedifficulty extends handle +type gametype extends handle +type mapflag extends handle +type mapvisibility extends handle +type mapsetting extends handle +type mapdensity extends handle +type mapcontrol extends handle +type minimapicon extends handle +type playerslotstate extends handle +type volumegroup extends handle +type camerafield extends handle +type camerasetup extends handle +type playercolor extends handle +type placement extends handle +type startlocprio extends handle +type raritycontrol extends handle +type blendmode extends handle +type texmapflags extends handle +type effect extends agent +type effecttype extends handle +type weathereffect extends handle +type terraindeformation extends handle +type fogstate extends handle +type fogmodifier extends agent +type dialog extends agent +type button extends agent +type quest extends agent +type questitem extends agent +type defeatcondition extends agent +type timerdialog extends agent +type leaderboard extends agent +type multiboard extends agent +type multiboarditem extends agent +type trackable extends agent +type gamecache extends agent +type version extends handle +type itemtype extends handle +type texttag extends handle +type attacktype extends handle +type damagetype extends handle +type weapontype extends handle +type soundtype extends handle +type lightning extends handle +type pathingtype extends handle +type mousebuttontype extends handle +type animtype extends handle +type subanimtype extends handle +type image extends handle +type ubersplat extends handle +type hashtable extends agent +type framehandle extends agent +type originframetype extends handle +type framepointtype extends handle +type textaligntype extends handle +type frameeventtype extends handle +type oskeytype extends handle +type metakeytype extends handle +type abilityintegerfield extends handle +type abilityrealfield extends handle +type abilitybooleanfield extends handle +type abilitystringfield extends handle +type abilityintegerlevelfield extends handle +type abilityreallevelfield extends handle +type abilitybooleanlevelfield extends handle +type abilitystringlevelfield extends handle +type abilityintegerlevelarrayfield extends handle +type abilityreallevelarrayfield extends handle +type abilitybooleanlevelarrayfield extends handle +type abilitystringlevelarrayfield extends handle +type unitintegerfield extends handle +type unitrealfield extends handle +type unitbooleanfield extends handle +type unitstringfield extends handle +type unitweaponintegerfield extends handle +type unitweaponrealfield extends handle +type unitweaponbooleanfield extends handle +type unitweaponstringfield extends handle +type itemintegerfield extends handle +type itemrealfield extends handle +type itembooleanfield extends handle +type itemstringfield extends handle +type movetype extends handle +type targetflag extends handle +type armortype extends handle +type heroattribute extends handle +type defensetype extends handle +type regentype extends handle +type unitcategory extends handle +type pathingflag extends handle +type commandbuttoneffect extends handle +type fogstyle extends handle +type equipmentType extends handle +type itemTag extends handle +type loadoutslot extends handle + +constant native ConvertRace takes integer i returns race +constant native ConvertAllianceType takes integer i returns alliancetype +constant native ConvertRacePref takes integer i returns racepreference +constant native ConvertIGameState takes integer i returns igamestate +constant native ConvertFGameState takes integer i returns fgamestate +constant native ConvertPlayerState takes integer i returns playerstate +constant native ConvertPlayerScore takes integer i returns playerscore +constant native ConvertPlayerGameResult takes integer i returns playergameresult +constant native ConvertUnitState takes integer i returns unitstate +constant native ConvertAIDifficulty takes integer i returns aidifficulty +constant native ConvertGameEvent takes integer i returns gameevent +constant native ConvertPlayerEvent takes integer i returns playerevent +constant native ConvertPlayerUnitEvent takes integer i returns playerunitevent +constant native ConvertWidgetEvent takes integer i returns widgetevent +constant native ConvertDialogEvent takes integer i returns dialogevent +constant native ConvertUnitEvent takes integer i returns unitevent +constant native ConvertLimitOp takes integer i returns limitop +constant native ConvertUnitType takes integer i returns unittype +constant native ConvertGameSpeed takes integer i returns gamespeed +constant native ConvertPlacement takes integer i returns placement +constant native ConvertStartLocPrio takes integer i returns startlocprio +constant native ConvertGameDifficulty takes integer i returns gamedifficulty +constant native ConvertGameType takes integer i returns gametype +constant native ConvertMapFlag takes integer i returns mapflag +constant native ConvertMapVisibility takes integer i returns mapvisibility +constant native ConvertMapSetting takes integer i returns mapsetting +constant native ConvertMapDensity takes integer i returns mapdensity +constant native ConvertMapControl takes integer i returns mapcontrol +constant native ConvertPlayerColor takes integer i returns playercolor +constant native ConvertPlayerSlotState takes integer i returns playerslotstate +constant native ConvertVolumeGroup takes integer i returns volumegroup +constant native ConvertCameraField takes integer i returns camerafield +constant native ConvertBlendMode takes integer i returns blendmode +constant native ConvertRarityControl takes integer i returns raritycontrol +constant native ConvertTexMapFlags takes integer i returns texmapflags +constant native ConvertFogState takes integer i returns fogstate +constant native ConvertEffectType takes integer i returns effecttype +constant native ConvertVersion takes integer i returns version +constant native ConvertItemType takes integer i returns itemtype +constant native ConvertAttackType takes integer i returns attacktype +constant native ConvertDamageType takes integer i returns damagetype +constant native ConvertWeaponType takes integer i returns weapontype +constant native ConvertSoundType takes integer i returns soundtype +constant native ConvertPathingType takes integer i returns pathingtype +constant native ConvertMouseButtonType takes integer i returns mousebuttontype +constant native ConvertAnimType takes integer i returns animtype +constant native ConvertSubAnimType takes integer i returns subanimtype +constant native ConvertOriginFrameType takes integer i returns originframetype +constant native ConvertFramePointType takes integer i returns framepointtype +constant native ConvertTextAlignType takes integer i returns textaligntype +constant native ConvertFrameEventType takes integer i returns frameeventtype +constant native ConvertOsKeyType takes integer i returns oskeytype +constant native ConvertAbilityIntegerField takes integer i returns abilityintegerfield +constant native ConvertAbilityRealField takes integer i returns abilityrealfield +constant native ConvertAbilityBooleanField takes integer i returns abilitybooleanfield +constant native ConvertAbilityStringField takes integer i returns abilitystringfield +constant native ConvertAbilityIntegerLevelField takes integer i returns abilityintegerlevelfield +constant native ConvertAbilityRealLevelField takes integer i returns abilityreallevelfield +constant native ConvertAbilityBooleanLevelField takes integer i returns abilitybooleanlevelfield +constant native ConvertAbilityStringLevelField takes integer i returns abilitystringlevelfield +constant native ConvertAbilityIntegerLevelArrayField takes integer i returns abilityintegerlevelarrayfield +constant native ConvertAbilityRealLevelArrayField takes integer i returns abilityreallevelarrayfield +constant native ConvertAbilityBooleanLevelArrayField takes integer i returns abilitybooleanlevelarrayfield +constant native ConvertAbilityStringLevelArrayField takes integer i returns abilitystringlevelarrayfield +constant native ConvertUnitIntegerField takes integer i returns unitintegerfield +constant native ConvertUnitRealField takes integer i returns unitrealfield +constant native ConvertUnitBooleanField takes integer i returns unitbooleanfield +constant native ConvertUnitStringField takes integer i returns unitstringfield +constant native ConvertUnitWeaponIntegerField takes integer i returns unitweaponintegerfield +constant native ConvertUnitWeaponRealField takes integer i returns unitweaponrealfield +constant native ConvertUnitWeaponBooleanField takes integer i returns unitweaponbooleanfield +constant native ConvertUnitWeaponStringField takes integer i returns unitweaponstringfield +constant native ConvertItemIntegerField takes integer i returns itemintegerfield +constant native ConvertItemRealField takes integer i returns itemrealfield +constant native ConvertItemBooleanField takes integer i returns itembooleanfield +constant native ConvertItemStringField takes integer i returns itemstringfield +constant native ConvertMoveType takes integer i returns movetype +constant native ConvertTargetFlag takes integer i returns targetflag +constant native ConvertArmorType takes integer i returns armortype +constant native ConvertHeroAttribute takes integer i returns heroattribute +constant native ConvertDefenseType takes integer i returns defensetype +constant native ConvertRegenType takes integer i returns regentype +constant native ConvertUnitCategory takes integer i returns unitcategory +constant native ConvertPathingFlag takes integer i returns pathingflag +constant native ConvertFogStyle takes integer i returns fogstyle +constant native ConvertEquipmentType takes integer i returns equipmentType +constant native ConvertItemTag takes integer i returns itemTag +constant native ConvertLoadoutSlot takes integer i returns loadoutslot + +constant native OrderId takes string orderIdString returns integer +constant native OrderId2String takes integer orderId returns string +constant native UnitId takes string unitIdString returns integer +constant native UnitId2String takes integer unitId returns string + +// Not currently working correctly... +constant native AbilityId takes string abilityIdString returns integer +constant native AbilityId2String takes integer abilityId returns string + +// Looks up the "name" field for any object (unit, item, ability) +constant native GetObjectName takes integer objectId returns string + +constant native GetBJMaxPlayers takes nothing returns integer +constant native GetBJPlayerNeutralVictim takes nothing returns integer +constant native GetBJPlayerNeutralExtra takes nothing returns integer +constant native GetBJMaxPlayerSlots takes nothing returns integer +constant native GetPlayerNeutralPassive takes nothing returns integer +constant native GetPlayerNeutralAggressive takes nothing returns integer + +globals + +//=================================================== +// Game Constants +//=================================================== + + // pfff + constant boolean FALSE = false + constant boolean TRUE = true + constant integer JASS_MAX_ARRAY_SIZE = 32768 + + constant integer PLAYER_NEUTRAL_PASSIVE = GetPlayerNeutralPassive() + constant integer PLAYER_NEUTRAL_AGGRESSIVE = GetPlayerNeutralAggressive() + + constant playercolor PLAYER_COLOR_RED = ConvertPlayerColor(0) + constant playercolor PLAYER_COLOR_BLUE = ConvertPlayerColor(1) + constant playercolor PLAYER_COLOR_CYAN = ConvertPlayerColor(2) + constant playercolor PLAYER_COLOR_PURPLE = ConvertPlayerColor(3) + constant playercolor PLAYER_COLOR_YELLOW = ConvertPlayerColor(4) + constant playercolor PLAYER_COLOR_ORANGE = ConvertPlayerColor(5) + constant playercolor PLAYER_COLOR_GREEN = ConvertPlayerColor(6) + constant playercolor PLAYER_COLOR_PINK = ConvertPlayerColor(7) + constant playercolor PLAYER_COLOR_LIGHT_GRAY = ConvertPlayerColor(8) + constant playercolor PLAYER_COLOR_LIGHT_BLUE = ConvertPlayerColor(9) + constant playercolor PLAYER_COLOR_AQUA = ConvertPlayerColor(10) + constant playercolor PLAYER_COLOR_BROWN = ConvertPlayerColor(11) + constant playercolor PLAYER_COLOR_MAROON = ConvertPlayerColor(12) + constant playercolor PLAYER_COLOR_NAVY = ConvertPlayerColor(13) + constant playercolor PLAYER_COLOR_TURQUOISE = ConvertPlayerColor(14) + constant playercolor PLAYER_COLOR_VIOLET = ConvertPlayerColor(15) + constant playercolor PLAYER_COLOR_WHEAT = ConvertPlayerColor(16) + constant playercolor PLAYER_COLOR_PEACH = ConvertPlayerColor(17) + constant playercolor PLAYER_COLOR_MINT = ConvertPlayerColor(18) + constant playercolor PLAYER_COLOR_LAVENDER = ConvertPlayerColor(19) + constant playercolor PLAYER_COLOR_COAL = ConvertPlayerColor(20) + constant playercolor PLAYER_COLOR_SNOW = ConvertPlayerColor(21) + constant playercolor PLAYER_COLOR_EMERALD = ConvertPlayerColor(22) + constant playercolor PLAYER_COLOR_PEANUT = ConvertPlayerColor(23) + constant playercolor PLAYER_COLOR_BLACK = ConvertPlayerColor(24) + + constant race RACE_HUMAN = ConvertRace(1) + constant race RACE_ORC = ConvertRace(2) + constant race RACE_UNDEAD = ConvertRace(3) + constant race RACE_NIGHTELF = ConvertRace(4) + constant race RACE_DEMON = ConvertRace(5) + constant race RACE_OTHER = ConvertRace(7) + + constant playergameresult PLAYER_GAME_RESULT_VICTORY = ConvertPlayerGameResult(0) + constant playergameresult PLAYER_GAME_RESULT_DEFEAT = ConvertPlayerGameResult(1) + constant playergameresult PLAYER_GAME_RESULT_TIE = ConvertPlayerGameResult(2) + constant playergameresult PLAYER_GAME_RESULT_NEUTRAL = ConvertPlayerGameResult(3) + + constant alliancetype ALLIANCE_PASSIVE = ConvertAllianceType(0) + constant alliancetype ALLIANCE_HELP_REQUEST = ConvertAllianceType(1) + constant alliancetype ALLIANCE_HELP_RESPONSE = ConvertAllianceType(2) + constant alliancetype ALLIANCE_SHARED_XP = ConvertAllianceType(3) + constant alliancetype ALLIANCE_SHARED_SPELLS = ConvertAllianceType(4) + constant alliancetype ALLIANCE_SHARED_VISION = ConvertAllianceType(5) + constant alliancetype ALLIANCE_SHARED_CONTROL = ConvertAllianceType(6) + constant alliancetype ALLIANCE_SHARED_ADVANCED_CONTROL= ConvertAllianceType(7) + constant alliancetype ALLIANCE_RESCUABLE = ConvertAllianceType(8) + constant alliancetype ALLIANCE_SHARED_VISION_FORCED = ConvertAllianceType(9) + + constant version VERSION_REIGN_OF_CHAOS = ConvertVersion(0) + constant version VERSION_FROZEN_THRONE = ConvertVersion(1) + + constant attacktype ATTACK_TYPE_NORMAL = ConvertAttackType(0) + constant attacktype ATTACK_TYPE_MELEE = ConvertAttackType(1) + constant attacktype ATTACK_TYPE_PIERCE = ConvertAttackType(2) + constant attacktype ATTACK_TYPE_SIEGE = ConvertAttackType(3) + constant attacktype ATTACK_TYPE_MAGIC = ConvertAttackType(4) + constant attacktype ATTACK_TYPE_CHAOS = ConvertAttackType(5) + constant attacktype ATTACK_TYPE_HERO = ConvertAttackType(6) + + constant damagetype DAMAGE_TYPE_UNKNOWN = ConvertDamageType(0) + constant damagetype DAMAGE_TYPE_NORMAL = ConvertDamageType(4) + constant damagetype DAMAGE_TYPE_ENHANCED = ConvertDamageType(5) + constant damagetype DAMAGE_TYPE_FIRE = ConvertDamageType(8) + constant damagetype DAMAGE_TYPE_COLD = ConvertDamageType(9) + constant damagetype DAMAGE_TYPE_LIGHTNING = ConvertDamageType(10) + constant damagetype DAMAGE_TYPE_POISON = ConvertDamageType(11) + constant damagetype DAMAGE_TYPE_DISEASE = ConvertDamageType(12) + constant damagetype DAMAGE_TYPE_DIVINE = ConvertDamageType(13) + constant damagetype DAMAGE_TYPE_MAGIC = ConvertDamageType(14) + constant damagetype DAMAGE_TYPE_SONIC = ConvertDamageType(15) + constant damagetype DAMAGE_TYPE_ACID = ConvertDamageType(16) + constant damagetype DAMAGE_TYPE_FORCE = ConvertDamageType(17) + constant damagetype DAMAGE_TYPE_DEATH = ConvertDamageType(18) + constant damagetype DAMAGE_TYPE_MIND = ConvertDamageType(19) + constant damagetype DAMAGE_TYPE_PLANT = ConvertDamageType(20) + constant damagetype DAMAGE_TYPE_DEFENSIVE = ConvertDamageType(21) + constant damagetype DAMAGE_TYPE_DEMOLITION = ConvertDamageType(22) + constant damagetype DAMAGE_TYPE_SLOW_POISON = ConvertDamageType(23) + constant damagetype DAMAGE_TYPE_SPIRIT_LINK = ConvertDamageType(24) + constant damagetype DAMAGE_TYPE_SHADOW_STRIKE = ConvertDamageType(25) + constant damagetype DAMAGE_TYPE_UNIVERSAL = ConvertDamageType(26) + + constant weapontype WEAPON_TYPE_WHOKNOWS = ConvertWeaponType(0) + constant weapontype WEAPON_TYPE_METAL_LIGHT_CHOP = ConvertWeaponType(1) + constant weapontype WEAPON_TYPE_METAL_MEDIUM_CHOP = ConvertWeaponType(2) + constant weapontype WEAPON_TYPE_METAL_HEAVY_CHOP = ConvertWeaponType(3) + constant weapontype WEAPON_TYPE_METAL_LIGHT_SLICE = ConvertWeaponType(4) + constant weapontype WEAPON_TYPE_METAL_MEDIUM_SLICE = ConvertWeaponType(5) + constant weapontype WEAPON_TYPE_METAL_HEAVY_SLICE = ConvertWeaponType(6) + constant weapontype WEAPON_TYPE_METAL_MEDIUM_BASH = ConvertWeaponType(7) + constant weapontype WEAPON_TYPE_METAL_HEAVY_BASH = ConvertWeaponType(8) + constant weapontype WEAPON_TYPE_METAL_MEDIUM_STAB = ConvertWeaponType(9) + constant weapontype WEAPON_TYPE_METAL_HEAVY_STAB = ConvertWeaponType(10) + constant weapontype WEAPON_TYPE_WOOD_LIGHT_SLICE = ConvertWeaponType(11) + constant weapontype WEAPON_TYPE_WOOD_MEDIUM_SLICE = ConvertWeaponType(12) + constant weapontype WEAPON_TYPE_WOOD_HEAVY_SLICE = ConvertWeaponType(13) + constant weapontype WEAPON_TYPE_WOOD_LIGHT_BASH = ConvertWeaponType(14) + constant weapontype WEAPON_TYPE_WOOD_MEDIUM_BASH = ConvertWeaponType(15) + constant weapontype WEAPON_TYPE_WOOD_HEAVY_BASH = ConvertWeaponType(16) + constant weapontype WEAPON_TYPE_WOOD_LIGHT_STAB = ConvertWeaponType(17) + constant weapontype WEAPON_TYPE_WOOD_MEDIUM_STAB = ConvertWeaponType(18) + constant weapontype WEAPON_TYPE_CLAW_LIGHT_SLICE = ConvertWeaponType(19) + constant weapontype WEAPON_TYPE_CLAW_MEDIUM_SLICE = ConvertWeaponType(20) + constant weapontype WEAPON_TYPE_CLAW_HEAVY_SLICE = ConvertWeaponType(21) + constant weapontype WEAPON_TYPE_AXE_MEDIUM_CHOP = ConvertWeaponType(22) + constant weapontype WEAPON_TYPE_ROCK_HEAVY_BASH = ConvertWeaponType(23) + + constant pathingtype PATHING_TYPE_ANY = ConvertPathingType(0) + constant pathingtype PATHING_TYPE_WALKABILITY = ConvertPathingType(1) + constant pathingtype PATHING_TYPE_FLYABILITY = ConvertPathingType(2) + constant pathingtype PATHING_TYPE_BUILDABILITY = ConvertPathingType(3) + constant pathingtype PATHING_TYPE_PEONHARVESTPATHING = ConvertPathingType(4) + constant pathingtype PATHING_TYPE_BLIGHTPATHING = ConvertPathingType(5) + constant pathingtype PATHING_TYPE_FLOATABILITY = ConvertPathingType(6) + constant pathingtype PATHING_TYPE_AMPHIBIOUSPATHING = ConvertPathingType(7) + + constant mousebuttontype MOUSE_BUTTON_TYPE_LEFT = ConvertMouseButtonType(1) + constant mousebuttontype MOUSE_BUTTON_TYPE_MIDDLE = ConvertMouseButtonType(2) + constant mousebuttontype MOUSE_BUTTON_TYPE_RIGHT = ConvertMouseButtonType(3) + + constant animtype ANIM_TYPE_BIRTH = ConvertAnimType(0) + constant animtype ANIM_TYPE_DEATH = ConvertAnimType(1) + constant animtype ANIM_TYPE_DECAY = ConvertAnimType(2) + constant animtype ANIM_TYPE_DISSIPATE = ConvertAnimType(3) + constant animtype ANIM_TYPE_STAND = ConvertAnimType(4) + constant animtype ANIM_TYPE_WALK = ConvertAnimType(5) + constant animtype ANIM_TYPE_ATTACK = ConvertAnimType(6) + constant animtype ANIM_TYPE_MORPH = ConvertAnimType(7) + constant animtype ANIM_TYPE_SLEEP = ConvertAnimType(8) + constant animtype ANIM_TYPE_SPELL = ConvertAnimType(9) + constant animtype ANIM_TYPE_PORTRAIT = ConvertAnimType(10) + + constant subanimtype SUBANIM_TYPE_ROOTED = ConvertSubAnimType(11) + constant subanimtype SUBANIM_TYPE_ALTERNATE_EX = ConvertSubAnimType(12) + constant subanimtype SUBANIM_TYPE_LOOPING = ConvertSubAnimType(13) + constant subanimtype SUBANIM_TYPE_SLAM = ConvertSubAnimType(14) + constant subanimtype SUBANIM_TYPE_THROW = ConvertSubAnimType(15) + constant subanimtype SUBANIM_TYPE_SPIKED = ConvertSubAnimType(16) + constant subanimtype SUBANIM_TYPE_FAST = ConvertSubAnimType(17) + constant subanimtype SUBANIM_TYPE_SPIN = ConvertSubAnimType(18) + constant subanimtype SUBANIM_TYPE_READY = ConvertSubAnimType(19) + constant subanimtype SUBANIM_TYPE_CHANNEL = ConvertSubAnimType(20) + constant subanimtype SUBANIM_TYPE_DEFEND = ConvertSubAnimType(21) + constant subanimtype SUBANIM_TYPE_VICTORY = ConvertSubAnimType(22) + constant subanimtype SUBANIM_TYPE_TURN = ConvertSubAnimType(23) + constant subanimtype SUBANIM_TYPE_LEFT = ConvertSubAnimType(24) + constant subanimtype SUBANIM_TYPE_RIGHT = ConvertSubAnimType(25) + constant subanimtype SUBANIM_TYPE_FIRE = ConvertSubAnimType(26) + constant subanimtype SUBANIM_TYPE_FLESH = ConvertSubAnimType(27) + constant subanimtype SUBANIM_TYPE_HIT = ConvertSubAnimType(28) + constant subanimtype SUBANIM_TYPE_WOUNDED = ConvertSubAnimType(29) + constant subanimtype SUBANIM_TYPE_LIGHT = ConvertSubAnimType(30) + constant subanimtype SUBANIM_TYPE_MODERATE = ConvertSubAnimType(31) + constant subanimtype SUBANIM_TYPE_SEVERE = ConvertSubAnimType(32) + constant subanimtype SUBANIM_TYPE_CRITICAL = ConvertSubAnimType(33) + constant subanimtype SUBANIM_TYPE_COMPLETE = ConvertSubAnimType(34) + constant subanimtype SUBANIM_TYPE_GOLD = ConvertSubAnimType(35) + constant subanimtype SUBANIM_TYPE_LUMBER = ConvertSubAnimType(36) + constant subanimtype SUBANIM_TYPE_WORK = ConvertSubAnimType(37) + constant subanimtype SUBANIM_TYPE_TALK = ConvertSubAnimType(38) + constant subanimtype SUBANIM_TYPE_FIRST = ConvertSubAnimType(39) + constant subanimtype SUBANIM_TYPE_SECOND = ConvertSubAnimType(40) + constant subanimtype SUBANIM_TYPE_THIRD = ConvertSubAnimType(41) + constant subanimtype SUBANIM_TYPE_FOURTH = ConvertSubAnimType(42) + constant subanimtype SUBANIM_TYPE_FIFTH = ConvertSubAnimType(43) + constant subanimtype SUBANIM_TYPE_ONE = ConvertSubAnimType(44) + constant subanimtype SUBANIM_TYPE_TWO = ConvertSubAnimType(45) + constant subanimtype SUBANIM_TYPE_THREE = ConvertSubAnimType(46) + constant subanimtype SUBANIM_TYPE_FOUR = ConvertSubAnimType(47) + constant subanimtype SUBANIM_TYPE_FIVE = ConvertSubAnimType(48) + constant subanimtype SUBANIM_TYPE_SMALL = ConvertSubAnimType(49) + constant subanimtype SUBANIM_TYPE_MEDIUM = ConvertSubAnimType(50) + constant subanimtype SUBANIM_TYPE_LARGE = ConvertSubAnimType(51) + constant subanimtype SUBANIM_TYPE_UPGRADE = ConvertSubAnimType(52) + constant subanimtype SUBANIM_TYPE_DRAIN = ConvertSubAnimType(53) + constant subanimtype SUBANIM_TYPE_FILL = ConvertSubAnimType(54) + constant subanimtype SUBANIM_TYPE_CHAINLIGHTNING = ConvertSubAnimType(55) + constant subanimtype SUBANIM_TYPE_EATTREE = ConvertSubAnimType(56) + constant subanimtype SUBANIM_TYPE_PUKE = ConvertSubAnimType(57) + constant subanimtype SUBANIM_TYPE_FLAIL = ConvertSubAnimType(58) + constant subanimtype SUBANIM_TYPE_OFF = ConvertSubAnimType(59) + constant subanimtype SUBANIM_TYPE_SWIM = ConvertSubAnimType(60) + constant subanimtype SUBANIM_TYPE_ENTANGLE = ConvertSubAnimType(61) + constant subanimtype SUBANIM_TYPE_BERSERK = ConvertSubAnimType(62) + +//=================================================== +// Map Setup Constants +//=================================================== + + constant racepreference RACE_PREF_HUMAN = ConvertRacePref(1) + constant racepreference RACE_PREF_ORC = ConvertRacePref(2) + constant racepreference RACE_PREF_NIGHTELF = ConvertRacePref(4) + constant racepreference RACE_PREF_UNDEAD = ConvertRacePref(8) + constant racepreference RACE_PREF_DEMON = ConvertRacePref(16) + constant racepreference RACE_PREF_RANDOM = ConvertRacePref(32) + constant racepreference RACE_PREF_USER_SELECTABLE = ConvertRacePref(64) + constant racepreference RACE_PREF_FORSAKEN = ConvertRacePref(128) + + constant mapcontrol MAP_CONTROL_USER = ConvertMapControl(0) + constant mapcontrol MAP_CONTROL_COMPUTER = ConvertMapControl(1) + constant mapcontrol MAP_CONTROL_RESCUABLE = ConvertMapControl(2) + constant mapcontrol MAP_CONTROL_NEUTRAL = ConvertMapControl(3) + constant mapcontrol MAP_CONTROL_CREEP = ConvertMapControl(4) + constant mapcontrol MAP_CONTROL_NONE = ConvertMapControl(5) + + constant gametype GAME_TYPE_MELEE = ConvertGameType(1) + constant gametype GAME_TYPE_FFA = ConvertGameType(2) + constant gametype GAME_TYPE_USE_MAP_SETTINGS = ConvertGameType(4) + constant gametype GAME_TYPE_BLIZ = ConvertGameType(8) + constant gametype GAME_TYPE_ONE_ON_ONE = ConvertGameType(16) + constant gametype GAME_TYPE_TWO_TEAM_PLAY = ConvertGameType(32) + constant gametype GAME_TYPE_THREE_TEAM_PLAY = ConvertGameType(64) + constant gametype GAME_TYPE_FOUR_TEAM_PLAY = ConvertGameType(128) + + constant mapflag MAP_FOG_HIDE_TERRAIN = ConvertMapFlag(1) + constant mapflag MAP_FOG_MAP_EXPLORED = ConvertMapFlag(2) + constant mapflag MAP_FOG_ALWAYS_VISIBLE = ConvertMapFlag(4) + + constant mapflag MAP_USE_HANDICAPS = ConvertMapFlag(8) + constant mapflag MAP_OBSERVERS = ConvertMapFlag(16) + constant mapflag MAP_OBSERVERS_ON_DEATH = ConvertMapFlag(32) + + constant mapflag MAP_FIXED_COLORS = ConvertMapFlag(128) + + constant mapflag MAP_LOCK_RESOURCE_TRADING = ConvertMapFlag(256) + constant mapflag MAP_RESOURCE_TRADING_ALLIES_ONLY = ConvertMapFlag(512) + + constant mapflag MAP_LOCK_ALLIANCE_CHANGES = ConvertMapFlag(1024) + constant mapflag MAP_ALLIANCE_CHANGES_HIDDEN = ConvertMapFlag(2048) + + constant mapflag MAP_CHEATS = ConvertMapFlag(4096) + constant mapflag MAP_CHEATS_HIDDEN = ConvertMapFlag(8192) + + constant mapflag MAP_LOCK_SPEED = ConvertMapFlag(8192*2) + constant mapflag MAP_LOCK_RANDOM_SEED = ConvertMapFlag(8192*4) + constant mapflag MAP_SHARED_ADVANCED_CONTROL = ConvertMapFlag(8192*8) + constant mapflag MAP_RANDOM_HERO = ConvertMapFlag(8192*16) + constant mapflag MAP_RANDOM_RACES = ConvertMapFlag(8192*32) + constant mapflag MAP_RELOADED = ConvertMapFlag(8192*64) + + constant placement MAP_PLACEMENT_RANDOM = ConvertPlacement(0) // random among all slots + constant placement MAP_PLACEMENT_FIXED = ConvertPlacement(1) // player 0 in start loc 0... + constant placement MAP_PLACEMENT_USE_MAP_SETTINGS = ConvertPlacement(2) // whatever was specified by the script + constant placement MAP_PLACEMENT_TEAMS_TOGETHER = ConvertPlacement(3) // random with allies next to each other + + constant startlocprio MAP_LOC_PRIO_LOW = ConvertStartLocPrio(0) + constant startlocprio MAP_LOC_PRIO_HIGH = ConvertStartLocPrio(1) + constant startlocprio MAP_LOC_PRIO_NOT = ConvertStartLocPrio(2) + + constant mapdensity MAP_DENSITY_NONE = ConvertMapDensity(0) + constant mapdensity MAP_DENSITY_LIGHT = ConvertMapDensity(1) + constant mapdensity MAP_DENSITY_MEDIUM = ConvertMapDensity(2) + constant mapdensity MAP_DENSITY_HEAVY = ConvertMapDensity(3) + + constant gamedifficulty MAP_DIFFICULTY_EASY = ConvertGameDifficulty(0) + constant gamedifficulty MAP_DIFFICULTY_NORMAL = ConvertGameDifficulty(1) + constant gamedifficulty MAP_DIFFICULTY_HARD = ConvertGameDifficulty(2) + constant gamedifficulty MAP_DIFFICULTY_INSANE = ConvertGameDifficulty(3) + + constant gamespeed MAP_SPEED_SLOWEST = ConvertGameSpeed(0) + constant gamespeed MAP_SPEED_SLOW = ConvertGameSpeed(1) + constant gamespeed MAP_SPEED_NORMAL = ConvertGameSpeed(2) + constant gamespeed MAP_SPEED_FAST = ConvertGameSpeed(3) + constant gamespeed MAP_SPEED_FASTEST = ConvertGameSpeed(4) + + constant playerslotstate PLAYER_SLOT_STATE_EMPTY = ConvertPlayerSlotState(0) + constant playerslotstate PLAYER_SLOT_STATE_PLAYING = ConvertPlayerSlotState(1) + constant playerslotstate PLAYER_SLOT_STATE_LEFT = ConvertPlayerSlotState(2) + + constant fogstyle FOG_STYLE_LINEAR = ConvertFogStyle(0) + constant fogstyle FOG_STYLE_EXP = ConvertFogStyle(1) + constant fogstyle FOG_STYLE_EXP2 = ConvertFogStyle(2) + constant fogstyle FOG_STYLE_HEIGHT = ConvertFogStyle(3) + constant fogstyle FOG_STYLE_NEW_EXP = ConvertFogStyle(4) + constant fogstyle FOG_STYLE_NEW_EXP_2 = ConvertFogStyle(5) + +//=================================================== +// Sound Constants +//=================================================== + constant volumegroup SOUND_VOLUMEGROUP_UNITMOVEMENT = ConvertVolumeGroup(0) + constant volumegroup SOUND_VOLUMEGROUP_UNITSOUNDS = ConvertVolumeGroup(1) + constant volumegroup SOUND_VOLUMEGROUP_COMBAT = ConvertVolumeGroup(2) + constant volumegroup SOUND_VOLUMEGROUP_SPELLS = ConvertVolumeGroup(3) + constant volumegroup SOUND_VOLUMEGROUP_UI = ConvertVolumeGroup(4) + constant volumegroup SOUND_VOLUMEGROUP_MUSIC = ConvertVolumeGroup(5) + constant volumegroup SOUND_VOLUMEGROUP_AMBIENTSOUNDS = ConvertVolumeGroup(6) + constant volumegroup SOUND_VOLUMEGROUP_FIRE = ConvertVolumeGroup(7) +//Cinematic Sound Constants + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_GENERAL = ConvertVolumeGroup(8) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_AMBIENT = ConvertVolumeGroup(9) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_MUSIC = ConvertVolumeGroup(10) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_DIALOGUE = ConvertVolumeGroup(11) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_1 = ConvertVolumeGroup(12) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_2 = ConvertVolumeGroup(13) + constant volumegroup SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_3 = ConvertVolumeGroup(14) + + +//=================================================== +// Game, Player, and Unit States +// +// For use with TriggerRegisterStateEvent +// +//=================================================== + + constant igamestate GAME_STATE_DIVINE_INTERVENTION = ConvertIGameState(0) + constant igamestate GAME_STATE_DISCONNECTED = ConvertIGameState(1) + constant fgamestate GAME_STATE_TIME_OF_DAY = ConvertFGameState(2) + + constant playerstate PLAYER_STATE_GAME_RESULT = ConvertPlayerState(0) + + // current resource levels + // + constant playerstate PLAYER_STATE_RESOURCE_GOLD = ConvertPlayerState(1) + constant playerstate PLAYER_STATE_RESOURCE_LUMBER = ConvertPlayerState(2) + constant playerstate PLAYER_STATE_RESOURCE_HERO_TOKENS = ConvertPlayerState(3) + constant playerstate PLAYER_STATE_RESOURCE_FOOD_CAP = ConvertPlayerState(4) + constant playerstate PLAYER_STATE_RESOURCE_FOOD_USED = ConvertPlayerState(5) + constant playerstate PLAYER_STATE_FOOD_CAP_CEILING = ConvertPlayerState(6) + + constant playerstate PLAYER_STATE_GIVES_BOUNTY = ConvertPlayerState(7) + constant playerstate PLAYER_STATE_ALLIED_VICTORY = ConvertPlayerState(8) + constant playerstate PLAYER_STATE_PLACED = ConvertPlayerState(9) + constant playerstate PLAYER_STATE_OBSERVER_ON_DEATH = ConvertPlayerState(10) + constant playerstate PLAYER_STATE_OBSERVER = ConvertPlayerState(11) + constant playerstate PLAYER_STATE_UNFOLLOWABLE = ConvertPlayerState(12) + + // taxation rate for each resource + // + constant playerstate PLAYER_STATE_GOLD_UPKEEP_RATE = ConvertPlayerState(13) + constant playerstate PLAYER_STATE_LUMBER_UPKEEP_RATE = ConvertPlayerState(14) + + // cumulative resources collected by the player during the mission + // + constant playerstate PLAYER_STATE_GOLD_GATHERED = ConvertPlayerState(15) + constant playerstate PLAYER_STATE_LUMBER_GATHERED = ConvertPlayerState(16) + + constant playerstate PLAYER_STATE_NO_CREEP_SLEEP = ConvertPlayerState(25) + + constant unitstate UNIT_STATE_LIFE = ConvertUnitState(0) + constant unitstate UNIT_STATE_MAX_LIFE = ConvertUnitState(1) + constant unitstate UNIT_STATE_MANA = ConvertUnitState(2) + constant unitstate UNIT_STATE_MAX_MANA = ConvertUnitState(3) + + constant aidifficulty AI_DIFFICULTY_NEWBIE = ConvertAIDifficulty(0) + constant aidifficulty AI_DIFFICULTY_NORMAL = ConvertAIDifficulty(1) + constant aidifficulty AI_DIFFICULTY_INSANE = ConvertAIDifficulty(2) + + // player score values + constant playerscore PLAYER_SCORE_UNITS_TRAINED = ConvertPlayerScore(0) + constant playerscore PLAYER_SCORE_UNITS_KILLED = ConvertPlayerScore(1) + constant playerscore PLAYER_SCORE_STRUCT_BUILT = ConvertPlayerScore(2) + constant playerscore PLAYER_SCORE_STRUCT_RAZED = ConvertPlayerScore(3) + constant playerscore PLAYER_SCORE_TECH_PERCENT = ConvertPlayerScore(4) + constant playerscore PLAYER_SCORE_FOOD_MAXPROD = ConvertPlayerScore(5) + constant playerscore PLAYER_SCORE_FOOD_MAXUSED = ConvertPlayerScore(6) + constant playerscore PLAYER_SCORE_HEROES_KILLED = ConvertPlayerScore(7) + constant playerscore PLAYER_SCORE_ITEMS_GAINED = ConvertPlayerScore(8) + constant playerscore PLAYER_SCORE_MERCS_HIRED = ConvertPlayerScore(9) + constant playerscore PLAYER_SCORE_GOLD_MINED_TOTAL = ConvertPlayerScore(10) + constant playerscore PLAYER_SCORE_GOLD_MINED_UPKEEP = ConvertPlayerScore(11) + constant playerscore PLAYER_SCORE_GOLD_LOST_UPKEEP = ConvertPlayerScore(12) + constant playerscore PLAYER_SCORE_GOLD_LOST_TAX = ConvertPlayerScore(13) + constant playerscore PLAYER_SCORE_GOLD_GIVEN = ConvertPlayerScore(14) + constant playerscore PLAYER_SCORE_GOLD_RECEIVED = ConvertPlayerScore(15) + constant playerscore PLAYER_SCORE_LUMBER_TOTAL = ConvertPlayerScore(16) + constant playerscore PLAYER_SCORE_LUMBER_LOST_UPKEEP = ConvertPlayerScore(17) + constant playerscore PLAYER_SCORE_LUMBER_LOST_TAX = ConvertPlayerScore(18) + constant playerscore PLAYER_SCORE_LUMBER_GIVEN = ConvertPlayerScore(19) + constant playerscore PLAYER_SCORE_LUMBER_RECEIVED = ConvertPlayerScore(20) + constant playerscore PLAYER_SCORE_UNIT_TOTAL = ConvertPlayerScore(21) + constant playerscore PLAYER_SCORE_HERO_TOTAL = ConvertPlayerScore(22) + constant playerscore PLAYER_SCORE_RESOURCE_TOTAL = ConvertPlayerScore(23) + constant playerscore PLAYER_SCORE_TOTAL = ConvertPlayerScore(24) + +//=================================================== +// Game, Player and Unit Events +// +// When an event causes a trigger to fire these +// values allow the action code to determine which +// event was dispatched and therefore which set of +// native functions should be used to get information +// about the event. +// +// Do NOT change the order or value of these constants +// without insuring that the JASS_GAME_EVENTS_WAR3 enum +// is changed to match. +// +//=================================================== + + //=================================================== + // For use with TriggerRegisterGameEvent + //=================================================== + + constant gameevent EVENT_GAME_VICTORY = ConvertGameEvent(0) + constant gameevent EVENT_GAME_END_LEVEL = ConvertGameEvent(1) + + constant gameevent EVENT_GAME_VARIABLE_LIMIT = ConvertGameEvent(2) + constant gameevent EVENT_GAME_STATE_LIMIT = ConvertGameEvent(3) + + constant gameevent EVENT_GAME_TIMER_EXPIRED = ConvertGameEvent(4) + + constant gameevent EVENT_GAME_ENTER_REGION = ConvertGameEvent(5) + constant gameevent EVENT_GAME_LEAVE_REGION = ConvertGameEvent(6) + + constant gameevent EVENT_GAME_TRACKABLE_HIT = ConvertGameEvent(7) + constant gameevent EVENT_GAME_TRACKABLE_TRACK = ConvertGameEvent(8) + + constant gameevent EVENT_GAME_SHOW_SKILL = ConvertGameEvent(9) + constant gameevent EVENT_GAME_BUILD_SUBMENU = ConvertGameEvent(10) + + //=================================================== + // For use with TriggerRegisterPlayerEvent + //=================================================== + constant playerevent EVENT_PLAYER_STATE_LIMIT = ConvertPlayerEvent(11) + constant playerevent EVENT_PLAYER_ALLIANCE_CHANGED = ConvertPlayerEvent(12) + + constant playerevent EVENT_PLAYER_DEFEAT = ConvertPlayerEvent(13) + constant playerevent EVENT_PLAYER_VICTORY = ConvertPlayerEvent(14) + constant playerevent EVENT_PLAYER_LEAVE = ConvertPlayerEvent(15) + constant playerevent EVENT_PLAYER_CHAT = ConvertPlayerEvent(16) + constant playerevent EVENT_PLAYER_END_CINEMATIC = ConvertPlayerEvent(17) + + //=================================================== + // For use with TriggerRegisterPlayerUnitEvent + //=================================================== + + constant playerunitevent EVENT_PLAYER_UNIT_ATTACKED = ConvertPlayerUnitEvent(18) + constant playerunitevent EVENT_PLAYER_UNIT_RESCUED = ConvertPlayerUnitEvent(19) + + constant playerunitevent EVENT_PLAYER_UNIT_DEATH = ConvertPlayerUnitEvent(20) + constant playerunitevent EVENT_PLAYER_UNIT_DECAY = ConvertPlayerUnitEvent(21) + + constant playerunitevent EVENT_PLAYER_UNIT_DETECTED = ConvertPlayerUnitEvent(22) + constant playerunitevent EVENT_PLAYER_UNIT_HIDDEN = ConvertPlayerUnitEvent(23) + + constant playerunitevent EVENT_PLAYER_UNIT_SELECTED = ConvertPlayerUnitEvent(24) + constant playerunitevent EVENT_PLAYER_UNIT_DESELECTED = ConvertPlayerUnitEvent(25) + + constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_START = ConvertPlayerUnitEvent(26) + constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL = ConvertPlayerUnitEvent(27) + constant playerunitevent EVENT_PLAYER_UNIT_CONSTRUCT_FINISH = ConvertPlayerUnitEvent(28) + + constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_START = ConvertPlayerUnitEvent(29) + constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_CANCEL = ConvertPlayerUnitEvent(30) + constant playerunitevent EVENT_PLAYER_UNIT_UPGRADE_FINISH = ConvertPlayerUnitEvent(31) + + constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_START = ConvertPlayerUnitEvent(32) + constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_CANCEL = ConvertPlayerUnitEvent(33) + constant playerunitevent EVENT_PLAYER_UNIT_TRAIN_FINISH = ConvertPlayerUnitEvent(34) + + constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_START = ConvertPlayerUnitEvent(35) + constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_CANCEL = ConvertPlayerUnitEvent(36) + constant playerunitevent EVENT_PLAYER_UNIT_RESEARCH_FINISH = ConvertPlayerUnitEvent(37) + constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_ORDER = ConvertPlayerUnitEvent(38) + constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER = ConvertPlayerUnitEvent(39) + constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER = ConvertPlayerUnitEvent(40) + constant playerunitevent EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER = ConvertPlayerUnitEvent(40) // for compat + + constant playerunitevent EVENT_PLAYER_HERO_LEVEL = ConvertPlayerUnitEvent(41) + constant playerunitevent EVENT_PLAYER_HERO_SKILL = ConvertPlayerUnitEvent(42) + + constant playerunitevent EVENT_PLAYER_HERO_REVIVABLE = ConvertPlayerUnitEvent(43) + + constant playerunitevent EVENT_PLAYER_HERO_REVIVE_START = ConvertPlayerUnitEvent(44) + constant playerunitevent EVENT_PLAYER_HERO_REVIVE_CANCEL = ConvertPlayerUnitEvent(45) + constant playerunitevent EVENT_PLAYER_HERO_REVIVE_FINISH = ConvertPlayerUnitEvent(46) + constant playerunitevent EVENT_PLAYER_UNIT_SUMMON = ConvertPlayerUnitEvent(47) + constant playerunitevent EVENT_PLAYER_UNIT_DROP_ITEM = ConvertPlayerUnitEvent(48) + constant playerunitevent EVENT_PLAYER_UNIT_PICKUP_ITEM = ConvertPlayerUnitEvent(49) + constant playerunitevent EVENT_PLAYER_UNIT_USE_ITEM = ConvertPlayerUnitEvent(50) + + constant playerunitevent EVENT_PLAYER_UNIT_LOADED = ConvertPlayerUnitEvent(51) + constant playerunitevent EVENT_PLAYER_UNIT_DAMAGED = ConvertPlayerUnitEvent(308) + constant playerunitevent EVENT_PLAYER_UNIT_DAMAGING = ConvertPlayerUnitEvent(315) + + //=================================================== + // For use with TriggerRegisterUnitEvent + //=================================================== + + constant unitevent EVENT_UNIT_DAMAGED = ConvertUnitEvent(52) + constant unitevent EVENT_UNIT_DAMAGING = ConvertUnitEvent(314) + constant unitevent EVENT_UNIT_DEATH = ConvertUnitEvent(53) + constant unitevent EVENT_UNIT_DECAY = ConvertUnitEvent(54) + constant unitevent EVENT_UNIT_DETECTED = ConvertUnitEvent(55) + constant unitevent EVENT_UNIT_HIDDEN = ConvertUnitEvent(56) + constant unitevent EVENT_UNIT_SELECTED = ConvertUnitEvent(57) + constant unitevent EVENT_UNIT_DESELECTED = ConvertUnitEvent(58) + + constant unitevent EVENT_UNIT_STATE_LIMIT = ConvertUnitEvent(59) + + // Events which may have a filter for the "other unit" + // + constant unitevent EVENT_UNIT_ACQUIRED_TARGET = ConvertUnitEvent(60) + constant unitevent EVENT_UNIT_TARGET_IN_RANGE = ConvertUnitEvent(61) + constant unitevent EVENT_UNIT_ATTACKED = ConvertUnitEvent(62) + constant unitevent EVENT_UNIT_RESCUED = ConvertUnitEvent(63) + + constant unitevent EVENT_UNIT_CONSTRUCT_CANCEL = ConvertUnitEvent(64) + constant unitevent EVENT_UNIT_CONSTRUCT_FINISH = ConvertUnitEvent(65) + + constant unitevent EVENT_UNIT_UPGRADE_START = ConvertUnitEvent(66) + constant unitevent EVENT_UNIT_UPGRADE_CANCEL = ConvertUnitEvent(67) + constant unitevent EVENT_UNIT_UPGRADE_FINISH = ConvertUnitEvent(68) + + // Events which involve the specified unit performing + // training of other units + // + constant unitevent EVENT_UNIT_TRAIN_START = ConvertUnitEvent(69) + constant unitevent EVENT_UNIT_TRAIN_CANCEL = ConvertUnitEvent(70) + constant unitevent EVENT_UNIT_TRAIN_FINISH = ConvertUnitEvent(71) + + constant unitevent EVENT_UNIT_RESEARCH_START = ConvertUnitEvent(72) + constant unitevent EVENT_UNIT_RESEARCH_CANCEL = ConvertUnitEvent(73) + constant unitevent EVENT_UNIT_RESEARCH_FINISH = ConvertUnitEvent(74) + + constant unitevent EVENT_UNIT_ISSUED_ORDER = ConvertUnitEvent(75) + constant unitevent EVENT_UNIT_ISSUED_POINT_ORDER = ConvertUnitEvent(76) + constant unitevent EVENT_UNIT_ISSUED_TARGET_ORDER = ConvertUnitEvent(77) + + constant unitevent EVENT_UNIT_HERO_LEVEL = ConvertUnitEvent(78) + constant unitevent EVENT_UNIT_HERO_SKILL = ConvertUnitEvent(79) + + constant unitevent EVENT_UNIT_HERO_REVIVABLE = ConvertUnitEvent(80) + constant unitevent EVENT_UNIT_HERO_REVIVE_START = ConvertUnitEvent(81) + constant unitevent EVENT_UNIT_HERO_REVIVE_CANCEL = ConvertUnitEvent(82) + constant unitevent EVENT_UNIT_HERO_REVIVE_FINISH = ConvertUnitEvent(83) + + constant unitevent EVENT_UNIT_SUMMON = ConvertUnitEvent(84) + + constant unitevent EVENT_UNIT_DROP_ITEM = ConvertUnitEvent(85) + constant unitevent EVENT_UNIT_PICKUP_ITEM = ConvertUnitEvent(86) + constant unitevent EVENT_UNIT_USE_ITEM = ConvertUnitEvent(87) + + constant unitevent EVENT_UNIT_LOADED = ConvertUnitEvent(88) + + constant widgetevent EVENT_WIDGET_DEATH = ConvertWidgetEvent(89) + + constant dialogevent EVENT_DIALOG_BUTTON_CLICK = ConvertDialogEvent(90) + constant dialogevent EVENT_DIALOG_CLICK = ConvertDialogEvent(91) + + //=================================================== + // Frozen Throne Expansion Events + // Need to be added here to preserve compat + //=================================================== + + //=================================================== + // For use with TriggerRegisterGameEvent + //=================================================== + + constant gameevent EVENT_GAME_LOADED = ConvertGameEvent(256) + constant gameevent EVENT_GAME_TOURNAMENT_FINISH_SOON = ConvertGameEvent(257) + constant gameevent EVENT_GAME_TOURNAMENT_FINISH_NOW = ConvertGameEvent(258) + constant gameevent EVENT_GAME_SAVE = ConvertGameEvent(259) + constant gameevent EVENT_GAME_CUSTOM_UI_FRAME = ConvertGameEvent(310) + + //=================================================== + // For use with TriggerRegisterPlayerEvent + //=================================================== + + constant playerevent EVENT_PLAYER_ARROW_LEFT_DOWN = ConvertPlayerEvent(261) + constant playerevent EVENT_PLAYER_ARROW_LEFT_UP = ConvertPlayerEvent(262) + constant playerevent EVENT_PLAYER_ARROW_RIGHT_DOWN = ConvertPlayerEvent(263) + constant playerevent EVENT_PLAYER_ARROW_RIGHT_UP = ConvertPlayerEvent(264) + constant playerevent EVENT_PLAYER_ARROW_DOWN_DOWN = ConvertPlayerEvent(265) + constant playerevent EVENT_PLAYER_ARROW_DOWN_UP = ConvertPlayerEvent(266) + constant playerevent EVENT_PLAYER_ARROW_UP_DOWN = ConvertPlayerEvent(267) + constant playerevent EVENT_PLAYER_ARROW_UP_UP = ConvertPlayerEvent(268) + constant playerevent EVENT_PLAYER_MOUSE_DOWN = ConvertPlayerEvent(305) + constant playerevent EVENT_PLAYER_MOUSE_UP = ConvertPlayerEvent(306) + constant playerevent EVENT_PLAYER_MOUSE_MOVE = ConvertPlayerEvent(307) + constant playerevent EVENT_PLAYER_SYNC_DATA = ConvertPlayerEvent(309) + constant playerevent EVENT_PLAYER_KEY = ConvertPlayerEvent(311) + constant playerevent EVENT_PLAYER_KEY_DOWN = ConvertPlayerEvent(312) + constant playerevent EVENT_PLAYER_KEY_UP = ConvertPlayerEvent(313) + + //=================================================== + // For use with TriggerRegisterPlayerUnitEvent + //=================================================== + + constant playerunitevent EVENT_PLAYER_UNIT_SELL = ConvertPlayerUnitEvent(269) + constant playerunitevent EVENT_PLAYER_UNIT_CHANGE_OWNER = ConvertPlayerUnitEvent(270) + constant playerunitevent EVENT_PLAYER_UNIT_SELL_ITEM = ConvertPlayerUnitEvent(271) + constant playerunitevent EVENT_PLAYER_UNIT_SPELL_CHANNEL = ConvertPlayerUnitEvent(272) + constant playerunitevent EVENT_PLAYER_UNIT_SPELL_CAST = ConvertPlayerUnitEvent(273) + constant playerunitevent EVENT_PLAYER_UNIT_SPELL_EFFECT = ConvertPlayerUnitEvent(274) + constant playerunitevent EVENT_PLAYER_UNIT_SPELL_FINISH = ConvertPlayerUnitEvent(275) + constant playerunitevent EVENT_PLAYER_UNIT_SPELL_ENDCAST = ConvertPlayerUnitEvent(276) + constant playerunitevent EVENT_PLAYER_UNIT_PAWN_ITEM = ConvertPlayerUnitEvent(277) + constant playerunitevent EVENT_PLAYER_UNIT_STACK_ITEM = ConvertPlayerUnitEvent(319) + constant playerunitevent EVENT_PLAYER_UNIT_EQUIP_ITEM = ConvertPlayerUnitEvent(321) + constant playerunitevent EVENT_PLAYER_UNIT_UNEQUIP_ITEM = ConvertPlayerUnitEvent(323) + + //=================================================== + // For use with TriggerRegisterUnitEvent + //=================================================== + + constant unitevent EVENT_UNIT_SELL = ConvertUnitEvent(286) + constant unitevent EVENT_UNIT_CHANGE_OWNER = ConvertUnitEvent(287) + constant unitevent EVENT_UNIT_SELL_ITEM = ConvertUnitEvent(288) + constant unitevent EVENT_UNIT_SPELL_CHANNEL = ConvertUnitEvent(289) + constant unitevent EVENT_UNIT_SPELL_CAST = ConvertUnitEvent(290) + constant unitevent EVENT_UNIT_SPELL_EFFECT = ConvertUnitEvent(291) + constant unitevent EVENT_UNIT_SPELL_FINISH = ConvertUnitEvent(292) + constant unitevent EVENT_UNIT_SPELL_ENDCAST = ConvertUnitEvent(293) + constant unitevent EVENT_UNIT_PAWN_ITEM = ConvertUnitEvent(294) + constant unitevent EVENT_UNIT_STACK_ITEM = ConvertUnitEvent(318) + constant unitevent EVENT_UNIT_EQUIP_ITEM = ConvertUnitEvent(320) + constant unitevent EVENT_UNIT_UNEQUIP_ITEM = ConvertUnitEvent(322) + + //=================================================== + // Limit Event API constants + // variable, player state, game state, and unit state events + // ( do NOT change the order of these... ) + //=================================================== + constant limitop LESS_THAN = ConvertLimitOp(0) + constant limitop LESS_THAN_OR_EQUAL = ConvertLimitOp(1) + constant limitop EQUAL = ConvertLimitOp(2) + constant limitop GREATER_THAN_OR_EQUAL = ConvertLimitOp(3) + constant limitop GREATER_THAN = ConvertLimitOp(4) + constant limitop NOT_EQUAL = ConvertLimitOp(5) + +//=================================================== +// Unit Type Constants for use with IsUnitType() +//=================================================== + + constant unittype UNIT_TYPE_HERO = ConvertUnitType(0) + constant unittype UNIT_TYPE_DEAD = ConvertUnitType(1) + constant unittype UNIT_TYPE_STRUCTURE = ConvertUnitType(2) + + constant unittype UNIT_TYPE_FLYING = ConvertUnitType(3) + constant unittype UNIT_TYPE_GROUND = ConvertUnitType(4) + + constant unittype UNIT_TYPE_ATTACKS_FLYING = ConvertUnitType(5) + constant unittype UNIT_TYPE_ATTACKS_GROUND = ConvertUnitType(6) + + constant unittype UNIT_TYPE_MELEE_ATTACKER = ConvertUnitType(7) + constant unittype UNIT_TYPE_RANGED_ATTACKER = ConvertUnitType(8) + + constant unittype UNIT_TYPE_GIANT = ConvertUnitType(9) + constant unittype UNIT_TYPE_SUMMONED = ConvertUnitType(10) + constant unittype UNIT_TYPE_STUNNED = ConvertUnitType(11) + constant unittype UNIT_TYPE_PLAGUED = ConvertUnitType(12) + constant unittype UNIT_TYPE_SNARED = ConvertUnitType(13) + + constant unittype UNIT_TYPE_UNDEAD = ConvertUnitType(14) + constant unittype UNIT_TYPE_MECHANICAL = ConvertUnitType(15) + constant unittype UNIT_TYPE_PEON = ConvertUnitType(16) + constant unittype UNIT_TYPE_SAPPER = ConvertUnitType(17) + constant unittype UNIT_TYPE_TOWNHALL = ConvertUnitType(18) + constant unittype UNIT_TYPE_ANCIENT = ConvertUnitType(19) + + constant unittype UNIT_TYPE_TAUREN = ConvertUnitType(20) + constant unittype UNIT_TYPE_POISONED = ConvertUnitType(21) + constant unittype UNIT_TYPE_POLYMORPHED = ConvertUnitType(22) + constant unittype UNIT_TYPE_SLEEPING = ConvertUnitType(23) + constant unittype UNIT_TYPE_RESISTANT = ConvertUnitType(24) + constant unittype UNIT_TYPE_ETHEREAL = ConvertUnitType(25) + constant unittype UNIT_TYPE_MAGIC_IMMUNE = ConvertUnitType(26) + +//=================================================== +// Unit Type Constants for use with ChooseRandomItemEx() +//=================================================== + + constant itemtype ITEM_TYPE_PERMANENT = ConvertItemType(0) + constant itemtype ITEM_TYPE_CHARGED = ConvertItemType(1) + constant itemtype ITEM_TYPE_POWERUP = ConvertItemType(2) + constant itemtype ITEM_TYPE_ARTIFACT = ConvertItemType(3) + constant itemtype ITEM_TYPE_PURCHASABLE = ConvertItemType(4) + constant itemtype ITEM_TYPE_CAMPAIGN = ConvertItemType(5) + constant itemtype ITEM_TYPE_MISCELLANEOUS = ConvertItemType(6) + constant itemtype ITEM_TYPE_EQUIPMENT = ConvertItemType(7) + constant itemtype ITEM_TYPE_UNKNOWN = ConvertItemType(8) + constant itemtype ITEM_TYPE_ANY = ConvertItemType(9) + + // Deprecated, should use ITEM_TYPE_POWERUP + constant itemtype ITEM_TYPE_TOME = ConvertItemType(2) + +//=================================================== +// Item Equipment Type Constants for use with ChooseRandomItemExWithFilter() +//=================================================== + + constant equipmentType EQUIPMENT_TYPE_NONE = ConvertEquipmentType(0) + constant equipmentType EQUIPMENT_TYPE_HEAD = ConvertEquipmentType(1) + constant equipmentType EQUIPMENT_TYPE_CHEST = ConvertEquipmentType(2) + constant equipmentType EQUIPMENT_TYPE_GLOVES = ConvertEquipmentType(3) + constant equipmentType EQUIPMENT_TYPE_BOOTS = ConvertEquipmentType(4) + constant equipmentType EQUIPMENT_TYPE_RING = ConvertEquipmentType(5) + constant equipmentType EQUIPMENT_TYPE_PRIMARY = ConvertEquipmentType(6) + constant equipmentType EQUIPMENT_TYPE_OFFHAND = ConvertEquipmentType(7) + constant equipmentType EQUIPMENT_TYPE_TRINKET = ConvertEquipmentType(8) + constant equipmentType EQUIPMENT_TYPE_ANY = ConvertEquipmentType(9) + +//=================================================== +// Item Tag Type Constants for use with ChooseRandomItemExWithFilter() +//=================================================== + + constant itemTag ITEMTAG_TYPE_UNDEFINED = ConvertItemTag(0) + constant itemTag ITEMTAG_TYPE_DROPPABLE = ConvertItemTag(1) + constant itemTag ITEMTAG_TYPE_QUESTREWARD = ConvertItemTag(2) + constant itemTag ITEMTAG_TYPE_BOSSDROP = ConvertItemTag(3) + constant itemTag ITEMTAG_TYPE_SECRET = ConvertItemTag(4) + constant itemTag ITEMTAG_TYPE_PUZZLE = ConvertItemTag(5) + constant itemTag ITEMTAG_TYPE_WORLD = ConvertItemTag(6) + constant itemTag ITEMTAG_TYPE_SHOP = ConvertItemTag(7) + constant itemTag ITEMTAG_TYPE_ANY = ConvertItemTag(8) + +//=================================================== +// Equipment slot constants +//=================================================== + + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_HEAD = ConvertLoadoutSlot(0) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_CHEST = ConvertLoadoutSlot(1) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_GLOVES = ConvertLoadoutSlot(2) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_BOOTS = ConvertLoadoutSlot(3) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_RING = ConvertLoadoutSlot(4) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_RINGALT = ConvertLoadoutSlot(5) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_PRIMARY = ConvertLoadoutSlot(6) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_OFFHAND = ConvertLoadoutSlot(7) + constant loadoutslot EQUIPMENT_LOADOUT_SLOT_TRINKET = ConvertLoadoutSlot(8) + +//=================================================== +// Animatable Camera Fields +//=================================================== + + constant camerafield CAMERA_FIELD_TARGET_DISTANCE = ConvertCameraField(0) + constant camerafield CAMERA_FIELD_FARZ = ConvertCameraField(1) + constant camerafield CAMERA_FIELD_ANGLE_OF_ATTACK = ConvertCameraField(2) + constant camerafield CAMERA_FIELD_FIELD_OF_VIEW = ConvertCameraField(3) + constant camerafield CAMERA_FIELD_ROLL = ConvertCameraField(4) + constant camerafield CAMERA_FIELD_ROTATION = ConvertCameraField(5) + constant camerafield CAMERA_FIELD_ZOFFSET = ConvertCameraField(6) + constant camerafield CAMERA_FIELD_NEARZ = ConvertCameraField(7) + constant camerafield CAMERA_FIELD_LOCAL_PITCH = ConvertCameraField(8) + constant camerafield CAMERA_FIELD_LOCAL_YAW = ConvertCameraField(9) + constant camerafield CAMERA_FIELD_LOCAL_ROLL = ConvertCameraField(10) + constant camerafield CAMERA_FIELD_DEPTH_OF_FIELD_DISTANCE = ConvertCameraField(11) + constant camerafield CAMERA_FIELD_DEPTH_OF_FIELD_SCALE = ConvertCameraField(12) + constant camerafield CAMERA_FIELD_ZABSOLUTE = ConvertCameraField(13) + + constant blendmode BLEND_MODE_NONE = ConvertBlendMode(0) + constant blendmode BLEND_MODE_DONT_CARE = ConvertBlendMode(0) + constant blendmode BLEND_MODE_KEYALPHA = ConvertBlendMode(1) + constant blendmode BLEND_MODE_BLEND = ConvertBlendMode(2) + constant blendmode BLEND_MODE_ADDITIVE = ConvertBlendMode(3) + constant blendmode BLEND_MODE_MODULATE = ConvertBlendMode(4) + constant blendmode BLEND_MODE_MODULATE_2X = ConvertBlendMode(5) + + constant raritycontrol RARITY_FREQUENT = ConvertRarityControl(0) + constant raritycontrol RARITY_RARE = ConvertRarityControl(1) + + constant texmapflags TEXMAP_FLAG_NONE = ConvertTexMapFlags(0) + constant texmapflags TEXMAP_FLAG_WRAP_U = ConvertTexMapFlags(1) + constant texmapflags TEXMAP_FLAG_WRAP_V = ConvertTexMapFlags(2) + constant texmapflags TEXMAP_FLAG_WRAP_UV = ConvertTexMapFlags(3) + + constant fogstate FOG_OF_WAR_MASKED = ConvertFogState(1) + constant fogstate FOG_OF_WAR_FOGGED = ConvertFogState(2) + constant fogstate FOG_OF_WAR_VISIBLE = ConvertFogState(4) + +//=================================================== +// Camera Margin constants for use with GetCameraMargin +//=================================================== + + constant integer CAMERA_MARGIN_LEFT = 0 + constant integer CAMERA_MARGIN_RIGHT = 1 + constant integer CAMERA_MARGIN_TOP = 2 + constant integer CAMERA_MARGIN_BOTTOM = 3 + +//=================================================== +// Effect API constants +//=================================================== + + constant effecttype EFFECT_TYPE_EFFECT = ConvertEffectType(0) + constant effecttype EFFECT_TYPE_TARGET = ConvertEffectType(1) + constant effecttype EFFECT_TYPE_CASTER = ConvertEffectType(2) + constant effecttype EFFECT_TYPE_SPECIAL = ConvertEffectType(3) + constant effecttype EFFECT_TYPE_AREA_EFFECT = ConvertEffectType(4) + constant effecttype EFFECT_TYPE_MISSILE = ConvertEffectType(5) + constant effecttype EFFECT_TYPE_LIGHTNING = ConvertEffectType(6) + + constant soundtype SOUND_TYPE_EFFECT = ConvertSoundType(0) + constant soundtype SOUND_TYPE_EFFECT_LOOPED = ConvertSoundType(1) + +//=================================================== +// Custom UI API constants +//=================================================== + + constant originframetype ORIGIN_FRAME_GAME_UI = ConvertOriginFrameType(0) + constant originframetype ORIGIN_FRAME_COMMAND_BUTTON = ConvertOriginFrameType(1) + constant originframetype ORIGIN_FRAME_HERO_BAR = ConvertOriginFrameType(2) + constant originframetype ORIGIN_FRAME_HERO_BUTTON = ConvertOriginFrameType(3) + constant originframetype ORIGIN_FRAME_HERO_HP_BAR = ConvertOriginFrameType(4) + constant originframetype ORIGIN_FRAME_HERO_MANA_BAR = ConvertOriginFrameType(5) + constant originframetype ORIGIN_FRAME_HERO_BUTTON_INDICATOR = ConvertOriginFrameType(6) + constant originframetype ORIGIN_FRAME_ITEM_BUTTON = ConvertOriginFrameType(7) + constant originframetype ORIGIN_FRAME_MINIMAP = ConvertOriginFrameType(8) + constant originframetype ORIGIN_FRAME_MINIMAP_BUTTON = ConvertOriginFrameType(9) + constant originframetype ORIGIN_FRAME_SYSTEM_BUTTON = ConvertOriginFrameType(10) + constant originframetype ORIGIN_FRAME_TOOLTIP = ConvertOriginFrameType(11) + constant originframetype ORIGIN_FRAME_UBERTOOLTIP = ConvertOriginFrameType(12) + constant originframetype ORIGIN_FRAME_CHAT_MSG = ConvertOriginFrameType(13) + constant originframetype ORIGIN_FRAME_UNIT_MSG = ConvertOriginFrameType(14) + constant originframetype ORIGIN_FRAME_TOP_MSG = ConvertOriginFrameType(15) + constant originframetype ORIGIN_FRAME_PORTRAIT = ConvertOriginFrameType(16) + constant originframetype ORIGIN_FRAME_WORLD_FRAME = ConvertOriginFrameType(17) + constant originframetype ORIGIN_FRAME_SIMPLE_UI_PARENT = ConvertOriginFrameType(18) + constant originframetype ORIGIN_FRAME_PORTRAIT_HP_TEXT = ConvertOriginFrameType(19) + constant originframetype ORIGIN_FRAME_PORTRAIT_MANA_TEXT = ConvertOriginFrameType(20) + constant originframetype ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR = ConvertOriginFrameType(21) + constant originframetype ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR_LABEL = ConvertOriginFrameType(22) + + constant framepointtype FRAMEPOINT_TOPLEFT = ConvertFramePointType(0) + constant framepointtype FRAMEPOINT_TOP = ConvertFramePointType(1) + constant framepointtype FRAMEPOINT_TOPRIGHT = ConvertFramePointType(2) + constant framepointtype FRAMEPOINT_LEFT = ConvertFramePointType(3) + constant framepointtype FRAMEPOINT_CENTER = ConvertFramePointType(4) + constant framepointtype FRAMEPOINT_RIGHT = ConvertFramePointType(5) + constant framepointtype FRAMEPOINT_BOTTOMLEFT = ConvertFramePointType(6) + constant framepointtype FRAMEPOINT_BOTTOM = ConvertFramePointType(7) + constant framepointtype FRAMEPOINT_BOTTOMRIGHT = ConvertFramePointType(8) + + constant textaligntype TEXT_JUSTIFY_TOP = ConvertTextAlignType(0) + constant textaligntype TEXT_JUSTIFY_MIDDLE = ConvertTextAlignType(1) + constant textaligntype TEXT_JUSTIFY_BOTTOM = ConvertTextAlignType(2) + constant textaligntype TEXT_JUSTIFY_LEFT = ConvertTextAlignType(3) + constant textaligntype TEXT_JUSTIFY_CENTER = ConvertTextAlignType(4) + constant textaligntype TEXT_JUSTIFY_RIGHT = ConvertTextAlignType(5) + + constant frameeventtype FRAMEEVENT_CONTROL_CLICK = ConvertFrameEventType(1) + constant frameeventtype FRAMEEVENT_MOUSE_ENTER = ConvertFrameEventType(2) + constant frameeventtype FRAMEEVENT_MOUSE_LEAVE = ConvertFrameEventType(3) + constant frameeventtype FRAMEEVENT_MOUSE_UP = ConvertFrameEventType(4) + constant frameeventtype FRAMEEVENT_MOUSE_DOWN = ConvertFrameEventType(5) + constant frameeventtype FRAMEEVENT_MOUSE_WHEEL = ConvertFrameEventType(6) + constant frameeventtype FRAMEEVENT_CHECKBOX_CHECKED = ConvertFrameEventType(7) + constant frameeventtype FRAMEEVENT_CHECKBOX_UNCHECKED = ConvertFrameEventType(8) + constant frameeventtype FRAMEEVENT_EDITBOX_TEXT_CHANGED = ConvertFrameEventType(9) + constant frameeventtype FRAMEEVENT_POPUPMENU_ITEM_CHANGED = ConvertFrameEventType(10) + constant frameeventtype FRAMEEVENT_MOUSE_DOUBLECLICK = ConvertFrameEventType(11) + constant frameeventtype FRAMEEVENT_SPRITE_ANIM_UPDATE = ConvertFrameEventType(12) + constant frameeventtype FRAMEEVENT_SLIDER_VALUE_CHANGED = ConvertFrameEventType(13) + constant frameeventtype FRAMEEVENT_DIALOG_CANCEL = ConvertFrameEventType(14) + constant frameeventtype FRAMEEVENT_DIALOG_ACCEPT = ConvertFrameEventType(15) + constant frameeventtype FRAMEEVENT_EDITBOX_ENTER = ConvertFrameEventType(16) + +//=================================================== +// OS Key constants +//=================================================== + + constant oskeytype OSKEY_BACKSPACE = ConvertOsKeyType($08) + constant oskeytype OSKEY_TAB = ConvertOsKeyType($09) + constant oskeytype OSKEY_CLEAR = ConvertOsKeyType($0C) + constant oskeytype OSKEY_RETURN = ConvertOsKeyType($0D) + constant oskeytype OSKEY_SHIFT = ConvertOsKeyType($10) + constant oskeytype OSKEY_CONTROL = ConvertOsKeyType($11) + constant oskeytype OSKEY_ALT = ConvertOsKeyType($12) + constant oskeytype OSKEY_PAUSE = ConvertOsKeyType($13) + constant oskeytype OSKEY_CAPSLOCK = ConvertOsKeyType($14) + constant oskeytype OSKEY_KANA = ConvertOsKeyType($15) + constant oskeytype OSKEY_HANGUL = ConvertOsKeyType($15) + constant oskeytype OSKEY_JUNJA = ConvertOsKeyType($17) + constant oskeytype OSKEY_FINAL = ConvertOsKeyType($18) + constant oskeytype OSKEY_HANJA = ConvertOsKeyType($19) + constant oskeytype OSKEY_KANJI = ConvertOsKeyType($19) + constant oskeytype OSKEY_ESCAPE = ConvertOsKeyType($1B) + constant oskeytype OSKEY_CONVERT = ConvertOsKeyType($1C) + constant oskeytype OSKEY_NONCONVERT = ConvertOsKeyType($1D) + constant oskeytype OSKEY_ACCEPT = ConvertOsKeyType($1E) + constant oskeytype OSKEY_MODECHANGE = ConvertOsKeyType($1F) + constant oskeytype OSKEY_SPACE = ConvertOsKeyType($20) + constant oskeytype OSKEY_PAGEUP = ConvertOsKeyType($21) + constant oskeytype OSKEY_PAGEDOWN = ConvertOsKeyType($22) + constant oskeytype OSKEY_END = ConvertOsKeyType($23) + constant oskeytype OSKEY_HOME = ConvertOsKeyType($24) + constant oskeytype OSKEY_LEFT = ConvertOsKeyType($25) + constant oskeytype OSKEY_UP = ConvertOsKeyType($26) + constant oskeytype OSKEY_RIGHT = ConvertOsKeyType($27) + constant oskeytype OSKEY_DOWN = ConvertOsKeyType($28) + constant oskeytype OSKEY_SELECT = ConvertOsKeyType($29) + constant oskeytype OSKEY_PRINT = ConvertOsKeyType($2A) + constant oskeytype OSKEY_EXECUTE = ConvertOsKeyType($2B) + constant oskeytype OSKEY_PRINTSCREEN = ConvertOsKeyType($2C) + constant oskeytype OSKEY_INSERT = ConvertOsKeyType($2D) + constant oskeytype OSKEY_DELETE = ConvertOsKeyType($2E) + constant oskeytype OSKEY_HELP = ConvertOsKeyType($2F) + constant oskeytype OSKEY_0 = ConvertOsKeyType($30) + constant oskeytype OSKEY_1 = ConvertOsKeyType($31) + constant oskeytype OSKEY_2 = ConvertOsKeyType($32) + constant oskeytype OSKEY_3 = ConvertOsKeyType($33) + constant oskeytype OSKEY_4 = ConvertOsKeyType($34) + constant oskeytype OSKEY_5 = ConvertOsKeyType($35) + constant oskeytype OSKEY_6 = ConvertOsKeyType($36) + constant oskeytype OSKEY_7 = ConvertOsKeyType($37) + constant oskeytype OSKEY_8 = ConvertOsKeyType($38) + constant oskeytype OSKEY_9 = ConvertOsKeyType($39) + constant oskeytype OSKEY_A = ConvertOsKeyType($41) + constant oskeytype OSKEY_B = ConvertOsKeyType($42) + constant oskeytype OSKEY_C = ConvertOsKeyType($43) + constant oskeytype OSKEY_D = ConvertOsKeyType($44) + constant oskeytype OSKEY_E = ConvertOsKeyType($45) + constant oskeytype OSKEY_F = ConvertOsKeyType($46) + constant oskeytype OSKEY_G = ConvertOsKeyType($47) + constant oskeytype OSKEY_H = ConvertOsKeyType($48) + constant oskeytype OSKEY_I = ConvertOsKeyType($49) + constant oskeytype OSKEY_J = ConvertOsKeyType($4A) + constant oskeytype OSKEY_K = ConvertOsKeyType($4B) + constant oskeytype OSKEY_L = ConvertOsKeyType($4C) + constant oskeytype OSKEY_M = ConvertOsKeyType($4D) + constant oskeytype OSKEY_N = ConvertOsKeyType($4E) + constant oskeytype OSKEY_O = ConvertOsKeyType($4F) + constant oskeytype OSKEY_P = ConvertOsKeyType($50) + constant oskeytype OSKEY_Q = ConvertOsKeyType($51) + constant oskeytype OSKEY_R = ConvertOsKeyType($52) + constant oskeytype OSKEY_S = ConvertOsKeyType($53) + constant oskeytype OSKEY_T = ConvertOsKeyType($54) + constant oskeytype OSKEY_U = ConvertOsKeyType($55) + constant oskeytype OSKEY_V = ConvertOsKeyType($56) + constant oskeytype OSKEY_W = ConvertOsKeyType($57) + constant oskeytype OSKEY_X = ConvertOsKeyType($58) + constant oskeytype OSKEY_Y = ConvertOsKeyType($59) + constant oskeytype OSKEY_Z = ConvertOsKeyType($5A) + constant oskeytype OSKEY_LMETA = ConvertOsKeyType($5B) + constant oskeytype OSKEY_RMETA = ConvertOsKeyType($5C) + constant oskeytype OSKEY_APPS = ConvertOsKeyType($5D) + constant oskeytype OSKEY_SLEEP = ConvertOsKeyType($5F) + constant oskeytype OSKEY_NUMPAD0 = ConvertOsKeyType($60) + constant oskeytype OSKEY_NUMPAD1 = ConvertOsKeyType($61) + constant oskeytype OSKEY_NUMPAD2 = ConvertOsKeyType($62) + constant oskeytype OSKEY_NUMPAD3 = ConvertOsKeyType($63) + constant oskeytype OSKEY_NUMPAD4 = ConvertOsKeyType($64) + constant oskeytype OSKEY_NUMPAD5 = ConvertOsKeyType($65) + constant oskeytype OSKEY_NUMPAD6 = ConvertOsKeyType($66) + constant oskeytype OSKEY_NUMPAD7 = ConvertOsKeyType($67) + constant oskeytype OSKEY_NUMPAD8 = ConvertOsKeyType($68) + constant oskeytype OSKEY_NUMPAD9 = ConvertOsKeyType($69) + constant oskeytype OSKEY_MULTIPLY = ConvertOsKeyType($6A) + constant oskeytype OSKEY_ADD = ConvertOsKeyType($6B) + constant oskeytype OSKEY_SEPARATOR = ConvertOsKeyType($6C) + constant oskeytype OSKEY_SUBTRACT = ConvertOsKeyType($6D) + constant oskeytype OSKEY_DECIMAL = ConvertOsKeyType($6E) + constant oskeytype OSKEY_DIVIDE = ConvertOsKeyType($6F) + constant oskeytype OSKEY_F1 = ConvertOsKeyType($70) + constant oskeytype OSKEY_F2 = ConvertOsKeyType($71) + constant oskeytype OSKEY_F3 = ConvertOsKeyType($72) + constant oskeytype OSKEY_F4 = ConvertOsKeyType($73) + constant oskeytype OSKEY_F5 = ConvertOsKeyType($74) + constant oskeytype OSKEY_F6 = ConvertOsKeyType($75) + constant oskeytype OSKEY_F7 = ConvertOsKeyType($76) + constant oskeytype OSKEY_F8 = ConvertOsKeyType($77) + constant oskeytype OSKEY_F9 = ConvertOsKeyType($78) + constant oskeytype OSKEY_F10 = ConvertOsKeyType($79) + constant oskeytype OSKEY_F11 = ConvertOsKeyType($7A) + constant oskeytype OSKEY_F12 = ConvertOsKeyType($7B) + constant oskeytype OSKEY_F13 = ConvertOsKeyType($7C) + constant oskeytype OSKEY_F14 = ConvertOsKeyType($7D) + constant oskeytype OSKEY_F15 = ConvertOsKeyType($7E) + constant oskeytype OSKEY_F16 = ConvertOsKeyType($7F) + constant oskeytype OSKEY_F17 = ConvertOsKeyType($80) + constant oskeytype OSKEY_F18 = ConvertOsKeyType($81) + constant oskeytype OSKEY_F19 = ConvertOsKeyType($82) + constant oskeytype OSKEY_F20 = ConvertOsKeyType($83) + constant oskeytype OSKEY_F21 = ConvertOsKeyType($84) + constant oskeytype OSKEY_F22 = ConvertOsKeyType($85) + constant oskeytype OSKEY_F23 = ConvertOsKeyType($86) + constant oskeytype OSKEY_F24 = ConvertOsKeyType($87) + constant oskeytype OSKEY_NUMLOCK = ConvertOsKeyType($90) + constant oskeytype OSKEY_SCROLLLOCK = ConvertOsKeyType($91) + constant oskeytype OSKEY_OEM_NEC_EQUAL = ConvertOsKeyType($92) + constant oskeytype OSKEY_OEM_FJ_JISHO = ConvertOsKeyType($92) + constant oskeytype OSKEY_OEM_FJ_MASSHOU = ConvertOsKeyType($93) + constant oskeytype OSKEY_OEM_FJ_TOUROKU = ConvertOsKeyType($94) + constant oskeytype OSKEY_OEM_FJ_LOYA = ConvertOsKeyType($95) + constant oskeytype OSKEY_OEM_FJ_ROYA = ConvertOsKeyType($96) + constant oskeytype OSKEY_LSHIFT = ConvertOsKeyType($A0) + constant oskeytype OSKEY_RSHIFT = ConvertOsKeyType($A1) + constant oskeytype OSKEY_LCONTROL = ConvertOsKeyType($A2) + constant oskeytype OSKEY_RCONTROL = ConvertOsKeyType($A3) + constant oskeytype OSKEY_LALT = ConvertOsKeyType($A4) + constant oskeytype OSKEY_RALT = ConvertOsKeyType($A5) + constant oskeytype OSKEY_BROWSER_BACK = ConvertOsKeyType($A6) + constant oskeytype OSKEY_BROWSER_FORWARD = ConvertOsKeyType($A7) + constant oskeytype OSKEY_BROWSER_REFRESH = ConvertOsKeyType($A8) + constant oskeytype OSKEY_BROWSER_STOP = ConvertOsKeyType($A9) + constant oskeytype OSKEY_BROWSER_SEARCH = ConvertOsKeyType($AA) + constant oskeytype OSKEY_BROWSER_FAVORITES = ConvertOsKeyType($AB) + constant oskeytype OSKEY_BROWSER_HOME = ConvertOsKeyType($AC) + constant oskeytype OSKEY_VOLUME_MUTE = ConvertOsKeyType($AD) + constant oskeytype OSKEY_VOLUME_DOWN = ConvertOsKeyType($AE) + constant oskeytype OSKEY_VOLUME_UP = ConvertOsKeyType($AF) + constant oskeytype OSKEY_MEDIA_NEXT_TRACK = ConvertOsKeyType($B0) + constant oskeytype OSKEY_MEDIA_PREV_TRACK = ConvertOsKeyType($B1) + constant oskeytype OSKEY_MEDIA_STOP = ConvertOsKeyType($B2) + constant oskeytype OSKEY_MEDIA_PLAY_PAUSE = ConvertOsKeyType($B3) + constant oskeytype OSKEY_LAUNCH_MAIL = ConvertOsKeyType($B4) + constant oskeytype OSKEY_LAUNCH_MEDIA_SELECT = ConvertOsKeyType($B5) + constant oskeytype OSKEY_LAUNCH_APP1 = ConvertOsKeyType($B6) + constant oskeytype OSKEY_LAUNCH_APP2 = ConvertOsKeyType($B7) + constant oskeytype OSKEY_OEM_1 = ConvertOsKeyType($BA) + constant oskeytype OSKEY_OEM_PLUS = ConvertOsKeyType($BB) + constant oskeytype OSKEY_OEM_COMMA = ConvertOsKeyType($BC) + constant oskeytype OSKEY_OEM_MINUS = ConvertOsKeyType($BD) + constant oskeytype OSKEY_OEM_PERIOD = ConvertOsKeyType($BE) + constant oskeytype OSKEY_OEM_2 = ConvertOsKeyType($BF) + constant oskeytype OSKEY_OEM_3 = ConvertOsKeyType($C0) + constant oskeytype OSKEY_OEM_4 = ConvertOsKeyType($DB) + constant oskeytype OSKEY_OEM_5 = ConvertOsKeyType($DC) + constant oskeytype OSKEY_OEM_6 = ConvertOsKeyType($DD) + constant oskeytype OSKEY_OEM_7 = ConvertOsKeyType($DE) + constant oskeytype OSKEY_OEM_8 = ConvertOsKeyType($DF) + constant oskeytype OSKEY_OEM_AX = ConvertOsKeyType($E1) + constant oskeytype OSKEY_OEM_102 = ConvertOsKeyType($E2) + constant oskeytype OSKEY_ICO_HELP = ConvertOsKeyType($E3) + constant oskeytype OSKEY_ICO_00 = ConvertOsKeyType($E4) + constant oskeytype OSKEY_PROCESSKEY = ConvertOsKeyType($E5) + constant oskeytype OSKEY_ICO_CLEAR = ConvertOsKeyType($E6) + constant oskeytype OSKEY_PACKET = ConvertOsKeyType($E7) + constant oskeytype OSKEY_OEM_RESET = ConvertOsKeyType($E9) + constant oskeytype OSKEY_OEM_JUMP = ConvertOsKeyType($EA) + constant oskeytype OSKEY_OEM_PA1 = ConvertOsKeyType($EB) + constant oskeytype OSKEY_OEM_PA2 = ConvertOsKeyType($EC) + constant oskeytype OSKEY_OEM_PA3 = ConvertOsKeyType($ED) + constant oskeytype OSKEY_OEM_WSCTRL = ConvertOsKeyType($EE) + constant oskeytype OSKEY_OEM_CUSEL = ConvertOsKeyType($EF) + constant oskeytype OSKEY_OEM_ATTN = ConvertOsKeyType($F0) + constant oskeytype OSKEY_OEM_FINISH = ConvertOsKeyType($F1) + constant oskeytype OSKEY_OEM_COPY = ConvertOsKeyType($F2) + constant oskeytype OSKEY_OEM_AUTO = ConvertOsKeyType($F3) + constant oskeytype OSKEY_OEM_ENLW = ConvertOsKeyType($F4) + constant oskeytype OSKEY_OEM_BACKTAB = ConvertOsKeyType($F5) + constant oskeytype OSKEY_ATTN = ConvertOsKeyType($F6) + constant oskeytype OSKEY_CRSEL = ConvertOsKeyType($F7) + constant oskeytype OSKEY_EXSEL = ConvertOsKeyType($F8) + constant oskeytype OSKEY_EREOF = ConvertOsKeyType($F9) + constant oskeytype OSKEY_PLAY = ConvertOsKeyType($FA) + constant oskeytype OSKEY_ZOOM = ConvertOsKeyType($FB) + constant oskeytype OSKEY_NONAME = ConvertOsKeyType($FC) + constant oskeytype OSKEY_PA1 = ConvertOsKeyType($FD) + constant oskeytype OSKEY_OEM_CLEAR = ConvertOsKeyType($FE) + +//=================================================== +// Meta Key constants +//=================================================== + constant integer METAKEY_NONE = 0 + constant integer METAKEY_SHIFT = 1 + constant integer METAKEY_CTRL = 2 + constant integer METAKEY_ALT = 4 + constant integer METAKEY_WINKEYS = 8 + +//=================================================== +// Instanced Object Operation API constants +//=================================================== + + // Ability + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_NORMAL_X = ConvertAbilityIntegerField('abpx') + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_NORMAL_Y = ConvertAbilityIntegerField('abpy') + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_ACTIVATED_X = ConvertAbilityIntegerField('aubx') + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_ACTIVATED_Y = ConvertAbilityIntegerField('auby') + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_RESEARCH_X = ConvertAbilityIntegerField('arpx') + constant abilityintegerfield ABILITY_IF_BUTTON_POSITION_RESEARCH_Y = ConvertAbilityIntegerField('arpy') + constant abilityintegerfield ABILITY_IF_MISSILE_SPEED = ConvertAbilityIntegerField('amsp') + constant abilityintegerfield ABILITY_IF_TARGET_ATTACHMENTS = ConvertAbilityIntegerField('atac') + constant abilityintegerfield ABILITY_IF_CASTER_ATTACHMENTS = ConvertAbilityIntegerField('acac') + constant abilityintegerfield ABILITY_IF_PRIORITY = ConvertAbilityIntegerField('apri') + constant abilityintegerfield ABILITY_IF_LEVELS = ConvertAbilityIntegerField('alev') + constant abilityintegerfield ABILITY_IF_REQUIRED_LEVEL = ConvertAbilityIntegerField('arlv') + constant abilityintegerfield ABILITY_IF_LEVEL_SKIP_REQUIREMENT = ConvertAbilityIntegerField('alsk') + + constant abilitybooleanfield ABILITY_BF_HERO_ABILITY = ConvertAbilityBooleanField('aher') // Get only + constant abilitybooleanfield ABILITY_BF_ITEM_ABILITY = ConvertAbilityBooleanField('aite') + constant abilitybooleanfield ABILITY_BF_CHECK_DEPENDENCIES = ConvertAbilityBooleanField('achd') + + constant abilityrealfield ABILITY_RF_ARF_MISSILE_ARC = ConvertAbilityRealField('amac') + + constant abilitystringfield ABILITY_SF_NAME = ConvertAbilityStringField('anam') // Get Only + constant abilitystringfield ABILITY_SF_ICON_ACTIVATED = ConvertAbilityStringField('auar') + constant abilitystringfield ABILITY_SF_ICON_RESEARCH = ConvertAbilityStringField('arar') + constant abilitystringfield ABILITY_SF_EFFECT_SOUND = ConvertAbilityStringField('aefs') + constant abilitystringfield ABILITY_SF_EFFECT_SOUND_LOOPING = ConvertAbilityStringField('aefl') + + constant abilityintegerlevelfield ABILITY_ILF_MANA_COST = ConvertAbilityIntegerLevelField('amcs') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_WAVES = ConvertAbilityIntegerLevelField('Hbz1') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SHARDS = ConvertAbilityIntegerLevelField('Hbz3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_UNITS_TELEPORTED = ConvertAbilityIntegerLevelField('Hmt1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_COUNT_HWE2 = ConvertAbilityIntegerLevelField('Hwe2') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_IMAGES = ConvertAbilityIntegerLevelField('Omi1') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_UAN1 = ConvertAbilityIntegerLevelField('Uan1') + constant abilityintegerlevelfield ABILITY_ILF_MORPHING_FLAGS = ConvertAbilityIntegerLevelField('Eme2') + constant abilityintegerlevelfield ABILITY_ILF_STRENGTH_BONUS_NRG5 = ConvertAbilityIntegerLevelField('Nrg5') + constant abilityintegerlevelfield ABILITY_ILF_DEFENSE_BONUS_NRG6 = ConvertAbilityIntegerLevelField('Nrg6') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_TARGETS_HIT = ConvertAbilityIntegerLevelField('Ocl2') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_OFS1 = ConvertAbilityIntegerLevelField('Ofs1') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_OSF2 = ConvertAbilityIntegerLevelField('Osf2') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_EFN1 = ConvertAbilityIntegerLevelField('Efn1') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_HRE1 = ConvertAbilityIntegerLevelField('Hre1') + constant abilityintegerlevelfield ABILITY_ILF_STACK_FLAGS = ConvertAbilityIntegerLevelField('Hca4') + constant abilityintegerlevelfield ABILITY_ILF_MINIMUM_NUMBER_OF_UNITS = ConvertAbilityIntegerLevelField('Ndp2') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_NDP3 = ConvertAbilityIntegerLevelField('Ndp3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_UNITS_CREATED_NRC2 = ConvertAbilityIntegerLevelField('Nrc2') + constant abilityintegerlevelfield ABILITY_ILF_SHIELD_LIFE = ConvertAbilityIntegerLevelField('Ams3') + constant abilityintegerlevelfield ABILITY_ILF_MANA_LOSS_AMS4 = ConvertAbilityIntegerLevelField('Ams4') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_PER_INTERVAL_BGM1 = ConvertAbilityIntegerLevelField('Bgm1') + constant abilityintegerlevelfield ABILITY_ILF_MAX_NUMBER_OF_MINERS = ConvertAbilityIntegerLevelField('Bgm3') + constant abilityintegerlevelfield ABILITY_ILF_CARGO_CAPACITY = ConvertAbilityIntegerLevelField('Car1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_CREEP_LEVEL_DEV3 = ConvertAbilityIntegerLevelField('Dev3') + constant abilityintegerlevelfield ABILITY_ILF_MAX_CREEP_LEVEL_DEV1 = ConvertAbilityIntegerLevelField('Dev1') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_PER_INTERVAL_EGM1 = ConvertAbilityIntegerLevelField('Egm1') + constant abilityintegerlevelfield ABILITY_ILF_DEFENSE_REDUCTION = ConvertAbilityIntegerLevelField('Fae1') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_FLA1 = ConvertAbilityIntegerLevelField('Fla1') + constant abilityintegerlevelfield ABILITY_ILF_FLARE_COUNT = ConvertAbilityIntegerLevelField('Fla3') + constant abilityintegerlevelfield ABILITY_ILF_MAX_GOLD = ConvertAbilityIntegerLevelField('Gld1') + constant abilityintegerlevelfield ABILITY_ILF_MINING_CAPACITY = ConvertAbilityIntegerLevelField('Gld3') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_CORPSES_GYD1 = ConvertAbilityIntegerLevelField('Gyd1') + constant abilityintegerlevelfield ABILITY_ILF_DAMAGE_TO_TREE = ConvertAbilityIntegerLevelField('Har1') + constant abilityintegerlevelfield ABILITY_ILF_LUMBER_CAPACITY = ConvertAbilityIntegerLevelField('Har2') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_CAPACITY = ConvertAbilityIntegerLevelField('Har3') + constant abilityintegerlevelfield ABILITY_ILF_DEFENSE_INCREASE_INF2 = ConvertAbilityIntegerLevelField('Inf2') + constant abilityintegerlevelfield ABILITY_ILF_INTERACTION_TYPE = ConvertAbilityIntegerLevelField('Neu2') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_COST_NDT1 = ConvertAbilityIntegerLevelField('Ndt1') + constant abilityintegerlevelfield ABILITY_ILF_LUMBER_COST_NDT2 = ConvertAbilityIntegerLevelField('Ndt2') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_NDT3 = ConvertAbilityIntegerLevelField('Ndt3') + constant abilityintegerlevelfield ABILITY_ILF_STACKING_TYPE_POI4 = ConvertAbilityIntegerLevelField('Poi4') + constant abilityintegerlevelfield ABILITY_ILF_STACKING_TYPE_POA5 = ConvertAbilityIntegerLevelField('Poa5') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_CREEP_LEVEL_PLY1 = ConvertAbilityIntegerLevelField('Ply1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_CREEP_LEVEL_POS1 = ConvertAbilityIntegerLevelField('Pos1') + constant abilityintegerlevelfield ABILITY_ILF_MOVEMENT_UPDATE_FREQUENCY_PRG1 = ConvertAbilityIntegerLevelField('Prg1') + constant abilityintegerlevelfield ABILITY_ILF_ATTACK_UPDATE_FREQUENCY_PRG2 = ConvertAbilityIntegerLevelField('Prg2') + constant abilityintegerlevelfield ABILITY_ILF_MANA_LOSS_PRG6 = ConvertAbilityIntegerLevelField('Prg6') + constant abilityintegerlevelfield ABILITY_ILF_UNITS_SUMMONED_TYPE_ONE = ConvertAbilityIntegerLevelField('Rai1') + constant abilityintegerlevelfield ABILITY_ILF_UNITS_SUMMONED_TYPE_TWO = ConvertAbilityIntegerLevelField('Rai2') + constant abilityintegerlevelfield ABILITY_ILF_MAX_UNITS_SUMMONED = ConvertAbilityIntegerLevelField('Ucb5') + constant abilityintegerlevelfield ABILITY_ILF_ALLOW_WHEN_FULL_REJ3 = ConvertAbilityIntegerLevelField('Rej3') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_UNITS_CHARGED_TO_CASTER = ConvertAbilityIntegerLevelField('Rpb5') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_UNITS_AFFECTED = ConvertAbilityIntegerLevelField('Rpb6') + constant abilityintegerlevelfield ABILITY_ILF_DEFENSE_INCREASE_ROA2 = ConvertAbilityIntegerLevelField('Roa2') + constant abilityintegerlevelfield ABILITY_ILF_MAX_UNITS_ROA7 = ConvertAbilityIntegerLevelField('Roa7') + constant abilityintegerlevelfield ABILITY_ILF_ROOTED_WEAPONS = ConvertAbilityIntegerLevelField('Roo1') + constant abilityintegerlevelfield ABILITY_ILF_UPROOTED_WEAPONS = ConvertAbilityIntegerLevelField('Roo2') + constant abilityintegerlevelfield ABILITY_ILF_UPROOTED_DEFENSE_TYPE = ConvertAbilityIntegerLevelField('Roo4') + constant abilityintegerlevelfield ABILITY_ILF_ACCUMULATION_STEP = ConvertAbilityIntegerLevelField('Sal2') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_OWLS = ConvertAbilityIntegerLevelField('Esn4') + constant abilityintegerlevelfield ABILITY_ILF_STACKING_TYPE_SPO4 = ConvertAbilityIntegerLevelField('Spo4') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_UNITS = ConvertAbilityIntegerLevelField('Sod1') + constant abilityintegerlevelfield ABILITY_ILF_SPIDER_CAPACITY = ConvertAbilityIntegerLevelField('Spa1') + constant abilityintegerlevelfield ABILITY_ILF_INTERVALS_BEFORE_CHANGING_TREES = ConvertAbilityIntegerLevelField('Wha2') + constant abilityintegerlevelfield ABILITY_ILF_AGILITY_BONUS = ConvertAbilityIntegerLevelField('Iagi') + constant abilityintegerlevelfield ABILITY_ILF_INTELLIGENCE_BONUS = ConvertAbilityIntegerLevelField('Iint') + constant abilityintegerlevelfield ABILITY_ILF_STRENGTH_BONUS_ISTR = ConvertAbilityIntegerLevelField('Istr') + constant abilityintegerlevelfield ABILITY_ILF_ATTACK_BONUS = ConvertAbilityIntegerLevelField('Iatt') + constant abilityintegerlevelfield ABILITY_ILF_DEFENSE_BONUS_IDEF = ConvertAbilityIntegerLevelField('Idef') + constant abilityintegerlevelfield ABILITY_ILF_SUMMON_1_AMOUNT = ConvertAbilityIntegerLevelField('Isn1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMON_2_AMOUNT = ConvertAbilityIntegerLevelField('Isn2') + constant abilityintegerlevelfield ABILITY_ILF_EXPERIENCE_GAINED = ConvertAbilityIntegerLevelField('Ixpg') + constant abilityintegerlevelfield ABILITY_ILF_HIT_POINTS_GAINED_IHPG = ConvertAbilityIntegerLevelField('Ihpg') + constant abilityintegerlevelfield ABILITY_ILF_MANA_POINTS_GAINED_IMPG = ConvertAbilityIntegerLevelField('Impg') + constant abilityintegerlevelfield ABILITY_ILF_HIT_POINTS_GAINED_IHP2 = ConvertAbilityIntegerLevelField('Ihp2') + constant abilityintegerlevelfield ABILITY_ILF_MANA_POINTS_GAINED_IMP2 = ConvertAbilityIntegerLevelField('Imp2') + constant abilityintegerlevelfield ABILITY_ILF_DAMAGE_BONUS_DICE = ConvertAbilityIntegerLevelField('Idic') + constant abilityintegerlevelfield ABILITY_ILF_ARMOR_PENALTY_IARP = ConvertAbilityIntegerLevelField('Iarp') + constant abilityintegerlevelfield ABILITY_ILF_ENABLED_ATTACK_INDEX_IOB5 = ConvertAbilityIntegerLevelField('Iob5') + constant abilityintegerlevelfield ABILITY_ILF_LEVELS_GAINED = ConvertAbilityIntegerLevelField('Ilev') + constant abilityintegerlevelfield ABILITY_ILF_MAX_LIFE_GAINED = ConvertAbilityIntegerLevelField('Ilif') + constant abilityintegerlevelfield ABILITY_ILF_MAX_MANA_GAINED = ConvertAbilityIntegerLevelField('Iman') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_GIVEN = ConvertAbilityIntegerLevelField('Igol') + constant abilityintegerlevelfield ABILITY_ILF_LUMBER_GIVEN = ConvertAbilityIntegerLevelField('Ilum') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_IFA1 = ConvertAbilityIntegerLevelField('Ifa1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_CREEP_LEVEL_ICRE = ConvertAbilityIntegerLevelField('Icre') + constant abilityintegerlevelfield ABILITY_ILF_MOVEMENT_SPEED_BONUS = ConvertAbilityIntegerLevelField('Imvb') + constant abilityintegerlevelfield ABILITY_ILF_HIT_POINTS_REGENERATED_PER_SECOND = ConvertAbilityIntegerLevelField('Ihpr') + constant abilityintegerlevelfield ABILITY_ILF_SIGHT_RANGE_BONUS = ConvertAbilityIntegerLevelField('Isib') + constant abilityintegerlevelfield ABILITY_ILF_DAMAGE_PER_DURATION = ConvertAbilityIntegerLevelField('Icfd') + constant abilityintegerlevelfield ABILITY_ILF_MANA_USED_PER_SECOND = ConvertAbilityIntegerLevelField('Icfm') + constant abilityintegerlevelfield ABILITY_ILF_EXTRA_MANA_REQUIRED = ConvertAbilityIntegerLevelField('Icfx') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_RADIUS_IDET = ConvertAbilityIntegerLevelField('Idet') + constant abilityintegerlevelfield ABILITY_ILF_MANA_LOSS_PER_UNIT_IDIM = ConvertAbilityIntegerLevelField('Idim') + constant abilityintegerlevelfield ABILITY_ILF_DAMAGE_TO_SUMMONED_UNITS_IDID = ConvertAbilityIntegerLevelField('Idid') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_IREC = ConvertAbilityIntegerLevelField('Irec') + constant abilityintegerlevelfield ABILITY_ILF_DELAY_AFTER_DEATH_SECONDS = ConvertAbilityIntegerLevelField('Ircd') + constant abilityintegerlevelfield ABILITY_ILF_RESTORED_LIFE = ConvertAbilityIntegerLevelField('irc2') + constant abilityintegerlevelfield ABILITY_ILF_RESTORED_MANA__1_FOR_CURRENT = ConvertAbilityIntegerLevelField('irc3') + constant abilityintegerlevelfield ABILITY_ILF_HIT_POINTS_RESTORED = ConvertAbilityIntegerLevelField('Ihps') + constant abilityintegerlevelfield ABILITY_ILF_MANA_POINTS_RESTORED = ConvertAbilityIntegerLevelField('Imps') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_ITPM = ConvertAbilityIntegerLevelField('Itpm') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_CAD1 = ConvertAbilityIntegerLevelField('Cad1') + constant abilityintegerlevelfield ABILITY_ILF_TERRAIN_DEFORMATION_DURATION_MS = ConvertAbilityIntegerLevelField('Wrs3') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_UNITS = ConvertAbilityIntegerLevelField('Uds1') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_DET1 = ConvertAbilityIntegerLevelField('Det1') + constant abilityintegerlevelfield ABILITY_ILF_GOLD_COST_PER_STRUCTURE = ConvertAbilityIntegerLevelField('Nsp1') + constant abilityintegerlevelfield ABILITY_ILF_LUMBER_COST_PER_USE = ConvertAbilityIntegerLevelField('Nsp2') + constant abilityintegerlevelfield ABILITY_ILF_DETECTION_TYPE_NSP3 = ConvertAbilityIntegerLevelField('Nsp3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SWARM_UNITS = ConvertAbilityIntegerLevelField('Uls1') + constant abilityintegerlevelfield ABILITY_ILF_MAX_SWARM_UNITS_PER_TARGET = ConvertAbilityIntegerLevelField('Uls3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_NBA2 = ConvertAbilityIntegerLevelField('Nba2') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_CREEP_LEVEL_NCH1 = ConvertAbilityIntegerLevelField('Nch1') + constant abilityintegerlevelfield ABILITY_ILF_ATTACKS_PREVENTED = ConvertAbilityIntegerLevelField('Nsi1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_TARGETS_EFK3 = ConvertAbilityIntegerLevelField('Efk3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_ESV1 = ConvertAbilityIntegerLevelField('Esv1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_CORPSES_EXH1 = ConvertAbilityIntegerLevelField('exh1') + constant abilityintegerlevelfield ABILITY_ILF_ITEM_CAPACITY = ConvertAbilityIntegerLevelField('inv1') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_NUMBER_OF_TARGETS_SPL2 = ConvertAbilityIntegerLevelField('spl2') + constant abilityintegerlevelfield ABILITY_ILF_ALLOW_WHEN_FULL_IRL3 = ConvertAbilityIntegerLevelField('irl3') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_DISPELLED_UNITS = ConvertAbilityIntegerLevelField('idc3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_LURES = ConvertAbilityIntegerLevelField('imo1') + constant abilityintegerlevelfield ABILITY_ILF_NEW_TIME_OF_DAY_HOUR = ConvertAbilityIntegerLevelField('ict1') + constant abilityintegerlevelfield ABILITY_ILF_NEW_TIME_OF_DAY_MINUTE = ConvertAbilityIntegerLevelField('ict2') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_UNITS_CREATED_MEC1 = ConvertAbilityIntegerLevelField('mec1') + constant abilityintegerlevelfield ABILITY_ILF_MINIMUM_SPELLS = ConvertAbilityIntegerLevelField('spb3') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_SPELLS = ConvertAbilityIntegerLevelField('spb4') + constant abilityintegerlevelfield ABILITY_ILF_DISABLED_ATTACK_INDEX = ConvertAbilityIntegerLevelField('gra3') + constant abilityintegerlevelfield ABILITY_ILF_ENABLED_ATTACK_INDEX_GRA4 = ConvertAbilityIntegerLevelField('gra4') + constant abilityintegerlevelfield ABILITY_ILF_MAXIMUM_ATTACKS = ConvertAbilityIntegerLevelField('gra5') + constant abilityintegerlevelfield ABILITY_ILF_BUILDING_TYPES_ALLOWED_NPR1 = ConvertAbilityIntegerLevelField('Npr1') + constant abilityintegerlevelfield ABILITY_ILF_BUILDING_TYPES_ALLOWED_NSA1 = ConvertAbilityIntegerLevelField('Nsa1') + constant abilityintegerlevelfield ABILITY_ILF_ATTACK_MODIFICATION = ConvertAbilityIntegerLevelField('Iaa1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_COUNT_NPA5 = ConvertAbilityIntegerLevelField('Npa5') + constant abilityintegerlevelfield ABILITY_ILF_UPGRADE_LEVELS = ConvertAbilityIntegerLevelField('Igl1') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_NDO2 = ConvertAbilityIntegerLevelField('Ndo2') + constant abilityintegerlevelfield ABILITY_ILF_BEASTS_PER_SECOND = ConvertAbilityIntegerLevelField('Nst1') + constant abilityintegerlevelfield ABILITY_ILF_TARGET_TYPE = ConvertAbilityIntegerLevelField('Ncl2') + constant abilityintegerlevelfield ABILITY_ILF_OPTIONS = ConvertAbilityIntegerLevelField('Ncl3') + constant abilityintegerlevelfield ABILITY_ILF_ARMOR_PENALTY_NAB3 = ConvertAbilityIntegerLevelField('Nab3') + constant abilityintegerlevelfield ABILITY_ILF_WAVE_COUNT_NHS6 = ConvertAbilityIntegerLevelField('Nhs6') + constant abilityintegerlevelfield ABILITY_ILF_MAX_CREEP_LEVEL_NTM3 = ConvertAbilityIntegerLevelField('Ntm3') + constant abilityintegerlevelfield ABILITY_ILF_MISSILE_COUNT = ConvertAbilityIntegerLevelField('Ncs3') + constant abilityintegerlevelfield ABILITY_ILF_SPLIT_ATTACK_COUNT = ConvertAbilityIntegerLevelField('Nlm3') + constant abilityintegerlevelfield ABILITY_ILF_GENERATION_COUNT = ConvertAbilityIntegerLevelField('Nlm6') + constant abilityintegerlevelfield ABILITY_ILF_ROCK_RING_COUNT = ConvertAbilityIntegerLevelField('Nvc1') + constant abilityintegerlevelfield ABILITY_ILF_WAVE_COUNT_NVC2 = ConvertAbilityIntegerLevelField('Nvc2') + constant abilityintegerlevelfield ABILITY_ILF_PREFER_HOSTILES_TAU1 = ConvertAbilityIntegerLevelField('Tau1') + constant abilityintegerlevelfield ABILITY_ILF_PREFER_FRIENDLIES_TAU2 = ConvertAbilityIntegerLevelField('Tau2') + constant abilityintegerlevelfield ABILITY_ILF_MAX_UNITS_TAU3 = ConvertAbilityIntegerLevelField('Tau3') + constant abilityintegerlevelfield ABILITY_ILF_NUMBER_OF_PULSES = ConvertAbilityIntegerLevelField('Tau4') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_HWE1 = ConvertAbilityIntegerLevelField('Hwe1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_UIN4 = ConvertAbilityIntegerLevelField('Uin4') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_OSF1 = ConvertAbilityIntegerLevelField('Osf1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_EFNU = ConvertAbilityIntegerLevelField('Efnu') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_NBAU = ConvertAbilityIntegerLevelField('Nbau') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_NTOU = ConvertAbilityIntegerLevelField('Ntou') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_ESVU = ConvertAbilityIntegerLevelField('Esvu') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPES = ConvertAbilityIntegerLevelField('Nef1') + constant abilityintegerlevelfield ABILITY_ILF_SUMMONED_UNIT_TYPE_NDOU = ConvertAbilityIntegerLevelField('Ndou') + constant abilityintegerlevelfield ABILITY_ILF_ALTERNATE_FORM_UNIT_EMEU = ConvertAbilityIntegerLevelField('Emeu') + constant abilityintegerlevelfield ABILITY_ILF_PLAGUE_WARD_UNIT_TYPE = ConvertAbilityIntegerLevelField('Aplu') + constant abilityintegerlevelfield ABILITY_ILF_ALLOWED_UNIT_TYPE_BTL1 = ConvertAbilityIntegerLevelField('Btl1') + constant abilityintegerlevelfield ABILITY_ILF_NEW_UNIT_TYPE = ConvertAbilityIntegerLevelField('Cha1') + constant abilityintegerlevelfield ABILITY_ILF_RESULTING_UNIT_TYPE_ENT1 = ConvertAbilityIntegerLevelField('ent1') + constant abilityintegerlevelfield ABILITY_ILF_CORPSE_UNIT_TYPE = ConvertAbilityIntegerLevelField('Gydu') + constant abilityintegerlevelfield ABILITY_ILF_ALLOWED_UNIT_TYPE_LOA1 = ConvertAbilityIntegerLevelField('Loa1') + constant abilityintegerlevelfield ABILITY_ILF_UNIT_TYPE_FOR_LIMIT_CHECK = ConvertAbilityIntegerLevelField('Raiu') + constant abilityintegerlevelfield ABILITY_ILF_WARD_UNIT_TYPE_STAU = ConvertAbilityIntegerLevelField('Stau') + constant abilityintegerlevelfield ABILITY_ILF_EFFECT_ABILITY = ConvertAbilityIntegerLevelField('Iobu') + constant abilityintegerlevelfield ABILITY_ILF_CONVERSION_UNIT = ConvertAbilityIntegerLevelField('Ndc2') + constant abilityintegerlevelfield ABILITY_ILF_UNIT_TO_PRESERVE = ConvertAbilityIntegerLevelField('Nsl1') + constant abilityintegerlevelfield ABILITY_ILF_UNIT_TYPE_ALLOWED = ConvertAbilityIntegerLevelField('Chl1') + constant abilityintegerlevelfield ABILITY_ILF_SWARM_UNIT_TYPE = ConvertAbilityIntegerLevelField('Ulsu') + constant abilityintegerlevelfield ABILITY_ILF_RESULTING_UNIT_TYPE_COAU = ConvertAbilityIntegerLevelField('coau') + constant abilityintegerlevelfield ABILITY_ILF_UNIT_TYPE_EXHU = ConvertAbilityIntegerLevelField('exhu') + constant abilityintegerlevelfield ABILITY_ILF_WARD_UNIT_TYPE_HWDU = ConvertAbilityIntegerLevelField('hwdu') + constant abilityintegerlevelfield ABILITY_ILF_LURE_UNIT_TYPE = ConvertAbilityIntegerLevelField('imou') + constant abilityintegerlevelfield ABILITY_ILF_UNIT_TYPE_IPMU = ConvertAbilityIntegerLevelField('ipmu') + constant abilityintegerlevelfield ABILITY_ILF_FACTORY_UNIT_ID = ConvertAbilityIntegerLevelField('Nsyu') + constant abilityintegerlevelfield ABILITY_ILF_SPAWN_UNIT_ID_NFYU = ConvertAbilityIntegerLevelField('Nfyu') + constant abilityintegerlevelfield ABILITY_ILF_DESTRUCTIBLE_ID = ConvertAbilityIntegerLevelField('Nvcu') + constant abilityintegerlevelfield ABILITY_ILF_UPGRADE_TYPE = ConvertAbilityIntegerLevelField('Iglu') + + constant abilityreallevelfield ABILITY_RLF_CASTING_TIME = ConvertAbilityRealLevelField('acas') + constant abilityreallevelfield ABILITY_RLF_DURATION_NORMAL = ConvertAbilityRealLevelField('adur') + constant abilityreallevelfield ABILITY_RLF_DURATION_HERO = ConvertAbilityRealLevelField('ahdu') + constant abilityreallevelfield ABILITY_RLF_COOLDOWN = ConvertAbilityRealLevelField('acdn') + constant abilityreallevelfield ABILITY_RLF_AREA_OF_EFFECT = ConvertAbilityRealLevelField('aare') + constant abilityreallevelfield ABILITY_RLF_CAST_RANGE = ConvertAbilityRealLevelField('aran') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_HBZ2 = ConvertAbilityRealLevelField('Hbz2') + constant abilityreallevelfield ABILITY_RLF_BUILDING_REDUCTION_HBZ4 = ConvertAbilityRealLevelField('Hbz4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_HBZ5 = ConvertAbilityRealLevelField('Hbz5') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_DAMAGE_PER_WAVE = ConvertAbilityRealLevelField('Hbz6') + constant abilityreallevelfield ABILITY_RLF_MANA_REGENERATION_INCREASE = ConvertAbilityRealLevelField('Hab1') + constant abilityreallevelfield ABILITY_RLF_CASTING_DELAY = ConvertAbilityRealLevelField('Hmt2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_OWW1 = ConvertAbilityRealLevelField('Oww1') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_OWW2 = ConvertAbilityRealLevelField('Oww2') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_CRITICAL_STRIKE = ConvertAbilityRealLevelField('Ocr1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_MULTIPLIER_OCR2 = ConvertAbilityRealLevelField('Ocr2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_OCR3 = ConvertAbilityRealLevelField('Ocr3') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_EVADE_OCR4 = ConvertAbilityRealLevelField('Ocr4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_PERCENT_OMI2 = ConvertAbilityRealLevelField('Omi2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_TAKEN_PERCENT_OMI3 = ConvertAbilityRealLevelField('Omi3') + constant abilityreallevelfield ABILITY_RLF_ANIMATION_DELAY = ConvertAbilityRealLevelField('Omi4') + constant abilityreallevelfield ABILITY_RLF_TRANSITION_TIME = ConvertAbilityRealLevelField('Owk1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_OWK2 = ConvertAbilityRealLevelField('Owk2') + constant abilityreallevelfield ABILITY_RLF_BACKSTAB_DAMAGE = ConvertAbilityRealLevelField('Owk3') + constant abilityreallevelfield ABILITY_RLF_AMOUNT_HEALED_DAMAGED_UDC1 = ConvertAbilityRealLevelField('Udc1') + constant abilityreallevelfield ABILITY_RLF_LIFE_CONVERTED_TO_MANA = ConvertAbilityRealLevelField('Udp1') + constant abilityreallevelfield ABILITY_RLF_LIFE_CONVERTED_TO_LIFE = ConvertAbilityRealLevelField('Udp2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_UAU1 = ConvertAbilityRealLevelField('Uau1') + constant abilityreallevelfield ABILITY_RLF_LIFE_REGENERATION_INCREASE_PERCENT = ConvertAbilityRealLevelField('Uau2') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_EVADE_EEV1 = ConvertAbilityRealLevelField('Eev1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_INTERVAL = ConvertAbilityRealLevelField('Eim1') + constant abilityreallevelfield ABILITY_RLF_MANA_DRAINED_PER_SECOND_EIM2 = ConvertAbilityRealLevelField('Eim2') + constant abilityreallevelfield ABILITY_RLF_BUFFER_MANA_REQUIRED = ConvertAbilityRealLevelField('Eim3') + constant abilityreallevelfield ABILITY_RLF_MAX_MANA_DRAINED = ConvertAbilityRealLevelField('Emb1') + constant abilityreallevelfield ABILITY_RLF_BOLT_DELAY = ConvertAbilityRealLevelField('Emb2') + constant abilityreallevelfield ABILITY_RLF_BOLT_LIFETIME = ConvertAbilityRealLevelField('Emb3') + constant abilityreallevelfield ABILITY_RLF_ALTITUDE_ADJUSTMENT_DURATION = ConvertAbilityRealLevelField('Eme3') + constant abilityreallevelfield ABILITY_RLF_LANDING_DELAY_TIME = ConvertAbilityRealLevelField('Eme4') + constant abilityreallevelfield ABILITY_RLF_ALTERNATE_FORM_HIT_POINT_BONUS = ConvertAbilityRealLevelField('Eme5') + constant abilityreallevelfield ABILITY_RLF_MOVE_SPEED_BONUS_INFO_PANEL_ONLY = ConvertAbilityRealLevelField('Ncr5') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_BONUS_INFO_PANEL_ONLY = ConvertAbilityRealLevelField('Ncr6') + constant abilityreallevelfield ABILITY_RLF_LIFE_REGENERATION_RATE_PER_SECOND = ConvertAbilityRealLevelField('ave5') + constant abilityreallevelfield ABILITY_RLF_STUN_DURATION_USL1 = ConvertAbilityRealLevelField('Usl1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_DAMAGE_STOLEN_PERCENT = ConvertAbilityRealLevelField('Uav1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_UCS1 = ConvertAbilityRealLevelField('Ucs1') + constant abilityreallevelfield ABILITY_RLF_MAX_DAMAGE_UCS2 = ConvertAbilityRealLevelField('Ucs2') + constant abilityreallevelfield ABILITY_RLF_DISTANCE_UCS3 = ConvertAbilityRealLevelField('Ucs3') + constant abilityreallevelfield ABILITY_RLF_FINAL_AREA_UCS4 = ConvertAbilityRealLevelField('Ucs4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_UIN1 = ConvertAbilityRealLevelField('Uin1') + constant abilityreallevelfield ABILITY_RLF_DURATION = ConvertAbilityRealLevelField('Uin2') + constant abilityreallevelfield ABILITY_RLF_IMPACT_DELAY = ConvertAbilityRealLevelField('Uin3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_TARGET_OCL1 = ConvertAbilityRealLevelField('Ocl1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_REDUCTION_PER_TARGET = ConvertAbilityRealLevelField('Ocl3') + constant abilityreallevelfield ABILITY_RLF_EFFECT_DELAY_OEQ1 = ConvertAbilityRealLevelField('Oeq1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_TO_BUILDINGS = ConvertAbilityRealLevelField('Oeq2') + constant abilityreallevelfield ABILITY_RLF_UNITS_SLOWED_PERCENT = ConvertAbilityRealLevelField('Oeq3') + constant abilityreallevelfield ABILITY_RLF_FINAL_AREA_OEQ4 = ConvertAbilityRealLevelField('Oeq4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_EER1 = ConvertAbilityRealLevelField('Eer1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_TO_ATTACKERS = ConvertAbilityRealLevelField('Eah1') + constant abilityreallevelfield ABILITY_RLF_LIFE_HEALED = ConvertAbilityRealLevelField('Etq1') + constant abilityreallevelfield ABILITY_RLF_HEAL_INTERVAL = ConvertAbilityRealLevelField('Etq2') + constant abilityreallevelfield ABILITY_RLF_BUILDING_REDUCTION_ETQ3 = ConvertAbilityRealLevelField('Etq3') + constant abilityreallevelfield ABILITY_RLF_INITIAL_IMMUNITY_DURATION = ConvertAbilityRealLevelField('Etq4') + constant abilityreallevelfield ABILITY_RLF_MAX_LIFE_DRAINED_PER_SECOND_PERCENT = ConvertAbilityRealLevelField('Udd1') + constant abilityreallevelfield ABILITY_RLF_BUILDING_REDUCTION_UDD2 = ConvertAbilityRealLevelField('Udd2') + constant abilityreallevelfield ABILITY_RLF_ARMOR_DURATION = ConvertAbilityRealLevelField('Ufa1') + constant abilityreallevelfield ABILITY_RLF_ARMOR_BONUS_UFA2 = ConvertAbilityRealLevelField('Ufa2') + constant abilityreallevelfield ABILITY_RLF_AREA_OF_EFFECT_DAMAGE = ConvertAbilityRealLevelField('Ufn1') + constant abilityreallevelfield ABILITY_RLF_SPECIFIC_TARGET_DAMAGE_UFN2 = ConvertAbilityRealLevelField('Ufn2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_HFA1 = ConvertAbilityRealLevelField('Hfa1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_ESF1 = ConvertAbilityRealLevelField('Esf1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INTERVAL_ESF2 = ConvertAbilityRealLevelField('Esf2') + constant abilityreallevelfield ABILITY_RLF_BUILDING_REDUCTION_ESF3 = ConvertAbilityRealLevelField('Esf3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_PERCENT = ConvertAbilityRealLevelField('Ear1') + constant abilityreallevelfield ABILITY_RLF_DEFENSE_BONUS_HAV1 = ConvertAbilityRealLevelField('Hav1') + constant abilityreallevelfield ABILITY_RLF_HIT_POINT_BONUS = ConvertAbilityRealLevelField('Hav2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_HAV3 = ConvertAbilityRealLevelField('Hav3') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_HAV4 = ConvertAbilityRealLevelField('Hav4') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_BASH = ConvertAbilityRealLevelField('Hbh1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_MULTIPLIER_HBH2 = ConvertAbilityRealLevelField('Hbh2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_HBH3 = ConvertAbilityRealLevelField('Hbh3') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_MISS_HBH4 = ConvertAbilityRealLevelField('Hbh4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_HTB1 = ConvertAbilityRealLevelField('Htb1') + constant abilityreallevelfield ABILITY_RLF_AOE_DAMAGE = ConvertAbilityRealLevelField('Htc1') + constant abilityreallevelfield ABILITY_RLF_SPECIFIC_TARGET_DAMAGE_HTC2 = ConvertAbilityRealLevelField('Htc2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_HTC3 = ConvertAbilityRealLevelField('Htc3') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_HTC4 = ConvertAbilityRealLevelField('Htc4') + constant abilityreallevelfield ABILITY_RLF_ARMOR_BONUS_HAD1 = ConvertAbilityRealLevelField('Had1') + constant abilityreallevelfield ABILITY_RLF_AMOUNT_HEALED_DAMAGED_HHB1 = ConvertAbilityRealLevelField('Hhb1') + constant abilityreallevelfield ABILITY_RLF_EXTRA_DAMAGE_HCA1 = ConvertAbilityRealLevelField('Hca1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_HCA2 = ConvertAbilityRealLevelField('Hca2') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_HCA3 = ConvertAbilityRealLevelField('Hca3') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_OAE1 = ConvertAbilityRealLevelField('Oae1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_INCREASE_PERCENT_OAE2 = ConvertAbilityRealLevelField('Oae2') + constant abilityreallevelfield ABILITY_RLF_REINCARNATION_DELAY = ConvertAbilityRealLevelField('Ore1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_OSH1 = ConvertAbilityRealLevelField('Osh1') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_DAMAGE_OSH2 = ConvertAbilityRealLevelField('Osh2') + constant abilityreallevelfield ABILITY_RLF_DISTANCE_OSH3 = ConvertAbilityRealLevelField('Osh3') + constant abilityreallevelfield ABILITY_RLF_FINAL_AREA_OSH4 = ConvertAbilityRealLevelField('Osh4') + constant abilityreallevelfield ABILITY_RLF_GRAPHIC_DELAY_NFD1 = ConvertAbilityRealLevelField('Nfd1') + constant abilityreallevelfield ABILITY_RLF_GRAPHIC_DURATION_NFD2 = ConvertAbilityRealLevelField('Nfd2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_NFD3 = ConvertAbilityRealLevelField('Nfd3') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_AMS1 = ConvertAbilityRealLevelField('Ams1') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_AMS2 = ConvertAbilityRealLevelField('Ams2') + constant abilityreallevelfield ABILITY_RLF_AURA_DURATION = ConvertAbilityRealLevelField('Apl1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_APL2 = ConvertAbilityRealLevelField('Apl2') + constant abilityreallevelfield ABILITY_RLF_DURATION_OF_PLAGUE_WARD = ConvertAbilityRealLevelField('Apl3') + constant abilityreallevelfield ABILITY_RLF_AMOUNT_OF_HIT_POINTS_REGENERATED = ConvertAbilityRealLevelField('Oar1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_DAMAGE_INCREASE_AKB1 = ConvertAbilityRealLevelField('Akb1') + constant abilityreallevelfield ABILITY_RLF_MANA_LOSS_ADM1 = ConvertAbilityRealLevelField('Adm1') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_ADM2 = ConvertAbilityRealLevelField('Adm2') + constant abilityreallevelfield ABILITY_RLF_EXPANSION_AMOUNT = ConvertAbilityRealLevelField('Bli1') + constant abilityreallevelfield ABILITY_RLF_INTERVAL_DURATION_BGM2 = ConvertAbilityRealLevelField('Bgm2') + constant abilityreallevelfield ABILITY_RLF_RADIUS_OF_MINING_RING = ConvertAbilityRealLevelField('Bgm4') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_INCREASE_PERCENT_BLO1 = ConvertAbilityRealLevelField('Blo1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_BLO2 = ConvertAbilityRealLevelField('Blo2') + constant abilityreallevelfield ABILITY_RLF_SCALING_FACTOR = ConvertAbilityRealLevelField('Blo3') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_PER_SECOND_CAN1 = ConvertAbilityRealLevelField('Can1') + constant abilityreallevelfield ABILITY_RLF_MAX_HIT_POINTS = ConvertAbilityRealLevelField('Can2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_DEV2 = ConvertAbilityRealLevelField('Dev2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_UPDATE_FREQUENCY_CHD1 = ConvertAbilityRealLevelField('Chd1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_UPDATE_FREQUENCY_CHD2 = ConvertAbilityRealLevelField('Chd2') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_CHD3 = ConvertAbilityRealLevelField('Chd3') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_CRI1 = ConvertAbilityRealLevelField('Cri1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_CRI2 = ConvertAbilityRealLevelField('Cri2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_REDUCTION_CRI3 = ConvertAbilityRealLevelField('Cri3') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_MISS_CRS = ConvertAbilityRealLevelField('Crs1') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_RADIUS_DDA1 = ConvertAbilityRealLevelField('Dda1') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_AMOUNT_DDA2 = ConvertAbilityRealLevelField('Dda2') + constant abilityreallevelfield ABILITY_RLF_PARTIAL_DAMAGE_RADIUS = ConvertAbilityRealLevelField('Dda3') + constant abilityreallevelfield ABILITY_RLF_PARTIAL_DAMAGE_AMOUNT = ConvertAbilityRealLevelField('Dda4') + constant abilityreallevelfield ABILITY_RLF_BUILDING_DAMAGE_FACTOR_SDS1 = ConvertAbilityRealLevelField('Sds1') + constant abilityreallevelfield ABILITY_RLF_MAX_DAMAGE_UCO5 = ConvertAbilityRealLevelField('Uco5') + constant abilityreallevelfield ABILITY_RLF_MOVE_SPEED_BONUS_UCO6 = ConvertAbilityRealLevelField('Uco6') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_TAKEN_PERCENT_DEF1 = ConvertAbilityRealLevelField('Def1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_PERCENT_DEF2 = ConvertAbilityRealLevelField('Def2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_DEF3 = ConvertAbilityRealLevelField('Def3') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_DEF4 = ConvertAbilityRealLevelField('Def4') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_DEF5 = ConvertAbilityRealLevelField('Def5') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_DEFLECT = ConvertAbilityRealLevelField('Def6') + constant abilityreallevelfield ABILITY_RLF_DEFLECT_DAMAGE_TAKEN_PIERCING = ConvertAbilityRealLevelField('Def7') + constant abilityreallevelfield ABILITY_RLF_DEFLECT_DAMAGE_TAKEN_SPELLS = ConvertAbilityRealLevelField('Def8') + constant abilityreallevelfield ABILITY_RLF_RIP_DELAY = ConvertAbilityRealLevelField('Eat1') + constant abilityreallevelfield ABILITY_RLF_EAT_DELAY = ConvertAbilityRealLevelField('Eat2') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_GAINED_EAT3 = ConvertAbilityRealLevelField('Eat3') + constant abilityreallevelfield ABILITY_RLF_AIR_UNIT_LOWER_DURATION = ConvertAbilityRealLevelField('Ens1') + constant abilityreallevelfield ABILITY_RLF_AIR_UNIT_HEIGHT = ConvertAbilityRealLevelField('Ens2') + constant abilityreallevelfield ABILITY_RLF_MELEE_ATTACK_RANGE = ConvertAbilityRealLevelField('Ens3') + constant abilityreallevelfield ABILITY_RLF_INTERVAL_DURATION_EGM2 = ConvertAbilityRealLevelField('Egm2') + constant abilityreallevelfield ABILITY_RLF_EFFECT_DELAY_FLA2 = ConvertAbilityRealLevelField('Fla2') + constant abilityreallevelfield ABILITY_RLF_MINING_DURATION = ConvertAbilityRealLevelField('Gld2') + constant abilityreallevelfield ABILITY_RLF_RADIUS_OF_GRAVESTONES = ConvertAbilityRealLevelField('Gyd2') + constant abilityreallevelfield ABILITY_RLF_RADIUS_OF_CORPSES = ConvertAbilityRealLevelField('Gyd3') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_GAINED_HEA1 = ConvertAbilityRealLevelField('Hea1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INCREASE_PERCENT_INF1 = ConvertAbilityRealLevelField('Inf1') + constant abilityreallevelfield ABILITY_RLF_AUTOCAST_RANGE = ConvertAbilityRealLevelField('Inf3') + constant abilityreallevelfield ABILITY_RLF_LIFE_REGEN_RATE = ConvertAbilityRealLevelField('Inf4') + constant abilityreallevelfield ABILITY_RLF_GRAPHIC_DELAY_LIT1 = ConvertAbilityRealLevelField('Lit1') + constant abilityreallevelfield ABILITY_RLF_GRAPHIC_DURATION_LIT2 = ConvertAbilityRealLevelField('Lit2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_LSH1 = ConvertAbilityRealLevelField('Lsh1') + constant abilityreallevelfield ABILITY_RLF_MANA_GAINED = ConvertAbilityRealLevelField('Mbt1') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_GAINED_MBT2 = ConvertAbilityRealLevelField('Mbt2') + constant abilityreallevelfield ABILITY_RLF_AUTOCAST_REQUIREMENT = ConvertAbilityRealLevelField('Mbt3') + constant abilityreallevelfield ABILITY_RLF_WATER_HEIGHT = ConvertAbilityRealLevelField('Mbt4') + constant abilityreallevelfield ABILITY_RLF_ACTIVATION_DELAY_MIN1 = ConvertAbilityRealLevelField('Min1') + constant abilityreallevelfield ABILITY_RLF_INVISIBILITY_TRANSITION_TIME = ConvertAbilityRealLevelField('Min2') + constant abilityreallevelfield ABILITY_RLF_ACTIVATION_RADIUS = ConvertAbilityRealLevelField('Neu1') + constant abilityreallevelfield ABILITY_RLF_AMOUNT_REGENERATED = ConvertAbilityRealLevelField('Arm1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_POI1 = ConvertAbilityRealLevelField('Poi1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_POI2 = ConvertAbilityRealLevelField('Poi2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_POI3 = ConvertAbilityRealLevelField('Poi3') + constant abilityreallevelfield ABILITY_RLF_EXTRA_DAMAGE_POA1 = ConvertAbilityRealLevelField('Poa1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_POA2 = ConvertAbilityRealLevelField('Poa2') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_POA3 = ConvertAbilityRealLevelField('Poa3') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_POA4 = ConvertAbilityRealLevelField('Poa4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_AMPLIFICATION = ConvertAbilityRealLevelField('Pos2') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_STOMP_PERCENT = ConvertAbilityRealLevelField('War1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_WAR2 = ConvertAbilityRealLevelField('War2') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_RADIUS_WAR3 = ConvertAbilityRealLevelField('War3') + constant abilityreallevelfield ABILITY_RLF_HALF_DAMAGE_RADIUS_WAR4 = ConvertAbilityRealLevelField('War4') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_PRG3 = ConvertAbilityRealLevelField('Prg3') + constant abilityreallevelfield ABILITY_RLF_UNIT_PAUSE_DURATION = ConvertAbilityRealLevelField('Prg4') + constant abilityreallevelfield ABILITY_RLF_HERO_PAUSE_DURATION = ConvertAbilityRealLevelField('Prg5') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_GAINED_REJ1 = ConvertAbilityRealLevelField('Rej1') + constant abilityreallevelfield ABILITY_RLF_MANA_POINTS_GAINED_REJ2 = ConvertAbilityRealLevelField('Rej2') + constant abilityreallevelfield ABILITY_RLF_MINIMUM_LIFE_REQUIRED = ConvertAbilityRealLevelField('Rpb3') + constant abilityreallevelfield ABILITY_RLF_MINIMUM_MANA_REQUIRED = ConvertAbilityRealLevelField('Rpb4') + constant abilityreallevelfield ABILITY_RLF_REPAIR_COST_RATIO = ConvertAbilityRealLevelField('Rep1') + constant abilityreallevelfield ABILITY_RLF_REPAIR_TIME_RATIO = ConvertAbilityRealLevelField('Rep2') + constant abilityreallevelfield ABILITY_RLF_POWERBUILD_COST = ConvertAbilityRealLevelField('Rep3') + constant abilityreallevelfield ABILITY_RLF_POWERBUILD_RATE = ConvertAbilityRealLevelField('Rep4') + constant abilityreallevelfield ABILITY_RLF_NAVAL_RANGE_BONUS = ConvertAbilityRealLevelField('Rep5') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INCREASE_PERCENT_ROA1 = ConvertAbilityRealLevelField('Roa1') + constant abilityreallevelfield ABILITY_RLF_LIFE_REGENERATION_RATE = ConvertAbilityRealLevelField('Roa3') + constant abilityreallevelfield ABILITY_RLF_MANA_REGEN = ConvertAbilityRealLevelField('Roa4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INCREASE = ConvertAbilityRealLevelField('Nbr1') + constant abilityreallevelfield ABILITY_RLF_SALVAGE_COST_RATIO = ConvertAbilityRealLevelField('Sal1') + constant abilityreallevelfield ABILITY_RLF_IN_FLIGHT_SIGHT_RADIUS = ConvertAbilityRealLevelField('Esn1') + constant abilityreallevelfield ABILITY_RLF_HOVERING_SIGHT_RADIUS = ConvertAbilityRealLevelField('Esn2') + constant abilityreallevelfield ABILITY_RLF_HOVERING_HEIGHT = ConvertAbilityRealLevelField('Esn3') + constant abilityreallevelfield ABILITY_RLF_DURATION_OF_OWLS = ConvertAbilityRealLevelField('Esn5') + constant abilityreallevelfield ABILITY_RLF_FADE_DURATION = ConvertAbilityRealLevelField('Shm1') + constant abilityreallevelfield ABILITY_RLF_DAY_NIGHT_DURATION = ConvertAbilityRealLevelField('Shm2') + constant abilityreallevelfield ABILITY_RLF_ACTION_DURATION = ConvertAbilityRealLevelField('Shm3') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_SLO1 = ConvertAbilityRealLevelField('Slo1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_SLO2 = ConvertAbilityRealLevelField('Slo2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_SPO1 = ConvertAbilityRealLevelField('Spo1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_SPO2 = ConvertAbilityRealLevelField('Spo2') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_SPO3 = ConvertAbilityRealLevelField('Spo3') + constant abilityreallevelfield ABILITY_RLF_ACTIVATION_DELAY_STA1 = ConvertAbilityRealLevelField('Sta1') + constant abilityreallevelfield ABILITY_RLF_DETECTION_RADIUS_STA2 = ConvertAbilityRealLevelField('Sta2') + constant abilityreallevelfield ABILITY_RLF_DETONATION_RADIUS = ConvertAbilityRealLevelField('Sta3') + constant abilityreallevelfield ABILITY_RLF_STUN_DURATION_STA4 = ConvertAbilityRealLevelField('Sta4') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_BONUS_PERCENT = ConvertAbilityRealLevelField('Uhf1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_UHF2 = ConvertAbilityRealLevelField('Uhf2') + constant abilityreallevelfield ABILITY_RLF_LUMBER_PER_INTERVAL = ConvertAbilityRealLevelField('Wha1') + constant abilityreallevelfield ABILITY_RLF_ART_ATTACHMENT_HEIGHT = ConvertAbilityRealLevelField('Wha3') + constant abilityreallevelfield ABILITY_RLF_TELEPORT_AREA_WIDTH = ConvertAbilityRealLevelField('Wrp1') + constant abilityreallevelfield ABILITY_RLF_TELEPORT_AREA_HEIGHT = ConvertAbilityRealLevelField('Wrp2') + constant abilityreallevelfield ABILITY_RLF_LIFE_STOLEN_PER_ATTACK = ConvertAbilityRealLevelField('Ivam') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_IDAM = ConvertAbilityRealLevelField('Idam') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_HIT_UNITS_PERCENT = ConvertAbilityRealLevelField('Iob2') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_HIT_HEROS_PERCENT = ConvertAbilityRealLevelField('Iob3') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_HIT_SUMMONS_PERCENT = ConvertAbilityRealLevelField('Iob4') + constant abilityreallevelfield ABILITY_RLF_DELAY_FOR_TARGET_EFFECT = ConvertAbilityRealLevelField('Idel') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_PERCENT_OF_NORMAL = ConvertAbilityRealLevelField('Iild') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RECEIVED_MULTIPLIER = ConvertAbilityRealLevelField('Iilw') + constant abilityreallevelfield ABILITY_RLF_MANA_REGENERATION_BONUS_AS_FRACTION_OF_NORMAL = ConvertAbilityRealLevelField('Imrp') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_ISPI = ConvertAbilityRealLevelField('Ispi') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_IDPS = ConvertAbilityRealLevelField('Idps') + constant abilityreallevelfield ABILITY_RLF_ATTACK_DAMAGE_INCREASE_CAC1 = ConvertAbilityRealLevelField('Cac1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_COR1 = ConvertAbilityRealLevelField('Cor1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1 = ConvertAbilityRealLevelField('Isx1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_WRS1 = ConvertAbilityRealLevelField('Wrs1') + constant abilityreallevelfield ABILITY_RLF_TERRAIN_DEFORMATION_AMPLITUDE = ConvertAbilityRealLevelField('Wrs2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_CTC1 = ConvertAbilityRealLevelField('Ctc1') + constant abilityreallevelfield ABILITY_RLF_EXTRA_DAMAGE_TO_TARGET = ConvertAbilityRealLevelField('Ctc2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_CTC3 = ConvertAbilityRealLevelField('Ctc3') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_CTC4 = ConvertAbilityRealLevelField('Ctc4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_CTB1 = ConvertAbilityRealLevelField('Ctb1') + constant abilityreallevelfield ABILITY_RLF_CASTING_DELAY_SECONDS = ConvertAbilityRealLevelField('Uds2') + constant abilityreallevelfield ABILITY_RLF_MANA_LOSS_PER_UNIT_DTN1 = ConvertAbilityRealLevelField('Dtn1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_TO_SUMMONED_UNITS_DTN2 = ConvertAbilityRealLevelField('Dtn2') + constant abilityreallevelfield ABILITY_RLF_TRANSITION_TIME_SECONDS = ConvertAbilityRealLevelField('Ivs1') + constant abilityreallevelfield ABILITY_RLF_MANA_DRAINED_PER_SECOND_NMR1 = ConvertAbilityRealLevelField('Nmr1') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_REDUCE_DAMAGE_PERCENT = ConvertAbilityRealLevelField('Ssk1') + constant abilityreallevelfield ABILITY_RLF_MINIMUM_DAMAGE = ConvertAbilityRealLevelField('Ssk2') + constant abilityreallevelfield ABILITY_RLF_IGNORED_DAMAGE = ConvertAbilityRealLevelField('Ssk3') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_DEALT = ConvertAbilityRealLevelField('Hfs1') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_INTERVAL = ConvertAbilityRealLevelField('Hfs2') + constant abilityreallevelfield ABILITY_RLF_HALF_DAMAGE_DEALT = ConvertAbilityRealLevelField('Hfs3') + constant abilityreallevelfield ABILITY_RLF_HALF_DAMAGE_INTERVAL = ConvertAbilityRealLevelField('Hfs4') + constant abilityreallevelfield ABILITY_RLF_BUILDING_REDUCTION_HFS5 = ConvertAbilityRealLevelField('Hfs5') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_DAMAGE_HFS6 = ConvertAbilityRealLevelField('Hfs6') + constant abilityreallevelfield ABILITY_RLF_MANA_PER_HIT_POINT = ConvertAbilityRealLevelField('Nms1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_ABSORBED_PERCENT = ConvertAbilityRealLevelField('Nms2') + constant abilityreallevelfield ABILITY_RLF_WAVE_DISTANCE = ConvertAbilityRealLevelField('Uim1') + constant abilityreallevelfield ABILITY_RLF_WAVE_TIME_SECONDS = ConvertAbilityRealLevelField('Uim2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DEALT_UIM3 = ConvertAbilityRealLevelField('Uim3') + constant abilityreallevelfield ABILITY_RLF_AIR_TIME_SECONDS_UIM4 = ConvertAbilityRealLevelField('Uim4') + constant abilityreallevelfield ABILITY_RLF_UNIT_RELEASE_INTERVAL_SECONDS = ConvertAbilityRealLevelField('Uls2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RETURN_FACTOR = ConvertAbilityRealLevelField('Uls4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RETURN_THRESHOLD = ConvertAbilityRealLevelField('Uls5') + constant abilityreallevelfield ABILITY_RLF_RETURNED_DAMAGE_FACTOR = ConvertAbilityRealLevelField('Uts1') + constant abilityreallevelfield ABILITY_RLF_RECEIVED_DAMAGE_FACTOR = ConvertAbilityRealLevelField('Uts2') + constant abilityreallevelfield ABILITY_RLF_DEFENSE_BONUS_UTS3 = ConvertAbilityRealLevelField('Uts3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_NBA1 = ConvertAbilityRealLevelField('Nba1') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DURATION_SECONDS_NBA3 = ConvertAbilityRealLevelField('Nba3') + constant abilityreallevelfield ABILITY_RLF_MANA_PER_SUMMONED_HITPOINT = ConvertAbilityRealLevelField('Cmg2') + constant abilityreallevelfield ABILITY_RLF_CHARGE_FOR_CURRENT_LIFE = ConvertAbilityRealLevelField('Cmg3') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_DRAINED = ConvertAbilityRealLevelField('Ndr1') + constant abilityreallevelfield ABILITY_RLF_MANA_POINTS_DRAINED = ConvertAbilityRealLevelField('Ndr2') + constant abilityreallevelfield ABILITY_RLF_DRAIN_INTERVAL_SECONDS = ConvertAbilityRealLevelField('Ndr3') + constant abilityreallevelfield ABILITY_RLF_LIFE_TRANSFERRED_PER_SECOND = ConvertAbilityRealLevelField('Ndr4') + constant abilityreallevelfield ABILITY_RLF_MANA_TRANSFERRED_PER_SECOND = ConvertAbilityRealLevelField('Ndr5') + constant abilityreallevelfield ABILITY_RLF_BONUS_LIFE_FACTOR = ConvertAbilityRealLevelField('Ndr6') + constant abilityreallevelfield ABILITY_RLF_BONUS_LIFE_DECAY = ConvertAbilityRealLevelField('Ndr7') + constant abilityreallevelfield ABILITY_RLF_BONUS_MANA_FACTOR = ConvertAbilityRealLevelField('Ndr8') + constant abilityreallevelfield ABILITY_RLF_BONUS_MANA_DECAY = ConvertAbilityRealLevelField('Ndr9') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_MISS_PERCENT = ConvertAbilityRealLevelField('Nsi2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_MODIFIER = ConvertAbilityRealLevelField('Nsi3') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_MODIFIER = ConvertAbilityRealLevelField('Nsi4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_TDG1 = ConvertAbilityRealLevelField('Tdg1') + constant abilityreallevelfield ABILITY_RLF_MEDIUM_DAMAGE_RADIUS_TDG2 = ConvertAbilityRealLevelField('Tdg2') + constant abilityreallevelfield ABILITY_RLF_MEDIUM_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField('Tdg3') + constant abilityreallevelfield ABILITY_RLF_SMALL_DAMAGE_RADIUS_TDG4 = ConvertAbilityRealLevelField('Tdg4') + constant abilityreallevelfield ABILITY_RLF_SMALL_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField('Tdg5') + constant abilityreallevelfield ABILITY_RLF_AIR_TIME_SECONDS_TSP1 = ConvertAbilityRealLevelField('Tsp1') + constant abilityreallevelfield ABILITY_RLF_MINIMUM_HIT_INTERVAL_SECONDS = ConvertAbilityRealLevelField('Tsp2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_NBF5 = ConvertAbilityRealLevelField('Nbf5') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_RANGE = ConvertAbilityRealLevelField('Ebl1') + constant abilityreallevelfield ABILITY_RLF_MINIMUM_RANGE = ConvertAbilityRealLevelField('Ebl2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_TARGET_EFK1 = ConvertAbilityRealLevelField('Efk1') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_TOTAL_DAMAGE = ConvertAbilityRealLevelField('Efk2') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_SPEED_ADJUSTMENT = ConvertAbilityRealLevelField('Efk4') + constant abilityreallevelfield ABILITY_RLF_DECAYING_DAMAGE = ConvertAbilityRealLevelField('Esh1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_FACTOR_ESH2 = ConvertAbilityRealLevelField('Esh2') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_FACTOR_ESH3 = ConvertAbilityRealLevelField('Esh3') + constant abilityreallevelfield ABILITY_RLF_DECAY_POWER = ConvertAbilityRealLevelField('Esh4') + constant abilityreallevelfield ABILITY_RLF_INITIAL_DAMAGE_ESH5 = ConvertAbilityRealLevelField('Esh5') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_LIFE_ABSORBED = ConvertAbilityRealLevelField('abs1') + constant abilityreallevelfield ABILITY_RLF_MAXIMUM_MANA_ABSORBED = ConvertAbilityRealLevelField('abs2') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_INCREASE_BSK1 = ConvertAbilityRealLevelField('bsk1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_INCREASE_BSK2 = ConvertAbilityRealLevelField('bsk2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_TAKEN_INCREASE = ConvertAbilityRealLevelField('bsk3') + constant abilityreallevelfield ABILITY_RLF_LIFE_PER_UNIT = ConvertAbilityRealLevelField('dvm1') + constant abilityreallevelfield ABILITY_RLF_MANA_PER_UNIT = ConvertAbilityRealLevelField('dvm2') + constant abilityreallevelfield ABILITY_RLF_LIFE_PER_BUFF = ConvertAbilityRealLevelField('dvm3') + constant abilityreallevelfield ABILITY_RLF_MANA_PER_BUFF = ConvertAbilityRealLevelField('dvm4') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_DVM5 = ConvertAbilityRealLevelField('dvm5') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_FAK1 = ConvertAbilityRealLevelField('fak1') + constant abilityreallevelfield ABILITY_RLF_MEDIUM_DAMAGE_FACTOR_FAK2 = ConvertAbilityRealLevelField('fak2') + constant abilityreallevelfield ABILITY_RLF_SMALL_DAMAGE_FACTOR_FAK3 = ConvertAbilityRealLevelField('fak3') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_RADIUS_FAK4 = ConvertAbilityRealLevelField('fak4') + constant abilityreallevelfield ABILITY_RLF_HALF_DAMAGE_RADIUS_FAK5 = ConvertAbilityRealLevelField('fak5') + constant abilityreallevelfield ABILITY_RLF_EXTRA_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField('liq1') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_LIQ2 = ConvertAbilityRealLevelField('liq2') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_LIQ3 = ConvertAbilityRealLevelField('liq3') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_FACTOR = ConvertAbilityRealLevelField('mim1') + constant abilityreallevelfield ABILITY_RLF_UNIT_DAMAGE_PER_MANA_POINT = ConvertAbilityRealLevelField('mfl1') + constant abilityreallevelfield ABILITY_RLF_HERO_DAMAGE_PER_MANA_POINT = ConvertAbilityRealLevelField('mfl2') + constant abilityreallevelfield ABILITY_RLF_UNIT_MAXIMUM_DAMAGE = ConvertAbilityRealLevelField('mfl3') + constant abilityreallevelfield ABILITY_RLF_HERO_MAXIMUM_DAMAGE = ConvertAbilityRealLevelField('mfl4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_COOLDOWN = ConvertAbilityRealLevelField('mfl5') + constant abilityreallevelfield ABILITY_RLF_DISTRIBUTED_DAMAGE_FACTOR_SPL1 = ConvertAbilityRealLevelField('spl1') + constant abilityreallevelfield ABILITY_RLF_LIFE_REGENERATED = ConvertAbilityRealLevelField('irl1') + constant abilityreallevelfield ABILITY_RLF_MANA_REGENERATED = ConvertAbilityRealLevelField('irl2') + constant abilityreallevelfield ABILITY_RLF_MANA_LOSS_PER_UNIT_IDC1 = ConvertAbilityRealLevelField('idc1') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DAMAGE_IDC2 = ConvertAbilityRealLevelField('idc2') + constant abilityreallevelfield ABILITY_RLF_ACTIVATION_DELAY_IMO2 = ConvertAbilityRealLevelField('imo2') + constant abilityreallevelfield ABILITY_RLF_LURE_INTERVAL_SECONDS = ConvertAbilityRealLevelField('imo3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_ISR1 = ConvertAbilityRealLevelField('isr1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_REDUCTION_ISR2 = ConvertAbilityRealLevelField('isr2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_IPV1 = ConvertAbilityRealLevelField('ipv1') + constant abilityreallevelfield ABILITY_RLF_LIFE_STEAL_AMOUNT = ConvertAbilityRealLevelField('ipv2') + constant abilityreallevelfield ABILITY_RLF_LIFE_RESTORED_FACTOR = ConvertAbilityRealLevelField('ast1') + constant abilityreallevelfield ABILITY_RLF_MANA_RESTORED_FACTOR = ConvertAbilityRealLevelField('ast2') + constant abilityreallevelfield ABILITY_RLF_ATTACH_DELAY = ConvertAbilityRealLevelField('gra1') + constant abilityreallevelfield ABILITY_RLF_REMOVE_DELAY = ConvertAbilityRealLevelField('gra2') + constant abilityreallevelfield ABILITY_RLF_HERO_REGENERATION_DELAY = ConvertAbilityRealLevelField('Nsa2') + constant abilityreallevelfield ABILITY_RLF_UNIT_REGENERATION_DELAY = ConvertAbilityRealLevelField('Nsa3') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_NSA4 = ConvertAbilityRealLevelField('Nsa4') + constant abilityreallevelfield ABILITY_RLF_HIT_POINTS_PER_SECOND_NSA5 = ConvertAbilityRealLevelField('Nsa5') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_TO_SUMMONED_UNITS_IXS1 = ConvertAbilityRealLevelField('Ixs1') + constant abilityreallevelfield ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_IXS2 = ConvertAbilityRealLevelField('Ixs2') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DURATION = ConvertAbilityRealLevelField('Npa6') + constant abilityreallevelfield ABILITY_RLF_SHIELD_COOLDOWN_TIME = ConvertAbilityRealLevelField('Nse1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_NDO1 = ConvertAbilityRealLevelField('Ndo1') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_UNIT_DURATION_SECONDS_NDO3 = ConvertAbilityRealLevelField('Ndo3') + constant abilityreallevelfield ABILITY_RLF_MEDIUM_DAMAGE_RADIUS_FLK1 = ConvertAbilityRealLevelField('flk1') + constant abilityreallevelfield ABILITY_RLF_SMALL_DAMAGE_RADIUS_FLK2 = ConvertAbilityRealLevelField('flk2') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_AMOUNT_FLK3 = ConvertAbilityRealLevelField('flk3') + constant abilityreallevelfield ABILITY_RLF_MEDIUM_DAMAGE_AMOUNT = ConvertAbilityRealLevelField('flk4') + constant abilityreallevelfield ABILITY_RLF_SMALL_DAMAGE_AMOUNT = ConvertAbilityRealLevelField('flk5') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_HBN1 = ConvertAbilityRealLevelField('Hbn1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_HBN2 = ConvertAbilityRealLevelField('Hbn2') + constant abilityreallevelfield ABILITY_RLF_MAX_MANA_DRAINED_UNITS = ConvertAbilityRealLevelField('fbk1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RATIO_UNITS_PERCENT = ConvertAbilityRealLevelField('fbk2') + constant abilityreallevelfield ABILITY_RLF_MAX_MANA_DRAINED_HEROS = ConvertAbilityRealLevelField('fbk3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RATIO_HEROS_PERCENT = ConvertAbilityRealLevelField('fbk4') + constant abilityreallevelfield ABILITY_RLF_SUMMONED_DAMAGE = ConvertAbilityRealLevelField('fbk5') + constant abilityreallevelfield ABILITY_RLF_DISTRIBUTED_DAMAGE_FACTOR_NCA1 = ConvertAbilityRealLevelField('nca1') + constant abilityreallevelfield ABILITY_RLF_INITIAL_DAMAGE_PXF1 = ConvertAbilityRealLevelField('pxf1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_PXF2 = ConvertAbilityRealLevelField('pxf2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PER_SECOND_MLS1 = ConvertAbilityRealLevelField('mls1') + constant abilityreallevelfield ABILITY_RLF_BEAST_COLLISION_RADIUS = ConvertAbilityRealLevelField('Nst2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_AMOUNT_NST3 = ConvertAbilityRealLevelField('Nst3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_RADIUS = ConvertAbilityRealLevelField('Nst4') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_DELAY = ConvertAbilityRealLevelField('Nst5') + constant abilityreallevelfield ABILITY_RLF_FOLLOW_THROUGH_TIME = ConvertAbilityRealLevelField('Ncl1') + constant abilityreallevelfield ABILITY_RLF_ART_DURATION = ConvertAbilityRealLevelField('Ncl4') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_NAB1 = ConvertAbilityRealLevelField('Nab1') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_NAB2 = ConvertAbilityRealLevelField('Nab2') + constant abilityreallevelfield ABILITY_RLF_PRIMARY_DAMAGE = ConvertAbilityRealLevelField('Nab4') + constant abilityreallevelfield ABILITY_RLF_SECONDARY_DAMAGE = ConvertAbilityRealLevelField('Nab5') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INTERVAL_NAB6 = ConvertAbilityRealLevelField('Nab6') + constant abilityreallevelfield ABILITY_RLF_GOLD_COST_FACTOR = ConvertAbilityRealLevelField('Ntm1') + constant abilityreallevelfield ABILITY_RLF_LUMBER_COST_FACTOR = ConvertAbilityRealLevelField('Ntm2') + constant abilityreallevelfield ABILITY_RLF_MOVE_SPEED_BONUS_NEG1 = ConvertAbilityRealLevelField('Neg1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_BONUS_NEG2 = ConvertAbilityRealLevelField('Neg2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_AMOUNT_NCS1 = ConvertAbilityRealLevelField('Ncs1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_INTERVAL_NCS2 = ConvertAbilityRealLevelField('Ncs2') + constant abilityreallevelfield ABILITY_RLF_MAX_DAMAGE_NCS4 = ConvertAbilityRealLevelField('Ncs4') + constant abilityreallevelfield ABILITY_RLF_BUILDING_DAMAGE_FACTOR_NCS5 = ConvertAbilityRealLevelField('Ncs5') + constant abilityreallevelfield ABILITY_RLF_EFFECT_DURATION = ConvertAbilityRealLevelField('Ncs6') + constant abilityreallevelfield ABILITY_RLF_SPAWN_INTERVAL_NSY1 = ConvertAbilityRealLevelField('Nsy1') + constant abilityreallevelfield ABILITY_RLF_SPAWN_UNIT_DURATION = ConvertAbilityRealLevelField('Nsy3') + constant abilityreallevelfield ABILITY_RLF_SPAWN_UNIT_OFFSET = ConvertAbilityRealLevelField('Nsy4') + constant abilityreallevelfield ABILITY_RLF_LEASH_RANGE_NSY5 = ConvertAbilityRealLevelField('Nsy5') + constant abilityreallevelfield ABILITY_RLF_SPAWN_INTERVAL_NFY1 = ConvertAbilityRealLevelField('Nfy1') + constant abilityreallevelfield ABILITY_RLF_LEASH_RANGE_NFY2 = ConvertAbilityRealLevelField('Nfy2') + constant abilityreallevelfield ABILITY_RLF_CHANCE_TO_DEMOLISH = ConvertAbilityRealLevelField('Nde1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_MULTIPLIER_BUILDINGS = ConvertAbilityRealLevelField('Nde2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_MULTIPLIER_UNITS = ConvertAbilityRealLevelField('Nde3') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_MULTIPLIER_HEROES = ConvertAbilityRealLevelField('Nde4') + constant abilityreallevelfield ABILITY_RLF_BONUS_DAMAGE_MULTIPLIER = ConvertAbilityRealLevelField('Nic1') + constant abilityreallevelfield ABILITY_RLF_DEATH_DAMAGE_FULL_AMOUNT = ConvertAbilityRealLevelField('Nic2') + constant abilityreallevelfield ABILITY_RLF_DEATH_DAMAGE_FULL_AREA = ConvertAbilityRealLevelField('Nic3') + constant abilityreallevelfield ABILITY_RLF_DEATH_DAMAGE_HALF_AMOUNT = ConvertAbilityRealLevelField('Nic4') + constant abilityreallevelfield ABILITY_RLF_DEATH_DAMAGE_HALF_AREA = ConvertAbilityRealLevelField('Nic5') + constant abilityreallevelfield ABILITY_RLF_DEATH_DAMAGE_DELAY = ConvertAbilityRealLevelField('Nic6') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_AMOUNT_NSO1 = ConvertAbilityRealLevelField('Nso1') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PERIOD = ConvertAbilityRealLevelField('Nso2') + constant abilityreallevelfield ABILITY_RLF_DAMAGE_PENALTY = ConvertAbilityRealLevelField('Nso3') + constant abilityreallevelfield ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_NSO4 = ConvertAbilityRealLevelField('Nso4') + constant abilityreallevelfield ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_NSO5 = ConvertAbilityRealLevelField('Nso5') + constant abilityreallevelfield ABILITY_RLF_SPLIT_DELAY = ConvertAbilityRealLevelField('Nlm2') + constant abilityreallevelfield ABILITY_RLF_MAX_HITPOINT_FACTOR = ConvertAbilityRealLevelField('Nlm4') + constant abilityreallevelfield ABILITY_RLF_LIFE_DURATION_SPLIT_BONUS = ConvertAbilityRealLevelField('Nlm5') + constant abilityreallevelfield ABILITY_RLF_WAVE_INTERVAL = ConvertAbilityRealLevelField('Nvc3') + constant abilityreallevelfield ABILITY_RLF_BUILDING_DAMAGE_FACTOR_NVC4 = ConvertAbilityRealLevelField('Nvc4') + constant abilityreallevelfield ABILITY_RLF_FULL_DAMAGE_AMOUNT_NVC5 = ConvertAbilityRealLevelField('Nvc5') + constant abilityreallevelfield ABILITY_RLF_HALF_DAMAGE_FACTOR = ConvertAbilityRealLevelField('Nvc6') + constant abilityreallevelfield ABILITY_RLF_INTERVAL_BETWEEN_PULSES = ConvertAbilityRealLevelField('Tau5') + + constant abilitybooleanlevelfield ABILITY_BLF_PERCENT_BONUS_HAB2 = ConvertAbilityBooleanLevelField('Hab2') + constant abilitybooleanlevelfield ABILITY_BLF_USE_TELEPORT_CLUSTERING_HMT3 = ConvertAbilityBooleanLevelField('Hmt3') + constant abilitybooleanlevelfield ABILITY_BLF_NEVER_MISS_OCR5 = ConvertAbilityBooleanLevelField('Ocr5') + constant abilitybooleanlevelfield ABILITY_BLF_EXCLUDE_ITEM_DAMAGE = ConvertAbilityBooleanLevelField('Ocr6') + constant abilitybooleanlevelfield ABILITY_BLF_BACKSTAB_DAMAGE = ConvertAbilityBooleanLevelField('Owk4') + constant abilitybooleanlevelfield ABILITY_BLF_INHERIT_UPGRADES_UAN3 = ConvertAbilityBooleanLevelField('Uan3') + constant abilitybooleanlevelfield ABILITY_BLF_MANA_CONVERSION_AS_PERCENT = ConvertAbilityBooleanLevelField('Udp3') + constant abilitybooleanlevelfield ABILITY_BLF_LIFE_CONVERSION_AS_PERCENT = ConvertAbilityBooleanLevelField('Udp4') + constant abilitybooleanlevelfield ABILITY_BLF_LEAVE_TARGET_ALIVE = ConvertAbilityBooleanLevelField('Udp5') + constant abilitybooleanlevelfield ABILITY_BLF_PERCENT_BONUS_UAU3 = ConvertAbilityBooleanLevelField('Uau3') + constant abilitybooleanlevelfield ABILITY_BLF_DAMAGE_IS_PERCENT_RECEIVED = ConvertAbilityBooleanLevelField('Eah2') + constant abilitybooleanlevelfield ABILITY_BLF_MELEE_BONUS = ConvertAbilityBooleanLevelField('Ear2') + constant abilitybooleanlevelfield ABILITY_BLF_RANGED_BONUS = ConvertAbilityBooleanLevelField('Ear3') + constant abilitybooleanlevelfield ABILITY_BLF_FLAT_BONUS = ConvertAbilityBooleanLevelField('Ear4') + constant abilitybooleanlevelfield ABILITY_BLF_NEVER_MISS_HBH5 = ConvertAbilityBooleanLevelField('Hbh5') + constant abilitybooleanlevelfield ABILITY_BLF_PERCENT_BONUS_HAD2 = ConvertAbilityBooleanLevelField('Had2') + constant abilitybooleanlevelfield ABILITY_BLF_CAN_DEACTIVATE = ConvertAbilityBooleanLevelField('Hds1') + constant abilitybooleanlevelfield ABILITY_BLF_RAISED_UNITS_ARE_INVULNERABLE = ConvertAbilityBooleanLevelField('Hre2') + constant abilitybooleanlevelfield ABILITY_BLF_PERCENTAGE_OAR2 = ConvertAbilityBooleanLevelField('Oar2') + constant abilitybooleanlevelfield ABILITY_BLF_SUMMON_BUSY_UNITS = ConvertAbilityBooleanLevelField('Btl2') + constant abilitybooleanlevelfield ABILITY_BLF_CREATES_BLIGHT = ConvertAbilityBooleanLevelField('Bli2') + constant abilitybooleanlevelfield ABILITY_BLF_EXPLODES_ON_DEATH = ConvertAbilityBooleanLevelField('Sds6') + constant abilitybooleanlevelfield ABILITY_BLF_ALWAYS_AUTOCAST_FAE2 = ConvertAbilityBooleanLevelField('Fae2') + constant abilitybooleanlevelfield ABILITY_BLF_REGENERATE_ONLY_AT_NIGHT = ConvertAbilityBooleanLevelField('Mbt5') + constant abilitybooleanlevelfield ABILITY_BLF_SHOW_SELECT_UNIT_BUTTON = ConvertAbilityBooleanLevelField('Neu3') + constant abilitybooleanlevelfield ABILITY_BLF_SHOW_UNIT_INDICATOR = ConvertAbilityBooleanLevelField('Neu4') + constant abilitybooleanlevelfield ABILITY_BLF_CHARGE_OWNING_PLAYER = ConvertAbilityBooleanLevelField('Ans6') + constant abilitybooleanlevelfield ABILITY_BLF_PERCENTAGE_ARM2 = ConvertAbilityBooleanLevelField('Arm2') + constant abilitybooleanlevelfield ABILITY_BLF_TARGET_IS_INVULNERABLE = ConvertAbilityBooleanLevelField('Pos3') + constant abilitybooleanlevelfield ABILITY_BLF_TARGET_IS_MAGIC_IMMUNE = ConvertAbilityBooleanLevelField('Pos4') + constant abilitybooleanlevelfield ABILITY_BLF_KILL_ON_CASTER_DEATH = ConvertAbilityBooleanLevelField('Ucb6') + constant abilitybooleanlevelfield ABILITY_BLF_NO_TARGET_REQUIRED_REJ4 = ConvertAbilityBooleanLevelField('Rej4') + constant abilitybooleanlevelfield ABILITY_BLF_ACCEPTS_GOLD = ConvertAbilityBooleanLevelField('Rtn1') + constant abilitybooleanlevelfield ABILITY_BLF_ACCEPTS_LUMBER = ConvertAbilityBooleanLevelField('Rtn2') + constant abilitybooleanlevelfield ABILITY_BLF_PREFER_HOSTILES_ROA5 = ConvertAbilityBooleanLevelField('Roa5') + constant abilitybooleanlevelfield ABILITY_BLF_PREFER_FRIENDLIES_ROA6 = ConvertAbilityBooleanLevelField('Roa6') + constant abilitybooleanlevelfield ABILITY_BLF_ROOTED_TURNING = ConvertAbilityBooleanLevelField('Roo3') + constant abilitybooleanlevelfield ABILITY_BLF_ALWAYS_AUTOCAST_SLO3 = ConvertAbilityBooleanLevelField('Slo3') + constant abilitybooleanlevelfield ABILITY_BLF_HIDE_BUTTON = ConvertAbilityBooleanLevelField('Ihid') + constant abilitybooleanlevelfield ABILITY_BLF_USE_TELEPORT_CLUSTERING_ITP2 = ConvertAbilityBooleanLevelField('Itp2') + constant abilitybooleanlevelfield ABILITY_BLF_IMMUNE_TO_MORPH_EFFECTS = ConvertAbilityBooleanLevelField('Eth1') + constant abilitybooleanlevelfield ABILITY_BLF_DOES_NOT_BLOCK_BUILDINGS = ConvertAbilityBooleanLevelField('Eth2') + constant abilitybooleanlevelfield ABILITY_BLF_AUTO_ACQUIRE_ATTACK_TARGETS = ConvertAbilityBooleanLevelField('Gho1') + constant abilitybooleanlevelfield ABILITY_BLF_IMMUNE_TO_MORPH_EFFECTS_GHO2 = ConvertAbilityBooleanLevelField('Gho2') + constant abilitybooleanlevelfield ABILITY_BLF_DO_NOT_BLOCK_BUILDINGS = ConvertAbilityBooleanLevelField('Gho3') + constant abilitybooleanlevelfield ABILITY_BLF_INCLUDE_RANGED_DAMAGE = ConvertAbilityBooleanLevelField('Ssk4') + constant abilitybooleanlevelfield ABILITY_BLF_INCLUDE_MELEE_DAMAGE = ConvertAbilityBooleanLevelField('Ssk5') + constant abilitybooleanlevelfield ABILITY_BLF_MOVE_TO_PARTNER = ConvertAbilityBooleanLevelField('coa2') + constant abilitybooleanlevelfield ABILITY_BLF_CAN_BE_DISPELLED = ConvertAbilityBooleanLevelField('cyc1') + constant abilitybooleanlevelfield ABILITY_BLF_IGNORE_FRIENDLY_BUFFS = ConvertAbilityBooleanLevelField('dvm6') + constant abilitybooleanlevelfield ABILITY_BLF_DROP_ITEMS_ON_DEATH = ConvertAbilityBooleanLevelField('inv2') + constant abilitybooleanlevelfield ABILITY_BLF_CAN_USE_ITEMS = ConvertAbilityBooleanLevelField('inv3') + constant abilitybooleanlevelfield ABILITY_BLF_CAN_GET_ITEMS = ConvertAbilityBooleanLevelField('inv4') + constant abilitybooleanlevelfield ABILITY_BLF_CAN_DROP_ITEMS = ConvertAbilityBooleanLevelField('inv5') + constant abilitybooleanlevelfield ABILITY_BLF_REPAIRS_ALLOWED = ConvertAbilityBooleanLevelField('liq4') + constant abilitybooleanlevelfield ABILITY_BLF_CASTER_ONLY_SPLASH = ConvertAbilityBooleanLevelField('mfl6') + constant abilitybooleanlevelfield ABILITY_BLF_NO_TARGET_REQUIRED_IRL4 = ConvertAbilityBooleanLevelField('irl4') + constant abilitybooleanlevelfield ABILITY_BLF_DISPEL_ON_ATTACK = ConvertAbilityBooleanLevelField('irl5') + constant abilitybooleanlevelfield ABILITY_BLF_AMOUNT_IS_RAW_VALUE = ConvertAbilityBooleanLevelField('ipv3') + constant abilitybooleanlevelfield ABILITY_BLF_SHARED_SPELL_COOLDOWN = ConvertAbilityBooleanLevelField('spb2') + constant abilitybooleanlevelfield ABILITY_BLF_SLEEP_ONCE = ConvertAbilityBooleanLevelField('sla1') + constant abilitybooleanlevelfield ABILITY_BLF_ALLOW_ON_ANY_PLAYER_SLOT = ConvertAbilityBooleanLevelField('sla2') + constant abilitybooleanlevelfield ABILITY_BLF_DISABLE_OTHER_ABILITIES = ConvertAbilityBooleanLevelField('Ncl5') + constant abilitybooleanlevelfield ABILITY_BLF_ALLOW_BOUNTY = ConvertAbilityBooleanLevelField('Ntm4') + + constant abilitystringlevelfield ABILITY_SLF_ICON_NORMAL = ConvertAbilityStringLevelField('aart') + constant abilitystringlevelfield ABILITY_SLF_CASTER = ConvertAbilityStringLevelField('acat') + constant abilitystringlevelfield ABILITY_SLF_TARGET = ConvertAbilityStringLevelField('atat') + constant abilitystringlevelfield ABILITY_SLF_SPECIAL = ConvertAbilityStringLevelField('asat') + constant abilitystringlevelfield ABILITY_SLF_EFFECT = ConvertAbilityStringLevelField('aeat') + constant abilitystringlevelfield ABILITY_SLF_AREA_EFFECT = ConvertAbilityStringLevelField('aaea') + constant abilitystringlevelfield ABILITY_SLF_LIGHTNING_EFFECTS = ConvertAbilityStringLevelField('alig') + constant abilitystringlevelfield ABILITY_SLF_MISSILE_ART = ConvertAbilityStringLevelField('amat') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_LEARN = ConvertAbilityStringLevelField('aret') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_LEARN_EXTENDED = ConvertAbilityStringLevelField('arut') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_NORMAL = ConvertAbilityStringLevelField('atp1') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_TURN_OFF = ConvertAbilityStringLevelField('aut1') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_NORMAL_EXTENDED = ConvertAbilityStringLevelField('aub1') + constant abilitystringlevelfield ABILITY_SLF_TOOLTIP_TURN_OFF_EXTENDED = ConvertAbilityStringLevelField('auu1') + constant abilitystringlevelfield ABILITY_SLF_NORMAL_FORM_UNIT_EME1 = ConvertAbilityStringLevelField('Eme1') + constant abilitystringlevelfield ABILITY_SLF_SPAWNED_UNITS = ConvertAbilityStringLevelField('Ndp1') + constant abilitystringlevelfield ABILITY_SLF_ABILITY_FOR_UNIT_CREATION = ConvertAbilityStringLevelField('Nrc1') + constant abilitystringlevelfield ABILITY_SLF_NORMAL_FORM_UNIT_MIL1 = ConvertAbilityStringLevelField('Mil1') + constant abilitystringlevelfield ABILITY_SLF_ALTERNATE_FORM_UNIT_MIL2 = ConvertAbilityStringLevelField('Mil2') + constant abilitystringlevelfield ABILITY_SLF_BASE_ORDER_ID_ANS5 = ConvertAbilityStringLevelField('Ans5') + constant abilitystringlevelfield ABILITY_SLF_MORPH_UNITS_GROUND = ConvertAbilityStringLevelField('Ply2') + constant abilitystringlevelfield ABILITY_SLF_MORPH_UNITS_AIR = ConvertAbilityStringLevelField('Ply3') + constant abilitystringlevelfield ABILITY_SLF_MORPH_UNITS_AMPHIBIOUS = ConvertAbilityStringLevelField('Ply4') + constant abilitystringlevelfield ABILITY_SLF_MORPH_UNITS_WATER = ConvertAbilityStringLevelField('Ply5') + constant abilitystringlevelfield ABILITY_SLF_UNIT_TYPE_ONE = ConvertAbilityStringLevelField('Rai3') + constant abilitystringlevelfield ABILITY_SLF_UNIT_TYPE_TWO = ConvertAbilityStringLevelField('Rai4') + constant abilitystringlevelfield ABILITY_SLF_UNIT_TYPE_SOD2 = ConvertAbilityStringLevelField('Sod2') + constant abilitystringlevelfield ABILITY_SLF_SUMMON_1_UNIT_TYPE = ConvertAbilityStringLevelField('Ist1') + constant abilitystringlevelfield ABILITY_SLF_SUMMON_2_UNIT_TYPE = ConvertAbilityStringLevelField('Ist2') + constant abilitystringlevelfield ABILITY_SLF_RACE_TO_CONVERT = ConvertAbilityStringLevelField('Ndc1') + constant abilitystringlevelfield ABILITY_SLF_PARTNER_UNIT_TYPE = ConvertAbilityStringLevelField('coa1') + constant abilitystringlevelfield ABILITY_SLF_PARTNER_UNIT_TYPE_ONE = ConvertAbilityStringLevelField('dcp1') + constant abilitystringlevelfield ABILITY_SLF_PARTNER_UNIT_TYPE_TWO = ConvertAbilityStringLevelField('dcp2') + constant abilitystringlevelfield ABILITY_SLF_REQUIRED_UNIT_TYPE = ConvertAbilityStringLevelField('tpi1') + constant abilitystringlevelfield ABILITY_SLF_CONVERTED_UNIT_TYPE = ConvertAbilityStringLevelField('tpi2') + constant abilitystringlevelfield ABILITY_SLF_SPELL_LIST = ConvertAbilityStringLevelField('spb1') + constant abilitystringlevelfield ABILITY_SLF_BASE_ORDER_ID_SPB5 = ConvertAbilityStringLevelField('spb5') + constant abilitystringlevelfield ABILITY_SLF_BASE_ORDER_ID_NCL6 = ConvertAbilityStringLevelField('Ncl6') + constant abilitystringlevelfield ABILITY_SLF_ABILITY_UPGRADE_1 = ConvertAbilityStringLevelField('Neg3') + constant abilitystringlevelfield ABILITY_SLF_ABILITY_UPGRADE_2 = ConvertAbilityStringLevelField('Neg4') + constant abilitystringlevelfield ABILITY_SLF_ABILITY_UPGRADE_3 = ConvertAbilityStringLevelField('Neg5') + constant abilitystringlevelfield ABILITY_SLF_ABILITY_UPGRADE_4 = ConvertAbilityStringLevelField('Neg6') + constant abilitystringlevelfield ABILITY_SLF_SPAWN_UNIT_ID_NSY2 = ConvertAbilityStringLevelField('Nsy2') + + // Item + constant itemintegerfield ITEM_IF_LEVEL = ConvertItemIntegerField('ilev') + constant itemintegerfield ITEM_IF_NUMBER_OF_CHARGES = ConvertItemIntegerField('iuse') + constant itemintegerfield ITEM_IF_COOLDOWN_GROUP = ConvertItemIntegerField('icid') + constant itemintegerfield ITEM_IF_MAX_HIT_POINTS = ConvertItemIntegerField('ihtp') + constant itemintegerfield ITEM_IF_HIT_POINTS = ConvertItemIntegerField('ihpc') + constant itemintegerfield ITEM_IF_PRIORITY = ConvertItemIntegerField('ipri') + constant itemintegerfield ITEM_IF_ARMOR_TYPE = ConvertItemIntegerField('iarm') + constant itemintegerfield ITEM_IF_TINTING_COLOR_RED = ConvertItemIntegerField('iclr') + constant itemintegerfield ITEM_IF_TINTING_COLOR_GREEN = ConvertItemIntegerField('iclg') + constant itemintegerfield ITEM_IF_TINTING_COLOR_BLUE = ConvertItemIntegerField('iclb') + constant itemintegerfield ITEM_IF_TINTING_COLOR_ALPHA = ConvertItemIntegerField('ical') + + constant itemrealfield ITEM_RF_SCALING_VALUE = ConvertItemRealField('isca') + + constant itembooleanfield ITEM_BF_DROPPED_WHEN_CARRIER_DIES = ConvertItemBooleanField('idrp') + constant itembooleanfield ITEM_BF_CAN_BE_DROPPED = ConvertItemBooleanField('idro') + constant itembooleanfield ITEM_BF_PERISHABLE = ConvertItemBooleanField('iper') + constant itembooleanfield ITEM_BF_INCLUDE_AS_RANDOM_CHOICE = ConvertItemBooleanField('iprn') + constant itembooleanfield ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED = ConvertItemBooleanField('ipow') + constant itembooleanfield ITEM_BF_CAN_BE_SOLD_TO_MERCHANTS = ConvertItemBooleanField('ipaw') + constant itembooleanfield ITEM_BF_ACTIVELY_USED = ConvertItemBooleanField('iusa') + + constant itemstringfield ITEM_SF_MODEL_USED = ConvertItemStringField('ifil') + + // Unit + constant unitintegerfield UNIT_IF_DEFENSE_TYPE = ConvertUnitIntegerField('udty') + constant unitintegerfield UNIT_IF_ARMOR_TYPE = ConvertUnitIntegerField('uarm') + constant unitintegerfield UNIT_IF_LOOPING_FADE_IN_RATE = ConvertUnitIntegerField('ulfi') + constant unitintegerfield UNIT_IF_LOOPING_FADE_OUT_RATE = ConvertUnitIntegerField('ulfo') + constant unitintegerfield UNIT_IF_AGILITY = ConvertUnitIntegerField('uagc') + constant unitintegerfield UNIT_IF_INTELLIGENCE = ConvertUnitIntegerField('uinc') + constant unitintegerfield UNIT_IF_STRENGTH = ConvertUnitIntegerField('ustc') + constant unitintegerfield UNIT_IF_AGILITY_PERMANENT = ConvertUnitIntegerField('uagm') + constant unitintegerfield UNIT_IF_INTELLIGENCE_PERMANENT = ConvertUnitIntegerField('uinm') + constant unitintegerfield UNIT_IF_STRENGTH_PERMANENT = ConvertUnitIntegerField('ustm') + constant unitintegerfield UNIT_IF_AGILITY_WITH_BONUS = ConvertUnitIntegerField('uagb') + constant unitintegerfield UNIT_IF_INTELLIGENCE_WITH_BONUS = ConvertUnitIntegerField('uinb') + constant unitintegerfield UNIT_IF_STRENGTH_WITH_BONUS = ConvertUnitIntegerField('ustb') + constant unitintegerfield UNIT_IF_GOLD_BOUNTY_AWARDED_NUMBER_OF_DICE = ConvertUnitIntegerField('ubdi') + constant unitintegerfield UNIT_IF_GOLD_BOUNTY_AWARDED_BASE = ConvertUnitIntegerField('ubba') + constant unitintegerfield UNIT_IF_GOLD_BOUNTY_AWARDED_SIDES_PER_DIE = ConvertUnitIntegerField('ubsi') + constant unitintegerfield UNIT_IF_LUMBER_BOUNTY_AWARDED_NUMBER_OF_DICE = ConvertUnitIntegerField('ulbd') + constant unitintegerfield UNIT_IF_LUMBER_BOUNTY_AWARDED_BASE = ConvertUnitIntegerField('ulba') + constant unitintegerfield UNIT_IF_LUMBER_BOUNTY_AWARDED_SIDES_PER_DIE = ConvertUnitIntegerField('ulbs') + constant unitintegerfield UNIT_IF_LEVEL = ConvertUnitIntegerField('ulev') + constant unitintegerfield UNIT_IF_FORMATION_RANK = ConvertUnitIntegerField('ufor') + constant unitintegerfield UNIT_IF_ORIENTATION_INTERPOLATION = ConvertUnitIntegerField('uori') + constant unitintegerfield UNIT_IF_ELEVATION_SAMPLE_POINTS = ConvertUnitIntegerField('uept') + constant unitintegerfield UNIT_IF_TINTING_COLOR_RED = ConvertUnitIntegerField('uclr') + constant unitintegerfield UNIT_IF_TINTING_COLOR_GREEN = ConvertUnitIntegerField('uclg') + constant unitintegerfield UNIT_IF_TINTING_COLOR_BLUE = ConvertUnitIntegerField('uclb') + constant unitintegerfield UNIT_IF_TINTING_COLOR_ALPHA = ConvertUnitIntegerField('ucal') + constant unitintegerfield UNIT_IF_MOVE_TYPE = ConvertUnitIntegerField('umvt') + constant unitintegerfield UNIT_IF_TARGETED_AS = ConvertUnitIntegerField('utar') + constant unitintegerfield UNIT_IF_UNIT_CLASSIFICATION = ConvertUnitIntegerField('utyp') + constant unitintegerfield UNIT_IF_HIT_POINTS_REGENERATION_TYPE = ConvertUnitIntegerField('uhrt') + constant unitintegerfield UNIT_IF_PLACEMENT_PREVENTED_BY = ConvertUnitIntegerField('upar') + constant unitintegerfield UNIT_IF_PRIMARY_ATTRIBUTE = ConvertUnitIntegerField('upra') + + constant unitrealfield UNIT_RF_STRENGTH_PER_LEVEL = ConvertUnitRealField('ustp') + constant unitrealfield UNIT_RF_AGILITY_PER_LEVEL = ConvertUnitRealField('uagp') + constant unitrealfield UNIT_RF_INTELLIGENCE_PER_LEVEL = ConvertUnitRealField('uinp') + constant unitrealfield UNIT_RF_HIT_POINTS_REGENERATION_RATE = ConvertUnitRealField('uhpr') + constant unitrealfield UNIT_RF_MANA_REGENERATION = ConvertUnitRealField('umpr') + constant unitrealfield UNIT_RF_DEATH_TIME = ConvertUnitRealField('udtm') + constant unitrealfield UNIT_RF_FLY_HEIGHT = ConvertUnitRealField('ufyh') + constant unitrealfield UNIT_RF_FLY_MAX_HEIGHT = ConvertUnitRealField('ufmh') + constant unitrealfield UNIT_RF_TURN_RATE = ConvertUnitRealField('umvr') + constant unitrealfield UNIT_RF_ELEVATION_SAMPLE_RADIUS = ConvertUnitRealField('uerd') + constant unitrealfield UNIT_RF_FOG_OF_WAR_SAMPLE_RADIUS = ConvertUnitRealField('ufrd') + constant unitrealfield UNIT_RF_MAXIMUM_PITCH_ANGLE_DEGREES = ConvertUnitRealField('umxp') + constant unitrealfield UNIT_RF_MAXIMUM_ROLL_ANGLE_DEGREES = ConvertUnitRealField('umxr') + constant unitrealfield UNIT_RF_SCALING_VALUE = ConvertUnitRealField('usca') + constant unitrealfield UNIT_RF_ANIMATION_RUN_SPEED = ConvertUnitRealField('urun') + constant unitrealfield UNIT_RF_SELECTION_SCALE = ConvertUnitRealField('ussc') + constant unitrealfield UNIT_RF_SELECTION_CIRCLE_HEIGHT = ConvertUnitRealField('uslz') + constant unitrealfield UNIT_RF_SHADOW_IMAGE_HEIGHT = ConvertUnitRealField('ushh') + constant unitrealfield UNIT_RF_SHADOW_IMAGE_WIDTH = ConvertUnitRealField('ushw') + constant unitrealfield UNIT_RF_SHADOW_IMAGE_CENTER_X = ConvertUnitRealField('ushx') + constant unitrealfield UNIT_RF_SHADOW_IMAGE_CENTER_Y = ConvertUnitRealField('ushy') + constant unitrealfield UNIT_RF_ANIMATION_WALK_SPEED = ConvertUnitRealField('uwal') + constant unitrealfield UNIT_RF_DEFENSE = ConvertUnitRealField('udfc') + constant unitrealfield UNIT_RF_SIGHT_RADIUS = ConvertUnitRealField('usir') + constant unitrealfield UNIT_RF_PRIORITY = ConvertUnitRealField('upri') + constant unitrealfield UNIT_RF_SPEED = ConvertUnitRealField('umvc') + constant unitrealfield UNIT_RF_OCCLUDER_HEIGHT = ConvertUnitRealField('uocc') + constant unitrealfield UNIT_RF_HP = ConvertUnitRealField('uhpc') + constant unitrealfield UNIT_RF_MANA = ConvertUnitRealField('umpc') + constant unitrealfield UNIT_RF_ACQUISITION_RANGE = ConvertUnitRealField('uacq') + constant unitrealfield UNIT_RF_CAST_BACK_SWING = ConvertUnitRealField('ucbs') + constant unitrealfield UNIT_RF_CAST_POINT = ConvertUnitRealField('ucpt') + constant unitrealfield UNIT_RF_MINIMUM_ATTACK_RANGE = ConvertUnitRealField('uamn') + + constant unitbooleanfield UNIT_BF_RAISABLE = ConvertUnitBooleanField('urai') + constant unitbooleanfield UNIT_BF_DECAYABLE = ConvertUnitBooleanField('udec') + constant unitbooleanfield UNIT_BF_IS_A_BUILDING = ConvertUnitBooleanField('ubdg') + constant unitbooleanfield UNIT_BF_USE_EXTENDED_LINE_OF_SIGHT = ConvertUnitBooleanField('ulos') + constant unitbooleanfield UNIT_BF_NEUTRAL_BUILDING_SHOWS_MINIMAP_ICON = ConvertUnitBooleanField('unbm') + constant unitbooleanfield UNIT_BF_HERO_HIDE_HERO_INTERFACE_ICON = ConvertUnitBooleanField('uhhb') + constant unitbooleanfield UNIT_BF_HERO_HIDE_HERO_MINIMAP_DISPLAY = ConvertUnitBooleanField('uhhm') + constant unitbooleanfield UNIT_BF_HERO_HIDE_HERO_DEATH_MESSAGE = ConvertUnitBooleanField('uhhd') + constant unitbooleanfield UNIT_BF_HIDE_MINIMAP_DISPLAY = ConvertUnitBooleanField('uhom') + constant unitbooleanfield UNIT_BF_SCALE_PROJECTILES = ConvertUnitBooleanField('uscb') + constant unitbooleanfield UNIT_BF_SELECTION_CIRCLE_ON_WATER = ConvertUnitBooleanField('usew') + constant unitbooleanfield UNIT_BF_HAS_WATER_SHADOW = ConvertUnitBooleanField('ushr') + constant unitbooleanfield UNIT_BF_SHOW_AIR_TO_GROUND = ConvertUnitBooleanField('uatg') + constant unitbooleanfield UNIT_BF_FORCE_DISPLAY_HP = ConvertUnitBooleanField('ufhp') + + constant unitstringfield UNIT_SF_NAME = ConvertUnitStringField('unam') + constant unitstringfield UNIT_SF_PROPER_NAMES = ConvertUnitStringField('upro') + constant unitstringfield UNIT_SF_GROUND_TEXTURE = ConvertUnitStringField('uubs') + constant unitstringfield UNIT_SF_SHADOW_IMAGE_UNIT = ConvertUnitStringField('ushu') + + // Unit Weapon + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_NUMBER_OF_DICE = ConvertUnitWeaponIntegerField('ua1d') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_BASE = ConvertUnitWeaponIntegerField('ua1b') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_DAMAGE_SIDES_PER_DIE = ConvertUnitWeaponIntegerField('ua1s') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_MAXIMUM_NUMBER_OF_TARGETS = ConvertUnitWeaponIntegerField('utc1') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_ATTACK_TYPE = ConvertUnitWeaponIntegerField('ua1t') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND = ConvertUnitWeaponIntegerField('ucs1') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_AREA_OF_EFFECT_TARGETS = ConvertUnitWeaponIntegerField('ua1p') + constant unitweaponintegerfield UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED = ConvertUnitWeaponIntegerField('ua1g') + + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT = ConvertUnitWeaponRealField('ubs1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT = ConvertUnitWeaponRealField('udp1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN = ConvertUnitWeaponRealField('ua1c') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_LOSS_FACTOR = ConvertUnitWeaponRealField('udl1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_MEDIUM = ConvertUnitWeaponRealField('uhd1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_SMALL = ConvertUnitWeaponRealField('uqd1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_DISTANCE = ConvertUnitWeaponRealField('usd1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_RADIUS = ConvertUnitWeaponRealField('usr1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED = ConvertUnitWeaponRealField('ua1z') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC = ConvertUnitWeaponRealField('uma1') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_FULL_DAMAGE = ConvertUnitWeaponRealField('ua1f') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_MEDIUM_DAMAGE = ConvertUnitWeaponRealField('ua1h') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_SMALL_DAMAGE = ConvertUnitWeaponRealField('ua1q') + constant unitweaponrealfield UNIT_WEAPON_RF_ATTACK_RANGE = ConvertUnitWeaponRealField('ua1r') + + constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACK_SHOW_UI = ConvertUnitWeaponBooleanField('uwu1') + constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACKS_ENABLED = ConvertUnitWeaponBooleanField('uaen') + constant unitweaponbooleanfield UNIT_WEAPON_BF_ATTACK_PROJECTILE_HOMING_ENABLED = ConvertUnitWeaponBooleanField('umh1') + + constant unitweaponstringfield UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART = ConvertUnitWeaponStringField('ua1m') + + // Move Type + constant movetype MOVE_TYPE_UNKNOWN = ConvertMoveType(0) + constant movetype MOVE_TYPE_FOOT = ConvertMoveType(1) + constant movetype MOVE_TYPE_FLY = ConvertMoveType(2) + constant movetype MOVE_TYPE_HORSE = ConvertMoveType(4) + constant movetype MOVE_TYPE_HOVER = ConvertMoveType(8) + constant movetype MOVE_TYPE_FLOAT = ConvertMoveType(16) + constant movetype MOVE_TYPE_AMPHIBIOUS = ConvertMoveType(32) + constant movetype MOVE_TYPE_UNBUILDABLE = ConvertMoveType(64) + + // Target Flag + constant targetflag TARGET_FLAG_NONE = ConvertTargetFlag(1) + constant targetflag TARGET_FLAG_GROUND = ConvertTargetFlag(2) + constant targetflag TARGET_FLAG_AIR = ConvertTargetFlag(4) + constant targetflag TARGET_FLAG_STRUCTURE = ConvertTargetFlag(8) + constant targetflag TARGET_FLAG_WARD = ConvertTargetFlag(16) + constant targetflag TARGET_FLAG_ITEM = ConvertTargetFlag(32) + constant targetflag TARGET_FLAG_TREE = ConvertTargetFlag(64) + constant targetflag TARGET_FLAG_WALL = ConvertTargetFlag(128) + constant targetflag TARGET_FLAG_DEBRIS = ConvertTargetFlag(256) + constant targetflag TARGET_FLAG_DECORATION = ConvertTargetFlag(512) + constant targetflag TARGET_FLAG_BRIDGE = ConvertTargetFlag(1024) + + // defense type + constant defensetype DEFENSE_TYPE_LIGHT = ConvertDefenseType(0) + constant defensetype DEFENSE_TYPE_MEDIUM = ConvertDefenseType(1) + constant defensetype DEFENSE_TYPE_LARGE = ConvertDefenseType(2) + constant defensetype DEFENSE_TYPE_FORT = ConvertDefenseType(3) + constant defensetype DEFENSE_TYPE_NORMAL = ConvertDefenseType(4) + constant defensetype DEFENSE_TYPE_HERO = ConvertDefenseType(5) + constant defensetype DEFENSE_TYPE_DIVINE = ConvertDefenseType(6) + constant defensetype DEFENSE_TYPE_NONE = ConvertDefenseType(7) + + // Hero Attribute + constant heroattribute HERO_ATTRIBUTE_STR = ConvertHeroAttribute(1) + constant heroattribute HERO_ATTRIBUTE_INT = ConvertHeroAttribute(2) + constant heroattribute HERO_ATTRIBUTE_AGI = ConvertHeroAttribute(3) + + // Armor Type + constant armortype ARMOR_TYPE_WHOKNOWS = ConvertArmorType(0) + constant armortype ARMOR_TYPE_FLESH = ConvertArmorType(1) + constant armortype ARMOR_TYPE_METAL = ConvertArmorType(2) + constant armortype ARMOR_TYPE_WOOD = ConvertArmorType(3) + constant armortype ARMOR_TYPE_ETHREAL = ConvertArmorType(4) + constant armortype ARMOR_TYPE_STONE = ConvertArmorType(5) + + // Regeneration Type + constant regentype REGENERATION_TYPE_NONE = ConvertRegenType(0) + constant regentype REGENERATION_TYPE_ALWAYS = ConvertRegenType(1) + constant regentype REGENERATION_TYPE_BLIGHT = ConvertRegenType(2) + constant regentype REGENERATION_TYPE_DAY = ConvertRegenType(3) + constant regentype REGENERATION_TYPE_NIGHT = ConvertRegenType(4) + + // Unit Category + constant unitcategory UNIT_CATEGORY_GIANT = ConvertUnitCategory(1) + constant unitcategory UNIT_CATEGORY_UNDEAD = ConvertUnitCategory(2) + constant unitcategory UNIT_CATEGORY_SUMMONED = ConvertUnitCategory(4) + constant unitcategory UNIT_CATEGORY_MECHANICAL = ConvertUnitCategory(8) + constant unitcategory UNIT_CATEGORY_PEON = ConvertUnitCategory(16) + constant unitcategory UNIT_CATEGORY_SAPPER = ConvertUnitCategory(32) + constant unitcategory UNIT_CATEGORY_TOWNHALL = ConvertUnitCategory(64) + constant unitcategory UNIT_CATEGORY_ANCIENT = ConvertUnitCategory(128) + constant unitcategory UNIT_CATEGORY_NEUTRAL = ConvertUnitCategory(256) + constant unitcategory UNIT_CATEGORY_WARD = ConvertUnitCategory(512) + constant unitcategory UNIT_CATEGORY_STANDON = ConvertUnitCategory(1024) + constant unitcategory UNIT_CATEGORY_TAUREN = ConvertUnitCategory(2048) + + // Pathing Flag + constant pathingflag PATHING_FLAG_UNWALKABLE = ConvertPathingFlag(2) + constant pathingflag PATHING_FLAG_UNFLYABLE = ConvertPathingFlag(4) + constant pathingflag PATHING_FLAG_UNBUILDABLE = ConvertPathingFlag(8) + constant pathingflag PATHING_FLAG_UNPEONHARVEST = ConvertPathingFlag(16) + constant pathingflag PATHING_FLAG_BLIGHTED = ConvertPathingFlag(32) + constant pathingflag PATHING_FLAG_UNFLOATABLE = ConvertPathingFlag(64) + constant pathingflag PATHING_FLAG_UNAMPHIBIOUS = ConvertPathingFlag(128) + constant pathingflag PATHING_FLAG_UNITEMPLACABLE = ConvertPathingFlag(256) + +endglobals + +//============================================================================ +// MathAPI +native Deg2Rad takes real degrees returns real +native Rad2Deg takes real radians returns real + +native Sin takes real radians returns real +native Cos takes real radians returns real +native Tan takes real radians returns real + +// Expect values between -1 and 1...returns 0 for invalid input +native Asin takes real y returns real +native Acos takes real x returns real + +native Atan takes real x returns real + +// Returns 0 if x and y are both 0 +native Atan2 takes real y, real x returns real + +// Returns 0 if x <= 0 +native SquareRoot takes real x returns real + +// computes x to the y power +// y == 0.0 => 1 +// x ==0.0 and y < 0 => 0 +// +native Pow takes real x, real power returns real + +constant native MathRound takes real r returns integer + +//============================================================================ +// String Utility API +native I2R takes integer i returns real +native R2I takes real r returns integer +native I2S takes integer i returns string +native R2S takes real r returns string +native R2SW takes real r, integer width, integer precision returns string +native S2I takes string s returns integer +native S2R takes string s returns real +native GetHandleId takes handle h returns integer +native SubString takes string source, integer start, integer end returns string +native StringLength takes string s returns integer +native StringCase takes string source, boolean upper returns string +native StringHash takes string s returns integer + +native GetLocalizedString takes string source returns string +native GetLocalizedHotkey takes string source returns integer + +//============================================================================ +// Map Setup API +// +// These are native functions for describing the map configuration +// these funcs should only be used in the "config" function of +// a map script. The functions should also be called in this order +// ( i.e. call SetPlayers before SetPlayerColor... +// + +native SetMapName takes string name returns nothing +native SetMapDescription takes string description returns nothing + +native SetTeams takes integer teamcount returns nothing +native SetPlayers takes integer playercount returns nothing + +native DefineStartLocation takes integer whichStartLoc, real x, real y returns nothing +native DefineStartLocationLoc takes integer whichStartLoc, location whichLocation returns nothing +native SetStartLocPrioCount takes integer whichStartLoc, integer prioSlotCount returns nothing +native SetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex, integer otherStartLocIndex, startlocprio priority returns nothing +native GetStartLocPrioSlot takes integer whichStartLoc, integer prioSlotIndex returns integer +native GetStartLocPrio takes integer whichStartLoc, integer prioSlotIndex returns startlocprio +native SetEnemyStartLocPrioCount takes integer whichStartLoc, integer prioSlotCount returns nothing +native SetEnemyStartLocPrio takes integer whichStartLoc, integer prioSlotIndex, integer otherStartLocIndex, startlocprio priority returns nothing + +native SetGameTypeSupported takes gametype whichGameType, boolean value returns nothing +native SetMapFlag takes mapflag whichMapFlag, boolean value returns nothing +native SetGamePlacement takes placement whichPlacementType returns nothing +native SetGameSpeed takes gamespeed whichspeed returns nothing +native SetGameDifficulty takes gamedifficulty whichdifficulty returns nothing +native SetResourceDensity takes mapdensity whichdensity returns nothing +native SetCreatureDensity takes mapdensity whichdensity returns nothing + +native GetTeams takes nothing returns integer +native GetPlayers takes nothing returns integer + +native IsGameTypeSupported takes gametype whichGameType returns boolean +native GetGameTypeSelected takes nothing returns gametype +native IsMapFlagSet takes mapflag whichMapFlag returns boolean + +constant native GetGamePlacement takes nothing returns placement +constant native GetGameSpeed takes nothing returns gamespeed +constant native GetGameDifficulty takes nothing returns gamedifficulty +constant native GetResourceDensity takes nothing returns mapdensity +constant native GetCreatureDensity takes nothing returns mapdensity +constant native GetStartLocationX takes integer whichStartLocation returns real +constant native GetStartLocationY takes integer whichStartLocation returns real +constant native GetStartLocationLoc takes integer whichStartLocation returns location + + +native SetPlayerTeam takes player whichPlayer, integer whichTeam returns nothing +native SetPlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing +// forces player to have the specified start loc and marks the start loc as occupied +// which removes it from consideration for subsequently placed players +// ( i.e. you can use this to put people in a fixed loc and then +// use random placement for any unplaced players etc ) +native ForcePlayerStartLocation takes player whichPlayer, integer startLocIndex returns nothing +native SetPlayerColor takes player whichPlayer, playercolor color returns nothing +native SetPlayerAlliance takes player sourcePlayer, player otherPlayer, alliancetype whichAllianceSetting, boolean value returns nothing +native SetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource, integer rate returns nothing +native SetPlayerRacePreference takes player whichPlayer, racepreference whichRacePreference returns nothing +native SetPlayerRaceSkin takes player whichPlayer, racepreference whichRacePreference returns nothing +native SetPlayerRaceSelectable takes player whichPlayer, boolean value returns nothing +native SetPlayerController takes player whichPlayer, mapcontrol controlType returns nothing +native SetPlayerName takes player whichPlayer, string name returns nothing + +native SetPlayerOnScoreScreen takes player whichPlayer, boolean flag returns nothing + +native GetPlayerTeam takes player whichPlayer returns integer +native GetPlayerStartLocation takes player whichPlayer returns integer +native GetPlayerColor takes player whichPlayer returns playercolor +native GetPlayerSelectable takes player whichPlayer returns boolean +native GetPlayerController takes player whichPlayer returns mapcontrol +native GetPlayerSlotState takes player whichPlayer returns playerslotstate +native GetPlayerTaxRate takes player sourcePlayer, player otherPlayer, playerstate whichResource returns integer +native IsPlayerRacePrefSet takes player whichPlayer, racepreference pref returns boolean +native GetPlayerName takes player whichPlayer returns string + +//============================================================================ +// Timer API +// +native CreateTimer takes nothing returns timer +native DestroyTimer takes timer whichTimer returns nothing +native TimerStart takes timer whichTimer, real timeout, boolean periodic, code handlerFunc returns nothing +native TimerGetElapsed takes timer whichTimer returns real +native TimerGetRemaining takes timer whichTimer returns real +native TimerGetTimeout takes timer whichTimer returns real +native PauseTimer takes timer whichTimer returns nothing +native ResumeTimer takes timer whichTimer returns nothing +native GetExpiredTimer takes nothing returns timer + +//============================================================================ +// Group API +// +native CreateGroup takes nothing returns group +native DestroyGroup takes group whichGroup returns nothing +native GroupAddUnit takes group whichGroup, unit whichUnit returns boolean +native GroupRemoveUnit takes group whichGroup, unit whichUnit returns boolean +native BlzGroupAddGroupFast takes group whichGroup, group addGroup returns integer +native BlzGroupRemoveGroupFast takes group whichGroup, group removeGroup returns integer +native GroupClear takes group whichGroup returns nothing +native BlzGroupGetSize takes group whichGroup returns integer +native BlzGroupUnitAt takes group whichGroup, integer index returns unit +native GroupEnumUnitsOfType takes group whichGroup, string unitname, boolexpr filter returns nothing +native GroupEnumUnitsOfPlayer takes group whichGroup, player whichPlayer, boolexpr filter returns nothing +native GroupEnumUnitsOfTypeCounted takes group whichGroup, string unitname, boolexpr filter, integer countLimit returns nothing +native GroupEnumUnitsInRect takes group whichGroup, rect r, boolexpr filter returns nothing +native GroupEnumUnitsInRectCounted takes group whichGroup, rect r, boolexpr filter, integer countLimit returns nothing +native GroupEnumUnitsInRange takes group whichGroup, real x, real y, real radius, boolexpr filter returns nothing +native GroupEnumUnitsInRangeOfLoc takes group whichGroup, location whichLocation, real radius, boolexpr filter returns nothing +native GroupEnumUnitsInRangeCounted takes group whichGroup, real x, real y, real radius, boolexpr filter, integer countLimit returns nothing +native GroupEnumUnitsInRangeOfLocCounted takes group whichGroup, location whichLocation, real radius, boolexpr filter, integer countLimit returns nothing +native GroupEnumUnitsSelected takes group whichGroup, player whichPlayer, boolexpr filter returns nothing + +native GroupImmediateOrder takes group whichGroup, string order returns boolean +native GroupImmediateOrderById takes group whichGroup, integer order returns boolean +native GroupPointOrder takes group whichGroup, string order, real x, real y returns boolean +native GroupPointOrderLoc takes group whichGroup, string order, location whichLocation returns boolean +native GroupPointOrderById takes group whichGroup, integer order, real x, real y returns boolean +native GroupPointOrderByIdLoc takes group whichGroup, integer order, location whichLocation returns boolean +native GroupTargetOrder takes group whichGroup, string order, widget targetWidget returns boolean +native GroupTargetOrderById takes group whichGroup, integer order, widget targetWidget returns boolean + +// This will be difficult to support with potentially disjoint, cell-based regions +// as it would involve enumerating all the cells that are covered by a particularregion +// a better implementation would be a trigger that adds relevant units as they enter +// and removes them if they leave... +native ForGroup takes group whichGroup, code callback returns nothing +native FirstOfGroup takes group whichGroup returns unit + +//============================================================================ +// Force API +// +native CreateForce takes nothing returns force +native DestroyForce takes force whichForce returns nothing +native ForceAddPlayer takes force whichForce, player whichPlayer returns nothing +native ForceRemovePlayer takes force whichForce, player whichPlayer returns nothing +native BlzForceHasPlayer takes force whichForce, player whichPlayer returns boolean +native ForceClear takes force whichForce returns nothing +native ForceEnumPlayers takes force whichForce, boolexpr filter returns nothing +native ForceEnumPlayersCounted takes force whichForce, boolexpr filter, integer countLimit returns nothing +native ForceEnumAllies takes force whichForce, player whichPlayer, boolexpr filter returns nothing +native ForceEnumEnemies takes force whichForce, player whichPlayer, boolexpr filter returns nothing +native ForForce takes force whichForce, code callback returns nothing + +//============================================================================ +// Region and Location API +// +native Rect takes real minx, real miny, real maxx, real maxy returns rect +native RectFromLoc takes location min, location max returns rect +native RemoveRect takes rect whichRect returns nothing +native SetRect takes rect whichRect, real minx, real miny, real maxx, real maxy returns nothing +native SetRectFromLoc takes rect whichRect, location min, location max returns nothing +native MoveRectTo takes rect whichRect, real newCenterX, real newCenterY returns nothing +native MoveRectToLoc takes rect whichRect, location newCenterLoc returns nothing + +native GetRectCenterX takes rect whichRect returns real +native GetRectCenterY takes rect whichRect returns real +native GetRectMinX takes rect whichRect returns real +native GetRectMinY takes rect whichRect returns real +native GetRectMaxX takes rect whichRect returns real +native GetRectMaxY takes rect whichRect returns real + +native CreateRegion takes nothing returns region +native RemoveRegion takes region whichRegion returns nothing + +native RegionAddRect takes region whichRegion, rect r returns nothing +native RegionClearRect takes region whichRegion, rect r returns nothing + +native RegionAddCell takes region whichRegion, real x, real y returns nothing +native RegionAddCellAtLoc takes region whichRegion, location whichLocation returns nothing +native RegionClearCell takes region whichRegion, real x, real y returns nothing +native RegionClearCellAtLoc takes region whichRegion, location whichLocation returns nothing + +native Location takes real x, real y returns location +native RemoveLocation takes location whichLocation returns nothing +native MoveLocation takes location whichLocation, real newX, real newY returns nothing +native GetLocationX takes location whichLocation returns real +native GetLocationY takes location whichLocation returns real + +// This function is asynchronous. The values it returns are not guaranteed synchronous between each player. +// If you attempt to use it in a synchronous manner, it may cause a desync. +native GetLocationZ takes location whichLocation returns real + +native IsUnitInRegion takes region whichRegion, unit whichUnit returns boolean +native IsPointInRegion takes region whichRegion, real x, real y returns boolean +native IsLocationInRegion takes region whichRegion, location whichLocation returns boolean + +// Returns full map bounds, including unplayable borders, in world coordinates +native GetWorldBounds takes nothing returns rect + +//============================================================================ +// Native trigger interface +// +native CreateTrigger takes nothing returns trigger +native DestroyTrigger takes trigger whichTrigger returns nothing +native ResetTrigger takes trigger whichTrigger returns nothing +native EnableTrigger takes trigger whichTrigger returns nothing +native DisableTrigger takes trigger whichTrigger returns nothing +native IsTriggerEnabled takes trigger whichTrigger returns boolean + +native TriggerWaitOnSleeps takes trigger whichTrigger, boolean flag returns nothing +native IsTriggerWaitOnSleeps takes trigger whichTrigger returns boolean + +constant native GetFilterUnit takes nothing returns unit +constant native GetEnumUnit takes nothing returns unit + +constant native GetFilterDestructable takes nothing returns destructable +constant native GetEnumDestructable takes nothing returns destructable + +constant native GetFilterItem takes nothing returns item +constant native GetEnumItem takes nothing returns item + +constant native ParseTags takes string taggedString returns string + +constant native GetFilterPlayer takes nothing returns player +constant native GetEnumPlayer takes nothing returns player + +constant native GetTriggeringTrigger takes nothing returns trigger +constant native GetTriggerEventId takes nothing returns eventid +constant native GetTriggerEvalCount takes trigger whichTrigger returns integer +constant native GetTriggerExecCount takes trigger whichTrigger returns integer + +native ExecuteFunc takes string funcName returns nothing + +//============================================================================ +// Boolean Expr API ( for compositing trigger conditions and unit filter funcs...) +//============================================================================ +native And takes boolexpr operandA, boolexpr operandB returns boolexpr +native Or takes boolexpr operandA, boolexpr operandB returns boolexpr +native Not takes boolexpr operand returns boolexpr +native Condition takes code func returns conditionfunc +native DestroyCondition takes conditionfunc c returns nothing +native Filter takes code func returns filterfunc +native DestroyFilter takes filterfunc f returns nothing +native DestroyBoolExpr takes boolexpr e returns nothing + +//============================================================================ +// Trigger Game Event API +//============================================================================ + +native TriggerRegisterVariableEvent takes trigger whichTrigger, string varName, limitop opcode, real limitval returns event + + // EVENT_GAME_VARIABLE_LIMIT + //constant native string GetTriggeringVariableName takes nothing returns string + +// Creates it's own timer and triggers when it expires +native TriggerRegisterTimerEvent takes trigger whichTrigger, real timeout, boolean periodic returns event + +// Triggers when the timer you tell it about expires +native TriggerRegisterTimerExpireEvent takes trigger whichTrigger, timer t returns event + +native TriggerRegisterGameStateEvent takes trigger whichTrigger, gamestate whichState, limitop opcode, real limitval returns event + +native TriggerRegisterDialogEvent takes trigger whichTrigger, dialog whichDialog returns event +native TriggerRegisterDialogButtonEvent takes trigger whichTrigger, button whichButton returns event + +// EVENT_GAME_STATE_LIMIT +constant native GetEventGameState takes nothing returns gamestate + +native TriggerRegisterGameEvent takes trigger whichTrigger, gameevent whichGameEvent returns event + +// EVENT_GAME_VICTORY +constant native GetWinningPlayer takes nothing returns player + + +native TriggerRegisterEnterRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event + +// EVENT_GAME_ENTER_REGION +constant native GetTriggeringRegion takes nothing returns region +constant native GetEnteringUnit takes nothing returns unit + +// EVENT_GAME_LEAVE_REGION + +native TriggerRegisterLeaveRegion takes trigger whichTrigger, region whichRegion, boolexpr filter returns event +constant native GetLeavingUnit takes nothing returns unit + +native TriggerRegisterTrackableHitEvent takes trigger whichTrigger, trackable t returns event +native TriggerRegisterTrackableTrackEvent takes trigger whichTrigger, trackable t returns event + +// EVENT_COMMAND_BUTTON_CLICK +native TriggerRegisterCommandEvent takes trigger whichTrigger, integer whichAbility, string order returns event +native TriggerRegisterUpgradeCommandEvent takes trigger whichTrigger, integer whichUpgrade returns event + +// EVENT_GAME_TRACKABLE_HIT +// EVENT_GAME_TRACKABLE_TRACK +constant native GetTriggeringTrackable takes nothing returns trackable + +// EVENT_DIALOG_BUTTON_CLICK +constant native GetClickedButton takes nothing returns button +constant native GetClickedDialog takes nothing returns dialog + +// EVENT_GAME_TOURNAMENT_FINISH_SOON +constant native GetTournamentFinishSoonTimeRemaining takes nothing returns real +constant native GetTournamentFinishNowRule takes nothing returns integer +constant native GetTournamentFinishNowPlayer takes nothing returns player +constant native GetTournamentScore takes player whichPlayer returns integer + +// EVENT_GAME_SAVE +constant native GetSaveBasicFilename takes nothing returns string + +//============================================================================ +// Trigger Player Based Event API +//============================================================================ + +native TriggerRegisterPlayerEvent takes trigger whichTrigger, player whichPlayer, playerevent whichPlayerEvent returns event + +// EVENT_PLAYER_DEFEAT +// EVENT_PLAYER_VICTORY +constant native GetTriggerPlayer takes nothing returns player + +native TriggerRegisterPlayerUnitEvent takes trigger whichTrigger, player whichPlayer, playerunitevent whichPlayerUnitEvent, boolexpr filter returns event + +// EVENT_PLAYER_HERO_LEVEL +// EVENT_UNIT_HERO_LEVEL +constant native GetLevelingUnit takes nothing returns unit + +// EVENT_PLAYER_HERO_SKILL +// EVENT_UNIT_HERO_SKILL +constant native GetLearningUnit takes nothing returns unit +constant native GetLearnedSkill takes nothing returns integer +constant native GetLearnedSkillLevel takes nothing returns integer + +// EVENT_PLAYER_HERO_REVIVABLE +constant native GetRevivableUnit takes nothing returns unit + +// EVENT_PLAYER_HERO_REVIVE_START +// EVENT_PLAYER_HERO_REVIVE_CANCEL +// EVENT_PLAYER_HERO_REVIVE_FINISH +// EVENT_UNIT_HERO_REVIVE_START +// EVENT_UNIT_HERO_REVIVE_CANCEL +// EVENT_UNIT_HERO_REVIVE_FINISH +constant native GetRevivingUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_ATTACKED +constant native GetAttacker takes nothing returns unit + +// EVENT_PLAYER_UNIT_RESCUED +constant native GetRescuer takes nothing returns unit + +// EVENT_PLAYER_UNIT_DEATH +constant native GetDyingUnit takes nothing returns unit +constant native GetKillingUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_DECAY +constant native GetDecayingUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_SELECTED +//constant native GetSelectedUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_CONSTRUCT_START +constant native GetConstructingStructure takes nothing returns unit + +// EVENT_PLAYER_UNIT_CONSTRUCT_FINISH +// EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL +constant native GetCancelledStructure takes nothing returns unit +constant native GetConstructedStructure takes nothing returns unit + +// EVENT_PLAYER_UNIT_RESEARCH_START +// EVENT_PLAYER_UNIT_RESEARCH_CANCEL +// EVENT_PLAYER_UNIT_RESEARCH_FINISH +constant native GetResearchingUnit takes nothing returns unit +constant native GetResearched takes nothing returns integer + +// EVENT_PLAYER_UNIT_TRAIN_START +// EVENT_PLAYER_UNIT_TRAIN_CANCEL +constant native GetTrainedUnitType takes nothing returns integer + +// EVENT_PLAYER_UNIT_TRAIN_FINISH +constant native GetTrainedUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_DETECTED +constant native GetDetectedUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_SUMMONED +constant native GetSummoningUnit takes nothing returns unit +constant native GetSummonedUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_LOADED +constant native GetTransportUnit takes nothing returns unit +constant native GetLoadedUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_SELL +constant native GetSellingUnit takes nothing returns unit +constant native GetSoldUnit takes nothing returns unit +constant native GetBuyingUnit takes nothing returns unit + +// EVENT_PLAYER_UNIT_SELL_ITEM +constant native GetSoldItem takes nothing returns item + +// EVENT_PLAYER_UNIT_CHANGE_OWNER +constant native GetChangingUnit takes nothing returns unit +constant native GetChangingUnitPrevOwner takes nothing returns player + +// EVENT_PLAYER_UNIT_DROP_ITEM +// EVENT_PLAYER_UNIT_PICKUP_ITEM +// EVENT_PLAYER_UNIT_USE_ITEM +constant native GetManipulatingUnit takes nothing returns unit +constant native GetManipulatedItem takes nothing returns item + +// EVENT_PLAYER_UNIT_EQUIP_ITEM +constant native GetEquippedItem takes nothing returns item + +// EVENT_PLAYER_UNIT_UNEQUIP_ITEM +constant native GetUnequippedItem takes nothing returns item + +// For EVENT_PLAYER_UNIT_PICKUP_ITEM, returns the item absorbing the picked up item in case it is stacking. +// Returns null if the item was a powerup and not a stacking item. +constant native BlzGetAbsorbingItem takes nothing returns item +constant native BlzGetManipulatedItemWasAbsorbed takes nothing returns boolean + +// EVENT_PLAYER_UNIT_STACK_ITEM +// Source is the item that is losing charges, Target is the item getting charges. +constant native BlzGetStackingItemSource takes nothing returns item +constant native BlzGetStackingItemTarget takes nothing returns item +constant native BlzGetStackingItemTargetPreviousCharges takes nothing returns integer + +// EVENT_PLAYER_UNIT_ISSUED_ORDER +constant native GetOrderedUnit takes nothing returns unit +constant native GetIssuedOrderId takes nothing returns integer + +// EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER +constant native GetOrderPointX takes nothing returns real +constant native GetOrderPointY takes nothing returns real +constant native GetOrderPointLoc takes nothing returns location + +// EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER +constant native GetOrderTarget takes nothing returns widget +constant native GetOrderTargetDestructable takes nothing returns destructable +constant native GetOrderTargetItem takes nothing returns item +constant native GetOrderTargetUnit takes nothing returns unit + +// EVENT_UNIT_SPELL_CHANNEL +// EVENT_UNIT_SPELL_CAST +// EVENT_UNIT_SPELL_EFFECT +// EVENT_UNIT_SPELL_FINISH +// EVENT_UNIT_SPELL_ENDCAST +// EVENT_PLAYER_UNIT_SPELL_CHANNEL +// EVENT_PLAYER_UNIT_SPELL_CAST +// EVENT_PLAYER_UNIT_SPELL_EFFECT +// EVENT_PLAYER_UNIT_SPELL_FINISH +// EVENT_PLAYER_UNIT_SPELL_ENDCAST +constant native GetSpellAbilityUnit takes nothing returns unit +constant native GetSpellAbilityId takes nothing returns integer +constant native GetSpellAbility takes nothing returns ability +constant native GetSpellTargetLoc takes nothing returns location +constant native GetSpellTargetX takes nothing returns real +constant native GetSpellTargetY takes nothing returns real +constant native GetSpellTargetDestructable takes nothing returns destructable +constant native GetSpellTargetItem takes nothing returns item +constant native GetSpellTargetUnit takes nothing returns unit + +native TriggerRegisterPlayerAllianceChange takes trigger whichTrigger, player whichPlayer, alliancetype whichAlliance returns event +native TriggerRegisterPlayerStateEvent takes trigger whichTrigger, player whichPlayer, playerstate whichState, limitop opcode, real limitval returns event + +// EVENT_PLAYER_STATE_LIMIT +constant native GetEventPlayerState takes nothing returns playerstate + +native TriggerRegisterPlayerChatEvent takes trigger whichTrigger, player whichPlayer, string chatMessageToDetect, boolean exactMatchOnly returns event + +// EVENT_PLAYER_CHAT + +// returns the actual string they typed in ( same as what you registered for +// if you required exact match ) +constant native GetEventPlayerChatString takes nothing returns string + +// returns the string that you registered for +constant native GetEventPlayerChatStringMatched takes nothing returns string + +native TriggerRegisterDeathEvent takes trigger whichTrigger, widget whichWidget returns event + +//============================================================================ +// Trigger Unit Based Event API +//============================================================================ + +// returns handle to unit which triggered the most recent event when called from +// within a trigger action function...returns null handle when used incorrectly + +constant native GetTriggerUnit takes nothing returns unit + +native TriggerRegisterUnitStateEvent takes trigger whichTrigger, unit whichUnit, unitstate whichState, limitop opcode, real limitval returns event + +// EVENT_UNIT_STATE_LIMIT +constant native GetEventUnitState takes nothing returns unitstate + +native TriggerRegisterUnitEvent takes trigger whichTrigger, unit whichUnit, unitevent whichEvent returns event + +// EVENT_UNIT_DAMAGED +constant native GetEventDamage takes nothing returns real +constant native GetEventDamageSource takes nothing returns unit + +// EVENT_UNIT_DEATH +// EVENT_UNIT_DECAY +// Use the GetDyingUnit and GetDecayingUnit funcs above + +// EVENT_UNIT_DETECTED +constant native GetEventDetectingPlayer takes nothing returns player + +native TriggerRegisterFilterUnitEvent takes trigger whichTrigger, unit whichUnit, unitevent whichEvent, boolexpr filter returns event + +// EVENT_UNIT_ACQUIRED_TARGET +// EVENT_UNIT_TARGET_IN_RANGE +constant native GetEventTargetUnit takes nothing returns unit + +// EVENT_UNIT_ATTACKED +// Use GetAttacker from the Player Unit Event API Below... + +// EVENT_UNIT_RESCUEDED +// Use GetRescuer from the Player Unit Event API Below... + +// EVENT_UNIT_CONSTRUCT_CANCEL +// EVENT_UNIT_CONSTRUCT_FINISH + +// See the Player Unit Construction Event API above for event info funcs + +// EVENT_UNIT_TRAIN_START +// EVENT_UNIT_TRAIN_CANCELLED +// EVENT_UNIT_TRAIN_FINISH + +// See the Player Unit Training Event API above for event info funcs + +// EVENT_UNIT_SELL + +// See the Player Unit Sell Event API above for event info funcs + +// EVENT_UNIT_DROP_ITEM +// EVENT_UNIT_PICKUP_ITEM +// EVENT_UNIT_USE_ITEM +// See the Player Unit/Item manipulation Event API above for event info funcs + +// EVENT_UNIT_STACK_ITEM +// See the Player Unit/Item stack Event API above for event info funcs + +// EVENT_UNIT_ISSUED_ORDER +// EVENT_UNIT_ISSUED_POINT_ORDER +// EVENT_UNIT_ISSUED_TARGET_ORDER + +// See the Player Unit Order Event API above for event info funcs + +native TriggerRegisterUnitInRange takes trigger whichTrigger, unit whichUnit, real range, boolexpr filter returns event + +native TriggerAddCondition takes trigger whichTrigger, boolexpr condition returns triggercondition +native TriggerRemoveCondition takes trigger whichTrigger, triggercondition whichCondition returns nothing +native TriggerClearConditions takes trigger whichTrigger returns nothing + +native TriggerAddAction takes trigger whichTrigger, code actionFunc returns triggeraction +native TriggerRemoveAction takes trigger whichTrigger, triggeraction whichAction returns nothing +native TriggerClearActions takes trigger whichTrigger returns nothing +native TriggerSleepAction takes real timeout returns nothing +native TriggerWaitForSound takes sound s, real offset returns nothing +native TriggerEvaluate takes trigger whichTrigger returns boolean +native TriggerExecute takes trigger whichTrigger returns nothing +native TriggerExecuteWait takes trigger whichTrigger returns nothing +native TriggerSyncStart takes nothing returns nothing +native TriggerSyncReady takes nothing returns nothing +native BlzTriggerIsRunning takes trigger whichTrigger returns boolean +native BlzTriggerInterrupt takes trigger whichTrigger returns nothing + +//============================================================================ +// Widget API +native GetWidgetLife takes widget whichWidget returns real +native SetWidgetLife takes widget whichWidget, real newLife returns nothing +native GetWidgetX takes widget whichWidget returns real +native GetWidgetY takes widget whichWidget returns real +constant native GetTriggerWidget takes nothing returns widget + +//============================================================================ +// Destructable Object API +// Facing arguments are specified in degrees +native CreateDestructable takes integer objectid, real x, real y, real face, real scale, integer variation returns destructable +native CreateDestructableZ takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns destructable +native CreateDeadDestructable takes integer objectid, real x, real y, real face, real scale, integer variation returns destructable +native CreateDeadDestructableZ takes integer objectid, real x, real y, real z, real face, real scale, integer variation returns destructable +native RemoveDestructable takes destructable d returns nothing +native KillDestructable takes destructable d returns nothing +native SetDestructableInvulnerable takes destructable d, boolean flag returns nothing +native IsDestructableInvulnerable takes destructable d returns boolean +native EnumDestructablesInRect takes rect r, boolexpr filter, code actionFunc returns nothing +native GetDestructableTypeId takes destructable d returns integer +native GetDestructableX takes destructable d returns real +native GetDestructableY takes destructable d returns real +native SetDestructableLife takes destructable d, real life returns nothing +native GetDestructableLife takes destructable d returns real +native SetDestructableMaxLife takes destructable d, real max returns nothing +native GetDestructableMaxLife takes destructable d returns real +native DestructableRestoreLife takes destructable d, real life, boolean birth returns nothing +native QueueDestructableAnimation takes destructable d, string whichAnimation returns nothing +native SetDestructableAnimation takes destructable d, string whichAnimation returns nothing +native SetDestructableAnimationSpeed takes destructable d, real speedFactor returns nothing +native SetDestructableColor takes destructable d, playercolor color returns nothing +native ShowDestructable takes destructable d, boolean flag returns nothing +native GetDestructableOccluderHeight takes destructable d returns real +native SetDestructableOccluderHeight takes destructable d, real height returns nothing +native GetDestructableName takes destructable d returns string +constant native GetTriggerDestructable takes nothing returns destructable + +//============================================================================ +// Item API +native CreateItem takes integer itemid, real x, real y returns item +native RemoveItem takes item whichItem returns nothing +native GetItemPlayer takes item whichItem returns player +native GetItemTypeId takes item i returns integer +native GetItemX takes item i returns real +native GetItemY takes item i returns real +native SetItemPosition takes item i, real x, real y returns nothing +native SetItemColor takes item whichItem, playercolor whichColor returns nothing +native SetItemDropOnDeath takes item whichItem, boolean flag returns nothing +native SetItemDroppable takes item i, boolean flag returns nothing +native SetItemPawnable takes item i, boolean flag returns nothing +native SetItemPlayer takes item whichItem, player whichPlayer, boolean changeColor returns nothing +native SetItemInvulnerable takes item whichItem, boolean flag returns nothing +native IsItemInvulnerable takes item whichItem returns boolean +native IsItemEquipped takes item whichItem returns boolean +native IsItemInBag takes item whichItem returns boolean +native SetItemVisible takes item whichItem, boolean show returns nothing +native IsItemVisible takes item whichItem returns boolean +native IsItemOwned takes item whichItem returns boolean +native IsItemPowerup takes item whichItem returns boolean +native IsItemSellable takes item whichItem returns boolean +native IsItemPawnable takes item whichItem returns boolean +native IsItemIdPowerup takes integer itemId returns boolean +native IsItemIdSellable takes integer itemId returns boolean +native IsItemIdPawnable takes integer itemId returns boolean +native EnumItemsInRect takes rect r, boolexpr filter, code actionFunc returns nothing +native GetItemLevel takes item whichItem returns integer +native GetItemType takes item whichItem returns itemtype +native SetItemDropID takes item whichItem, integer unitId returns nothing +constant native GetItemName takes item whichItem returns string +native GetItemCharges takes item whichItem returns integer +native SetItemCharges takes item whichItem, integer charges returns nothing +native GetItemUserData takes item whichItem returns integer +native SetItemUserData takes item whichItem, integer data returns nothing +native GetItemEquipmentType takes item whichItem returns equipmentType +native GetItemTag takes item whichItem returns itemTag + +//============================================================================ +// Unit API +// Facing arguments are specified in degrees +native CreateUnit takes player id, integer unitid, real x, real y, real face returns unit +native CreateUnitByName takes player whichPlayer, string unitname, real x, real y, real face returns unit +native CreateUnitAtLoc takes player id, integer unitid, location whichLocation, real face returns unit +native CreateUnitAtLocByName takes player id, string unitname, location whichLocation, real face returns unit +native CreateCorpse takes player whichPlayer, integer unitid, real x, real y, real face returns unit + +native KillUnit takes unit whichUnit returns nothing +native RemoveUnit takes unit whichUnit returns nothing +native ShowUnit takes unit whichUnit, boolean show returns nothing + +native SetUnitState takes unit whichUnit, unitstate whichUnitState, real newVal returns nothing +native SetUnitX takes unit whichUnit, real newX returns nothing +native SetUnitY takes unit whichUnit, real newY returns nothing +native SetUnitPosition takes unit whichUnit, real newX, real newY returns nothing +native SetUnitPositionLoc takes unit whichUnit, location whichLocation returns nothing +native SetUnitFacing takes unit whichUnit, real facingAngle returns nothing +native SetUnitFacingTimed takes unit whichUnit, real facingAngle, real duration returns nothing +native SetUnitMoveSpeed takes unit whichUnit, real newSpeed returns nothing +native SetUnitFlyHeight takes unit whichUnit, real newHeight, real rate returns nothing +native SetUnitTurnSpeed takes unit whichUnit, real newTurnSpeed returns nothing +native SetUnitPropWindow takes unit whichUnit, real newPropWindowAngle returns nothing +native SetUnitAcquireRange takes unit whichUnit, real newAcquireRange returns nothing +native SetUnitCreepGuard takes unit whichUnit, boolean creepGuard returns nothing + +native GetUnitAcquireRange takes unit whichUnit returns real +native GetUnitTurnSpeed takes unit whichUnit returns real +native GetUnitPropWindow takes unit whichUnit returns real +native GetUnitFlyHeight takes unit whichUnit returns real + +native GetUnitDefaultAcquireRange takes unit whichUnit returns real +native GetUnitDefaultTurnSpeed takes unit whichUnit returns real +native GetUnitDefaultPropWindow takes unit whichUnit returns real +native GetUnitDefaultFlyHeight takes unit whichUnit returns real + +native SetUnitOwner takes unit whichUnit, player whichPlayer, boolean changeColor returns nothing +native SetUnitColor takes unit whichUnit, playercolor whichColor returns nothing + +native SetUnitScale takes unit whichUnit, real scaleX, real scaleY, real scaleZ returns nothing +native SetUnitTimeScale takes unit whichUnit, real timeScale returns nothing +native SetUnitBlendTime takes unit whichUnit, real blendTime returns nothing +native SetUnitVertexColor takes unit whichUnit, integer red, integer green, integer blue, integer alpha returns nothing + +native QueueUnitAnimation takes unit whichUnit, string whichAnimation returns nothing +native SetUnitAnimation takes unit whichUnit, string whichAnimation returns nothing +native SetUnitAnimationByIndex takes unit whichUnit, integer whichAnimation returns nothing +native SetUnitAnimationWithRarity takes unit whichUnit, string whichAnimation, raritycontrol rarity returns nothing +native AddUnitAnimationProperties takes unit whichUnit, string animProperties, boolean add returns nothing +native AllowHeroGlowOnUnit takes unit whichUnit returns nothing +native DisallowHeroGlowOnUnit takes unit whichUnit returns nothing +native HeroGlowIsAllowedOnUnit takes unit whichUnit returns boolean + +native BlzGetUnitAnimationDuration takes unit whichUnit, string whichAnimation returns real +native BlzGetUnitAnimationDurationByIndex takes unit whichUnit, integer index returns real + +native SetUnitLookAt takes unit whichUnit, string whichBone, unit lookAtTarget, real offsetX, real offsetY, real offsetZ returns nothing +native ResetUnitLookAt takes unit whichUnit returns nothing + +native SetUnitRescuable takes unit whichUnit, player byWhichPlayer, boolean flag returns nothing +native SetUnitRescueRange takes unit whichUnit, real range returns nothing + +native SetHeroStr takes unit whichHero, integer newStr, boolean permanent returns nothing +native SetHeroAgi takes unit whichHero, integer newAgi, boolean permanent returns nothing +native SetHeroInt takes unit whichHero, integer newInt, boolean permanent returns nothing + +native GetHeroStr takes unit whichHero, boolean includeBonuses returns integer +native GetHeroAgi takes unit whichHero, boolean includeBonuses returns integer +native GetHeroInt takes unit whichHero, boolean includeBonuses returns integer + +native UnitStripHeroLevel takes unit whichHero, integer howManyLevels returns boolean + +native GetHeroXP takes unit whichHero returns integer +native SetHeroXP takes unit whichHero, integer newXpVal, boolean showEyeCandy returns nothing + +native GetHeroSkillPoints takes unit whichHero returns integer +native UnitModifySkillPoints takes unit whichHero, integer skillPointDelta returns boolean + +native AddHeroXP takes unit whichHero, integer xpToAdd, boolean showEyeCandy returns nothing +native SetHeroLevel takes unit whichHero, integer level, boolean showEyeCandy returns nothing +constant native GetHeroLevel takes unit whichHero returns integer +constant native GetUnitLevel takes unit whichUnit returns integer +native GetHeroProperName takes unit whichHero returns string +native SuspendHeroXP takes unit whichHero, boolean flag returns nothing +native IsSuspendedXP takes unit whichHero returns boolean +native SelectHeroSkill takes unit whichHero, integer abilcode returns nothing +native GetUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer +native DecUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer +native IncUnitAbilityLevel takes unit whichUnit, integer abilcode returns integer +native SetUnitAbilityLevel takes unit whichUnit, integer abilcode, integer level returns integer +native ReviveHero takes unit whichHero, real x, real y, boolean doEyecandy returns boolean +native ReviveHeroLoc takes unit whichHero, location loc, boolean doEyecandy returns boolean +native SetUnitExploded takes unit whichUnit, boolean exploded returns nothing +native SetUnitInvulnerable takes unit whichUnit, boolean flag returns nothing +native PauseUnit takes unit whichUnit, boolean flag returns nothing +native IsUnitPaused takes unit whichHero returns boolean +native SetUnitPathing takes unit whichUnit, boolean flag returns nothing + +native ClearSelection takes nothing returns nothing +native SelectUnit takes unit whichUnit, boolean flag returns nothing + +native GetUnitPointValue takes unit whichUnit returns integer +native GetUnitPointValueByType takes integer unitType returns integer +//native SetUnitPointValueByType takes integer unitType, integer newPointValue returns nothing + +native UnitAddItem takes unit whichUnit, item whichItem returns boolean +native UnitEquipItem takes unit whichUnit, item whichItem returns boolean +native UnitAddItemById takes unit whichUnit, integer itemId returns item +native UnitAddItemToSlotById takes unit whichUnit, integer itemId, integer itemSlot returns boolean +native UnitRemoveItem takes unit whichUnit, item whichItem returns nothing +native UnitRemoveItemFromSlot takes unit whichUnit, integer itemSlot returns item +native UnitUnequipItem takes unit whichUnit, item whichItem returns nothing +native UnitUnequipItemFromSlot takes unit whichUnit, loadoutslot slot returns item +native UnitHasItem takes unit whichUnit, item whichItem returns boolean +native UnitHasItemBagged takes unit whichUnit, item whichItem returns boolean +native UnitItemInSlot takes unit whichUnit, integer itemSlot returns item +native UnitInventorySize takes unit whichUnit returns integer +native UnitExtendedInventorySize takes unit whichUnit returns integer + +native UnitItemInBagSlot takes unit whichUnit, integer itemSlot returns item +native UnitItemInEquipmentSlot takes unit whichUnit, loadoutslot itemSlot returns item +native UnitHasItemEquipped takes unit whichUnit, item whichItem returns boolean +native UnitHasLoadoutSlotEmpty takes unit whichUnit, loadoutslot itemSlot returns boolean +native UnitHasAnyItemEquiped takes unit whichUnit returns boolean +native UnitHasItemEquipmentOfType takes unit whichUnit, equipmentType equipmentId returns boolean +native UnitCanEquipItemOfEquipmentType takes unit whichUnit, equipmentType equipmentId returns boolean + +native UnitDropItemPoint takes unit whichUnit, item whichItem, real x, real y returns boolean +native UnitDropItemSlot takes unit whichUnit, item whichItem, integer slot returns boolean +native UnitDropItemTarget takes unit whichUnit, item whichItem, widget target returns boolean + +native UnitUseItem takes unit whichUnit, item whichItem returns boolean +native UnitUseItemPoint takes unit whichUnit, item whichItem, real x, real y returns boolean +native UnitUseItemTarget takes unit whichUnit, item whichItem, widget target returns boolean + +constant native GetUnitX takes unit whichUnit returns real +constant native GetUnitY takes unit whichUnit returns real +constant native GetUnitLoc takes unit whichUnit returns location +constant native GetUnitFacing takes unit whichUnit returns real +constant native GetUnitMoveSpeed takes unit whichUnit returns real +constant native GetUnitDefaultMoveSpeed takes unit whichUnit returns real +constant native GetUnitState takes unit whichUnit, unitstate whichUnitState returns real +constant native GetOwningPlayer takes unit whichUnit returns player +constant native GetUnitTypeId takes unit whichUnit returns integer +constant native GetUnitRace takes unit whichUnit returns race +constant native GetUnitName takes unit whichUnit returns string +constant native GetUnitFoodUsed takes unit whichUnit returns integer +constant native GetUnitFoodMade takes unit whichUnit returns integer +constant native GetFoodMade takes integer unitId returns integer +constant native GetFoodUsed takes integer unitId returns integer +native SetUnitUseFood takes unit whichUnit, boolean useFood returns nothing + +constant native GetUnitRallyPoint takes unit whichUnit returns location +constant native GetUnitRallyUnit takes unit whichUnit returns unit +constant native GetUnitRallyDestructable takes unit whichUnit returns destructable + +constant native IsUnitInGroup takes unit whichUnit, group whichGroup returns boolean +constant native IsUnitInForce takes unit whichUnit, force whichForce returns boolean +constant native IsUnitOwnedByPlayer takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitAlly takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitEnemy takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitVisible takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitDetected takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitInvisible takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitFogged takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitMasked takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitSelected takes unit whichUnit, player whichPlayer returns boolean +constant native IsUnitRace takes unit whichUnit, race whichRace returns boolean +constant native IsUnitType takes unit whichUnit, unittype whichUnitType returns boolean +constant native IsUnit takes unit whichUnit, unit whichSpecifiedUnit returns boolean +constant native IsUnitInRange takes unit whichUnit, unit otherUnit, real distance returns boolean +constant native IsUnitInRangeXY takes unit whichUnit, real x, real y, real distance returns boolean +constant native IsUnitInRangeLoc takes unit whichUnit, location whichLocation, real distance returns boolean +constant native IsUnitHidden takes unit whichUnit returns boolean +constant native IsUnitIllusion takes unit whichUnit returns boolean + +constant native IsUnitInTransport takes unit whichUnit, unit whichTransport returns boolean +constant native IsUnitLoaded takes unit whichUnit returns boolean + +constant native IsHeroUnitId takes integer unitId returns boolean +constant native IsUnitIdType takes integer unitId, unittype whichUnitType returns boolean + +native UnitShareVision takes unit whichUnit, player whichPlayer, boolean share returns nothing +native UnitSuspendDecay takes unit whichUnit, boolean suspend returns nothing +native UnitAddType takes unit whichUnit, unittype whichUnitType returns boolean +native UnitRemoveType takes unit whichUnit, unittype whichUnitType returns boolean + +native UnitAddAbility takes unit whichUnit, integer abilityId returns boolean +native UnitRemoveAbility takes unit whichUnit, integer abilityId returns boolean +native UnitMakeAbilityPermanent takes unit whichUnit, boolean permanent, integer abilityId returns boolean +native UnitRemoveBuffs takes unit whichUnit, boolean removePositive, boolean removeNegative returns nothing +native UnitRemoveBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns nothing +native UnitHasBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns boolean +native UnitCountBuffsEx takes unit whichUnit, boolean removePositive, boolean removeNegative, boolean magic, boolean physical, boolean timedLife, boolean aura, boolean autoDispel returns integer +native UnitAddSleep takes unit whichUnit, boolean add returns nothing +native UnitCanSleep takes unit whichUnit returns boolean +native UnitAddSleepPerm takes unit whichUnit, boolean add returns nothing +native UnitCanSleepPerm takes unit whichUnit returns boolean +native UnitIsSleeping takes unit whichUnit returns boolean +native UnitWakeUp takes unit whichUnit returns nothing +native UnitApplyTimedLife takes unit whichUnit, integer buffId, real duration returns nothing +native UnitIgnoreAlarm takes unit whichUnit, boolean flag returns boolean +native UnitIgnoreAlarmToggled takes unit whichUnit returns boolean +native UnitResetCooldown takes unit whichUnit returns nothing +native UnitSetConstructionProgress takes unit whichUnit, integer constructionPercentage returns nothing +native UnitSetUpgradeProgress takes unit whichUnit, integer upgradePercentage returns nothing +native UnitPauseTimedLife takes unit whichUnit, boolean flag returns nothing +native UnitSetUsesAltIcon takes unit whichUnit, boolean flag returns nothing + +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 +native UnitDamageTarget takes unit whichUnit, widget target, real amount, boolean attack, boolean ranged, attacktype attackType, damagetype damageType, weapontype weaponType returns boolean + +native IssueImmediateOrder takes unit whichUnit, string order returns boolean +native IssueImmediateOrderById takes unit whichUnit, integer order returns boolean +native IssuePointOrder takes unit whichUnit, string order, real x, real y returns boolean +native IssuePointOrderLoc takes unit whichUnit, string order, location whichLocation returns boolean +native IssuePointOrderById takes unit whichUnit, integer order, real x, real y returns boolean +native IssuePointOrderByIdLoc takes unit whichUnit, integer order, location whichLocation returns boolean +native IssueTargetOrder takes unit whichUnit, string order, widget targetWidget returns boolean +native IssueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean +native IssueInstantPointOrder takes unit whichUnit, string order, real x, real y, widget instantTargetWidget returns boolean +native IssueInstantPointOrderById takes unit whichUnit, integer order, real x, real y, widget instantTargetWidget returns boolean +native IssueInstantTargetOrder takes unit whichUnit, string order, widget targetWidget, widget instantTargetWidget returns boolean +native IssueInstantTargetOrderById takes unit whichUnit, integer order, widget targetWidget, widget instantTargetWidget returns boolean +native IssueBuildOrder takes unit whichPeon, string unitToBuild, real x, real y returns boolean +native IssueBuildOrderById takes unit whichPeon, integer unitId, real x, real y returns boolean + +native IssueNeutralImmediateOrder takes player forWhichPlayer, unit neutralStructure, string unitToBuild returns boolean +native IssueNeutralImmediateOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId returns boolean +native IssueNeutralPointOrder takes player forWhichPlayer,unit neutralStructure, string unitToBuild, real x, real y returns boolean +native IssueNeutralPointOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, real x, real y returns boolean +native IssueNeutralTargetOrder takes player forWhichPlayer,unit neutralStructure, string unitToBuild, widget target returns boolean +native IssueNeutralTargetOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, widget target returns boolean + +native GetUnitCurrentOrder takes unit whichUnit returns integer + +native SetResourceAmount takes unit whichUnit, integer amount returns nothing +native AddResourceAmount takes unit whichUnit, integer amount returns nothing +native GetResourceAmount takes unit whichUnit returns integer + +native WaygateGetDestinationX takes unit waygate returns real +native WaygateGetDestinationY takes unit waygate returns real +native WaygateSetDestination takes unit waygate, real x, real y returns nothing +native WaygateActivate takes unit waygate, boolean activate returns nothing +native WaygateIsActive takes unit waygate returns boolean + +native AddItemToAllStock takes integer itemId, integer currentStock, integer stockMax returns nothing +native AddItemToStock takes unit whichUnit, integer itemId, integer currentStock, integer stockMax returns nothing +native AddUnitToAllStock takes integer unitId, integer currentStock, integer stockMax returns nothing +native AddUnitToStock takes unit whichUnit, integer unitId, integer currentStock, integer stockMax returns nothing + +native RemoveItemFromAllStock takes integer itemId returns nothing +native RemoveItemFromStock takes unit whichUnit, integer itemId returns nothing +native RemoveUnitFromAllStock takes integer unitId returns nothing +native RemoveUnitFromStock takes unit whichUnit, integer unitId returns nothing + +native SetAllItemTypeSlots takes integer slots returns nothing +native SetAllUnitTypeSlots takes integer slots returns nothing +native SetItemTypeSlots takes unit whichUnit, integer slots returns nothing +native SetUnitTypeSlots takes unit whichUnit, integer slots returns nothing + +native GetUnitUserData takes unit whichUnit returns integer +native SetUnitUserData takes unit whichUnit, integer data returns nothing + +//============================================================================ +// Player API +constant native Player takes integer number returns player +constant native GetLocalPlayer takes nothing returns player +constant native IsPlayerAlly takes player whichPlayer, player otherPlayer returns boolean +constant native IsPlayerEnemy takes player whichPlayer, player otherPlayer returns boolean +constant native IsPlayerInForce takes player whichPlayer, force whichForce returns boolean +constant native IsPlayerObserver takes player whichPlayer returns boolean +constant native IsVisibleToPlayer takes real x, real y, player whichPlayer returns boolean +constant native IsLocationVisibleToPlayer takes location whichLocation, player whichPlayer returns boolean +constant native IsFoggedToPlayer takes real x, real y, player whichPlayer returns boolean +constant native IsLocationFoggedToPlayer takes location whichLocation, player whichPlayer returns boolean +constant native IsMaskedToPlayer takes real x, real y, player whichPlayer returns boolean +constant native IsLocationMaskedToPlayer takes location whichLocation, player whichPlayer returns boolean + +constant native GetPlayerRace takes player whichPlayer returns race +constant native GetPlayerId takes player whichPlayer returns integer +constant native GetPlayerUnitCount takes player whichPlayer, boolean includeIncomplete returns integer +constant native GetPlayerTypedUnitCount takes player whichPlayer, string unitName, boolean includeIncomplete, boolean includeUpgrades returns integer +constant native GetPlayerStructureCount takes player whichPlayer, boolean includeIncomplete returns integer +constant native GetPlayerState takes player whichPlayer, playerstate whichPlayerState returns integer +constant native GetPlayerScore takes player whichPlayer, playerscore whichPlayerScore returns integer +constant native GetPlayerAlliance takes player sourcePlayer, player otherPlayer, alliancetype whichAllianceSetting returns boolean + +constant native GetPlayerHandicap takes player whichPlayer returns real +constant native GetPlayerHandicapXP takes player whichPlayer returns real +constant native GetPlayerHandicapReviveTime takes player whichPlayer returns real +constant native GetPlayerHandicapDamage takes player whichPlayer returns real +constant native SetPlayerHandicap takes player whichPlayer, real handicap returns nothing +constant native SetPlayerHandicapXP takes player whichPlayer, real handicap returns nothing +constant native SetPlayerHandicapReviveTime takes player whichPlayer, real handicap returns nothing +constant native SetPlayerHandicapDamage takes player whichPlayer, real handicap returns nothing + +constant native SetPlayerTechMaxAllowed takes player whichPlayer, integer techid, integer maximum returns nothing +constant native GetPlayerTechMaxAllowed takes player whichPlayer, integer techid returns integer +constant native AddPlayerTechResearched takes player whichPlayer, integer techid, integer levels returns nothing +constant native SetPlayerTechResearched takes player whichPlayer, integer techid, integer setToLevel returns nothing +constant native GetPlayerTechResearched takes player whichPlayer, integer techid, boolean specificonly returns boolean +constant native GetPlayerTechCount takes player whichPlayer, integer techid, boolean specificonly returns integer + +native SetPlayerUnitsOwner takes player whichPlayer, integer newOwner returns nothing +native CripplePlayer takes player whichPlayer, force toWhichPlayers, boolean flag returns nothing + +native SetPlayerAbilityAvailable takes player whichPlayer, integer abilid, boolean avail returns nothing + +native SetPlayerState takes player whichPlayer, playerstate whichPlayerState, integer value returns nothing +native RemovePlayer takes player whichPlayer, playergameresult gameResult returns nothing + +// Used to store hero level data for the scorescreen +// before units are moved to neutral passive in melee games +// +native CachePlayerHeroData takes player whichPlayer returns nothing + +//============================================================================ +// Fog of War API +native SetFogStateRect takes player forWhichPlayer, fogstate whichState, rect where, boolean useSharedVision returns nothing +native SetFogStateRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision returns nothing +native SetFogStateRadiusLoc takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision returns nothing +native FogMaskEnable takes boolean enable returns nothing +native IsFogMaskEnabled takes nothing returns boolean +native FogEnable takes boolean enable returns nothing +native IsFogEnabled takes nothing returns boolean + +native CreateFogModifierRect takes player forWhichPlayer, fogstate whichState, rect where, boolean useSharedVision, boolean afterUnits returns fogmodifier +native CreateFogModifierRadius takes player forWhichPlayer, fogstate whichState, real centerx, real centerY, real radius, boolean useSharedVision, boolean afterUnits returns fogmodifier +native CreateFogModifierRadiusLoc takes player forWhichPlayer, fogstate whichState, location center, real radius, boolean useSharedVision, boolean afterUnits returns fogmodifier +native DestroyFogModifier takes fogmodifier whichFogModifier returns nothing +native FogModifierStart takes fogmodifier whichFogModifier returns nothing +native FogModifierStop takes fogmodifier whichFogModifier returns nothing + +//============================================================================ +// Game API +native VersionGet takes nothing returns version +native VersionCompatible takes version whichVersion returns boolean +native VersionSupported takes version whichVersion returns boolean + +native EndGame takes boolean doScoreScreen returns nothing + +// Async only! +native ChangeLevel takes string newLevel, boolean doScoreScreen returns nothing +native RestartGame takes boolean doScoreScreen returns nothing +native ReloadGame takes nothing returns nothing +// %%% SetCampaignMenuRace is deprecated. It must remain to support +// old maps which use it, but all new maps should use SetCampaignMenuRaceEx +native SetCampaignMenuRace takes race r returns nothing +native SetCampaignMenuRaceEx takes integer campaignIndex returns nothing +native ForceCampaignSelectScreen takes nothing returns nothing + +native LoadGame takes string saveFileName, boolean doScoreScreen returns nothing +native SaveGame takes string saveFileName returns nothing +native RenameSaveDirectory takes string sourceDirName, string destDirName returns boolean +native RemoveSaveDirectory takes string sourceDirName returns boolean +native CopySaveGame takes string sourceSaveName, string destSaveName returns boolean +native SaveGameExists takes string saveName returns boolean +native SetMaxCheckpointSaves takes integer maxCheckpointSaves returns nothing +native SaveGameCheckpoint takes string saveFileName, boolean showWindow returns nothing +native SyncSelections takes nothing returns nothing +native SetFloatGameState takes fgamestate whichFloatGameState, real value returns nothing +constant native GetFloatGameState takes fgamestate whichFloatGameState returns real +native SetIntegerGameState takes igamestate whichIntegerGameState, integer value returns nothing +constant native GetIntegerGameState takes igamestate whichIntegerGameState returns integer + + +//============================================================================ +// Campaign API +native SetTutorialCleared takes boolean cleared returns nothing +native SetMissionAvailable takes integer campaignNumber, integer missionNumber, boolean available returns nothing +native SetCampaignAvailable takes integer campaignNumber, boolean available returns nothing +native SetOpCinematicAvailable takes integer campaignNumber, boolean available returns nothing +native SetEdCinematicAvailable takes integer campaignNumber, boolean available returns nothing +native GetDefaultDifficulty takes nothing returns gamedifficulty +native SetDefaultDifficulty takes gamedifficulty g returns nothing +native SetCustomCampaignButtonVisible takes integer whichButton, boolean visible returns nothing +native GetCustomCampaignButtonVisible takes integer whichButton returns boolean +native DoNotSaveReplay takes nothing returns nothing + +//============================================================================ +// Dialog API +native DialogCreate takes nothing returns dialog +native DialogDestroy takes dialog whichDialog returns nothing +native DialogClear takes dialog whichDialog returns nothing +native DialogSetMessage takes dialog whichDialog, string messageText returns nothing +native DialogAddButton takes dialog whichDialog, string buttonText, integer hotkey returns button +native DialogAddQuitButton takes dialog whichDialog, boolean doScoreScreen, string buttonText, integer hotkey returns button +native DialogDisplay takes player whichPlayer, dialog whichDialog, boolean flag returns nothing + +// Creates a new or reads in an existing game cache file stored +// in the current campaign profile dir +// +native ReloadGameCachesFromDisk takes nothing returns boolean + +native InitGameCache takes string campaignFile returns gamecache +native SaveGameCache takes gamecache whichCache returns boolean + +native StoreInteger takes gamecache cache, string missionKey, string key, integer value returns nothing +native StoreReal takes gamecache cache, string missionKey, string key, real value returns nothing +native StoreBoolean takes gamecache cache, string missionKey, string key, boolean value returns nothing +native StoreUnit takes gamecache cache, string missionKey, string key, unit whichUnit returns boolean +native StoreString takes gamecache cache, string missionKey, string key, string value returns boolean + +native SyncStoredInteger takes gamecache cache, string missionKey, string key returns nothing +native SyncStoredReal takes gamecache cache, string missionKey, string key returns nothing +native SyncStoredBoolean takes gamecache cache, string missionKey, string key returns nothing +native SyncStoredUnit takes gamecache cache, string missionKey, string key returns nothing +native SyncStoredString takes gamecache cache, string missionKey, string key returns nothing + +native HaveStoredInteger takes gamecache cache, string missionKey, string key returns boolean +native HaveStoredReal takes gamecache cache, string missionKey, string key returns boolean +native HaveStoredBoolean takes gamecache cache, string missionKey, string key returns boolean +native HaveStoredUnit takes gamecache cache, string missionKey, string key returns boolean +native HaveStoredString takes gamecache cache, string missionKey, string key returns boolean + +native FlushGameCache takes gamecache cache returns nothing +native FlushStoredMission takes gamecache cache, string missionKey returns nothing +native FlushStoredInteger takes gamecache cache, string missionKey, string key returns nothing +native FlushStoredReal takes gamecache cache, string missionKey, string key returns nothing +native FlushStoredBoolean takes gamecache cache, string missionKey, string key returns nothing +native FlushStoredUnit takes gamecache cache, string missionKey, string key returns nothing +native FlushStoredString takes gamecache cache, string missionKey, string key returns nothing + +// Will return 0 if the specified value's data is not found in the cache +native GetStoredInteger takes gamecache cache, string missionKey, string key returns integer +native GetStoredReal takes gamecache cache, string missionKey, string key returns real +native GetStoredBoolean takes gamecache cache, string missionKey, string key returns boolean +native GetStoredString takes gamecache cache, string missionKey, string key returns string +native RestoreUnit takes gamecache cache, string missionKey, string key, player forWhichPlayer, real x, real y, real facing returns unit + + +native InitHashtable takes nothing returns hashtable + +native SaveInteger takes hashtable table, integer parentKey, integer childKey, integer value returns nothing +native SaveReal takes hashtable table, integer parentKey, integer childKey, real value returns nothing +native SaveBoolean takes hashtable table, integer parentKey, integer childKey, boolean value returns nothing +native SaveStr takes hashtable table, integer parentKey, integer childKey, string value returns boolean +native SavePlayerHandle takes hashtable table, integer parentKey, integer childKey, player whichPlayer returns boolean +native SaveWidgetHandle takes hashtable table, integer parentKey, integer childKey, widget whichWidget returns boolean +native SaveDestructableHandle takes hashtable table, integer parentKey, integer childKey, destructable whichDestructable returns boolean +native SaveItemHandle takes hashtable table, integer parentKey, integer childKey, item whichItem returns boolean +native SaveUnitHandle takes hashtable table, integer parentKey, integer childKey, unit whichUnit returns boolean +native SaveAbilityHandle takes hashtable table, integer parentKey, integer childKey, ability whichAbility returns boolean +native SaveTimerHandle takes hashtable table, integer parentKey, integer childKey, timer whichTimer returns boolean +native SaveTriggerHandle takes hashtable table, integer parentKey, integer childKey, trigger whichTrigger returns boolean +native SaveTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey, triggercondition whichTriggercondition returns boolean +native SaveTriggerActionHandle takes hashtable table, integer parentKey, integer childKey, triggeraction whichTriggeraction returns boolean +native SaveTriggerEventHandle takes hashtable table, integer parentKey, integer childKey, event whichEvent returns boolean +native SaveForceHandle takes hashtable table, integer parentKey, integer childKey, force whichForce returns boolean +native SaveGroupHandle takes hashtable table, integer parentKey, integer childKey, group whichGroup returns boolean +native SaveLocationHandle takes hashtable table, integer parentKey, integer childKey, location whichLocation returns boolean +native SaveRectHandle takes hashtable table, integer parentKey, integer childKey, rect whichRect returns boolean +native SaveBooleanExprHandle takes hashtable table, integer parentKey, integer childKey, boolexpr whichBoolexpr returns boolean +native SaveSoundHandle takes hashtable table, integer parentKey, integer childKey, sound whichSound returns boolean +native SaveEffectHandle takes hashtable table, integer parentKey, integer childKey, effect whichEffect returns boolean +native SaveUnitPoolHandle takes hashtable table, integer parentKey, integer childKey, unitpool whichUnitpool returns boolean +native SaveItemPoolHandle takes hashtable table, integer parentKey, integer childKey, itempool whichItempool returns boolean +native SaveQuestHandle takes hashtable table, integer parentKey, integer childKey, quest whichQuest returns boolean +native SaveQuestItemHandle takes hashtable table, integer parentKey, integer childKey, questitem whichQuestitem returns boolean +native SaveDefeatConditionHandle takes hashtable table, integer parentKey, integer childKey, defeatcondition whichDefeatcondition returns boolean +native SaveTimerDialogHandle takes hashtable table, integer parentKey, integer childKey, timerdialog whichTimerdialog returns boolean +native SaveLeaderboardHandle takes hashtable table, integer parentKey, integer childKey, leaderboard whichLeaderboard returns boolean +native SaveMultiboardHandle takes hashtable table, integer parentKey, integer childKey, multiboard whichMultiboard returns boolean +native SaveMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey, multiboarditem whichMultiboarditem returns boolean +native SaveTrackableHandle takes hashtable table, integer parentKey, integer childKey, trackable whichTrackable returns boolean +native SaveDialogHandle takes hashtable table, integer parentKey, integer childKey, dialog whichDialog returns boolean +native SaveButtonHandle takes hashtable table, integer parentKey, integer childKey, button whichButton returns boolean +native SaveTextTagHandle takes hashtable table, integer parentKey, integer childKey, texttag whichTexttag returns boolean +native SaveLightningHandle takes hashtable table, integer parentKey, integer childKey, lightning whichLightning returns boolean +native SaveImageHandle takes hashtable table, integer parentKey, integer childKey, image whichImage returns boolean +native SaveUbersplatHandle takes hashtable table, integer parentKey, integer childKey, ubersplat whichUbersplat returns boolean +native SaveRegionHandle takes hashtable table, integer parentKey, integer childKey, region whichRegion returns boolean +native SaveFogStateHandle takes hashtable table, integer parentKey, integer childKey, fogstate whichFogState returns boolean +native SaveFogModifierHandle takes hashtable table, integer parentKey, integer childKey, fogmodifier whichFogModifier returns boolean +native SaveAgentHandle takes hashtable table, integer parentKey, integer childKey, agent whichAgent returns boolean +native SaveHashtableHandle takes hashtable table, integer parentKey, integer childKey, hashtable whichHashtable returns boolean +native SaveFrameHandle takes hashtable table, integer parentKey, integer childKey, framehandle whichFrameHandle returns boolean + + +native LoadInteger takes hashtable table, integer parentKey, integer childKey returns integer +native LoadReal takes hashtable table, integer parentKey, integer childKey returns real +native LoadBoolean takes hashtable table, integer parentKey, integer childKey returns boolean +native LoadStr takes hashtable table, integer parentKey, integer childKey returns string +native LoadPlayerHandle takes hashtable table, integer parentKey, integer childKey returns player +native LoadWidgetHandle takes hashtable table, integer parentKey, integer childKey returns widget +native LoadDestructableHandle takes hashtable table, integer parentKey, integer childKey returns destructable +native LoadItemHandle takes hashtable table, integer parentKey, integer childKey returns item +native LoadUnitHandle takes hashtable table, integer parentKey, integer childKey returns unit +native LoadAbilityHandle takes hashtable table, integer parentKey, integer childKey returns ability +native LoadTimerHandle takes hashtable table, integer parentKey, integer childKey returns timer +native LoadTriggerHandle takes hashtable table, integer parentKey, integer childKey returns trigger +native LoadTriggerConditionHandle takes hashtable table, integer parentKey, integer childKey returns triggercondition +native LoadTriggerActionHandle takes hashtable table, integer parentKey, integer childKey returns triggeraction +native LoadTriggerEventHandle takes hashtable table, integer parentKey, integer childKey returns event +native LoadForceHandle takes hashtable table, integer parentKey, integer childKey returns force +native LoadGroupHandle takes hashtable table, integer parentKey, integer childKey returns group +native LoadLocationHandle takes hashtable table, integer parentKey, integer childKey returns location +native LoadRectHandle takes hashtable table, integer parentKey, integer childKey returns rect +native LoadBooleanExprHandle takes hashtable table, integer parentKey, integer childKey returns boolexpr +native LoadSoundHandle takes hashtable table, integer parentKey, integer childKey returns sound +native LoadEffectHandle takes hashtable table, integer parentKey, integer childKey returns effect +native LoadUnitPoolHandle takes hashtable table, integer parentKey, integer childKey returns unitpool +native LoadItemPoolHandle takes hashtable table, integer parentKey, integer childKey returns itempool +native LoadQuestHandle takes hashtable table, integer parentKey, integer childKey returns quest +native LoadQuestItemHandle takes hashtable table, integer parentKey, integer childKey returns questitem +native LoadDefeatConditionHandle takes hashtable table, integer parentKey, integer childKey returns defeatcondition +native LoadTimerDialogHandle takes hashtable table, integer parentKey, integer childKey returns timerdialog +native LoadLeaderboardHandle takes hashtable table, integer parentKey, integer childKey returns leaderboard +native LoadMultiboardHandle takes hashtable table, integer parentKey, integer childKey returns multiboard +native LoadMultiboardItemHandle takes hashtable table, integer parentKey, integer childKey returns multiboarditem +native LoadTrackableHandle takes hashtable table, integer parentKey, integer childKey returns trackable +native LoadDialogHandle takes hashtable table, integer parentKey, integer childKey returns dialog +native LoadButtonHandle takes hashtable table, integer parentKey, integer childKey returns button +native LoadTextTagHandle takes hashtable table, integer parentKey, integer childKey returns texttag +native LoadLightningHandle takes hashtable table, integer parentKey, integer childKey returns lightning +native LoadImageHandle takes hashtable table, integer parentKey, integer childKey returns image +native LoadUbersplatHandle takes hashtable table, integer parentKey, integer childKey returns ubersplat +native LoadRegionHandle takes hashtable table, integer parentKey, integer childKey returns region +native LoadFogStateHandle takes hashtable table, integer parentKey, integer childKey returns fogstate +native LoadFogModifierHandle takes hashtable table, integer parentKey, integer childKey returns fogmodifier +native LoadHashtableHandle takes hashtable table, integer parentKey, integer childKey returns hashtable +native LoadFrameHandle takes hashtable table, integer parentKey, integer childKey returns framehandle + +native HaveSavedInteger takes hashtable table, integer parentKey, integer childKey returns boolean +native HaveSavedReal takes hashtable table, integer parentKey, integer childKey returns boolean +native HaveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns boolean +native HaveSavedString takes hashtable table, integer parentKey, integer childKey returns boolean +native HaveSavedHandle takes hashtable table, integer parentKey, integer childKey returns boolean + +native RemoveSavedInteger takes hashtable table, integer parentKey, integer childKey returns nothing +native RemoveSavedReal takes hashtable table, integer parentKey, integer childKey returns nothing +native RemoveSavedBoolean takes hashtable table, integer parentKey, integer childKey returns nothing +native RemoveSavedString takes hashtable table, integer parentKey, integer childKey returns nothing +native RemoveSavedHandle takes hashtable table, integer parentKey, integer childKey returns nothing + +native FlushParentHashtable takes hashtable table returns nothing +native FlushChildHashtable takes hashtable table, integer parentKey returns nothing + + +//============================================================================ +// Randomization API +native GetRandomInt takes integer lowBound, integer highBound returns integer +native GetRandomReal takes real lowBound, real highBound returns real + +native CreateUnitPool takes nothing returns unitpool +native DestroyUnitPool takes unitpool whichPool returns nothing +native UnitPoolAddUnitType takes unitpool whichPool, integer unitId, real weight returns nothing +native UnitPoolRemoveUnitType takes unitpool whichPool, integer unitId returns nothing +native PlaceRandomUnit takes unitpool whichPool, player forWhichPlayer, real x, real y, real facing returns unit + +native CreateItemPool takes nothing returns itempool +native DestroyItemPool takes itempool whichItemPool returns nothing +native ItemPoolAddItemType takes itempool whichItemPool, integer itemId, real weight returns nothing +native ItemPoolRemoveItemType takes itempool whichItemPool, integer itemId returns nothing +native PlaceRandomItem takes itempool whichItemPool, real x, real y returns item + +// Choose any random unit/item. (NP means Neutral Passive) +native ChooseRandomCreep takes integer level returns integer +native ChooseRandomNPBuilding takes nothing returns integer +native ChooseRandomItem takes integer level returns integer +native ChooseRandomItemEx takes itemtype whichType, integer level returns integer +native ChooseRandomItemExWithFilter takes itemtype whichType, integer level, equipmentType whichEquipmentType, itemTag whichTag returns integer +native SetRandomSeed takes integer seed returns nothing + +//============================================================================ +// Visual API +native SetTerrainFog takes real a, real b, real c, real d, real e returns nothing +native ResetTerrainFog takes nothing returns nothing + +native SetUnitFog takes real a, real b, real c, real d, real e returns nothing +native SetTerrainFogEx takes integer style, real zstart, real zend, real density, real red, real green, real blue returns nothing +native SetTerrainFogExV takes integer style, real zstart, real zend, real density, real heightStart, real heightEnd, real linearStart, real linearEnd, real red, real green, real blue returns nothing +native BlzSetTerrainFogStyle takes fogstyle style returns nothing +native BlzSetTerrainFogZStart takes real zStart returns nothing +native BlzSetTerrainFogZEnd takes real ZEnd returns nothing +native BlzSetTerrainFogDensity takes real density returns nothing +native BlzSetTerrainFogHeightStart takes real heightStart returns nothing +native BlzSetTerrainFogHeightEnd takes real heightEnd returns nothing +native BlzSetTerrainFogLinearStart takes real linearStart returns nothing +native BlzSetTerrainFogLinearEnd takes real linearEnd returns nothing +native BlzSetTerrainFogMaxLinearDensity takes real maxLinearDensity returns nothing +native BlzSetTerrainFogDrawOverSky takes boolean drawOverSky returns nothing +native BlzSetTerrainFogColor takes real red, real green, real blue returns nothing +native DisplayTextToPlayer takes player toPlayer, real x, real y, string message returns nothing +native DisplayTimedTextToPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing +native DisplayTimedTextFromPlayer takes player toPlayer, real x, real y, real duration, string message returns nothing +native ClearTextMessages takes nothing returns nothing +native SetDayNightModels takes string terrainDNCFile, string unitDNCFile returns nothing +native SetPortraitLight takes string portraitDNCFile returns nothing +native SetSkyModel takes string skyModelFile returns nothing +native EnableUserControl takes boolean b returns nothing +native EnableUserUI takes boolean b returns nothing +native SuspendTimeOfDay takes boolean b returns nothing +native SetTimeOfDayScale takes real r returns nothing +native GetTimeOfDayScale takes nothing returns real +native ShowInterface takes boolean flag, real fadeDuration returns nothing +native PauseGame takes boolean flag returns nothing +native UnitAddIndicator takes unit whichUnit, integer red, integer green, integer blue, integer alpha returns nothing +native AddIndicator takes widget whichWidget, integer red, integer green, integer blue, integer alpha returns nothing +native PingMinimap takes real x, real y, real duration returns nothing +native PingMinimapEx takes real x, real y, real duration, integer red, integer green, integer blue, boolean extraEffects returns nothing +native CreateMinimapIconOnUnit takes unit whichUnit, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon +native CreateMinimapIconAtLoc takes location where, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon +native CreateMinimapIcon takes real x, real y, integer red, integer green, integer blue, string pingPath, fogstate fogVisibility returns minimapicon +native SkinManagerGetLocalPath takes string key returns string +native DestroyMinimapIcon takes minimapicon pingId returns nothing +native SetMinimapIconVisible takes minimapicon whichMinimapIcon, boolean visible returns nothing +native SetMinimapIconOrphanDestroy takes minimapicon whichMinimapIcon, boolean doDestroy returns nothing +native EnableOcclusion takes boolean flag returns nothing +native SetIntroShotText takes string introText returns nothing +native SetIntroShotModel takes string introModelPath returns nothing +native EnableWorldFogBoundary takes boolean b returns nothing +native PlayModelCinematic takes string modelName returns nothing +native BlzPreloadModelCinematicGame takes string modelName returns boolean +native BlzGetModelCinematicGameShotCount takes nothing returns integer +native BlzGetModelCinematicGameCurrentShot takes nothing returns integer +native BlzGetModelCinematicGameRemainingTime takes nothing returns real +native BlzPlayModelCinematicGameAtPosition takes string modelName, real posX, real posY, real posZ, real RotZ returns nothing +native BlzSetCinematicEnabledDE takes boolean enable returns nothing +native BlzSetMinShadowCastingPointLightCount takes integer count returns nothing +native BlzGetMinShadowCastingPointLightCount takes nothing returns integer +native PlayCinematic takes string movieName returns nothing +native ForceUIKey takes string key returns nothing +native ForceUICancel takes nothing returns nothing +native DisplayLoadDialog takes nothing returns nothing +native SetAltMinimapIcon takes string iconPath returns nothing +native DisableRestartMission takes boolean flag returns nothing + +native CreateTextTag takes nothing returns texttag +native DestroyTextTag takes texttag t returns nothing +native SetTextTagText takes texttag t, string s, real height returns nothing +native SetTextTagPos takes texttag t, real x, real y, real heightOffset returns nothing +native SetTextTagPosUnit takes texttag t, unit whichUnit, real heightOffset returns nothing +native SetTextTagColor takes texttag t, integer red, integer green, integer blue, integer alpha returns nothing +native SetTextTagVelocity takes texttag t, real xvel, real yvel returns nothing +native SetTextTagVisibility takes texttag t, boolean flag returns nothing +native SetTextTagSuspended takes texttag t, boolean flag returns nothing +native SetTextTagPermanent takes texttag t, boolean flag returns nothing +native SetTextTagAge takes texttag t, real age returns nothing +native SetTextTagLifespan takes texttag t, real lifespan returns nothing +native SetTextTagFadepoint takes texttag t, real fadepoint returns nothing + +native SetReservedLocalHeroButtons takes integer reserved returns nothing +native GetAllyColorFilterState takes nothing returns integer +native SetAllyColorFilterState takes integer state returns nothing +native GetCreepCampFilterState takes nothing returns boolean +native SetCreepCampFilterState takes boolean state returns nothing +native EnableMinimapFilterButtons takes boolean enableAlly, boolean enableCreep returns nothing +native EnableDragSelect takes boolean state, boolean ui returns nothing +native EnablePreSelect takes boolean state, boolean ui returns nothing +native EnableSelect takes boolean state, boolean ui returns nothing + +//============================================================================ +// Trackable API +native CreateTrackable takes string trackableModelPath, real x, real y, real facing returns trackable + +//============================================================================ +// Quest API +native CreateQuest takes nothing returns quest +native DestroyQuest takes quest whichQuest returns nothing +native QuestSetTitle takes quest whichQuest, string title returns nothing +native QuestSetDescription takes quest whichQuest, string description returns nothing +native QuestSetIconPath takes quest whichQuest, string iconPath returns nothing + +native QuestSetRequired takes quest whichQuest, boolean required returns nothing +native QuestSetCompleted takes quest whichQuest, boolean completed returns nothing +native QuestSetDiscovered takes quest whichQuest, boolean discovered returns nothing +native QuestSetFailed takes quest whichQuest, boolean failed returns nothing +native QuestSetEnabled takes quest whichQuest, boolean enabled returns nothing + +native IsQuestRequired takes quest whichQuest returns boolean +native IsQuestCompleted takes quest whichQuest returns boolean +native IsQuestDiscovered takes quest whichQuest returns boolean +native IsQuestFailed takes quest whichQuest returns boolean +native IsQuestEnabled takes quest whichQuest returns boolean + +native QuestCreateItem takes quest whichQuest returns questitem +native QuestItemSetDescription takes questitem whichQuestItem, string description returns nothing +native QuestItemSetCompleted takes questitem whichQuestItem, boolean completed returns nothing + +native IsQuestItemCompleted takes questitem whichQuestItem returns boolean + +native CreateDefeatCondition takes nothing returns defeatcondition +native DestroyDefeatCondition takes defeatcondition whichCondition returns nothing +native DefeatConditionSetDescription takes defeatcondition whichCondition, string description returns nothing + +native FlashQuestDialogButton takes nothing returns nothing +native ForceQuestDialogUpdate takes nothing returns nothing + +//============================================================================ +// Timer Dialog API +native CreateTimerDialog takes timer t returns timerdialog +native DestroyTimerDialog takes timerdialog whichDialog returns nothing +native TimerDialogSetTitle takes timerdialog whichDialog, string title returns nothing +native TimerDialogSetTitleColor takes timerdialog whichDialog, integer red, integer green, integer blue, integer alpha returns nothing +native TimerDialogSetTimeColor takes timerdialog whichDialog, integer red, integer green, integer blue, integer alpha returns nothing +native TimerDialogSetSpeed takes timerdialog whichDialog, real speedMultFactor returns nothing +native TimerDialogDisplay takes timerdialog whichDialog, boolean display returns nothing +native IsTimerDialogDisplayed takes timerdialog whichDialog returns boolean +native TimerDialogSetRealTimeRemaining takes timerdialog whichDialog, real timeRemaining returns nothing + +//============================================================================ +// Leaderboard API + +// Create a leaderboard object +native CreateLeaderboard takes nothing returns leaderboard +native DestroyLeaderboard takes leaderboard lb returns nothing + +native LeaderboardDisplay takes leaderboard lb, boolean show returns nothing +native IsLeaderboardDisplayed takes leaderboard lb returns boolean + +native LeaderboardGetItemCount takes leaderboard lb returns integer + +native LeaderboardSetSizeByItemCount takes leaderboard lb, integer count returns nothing +native LeaderboardAddItem takes leaderboard lb, string label, integer value, player p returns nothing +native LeaderboardRemoveItem takes leaderboard lb, integer index returns nothing +native LeaderboardRemovePlayerItem takes leaderboard lb, player p returns nothing +native LeaderboardClear takes leaderboard lb returns nothing + +native LeaderboardSortItemsByValue takes leaderboard lb, boolean ascending returns nothing +native LeaderboardSortItemsByPlayer takes leaderboard lb, boolean ascending returns nothing +native LeaderboardSortItemsByLabel takes leaderboard lb, boolean ascending returns nothing + +native LeaderboardHasPlayerItem takes leaderboard lb, player p returns boolean +native LeaderboardGetPlayerIndex takes leaderboard lb, player p returns integer +native LeaderboardSetLabel takes leaderboard lb, string label returns nothing +native LeaderboardGetLabelText takes leaderboard lb returns string + +native PlayerSetLeaderboard takes player toPlayer, leaderboard lb returns nothing +native PlayerGetLeaderboard takes player toPlayer returns leaderboard + +native LeaderboardSetLabelColor takes leaderboard lb, integer red, integer green, integer blue, integer alpha returns nothing +native LeaderboardSetValueColor takes leaderboard lb, integer red, integer green, integer blue, integer alpha returns nothing +native LeaderboardSetStyle takes leaderboard lb, boolean showLabel, boolean showNames, boolean showValues, boolean showIcons returns nothing + +native LeaderboardSetItemValue takes leaderboard lb, integer whichItem, integer val returns nothing +native LeaderboardSetItemLabel takes leaderboard lb, integer whichItem, string val returns nothing +native LeaderboardSetItemStyle takes leaderboard lb, integer whichItem, boolean showLabel, boolean showValue, boolean showIcon returns nothing +native LeaderboardSetItemLabelColor takes leaderboard lb, integer whichItem, integer red, integer green, integer blue, integer alpha returns nothing +native LeaderboardSetItemValueColor takes leaderboard lb, integer whichItem, integer red, integer green, integer blue, integer alpha returns nothing + +//============================================================================ +// Multiboard API +//============================================================================ + +// Create a multiboard object +native CreateMultiboard takes nothing returns multiboard +native DestroyMultiboard takes multiboard lb returns nothing + +native MultiboardDisplay takes multiboard lb, boolean show returns nothing +native IsMultiboardDisplayed takes multiboard lb returns boolean + +native MultiboardMinimize takes multiboard lb, boolean minimize returns nothing +native IsMultiboardMinimized takes multiboard lb returns boolean +native MultiboardClear takes multiboard lb returns nothing + +native MultiboardSetTitleText takes multiboard lb, string label returns nothing +native MultiboardGetTitleText takes multiboard lb returns string +native MultiboardSetTitleTextColor takes multiboard lb, integer red, integer green, integer blue, integer alpha returns nothing + +native MultiboardGetRowCount takes multiboard lb returns integer +native MultiboardGetColumnCount takes multiboard lb returns integer + +native MultiboardSetColumnCount takes multiboard lb, integer count returns nothing +native MultiboardSetRowCount takes multiboard lb, integer count returns nothing + +// broadcast settings to all items +native MultiboardSetItemsStyle takes multiboard lb, boolean showValues, boolean showIcons returns nothing +native MultiboardSetItemsValue takes multiboard lb, string value returns nothing +native MultiboardSetItemsValueColor takes multiboard lb, integer red, integer green, integer blue, integer alpha returns nothing +native MultiboardSetItemsWidth takes multiboard lb, real width returns nothing +native MultiboardSetItemsIcon takes multiboard lb, string iconPath returns nothing + + +// funcs for modifying individual items +native MultiboardGetItem takes multiboard lb, integer row, integer column returns multiboarditem +native MultiboardReleaseItem takes multiboarditem mbi returns nothing + +native MultiboardSetItemStyle takes multiboarditem mbi, boolean showValue, boolean showIcon returns nothing +native MultiboardSetItemValue takes multiboarditem mbi, string val returns nothing +native MultiboardSetItemValueColor takes multiboarditem mbi, integer red, integer green, integer blue, integer alpha returns nothing +native MultiboardSetItemWidth takes multiboarditem mbi, real width returns nothing +native MultiboardSetItemIcon takes multiboarditem mbi, string iconFileName returns nothing + +// meant to unequivocally suspend display of existing and +// subsequently displayed multiboards +// +native MultiboardSuppressDisplay takes boolean flag returns nothing + +//============================================================================ +// Camera API +native SetCameraPosition takes real x, real y returns nothing +native SetCameraQuickPosition takes real x, real y returns nothing +native SetCameraBounds takes real x1, real y1, real x2, real y2, real x3, real y3, real x4, real y4 returns nothing +native StopCamera takes nothing returns nothing +native ResetToGameCamera takes real duration returns nothing +native PanCameraTo takes real x, real y returns nothing +native PanCameraToTimed takes real x, real y, real duration returns nothing +native PanCameraToWithZ takes real x, real y, real zOffsetDest returns nothing +native PanCameraToTimedWithZ takes real x, real y, real zOffsetDest, real duration returns nothing +native SetCinematicCamera takes string cameraModelFile returns nothing +native SetCameraRotateMode takes real x, real y, real radiansToSweep, real duration returns nothing +native SetCameraField takes camerafield whichField, real value, real duration returns nothing +native AdjustCameraField takes camerafield whichField, real offset, real duration returns nothing +native SetCameraFieldControlledByInput takes camerafield whichField, boolean controlled returns nothing +native GetCameraFieldControlledByInput takes camerafield whichField returns boolean +native SetCameraTargetController takes unit whichUnit, real xoffset, real yoffset, boolean inheritOrientation returns nothing +native SetCameraOrientController takes unit whichUnit, real xoffset, real yoffset returns nothing +native BlzCameraSetCameraType takes integer cameraType returns nothing +native BlzCameraGetCameraType takes nothing returns integer + +native CreateCameraSetup takes nothing returns camerasetup +native CameraSetupSetField takes camerasetup whichSetup, camerafield whichField, real value, real duration returns nothing +native CameraSetupGetField takes camerasetup whichSetup, camerafield whichField returns real +native CameraSetupSetDestPosition takes camerasetup whichSetup, real x, real y, real duration returns nothing +native CameraSetupGetDestPositionLoc takes camerasetup whichSetup returns location +native CameraSetupGetDestPositionX takes camerasetup whichSetup returns real +native CameraSetupGetDestPositionY takes camerasetup whichSetup returns real +native CameraSetupApply takes camerasetup whichSetup, boolean doPan, boolean panTimed returns nothing +native CameraSetupApplyWithZ takes camerasetup whichSetup, real zDestOffset returns nothing +native CameraSetupApplyForceDuration takes camerasetup whichSetup, boolean doPan, real forceDuration returns nothing +native CameraSetupApplyForceDurationWithZ takes camerasetup whichSetup, real zDestOffset, real forceDuration returns nothing +native BlzCameraSetupSetLabel takes camerasetup whichSetup, string label returns nothing +native BlzCameraSetupGetLabel takes camerasetup whichSetup returns string +native BlzCameraSetupSetCameraType takes camerasetup whichSetup, integer cameraType returns nothing +native BlzCameraSetupGetCameraType takes camerasetup whichSetup returns integer + +native CameraSetTargetNoise takes real mag, real velocity returns nothing +native CameraSetSourceNoise takes real mag, real velocity returns nothing + +native CameraSetTargetNoiseEx takes real mag, real velocity, boolean vertOnly returns nothing +native CameraSetSourceNoiseEx takes real mag, real velocity, boolean vertOnly returns nothing + +native CameraSetSmoothingFactor takes real factor returns nothing + +native CameraSetFocalDistance takes real distance returns nothing +native CameraSetDepthOfFieldScale takes real scale returns nothing + +native SetCineFilterTexture takes string filename returns nothing +native SetCineFilterBlendMode takes blendmode whichMode returns nothing +native SetCineFilterTexMapFlags takes texmapflags whichFlags returns nothing +native SetCineFilterStartUV takes real minu, real minv, real maxu, real maxv returns nothing +native SetCineFilterEndUV takes real minu, real minv, real maxu, real maxv returns nothing +native SetCineFilterStartColor takes integer red, integer green, integer blue, integer alpha returns nothing +native SetCineFilterEndColor takes integer red, integer green, integer blue, integer alpha returns nothing +native SetCineFilterDuration takes real duration returns nothing +native DisplayCineFilter takes boolean flag returns nothing +native IsCineFilterDisplayed takes nothing returns boolean + +native SetCinematicScene takes integer portraitUnitId, playercolor color, string speakerTitle, string text, real sceneDuration, real voiceoverDuration returns nothing +native EndCinematicScene takes nothing returns nothing +native ForceCinematicSubtitles takes boolean flag returns nothing +native SetCinematicAudio takes boolean cinematicAudio returns nothing + +native GetCameraMargin takes integer whichMargin returns real + +native EnableCameraBlocker takes rect r, boolean flag returns nothing +native AddCameraBlocker takes rect where returns nothing + +// These return values for the local players camera only... +constant native GetCameraBoundMinX takes nothing returns real +constant native GetCameraBoundMinY takes nothing returns real +constant native GetCameraBoundMaxX takes nothing returns real +constant native GetCameraBoundMaxY takes nothing returns real +constant native GetCameraField takes camerafield whichField returns real +constant native GetCameraTargetPositionX takes nothing returns real +constant native GetCameraTargetPositionY takes nothing returns real +constant native GetCameraTargetPositionZ takes nothing returns real +constant native GetCameraTargetPositionLoc takes nothing returns location +constant native GetCameraEyePositionX takes nothing returns real +constant native GetCameraEyePositionY takes nothing returns real +constant native GetCameraEyePositionZ takes nothing returns real +constant native GetCameraEyePositionLoc takes nothing returns location + +//============================================================================ +// Sound API +// +native NewSoundEnvironment takes string environmentName returns nothing + +native CreateSound takes string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string eaxSetting returns sound +native CreateSoundFilenameWithLabel takes string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string SLKEntryName returns sound +native CreateSoundFromLabel takes string soundLabel, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate returns sound +native CreateMIDISound takes string soundLabel, integer fadeInRate, integer fadeOutRate returns sound + +native SetSoundParamsFromLabel takes sound soundHandle, string soundLabel returns nothing +native SetSoundDistanceCutoff takes sound soundHandle, real cutoff returns nothing +native SetSoundChannel takes sound soundHandle, integer channel returns nothing +native SetSoundVolume takes sound soundHandle, integer volume returns nothing +native SetSoundPitch takes sound soundHandle, real pitch returns nothing + +// the following method must be called immediately after calling "StartSound" +native SetSoundPlayPosition takes sound soundHandle, integer millisecs returns nothing + +// these calls are only valid if the sound was created with 3d enabled +native SetSoundDistances takes sound soundHandle, real minDist, real maxDist returns nothing +native SetSoundConeAngles takes sound soundHandle, real inside, real outside, integer outsideVolume returns nothing +native SetSoundConeOrientation takes sound soundHandle, real x, real y, real z returns nothing +native SetSoundPosition takes sound soundHandle, real x, real y, real z returns nothing +native SetSoundVelocity takes sound soundHandle, real x, real y, real z returns nothing +native AttachSoundToUnit takes sound soundHandle, unit whichUnit returns nothing + +native StartSound takes sound soundHandle returns nothing +native StartSoundEx takes sound soundHandle, boolean fadeIn returns nothing +native StopSound takes sound soundHandle, boolean killWhenDone, boolean fadeOut returns nothing +native KillSoundWhenDone takes sound soundHandle returns nothing + +// Music Interface. Note that if music is disabled, these calls do nothing +native SetMapMusic takes string musicName, boolean random, integer index returns nothing +native ClearMapMusic takes nothing returns nothing + +native PlayMusic takes string musicName returns nothing +native PlayMusicEx takes string musicName, integer frommsecs, integer fadeinmsecs returns nothing +native StopMusic takes boolean fadeOut returns nothing +native ResumeMusic takes nothing returns nothing + +native PlayThematicMusic takes string musicFileName returns nothing +native PlayThematicMusicEx takes string musicFileName, integer frommsecs returns nothing +native BlzPauseThematicMusicOnFocusLost takes boolean pause returns nothing +native EndThematicMusic takes nothing returns nothing + +native SetMusicVolume takes integer volume returns nothing +native SetMusicPlayPosition takes integer millisecs returns nothing +native SetThematicMusicVolume takes integer volume returns nothing +native SetThematicMusicPlayPosition takes integer millisecs returns nothing + +// other music and sound calls +native SetSoundDuration takes sound soundHandle, integer duration returns nothing +native GetSoundDuration takes sound soundHandle returns integer +native GetSoundFileDuration takes string musicFileName returns integer + +native VolumeGroupSetVolume takes volumegroup vgroup, real scale returns nothing +native VolumeGroupReset takes nothing returns nothing + +native GetSoundIsPlaying takes sound soundHandle returns boolean +native GetSoundIsLoading takes sound soundHandle returns boolean + +native RegisterStackedSound takes sound soundHandle, boolean byPosition, real rectwidth, real rectheight returns nothing +native UnregisterStackedSound takes sound soundHandle, boolean byPosition, real rectwidth, real rectheight returns nothing + +native SetSoundFacialAnimationLabel takes sound soundHandle, string animationLabel returns boolean +native SetSoundFacialAnimationGroupLabel takes sound soundHandle, string groupLabel returns boolean +native SetSoundFacialAnimationSetFilepath takes sound soundHandle, string animationSetFilepath returns boolean + +//Subtitle support that is attached to the soundHandle rather than as disperate data with the legacy UI +native SetDialogueSpeakerNameKey takes sound soundHandle, string speakerName returns boolean +native GetDialogueSpeakerNameKey takes sound soundHandle returns string +native SetDialogueTextKey takes sound soundHandle, string dialogueText returns boolean +native GetDialogueTextKey takes sound soundHandle returns string + +//============================================================================ +// Effects API +// +native AddWeatherEffect takes rect where, integer effectID returns weathereffect +native RemoveWeatherEffect takes weathereffect whichEffect returns nothing +native EnableWeatherEffect takes weathereffect whichEffect, boolean enable returns nothing + +native TerrainDeformCrater takes real x, real y, real radius, real depth, integer duration, boolean permanent returns terraindeformation +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 +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 +native TerrainDeformRandom takes real x, real y, real radius, real minDelta, real maxDelta, integer duration, integer updateInterval returns terraindeformation +native TerrainDeformStop takes terraindeformation deformation, integer duration returns nothing +native TerrainDeformStopAll takes nothing returns nothing + +native AddSpecialEffect takes string modelName, real x, real y returns effect +native AddSpecialEffectLoc takes string modelName, location where returns effect +native AddSpecialEffectTarget takes string modelName, widget targetWidget, string attachPointName returns effect +native DestroyEffect takes effect whichEffect returns nothing + +native AddSpellEffect takes string abilityString, effecttype t, real x, real y returns effect +native AddSpellEffectLoc takes string abilityString, effecttype t,location where returns effect +native AddSpellEffectById takes integer abilityId, effecttype t,real x, real y returns effect +native AddSpellEffectByIdLoc takes integer abilityId, effecttype t,location where returns effect +native AddSpellEffectTarget takes string modelName, effecttype t, widget targetWidget, string attachPoint returns effect +native AddSpellEffectTargetById takes integer abilityId, effecttype t, widget targetWidget, string attachPoint returns effect + +native AddLightning takes string codeName, boolean checkVisibility, real x1, real y1, real x2, real y2 returns lightning +native AddLightningEx takes string codeName, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns lightning +native DestroyLightning takes lightning whichBolt returns boolean +native MoveLightning takes lightning whichBolt, boolean checkVisibility, real x1, real y1, real x2, real y2 returns boolean +native MoveLightningEx takes lightning whichBolt, boolean checkVisibility, real x1, real y1, real z1, real x2, real y2, real z2 returns boolean +native GetLightningColorA takes lightning whichBolt returns real +native GetLightningColorR takes lightning whichBolt returns real +native GetLightningColorG takes lightning whichBolt returns real +native GetLightningColorB takes lightning whichBolt returns real +native SetLightningColor takes lightning whichBolt, real r, real g, real b, real a returns boolean + +native GetAbilityEffect takes string abilityString, effecttype t, integer index returns string +native GetAbilityEffectById takes integer abilityId, effecttype t, integer index returns string +native GetAbilitySound takes string abilityString, soundtype t returns string +native GetAbilitySoundById takes integer abilityId, soundtype t returns string + +//============================================================================ +// Terrain API +// +native GetTerrainCliffLevel takes real x, real y returns integer +native SetWaterBaseColor takes integer red, integer green, integer blue, integer alpha returns nothing +native SetHDWaterParams takes integer red, integer green, integer blue, boolean useColor, integer vertexDisplacement, integer minOpacity, integer maxOpacity, integer reflectivity, integer emissivity, integer edgeSoftness, integer waveStrength returns nothing +native SetHDWaterParamsEx takes integer red, integer green, integer blue, boolean override, integer vertexDisplacement, integer minOpacity, integer maxOpacity, integer reflectivity, integer emissivity, integer edgeSoftness, integer waveStrength, integer envMapStrength returns nothing +native BlzSetHDWaterColor takes integer red, integer green, integer blue returns nothing +native BlzSetHDWaterColorOverride takes boolean override returns nothing +native BlzSetHDWaterVertexDisplacement takes integer vertexDisplacement returns nothing +native BlzSetHDWaterMinOpacity takes integer minOpacity returns nothing +native BlzSetHDWaterMaxOpacity takes integer maxOpacity returns nothing +native BlzSetHDWaterReflectivity takes integer reflectivity returns nothing +native BlzSetHDWaterEmissivity takes integer emissivity returns nothing +native BlzSetHDWaterEdgeSoftness takes integer edgeSoftness returns nothing +native BlzSetHDWaterWaveStrength takes integer waveStrength returns nothing +native BlzSetHDWaterEnvMapStrength takes integer envMapStrengthy returns nothing +native SetWaterDeforms takes boolean val returns nothing +native GetTerrainType takes real x, real y returns integer +native GetTerrainVariance takes real x, real y returns integer +native SetTerrainType takes real x, real y, integer terrainType, integer variation, integer area, integer shape returns nothing +native IsTerrainPathable takes real x, real y, pathingtype t returns boolean +native BlzIsTerrainPathableEx takes real x, real y, pathingtype t returns boolean +native SetTerrainPathable takes real x, real y, pathingtype t, boolean flag returns nothing + +//============================================================================ +// Image API +// +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 +native DestroyImage takes image whichImage returns nothing +native ShowImage takes image whichImage, boolean flag returns nothing +native SetImageConstantHeight takes image whichImage, boolean flag, real height returns nothing +native SetImagePosition takes image whichImage, real x, real y, real z returns nothing +native SetImageColor takes image whichImage, integer red, integer green, integer blue, integer alpha returns nothing +native SetImageRender takes image whichImage, boolean flag returns nothing +native SetImageRenderAlways takes image whichImage, boolean flag returns nothing +native SetImageAboveWater takes image whichImage, boolean flag, boolean useWaterAlpha returns nothing +native SetImageType takes image whichImage, integer imageType returns nothing + +//============================================================================ +// Ubersplat API +// +native CreateUbersplat takes real x, real y, string name, integer red, integer green, integer blue, integer alpha, boolean forcePaused, boolean noBirthTime returns ubersplat +native DestroyUbersplat takes ubersplat whichSplat returns nothing +native ResetUbersplat takes ubersplat whichSplat returns nothing +native FinishUbersplat takes ubersplat whichSplat returns nothing +native ShowUbersplat takes ubersplat whichSplat, boolean flag returns nothing +native SetUbersplatRender takes ubersplat whichSplat, boolean flag returns nothing +native SetUbersplatRenderAlways takes ubersplat whichSplat, boolean flag returns nothing + +//============================================================================ +// Blight API +// +native SetBlight takes player whichPlayer, real x, real y, real radius, boolean addBlight returns nothing +native SetBlightRect takes player whichPlayer, rect r, boolean addBlight returns nothing +native SetBlightPoint takes player whichPlayer, real x, real y, boolean addBlight returns nothing +native SetBlightLoc takes player whichPlayer, location whichLocation, real radius, boolean addBlight returns nothing +native CreateBlightedGoldmine takes player id, real x, real y, real face returns unit +native IsPointBlighted takes real x, real y returns boolean + +//============================================================================ +// Doodad API +// +native SetDoodadAnimation takes real x, real y, real radius, integer doodadID, boolean nearestOnly, string animName, boolean animRandom returns nothing +native SetDoodadAnimationRect takes rect r, integer doodadID, string animName, boolean animRandom returns nothing +native BlzSetSingleDoodadAnimation takes integer index, string animName, boolean animRandom returns nothing +native SetDoodadColor takes real x, real y, real radius, integer doodadID, boolean nearestOnly, playercolor whichColor returns nothing +native SetDoodadColorRect takes rect r, integer doodadID, playercolor whichColor returns nothing +native BlzSetSingleDoodadColor takes integer index, playercolor whichColor returns nothing +native BlzGetDoodadX takes integer index returns real +native BlzGetDoodadY takes integer index returns real +native BlzGetDoodadZ takes integer index returns real +native BlzGetDoodadScaleX takes integer index returns real +native BlzGetDoodadScaleY takes integer index returns real +native BlzGetDoodadScaleZ takes integer index returns real +native BlzGetDoodadIsUsingModelAxes takes integer index returns boolean +native BlzGetDoodadYaw takes integer index returns real +native BlzGetDoodadPitch takes integer index returns real +native BlzGetDoodadRoll takes integer index returns real +native BlzGetDoodadVariation takes integer index returns integer +native BlzGetDoodadId takes integer index returns integer +native BlzGetNumDoodads takes nothing returns integer + +//============================================================================ +// Computer AI interface +// +native StartMeleeAI takes player num, string script returns nothing +native StartCampaignAI takes player num, string script returns nothing +native CommandAI takes player num, integer command, integer data returns nothing +native PauseCompAI takes player p, boolean pause returns nothing +native GetAIDifficulty takes player num returns aidifficulty + +native RemoveGuardPosition takes unit hUnit returns nothing +native RecycleGuardPosition takes unit hUnit returns nothing +native RemoveAllGuardPositions takes player num returns nothing + +//============================================================================ +native Cheat takes string cheatStr returns nothing +native IsNoVictoryCheat takes nothing returns boolean +native IsNoDefeatCheat takes nothing returns boolean + +native Preload takes string filename returns nothing +native PreloadEnd takes real timeout returns nothing + +native PreloadStart takes nothing returns nothing +native PreloadRefresh takes nothing returns nothing +native PreloadEndEx takes nothing returns nothing + +native PreloadGenClear takes nothing returns nothing +native PreloadGenStart takes nothing returns nothing +native PreloadGenEnd takes string filename returns nothing +native Preloader takes string filename returns nothing + + +//============================================================================ +//Machinima API +//============================================================================ +native BlzHideCinematicPanels takes boolean enable returns nothing + + +// Automation Test +native AutomationSetTestType takes string testType returns nothing +native AutomationTestStart takes string testName returns nothing +native AutomationTestEnd takes nothing returns nothing +native AutomationTestingFinished takes nothing returns nothing + +// JAPI Functions +native BlzGetTriggerPlayerMouseX takes nothing returns real +native BlzGetTriggerPlayerMouseY takes nothing returns real +native BlzGetTriggerPlayerMousePosition takes nothing returns location +native BlzGetTriggerPlayerMouseButton takes nothing returns mousebuttontype +native BlzSetAbilityTooltip takes integer abilCode, string tooltip, integer level returns nothing +native BlzSetAbilityActivatedTooltip takes integer abilCode, string tooltip, integer level returns nothing +native BlzSetAbilityExtendedTooltip takes integer abilCode, string extendedTooltip, integer level returns nothing +native BlzSetAbilityActivatedExtendedTooltip takes integer abilCode, string extendedTooltip, integer level returns nothing +native BlzSetAbilityResearchTooltip takes integer abilCode, string researchTooltip, integer level returns nothing +native BlzSetAbilityResearchExtendedTooltip takes integer abilCode, string researchExtendedTooltip, integer level returns nothing +native BlzGetAbilityTooltip takes integer abilCode, integer level returns string +native BlzGetAbilityActivatedTooltip takes integer abilCode, integer level returns string +native BlzGetAbilityExtendedTooltip takes integer abilCode, integer level returns string +native BlzGetAbilityActivatedExtendedTooltip takes integer abilCode, integer level returns string +native BlzGetAbilityResearchTooltip takes integer abilCode, integer level returns string +native BlzGetAbilityResearchExtendedTooltip takes integer abilCode, integer level returns string +native BlzSetAbilityIcon takes integer abilCode, string iconPath returns nothing +native BlzGetAbilityIcon takes integer abilCode returns string +native BlzSetAbilityActivatedIcon takes integer abilCode, string iconPath returns nothing +native BlzGetAbilityActivatedIcon takes integer abilCode returns string +native BlzGetAbilityPosX takes integer abilCode returns integer +native BlzGetAbilityPosY takes integer abilCode returns integer +native BlzSetAbilityPosX takes integer abilCode, integer x returns nothing +native BlzSetAbilityPosY takes integer abilCode, integer y returns nothing +native BlzGetAbilityActivatedPosX takes integer abilCode returns integer +native BlzGetAbilityActivatedPosY takes integer abilCode returns integer +native BlzSetAbilityActivatedPosX takes integer abilCode, integer x returns nothing +native BlzSetAbilityActivatedPosY takes integer abilCode, integer y returns nothing +native BlzGetUnitMaxHP takes unit whichUnit returns integer +native BlzSetUnitMaxHP takes unit whichUnit, integer hp returns nothing +native BlzGetUnitMaxMana takes unit whichUnit returns integer +native BlzSetUnitMaxMana takes unit whichUnit, integer mana returns nothing +native BlzSetItemName takes item whichItem, string name returns nothing +native BlzSetItemDescription takes item whichItem, string description returns nothing +native BlzGetItemDescription takes item whichItem returns string +native BlzSetItemTooltip takes item whichItem, string tooltip returns nothing +native BlzGetItemTooltip takes item whichItem returns string +native BlzSetItemExtendedTooltip takes item whichItem, string extendedTooltip returns nothing +native BlzGetItemExtendedTooltip takes item whichItem returns string +native BlzSetItemIconPath takes item whichItem, string iconPath returns nothing +native BlzGetItemIconPath takes item whichItem returns string +native BlzSetUnitName takes unit whichUnit, string name returns nothing +native BlzSetHeroProperName takes unit whichUnit, string heroProperName returns nothing +native BlzGetUnitBaseDamage takes unit whichUnit, integer weaponIndex returns integer +native BlzSetUnitBaseDamage takes unit whichUnit, integer baseDamage, integer weaponIndex returns nothing +native BlzGetUnitDiceNumber takes unit whichUnit, integer weaponIndex returns integer +native BlzSetUnitDiceNumber takes unit whichUnit, integer diceNumber, integer weaponIndex returns nothing +native BlzGetUnitDiceSides takes unit whichUnit, integer weaponIndex returns integer +native BlzSetUnitDiceSides takes unit whichUnit, integer diceSides, integer weaponIndex returns nothing +native BlzGetUnitAttackCooldown takes unit whichUnit, integer weaponIndex returns real +native BlzSetUnitAttackCooldown takes unit whichUnit, real cooldown, integer weaponIndex returns nothing +native BlzResetUnitAttack takes unit whichUnit, integer weaponIndex returns nothing +native BlzSetSpecialEffectColorByPlayer takes effect whichEffect, player whichPlayer returns nothing +native BlzSetSpecialEffectColor takes effect whichEffect, integer r, integer g, integer b returns nothing +native BlzSetSpecialEffectAlpha takes effect whichEffect, integer alpha returns nothing +native BlzSetSpecialEffectScale takes effect whichEffect, real scale returns nothing +native BlzSetSpecialEffectPosition takes effect whichEffect, real x, real y, real z returns nothing +native BlzSetSpecialEffectHeight takes effect whichEffect, real height returns nothing +native BlzSetSpecialEffectTimeScale takes effect whichEffect, real timeScale returns nothing +native BlzSetSpecialEffectTime takes effect whichEffect, real time returns nothing +native BlzSetSpecialEffectOrientation takes effect whichEffect, real yaw, real pitch, real roll returns nothing +native BlzSetSpecialEffectYaw takes effect whichEffect, real yaw returns nothing +native BlzSetSpecialEffectPitch takes effect whichEffect, real pitch returns nothing +native BlzSetSpecialEffectRoll takes effect whichEffect, real roll returns nothing +native BlzSetSpecialEffectX takes effect whichEffect, real x returns nothing +native BlzSetSpecialEffectY takes effect whichEffect, real y returns nothing +native BlzSetSpecialEffectZ takes effect whichEffect, real z returns nothing +native BlzSetSpecialEffectPositionLoc takes effect whichEffect, location loc returns nothing +native BlzGetLocalSpecialEffectX takes effect whichEffect returns real +native BlzGetLocalSpecialEffectY takes effect whichEffect returns real +native BlzGetLocalSpecialEffectZ takes effect whichEffect returns real +native BlzSpecialEffectClearSubAnimations takes effect whichEffect returns nothing +native BlzSpecialEffectRemoveSubAnimation takes effect whichEffect, subanimtype whichSubAnim returns nothing +native BlzSpecialEffectAddSubAnimation takes effect whichEffect, subanimtype whichSubAnim returns nothing +native BlzPlaySpecialEffect takes effect whichEffect, animtype whichAnim returns nothing +native BlzPlaySpecialEffectWithTimeScale takes effect whichEffect, animtype whichAnim, real timeScale returns nothing +native BlzSetSpecialEffectAnimationBlendTime takes effect whichEffect, real blendTime returns nothing +native BlzQueueSpecialEffectAnimation takes effect whichEffect, string whichAnimation returns nothing +native BlzSetSpecialEffectAnimation takes effect whichEffect, string whichAnimation returns nothing +native BlzGetAnimName takes animtype whichAnim returns string +native BlzGetUnitArmor takes unit whichUnit returns real +native BlzSetUnitArmor takes unit whichUnit, real armorAmount returns nothing +native BlzUnitHideAbility takes unit whichUnit, integer abilId, boolean flag returns nothing +native BlzUnitDisableAbility takes unit whichUnit, integer abilId, boolean flag, boolean hideUI returns nothing +native BlzUnitEnableAuras takes unit whichUnit, boolean enable, boolean affectsUI returns nothing +native BlzUnitCancelTimedLife takes unit whichUnit returns nothing +native BlzIsUnitSelectable takes unit whichUnit returns boolean +native BlzIsUnitInvulnerable takes unit whichUnit returns boolean +native BlzUnitInterruptAttack takes unit whichUnit returns nothing +native BlzGetUnitCollisionSize takes unit whichUnit returns real +native BlzGetAbilityManaCost takes integer abilId, integer level returns integer +native BlzGetAbilityCooldown takes integer abilId, integer level returns real +native BlzSetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level, real cooldown returns nothing +native BlzGetUnitAbilityCooldown takes unit whichUnit, integer abilId, integer level returns real +native BlzGetUnitAbilityCooldownRemaining takes unit whichUnit, integer abilId returns real +native BlzGetUnitAbilityCooldownPercent takes unit whichUnit, integer abilId returns real +native BlzSetUnitAbilityCooldownRemaining takes unit whichUnit, integer abilId, real duration returns nothing +native BlzSetUnitAbilityCooldownPercent takes unit whichUnit, integer abilId, real percent returns nothing +native BlzAdjustUnitAbilityCooldownRemaining takes unit whichUnit, integer abilId, real duration returns nothing +native BlzAdjustUnitAbilityCooldownPercent takes unit whichUnit, integer abilId, real percent returns nothing +native BlzEndUnitAbilityCooldown takes unit whichUnit, integer abilCode returns nothing +native BlzStartUnitAbilityCooldown takes unit whichUnit, integer abilCode, real cooldown returns nothing +native BlzGetUnitAbilityManaCost takes unit whichUnit, integer abilId, integer level returns integer +native BlzSetUnitAbilityManaCost takes unit whichUnit, integer abilId, integer level, integer manaCost returns nothing +native BlzGetLocalUnitZ takes unit whichUnit returns real +native BlzDecPlayerTechResearched takes player whichPlayer, integer techid, integer levels returns nothing +native BlzSetEventDamage takes real damage returns nothing +native BlzGetEventDamageTarget takes nothing returns unit +native BlzGetEventAttackType takes nothing returns attacktype +native BlzGetEventDamageType takes nothing returns damagetype +native BlzGetEventWeaponType takes nothing returns weapontype +native BlzSetEventAttackType takes attacktype attackType returns boolean +native BlzSetEventDamageType takes damagetype damageType returns boolean +native BlzSetEventWeaponType takes weapontype weaponType returns boolean +native BlzGetEventIsAttack takes nothing returns boolean +// Add this function to follow the style of GetUnitX and GetUnitY, it has the same result as BlzGetLocalUnitZ +native BlzGetUnitZ takes unit whichUnit returns real +native BlzEnableSelections takes boolean enableSelection, boolean enableSelectionCircle returns nothing +native BlzIsSelectionEnabled takes nothing returns boolean +native BlzIsSelectionCircleEnabled takes nothing returns boolean +native BlzCameraSetupApplyForceDurationSmooth takes camerasetup whichSetup, boolean doPan, real forcedDuration, real easeInDuration, real easeOutDuration, real smoothFactor returns nothing +native BlzEnableTargetIndicator takes boolean enable returns nothing +native BlzIsTargetIndicatorEnabled takes nothing returns boolean +native BlzShowTerrain takes boolean show returns nothing +native BlzShowSkyBox takes boolean show returns nothing +native BlzStartRecording takes integer fps returns nothing +native BlzEndRecording takes nothing returns nothing +native BlzShowUnitTeamGlow takes unit whichUnit, boolean show returns nothing + +native BlzGetOriginFrame takes originframetype frameType, integer index returns framehandle +native BlzEnableUIAutoPosition takes boolean enable returns nothing +native BlzHideOriginFrames takes boolean enable returns nothing +native BlzConvertColor takes integer a, integer r, integer g, integer b returns integer +native BlzLoadTOCFile takes string TOCFile returns boolean +native BlzCreateFrame takes string name, framehandle owner, integer priority, integer createContext returns framehandle +native BlzCreateSimpleFrame takes string name, framehandle owner, integer createContext returns framehandle +native BlzCreateFrameByType takes string typeName, string name, framehandle owner, string inherits, integer createContext returns framehandle +native BlzDestroyFrame takes framehandle frame returns nothing +native BlzFrameSetPoint takes framehandle frame, framepointtype point, framehandle relative, framepointtype relativePoint, real x, real y returns nothing +native BlzFrameSetAbsPoint takes framehandle frame, framepointtype point, real x, real y returns nothing +native BlzFrameClearAllPoints takes framehandle frame returns nothing +native BlzFrameSetAllPoints takes framehandle frame, framehandle relative returns nothing +native BlzFrameSetVisible takes framehandle frame, boolean visible returns nothing +native BlzFrameIsVisible takes framehandle frame returns boolean +native BlzGetFrameByName takes string name, integer createContext returns framehandle +native BlzFrameGetName takes framehandle frame returns string +native BlzFrameClick takes framehandle frame returns nothing +native BlzFrameSetText takes framehandle frame, string text returns nothing +native BlzFrameGetText takes framehandle frame returns string +native BlzFrameAddText takes framehandle frame, string text returns nothing +native BlzFrameSetTextSizeLimit takes framehandle frame, integer size returns nothing +native BlzFrameGetTextSizeLimit takes framehandle frame returns integer +native BlzFrameSetTextColor takes framehandle frame, integer color returns nothing +native BlzFrameSetFocus takes framehandle frame, boolean flag returns nothing +native BlzFrameSetModel takes framehandle frame, string modelFile, integer cameraIndex returns nothing +native BlzFrameSetEnable takes framehandle frame, boolean enabled returns nothing +native BlzFrameGetEnable takes framehandle frame returns boolean +native BlzFrameSetAlpha takes framehandle frame, integer alpha returns nothing +native BlzFrameGetAlpha takes framehandle frame returns integer +native BlzFrameSetSpriteAnimate takes framehandle frame, integer primaryProp, integer flags returns nothing +native BlzFrameSetTexture takes framehandle frame, string texFile, integer flag, boolean blend returns nothing +native BlzFrameSetScale takes framehandle frame, real scale returns nothing +native BlzFrameSetTooltip takes framehandle frame, framehandle tooltip returns nothing +native BlzFrameCageMouse takes framehandle frame, boolean enable returns nothing +native BlzFrameSetValue takes framehandle frame, real value returns nothing +native BlzFrameGetValue takes framehandle frame returns real +native BlzTextAreaFrameSetAutoScroll takes framehandle frame, boolean value returns nothing +native BlzFrameSetMinMaxValue takes framehandle frame, real minValue, real maxValue returns nothing +native BlzFrameSetStepSize takes framehandle frame, real stepSize returns nothing +native BlzFrameSetSize takes framehandle frame, real width, real height returns nothing +native BlzFrameSetVertexColor takes framehandle frame, integer color returns nothing +native BlzFrameSetLevel takes framehandle frame, integer level returns nothing +native BlzFrameSetParent takes framehandle frame, framehandle parent returns nothing +native BlzFrameGetParent takes framehandle frame returns framehandle +native BlzFrameGetHeight takes framehandle frame returns real +native BlzFrameGetWidth takes framehandle frame returns real +native BlzFrameSetFont takes framehandle frame, string fileName, real height, integer flags returns nothing +native BlzFrameSetTextAlignment takes framehandle frame, textaligntype vert, textaligntype horz returns nothing +native BlzFrameGetChildrenCount takes framehandle frame returns integer +native BlzFrameGetChild takes framehandle frame, integer index returns framehandle +native BlzTriggerRegisterFrameEvent takes trigger whichTrigger, framehandle frame, frameeventtype eventId returns event +native BlzGetTriggerFrame takes nothing returns framehandle +native BlzGetTriggerFrameEvent takes nothing returns frameeventtype +native BlzGetTriggerFrameValue takes nothing returns real +native BlzGetTriggerFrameText takes nothing returns string +native BlzTriggerRegisterPlayerSyncEvent takes trigger whichTrigger, player whichPlayer, string prefix, boolean fromServer returns event +native BlzSendSyncData takes string prefix, string data returns boolean +native BlzGetTriggerSyncPrefix takes nothing returns string +native BlzGetTriggerSyncData takes nothing returns string +native BlzTriggerRegisterPlayerKeyEvent takes trigger whichTrigger, player whichPlayer, oskeytype key, integer metaKey, boolean keyDown returns event +native BlzGetTriggerPlayerKey takes nothing returns oskeytype +native BlzGetTriggerPlayerMetaKey takes nothing returns integer +native BlzGetTriggerPlayerIsKeyDown takes nothing returns boolean +native BlzIsMetaKeyPressed takes integer metakey returns boolean +native BlzIsKeyPressed takes oskeytype key returns boolean +native BlzIsMouseButtonPressed takes mousebuttontype mouseButtonType returns boolean +native BlzGetMouseScreenPosX takes nothing returns integer +native BlzGetMouseScreenPosY takes nothing returns integer +native BlzEnableCursor takes boolean enable returns nothing +native BlzSetMousePos takes integer x, integer y returns nothing +native BlzGetLocalClientWidth takes nothing returns integer +native BlzGetLocalClientHeight takes nothing returns integer +native BlzIsLocalClientActive takes nothing returns boolean +native BlzGetMouseFocusUnit takes nothing returns unit +native BlzPixelToFrameX takes integer pixelX returns real +native BlzPixelToFrameY takes integer pixelY returns real +native BlzFrameToPixelX takes real frameX returns integer +native BlzFrameToPixelY takes real frameY returns integer +native BlzChangeMinimapTerrainTex takes string texFile returns boolean +native BlzGetLocale takes nothing returns string +native BlzGetSpecialEffectScale takes effect whichEffect returns real +native BlzSetSpecialEffectMatrixScale takes effect whichEffect, real x, real y, real z returns nothing +native BlzResetSpecialEffectMatrix takes effect whichEffect returns nothing +native BlzGetUnitAbility takes unit whichUnit, integer abilId returns ability +native BlzGetUnitAbilityByIndex takes unit whichUnit, integer index returns ability +native BlzGetAbilityId takes ability whichAbility returns integer +native BlzDisplayChatMessage takes player whichPlayer, integer recipient, string message returns nothing +native BlzPauseUnitEx takes unit whichUnit, boolean flag returns nothing +// native BlzFourCC2S takes integer value returns string +// native BlzS2FourCC takes string value returns integer +native BlzSetUnitFacingEx takes unit whichUnit, real facingAngle returns nothing + +native CreateCommandButtonEffect takes integer abilityId, string order returns commandbuttoneffect +native CreateUpgradeCommandButtonEffect takes integer whichUprgade returns commandbuttoneffect +native CreateLearnCommandButtonEffect takes integer abilityId returns commandbuttoneffect +native DestroyCommandButtonEffect takes commandbuttoneffect whichEffect returns nothing + +// Bit Operations +native BlzBitOr takes integer x, integer y returns integer +native BlzBitAnd takes integer x, integer y returns integer +native BlzBitXor takes integer x, integer y returns integer + +// Intanced Object Operations +// Ability +native BlzGetAbilityBooleanField takes ability whichAbility, abilitybooleanfield whichField returns boolean +native BlzGetAbilityIntegerField takes ability whichAbility, abilityintegerfield whichField returns integer +native BlzGetAbilityRealField takes ability whichAbility, abilityrealfield whichField returns real +native BlzGetAbilityStringField takes ability whichAbility, abilitystringfield whichField returns string +native BlzGetAbilityBooleanLevelField takes ability whichAbility, abilitybooleanlevelfield whichField, integer level returns boolean +native BlzGetAbilityIntegerLevelField takes ability whichAbility, abilityintegerlevelfield whichField, integer level returns integer +native BlzGetAbilityRealLevelField takes ability whichAbility, abilityreallevelfield whichField, integer level returns real +native BlzGetAbilityStringLevelField takes ability whichAbility, abilitystringlevelfield whichField, integer level returns string +native BlzGetAbilityBooleanLevelArrayField takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, integer index returns boolean +native BlzGetAbilityIntegerLevelArrayField takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer index returns integer +native BlzGetAbilityRealLevelArrayField takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, integer index returns real +native BlzGetAbilityStringLevelArrayField takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, integer index returns string +native BlzSetAbilityBooleanField takes ability whichAbility, abilitybooleanfield whichField, boolean value returns boolean +native BlzSetAbilityIntegerField takes ability whichAbility, abilityintegerfield whichField, integer value returns boolean +native BlzSetAbilityRealField takes ability whichAbility, abilityrealfield whichField, real value returns boolean +native BlzSetAbilityStringField takes ability whichAbility, abilitystringfield whichField, string value returns boolean +native BlzSetAbilityBooleanLevelField takes ability whichAbility, abilitybooleanlevelfield whichField, integer level, boolean value returns boolean +native BlzSetAbilityIntegerLevelField takes ability whichAbility, abilityintegerlevelfield whichField, integer level, integer value returns boolean +native BlzSetAbilityRealLevelField takes ability whichAbility, abilityreallevelfield whichField, integer level, real value returns boolean +native BlzSetAbilityStringLevelField takes ability whichAbility, abilitystringlevelfield whichField, integer level, string value returns boolean +native BlzSetAbilityBooleanLevelArrayField takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, integer index, boolean value returns boolean +native BlzSetAbilityIntegerLevelArrayField takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer index, integer value returns boolean +native BlzSetAbilityRealLevelArrayField takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, integer index, real value returns boolean +native BlzSetAbilityStringLevelArrayField takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, integer index, string value returns boolean +native BlzAddAbilityBooleanLevelArrayField takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, boolean value returns boolean +native BlzAddAbilityIntegerLevelArrayField takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer value returns boolean +native BlzAddAbilityRealLevelArrayField takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, real value returns boolean +native BlzAddAbilityStringLevelArrayField takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, string value returns boolean +native BlzRemoveAbilityBooleanLevelArrayField takes ability whichAbility, abilitybooleanlevelarrayfield whichField, integer level, boolean value returns boolean +native BlzRemoveAbilityIntegerLevelArrayField takes ability whichAbility, abilityintegerlevelarrayfield whichField, integer level, integer value returns boolean +native BlzRemoveAbilityRealLevelArrayField takes ability whichAbility, abilityreallevelarrayfield whichField, integer level, real value returns boolean +native BlzRemoveAbilityStringLevelArrayField takes ability whichAbility, abilitystringlevelarrayfield whichField, integer level, string value returns boolean + +// Item +native BlzGetItemAbilityByIndex takes item whichItem, integer index returns ability +native BlzGetItemAbility takes item whichItem, integer abilCode returns ability +native BlzItemAddAbility takes item whichItem, integer abilCode returns boolean +native BlzGetItemBooleanField takes item whichItem, itembooleanfield whichField returns boolean +native BlzGetItemIntegerField takes item whichItem, itemintegerfield whichField returns integer +native BlzGetItemRealField takes item whichItem, itemrealfield whichField returns real +native BlzGetItemStringField takes item whichItem, itemstringfield whichField returns string +native BlzSetItemBooleanField takes item whichItem, itembooleanfield whichField, boolean value returns boolean +native BlzSetItemIntegerField takes item whichItem, itemintegerfield whichField, integer value returns boolean +native BlzSetItemRealField takes item whichItem, itemrealfield whichField, real value returns boolean +native BlzSetItemStringField takes item whichItem, itemstringfield whichField, string value returns boolean +native BlzItemRemoveAbility takes item whichItem, integer abilCode returns boolean + +// Unit +native BlzGetUnitBooleanField takes unit whichUnit, unitbooleanfield whichField returns boolean +native BlzGetUnitIntegerField takes unit whichUnit, unitintegerfield whichField returns integer +native BlzGetUnitRealField takes unit whichUnit, unitrealfield whichField returns real +native BlzGetUnitStringField takes unit whichUnit, unitstringfield whichField returns string +native BlzSetUnitBooleanField takes unit whichUnit, unitbooleanfield whichField, boolean value returns boolean +native BlzSetUnitIntegerField takes unit whichUnit, unitintegerfield whichField, integer value returns boolean +native BlzSetUnitRealField takes unit whichUnit, unitrealfield whichField, real value returns boolean +native BlzSetUnitStringField takes unit whichUnit, unitstringfield whichField, string value returns boolean + +// Unit Weapon +native BlzGetUnitWeaponBooleanField takes unit whichUnit, unitweaponbooleanfield whichField, integer index returns boolean +native BlzGetUnitWeaponIntegerField takes unit whichUnit, unitweaponintegerfield whichField, integer index returns integer +native BlzGetUnitWeaponRealField takes unit whichUnit, unitweaponrealfield whichField, integer index returns real +native BlzGetUnitWeaponStringField takes unit whichUnit, unitweaponstringfield whichField, integer index returns string +native BlzSetUnitWeaponBooleanField takes unit whichUnit, unitweaponbooleanfield whichField, integer index, boolean value returns boolean +native BlzSetUnitWeaponIntegerField takes unit whichUnit, unitweaponintegerfield whichField, integer index, integer value returns boolean +native BlzSetUnitWeaponRealField takes unit whichUnit, unitweaponrealfield whichField, integer index, real value returns boolean +native BlzSetUnitWeaponStringField takes unit whichUnit, unitweaponstringfield whichField, integer index, string value returns boolean + +// Skin +native BlzGetUnitSkin takes unit whichUnit returns integer +native BlzGetItemSkin takes item whichItem returns integer +// native BlzGetDestructableSkin takes destructable whichDestructable returns integer +native BlzSetUnitSkin takes unit whichUnit, integer skinId returns nothing +native BlzSetItemSkin takes item whichItem, integer skinId returns nothing +// native BlzSetDestructableSkin takes destructable whichDestructable, integer skinId returns nothing + +native BlzCreateItemWithSkin takes integer itemid, real x, real y, integer skinId returns item +native BlzCreateUnitWithSkin takes player id, integer unitid, real x, real y, real face, integer skinId returns unit +native BlzCreateDestructableWithSkin takes integer objectid, real x, real y, real face, real scale, integer variation, integer skinId returns destructable +native BlzCreateDestructableZWithSkin takes integer objectid, real x, real y, real z, real face, real scale, integer variation, integer skinId returns destructable +native BlzCreateDeadDestructableWithSkin takes integer objectid, real x, real y, real face, real scale, integer variation, integer skinId returns destructable +native BlzCreateDeadDestructableZWithSkin takes integer objectid, real x, real y, real z, real face, real scale, integer variation, integer skinId returns destructable +native BlzGetPlayerTownHallCount takes player whichPlayer returns integer + +native BlzQueueImmediateOrderById takes unit whichUnit, integer order returns boolean +native BlzQueuePointOrderById takes unit whichUnit, integer order, real x, real y returns boolean +native BlzQueueTargetOrderById takes unit whichUnit, integer order, widget targetWidget returns boolean +native BlzQueueInstantPointOrderById takes unit whichUnit, integer order, real x, real y, widget instantTargetWidget returns boolean +native BlzQueueInstantTargetOrderById takes unit whichUnit, integer order, widget targetWidget, widget instantTargetWidget returns boolean +native BlzQueueBuildOrderById takes unit whichPeon, integer unitId, real x, real y returns boolean +native BlzQueueNeutralImmediateOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId returns boolean +native BlzQueueNeutralPointOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, real x, real y returns boolean +native BlzQueueNeutralTargetOrderById takes player forWhichPlayer,unit neutralStructure, integer unitId, widget target returns boolean + +// returns the number of orders the unit currently has queued up +native BlzGetUnitOrderCount takes unit whichUnit returns integer +// clears either all orders or only queued up orders +native BlzUnitClearOrders takes unit whichUnit, boolean onlyQueued returns nothing +// stops the current order and optionally clears the queue +native BlzUnitForceStopOrder takes unit whichUnit, boolean clearQueue returns nothing + +native BlzCreateDestructablePitchRoll takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation returns destructable +native BlzCreateDestructableZPitchRoll takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation returns destructable +native BlzCreateDeadDestructablePitchRoll takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation returns destructable +native BlzCreateDeadDestructableZPitchRoll takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation returns destructable +native BlzCreateDestructableWithSkinPitchRoll takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, integer skinId returns destructable +native BlzCreateDestructableZWithSkinPitchRoll takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, integer skinId returns destructable +native BlzCreateDeadDestructableWithSkinPitchRoll takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, integer skinId returns destructable +native BlzCreateDeadDestructableZWithSkinPitchRoll takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, integer skinId returns destructable + +native BlzCreateDestructableWithColor takes integer objectid, real x, real y, real face, real scale, integer variation, playercolor color returns destructable +native BlzCreateDestructableZWithColor takes integer objectid, real x, real y, real z, real face, real scale, integer variation, playercolor color returns destructable +native BlzCreateDeadDestructableWithColor takes integer objectid, real x, real y, real face, real scale, integer variation, playercolor color returns destructable +native BlzCreateDeadDestructableZWithColor takes integer objectid, real x, real y, real z, real face, real scale, integer variation, playercolor color returns destructable +native BlzCreateDestructableWithSkinColor takes integer objectid, real x, real y, real face, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDestructableZWithSkinColor takes integer objectid, real x, real y, real z, real face, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDeadDestructableWithSkinColor takes integer objectid, real x, real y, real face, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDeadDestructableZWithSkinColor takes integer objectid, real x, real y, real z, real face, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDestructablePitchRollWithColor takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, playercolor color returns destructable +native BlzCreateDestructableZPitchRollWithColor takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, playercolor color returns destructable +native BlzCreateDeadDestructablePitchRollWithColor takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, playercolor color returns destructable +native BlzCreateDeadDestructableZPitchRollWithColor takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, playercolor color returns destructable +native BlzCreateDestructableWithSkinPitchRollColor takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDestructableZWithSkinPitchRollColor takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDeadDestructableWithSkinPitchRollColor takes integer objectid, real x, real y, real face, real roll, real pitch, real scale, integer variation, integer skinId, playercolor color returns destructable +native BlzCreateDeadDestructableZWithSkinPitchRollColor takes integer objectid, real x, real y, real z, real face, real roll, real pitch, real scale, integer variation, integer skinId, playercolor color returns destructable + +native SetDestructableVertexColor takes destructable whichDestructable, integer red, integer green, integer blue, integer alpha returns nothing \ No newline at end of file diff --git a/src/main/resources/wbschema.json b/src/main/resources/wbschema.json index 900adb6..7aecb8d 100644 --- a/src/main/resources/wbschema.json +++ b/src/main/resources/wbschema.json @@ -15,12 +15,12 @@ "enum": ["LUA", "JASS", "lua", "jass"] }, "wc3Patch": { - "description": "The WC3 patch target for this project. Use a friendly patch target such as v2.0, an exact wurstscript/jass-history dump folder, or a supported alias such as classic/pre1.29. Default: v2.0.", + "description": "The WC3 patch target for this project. Use a friendly patch target such as v3.0, an exact wurstscript/jass-history dump folder, or a supported alias such as classic/pre1.29. Default: v3.0.", "type": "string", "anyOf": [ { "enum": [ - "v2.0", "v1.36", "v1.35", "v1.34", "v1.33", "v1.32", "v1.31", "v1.30", "v1.29", "v1.28", + "v3.0", "v2.0", "v1.36", "v1.35", "v1.34", "v1.33", "v1.32", "v1.31", "v1.30", "v1.29", "v1.28", "v1.27b", "v1.27a", "v1.26a", "v1.25b", "v1.24e", "v1.24d", "v1.24c", "v1.24b", "v1.24a", "v1.23a", "v1.22a", diff --git a/src/test/kotlin/GenerateTests.kt b/src/test/kotlin/GenerateTests.kt index d11a977..d284117 100644 --- a/src/test/kotlin/GenerateTests.kt +++ b/src/test/kotlin/GenerateTests.kt @@ -90,6 +90,13 @@ class GenerateTests { @Test(priority = 10) fun testPatchAliasNormalizationAndLegacyDetection() { Assert.assertEquals(CoreJassProvider.normalizePatchInput("reforged"), CoreJassProvider.DEFAULT_PATCH) + Assert.assertEquals(CoreJassProvider.normalizePatchInput("latest"), CoreJassProvider.DEFAULT_PATCH) + Assert.assertEquals(CoreJassProvider.normalizePatchInput("3.0"), CoreJassProvider.DEFAULT_PATCH) + Assert.assertEquals( + CoreJassProvider.normalizePatchInput("Reforged-v3.0.0.24268-w3-3a9d8f2"), + CoreJassProvider.DEFAULT_PATCH + ) + Assert.assertTrue(CoreJassProvider.isReforgedPatch("v3.0")) Assert.assertEquals(CoreJassProvider.normalizePatchInput("pre1.29"), CoreJassProvider.PRE_129_PATCH) Assert.assertFalse(CoreJassProvider.isSupportedPatch("v9.99")) Assert.assertTrue(CoreJassProvider.isPre129Patch("TFT-v1.28.2.7395")) @@ -102,13 +109,21 @@ class GenerateTests { CoreJassProvider.describePatch("v1.36"), "v1.36 (Reforged)" ) + Assert.assertEquals( + CoreJassProvider.jassHistoryFolderForPatch("v3.0"), + "Reforged-v3.0.0.24268-w3-3a9d8f2" + ) + Assert.assertEquals( + CoreJassProvider.describePatch("v3.0"), + "v3.0 (latest Reforged / WC3 3.x core JASS)" + ) Assert.assertEquals( CoreJassProvider.jassHistoryFolderForPatch("v2.0"), "Reforged-v2.0.4.23745" ) Assert.assertEquals( CoreJassProvider.describePatch("v2.0"), - "v2.0 (latest Reforged / WC3 2.x core JASS)" + "v2.0 (Reforged)" ) } @@ -646,8 +661,8 @@ class GenerateTests { } @Test(priority = 10) - fun testDefaultPatchDownloadFailureUsesBundledV2CoreJass() { - val tmpDir = Files.createTempDirectory("grill-core-jass-v2-fallback-test") + fun testDefaultPatchDownloadFailureUsesBundledV3CoreJass() { + val tmpDir = Files.createTempDirectory("grill-core-jass-v3-fallback-test") val previousDownloader = CoreJassProvider.jassHistoryFileDownloader try { CoreJassProvider.jassHistoryFileDownloader = { _, _ -> throw RuntimeException("offline") } @@ -657,13 +672,13 @@ class GenerateTests { val buildDir = tmpDir.resolve("_build") val common = Files.readString(buildDir.resolve("common.j")) val blizzard = Files.readString(buildDir.resolve("blizzard.j")) - Assert.assertEquals(common, bundledCoreJassText("v2.0", "common.j")) - Assert.assertEquals(blizzard, bundledCoreJassText("v2.0", "blizzard.j")) - Assert.assertEquals(CoreJassProvider.bundledCoreJassFolderForPatch(CoreJassProvider.DEFAULT_PATCH), "v2.0") + Assert.assertEquals(common, bundledCoreJassText("v3.0", "common.j")) + Assert.assertEquals(blizzard, bundledCoreJassText("v3.0", "blizzard.j")) + Assert.assertEquals(CoreJassProvider.bundledCoreJassFolderForPatch(CoreJassProvider.DEFAULT_PATCH), "v3.0") Assert.assertEquals(CoreJassProvider.bundledCoreJassFolderForPatch("v1.36"), "reforged") Assert.assertTrue( Files.readString(buildDir.resolve("core-jass.provenance")) - .contains("jassHistoryFolder: Reforged-v2.0.4.23745") + .contains("jassHistoryFolder: Reforged-v3.0.0.24268-w3-3a9d8f2") ) } finally { CoreJassProvider.jassHistoryFileDownloader = previousDownloader