• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Lua dump of common.j / blizzard.j / common.ai

Level 23
Joined
Jan 3, 2022
Messages
498
Do the impossible, see the invisible
xxx, xxx, xxxxx xxx xxxxx!

To whom it may concern: I dumped the transpiled Lua files from memory. In hindsight I wonder, why nobody has thought of this before?

v2.0.2.22796

This could be useful for the rare stacktrace leading through common.j/blizzard.j/common.ai when running the map in Lua mode:
Luashine/jass-history/ lua-dump by using this script: Luashine/jassdoc @extra-files /extra-lua/tools/extract-luahelper.lua

Finally it's useful to study the jass2lua compiler in the game.

ping @Bribe @Eikonium @Sykranos @Arxos

Copy-pasting them here too for once:
Lua:
TypeDefine('agent', 'handle')
TypeDefine('event', 'agent')
TypeDefine('player', 'agent')
TypeDefine('widget', 'agent')
TypeDefine('unit', 'widget')
TypeDefine('destructable', 'widget')
TypeDefine('item', 'widget')
TypeDefine('ability', 'agent')
TypeDefine('buff', 'ability')
TypeDefine('force', 'agent')
TypeDefine('group', 'agent')
TypeDefine('trigger', 'agent')
TypeDefine('triggercondition', 'agent')
TypeDefine('triggeraction', 'handle')
TypeDefine('timer', 'agent')
TypeDefine('location', 'agent')
TypeDefine('region', 'agent')
TypeDefine('rect', 'agent')
TypeDefine('boolexpr', 'agent')
TypeDefine('sound', 'agent')
TypeDefine('conditionfunc', 'boolexpr')
TypeDefine('filterfunc', 'boolexpr')
TypeDefine('unitpool', 'handle')
TypeDefine('itempool', 'handle')
TypeDefine('race', 'handle')
TypeDefine('alliancetype', 'handle')
TypeDefine('racepreference', 'handle')
TypeDefine('gamestate', 'handle')
TypeDefine('igamestate', 'gamestate')
TypeDefine('fgamestate', 'gamestate')
TypeDefine('playerstate', 'handle')
TypeDefine('playerscore', 'handle')
TypeDefine('playergameresult', 'handle')
TypeDefine('unitstate', 'handle')
TypeDefine('aidifficulty', 'handle')
TypeDefine('eventid', 'handle')
TypeDefine('gameevent', 'eventid')
TypeDefine('playerevent', 'eventid')
TypeDefine('playerunitevent', 'eventid')
TypeDefine('unitevent', 'eventid')
TypeDefine('limitop', 'eventid')
TypeDefine('widgetevent', 'eventid')
TypeDefine('dialogevent', 'eventid')
TypeDefine('unittype', 'handle')
TypeDefine('gamespeed', 'handle')
TypeDefine('gamedifficulty', 'handle')
TypeDefine('gametype', 'handle')
TypeDefine('mapflag', 'handle')
TypeDefine('mapvisibility', 'handle')
TypeDefine('mapsetting', 'handle')
TypeDefine('mapdensity', 'handle')
TypeDefine('mapcontrol', 'handle')
TypeDefine('minimapicon', 'handle')
TypeDefine('playerslotstate', 'handle')
TypeDefine('volumegroup', 'handle')
TypeDefine('camerafield', 'handle')
TypeDefine('camerasetup', 'handle')
TypeDefine('playercolor', 'handle')
TypeDefine('placement', 'handle')
TypeDefine('startlocprio', 'handle')
TypeDefine('raritycontrol', 'handle')
TypeDefine('blendmode', 'handle')
TypeDefine('texmapflags', 'handle')
TypeDefine('effect', 'agent')
TypeDefine('effecttype', 'handle')
TypeDefine('weathereffect', 'handle')
TypeDefine('terraindeformation', 'handle')
TypeDefine('fogstate', 'handle')
TypeDefine('fogmodifier', 'agent')
TypeDefine('dialog', 'agent')
TypeDefine('button', 'agent')
TypeDefine('quest', 'agent')
TypeDefine('questitem', 'agent')
TypeDefine('defeatcondition', 'agent')
TypeDefine('timerdialog', 'agent')
TypeDefine('leaderboard', 'agent')
TypeDefine('multiboard', 'agent')
TypeDefine('multiboarditem', 'agent')
TypeDefine('trackable', 'agent')
TypeDefine('gamecache', 'agent')
TypeDefine('version', 'handle')
TypeDefine('itemtype', 'handle')
TypeDefine('texttag', 'handle')
TypeDefine('attacktype', 'handle')
TypeDefine('damagetype', 'handle')
TypeDefine('weapontype', 'handle')
TypeDefine('soundtype', 'handle')
TypeDefine('lightning', 'handle')
TypeDefine('pathingtype', 'handle')
TypeDefine('mousebuttontype', 'handle')
TypeDefine('animtype', 'handle')
TypeDefine('subanimtype', 'handle')
TypeDefine('image', 'handle')
TypeDefine('ubersplat', 'handle')
TypeDefine('hashtable', 'agent')
TypeDefine('framehandle', 'handle')
TypeDefine('originframetype', 'handle')
TypeDefine('framepointtype', 'handle')
TypeDefine('textaligntype', 'handle')
TypeDefine('frameeventtype', 'handle')
TypeDefine('oskeytype', 'handle')
TypeDefine('abilityintegerfield', 'handle')
TypeDefine('abilityrealfield', 'handle')
TypeDefine('abilitybooleanfield', 'handle')
TypeDefine('abilitystringfield', 'handle')
TypeDefine('abilityintegerlevelfield', 'handle')
TypeDefine('abilityreallevelfield', 'handle')
TypeDefine('abilitybooleanlevelfield', 'handle')
TypeDefine('abilitystringlevelfield', 'handle')
TypeDefine('abilityintegerlevelarrayfield', 'handle')
TypeDefine('abilityreallevelarrayfield', 'handle')
TypeDefine('abilitybooleanlevelarrayfield', 'handle')
TypeDefine('abilitystringlevelarrayfield', 'handle')
TypeDefine('unitintegerfield', 'handle')
TypeDefine('unitrealfield', 'handle')
TypeDefine('unitbooleanfield', 'handle')
TypeDefine('unitstringfield', 'handle')
TypeDefine('unitweaponintegerfield', 'handle')
TypeDefine('unitweaponrealfield', 'handle')
TypeDefine('unitweaponbooleanfield', 'handle')
TypeDefine('unitweaponstringfield', 'handle')
TypeDefine('itemintegerfield', 'handle')
TypeDefine('itemrealfield', 'handle')
TypeDefine('itembooleanfield', 'handle')
TypeDefine('itemstringfield', 'handle')
TypeDefine('movetype', 'handle')
TypeDefine('targetflag', 'handle')
TypeDefine('armortype', 'handle')
TypeDefine('heroattribute', 'handle')
TypeDefine('defensetype', 'handle')
TypeDefine('regentype', 'handle')
TypeDefine('unitcategory', 'handle')
TypeDefine('pathingflag', 'handle')
TypeDefine('commandbuttoneffect', 'handle')
FALSE = false
TRUE = true
JASS_MAX_ARRAY_SIZE = 32768
PLAYER_NEUTRAL_PASSIVE = GetPlayerNeutralPassive()
PLAYER_NEUTRAL_AGGRESSIVE = GetPlayerNeutralAggressive()
PLAYER_COLOR_RED = ConvertPlayerColor(0)
PLAYER_COLOR_BLUE = ConvertPlayerColor(1)
PLAYER_COLOR_CYAN = ConvertPlayerColor(2)
PLAYER_COLOR_PURPLE = ConvertPlayerColor(3)
PLAYER_COLOR_YELLOW = ConvertPlayerColor(4)
PLAYER_COLOR_ORANGE = ConvertPlayerColor(5)
PLAYER_COLOR_GREEN = ConvertPlayerColor(6)
PLAYER_COLOR_PINK = ConvertPlayerColor(7)
PLAYER_COLOR_LIGHT_GRAY = ConvertPlayerColor(8)
PLAYER_COLOR_LIGHT_BLUE = ConvertPlayerColor(9)
PLAYER_COLOR_AQUA = ConvertPlayerColor(10)
PLAYER_COLOR_BROWN = ConvertPlayerColor(11)
PLAYER_COLOR_MAROON = ConvertPlayerColor(12)
PLAYER_COLOR_NAVY = ConvertPlayerColor(13)
PLAYER_COLOR_TURQUOISE = ConvertPlayerColor(14)
PLAYER_COLOR_VIOLET = ConvertPlayerColor(15)
PLAYER_COLOR_WHEAT = ConvertPlayerColor(16)
PLAYER_COLOR_PEACH = ConvertPlayerColor(17)
PLAYER_COLOR_MINT = ConvertPlayerColor(18)
PLAYER_COLOR_LAVENDER = ConvertPlayerColor(19)
PLAYER_COLOR_COAL = ConvertPlayerColor(20)
PLAYER_COLOR_SNOW = ConvertPlayerColor(21)
PLAYER_COLOR_EMERALD = ConvertPlayerColor(22)
PLAYER_COLOR_PEANUT = ConvertPlayerColor(23)
RACE_HUMAN = ConvertRace(1)
RACE_ORC = ConvertRace(2)
RACE_UNDEAD = ConvertRace(3)
RACE_NIGHTELF = ConvertRace(4)
RACE_DEMON = ConvertRace(5)
RACE_OTHER = ConvertRace(7)
PLAYER_GAME_RESULT_VICTORY = ConvertPlayerGameResult(0)
PLAYER_GAME_RESULT_DEFEAT = ConvertPlayerGameResult(1)
PLAYER_GAME_RESULT_TIE = ConvertPlayerGameResult(2)
PLAYER_GAME_RESULT_NEUTRAL = ConvertPlayerGameResult(3)
ALLIANCE_PASSIVE = ConvertAllianceType(0)
ALLIANCE_HELP_REQUEST = ConvertAllianceType(1)
ALLIANCE_HELP_RESPONSE = ConvertAllianceType(2)
ALLIANCE_SHARED_XP = ConvertAllianceType(3)
ALLIANCE_SHARED_SPELLS = ConvertAllianceType(4)
ALLIANCE_SHARED_VISION = ConvertAllianceType(5)
ALLIANCE_SHARED_CONTROL = ConvertAllianceType(6)
ALLIANCE_SHARED_ADVANCED_CONTROL = ConvertAllianceType(7)
ALLIANCE_RESCUABLE = ConvertAllianceType(8)
ALLIANCE_SHARED_VISION_FORCED = ConvertAllianceType(9)
VERSION_REIGN_OF_CHAOS = ConvertVersion(0)
VERSION_FROZEN_THRONE = ConvertVersion(1)
ATTACK_TYPE_NORMAL = ConvertAttackType(0)
ATTACK_TYPE_MELEE = ConvertAttackType(1)
ATTACK_TYPE_PIERCE = ConvertAttackType(2)
ATTACK_TYPE_SIEGE = ConvertAttackType(3)
ATTACK_TYPE_MAGIC = ConvertAttackType(4)
ATTACK_TYPE_CHAOS = ConvertAttackType(5)
ATTACK_TYPE_HERO = ConvertAttackType(6)
DAMAGE_TYPE_UNKNOWN = ConvertDamageType(0)
DAMAGE_TYPE_NORMAL = ConvertDamageType(4)
DAMAGE_TYPE_ENHANCED = ConvertDamageType(5)
DAMAGE_TYPE_FIRE = ConvertDamageType(8)
DAMAGE_TYPE_COLD = ConvertDamageType(9)
DAMAGE_TYPE_LIGHTNING = ConvertDamageType(10)
DAMAGE_TYPE_POISON = ConvertDamageType(11)
DAMAGE_TYPE_DISEASE = ConvertDamageType(12)
DAMAGE_TYPE_DIVINE = ConvertDamageType(13)
DAMAGE_TYPE_MAGIC = ConvertDamageType(14)
DAMAGE_TYPE_SONIC = ConvertDamageType(15)
DAMAGE_TYPE_ACID = ConvertDamageType(16)
DAMAGE_TYPE_FORCE = ConvertDamageType(17)
DAMAGE_TYPE_DEATH = ConvertDamageType(18)
DAMAGE_TYPE_MIND = ConvertDamageType(19)
DAMAGE_TYPE_PLANT = ConvertDamageType(20)
DAMAGE_TYPE_DEFENSIVE = ConvertDamageType(21)
DAMAGE_TYPE_DEMOLITION = ConvertDamageType(22)
DAMAGE_TYPE_SLOW_POISON = ConvertDamageType(23)
DAMAGE_TYPE_SPIRIT_LINK = ConvertDamageType(24)
DAMAGE_TYPE_SHADOW_STRIKE = ConvertDamageType(25)
DAMAGE_TYPE_UNIVERSAL = ConvertDamageType(26)
WEAPON_TYPE_WHOKNOWS = ConvertWeaponType(0)
WEAPON_TYPE_METAL_LIGHT_CHOP = ConvertWeaponType(1)
WEAPON_TYPE_METAL_MEDIUM_CHOP = ConvertWeaponType(2)
WEAPON_TYPE_METAL_HEAVY_CHOP = ConvertWeaponType(3)
WEAPON_TYPE_METAL_LIGHT_SLICE = ConvertWeaponType(4)
WEAPON_TYPE_METAL_MEDIUM_SLICE = ConvertWeaponType(5)
WEAPON_TYPE_METAL_HEAVY_SLICE = ConvertWeaponType(6)
WEAPON_TYPE_METAL_MEDIUM_BASH = ConvertWeaponType(7)
WEAPON_TYPE_METAL_HEAVY_BASH = ConvertWeaponType(8)
WEAPON_TYPE_METAL_MEDIUM_STAB = ConvertWeaponType(9)
WEAPON_TYPE_METAL_HEAVY_STAB = ConvertWeaponType(10)
WEAPON_TYPE_WOOD_LIGHT_SLICE = ConvertWeaponType(11)
WEAPON_TYPE_WOOD_MEDIUM_SLICE = ConvertWeaponType(12)
WEAPON_TYPE_WOOD_HEAVY_SLICE = ConvertWeaponType(13)
WEAPON_TYPE_WOOD_LIGHT_BASH = ConvertWeaponType(14)
WEAPON_TYPE_WOOD_MEDIUM_BASH = ConvertWeaponType(15)
WEAPON_TYPE_WOOD_HEAVY_BASH = ConvertWeaponType(16)
WEAPON_TYPE_WOOD_LIGHT_STAB = ConvertWeaponType(17)
WEAPON_TYPE_WOOD_MEDIUM_STAB = ConvertWeaponType(18)
WEAPON_TYPE_CLAW_LIGHT_SLICE = ConvertWeaponType(19)
WEAPON_TYPE_CLAW_MEDIUM_SLICE = ConvertWeaponType(20)
WEAPON_TYPE_CLAW_HEAVY_SLICE = ConvertWeaponType(21)
WEAPON_TYPE_AXE_MEDIUM_CHOP = ConvertWeaponType(22)
WEAPON_TYPE_ROCK_HEAVY_BASH = ConvertWeaponType(23)
PATHING_TYPE_ANY = ConvertPathingType(0)
PATHING_TYPE_WALKABILITY = ConvertPathingType(1)
PATHING_TYPE_FLYABILITY = ConvertPathingType(2)
PATHING_TYPE_BUILDABILITY = ConvertPathingType(3)
PATHING_TYPE_PEONHARVESTPATHING = ConvertPathingType(4)
PATHING_TYPE_BLIGHTPATHING = ConvertPathingType(5)
PATHING_TYPE_FLOATABILITY = ConvertPathingType(6)
PATHING_TYPE_AMPHIBIOUSPATHING = ConvertPathingType(7)
MOUSE_BUTTON_TYPE_LEFT = ConvertMouseButtonType(1)
MOUSE_BUTTON_TYPE_MIDDLE = ConvertMouseButtonType(2)
MOUSE_BUTTON_TYPE_RIGHT = ConvertMouseButtonType(3)
ANIM_TYPE_BIRTH = ConvertAnimType(0)
ANIM_TYPE_DEATH = ConvertAnimType(1)
ANIM_TYPE_DECAY = ConvertAnimType(2)
ANIM_TYPE_DISSIPATE = ConvertAnimType(3)
ANIM_TYPE_STAND = ConvertAnimType(4)
ANIM_TYPE_WALK = ConvertAnimType(5)
ANIM_TYPE_ATTACK = ConvertAnimType(6)
ANIM_TYPE_MORPH = ConvertAnimType(7)
ANIM_TYPE_SLEEP = ConvertAnimType(8)
ANIM_TYPE_SPELL = ConvertAnimType(9)
ANIM_TYPE_PORTRAIT = ConvertAnimType(10)
SUBANIM_TYPE_ROOTED = ConvertSubAnimType(11)
SUBANIM_TYPE_ALTERNATE_EX = ConvertSubAnimType(12)
SUBANIM_TYPE_LOOPING = ConvertSubAnimType(13)
SUBANIM_TYPE_SLAM = ConvertSubAnimType(14)
SUBANIM_TYPE_THROW = ConvertSubAnimType(15)
SUBANIM_TYPE_SPIKED = ConvertSubAnimType(16)
SUBANIM_TYPE_FAST = ConvertSubAnimType(17)
SUBANIM_TYPE_SPIN = ConvertSubAnimType(18)
SUBANIM_TYPE_READY = ConvertSubAnimType(19)
SUBANIM_TYPE_CHANNEL = ConvertSubAnimType(20)
SUBANIM_TYPE_DEFEND = ConvertSubAnimType(21)
SUBANIM_TYPE_VICTORY = ConvertSubAnimType(22)
SUBANIM_TYPE_TURN = ConvertSubAnimType(23)
SUBANIM_TYPE_LEFT = ConvertSubAnimType(24)
SUBANIM_TYPE_RIGHT = ConvertSubAnimType(25)
SUBANIM_TYPE_FIRE = ConvertSubAnimType(26)
SUBANIM_TYPE_FLESH = ConvertSubAnimType(27)
SUBANIM_TYPE_HIT = ConvertSubAnimType(28)
SUBANIM_TYPE_WOUNDED = ConvertSubAnimType(29)
SUBANIM_TYPE_LIGHT = ConvertSubAnimType(30)
SUBANIM_TYPE_MODERATE = ConvertSubAnimType(31)
SUBANIM_TYPE_SEVERE = ConvertSubAnimType(32)
SUBANIM_TYPE_CRITICAL = ConvertSubAnimType(33)
SUBANIM_TYPE_COMPLETE = ConvertSubAnimType(34)
SUBANIM_TYPE_GOLD = ConvertSubAnimType(35)
SUBANIM_TYPE_LUMBER = ConvertSubAnimType(36)
SUBANIM_TYPE_WORK = ConvertSubAnimType(37)
SUBANIM_TYPE_TALK = ConvertSubAnimType(38)
SUBANIM_TYPE_FIRST = ConvertSubAnimType(39)
SUBANIM_TYPE_SECOND = ConvertSubAnimType(40)
SUBANIM_TYPE_THIRD = ConvertSubAnimType(41)
SUBANIM_TYPE_FOURTH = ConvertSubAnimType(42)
SUBANIM_TYPE_FIFTH = ConvertSubAnimType(43)
SUBANIM_TYPE_ONE = ConvertSubAnimType(44)
SUBANIM_TYPE_TWO = ConvertSubAnimType(45)
SUBANIM_TYPE_THREE = ConvertSubAnimType(46)
SUBANIM_TYPE_FOUR = ConvertSubAnimType(47)
SUBANIM_TYPE_FIVE = ConvertSubAnimType(48)
SUBANIM_TYPE_SMALL = ConvertSubAnimType(49)
SUBANIM_TYPE_MEDIUM = ConvertSubAnimType(50)
SUBANIM_TYPE_LARGE = ConvertSubAnimType(51)
SUBANIM_TYPE_UPGRADE = ConvertSubAnimType(52)
SUBANIM_TYPE_DRAIN = ConvertSubAnimType(53)
SUBANIM_TYPE_FILL = ConvertSubAnimType(54)
SUBANIM_TYPE_CHAINLIGHTNING = ConvertSubAnimType(55)
SUBANIM_TYPE_EATTREE = ConvertSubAnimType(56)
SUBANIM_TYPE_PUKE = ConvertSubAnimType(57)
SUBANIM_TYPE_FLAIL = ConvertSubAnimType(58)
SUBANIM_TYPE_OFF = ConvertSubAnimType(59)
SUBANIM_TYPE_SWIM = ConvertSubAnimType(60)
SUBANIM_TYPE_ENTANGLE = ConvertSubAnimType(61)
SUBANIM_TYPE_BERSERK = ConvertSubAnimType(62)
RACE_PREF_HUMAN = ConvertRacePref(1)
RACE_PREF_ORC = ConvertRacePref(2)
RACE_PREF_NIGHTELF = ConvertRacePref(4)
RACE_PREF_UNDEAD = ConvertRacePref(8)
RACE_PREF_DEMON = ConvertRacePref(16)
RACE_PREF_RANDOM = ConvertRacePref(32)
RACE_PREF_USER_SELECTABLE = ConvertRacePref(64)
MAP_CONTROL_USER = ConvertMapControl(0)
MAP_CONTROL_COMPUTER = ConvertMapControl(1)
MAP_CONTROL_RESCUABLE = ConvertMapControl(2)
MAP_CONTROL_NEUTRAL = ConvertMapControl(3)
MAP_CONTROL_CREEP = ConvertMapControl(4)
MAP_CONTROL_NONE = ConvertMapControl(5)
GAME_TYPE_MELEE = ConvertGameType(1)
GAME_TYPE_FFA = ConvertGameType(2)
GAME_TYPE_USE_MAP_SETTINGS = ConvertGameType(4)
GAME_TYPE_BLIZ = ConvertGameType(8)
GAME_TYPE_ONE_ON_ONE = ConvertGameType(16)
GAME_TYPE_TWO_TEAM_PLAY = ConvertGameType(32)
GAME_TYPE_THREE_TEAM_PLAY = ConvertGameType(64)
GAME_TYPE_FOUR_TEAM_PLAY = ConvertGameType(128)
MAP_FOG_HIDE_TERRAIN = ConvertMapFlag(1)
MAP_FOG_MAP_EXPLORED = ConvertMapFlag(2)
MAP_FOG_ALWAYS_VISIBLE = ConvertMapFlag(4)
MAP_USE_HANDICAPS = ConvertMapFlag(8)
MAP_OBSERVERS = ConvertMapFlag(16)
MAP_OBSERVERS_ON_DEATH = ConvertMapFlag(32)
MAP_FIXED_COLORS = ConvertMapFlag(128)
MAP_LOCK_RESOURCE_TRADING = ConvertMapFlag(256)
MAP_RESOURCE_TRADING_ALLIES_ONLY = ConvertMapFlag(512)
MAP_LOCK_ALLIANCE_CHANGES = ConvertMapFlag(1024)
MAP_ALLIANCE_CHANGES_HIDDEN = ConvertMapFlag(2048)
MAP_CHEATS = ConvertMapFlag(4096)
MAP_CHEATS_HIDDEN = ConvertMapFlag(8192)
MAP_LOCK_SPEED = ConvertMapFlag(8192 * 2)
MAP_LOCK_RANDOM_SEED = ConvertMapFlag(8192 * 4)
MAP_SHARED_ADVANCED_CONTROL = ConvertMapFlag(8192 * 8)
MAP_RANDOM_HERO = ConvertMapFlag(8192 * 16)
MAP_RANDOM_RACES = ConvertMapFlag(8192 * 32)
MAP_RELOADED = ConvertMapFlag(8192 * 64)
MAP_PLACEMENT_RANDOM = ConvertPlacement(0)
MAP_PLACEMENT_FIXED = ConvertPlacement(1)
MAP_PLACEMENT_USE_MAP_SETTINGS = ConvertPlacement(2)
MAP_PLACEMENT_TEAMS_TOGETHER = ConvertPlacement(3)
MAP_LOC_PRIO_LOW = ConvertStartLocPrio(0)
MAP_LOC_PRIO_HIGH = ConvertStartLocPrio(1)
MAP_LOC_PRIO_NOT = ConvertStartLocPrio(2)
MAP_DENSITY_NONE = ConvertMapDensity(0)
MAP_DENSITY_LIGHT = ConvertMapDensity(1)
MAP_DENSITY_MEDIUM = ConvertMapDensity(2)
MAP_DENSITY_HEAVY = ConvertMapDensity(3)
MAP_DIFFICULTY_EASY = ConvertGameDifficulty(0)
MAP_DIFFICULTY_NORMAL = ConvertGameDifficulty(1)
MAP_DIFFICULTY_HARD = ConvertGameDifficulty(2)
MAP_DIFFICULTY_INSANE = ConvertGameDifficulty(3)
MAP_SPEED_SLOWEST = ConvertGameSpeed(0)
MAP_SPEED_SLOW = ConvertGameSpeed(1)
MAP_SPEED_NORMAL = ConvertGameSpeed(2)
MAP_SPEED_FAST = ConvertGameSpeed(3)
MAP_SPEED_FASTEST = ConvertGameSpeed(4)
PLAYER_SLOT_STATE_EMPTY = ConvertPlayerSlotState(0)
PLAYER_SLOT_STATE_PLAYING = ConvertPlayerSlotState(1)
PLAYER_SLOT_STATE_LEFT = ConvertPlayerSlotState(2)
SOUND_VOLUMEGROUP_UNITMOVEMENT = ConvertVolumeGroup(0)
SOUND_VOLUMEGROUP_UNITSOUNDS = ConvertVolumeGroup(1)
SOUND_VOLUMEGROUP_COMBAT = ConvertVolumeGroup(2)
SOUND_VOLUMEGROUP_SPELLS = ConvertVolumeGroup(3)
SOUND_VOLUMEGROUP_UI = ConvertVolumeGroup(4)
SOUND_VOLUMEGROUP_MUSIC = ConvertVolumeGroup(5)
SOUND_VOLUMEGROUP_AMBIENTSOUNDS = ConvertVolumeGroup(6)
SOUND_VOLUMEGROUP_FIRE = ConvertVolumeGroup(7)
SOUND_VOLUMEGROUP_CINEMATIC_GENERAL = ConvertVolumeGroup(8)
SOUND_VOLUMEGROUP_CINEMATIC_AMBIENT = ConvertVolumeGroup(9)
SOUND_VOLUMEGROUP_CINEMATIC_MUSIC = ConvertVolumeGroup(10)
SOUND_VOLUMEGROUP_CINEMATIC_DIALOGUE = ConvertVolumeGroup(11)
SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_1 = ConvertVolumeGroup(12)
SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_2 = ConvertVolumeGroup(13)
SOUND_VOLUMEGROUP_CINEMATIC_SOUND_EFFECTS_3 = ConvertVolumeGroup(14)
GAME_STATE_DIVINE_INTERVENTION = ConvertIGameState(0)
GAME_STATE_DISCONNECTED = ConvertIGameState(1)
GAME_STATE_TIME_OF_DAY = ConvertFGameState(2)
PLAYER_STATE_GAME_RESULT = ConvertPlayerState(0)
PLAYER_STATE_RESOURCE_GOLD = ConvertPlayerState(1)
PLAYER_STATE_RESOURCE_LUMBER = ConvertPlayerState(2)
PLAYER_STATE_RESOURCE_HERO_TOKENS = ConvertPlayerState(3)
PLAYER_STATE_RESOURCE_FOOD_CAP = ConvertPlayerState(4)
PLAYER_STATE_RESOURCE_FOOD_USED = ConvertPlayerState(5)
PLAYER_STATE_FOOD_CAP_CEILING = ConvertPlayerState(6)
PLAYER_STATE_GIVES_BOUNTY = ConvertPlayerState(7)
PLAYER_STATE_ALLIED_VICTORY = ConvertPlayerState(8)
PLAYER_STATE_PLACED = ConvertPlayerState(9)
PLAYER_STATE_OBSERVER_ON_DEATH = ConvertPlayerState(10)
PLAYER_STATE_OBSERVER = ConvertPlayerState(11)
PLAYER_STATE_UNFOLLOWABLE = ConvertPlayerState(12)
PLAYER_STATE_GOLD_UPKEEP_RATE = ConvertPlayerState(13)
PLAYER_STATE_LUMBER_UPKEEP_RATE = ConvertPlayerState(14)
PLAYER_STATE_GOLD_GATHERED = ConvertPlayerState(15)
PLAYER_STATE_LUMBER_GATHERED = ConvertPlayerState(16)
PLAYER_STATE_NO_CREEP_SLEEP = ConvertPlayerState(25)
UNIT_STATE_LIFE = ConvertUnitState(0)
UNIT_STATE_MAX_LIFE = ConvertUnitState(1)
UNIT_STATE_MANA = ConvertUnitState(2)
UNIT_STATE_MAX_MANA = ConvertUnitState(3)
AI_DIFFICULTY_NEWBIE = ConvertAIDifficulty(0)
AI_DIFFICULTY_NORMAL = ConvertAIDifficulty(1)
AI_DIFFICULTY_INSANE = ConvertAIDifficulty(2)
PLAYER_SCORE_UNITS_TRAINED = ConvertPlayerScore(0)
PLAYER_SCORE_UNITS_KILLED = ConvertPlayerScore(1)
PLAYER_SCORE_STRUCT_BUILT = ConvertPlayerScore(2)
PLAYER_SCORE_STRUCT_RAZED = ConvertPlayerScore(3)
PLAYER_SCORE_TECH_PERCENT = ConvertPlayerScore(4)
PLAYER_SCORE_FOOD_MAXPROD = ConvertPlayerScore(5)
PLAYER_SCORE_FOOD_MAXUSED = ConvertPlayerScore(6)
PLAYER_SCORE_HEROES_KILLED = ConvertPlayerScore(7)
PLAYER_SCORE_ITEMS_GAINED = ConvertPlayerScore(8)
PLAYER_SCORE_MERCS_HIRED = ConvertPlayerScore(9)
PLAYER_SCORE_GOLD_MINED_TOTAL = ConvertPlayerScore(10)
PLAYER_SCORE_GOLD_MINED_UPKEEP = ConvertPlayerScore(11)
PLAYER_SCORE_GOLD_LOST_UPKEEP = ConvertPlayerScore(12)
PLAYER_SCORE_GOLD_LOST_TAX = ConvertPlayerScore(13)
PLAYER_SCORE_GOLD_GIVEN = ConvertPlayerScore(14)
PLAYER_SCORE_GOLD_RECEIVED = ConvertPlayerScore(15)
PLAYER_SCORE_LUMBER_TOTAL = ConvertPlayerScore(16)
PLAYER_SCORE_LUMBER_LOST_UPKEEP = ConvertPlayerScore(17)
PLAYER_SCORE_LUMBER_LOST_TAX = ConvertPlayerScore(18)
PLAYER_SCORE_LUMBER_GIVEN = ConvertPlayerScore(19)
PLAYER_SCORE_LUMBER_RECEIVED = ConvertPlayerScore(20)
PLAYER_SCORE_UNIT_TOTAL = ConvertPlayerScore(21)
PLAYER_SCORE_HERO_TOTAL = ConvertPlayerScore(22)
PLAYER_SCORE_RESOURCE_TOTAL = ConvertPlayerScore(23)
PLAYER_SCORE_TOTAL = ConvertPlayerScore(24)
EVENT_GAME_VICTORY = ConvertGameEvent(0)
EVENT_GAME_END_LEVEL = ConvertGameEvent(1)
EVENT_GAME_VARIABLE_LIMIT = ConvertGameEvent(2)
EVENT_GAME_STATE_LIMIT = ConvertGameEvent(3)
EVENT_GAME_TIMER_EXPIRED = ConvertGameEvent(4)
EVENT_GAME_ENTER_REGION = ConvertGameEvent(5)
EVENT_GAME_LEAVE_REGION = ConvertGameEvent(6)
EVENT_GAME_TRACKABLE_HIT = ConvertGameEvent(7)
EVENT_GAME_TRACKABLE_TRACK = ConvertGameEvent(8)
EVENT_GAME_SHOW_SKILL = ConvertGameEvent(9)
EVENT_GAME_BUILD_SUBMENU = ConvertGameEvent(10)
EVENT_PLAYER_STATE_LIMIT = ConvertPlayerEvent(11)
EVENT_PLAYER_ALLIANCE_CHANGED = ConvertPlayerEvent(12)
EVENT_PLAYER_DEFEAT = ConvertPlayerEvent(13)
EVENT_PLAYER_VICTORY = ConvertPlayerEvent(14)
EVENT_PLAYER_LEAVE = ConvertPlayerEvent(15)
EVENT_PLAYER_CHAT = ConvertPlayerEvent(16)
EVENT_PLAYER_END_CINEMATIC = ConvertPlayerEvent(17)
EVENT_PLAYER_UNIT_ATTACKED = ConvertPlayerUnitEvent(18)
EVENT_PLAYER_UNIT_RESCUED = ConvertPlayerUnitEvent(19)
EVENT_PLAYER_UNIT_DEATH = ConvertPlayerUnitEvent(20)
EVENT_PLAYER_UNIT_DECAY = ConvertPlayerUnitEvent(21)
EVENT_PLAYER_UNIT_DETECTED = ConvertPlayerUnitEvent(22)
EVENT_PLAYER_UNIT_HIDDEN = ConvertPlayerUnitEvent(23)
EVENT_PLAYER_UNIT_SELECTED = ConvertPlayerUnitEvent(24)
EVENT_PLAYER_UNIT_DESELECTED = ConvertPlayerUnitEvent(25)
EVENT_PLAYER_UNIT_CONSTRUCT_START = ConvertPlayerUnitEvent(26)
EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL = ConvertPlayerUnitEvent(27)
EVENT_PLAYER_UNIT_CONSTRUCT_FINISH = ConvertPlayerUnitEvent(28)
EVENT_PLAYER_UNIT_UPGRADE_START = ConvertPlayerUnitEvent(29)
EVENT_PLAYER_UNIT_UPGRADE_CANCEL = ConvertPlayerUnitEvent(30)
EVENT_PLAYER_UNIT_UPGRADE_FINISH = ConvertPlayerUnitEvent(31)
EVENT_PLAYER_UNIT_TRAIN_START = ConvertPlayerUnitEvent(32)
EVENT_PLAYER_UNIT_TRAIN_CANCEL = ConvertPlayerUnitEvent(33)
EVENT_PLAYER_UNIT_TRAIN_FINISH = ConvertPlayerUnitEvent(34)
EVENT_PLAYER_UNIT_RESEARCH_START = ConvertPlayerUnitEvent(35)
EVENT_PLAYER_UNIT_RESEARCH_CANCEL = ConvertPlayerUnitEvent(36)
EVENT_PLAYER_UNIT_RESEARCH_FINISH = ConvertPlayerUnitEvent(37)
EVENT_PLAYER_UNIT_ISSUED_ORDER = ConvertPlayerUnitEvent(38)
EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER = ConvertPlayerUnitEvent(39)
EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER = ConvertPlayerUnitEvent(40)
EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER = ConvertPlayerUnitEvent(40)
EVENT_PLAYER_HERO_LEVEL = ConvertPlayerUnitEvent(41)
EVENT_PLAYER_HERO_SKILL = ConvertPlayerUnitEvent(42)
EVENT_PLAYER_HERO_REVIVABLE = ConvertPlayerUnitEvent(43)
EVENT_PLAYER_HERO_REVIVE_START = ConvertPlayerUnitEvent(44)
EVENT_PLAYER_HERO_REVIVE_CANCEL = ConvertPlayerUnitEvent(45)
EVENT_PLAYER_HERO_REVIVE_FINISH = ConvertPlayerUnitEvent(46)
EVENT_PLAYER_UNIT_SUMMON = ConvertPlayerUnitEvent(47)
EVENT_PLAYER_UNIT_DROP_ITEM = ConvertPlayerUnitEvent(48)
EVENT_PLAYER_UNIT_PICKUP_ITEM = ConvertPlayerUnitEvent(49)
EVENT_PLAYER_UNIT_USE_ITEM = ConvertPlayerUnitEvent(50)
EVENT_PLAYER_UNIT_LOADED = ConvertPlayerUnitEvent(51)
EVENT_PLAYER_UNIT_DAMAGED = ConvertPlayerUnitEvent(308)
EVENT_PLAYER_UNIT_DAMAGING = ConvertPlayerUnitEvent(315)
EVENT_UNIT_DAMAGED = ConvertUnitEvent(52)
EVENT_UNIT_DAMAGING = ConvertUnitEvent(314)
EVENT_UNIT_DEATH = ConvertUnitEvent(53)
EVENT_UNIT_DECAY = ConvertUnitEvent(54)
EVENT_UNIT_DETECTED = ConvertUnitEvent(55)
EVENT_UNIT_HIDDEN = ConvertUnitEvent(56)
EVENT_UNIT_SELECTED = ConvertUnitEvent(57)
EVENT_UNIT_DESELECTED = ConvertUnitEvent(58)
EVENT_UNIT_STATE_LIMIT = ConvertUnitEvent(59)
EVENT_UNIT_ACQUIRED_TARGET = ConvertUnitEvent(60)
EVENT_UNIT_TARGET_IN_RANGE = ConvertUnitEvent(61)
EVENT_UNIT_ATTACKED = ConvertUnitEvent(62)
EVENT_UNIT_RESCUED = ConvertUnitEvent(63)
EVENT_UNIT_CONSTRUCT_CANCEL = ConvertUnitEvent(64)
EVENT_UNIT_CONSTRUCT_FINISH = ConvertUnitEvent(65)
EVENT_UNIT_UPGRADE_START = ConvertUnitEvent(66)
EVENT_UNIT_UPGRADE_CANCEL = ConvertUnitEvent(67)
EVENT_UNIT_UPGRADE_FINISH = ConvertUnitEvent(68)
EVENT_UNIT_TRAIN_START = ConvertUnitEvent(69)
EVENT_UNIT_TRAIN_CANCEL = ConvertUnitEvent(70)
EVENT_UNIT_TRAIN_FINISH = ConvertUnitEvent(71)
EVENT_UNIT_RESEARCH_START = ConvertUnitEvent(72)
EVENT_UNIT_RESEARCH_CANCEL = ConvertUnitEvent(73)
EVENT_UNIT_RESEARCH_FINISH = ConvertUnitEvent(74)
EVENT_UNIT_ISSUED_ORDER = ConvertUnitEvent(75)
EVENT_UNIT_ISSUED_POINT_ORDER = ConvertUnitEvent(76)
EVENT_UNIT_ISSUED_TARGET_ORDER = ConvertUnitEvent(77)
EVENT_UNIT_HERO_LEVEL = ConvertUnitEvent(78)
EVENT_UNIT_HERO_SKILL = ConvertUnitEvent(79)
EVENT_UNIT_HERO_REVIVABLE = ConvertUnitEvent(80)
EVENT_UNIT_HERO_REVIVE_START = ConvertUnitEvent(81)
EVENT_UNIT_HERO_REVIVE_CANCEL = ConvertUnitEvent(82)
EVENT_UNIT_HERO_REVIVE_FINISH = ConvertUnitEvent(83)
EVENT_UNIT_SUMMON = ConvertUnitEvent(84)
EVENT_UNIT_DROP_ITEM = ConvertUnitEvent(85)
EVENT_UNIT_PICKUP_ITEM = ConvertUnitEvent(86)
EVENT_UNIT_USE_ITEM = ConvertUnitEvent(87)
EVENT_UNIT_LOADED = ConvertUnitEvent(88)
EVENT_WIDGET_DEATH = ConvertWidgetEvent(89)
EVENT_DIALOG_BUTTON_CLICK = ConvertDialogEvent(90)
EVENT_DIALOG_CLICK = ConvertDialogEvent(91)
EVENT_GAME_LOADED = ConvertGameEvent(256)
EVENT_GAME_TOURNAMENT_FINISH_SOON = ConvertGameEvent(257)
EVENT_GAME_TOURNAMENT_FINISH_NOW = ConvertGameEvent(258)
EVENT_GAME_SAVE = ConvertGameEvent(259)
EVENT_GAME_CUSTOM_UI_FRAME = ConvertGameEvent(310)
EVENT_PLAYER_ARROW_LEFT_DOWN = ConvertPlayerEvent(261)
EVENT_PLAYER_ARROW_LEFT_UP = ConvertPlayerEvent(262)
EVENT_PLAYER_ARROW_RIGHT_DOWN = ConvertPlayerEvent(263)
EVENT_PLAYER_ARROW_RIGHT_UP = ConvertPlayerEvent(264)
EVENT_PLAYER_ARROW_DOWN_DOWN = ConvertPlayerEvent(265)
EVENT_PLAYER_ARROW_DOWN_UP = ConvertPlayerEvent(266)
EVENT_PLAYER_ARROW_UP_DOWN = ConvertPlayerEvent(267)
EVENT_PLAYER_ARROW_UP_UP = ConvertPlayerEvent(268)
EVENT_PLAYER_MOUSE_DOWN = ConvertPlayerEvent(305)
EVENT_PLAYER_MOUSE_UP = ConvertPlayerEvent(306)
EVENT_PLAYER_MOUSE_MOVE = ConvertPlayerEvent(307)
EVENT_PLAYER_SYNC_DATA = ConvertPlayerEvent(309)
EVENT_PLAYER_KEY = ConvertPlayerEvent(311)
EVENT_PLAYER_KEY_DOWN = ConvertPlayerEvent(312)
EVENT_PLAYER_KEY_UP = ConvertPlayerEvent(313)
EVENT_PLAYER_UNIT_SELL = ConvertPlayerUnitEvent(269)
EVENT_PLAYER_UNIT_CHANGE_OWNER = ConvertPlayerUnitEvent(270)
EVENT_PLAYER_UNIT_SELL_ITEM = ConvertPlayerUnitEvent(271)
EVENT_PLAYER_UNIT_SPELL_CHANNEL = ConvertPlayerUnitEvent(272)
EVENT_PLAYER_UNIT_SPELL_CAST = ConvertPlayerUnitEvent(273)
EVENT_PLAYER_UNIT_SPELL_EFFECT = ConvertPlayerUnitEvent(274)
EVENT_PLAYER_UNIT_SPELL_FINISH = ConvertPlayerUnitEvent(275)
EVENT_PLAYER_UNIT_SPELL_ENDCAST = ConvertPlayerUnitEvent(276)
EVENT_PLAYER_UNIT_PAWN_ITEM = ConvertPlayerUnitEvent(277)
EVENT_PLAYER_UNIT_STACK_ITEM = ConvertPlayerUnitEvent(319)
EVENT_UNIT_SELL = ConvertUnitEvent(286)
EVENT_UNIT_CHANGE_OWNER = ConvertUnitEvent(287)
EVENT_UNIT_SELL_ITEM = ConvertUnitEvent(288)
EVENT_UNIT_SPELL_CHANNEL = ConvertUnitEvent(289)
EVENT_UNIT_SPELL_CAST = ConvertUnitEvent(290)
EVENT_UNIT_SPELL_EFFECT = ConvertUnitEvent(291)
EVENT_UNIT_SPELL_FINISH = ConvertUnitEvent(292)
EVENT_UNIT_SPELL_ENDCAST = ConvertUnitEvent(293)
EVENT_UNIT_PAWN_ITEM = ConvertUnitEvent(294)
EVENT_UNIT_STACK_ITEM = ConvertUnitEvent(318)
LESS_THAN = ConvertLimitOp(0)
LESS_THAN_OR_EQUAL = ConvertLimitOp(1)
EQUAL = ConvertLimitOp(2)
GREATER_THAN_OR_EQUAL = ConvertLimitOp(3)
GREATER_THAN = ConvertLimitOp(4)
NOT_EQUAL = ConvertLimitOp(5)
UNIT_TYPE_HERO = ConvertUnitType(0)
UNIT_TYPE_DEAD = ConvertUnitType(1)
UNIT_TYPE_STRUCTURE = ConvertUnitType(2)
UNIT_TYPE_FLYING = ConvertUnitType(3)
UNIT_TYPE_GROUND = ConvertUnitType(4)
UNIT_TYPE_ATTACKS_FLYING = ConvertUnitType(5)
UNIT_TYPE_ATTACKS_GROUND = ConvertUnitType(6)
UNIT_TYPE_MELEE_ATTACKER = ConvertUnitType(7)
UNIT_TYPE_RANGED_ATTACKER = ConvertUnitType(8)
UNIT_TYPE_GIANT = ConvertUnitType(9)
UNIT_TYPE_SUMMONED = ConvertUnitType(10)
UNIT_TYPE_STUNNED = ConvertUnitType(11)
UNIT_TYPE_PLAGUED = ConvertUnitType(12)
UNIT_TYPE_SNARED = ConvertUnitType(13)
UNIT_TYPE_UNDEAD = ConvertUnitType(14)
UNIT_TYPE_MECHANICAL = ConvertUnitType(15)
UNIT_TYPE_PEON = ConvertUnitType(16)
UNIT_TYPE_SAPPER = ConvertUnitType(17)
UNIT_TYPE_TOWNHALL = ConvertUnitType(18)
UNIT_TYPE_ANCIENT = ConvertUnitType(19)
UNIT_TYPE_TAUREN = ConvertUnitType(20)
UNIT_TYPE_POISONED = ConvertUnitType(21)
UNIT_TYPE_POLYMORPHED = ConvertUnitType(22)
UNIT_TYPE_SLEEPING = ConvertUnitType(23)
UNIT_TYPE_RESISTANT = ConvertUnitType(24)
UNIT_TYPE_ETHEREAL = ConvertUnitType(25)
UNIT_TYPE_MAGIC_IMMUNE = ConvertUnitType(26)
ITEM_TYPE_PERMANENT = ConvertItemType(0)
ITEM_TYPE_CHARGED = ConvertItemType(1)
ITEM_TYPE_POWERUP = ConvertItemType(2)
ITEM_TYPE_ARTIFACT = ConvertItemType(3)
ITEM_TYPE_PURCHASABLE = ConvertItemType(4)
ITEM_TYPE_CAMPAIGN = ConvertItemType(5)
ITEM_TYPE_MISCELLANEOUS = ConvertItemType(6)
ITEM_TYPE_UNKNOWN = ConvertItemType(7)
ITEM_TYPE_ANY = ConvertItemType(8)
ITEM_TYPE_TOME = ConvertItemType(2)
CAMERA_FIELD_TARGET_DISTANCE = ConvertCameraField(0)
CAMERA_FIELD_FARZ = ConvertCameraField(1)
CAMERA_FIELD_ANGLE_OF_ATTACK = ConvertCameraField(2)
CAMERA_FIELD_FIELD_OF_VIEW = ConvertCameraField(3)
CAMERA_FIELD_ROLL = ConvertCameraField(4)
CAMERA_FIELD_ROTATION = ConvertCameraField(5)
CAMERA_FIELD_ZOFFSET = ConvertCameraField(6)
CAMERA_FIELD_NEARZ = ConvertCameraField(7)
CAMERA_FIELD_LOCAL_PITCH = ConvertCameraField(8)
CAMERA_FIELD_LOCAL_YAW = ConvertCameraField(9)
CAMERA_FIELD_LOCAL_ROLL = ConvertCameraField(10)
BLEND_MODE_NONE = ConvertBlendMode(0)
BLEND_MODE_DONT_CARE = ConvertBlendMode(0)
BLEND_MODE_KEYALPHA = ConvertBlendMode(1)
BLEND_MODE_BLEND = ConvertBlendMode(2)
BLEND_MODE_ADDITIVE = ConvertBlendMode(3)
BLEND_MODE_MODULATE = ConvertBlendMode(4)
BLEND_MODE_MODULATE_2X = ConvertBlendMode(5)
RARITY_FREQUENT = ConvertRarityControl(0)
RARITY_RARE = ConvertRarityControl(1)
TEXMAP_FLAG_NONE = ConvertTexMapFlags(0)
TEXMAP_FLAG_WRAP_U = ConvertTexMapFlags(1)
TEXMAP_FLAG_WRAP_V = ConvertTexMapFlags(2)
TEXMAP_FLAG_WRAP_UV = ConvertTexMapFlags(3)
FOG_OF_WAR_MASKED = ConvertFogState(1)
FOG_OF_WAR_FOGGED = ConvertFogState(2)
FOG_OF_WAR_VISIBLE = ConvertFogState(4)
CAMERA_MARGIN_LEFT = 0
CAMERA_MARGIN_RIGHT = 1
CAMERA_MARGIN_TOP = 2
CAMERA_MARGIN_BOTTOM = 3
EFFECT_TYPE_EFFECT = ConvertEffectType(0)
EFFECT_TYPE_TARGET = ConvertEffectType(1)
EFFECT_TYPE_CASTER = ConvertEffectType(2)
EFFECT_TYPE_SPECIAL = ConvertEffectType(3)
EFFECT_TYPE_AREA_EFFECT = ConvertEffectType(4)
EFFECT_TYPE_MISSILE = ConvertEffectType(5)
EFFECT_TYPE_LIGHTNING = ConvertEffectType(6)
SOUND_TYPE_EFFECT = ConvertSoundType(0)
SOUND_TYPE_EFFECT_LOOPED = ConvertSoundType(1)
ORIGIN_FRAME_GAME_UI = ConvertOriginFrameType(0)
ORIGIN_FRAME_COMMAND_BUTTON = ConvertOriginFrameType(1)
ORIGIN_FRAME_HERO_BAR = ConvertOriginFrameType(2)
ORIGIN_FRAME_HERO_BUTTON = ConvertOriginFrameType(3)
ORIGIN_FRAME_HERO_HP_BAR = ConvertOriginFrameType(4)
ORIGIN_FRAME_HERO_MANA_BAR = ConvertOriginFrameType(5)
ORIGIN_FRAME_HERO_BUTTON_INDICATOR = ConvertOriginFrameType(6)
ORIGIN_FRAME_ITEM_BUTTON = ConvertOriginFrameType(7)
ORIGIN_FRAME_MINIMAP = ConvertOriginFrameType(8)
ORIGIN_FRAME_MINIMAP_BUTTON = ConvertOriginFrameType(9)
ORIGIN_FRAME_SYSTEM_BUTTON = ConvertOriginFrameType(10)
ORIGIN_FRAME_TOOLTIP = ConvertOriginFrameType(11)
ORIGIN_FRAME_UBERTOOLTIP = ConvertOriginFrameType(12)
ORIGIN_FRAME_CHAT_MSG = ConvertOriginFrameType(13)
ORIGIN_FRAME_UNIT_MSG = ConvertOriginFrameType(14)
ORIGIN_FRAME_TOP_MSG = ConvertOriginFrameType(15)
ORIGIN_FRAME_PORTRAIT = ConvertOriginFrameType(16)
ORIGIN_FRAME_WORLD_FRAME = ConvertOriginFrameType(17)
ORIGIN_FRAME_SIMPLE_UI_PARENT = ConvertOriginFrameType(18)
ORIGIN_FRAME_PORTRAIT_HP_TEXT = ConvertOriginFrameType(19)
ORIGIN_FRAME_PORTRAIT_MANA_TEXT = ConvertOriginFrameType(20)
ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR = ConvertOriginFrameType(21)
ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR_LABEL = ConvertOriginFrameType(22)
FRAMEPOINT_TOPLEFT = ConvertFramePointType(0)
FRAMEPOINT_TOP = ConvertFramePointType(1)
FRAMEPOINT_TOPRIGHT = ConvertFramePointType(2)
FRAMEPOINT_LEFT = ConvertFramePointType(3)
FRAMEPOINT_CENTER = ConvertFramePointType(4)
FRAMEPOINT_RIGHT = ConvertFramePointType(5)
FRAMEPOINT_BOTTOMLEFT = ConvertFramePointType(6)
FRAMEPOINT_BOTTOM = ConvertFramePointType(7)
FRAMEPOINT_BOTTOMRIGHT = ConvertFramePointType(8)
TEXT_JUSTIFY_TOP = ConvertTextAlignType(0)
TEXT_JUSTIFY_MIDDLE = ConvertTextAlignType(1)
TEXT_JUSTIFY_BOTTOM = ConvertTextAlignType(2)
TEXT_JUSTIFY_LEFT = ConvertTextAlignType(3)
TEXT_JUSTIFY_CENTER = ConvertTextAlignType(4)
TEXT_JUSTIFY_RIGHT = ConvertTextAlignType(5)
FRAMEEVENT_CONTROL_CLICK = ConvertFrameEventType(1)
FRAMEEVENT_MOUSE_ENTER = ConvertFrameEventType(2)
FRAMEEVENT_MOUSE_LEAVE = ConvertFrameEventType(3)
FRAMEEVENT_MOUSE_UP = ConvertFrameEventType(4)
FRAMEEVENT_MOUSE_DOWN = ConvertFrameEventType(5)
FRAMEEVENT_MOUSE_WHEEL = ConvertFrameEventType(6)
FRAMEEVENT_CHECKBOX_CHECKED = ConvertFrameEventType(7)
FRAMEEVENT_CHECKBOX_UNCHECKED = ConvertFrameEventType(8)
FRAMEEVENT_EDITBOX_TEXT_CHANGED = ConvertFrameEventType(9)
FRAMEEVENT_POPUPMENU_ITEM_CHANGED = ConvertFrameEventType(10)
FRAMEEVENT_MOUSE_DOUBLECLICK = ConvertFrameEventType(11)
FRAMEEVENT_SPRITE_ANIM_UPDATE = ConvertFrameEventType(12)
FRAMEEVENT_SLIDER_VALUE_CHANGED = ConvertFrameEventType(13)
FRAMEEVENT_DIALOG_CANCEL = ConvertFrameEventType(14)
FRAMEEVENT_DIALOG_ACCEPT = ConvertFrameEventType(15)
FRAMEEVENT_EDITBOX_ENTER = ConvertFrameEventType(16)
OSKEY_BACKSPACE = ConvertOsKeyType(0x8)
OSKEY_TAB = ConvertOsKeyType(0x9)
OSKEY_CLEAR = ConvertOsKeyType(0xc)
OSKEY_RETURN = ConvertOsKeyType(0xd)
OSKEY_SHIFT = ConvertOsKeyType(0x10)
OSKEY_CONTROL = ConvertOsKeyType(0x11)
OSKEY_ALT = ConvertOsKeyType(0x12)
OSKEY_PAUSE = ConvertOsKeyType(0x13)
OSKEY_CAPSLOCK = ConvertOsKeyType(0x14)
OSKEY_KANA = ConvertOsKeyType(0x15)
OSKEY_HANGUL = ConvertOsKeyType(0x15)
OSKEY_JUNJA = ConvertOsKeyType(0x17)
OSKEY_FINAL = ConvertOsKeyType(0x18)
OSKEY_HANJA = ConvertOsKeyType(0x19)
OSKEY_KANJI = ConvertOsKeyType(0x19)
OSKEY_ESCAPE = ConvertOsKeyType(0x1b)
OSKEY_CONVERT = ConvertOsKeyType(0x1c)
OSKEY_NONCONVERT = ConvertOsKeyType(0x1d)
OSKEY_ACCEPT = ConvertOsKeyType(0x1e)
OSKEY_MODECHANGE = ConvertOsKeyType(0x1f)
OSKEY_SPACE = ConvertOsKeyType(0x20)
OSKEY_PAGEUP = ConvertOsKeyType(0x21)
OSKEY_PAGEDOWN = ConvertOsKeyType(0x22)
OSKEY_END = ConvertOsKeyType(0x23)
OSKEY_HOME = ConvertOsKeyType(0x24)
OSKEY_LEFT = ConvertOsKeyType(0x25)
OSKEY_UP = ConvertOsKeyType(0x26)
OSKEY_RIGHT = ConvertOsKeyType(0x27)
OSKEY_DOWN = ConvertOsKeyType(0x28)
OSKEY_SELECT = ConvertOsKeyType(0x29)
OSKEY_PRINT = ConvertOsKeyType(0x2a)
OSKEY_EXECUTE = ConvertOsKeyType(0x2b)
OSKEY_PRINTSCREEN = ConvertOsKeyType(0x2c)
OSKEY_INSERT = ConvertOsKeyType(0x2d)
OSKEY_DELETE = ConvertOsKeyType(0x2e)
OSKEY_HELP = ConvertOsKeyType(0x2f)
OSKEY_0 = ConvertOsKeyType(0x30)
OSKEY_1 = ConvertOsKeyType(0x31)
OSKEY_2 = ConvertOsKeyType(0x32)
OSKEY_3 = ConvertOsKeyType(0x33)
OSKEY_4 = ConvertOsKeyType(0x34)
OSKEY_5 = ConvertOsKeyType(0x35)
OSKEY_6 = ConvertOsKeyType(0x36)
OSKEY_7 = ConvertOsKeyType(0x37)
OSKEY_8 = ConvertOsKeyType(0x38)
OSKEY_9 = ConvertOsKeyType(0x39)
OSKEY_A = ConvertOsKeyType(0x41)
OSKEY_B = ConvertOsKeyType(0x42)
OSKEY_C = ConvertOsKeyType(0x43)
OSKEY_D = ConvertOsKeyType(0x44)
OSKEY_E = ConvertOsKeyType(0x45)
OSKEY_F = ConvertOsKeyType(0x46)
OSKEY_G = ConvertOsKeyType(0x47)
OSKEY_H = ConvertOsKeyType(0x48)
OSKEY_I = ConvertOsKeyType(0x49)
OSKEY_J = ConvertOsKeyType(0x4a)
OSKEY_K = ConvertOsKeyType(0x4b)
OSKEY_L = ConvertOsKeyType(0x4c)
OSKEY_M = ConvertOsKeyType(0x4d)
OSKEY_N = ConvertOsKeyType(0x4e)
OSKEY_O = ConvertOsKeyType(0x4f)
OSKEY_P = ConvertOsKeyType(0x50)
OSKEY_Q = ConvertOsKeyType(0x51)
OSKEY_R = ConvertOsKeyType(0x52)
OSKEY_S = ConvertOsKeyType(0x53)
OSKEY_T = ConvertOsKeyType(0x54)
OSKEY_U = ConvertOsKeyType(0x55)
OSKEY_V = ConvertOsKeyType(0x56)
OSKEY_W = ConvertOsKeyType(0x57)
OSKEY_X = ConvertOsKeyType(0x58)
OSKEY_Y = ConvertOsKeyType(0x59)
OSKEY_Z = ConvertOsKeyType(0x5a)
OSKEY_LMETA = ConvertOsKeyType(0x5b)
OSKEY_RMETA = ConvertOsKeyType(0x5c)
OSKEY_APPS = ConvertOsKeyType(0x5d)
OSKEY_SLEEP = ConvertOsKeyType(0x5f)
OSKEY_NUMPAD0 = ConvertOsKeyType(0x60)
OSKEY_NUMPAD1 = ConvertOsKeyType(0x61)
OSKEY_NUMPAD2 = ConvertOsKeyType(0x62)
OSKEY_NUMPAD3 = ConvertOsKeyType(0x63)
OSKEY_NUMPAD4 = ConvertOsKeyType(0x64)
OSKEY_NUMPAD5 = ConvertOsKeyType(0x65)
OSKEY_NUMPAD6 = ConvertOsKeyType(0x66)
OSKEY_NUMPAD7 = ConvertOsKeyType(0x67)
OSKEY_NUMPAD8 = ConvertOsKeyType(0x68)
OSKEY_NUMPAD9 = ConvertOsKeyType(0x69)
OSKEY_MULTIPLY = ConvertOsKeyType(0x6a)
OSKEY_ADD = ConvertOsKeyType(0x6b)
OSKEY_SEPARATOR = ConvertOsKeyType(0x6c)
OSKEY_SUBTRACT = ConvertOsKeyType(0x6d)
OSKEY_DECIMAL = ConvertOsKeyType(0x6e)
OSKEY_DIVIDE = ConvertOsKeyType(0x6f)
OSKEY_F1 = ConvertOsKeyType(0x70)
OSKEY_F2 = ConvertOsKeyType(0x71)
OSKEY_F3 = ConvertOsKeyType(0x72)
OSKEY_F4 = ConvertOsKeyType(0x73)
OSKEY_F5 = ConvertOsKeyType(0x74)
OSKEY_F6 = ConvertOsKeyType(0x75)
OSKEY_F7 = ConvertOsKeyType(0x76)
OSKEY_F8 = ConvertOsKeyType(0x77)
OSKEY_F9 = ConvertOsKeyType(0x78)
OSKEY_F10 = ConvertOsKeyType(0x79)
OSKEY_F11 = ConvertOsKeyType(0x7a)
OSKEY_F12 = ConvertOsKeyType(0x7b)
OSKEY_F13 = ConvertOsKeyType(0x7c)
OSKEY_F14 = ConvertOsKeyType(0x7d)
OSKEY_F15 = ConvertOsKeyType(0x7e)
OSKEY_F16 = ConvertOsKeyType(0x7f)
OSKEY_F17 = ConvertOsKeyType(0x80)
OSKEY_F18 = ConvertOsKeyType(0x81)
OSKEY_F19 = ConvertOsKeyType(0x82)
OSKEY_F20 = ConvertOsKeyType(0x83)
OSKEY_F21 = ConvertOsKeyType(0x84)
OSKEY_F22 = ConvertOsKeyType(0x85)
OSKEY_F23 = ConvertOsKeyType(0x86)
OSKEY_F24 = ConvertOsKeyType(0x87)
OSKEY_NUMLOCK = ConvertOsKeyType(0x90)
OSKEY_SCROLLLOCK = ConvertOsKeyType(0x91)
OSKEY_OEM_NEC_EQUAL = ConvertOsKeyType(0x92)
OSKEY_OEM_FJ_JISHO = ConvertOsKeyType(0x92)
OSKEY_OEM_FJ_MASSHOU = ConvertOsKeyType(0x93)
OSKEY_OEM_FJ_TOUROKU = ConvertOsKeyType(0x94)
OSKEY_OEM_FJ_LOYA = ConvertOsKeyType(0x95)
OSKEY_OEM_FJ_ROYA = ConvertOsKeyType(0x96)
OSKEY_LSHIFT = ConvertOsKeyType(0xa0)
OSKEY_RSHIFT = ConvertOsKeyType(0xa1)
OSKEY_LCONTROL = ConvertOsKeyType(0xa2)
OSKEY_RCONTROL = ConvertOsKeyType(0xa3)
OSKEY_LALT = ConvertOsKeyType(0xa4)
OSKEY_RALT = ConvertOsKeyType(0xa5)
OSKEY_BROWSER_BACK = ConvertOsKeyType(0xa6)
OSKEY_BROWSER_FORWARD = ConvertOsKeyType(0xa7)
OSKEY_BROWSER_REFRESH = ConvertOsKeyType(0xa8)
OSKEY_BROWSER_STOP = ConvertOsKeyType(0xa9)
OSKEY_BROWSER_SEARCH = ConvertOsKeyType(0xaa)
OSKEY_BROWSER_FAVORITES = ConvertOsKeyType(0xab)
OSKEY_BROWSER_HOME = ConvertOsKeyType(0xac)
OSKEY_VOLUME_MUTE = ConvertOsKeyType(0xad)
OSKEY_VOLUME_DOWN = ConvertOsKeyType(0xae)
OSKEY_VOLUME_UP = ConvertOsKeyType(0xaf)
OSKEY_MEDIA_NEXT_TRACK = ConvertOsKeyType(0xb0)
OSKEY_MEDIA_PREV_TRACK = ConvertOsKeyType(0xb1)
OSKEY_MEDIA_STOP = ConvertOsKeyType(0xb2)
OSKEY_MEDIA_PLAY_PAUSE = ConvertOsKeyType(0xb3)
OSKEY_LAUNCH_MAIL = ConvertOsKeyType(0xb4)
OSKEY_LAUNCH_MEDIA_SELECT = ConvertOsKeyType(0xb5)
OSKEY_LAUNCH_APP1 = ConvertOsKeyType(0xb6)
OSKEY_LAUNCH_APP2 = ConvertOsKeyType(0xb7)
OSKEY_OEM_1 = ConvertOsKeyType(0xba)
OSKEY_OEM_PLUS = ConvertOsKeyType(0xbb)
OSKEY_OEM_COMMA = ConvertOsKeyType(0xbc)
OSKEY_OEM_MINUS = ConvertOsKeyType(0xbd)
OSKEY_OEM_PERIOD = ConvertOsKeyType(0xbe)
OSKEY_OEM_2 = ConvertOsKeyType(0xbf)
OSKEY_OEM_3 = ConvertOsKeyType(0xc0)
OSKEY_OEM_4 = ConvertOsKeyType(0xdb)
OSKEY_OEM_5 = ConvertOsKeyType(0xdc)
OSKEY_OEM_6 = ConvertOsKeyType(0xdd)
OSKEY_OEM_7 = ConvertOsKeyType(0xde)
OSKEY_OEM_8 = ConvertOsKeyType(0xdf)
OSKEY_OEM_AX = ConvertOsKeyType(0xe1)
OSKEY_OEM_102 = ConvertOsKeyType(0xe2)
OSKEY_ICO_HELP = ConvertOsKeyType(0xe3)
OSKEY_ICO_00 = ConvertOsKeyType(0xe4)
OSKEY_PROCESSKEY = ConvertOsKeyType(0xe5)
OSKEY_ICO_CLEAR = ConvertOsKeyType(0xe6)
OSKEY_PACKET = ConvertOsKeyType(0xe7)
OSKEY_OEM_RESET = ConvertOsKeyType(0xe9)
OSKEY_OEM_JUMP = ConvertOsKeyType(0xea)
OSKEY_OEM_PA1 = ConvertOsKeyType(0xeb)
OSKEY_OEM_PA2 = ConvertOsKeyType(0xec)
OSKEY_OEM_PA3 = ConvertOsKeyType(0xed)
OSKEY_OEM_WSCTRL = ConvertOsKeyType(0xee)
OSKEY_OEM_CUSEL = ConvertOsKeyType(0xef)
OSKEY_OEM_ATTN = ConvertOsKeyType(0xf0)
OSKEY_OEM_FINISH = ConvertOsKeyType(0xf1)
OSKEY_OEM_COPY = ConvertOsKeyType(0xf2)
OSKEY_OEM_AUTO = ConvertOsKeyType(0xf3)
OSKEY_OEM_ENLW = ConvertOsKeyType(0xf4)
OSKEY_OEM_BACKTAB = ConvertOsKeyType(0xf5)
OSKEY_ATTN = ConvertOsKeyType(0xf6)
OSKEY_CRSEL = ConvertOsKeyType(0xf7)
OSKEY_EXSEL = ConvertOsKeyType(0xf8)
OSKEY_EREOF = ConvertOsKeyType(0xf9)
OSKEY_PLAY = ConvertOsKeyType(0xfa)
OSKEY_ZOOM = ConvertOsKeyType(0xfb)
OSKEY_NONAME = ConvertOsKeyType(0xfc)
OSKEY_PA1 = ConvertOsKeyType(0xfd)
OSKEY_OEM_CLEAR = ConvertOsKeyType(0xfe)
ABILITY_IF_BUTTON_POSITION_NORMAL_X = ConvertAbilityIntegerField(FourCC("abpx"))
ABILITY_IF_BUTTON_POSITION_NORMAL_Y = ConvertAbilityIntegerField(FourCC("abpy"))
ABILITY_IF_BUTTON_POSITION_ACTIVATED_X = ConvertAbilityIntegerField(FourCC("aubx"))
ABILITY_IF_BUTTON_POSITION_ACTIVATED_Y = ConvertAbilityIntegerField(FourCC("auby"))
ABILITY_IF_BUTTON_POSITION_RESEARCH_X = ConvertAbilityIntegerField(FourCC("arpx"))
ABILITY_IF_BUTTON_POSITION_RESEARCH_Y = ConvertAbilityIntegerField(FourCC("arpy"))
ABILITY_IF_MISSILE_SPEED = ConvertAbilityIntegerField(FourCC("amsp"))
ABILITY_IF_TARGET_ATTACHMENTS = ConvertAbilityIntegerField(FourCC("atac"))
ABILITY_IF_CASTER_ATTACHMENTS = ConvertAbilityIntegerField(FourCC("acac"))
ABILITY_IF_PRIORITY = ConvertAbilityIntegerField(FourCC("apri"))
ABILITY_IF_LEVELS = ConvertAbilityIntegerField(FourCC("alev"))
ABILITY_IF_REQUIRED_LEVEL = ConvertAbilityIntegerField(FourCC("arlv"))
ABILITY_IF_LEVEL_SKIP_REQUIREMENT = ConvertAbilityIntegerField(FourCC("alsk"))
ABILITY_BF_HERO_ABILITY = ConvertAbilityBooleanField(FourCC("aher"))
ABILITY_BF_ITEM_ABILITY = ConvertAbilityBooleanField(FourCC("aite"))
ABILITY_BF_CHECK_DEPENDENCIES = ConvertAbilityBooleanField(FourCC("achd"))
ABILITY_RF_ARF_MISSILE_ARC = ConvertAbilityRealField(FourCC("amac"))
ABILITY_SF_NAME = ConvertAbilityStringField(FourCC("anam"))
ABILITY_SF_ICON_ACTIVATED = ConvertAbilityStringField(FourCC("auar"))
ABILITY_SF_ICON_RESEARCH = ConvertAbilityStringField(FourCC("arar"))
ABILITY_SF_EFFECT_SOUND = ConvertAbilityStringField(FourCC("aefs"))
ABILITY_SF_EFFECT_SOUND_LOOPING = ConvertAbilityStringField(FourCC("aefl"))
ABILITY_ILF_MANA_COST = ConvertAbilityIntegerLevelField(FourCC("amcs"))
ABILITY_ILF_NUMBER_OF_WAVES = ConvertAbilityIntegerLevelField(FourCC("Hbz1"))
ABILITY_ILF_NUMBER_OF_SHARDS = ConvertAbilityIntegerLevelField(FourCC("Hbz3"))
ABILITY_ILF_NUMBER_OF_UNITS_TELEPORTED = ConvertAbilityIntegerLevelField(FourCC("Hmt1"))
ABILITY_ILF_SUMMONED_UNIT_COUNT_HWE2 = ConvertAbilityIntegerLevelField(FourCC("Hwe2"))
ABILITY_ILF_NUMBER_OF_IMAGES = ConvertAbilityIntegerLevelField(FourCC("Omi1"))
ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_UAN1 = ConvertAbilityIntegerLevelField(FourCC("Uan1"))
ABILITY_ILF_MORPHING_FLAGS = ConvertAbilityIntegerLevelField(FourCC("Eme2"))
ABILITY_ILF_STRENGTH_BONUS_NRG5 = ConvertAbilityIntegerLevelField(FourCC("Nrg5"))
ABILITY_ILF_DEFENSE_BONUS_NRG6 = ConvertAbilityIntegerLevelField(FourCC("Nrg6"))
ABILITY_ILF_NUMBER_OF_TARGETS_HIT = ConvertAbilityIntegerLevelField(FourCC("Ocl2"))
ABILITY_ILF_DETECTION_TYPE_OFS1 = ConvertAbilityIntegerLevelField(FourCC("Ofs1"))
ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_OSF2 = ConvertAbilityIntegerLevelField(FourCC("Osf2"))
ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_EFN1 = ConvertAbilityIntegerLevelField(FourCC("Efn1"))
ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_HRE1 = ConvertAbilityIntegerLevelField(FourCC("Hre1"))
ABILITY_ILF_STACK_FLAGS = ConvertAbilityIntegerLevelField(FourCC("Hca4"))
ABILITY_ILF_MINIMUM_NUMBER_OF_UNITS = ConvertAbilityIntegerLevelField(FourCC("Ndp2"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_NDP3 = ConvertAbilityIntegerLevelField(FourCC("Ndp3"))
ABILITY_ILF_NUMBER_OF_UNITS_CREATED_NRC2 = ConvertAbilityIntegerLevelField(FourCC("Nrc2"))
ABILITY_ILF_SHIELD_LIFE = ConvertAbilityIntegerLevelField(FourCC("Ams3"))
ABILITY_ILF_MANA_LOSS_AMS4 = ConvertAbilityIntegerLevelField(FourCC("Ams4"))
ABILITY_ILF_GOLD_PER_INTERVAL_BGM1 = ConvertAbilityIntegerLevelField(FourCC("Bgm1"))
ABILITY_ILF_MAX_NUMBER_OF_MINERS = ConvertAbilityIntegerLevelField(FourCC("Bgm3"))
ABILITY_ILF_CARGO_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("Car1"))
ABILITY_ILF_MAXIMUM_CREEP_LEVEL_DEV3 = ConvertAbilityIntegerLevelField(FourCC("Dev3"))
ABILITY_ILF_MAX_CREEP_LEVEL_DEV1 = ConvertAbilityIntegerLevelField(FourCC("Dev1"))
ABILITY_ILF_GOLD_PER_INTERVAL_EGM1 = ConvertAbilityIntegerLevelField(FourCC("Egm1"))
ABILITY_ILF_DEFENSE_REDUCTION = ConvertAbilityIntegerLevelField(FourCC("Fae1"))
ABILITY_ILF_DETECTION_TYPE_FLA1 = ConvertAbilityIntegerLevelField(FourCC("Fla1"))
ABILITY_ILF_FLARE_COUNT = ConvertAbilityIntegerLevelField(FourCC("Fla3"))
ABILITY_ILF_MAX_GOLD = ConvertAbilityIntegerLevelField(FourCC("Gld1"))
ABILITY_ILF_MINING_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("Gld3"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_CORPSES_GYD1 = ConvertAbilityIntegerLevelField(FourCC("Gyd1"))
ABILITY_ILF_DAMAGE_TO_TREE = ConvertAbilityIntegerLevelField(FourCC("Har1"))
ABILITY_ILF_LUMBER_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("Har2"))
ABILITY_ILF_GOLD_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("Har3"))
ABILITY_ILF_DEFENSE_INCREASE_INF2 = ConvertAbilityIntegerLevelField(FourCC("Inf2"))
ABILITY_ILF_INTERACTION_TYPE = ConvertAbilityIntegerLevelField(FourCC("Neu2"))
ABILITY_ILF_GOLD_COST_NDT1 = ConvertAbilityIntegerLevelField(FourCC("Ndt1"))
ABILITY_ILF_LUMBER_COST_NDT2 = ConvertAbilityIntegerLevelField(FourCC("Ndt2"))
ABILITY_ILF_DETECTION_TYPE_NDT3 = ConvertAbilityIntegerLevelField(FourCC("Ndt3"))
ABILITY_ILF_STACKING_TYPE_POI4 = ConvertAbilityIntegerLevelField(FourCC("Poi4"))
ABILITY_ILF_STACKING_TYPE_POA5 = ConvertAbilityIntegerLevelField(FourCC("Poa5"))
ABILITY_ILF_MAXIMUM_CREEP_LEVEL_PLY1 = ConvertAbilityIntegerLevelField(FourCC("Ply1"))
ABILITY_ILF_MAXIMUM_CREEP_LEVEL_POS1 = ConvertAbilityIntegerLevelField(FourCC("Pos1"))
ABILITY_ILF_MOVEMENT_UPDATE_FREQUENCY_PRG1 = ConvertAbilityIntegerLevelField(FourCC("Prg1"))
ABILITY_ILF_ATTACK_UPDATE_FREQUENCY_PRG2 = ConvertAbilityIntegerLevelField(FourCC("Prg2"))
ABILITY_ILF_MANA_LOSS_PRG6 = ConvertAbilityIntegerLevelField(FourCC("Prg6"))
ABILITY_ILF_UNITS_SUMMONED_TYPE_ONE = ConvertAbilityIntegerLevelField(FourCC("Rai1"))
ABILITY_ILF_UNITS_SUMMONED_TYPE_TWO = ConvertAbilityIntegerLevelField(FourCC("Rai2"))
ABILITY_ILF_MAX_UNITS_SUMMONED = ConvertAbilityIntegerLevelField(FourCC("Ucb5"))
ABILITY_ILF_ALLOW_WHEN_FULL_REJ3 = ConvertAbilityIntegerLevelField(FourCC("Rej3"))
ABILITY_ILF_MAXIMUM_UNITS_CHARGED_TO_CASTER = ConvertAbilityIntegerLevelField(FourCC("Rpb5"))
ABILITY_ILF_MAXIMUM_UNITS_AFFECTED = ConvertAbilityIntegerLevelField(FourCC("Rpb6"))
ABILITY_ILF_DEFENSE_INCREASE_ROA2 = ConvertAbilityIntegerLevelField(FourCC("Roa2"))
ABILITY_ILF_MAX_UNITS_ROA7 = ConvertAbilityIntegerLevelField(FourCC("Roa7"))
ABILITY_ILF_ROOTED_WEAPONS = ConvertAbilityIntegerLevelField(FourCC("Roo1"))
ABILITY_ILF_UPROOTED_WEAPONS = ConvertAbilityIntegerLevelField(FourCC("Roo2"))
ABILITY_ILF_UPROOTED_DEFENSE_TYPE = ConvertAbilityIntegerLevelField(FourCC("Roo4"))
ABILITY_ILF_ACCUMULATION_STEP = ConvertAbilityIntegerLevelField(FourCC("Sal2"))
ABILITY_ILF_NUMBER_OF_OWLS = ConvertAbilityIntegerLevelField(FourCC("Esn4"))
ABILITY_ILF_STACKING_TYPE_SPO4 = ConvertAbilityIntegerLevelField(FourCC("Spo4"))
ABILITY_ILF_NUMBER_OF_UNITS = ConvertAbilityIntegerLevelField(FourCC("Sod1"))
ABILITY_ILF_SPIDER_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("Spa1"))
ABILITY_ILF_INTERVALS_BEFORE_CHANGING_TREES = ConvertAbilityIntegerLevelField(FourCC("Wha2"))
ABILITY_ILF_AGILITY_BONUS = ConvertAbilityIntegerLevelField(FourCC("Iagi"))
ABILITY_ILF_INTELLIGENCE_BONUS = ConvertAbilityIntegerLevelField(FourCC("Iint"))
ABILITY_ILF_STRENGTH_BONUS_ISTR = ConvertAbilityIntegerLevelField(FourCC("Istr"))
ABILITY_ILF_ATTACK_BONUS = ConvertAbilityIntegerLevelField(FourCC("Iatt"))
ABILITY_ILF_DEFENSE_BONUS_IDEF = ConvertAbilityIntegerLevelField(FourCC("Idef"))
ABILITY_ILF_SUMMON_1_AMOUNT = ConvertAbilityIntegerLevelField(FourCC("Isn1"))
ABILITY_ILF_SUMMON_2_AMOUNT = ConvertAbilityIntegerLevelField(FourCC("Isn2"))
ABILITY_ILF_EXPERIENCE_GAINED = ConvertAbilityIntegerLevelField(FourCC("Ixpg"))
ABILITY_ILF_HIT_POINTS_GAINED_IHPG = ConvertAbilityIntegerLevelField(FourCC("Ihpg"))
ABILITY_ILF_MANA_POINTS_GAINED_IMPG = ConvertAbilityIntegerLevelField(FourCC("Impg"))
ABILITY_ILF_HIT_POINTS_GAINED_IHP2 = ConvertAbilityIntegerLevelField(FourCC("Ihp2"))
ABILITY_ILF_MANA_POINTS_GAINED_IMP2 = ConvertAbilityIntegerLevelField(FourCC("Imp2"))
ABILITY_ILF_DAMAGE_BONUS_DICE = ConvertAbilityIntegerLevelField(FourCC("Idic"))
ABILITY_ILF_ARMOR_PENALTY_IARP = ConvertAbilityIntegerLevelField(FourCC("Iarp"))
ABILITY_ILF_ENABLED_ATTACK_INDEX_IOB5 = ConvertAbilityIntegerLevelField(FourCC("Iob5"))
ABILITY_ILF_LEVELS_GAINED = ConvertAbilityIntegerLevelField(FourCC("Ilev"))
ABILITY_ILF_MAX_LIFE_GAINED = ConvertAbilityIntegerLevelField(FourCC("Ilif"))
ABILITY_ILF_MAX_MANA_GAINED = ConvertAbilityIntegerLevelField(FourCC("Iman"))
ABILITY_ILF_GOLD_GIVEN = ConvertAbilityIntegerLevelField(FourCC("Igol"))
ABILITY_ILF_LUMBER_GIVEN = ConvertAbilityIntegerLevelField(FourCC("Ilum"))
ABILITY_ILF_DETECTION_TYPE_IFA1 = ConvertAbilityIntegerLevelField(FourCC("Ifa1"))
ABILITY_ILF_MAXIMUM_CREEP_LEVEL_ICRE = ConvertAbilityIntegerLevelField(FourCC("Icre"))
ABILITY_ILF_MOVEMENT_SPEED_BONUS = ConvertAbilityIntegerLevelField(FourCC("Imvb"))
ABILITY_ILF_HIT_POINTS_REGENERATED_PER_SECOND = ConvertAbilityIntegerLevelField(FourCC("Ihpr"))
ABILITY_ILF_SIGHT_RANGE_BONUS = ConvertAbilityIntegerLevelField(FourCC("Isib"))
ABILITY_ILF_DAMAGE_PER_DURATION = ConvertAbilityIntegerLevelField(FourCC("Icfd"))
ABILITY_ILF_MANA_USED_PER_SECOND = ConvertAbilityIntegerLevelField(FourCC("Icfm"))
ABILITY_ILF_EXTRA_MANA_REQUIRED = ConvertAbilityIntegerLevelField(FourCC("Icfx"))
ABILITY_ILF_DETECTION_RADIUS_IDET = ConvertAbilityIntegerLevelField(FourCC("Idet"))
ABILITY_ILF_MANA_LOSS_PER_UNIT_IDIM = ConvertAbilityIntegerLevelField(FourCC("Idim"))
ABILITY_ILF_DAMAGE_TO_SUMMONED_UNITS_IDID = ConvertAbilityIntegerLevelField(FourCC("Idid"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_IREC = ConvertAbilityIntegerLevelField(FourCC("Irec"))
ABILITY_ILF_DELAY_AFTER_DEATH_SECONDS = ConvertAbilityIntegerLevelField(FourCC("Ircd"))
ABILITY_ILF_RESTORED_LIFE = ConvertAbilityIntegerLevelField(FourCC("irc2"))
ABILITY_ILF_RESTORED_MANA__1_FOR_CURRENT = ConvertAbilityIntegerLevelField(FourCC("irc3"))
ABILITY_ILF_HIT_POINTS_RESTORED = ConvertAbilityIntegerLevelField(FourCC("Ihps"))
ABILITY_ILF_MANA_POINTS_RESTORED = ConvertAbilityIntegerLevelField(FourCC("Imps"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_UNITS_ITPM = ConvertAbilityIntegerLevelField(FourCC("Itpm"))
ABILITY_ILF_NUMBER_OF_CORPSES_RAISED_CAD1 = ConvertAbilityIntegerLevelField(FourCC("Cad1"))
ABILITY_ILF_TERRAIN_DEFORMATION_DURATION_MS = ConvertAbilityIntegerLevelField(FourCC("Wrs3"))
ABILITY_ILF_MAXIMUM_UNITS = ConvertAbilityIntegerLevelField(FourCC("Uds1"))
ABILITY_ILF_DETECTION_TYPE_DET1 = ConvertAbilityIntegerLevelField(FourCC("Det1"))
ABILITY_ILF_GOLD_COST_PER_STRUCTURE = ConvertAbilityIntegerLevelField(FourCC("Nsp1"))
ABILITY_ILF_LUMBER_COST_PER_USE = ConvertAbilityIntegerLevelField(FourCC("Nsp2"))
ABILITY_ILF_DETECTION_TYPE_NSP3 = ConvertAbilityIntegerLevelField(FourCC("Nsp3"))
ABILITY_ILF_NUMBER_OF_SWARM_UNITS = ConvertAbilityIntegerLevelField(FourCC("Uls1"))
ABILITY_ILF_MAX_SWARM_UNITS_PER_TARGET = ConvertAbilityIntegerLevelField(FourCC("Uls3"))
ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_NBA2 = ConvertAbilityIntegerLevelField(FourCC("Nba2"))
ABILITY_ILF_MAXIMUM_CREEP_LEVEL_NCH1 = ConvertAbilityIntegerLevelField(FourCC("Nch1"))
ABILITY_ILF_ATTACKS_PREVENTED = ConvertAbilityIntegerLevelField(FourCC("Nsi1"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_TARGETS_EFK3 = ConvertAbilityIntegerLevelField(FourCC("Efk3"))
ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_ESV1 = ConvertAbilityIntegerLevelField(FourCC("Esv1"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_CORPSES_EXH1 = ConvertAbilityIntegerLevelField(FourCC("exh1"))
ABILITY_ILF_ITEM_CAPACITY = ConvertAbilityIntegerLevelField(FourCC("inv1"))
ABILITY_ILF_MAXIMUM_NUMBER_OF_TARGETS_SPL2 = ConvertAbilityIntegerLevelField(FourCC("spl2"))
ABILITY_ILF_ALLOW_WHEN_FULL_IRL3 = ConvertAbilityIntegerLevelField(FourCC("irl3"))
ABILITY_ILF_MAXIMUM_DISPELLED_UNITS = ConvertAbilityIntegerLevelField(FourCC("idc3"))
ABILITY_ILF_NUMBER_OF_LURES = ConvertAbilityIntegerLevelField(FourCC("imo1"))
ABILITY_ILF_NEW_TIME_OF_DAY_HOUR = ConvertAbilityIntegerLevelField(FourCC("ict1"))
ABILITY_ILF_NEW_TIME_OF_DAY_MINUTE = ConvertAbilityIntegerLevelField(FourCC("ict2"))
ABILITY_ILF_NUMBER_OF_UNITS_CREATED_MEC1 = ConvertAbilityIntegerLevelField(FourCC("mec1"))
ABILITY_ILF_MINIMUM_SPELLS = ConvertAbilityIntegerLevelField(FourCC("spb3"))
ABILITY_ILF_MAXIMUM_SPELLS = ConvertAbilityIntegerLevelField(FourCC("spb4"))
ABILITY_ILF_DISABLED_ATTACK_INDEX = ConvertAbilityIntegerLevelField(FourCC("gra3"))
ABILITY_ILF_ENABLED_ATTACK_INDEX_GRA4 = ConvertAbilityIntegerLevelField(FourCC("gra4"))
ABILITY_ILF_MAXIMUM_ATTACKS = ConvertAbilityIntegerLevelField(FourCC("gra5"))
ABILITY_ILF_BUILDING_TYPES_ALLOWED_NPR1 = ConvertAbilityIntegerLevelField(FourCC("Npr1"))
ABILITY_ILF_BUILDING_TYPES_ALLOWED_NSA1 = ConvertAbilityIntegerLevelField(FourCC("Nsa1"))
ABILITY_ILF_ATTACK_MODIFICATION = ConvertAbilityIntegerLevelField(FourCC("Iaa1"))
ABILITY_ILF_SUMMONED_UNIT_COUNT_NPA5 = ConvertAbilityIntegerLevelField(FourCC("Npa5"))
ABILITY_ILF_UPGRADE_LEVELS = ConvertAbilityIntegerLevelField(FourCC("Igl1"))
ABILITY_ILF_NUMBER_OF_SUMMONED_UNITS_NDO2 = ConvertAbilityIntegerLevelField(FourCC("Ndo2"))
ABILITY_ILF_BEASTS_PER_SECOND = ConvertAbilityIntegerLevelField(FourCC("Nst1"))
ABILITY_ILF_TARGET_TYPE = ConvertAbilityIntegerLevelField(FourCC("Ncl2"))
ABILITY_ILF_OPTIONS = ConvertAbilityIntegerLevelField(FourCC("Ncl3"))
ABILITY_ILF_ARMOR_PENALTY_NAB3 = ConvertAbilityIntegerLevelField(FourCC("Nab3"))
ABILITY_ILF_WAVE_COUNT_NHS6 = ConvertAbilityIntegerLevelField(FourCC("Nhs6"))
ABILITY_ILF_MAX_CREEP_LEVEL_NTM3 = ConvertAbilityIntegerLevelField(FourCC("Ntm3"))
ABILITY_ILF_MISSILE_COUNT = ConvertAbilityIntegerLevelField(FourCC("Ncs3"))
ABILITY_ILF_SPLIT_ATTACK_COUNT = ConvertAbilityIntegerLevelField(FourCC("Nlm3"))
ABILITY_ILF_GENERATION_COUNT = ConvertAbilityIntegerLevelField(FourCC("Nlm6"))
ABILITY_ILF_ROCK_RING_COUNT = ConvertAbilityIntegerLevelField(FourCC("Nvc1"))
ABILITY_ILF_WAVE_COUNT_NVC2 = ConvertAbilityIntegerLevelField(FourCC("Nvc2"))
ABILITY_ILF_PREFER_HOSTILES_TAU1 = ConvertAbilityIntegerLevelField(FourCC("Tau1"))
ABILITY_ILF_PREFER_FRIENDLIES_TAU2 = ConvertAbilityIntegerLevelField(FourCC("Tau2"))
ABILITY_ILF_MAX_UNITS_TAU3 = ConvertAbilityIntegerLevelField(FourCC("Tau3"))
ABILITY_ILF_NUMBER_OF_PULSES = ConvertAbilityIntegerLevelField(FourCC("Tau4"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_HWE1 = ConvertAbilityIntegerLevelField(FourCC("Hwe1"))
ABILITY_ILF_SUMMONED_UNIT_UIN4 = ConvertAbilityIntegerLevelField(FourCC("Uin4"))
ABILITY_ILF_SUMMONED_UNIT_OSF1 = ConvertAbilityIntegerLevelField(FourCC("Osf1"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_EFNU = ConvertAbilityIntegerLevelField(FourCC("Efnu"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_NBAU = ConvertAbilityIntegerLevelField(FourCC("Nbau"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_NTOU = ConvertAbilityIntegerLevelField(FourCC("Ntou"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_ESVU = ConvertAbilityIntegerLevelField(FourCC("Esvu"))
ABILITY_ILF_SUMMONED_UNIT_TYPES = ConvertAbilityIntegerLevelField(FourCC("Nef1"))
ABILITY_ILF_SUMMONED_UNIT_TYPE_NDOU = ConvertAbilityIntegerLevelField(FourCC("Ndou"))
ABILITY_ILF_ALTERNATE_FORM_UNIT_EMEU = ConvertAbilityIntegerLevelField(FourCC("Emeu"))
ABILITY_ILF_PLAGUE_WARD_UNIT_TYPE = ConvertAbilityIntegerLevelField(FourCC("Aplu"))
ABILITY_ILF_ALLOWED_UNIT_TYPE_BTL1 = ConvertAbilityIntegerLevelField(FourCC("Btl1"))
ABILITY_ILF_NEW_UNIT_TYPE = ConvertAbilityIntegerLevelField(FourCC("Cha1"))
ABILITY_ILF_RESULTING_UNIT_TYPE_ENT1 = ConvertAbilityIntegerLevelField(FourCC("ent1"))
ABILITY_ILF_CORPSE_UNIT_TYPE = ConvertAbilityIntegerLevelField(FourCC("Gydu"))
ABILITY_ILF_ALLOWED_UNIT_TYPE_LOA1 = ConvertAbilityIntegerLevelField(FourCC("Loa1"))
ABILITY_ILF_UNIT_TYPE_FOR_LIMIT_CHECK = ConvertAbilityIntegerLevelField(FourCC("Raiu"))
ABILITY_ILF_WARD_UNIT_TYPE_STAU = ConvertAbilityIntegerLevelField(FourCC("Stau"))
ABILITY_ILF_EFFECT_ABILITY = ConvertAbilityIntegerLevelField(FourCC("Iobu"))
ABILITY_ILF_CONVERSION_UNIT = ConvertAbilityIntegerLevelField(FourCC("Ndc2"))
ABILITY_ILF_UNIT_TO_PRESERVE = ConvertAbilityIntegerLevelField(FourCC("Nsl1"))
ABILITY_ILF_UNIT_TYPE_ALLOWED = ConvertAbilityIntegerLevelField(FourCC("Chl1"))
ABILITY_ILF_SWARM_UNIT_TYPE = ConvertAbilityIntegerLevelField(FourCC("Ulsu"))
ABILITY_ILF_RESULTING_UNIT_TYPE_COAU = ConvertAbilityIntegerLevelField(FourCC("coau"))
ABILITY_ILF_UNIT_TYPE_EXHU = ConvertAbilityIntegerLevelField(FourCC("exhu"))
ABILITY_ILF_WARD_UNIT_TYPE_HWDU = ConvertAbilityIntegerLevelField(FourCC("hwdu"))
ABILITY_ILF_LURE_UNIT_TYPE = ConvertAbilityIntegerLevelField(FourCC("imou"))
ABILITY_ILF_UNIT_TYPE_IPMU = ConvertAbilityIntegerLevelField(FourCC("ipmu"))
ABILITY_ILF_FACTORY_UNIT_ID = ConvertAbilityIntegerLevelField(FourCC("Nsyu"))
ABILITY_ILF_SPAWN_UNIT_ID_NFYU = ConvertAbilityIntegerLevelField(FourCC("Nfyu"))
ABILITY_ILF_DESTRUCTIBLE_ID = ConvertAbilityIntegerLevelField(FourCC("Nvcu"))
ABILITY_ILF_UPGRADE_TYPE = ConvertAbilityIntegerLevelField(FourCC("Iglu"))
ABILITY_RLF_CASTING_TIME = ConvertAbilityRealLevelField(FourCC("acas"))
ABILITY_RLF_DURATION_NORMAL = ConvertAbilityRealLevelField(FourCC("adur"))
ABILITY_RLF_DURATION_HERO = ConvertAbilityRealLevelField(FourCC("ahdu"))
ABILITY_RLF_COOLDOWN = ConvertAbilityRealLevelField(FourCC("acdn"))
ABILITY_RLF_AREA_OF_EFFECT = ConvertAbilityRealLevelField(FourCC("aare"))
ABILITY_RLF_CAST_RANGE = ConvertAbilityRealLevelField(FourCC("aran"))
ABILITY_RLF_DAMAGE_HBZ2 = ConvertAbilityRealLevelField(FourCC("Hbz2"))
ABILITY_RLF_BUILDING_REDUCTION_HBZ4 = ConvertAbilityRealLevelField(FourCC("Hbz4"))
ABILITY_RLF_DAMAGE_PER_SECOND_HBZ5 = ConvertAbilityRealLevelField(FourCC("Hbz5"))
ABILITY_RLF_MAXIMUM_DAMAGE_PER_WAVE = ConvertAbilityRealLevelField(FourCC("Hbz6"))
ABILITY_RLF_MANA_REGENERATION_INCREASE = ConvertAbilityRealLevelField(FourCC("Hab1"))
ABILITY_RLF_CASTING_DELAY = ConvertAbilityRealLevelField(FourCC("Hmt2"))
ABILITY_RLF_DAMAGE_PER_SECOND_OWW1 = ConvertAbilityRealLevelField(FourCC("Oww1"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_OWW2 = ConvertAbilityRealLevelField(FourCC("Oww2"))
ABILITY_RLF_CHANCE_TO_CRITICAL_STRIKE = ConvertAbilityRealLevelField(FourCC("Ocr1"))
ABILITY_RLF_DAMAGE_MULTIPLIER_OCR2 = ConvertAbilityRealLevelField(FourCC("Ocr2"))
ABILITY_RLF_DAMAGE_BONUS_OCR3 = ConvertAbilityRealLevelField(FourCC("Ocr3"))
ABILITY_RLF_CHANCE_TO_EVADE_OCR4 = ConvertAbilityRealLevelField(FourCC("Ocr4"))
ABILITY_RLF_DAMAGE_DEALT_PERCENT_OMI2 = ConvertAbilityRealLevelField(FourCC("Omi2"))
ABILITY_RLF_DAMAGE_TAKEN_PERCENT_OMI3 = ConvertAbilityRealLevelField(FourCC("Omi3"))
ABILITY_RLF_ANIMATION_DELAY = ConvertAbilityRealLevelField(FourCC("Omi4"))
ABILITY_RLF_TRANSITION_TIME = ConvertAbilityRealLevelField(FourCC("Owk1"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_OWK2 = ConvertAbilityRealLevelField(FourCC("Owk2"))
ABILITY_RLF_BACKSTAB_DAMAGE = ConvertAbilityRealLevelField(FourCC("Owk3"))
ABILITY_RLF_AMOUNT_HEALED_DAMAGED_UDC1 = ConvertAbilityRealLevelField(FourCC("Udc1"))
ABILITY_RLF_LIFE_CONVERTED_TO_MANA = ConvertAbilityRealLevelField(FourCC("Udp1"))
ABILITY_RLF_LIFE_CONVERTED_TO_LIFE = ConvertAbilityRealLevelField(FourCC("Udp2"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_UAU1 = ConvertAbilityRealLevelField(FourCC("Uau1"))
ABILITY_RLF_LIFE_REGENERATION_INCREASE_PERCENT = ConvertAbilityRealLevelField(FourCC("Uau2"))
ABILITY_RLF_CHANCE_TO_EVADE_EEV1 = ConvertAbilityRealLevelField(FourCC("Eev1"))
ABILITY_RLF_DAMAGE_PER_INTERVAL = ConvertAbilityRealLevelField(FourCC("Eim1"))
ABILITY_RLF_MANA_DRAINED_PER_SECOND_EIM2 = ConvertAbilityRealLevelField(FourCC("Eim2"))
ABILITY_RLF_BUFFER_MANA_REQUIRED = ConvertAbilityRealLevelField(FourCC("Eim3"))
ABILITY_RLF_MAX_MANA_DRAINED = ConvertAbilityRealLevelField(FourCC("Emb1"))
ABILITY_RLF_BOLT_DELAY = ConvertAbilityRealLevelField(FourCC("Emb2"))
ABILITY_RLF_BOLT_LIFETIME = ConvertAbilityRealLevelField(FourCC("Emb3"))
ABILITY_RLF_ALTITUDE_ADJUSTMENT_DURATION = ConvertAbilityRealLevelField(FourCC("Eme3"))
ABILITY_RLF_LANDING_DELAY_TIME = ConvertAbilityRealLevelField(FourCC("Eme4"))
ABILITY_RLF_ALTERNATE_FORM_HIT_POINT_BONUS = ConvertAbilityRealLevelField(FourCC("Eme5"))
ABILITY_RLF_MOVE_SPEED_BONUS_INFO_PANEL_ONLY = ConvertAbilityRealLevelField(FourCC("Ncr5"))
ABILITY_RLF_ATTACK_SPEED_BONUS_INFO_PANEL_ONLY = ConvertAbilityRealLevelField(FourCC("Ncr6"))
ABILITY_RLF_LIFE_REGENERATION_RATE_PER_SECOND = ConvertAbilityRealLevelField(FourCC("ave5"))
ABILITY_RLF_STUN_DURATION_USL1 = ConvertAbilityRealLevelField(FourCC("Usl1"))
ABILITY_RLF_ATTACK_DAMAGE_STOLEN_PERCENT = ConvertAbilityRealLevelField(FourCC("Uav1"))
ABILITY_RLF_DAMAGE_UCS1 = ConvertAbilityRealLevelField(FourCC("Ucs1"))
ABILITY_RLF_MAX_DAMAGE_UCS2 = ConvertAbilityRealLevelField(FourCC("Ucs2"))
ABILITY_RLF_DISTANCE_UCS3 = ConvertAbilityRealLevelField(FourCC("Ucs3"))
ABILITY_RLF_FINAL_AREA_UCS4 = ConvertAbilityRealLevelField(FourCC("Ucs4"))
ABILITY_RLF_DAMAGE_UIN1 = ConvertAbilityRealLevelField(FourCC("Uin1"))
ABILITY_RLF_DURATION = ConvertAbilityRealLevelField(FourCC("Uin2"))
ABILITY_RLF_IMPACT_DELAY = ConvertAbilityRealLevelField(FourCC("Uin3"))
ABILITY_RLF_DAMAGE_PER_TARGET_OCL1 = ConvertAbilityRealLevelField(FourCC("Ocl1"))
ABILITY_RLF_DAMAGE_REDUCTION_PER_TARGET = ConvertAbilityRealLevelField(FourCC("Ocl3"))
ABILITY_RLF_EFFECT_DELAY_OEQ1 = ConvertAbilityRealLevelField(FourCC("Oeq1"))
ABILITY_RLF_DAMAGE_PER_SECOND_TO_BUILDINGS = ConvertAbilityRealLevelField(FourCC("Oeq2"))
ABILITY_RLF_UNITS_SLOWED_PERCENT = ConvertAbilityRealLevelField(FourCC("Oeq3"))
ABILITY_RLF_FINAL_AREA_OEQ4 = ConvertAbilityRealLevelField(FourCC("Oeq4"))
ABILITY_RLF_DAMAGE_PER_SECOND_EER1 = ConvertAbilityRealLevelField(FourCC("Eer1"))
ABILITY_RLF_DAMAGE_DEALT_TO_ATTACKERS = ConvertAbilityRealLevelField(FourCC("Eah1"))
ABILITY_RLF_LIFE_HEALED = ConvertAbilityRealLevelField(FourCC("Etq1"))
ABILITY_RLF_HEAL_INTERVAL = ConvertAbilityRealLevelField(FourCC("Etq2"))
ABILITY_RLF_BUILDING_REDUCTION_ETQ3 = ConvertAbilityRealLevelField(FourCC("Etq3"))
ABILITY_RLF_INITIAL_IMMUNITY_DURATION = ConvertAbilityRealLevelField(FourCC("Etq4"))
ABILITY_RLF_MAX_LIFE_DRAINED_PER_SECOND_PERCENT = ConvertAbilityRealLevelField(FourCC("Udd1"))
ABILITY_RLF_BUILDING_REDUCTION_UDD2 = ConvertAbilityRealLevelField(FourCC("Udd2"))
ABILITY_RLF_ARMOR_DURATION = ConvertAbilityRealLevelField(FourCC("Ufa1"))
ABILITY_RLF_ARMOR_BONUS_UFA2 = ConvertAbilityRealLevelField(FourCC("Ufa2"))
ABILITY_RLF_AREA_OF_EFFECT_DAMAGE = ConvertAbilityRealLevelField(FourCC("Ufn1"))
ABILITY_RLF_SPECIFIC_TARGET_DAMAGE_UFN2 = ConvertAbilityRealLevelField(FourCC("Ufn2"))
ABILITY_RLF_DAMAGE_BONUS_HFA1 = ConvertAbilityRealLevelField(FourCC("Hfa1"))
ABILITY_RLF_DAMAGE_DEALT_ESF1 = ConvertAbilityRealLevelField(FourCC("Esf1"))
ABILITY_RLF_DAMAGE_INTERVAL_ESF2 = ConvertAbilityRealLevelField(FourCC("Esf2"))
ABILITY_RLF_BUILDING_REDUCTION_ESF3 = ConvertAbilityRealLevelField(FourCC("Esf3"))
ABILITY_RLF_DAMAGE_BONUS_PERCENT = ConvertAbilityRealLevelField(FourCC("Ear1"))
ABILITY_RLF_DEFENSE_BONUS_HAV1 = ConvertAbilityRealLevelField(FourCC("Hav1"))
ABILITY_RLF_HIT_POINT_BONUS = ConvertAbilityRealLevelField(FourCC("Hav2"))
ABILITY_RLF_DAMAGE_BONUS_HAV3 = ConvertAbilityRealLevelField(FourCC("Hav3"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_HAV4 = ConvertAbilityRealLevelField(FourCC("Hav4"))
ABILITY_RLF_CHANCE_TO_BASH = ConvertAbilityRealLevelField(FourCC("Hbh1"))
ABILITY_RLF_DAMAGE_MULTIPLIER_HBH2 = ConvertAbilityRealLevelField(FourCC("Hbh2"))
ABILITY_RLF_DAMAGE_BONUS_HBH3 = ConvertAbilityRealLevelField(FourCC("Hbh3"))
ABILITY_RLF_CHANCE_TO_MISS_HBH4 = ConvertAbilityRealLevelField(FourCC("Hbh4"))
ABILITY_RLF_DAMAGE_HTB1 = ConvertAbilityRealLevelField(FourCC("Htb1"))
ABILITY_RLF_AOE_DAMAGE = ConvertAbilityRealLevelField(FourCC("Htc1"))
ABILITY_RLF_SPECIFIC_TARGET_DAMAGE_HTC2 = ConvertAbilityRealLevelField(FourCC("Htc2"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_HTC3 = ConvertAbilityRealLevelField(FourCC("Htc3"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_HTC4 = ConvertAbilityRealLevelField(FourCC("Htc4"))
ABILITY_RLF_ARMOR_BONUS_HAD1 = ConvertAbilityRealLevelField(FourCC("Had1"))
ABILITY_RLF_AMOUNT_HEALED_DAMAGED_HHB1 = ConvertAbilityRealLevelField(FourCC("Hhb1"))
ABILITY_RLF_EXTRA_DAMAGE_HCA1 = ConvertAbilityRealLevelField(FourCC("Hca1"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_HCA2 = ConvertAbilityRealLevelField(FourCC("Hca2"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_HCA3 = ConvertAbilityRealLevelField(FourCC("Hca3"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_OAE1 = ConvertAbilityRealLevelField(FourCC("Oae1"))
ABILITY_RLF_ATTACK_SPEED_INCREASE_PERCENT_OAE2 = ConvertAbilityRealLevelField(FourCC("Oae2"))
ABILITY_RLF_REINCARNATION_DELAY = ConvertAbilityRealLevelField(FourCC("Ore1"))
ABILITY_RLF_DAMAGE_OSH1 = ConvertAbilityRealLevelField(FourCC("Osh1"))
ABILITY_RLF_MAXIMUM_DAMAGE_OSH2 = ConvertAbilityRealLevelField(FourCC("Osh2"))
ABILITY_RLF_DISTANCE_OSH3 = ConvertAbilityRealLevelField(FourCC("Osh3"))
ABILITY_RLF_FINAL_AREA_OSH4 = ConvertAbilityRealLevelField(FourCC("Osh4"))
ABILITY_RLF_GRAPHIC_DELAY_NFD1 = ConvertAbilityRealLevelField(FourCC("Nfd1"))
ABILITY_RLF_GRAPHIC_DURATION_NFD2 = ConvertAbilityRealLevelField(FourCC("Nfd2"))
ABILITY_RLF_DAMAGE_NFD3 = ConvertAbilityRealLevelField(FourCC("Nfd3"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_AMS1 = ConvertAbilityRealLevelField(FourCC("Ams1"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_AMS2 = ConvertAbilityRealLevelField(FourCC("Ams2"))
ABILITY_RLF_AURA_DURATION = ConvertAbilityRealLevelField(FourCC("Apl1"))
ABILITY_RLF_DAMAGE_PER_SECOND_APL2 = ConvertAbilityRealLevelField(FourCC("Apl2"))
ABILITY_RLF_DURATION_OF_PLAGUE_WARD = ConvertAbilityRealLevelField(FourCC("Apl3"))
ABILITY_RLF_AMOUNT_OF_HIT_POINTS_REGENERATED = ConvertAbilityRealLevelField(FourCC("Oar1"))
ABILITY_RLF_ATTACK_DAMAGE_INCREASE_AKB1 = ConvertAbilityRealLevelField(FourCC("Akb1"))
ABILITY_RLF_MANA_LOSS_ADM1 = ConvertAbilityRealLevelField(FourCC("Adm1"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_ADM2 = ConvertAbilityRealLevelField(FourCC("Adm2"))
ABILITY_RLF_EXPANSION_AMOUNT = ConvertAbilityRealLevelField(FourCC("Bli1"))
ABILITY_RLF_INTERVAL_DURATION_BGM2 = ConvertAbilityRealLevelField(FourCC("Bgm2"))
ABILITY_RLF_RADIUS_OF_MINING_RING = ConvertAbilityRealLevelField(FourCC("Bgm4"))
ABILITY_RLF_ATTACK_SPEED_INCREASE_PERCENT_BLO1 = ConvertAbilityRealLevelField(FourCC("Blo1"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_PERCENT_BLO2 = ConvertAbilityRealLevelField(FourCC("Blo2"))
ABILITY_RLF_SCALING_FACTOR = ConvertAbilityRealLevelField(FourCC("Blo3"))
ABILITY_RLF_HIT_POINTS_PER_SECOND_CAN1 = ConvertAbilityRealLevelField(FourCC("Can1"))
ABILITY_RLF_MAX_HIT_POINTS = ConvertAbilityRealLevelField(FourCC("Can2"))
ABILITY_RLF_DAMAGE_PER_SECOND_DEV2 = ConvertAbilityRealLevelField(FourCC("Dev2"))
ABILITY_RLF_MOVEMENT_UPDATE_FREQUENCY_CHD1 = ConvertAbilityRealLevelField(FourCC("Chd1"))
ABILITY_RLF_ATTACK_UPDATE_FREQUENCY_CHD2 = ConvertAbilityRealLevelField(FourCC("Chd2"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_CHD3 = ConvertAbilityRealLevelField(FourCC("Chd3"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_CRI1 = ConvertAbilityRealLevelField(FourCC("Cri1"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_CRI2 = ConvertAbilityRealLevelField(FourCC("Cri2"))
ABILITY_RLF_DAMAGE_REDUCTION_CRI3 = ConvertAbilityRealLevelField(FourCC("Cri3"))
ABILITY_RLF_CHANCE_TO_MISS_CRS = ConvertAbilityRealLevelField(FourCC("Crs1"))
ABILITY_RLF_FULL_DAMAGE_RADIUS_DDA1 = ConvertAbilityRealLevelField(FourCC("Dda1"))
ABILITY_RLF_FULL_DAMAGE_AMOUNT_DDA2 = ConvertAbilityRealLevelField(FourCC("Dda2"))
ABILITY_RLF_PARTIAL_DAMAGE_RADIUS = ConvertAbilityRealLevelField(FourCC("Dda3"))
ABILITY_RLF_PARTIAL_DAMAGE_AMOUNT = ConvertAbilityRealLevelField(FourCC("Dda4"))
ABILITY_RLF_BUILDING_DAMAGE_FACTOR_SDS1 = ConvertAbilityRealLevelField(FourCC("Sds1"))
ABILITY_RLF_MAX_DAMAGE_UCO5 = ConvertAbilityRealLevelField(FourCC("Uco5"))
ABILITY_RLF_MOVE_SPEED_BONUS_UCO6 = ConvertAbilityRealLevelField(FourCC("Uco6"))
ABILITY_RLF_DAMAGE_TAKEN_PERCENT_DEF1 = ConvertAbilityRealLevelField(FourCC("Def1"))
ABILITY_RLF_DAMAGE_DEALT_PERCENT_DEF2 = ConvertAbilityRealLevelField(FourCC("Def2"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_DEF3 = ConvertAbilityRealLevelField(FourCC("Def3"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_DEF4 = ConvertAbilityRealLevelField(FourCC("Def4"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_DEF5 = ConvertAbilityRealLevelField(FourCC("Def5"))
ABILITY_RLF_CHANCE_TO_DEFLECT = ConvertAbilityRealLevelField(FourCC("Def6"))
ABILITY_RLF_DEFLECT_DAMAGE_TAKEN_PIERCING = ConvertAbilityRealLevelField(FourCC("Def7"))
ABILITY_RLF_DEFLECT_DAMAGE_TAKEN_SPELLS = ConvertAbilityRealLevelField(FourCC("Def8"))
ABILITY_RLF_RIP_DELAY = ConvertAbilityRealLevelField(FourCC("Eat1"))
ABILITY_RLF_EAT_DELAY = ConvertAbilityRealLevelField(FourCC("Eat2"))
ABILITY_RLF_HIT_POINTS_GAINED_EAT3 = ConvertAbilityRealLevelField(FourCC("Eat3"))
ABILITY_RLF_AIR_UNIT_LOWER_DURATION = ConvertAbilityRealLevelField(FourCC("Ens1"))
ABILITY_RLF_AIR_UNIT_HEIGHT = ConvertAbilityRealLevelField(FourCC("Ens2"))
ABILITY_RLF_MELEE_ATTACK_RANGE = ConvertAbilityRealLevelField(FourCC("Ens3"))
ABILITY_RLF_INTERVAL_DURATION_EGM2 = ConvertAbilityRealLevelField(FourCC("Egm2"))
ABILITY_RLF_EFFECT_DELAY_FLA2 = ConvertAbilityRealLevelField(FourCC("Fla2"))
ABILITY_RLF_MINING_DURATION = ConvertAbilityRealLevelField(FourCC("Gld2"))
ABILITY_RLF_RADIUS_OF_GRAVESTONES = ConvertAbilityRealLevelField(FourCC("Gyd2"))
ABILITY_RLF_RADIUS_OF_CORPSES = ConvertAbilityRealLevelField(FourCC("Gyd3"))
ABILITY_RLF_HIT_POINTS_GAINED_HEA1 = ConvertAbilityRealLevelField(FourCC("Hea1"))
ABILITY_RLF_DAMAGE_INCREASE_PERCENT_INF1 = ConvertAbilityRealLevelField(FourCC("Inf1"))
ABILITY_RLF_AUTOCAST_RANGE = ConvertAbilityRealLevelField(FourCC("Inf3"))
ABILITY_RLF_LIFE_REGEN_RATE = ConvertAbilityRealLevelField(FourCC("Inf4"))
ABILITY_RLF_GRAPHIC_DELAY_LIT1 = ConvertAbilityRealLevelField(FourCC("Lit1"))
ABILITY_RLF_GRAPHIC_DURATION_LIT2 = ConvertAbilityRealLevelField(FourCC("Lit2"))
ABILITY_RLF_DAMAGE_PER_SECOND_LSH1 = ConvertAbilityRealLevelField(FourCC("Lsh1"))
ABILITY_RLF_MANA_GAINED = ConvertAbilityRealLevelField(FourCC("Mbt1"))
ABILITY_RLF_HIT_POINTS_GAINED_MBT2 = ConvertAbilityRealLevelField(FourCC("Mbt2"))
ABILITY_RLF_AUTOCAST_REQUIREMENT = ConvertAbilityRealLevelField(FourCC("Mbt3"))
ABILITY_RLF_WATER_HEIGHT = ConvertAbilityRealLevelField(FourCC("Mbt4"))
ABILITY_RLF_ACTIVATION_DELAY_MIN1 = ConvertAbilityRealLevelField(FourCC("Min1"))
ABILITY_RLF_INVISIBILITY_TRANSITION_TIME = ConvertAbilityRealLevelField(FourCC("Min2"))
ABILITY_RLF_ACTIVATION_RADIUS = ConvertAbilityRealLevelField(FourCC("Neu1"))
ABILITY_RLF_AMOUNT_REGENERATED = ConvertAbilityRealLevelField(FourCC("Arm1"))
ABILITY_RLF_DAMAGE_PER_SECOND_POI1 = ConvertAbilityRealLevelField(FourCC("Poi1"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_POI2 = ConvertAbilityRealLevelField(FourCC("Poi2"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_POI3 = ConvertAbilityRealLevelField(FourCC("Poi3"))
ABILITY_RLF_EXTRA_DAMAGE_POA1 = ConvertAbilityRealLevelField(FourCC("Poa1"))
ABILITY_RLF_DAMAGE_PER_SECOND_POA2 = ConvertAbilityRealLevelField(FourCC("Poa2"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_POA3 = ConvertAbilityRealLevelField(FourCC("Poa3"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_POA4 = ConvertAbilityRealLevelField(FourCC("Poa4"))
ABILITY_RLF_DAMAGE_AMPLIFICATION = ConvertAbilityRealLevelField(FourCC("Pos2"))
ABILITY_RLF_CHANCE_TO_STOMP_PERCENT = ConvertAbilityRealLevelField(FourCC("War1"))
ABILITY_RLF_DAMAGE_DEALT_WAR2 = ConvertAbilityRealLevelField(FourCC("War2"))
ABILITY_RLF_FULL_DAMAGE_RADIUS_WAR3 = ConvertAbilityRealLevelField(FourCC("War3"))
ABILITY_RLF_HALF_DAMAGE_RADIUS_WAR4 = ConvertAbilityRealLevelField(FourCC("War4"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_PRG3 = ConvertAbilityRealLevelField(FourCC("Prg3"))
ABILITY_RLF_UNIT_PAUSE_DURATION = ConvertAbilityRealLevelField(FourCC("Prg4"))
ABILITY_RLF_HERO_PAUSE_DURATION = ConvertAbilityRealLevelField(FourCC("Prg5"))
ABILITY_RLF_HIT_POINTS_GAINED_REJ1 = ConvertAbilityRealLevelField(FourCC("Rej1"))
ABILITY_RLF_MANA_POINTS_GAINED_REJ2 = ConvertAbilityRealLevelField(FourCC("Rej2"))
ABILITY_RLF_MINIMUM_LIFE_REQUIRED = ConvertAbilityRealLevelField(FourCC("Rpb3"))
ABILITY_RLF_MINIMUM_MANA_REQUIRED = ConvertAbilityRealLevelField(FourCC("Rpb4"))
ABILITY_RLF_REPAIR_COST_RATIO = ConvertAbilityRealLevelField(FourCC("Rep1"))
ABILITY_RLF_REPAIR_TIME_RATIO = ConvertAbilityRealLevelField(FourCC("Rep2"))
ABILITY_RLF_POWERBUILD_COST = ConvertAbilityRealLevelField(FourCC("Rep3"))
ABILITY_RLF_POWERBUILD_RATE = ConvertAbilityRealLevelField(FourCC("Rep4"))
ABILITY_RLF_NAVAL_RANGE_BONUS = ConvertAbilityRealLevelField(FourCC("Rep5"))
ABILITY_RLF_DAMAGE_INCREASE_PERCENT_ROA1 = ConvertAbilityRealLevelField(FourCC("Roa1"))
ABILITY_RLF_LIFE_REGENERATION_RATE = ConvertAbilityRealLevelField(FourCC("Roa3"))
ABILITY_RLF_MANA_REGEN = ConvertAbilityRealLevelField(FourCC("Roa4"))
ABILITY_RLF_DAMAGE_INCREASE = ConvertAbilityRealLevelField(FourCC("Nbr1"))
ABILITY_RLF_SALVAGE_COST_RATIO = ConvertAbilityRealLevelField(FourCC("Sal1"))
ABILITY_RLF_IN_FLIGHT_SIGHT_RADIUS = ConvertAbilityRealLevelField(FourCC("Esn1"))
ABILITY_RLF_HOVERING_SIGHT_RADIUS = ConvertAbilityRealLevelField(FourCC("Esn2"))
ABILITY_RLF_HOVERING_HEIGHT = ConvertAbilityRealLevelField(FourCC("Esn3"))
ABILITY_RLF_DURATION_OF_OWLS = ConvertAbilityRealLevelField(FourCC("Esn5"))
ABILITY_RLF_FADE_DURATION = ConvertAbilityRealLevelField(FourCC("Shm1"))
ABILITY_RLF_DAY_NIGHT_DURATION = ConvertAbilityRealLevelField(FourCC("Shm2"))
ABILITY_RLF_ACTION_DURATION = ConvertAbilityRealLevelField(FourCC("Shm3"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_SLO1 = ConvertAbilityRealLevelField(FourCC("Slo1"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_SLO2 = ConvertAbilityRealLevelField(FourCC("Slo2"))
ABILITY_RLF_DAMAGE_PER_SECOND_SPO1 = ConvertAbilityRealLevelField(FourCC("Spo1"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_SPO2 = ConvertAbilityRealLevelField(FourCC("Spo2"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_SPO3 = ConvertAbilityRealLevelField(FourCC("Spo3"))
ABILITY_RLF_ACTIVATION_DELAY_STA1 = ConvertAbilityRealLevelField(FourCC("Sta1"))
ABILITY_RLF_DETECTION_RADIUS_STA2 = ConvertAbilityRealLevelField(FourCC("Sta2"))
ABILITY_RLF_DETONATION_RADIUS = ConvertAbilityRealLevelField(FourCC("Sta3"))
ABILITY_RLF_STUN_DURATION_STA4 = ConvertAbilityRealLevelField(FourCC("Sta4"))
ABILITY_RLF_ATTACK_SPEED_BONUS_PERCENT = ConvertAbilityRealLevelField(FourCC("Uhf1"))
ABILITY_RLF_DAMAGE_PER_SECOND_UHF2 = ConvertAbilityRealLevelField(FourCC("Uhf2"))
ABILITY_RLF_LUMBER_PER_INTERVAL = ConvertAbilityRealLevelField(FourCC("Wha1"))
ABILITY_RLF_ART_ATTACHMENT_HEIGHT = ConvertAbilityRealLevelField(FourCC("Wha3"))
ABILITY_RLF_TELEPORT_AREA_WIDTH = ConvertAbilityRealLevelField(FourCC("Wrp1"))
ABILITY_RLF_TELEPORT_AREA_HEIGHT = ConvertAbilityRealLevelField(FourCC("Wrp2"))
ABILITY_RLF_LIFE_STOLEN_PER_ATTACK = ConvertAbilityRealLevelField(FourCC("Ivam"))
ABILITY_RLF_DAMAGE_BONUS_IDAM = ConvertAbilityRealLevelField(FourCC("Idam"))
ABILITY_RLF_CHANCE_TO_HIT_UNITS_PERCENT = ConvertAbilityRealLevelField(FourCC("Iob2"))
ABILITY_RLF_CHANCE_TO_HIT_HEROS_PERCENT = ConvertAbilityRealLevelField(FourCC("Iob3"))
ABILITY_RLF_CHANCE_TO_HIT_SUMMONS_PERCENT = ConvertAbilityRealLevelField(FourCC("Iob4"))
ABILITY_RLF_DELAY_FOR_TARGET_EFFECT = ConvertAbilityRealLevelField(FourCC("Idel"))
ABILITY_RLF_DAMAGE_DEALT_PERCENT_OF_NORMAL = ConvertAbilityRealLevelField(FourCC("Iild"))
ABILITY_RLF_DAMAGE_RECEIVED_MULTIPLIER = ConvertAbilityRealLevelField(FourCC("Iilw"))
ABILITY_RLF_MANA_REGENERATION_BONUS_AS_FRACTION_OF_NORMAL = ConvertAbilityRealLevelField(FourCC("Imrp"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_ISPI = ConvertAbilityRealLevelField(FourCC("Ispi"))
ABILITY_RLF_DAMAGE_PER_SECOND_IDPS = ConvertAbilityRealLevelField(FourCC("Idps"))
ABILITY_RLF_ATTACK_DAMAGE_INCREASE_CAC1 = ConvertAbilityRealLevelField(FourCC("Cac1"))
ABILITY_RLF_DAMAGE_PER_SECOND_COR1 = ConvertAbilityRealLevelField(FourCC("Cor1"))
ABILITY_RLF_ATTACK_SPEED_INCREASE_ISX1 = ConvertAbilityRealLevelField(FourCC("Isx1"))
ABILITY_RLF_DAMAGE_WRS1 = ConvertAbilityRealLevelField(FourCC("Wrs1"))
ABILITY_RLF_TERRAIN_DEFORMATION_AMPLITUDE = ConvertAbilityRealLevelField(FourCC("Wrs2"))
ABILITY_RLF_DAMAGE_CTC1 = ConvertAbilityRealLevelField(FourCC("Ctc1"))
ABILITY_RLF_EXTRA_DAMAGE_TO_TARGET = ConvertAbilityRealLevelField(FourCC("Ctc2"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_CTC3 = ConvertAbilityRealLevelField(FourCC("Ctc3"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_CTC4 = ConvertAbilityRealLevelField(FourCC("Ctc4"))
ABILITY_RLF_DAMAGE_CTB1 = ConvertAbilityRealLevelField(FourCC("Ctb1"))
ABILITY_RLF_CASTING_DELAY_SECONDS = ConvertAbilityRealLevelField(FourCC("Uds2"))
ABILITY_RLF_MANA_LOSS_PER_UNIT_DTN1 = ConvertAbilityRealLevelField(FourCC("Dtn1"))
ABILITY_RLF_DAMAGE_TO_SUMMONED_UNITS_DTN2 = ConvertAbilityRealLevelField(FourCC("Dtn2"))
ABILITY_RLF_TRANSITION_TIME_SECONDS = ConvertAbilityRealLevelField(FourCC("Ivs1"))
ABILITY_RLF_MANA_DRAINED_PER_SECOND_NMR1 = ConvertAbilityRealLevelField(FourCC("Nmr1"))
ABILITY_RLF_CHANCE_TO_REDUCE_DAMAGE_PERCENT = ConvertAbilityRealLevelField(FourCC("Ssk1"))
ABILITY_RLF_MINIMUM_DAMAGE = ConvertAbilityRealLevelField(FourCC("Ssk2"))
ABILITY_RLF_IGNORED_DAMAGE = ConvertAbilityRealLevelField(FourCC("Ssk3"))
ABILITY_RLF_FULL_DAMAGE_DEALT = ConvertAbilityRealLevelField(FourCC("Hfs1"))
ABILITY_RLF_FULL_DAMAGE_INTERVAL = ConvertAbilityRealLevelField(FourCC("Hfs2"))
ABILITY_RLF_HALF_DAMAGE_DEALT = ConvertAbilityRealLevelField(FourCC("Hfs3"))
ABILITY_RLF_HALF_DAMAGE_INTERVAL = ConvertAbilityRealLevelField(FourCC("Hfs4"))
ABILITY_RLF_BUILDING_REDUCTION_HFS5 = ConvertAbilityRealLevelField(FourCC("Hfs5"))
ABILITY_RLF_MAXIMUM_DAMAGE_HFS6 = ConvertAbilityRealLevelField(FourCC("Hfs6"))
ABILITY_RLF_MANA_PER_HIT_POINT = ConvertAbilityRealLevelField(FourCC("Nms1"))
ABILITY_RLF_DAMAGE_ABSORBED_PERCENT = ConvertAbilityRealLevelField(FourCC("Nms2"))
ABILITY_RLF_WAVE_DISTANCE = ConvertAbilityRealLevelField(FourCC("Uim1"))
ABILITY_RLF_WAVE_TIME_SECONDS = ConvertAbilityRealLevelField(FourCC("Uim2"))
ABILITY_RLF_DAMAGE_DEALT_UIM3 = ConvertAbilityRealLevelField(FourCC("Uim3"))
ABILITY_RLF_AIR_TIME_SECONDS_UIM4 = ConvertAbilityRealLevelField(FourCC("Uim4"))
ABILITY_RLF_UNIT_RELEASE_INTERVAL_SECONDS = ConvertAbilityRealLevelField(FourCC("Uls2"))
ABILITY_RLF_DAMAGE_RETURN_FACTOR = ConvertAbilityRealLevelField(FourCC("Uls4"))
ABILITY_RLF_DAMAGE_RETURN_THRESHOLD = ConvertAbilityRealLevelField(FourCC("Uls5"))
ABILITY_RLF_RETURNED_DAMAGE_FACTOR = ConvertAbilityRealLevelField(FourCC("Uts1"))
ABILITY_RLF_RECEIVED_DAMAGE_FACTOR = ConvertAbilityRealLevelField(FourCC("Uts2"))
ABILITY_RLF_DEFENSE_BONUS_UTS3 = ConvertAbilityRealLevelField(FourCC("Uts3"))
ABILITY_RLF_DAMAGE_BONUS_NBA1 = ConvertAbilityRealLevelField(FourCC("Nba1"))
ABILITY_RLF_SUMMONED_UNIT_DURATION_SECONDS_NBA3 = ConvertAbilityRealLevelField(FourCC("Nba3"))
ABILITY_RLF_MANA_PER_SUMMONED_HITPOINT = ConvertAbilityRealLevelField(FourCC("Cmg2"))
ABILITY_RLF_CHARGE_FOR_CURRENT_LIFE = ConvertAbilityRealLevelField(FourCC("Cmg3"))
ABILITY_RLF_HIT_POINTS_DRAINED = ConvertAbilityRealLevelField(FourCC("Ndr1"))
ABILITY_RLF_MANA_POINTS_DRAINED = ConvertAbilityRealLevelField(FourCC("Ndr2"))
ABILITY_RLF_DRAIN_INTERVAL_SECONDS = ConvertAbilityRealLevelField(FourCC("Ndr3"))
ABILITY_RLF_LIFE_TRANSFERRED_PER_SECOND = ConvertAbilityRealLevelField(FourCC("Ndr4"))
ABILITY_RLF_MANA_TRANSFERRED_PER_SECOND = ConvertAbilityRealLevelField(FourCC("Ndr5"))
ABILITY_RLF_BONUS_LIFE_FACTOR = ConvertAbilityRealLevelField(FourCC("Ndr6"))
ABILITY_RLF_BONUS_LIFE_DECAY = ConvertAbilityRealLevelField(FourCC("Ndr7"))
ABILITY_RLF_BONUS_MANA_FACTOR = ConvertAbilityRealLevelField(FourCC("Ndr8"))
ABILITY_RLF_BONUS_MANA_DECAY = ConvertAbilityRealLevelField(FourCC("Ndr9"))
ABILITY_RLF_CHANCE_TO_MISS_PERCENT = ConvertAbilityRealLevelField(FourCC("Nsi2"))
ABILITY_RLF_MOVEMENT_SPEED_MODIFIER = ConvertAbilityRealLevelField(FourCC("Nsi3"))
ABILITY_RLF_ATTACK_SPEED_MODIFIER = ConvertAbilityRealLevelField(FourCC("Nsi4"))
ABILITY_RLF_DAMAGE_PER_SECOND_TDG1 = ConvertAbilityRealLevelField(FourCC("Tdg1"))
ABILITY_RLF_MEDIUM_DAMAGE_RADIUS_TDG2 = ConvertAbilityRealLevelField(FourCC("Tdg2"))
ABILITY_RLF_MEDIUM_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField(FourCC("Tdg3"))
ABILITY_RLF_SMALL_DAMAGE_RADIUS_TDG4 = ConvertAbilityRealLevelField(FourCC("Tdg4"))
ABILITY_RLF_SMALL_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField(FourCC("Tdg5"))
ABILITY_RLF_AIR_TIME_SECONDS_TSP1 = ConvertAbilityRealLevelField(FourCC("Tsp1"))
ABILITY_RLF_MINIMUM_HIT_INTERVAL_SECONDS = ConvertAbilityRealLevelField(FourCC("Tsp2"))
ABILITY_RLF_DAMAGE_PER_SECOND_NBF5 = ConvertAbilityRealLevelField(FourCC("Nbf5"))
ABILITY_RLF_MAXIMUM_RANGE = ConvertAbilityRealLevelField(FourCC("Ebl1"))
ABILITY_RLF_MINIMUM_RANGE = ConvertAbilityRealLevelField(FourCC("Ebl2"))
ABILITY_RLF_DAMAGE_PER_TARGET_EFK1 = ConvertAbilityRealLevelField(FourCC("Efk1"))
ABILITY_RLF_MAXIMUM_TOTAL_DAMAGE = ConvertAbilityRealLevelField(FourCC("Efk2"))
ABILITY_RLF_MAXIMUM_SPEED_ADJUSTMENT = ConvertAbilityRealLevelField(FourCC("Efk4"))
ABILITY_RLF_DECAYING_DAMAGE = ConvertAbilityRealLevelField(FourCC("Esh1"))
ABILITY_RLF_MOVEMENT_SPEED_FACTOR_ESH2 = ConvertAbilityRealLevelField(FourCC("Esh2"))
ABILITY_RLF_ATTACK_SPEED_FACTOR_ESH3 = ConvertAbilityRealLevelField(FourCC("Esh3"))
ABILITY_RLF_DECAY_POWER = ConvertAbilityRealLevelField(FourCC("Esh4"))
ABILITY_RLF_INITIAL_DAMAGE_ESH5 = ConvertAbilityRealLevelField(FourCC("Esh5"))
ABILITY_RLF_MAXIMUM_LIFE_ABSORBED = ConvertAbilityRealLevelField(FourCC("abs1"))
ABILITY_RLF_MAXIMUM_MANA_ABSORBED = ConvertAbilityRealLevelField(FourCC("abs2"))
ABILITY_RLF_MOVEMENT_SPEED_INCREASE_BSK1 = ConvertAbilityRealLevelField(FourCC("bsk1"))
ABILITY_RLF_ATTACK_SPEED_INCREASE_BSK2 = ConvertAbilityRealLevelField(FourCC("bsk2"))
ABILITY_RLF_DAMAGE_TAKEN_INCREASE = ConvertAbilityRealLevelField(FourCC("bsk3"))
ABILITY_RLF_LIFE_PER_UNIT = ConvertAbilityRealLevelField(FourCC("dvm1"))
ABILITY_RLF_MANA_PER_UNIT = ConvertAbilityRealLevelField(FourCC("dvm2"))
ABILITY_RLF_LIFE_PER_BUFF = ConvertAbilityRealLevelField(FourCC("dvm3"))
ABILITY_RLF_MANA_PER_BUFF = ConvertAbilityRealLevelField(FourCC("dvm4"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_DVM5 = ConvertAbilityRealLevelField(FourCC("dvm5"))
ABILITY_RLF_DAMAGE_BONUS_FAK1 = ConvertAbilityRealLevelField(FourCC("fak1"))
ABILITY_RLF_MEDIUM_DAMAGE_FACTOR_FAK2 = ConvertAbilityRealLevelField(FourCC("fak2"))
ABILITY_RLF_SMALL_DAMAGE_FACTOR_FAK3 = ConvertAbilityRealLevelField(FourCC("fak3"))
ABILITY_RLF_FULL_DAMAGE_RADIUS_FAK4 = ConvertAbilityRealLevelField(FourCC("fak4"))
ABILITY_RLF_HALF_DAMAGE_RADIUS_FAK5 = ConvertAbilityRealLevelField(FourCC("fak5"))
ABILITY_RLF_EXTRA_DAMAGE_PER_SECOND = ConvertAbilityRealLevelField(FourCC("liq1"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_LIQ2 = ConvertAbilityRealLevelField(FourCC("liq2"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_LIQ3 = ConvertAbilityRealLevelField(FourCC("liq3"))
ABILITY_RLF_MAGIC_DAMAGE_FACTOR = ConvertAbilityRealLevelField(FourCC("mim1"))
ABILITY_RLF_UNIT_DAMAGE_PER_MANA_POINT = ConvertAbilityRealLevelField(FourCC("mfl1"))
ABILITY_RLF_HERO_DAMAGE_PER_MANA_POINT = ConvertAbilityRealLevelField(FourCC("mfl2"))
ABILITY_RLF_UNIT_MAXIMUM_DAMAGE = ConvertAbilityRealLevelField(FourCC("mfl3"))
ABILITY_RLF_HERO_MAXIMUM_DAMAGE = ConvertAbilityRealLevelField(FourCC("mfl4"))
ABILITY_RLF_DAMAGE_COOLDOWN = ConvertAbilityRealLevelField(FourCC("mfl5"))
ABILITY_RLF_DISTRIBUTED_DAMAGE_FACTOR_SPL1 = ConvertAbilityRealLevelField(FourCC("spl1"))
ABILITY_RLF_LIFE_REGENERATED = ConvertAbilityRealLevelField(FourCC("irl1"))
ABILITY_RLF_MANA_REGENERATED = ConvertAbilityRealLevelField(FourCC("irl2"))
ABILITY_RLF_MANA_LOSS_PER_UNIT_IDC1 = ConvertAbilityRealLevelField(FourCC("idc1"))
ABILITY_RLF_SUMMONED_UNIT_DAMAGE_IDC2 = ConvertAbilityRealLevelField(FourCC("idc2"))
ABILITY_RLF_ACTIVATION_DELAY_IMO2 = ConvertAbilityRealLevelField(FourCC("imo2"))
ABILITY_RLF_LURE_INTERVAL_SECONDS = ConvertAbilityRealLevelField(FourCC("imo3"))
ABILITY_RLF_DAMAGE_BONUS_ISR1 = ConvertAbilityRealLevelField(FourCC("isr1"))
ABILITY_RLF_DAMAGE_REDUCTION_ISR2 = ConvertAbilityRealLevelField(FourCC("isr2"))
ABILITY_RLF_DAMAGE_BONUS_IPV1 = ConvertAbilityRealLevelField(FourCC("ipv1"))
ABILITY_RLF_LIFE_STEAL_AMOUNT = ConvertAbilityRealLevelField(FourCC("ipv2"))
ABILITY_RLF_LIFE_RESTORED_FACTOR = ConvertAbilityRealLevelField(FourCC("ast1"))
ABILITY_RLF_MANA_RESTORED_FACTOR = ConvertAbilityRealLevelField(FourCC("ast2"))
ABILITY_RLF_ATTACH_DELAY = ConvertAbilityRealLevelField(FourCC("gra1"))
ABILITY_RLF_REMOVE_DELAY = ConvertAbilityRealLevelField(FourCC("gra2"))
ABILITY_RLF_HERO_REGENERATION_DELAY = ConvertAbilityRealLevelField(FourCC("Nsa2"))
ABILITY_RLF_UNIT_REGENERATION_DELAY = ConvertAbilityRealLevelField(FourCC("Nsa3"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_NSA4 = ConvertAbilityRealLevelField(FourCC("Nsa4"))
ABILITY_RLF_HIT_POINTS_PER_SECOND_NSA5 = ConvertAbilityRealLevelField(FourCC("Nsa5"))
ABILITY_RLF_DAMAGE_TO_SUMMONED_UNITS_IXS1 = ConvertAbilityRealLevelField(FourCC("Ixs1"))
ABILITY_RLF_MAGIC_DAMAGE_REDUCTION_IXS2 = ConvertAbilityRealLevelField(FourCC("Ixs2"))
ABILITY_RLF_SUMMONED_UNIT_DURATION = ConvertAbilityRealLevelField(FourCC("Npa6"))
ABILITY_RLF_SHIELD_COOLDOWN_TIME = ConvertAbilityRealLevelField(FourCC("Nse1"))
ABILITY_RLF_DAMAGE_PER_SECOND_NDO1 = ConvertAbilityRealLevelField(FourCC("Ndo1"))
ABILITY_RLF_SUMMONED_UNIT_DURATION_SECONDS_NDO3 = ConvertAbilityRealLevelField(FourCC("Ndo3"))
ABILITY_RLF_MEDIUM_DAMAGE_RADIUS_FLK1 = ConvertAbilityRealLevelField(FourCC("flk1"))
ABILITY_RLF_SMALL_DAMAGE_RADIUS_FLK2 = ConvertAbilityRealLevelField(FourCC("flk2"))
ABILITY_RLF_FULL_DAMAGE_AMOUNT_FLK3 = ConvertAbilityRealLevelField(FourCC("flk3"))
ABILITY_RLF_MEDIUM_DAMAGE_AMOUNT = ConvertAbilityRealLevelField(FourCC("flk4"))
ABILITY_RLF_SMALL_DAMAGE_AMOUNT = ConvertAbilityRealLevelField(FourCC("flk5"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_HBN1 = ConvertAbilityRealLevelField(FourCC("Hbn1"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_HBN2 = ConvertAbilityRealLevelField(FourCC("Hbn2"))
ABILITY_RLF_MAX_MANA_DRAINED_UNITS = ConvertAbilityRealLevelField(FourCC("fbk1"))
ABILITY_RLF_DAMAGE_RATIO_UNITS_PERCENT = ConvertAbilityRealLevelField(FourCC("fbk2"))
ABILITY_RLF_MAX_MANA_DRAINED_HEROS = ConvertAbilityRealLevelField(FourCC("fbk3"))
ABILITY_RLF_DAMAGE_RATIO_HEROS_PERCENT = ConvertAbilityRealLevelField(FourCC("fbk4"))
ABILITY_RLF_SUMMONED_DAMAGE = ConvertAbilityRealLevelField(FourCC("fbk5"))
ABILITY_RLF_DISTRIBUTED_DAMAGE_FACTOR_NCA1 = ConvertAbilityRealLevelField(FourCC("nca1"))
ABILITY_RLF_INITIAL_DAMAGE_PXF1 = ConvertAbilityRealLevelField(FourCC("pxf1"))
ABILITY_RLF_DAMAGE_PER_SECOND_PXF2 = ConvertAbilityRealLevelField(FourCC("pxf2"))
ABILITY_RLF_DAMAGE_PER_SECOND_MLS1 = ConvertAbilityRealLevelField(FourCC("mls1"))
ABILITY_RLF_BEAST_COLLISION_RADIUS = ConvertAbilityRealLevelField(FourCC("Nst2"))
ABILITY_RLF_DAMAGE_AMOUNT_NST3 = ConvertAbilityRealLevelField(FourCC("Nst3"))
ABILITY_RLF_DAMAGE_RADIUS = ConvertAbilityRealLevelField(FourCC("Nst4"))
ABILITY_RLF_DAMAGE_DELAY = ConvertAbilityRealLevelField(FourCC("Nst5"))
ABILITY_RLF_FOLLOW_THROUGH_TIME = ConvertAbilityRealLevelField(FourCC("Ncl1"))
ABILITY_RLF_ART_DURATION = ConvertAbilityRealLevelField(FourCC("Ncl4"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_NAB1 = ConvertAbilityRealLevelField(FourCC("Nab1"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_NAB2 = ConvertAbilityRealLevelField(FourCC("Nab2"))
ABILITY_RLF_PRIMARY_DAMAGE = ConvertAbilityRealLevelField(FourCC("Nab4"))
ABILITY_RLF_SECONDARY_DAMAGE = ConvertAbilityRealLevelField(FourCC("Nab5"))
ABILITY_RLF_DAMAGE_INTERVAL_NAB6 = ConvertAbilityRealLevelField(FourCC("Nab6"))
ABILITY_RLF_GOLD_COST_FACTOR = ConvertAbilityRealLevelField(FourCC("Ntm1"))
ABILITY_RLF_LUMBER_COST_FACTOR = ConvertAbilityRealLevelField(FourCC("Ntm2"))
ABILITY_RLF_MOVE_SPEED_BONUS_NEG1 = ConvertAbilityRealLevelField(FourCC("Neg1"))
ABILITY_RLF_DAMAGE_BONUS_NEG2 = ConvertAbilityRealLevelField(FourCC("Neg2"))
ABILITY_RLF_DAMAGE_AMOUNT_NCS1 = ConvertAbilityRealLevelField(FourCC("Ncs1"))
ABILITY_RLF_DAMAGE_INTERVAL_NCS2 = ConvertAbilityRealLevelField(FourCC("Ncs2"))
ABILITY_RLF_MAX_DAMAGE_NCS4 = ConvertAbilityRealLevelField(FourCC("Ncs4"))
ABILITY_RLF_BUILDING_DAMAGE_FACTOR_NCS5 = ConvertAbilityRealLevelField(FourCC("Ncs5"))
ABILITY_RLF_EFFECT_DURATION = ConvertAbilityRealLevelField(FourCC("Ncs6"))
ABILITY_RLF_SPAWN_INTERVAL_NSY1 = ConvertAbilityRealLevelField(FourCC("Nsy1"))
ABILITY_RLF_SPAWN_UNIT_DURATION = ConvertAbilityRealLevelField(FourCC("Nsy3"))
ABILITY_RLF_SPAWN_UNIT_OFFSET = ConvertAbilityRealLevelField(FourCC("Nsy4"))
ABILITY_RLF_LEASH_RANGE_NSY5 = ConvertAbilityRealLevelField(FourCC("Nsy5"))
ABILITY_RLF_SPAWN_INTERVAL_NFY1 = ConvertAbilityRealLevelField(FourCC("Nfy1"))
ABILITY_RLF_LEASH_RANGE_NFY2 = ConvertAbilityRealLevelField(FourCC("Nfy2"))
ABILITY_RLF_CHANCE_TO_DEMOLISH = ConvertAbilityRealLevelField(FourCC("Nde1"))
ABILITY_RLF_DAMAGE_MULTIPLIER_BUILDINGS = ConvertAbilityRealLevelField(FourCC("Nde2"))
ABILITY_RLF_DAMAGE_MULTIPLIER_UNITS = ConvertAbilityRealLevelField(FourCC("Nde3"))
ABILITY_RLF_DAMAGE_MULTIPLIER_HEROES = ConvertAbilityRealLevelField(FourCC("Nde4"))
ABILITY_RLF_BONUS_DAMAGE_MULTIPLIER = ConvertAbilityRealLevelField(FourCC("Nic1"))
ABILITY_RLF_DEATH_DAMAGE_FULL_AMOUNT = ConvertAbilityRealLevelField(FourCC("Nic2"))
ABILITY_RLF_DEATH_DAMAGE_FULL_AREA = ConvertAbilityRealLevelField(FourCC("Nic3"))
ABILITY_RLF_DEATH_DAMAGE_HALF_AMOUNT = ConvertAbilityRealLevelField(FourCC("Nic4"))
ABILITY_RLF_DEATH_DAMAGE_HALF_AREA = ConvertAbilityRealLevelField(FourCC("Nic5"))
ABILITY_RLF_DEATH_DAMAGE_DELAY = ConvertAbilityRealLevelField(FourCC("Nic6"))
ABILITY_RLF_DAMAGE_AMOUNT_NSO1 = ConvertAbilityRealLevelField(FourCC("Nso1"))
ABILITY_RLF_DAMAGE_PERIOD = ConvertAbilityRealLevelField(FourCC("Nso2"))
ABILITY_RLF_DAMAGE_PENALTY = ConvertAbilityRealLevelField(FourCC("Nso3"))
ABILITY_RLF_MOVEMENT_SPEED_REDUCTION_PERCENT_NSO4 = ConvertAbilityRealLevelField(FourCC("Nso4"))
ABILITY_RLF_ATTACK_SPEED_REDUCTION_PERCENT_NSO5 = ConvertAbilityRealLevelField(FourCC("Nso5"))
ABILITY_RLF_SPLIT_DELAY = ConvertAbilityRealLevelField(FourCC("Nlm2"))
ABILITY_RLF_MAX_HITPOINT_FACTOR = ConvertAbilityRealLevelField(FourCC("Nlm4"))
ABILITY_RLF_LIFE_DURATION_SPLIT_BONUS = ConvertAbilityRealLevelField(FourCC("Nlm5"))
ABILITY_RLF_WAVE_INTERVAL = ConvertAbilityRealLevelField(FourCC("Nvc3"))
ABILITY_RLF_BUILDING_DAMAGE_FACTOR_NVC4 = ConvertAbilityRealLevelField(FourCC("Nvc4"))
ABILITY_RLF_FULL_DAMAGE_AMOUNT_NVC5 = ConvertAbilityRealLevelField(FourCC("Nvc5"))
ABILITY_RLF_HALF_DAMAGE_FACTOR = ConvertAbilityRealLevelField(FourCC("Nvc6"))
ABILITY_RLF_INTERVAL_BETWEEN_PULSES = ConvertAbilityRealLevelField(FourCC("Tau5"))
ABILITY_BLF_PERCENT_BONUS_HAB2 = ConvertAbilityBooleanLevelField(FourCC("Hab2"))
ABILITY_BLF_USE_TELEPORT_CLUSTERING_HMT3 = ConvertAbilityBooleanLevelField(FourCC("Hmt3"))
ABILITY_BLF_NEVER_MISS_OCR5 = ConvertAbilityBooleanLevelField(FourCC("Ocr5"))
ABILITY_BLF_EXCLUDE_ITEM_DAMAGE = ConvertAbilityBooleanLevelField(FourCC("Ocr6"))
ABILITY_BLF_BACKSTAB_DAMAGE = ConvertAbilityBooleanLevelField(FourCC("Owk4"))
ABILITY_BLF_INHERIT_UPGRADES_UAN3 = ConvertAbilityBooleanLevelField(FourCC("Uan3"))
ABILITY_BLF_MANA_CONVERSION_AS_PERCENT = ConvertAbilityBooleanLevelField(FourCC("Udp3"))
ABILITY_BLF_LIFE_CONVERSION_AS_PERCENT = ConvertAbilityBooleanLevelField(FourCC("Udp4"))
ABILITY_BLF_LEAVE_TARGET_ALIVE = ConvertAbilityBooleanLevelField(FourCC("Udp5"))
ABILITY_BLF_PERCENT_BONUS_UAU3 = ConvertAbilityBooleanLevelField(FourCC("Uau3"))
ABILITY_BLF_DAMAGE_IS_PERCENT_RECEIVED = ConvertAbilityBooleanLevelField(FourCC("Eah2"))
ABILITY_BLF_MELEE_BONUS = ConvertAbilityBooleanLevelField(FourCC("Ear2"))
ABILITY_BLF_RANGED_BONUS = ConvertAbilityBooleanLevelField(FourCC("Ear3"))
ABILITY_BLF_FLAT_BONUS = ConvertAbilityBooleanLevelField(FourCC("Ear4"))
ABILITY_BLF_NEVER_MISS_HBH5 = ConvertAbilityBooleanLevelField(FourCC("Hbh5"))
ABILITY_BLF_PERCENT_BONUS_HAD2 = ConvertAbilityBooleanLevelField(FourCC("Had2"))
ABILITY_BLF_CAN_DEACTIVATE = ConvertAbilityBooleanLevelField(FourCC("Hds1"))
ABILITY_BLF_RAISED_UNITS_ARE_INVULNERABLE = ConvertAbilityBooleanLevelField(FourCC("Hre2"))
ABILITY_BLF_PERCENTAGE_OAR2 = ConvertAbilityBooleanLevelField(FourCC("Oar2"))
ABILITY_BLF_SUMMON_BUSY_UNITS = ConvertAbilityBooleanLevelField(FourCC("Btl2"))
ABILITY_BLF_CREATES_BLIGHT = ConvertAbilityBooleanLevelField(FourCC("Bli2"))
ABILITY_BLF_EXPLODES_ON_DEATH = ConvertAbilityBooleanLevelField(FourCC("Sds6"))
ABILITY_BLF_ALWAYS_AUTOCAST_FAE2 = ConvertAbilityBooleanLevelField(FourCC("Fae2"))
ABILITY_BLF_REGENERATE_ONLY_AT_NIGHT = ConvertAbilityBooleanLevelField(FourCC("Mbt5"))
ABILITY_BLF_SHOW_SELECT_UNIT_BUTTON = ConvertAbilityBooleanLevelField(FourCC("Neu3"))
ABILITY_BLF_SHOW_UNIT_INDICATOR = ConvertAbilityBooleanLevelField(FourCC("Neu4"))
ABILITY_BLF_CHARGE_OWNING_PLAYER = ConvertAbilityBooleanLevelField(FourCC("Ans6"))
ABILITY_BLF_PERCENTAGE_ARM2 = ConvertAbilityBooleanLevelField(FourCC("Arm2"))
ABILITY_BLF_TARGET_IS_INVULNERABLE = ConvertAbilityBooleanLevelField(FourCC("Pos3"))
ABILITY_BLF_TARGET_IS_MAGIC_IMMUNE = ConvertAbilityBooleanLevelField(FourCC("Pos4"))
ABILITY_BLF_KILL_ON_CASTER_DEATH = ConvertAbilityBooleanLevelField(FourCC("Ucb6"))
ABILITY_BLF_NO_TARGET_REQUIRED_REJ4 = ConvertAbilityBooleanLevelField(FourCC("Rej4"))
ABILITY_BLF_ACCEPTS_GOLD = ConvertAbilityBooleanLevelField(FourCC("Rtn1"))
ABILITY_BLF_ACCEPTS_LUMBER = ConvertAbilityBooleanLevelField(FourCC("Rtn2"))
ABILITY_BLF_PREFER_HOSTILES_ROA5 = ConvertAbilityBooleanLevelField(FourCC("Roa5"))
ABILITY_BLF_PREFER_FRIENDLIES_ROA6 = ConvertAbilityBooleanLevelField(FourCC("Roa6"))
ABILITY_BLF_ROOTED_TURNING = ConvertAbilityBooleanLevelField(FourCC("Roo3"))
ABILITY_BLF_ALWAYS_AUTOCAST_SLO3 = ConvertAbilityBooleanLevelField(FourCC("Slo3"))
ABILITY_BLF_HIDE_BUTTON = ConvertAbilityBooleanLevelField(FourCC("Ihid"))
ABILITY_BLF_USE_TELEPORT_CLUSTERING_ITP2 = ConvertAbilityBooleanLevelField(FourCC("Itp2"))
ABILITY_BLF_IMMUNE_TO_MORPH_EFFECTS = ConvertAbilityBooleanLevelField(FourCC("Eth1"))
ABILITY_BLF_DOES_NOT_BLOCK_BUILDINGS = ConvertAbilityBooleanLevelField(FourCC("Eth2"))
ABILITY_BLF_AUTO_ACQUIRE_ATTACK_TARGETS = ConvertAbilityBooleanLevelField(FourCC("Gho1"))
ABILITY_BLF_IMMUNE_TO_MORPH_EFFECTS_GHO2 = ConvertAbilityBooleanLevelField(FourCC("Gho2"))
ABILITY_BLF_DO_NOT_BLOCK_BUILDINGS = ConvertAbilityBooleanLevelField(FourCC("Gho3"))
ABILITY_BLF_INCLUDE_RANGED_DAMAGE = ConvertAbilityBooleanLevelField(FourCC("Ssk4"))
ABILITY_BLF_INCLUDE_MELEE_DAMAGE = ConvertAbilityBooleanLevelField(FourCC("Ssk5"))
ABILITY_BLF_MOVE_TO_PARTNER = ConvertAbilityBooleanLevelField(FourCC("coa2"))
ABILITY_BLF_CAN_BE_DISPELLED = ConvertAbilityBooleanLevelField(FourCC("cyc1"))
ABILITY_BLF_IGNORE_FRIENDLY_BUFFS = ConvertAbilityBooleanLevelField(FourCC("dvm6"))
ABILITY_BLF_DROP_ITEMS_ON_DEATH = ConvertAbilityBooleanLevelField(FourCC("inv2"))
ABILITY_BLF_CAN_USE_ITEMS = ConvertAbilityBooleanLevelField(FourCC("inv3"))
ABILITY_BLF_CAN_GET_ITEMS = ConvertAbilityBooleanLevelField(FourCC("inv4"))
ABILITY_BLF_CAN_DROP_ITEMS = ConvertAbilityBooleanLevelField(FourCC("inv5"))
ABILITY_BLF_REPAIRS_ALLOWED = ConvertAbilityBooleanLevelField(FourCC("liq4"))
ABILITY_BLF_CASTER_ONLY_SPLASH = ConvertAbilityBooleanLevelField(FourCC("mfl6"))
ABILITY_BLF_NO_TARGET_REQUIRED_IRL4 = ConvertAbilityBooleanLevelField(FourCC("irl4"))
ABILITY_BLF_DISPEL_ON_ATTACK = ConvertAbilityBooleanLevelField(FourCC("irl5"))
ABILITY_BLF_AMOUNT_IS_RAW_VALUE = ConvertAbilityBooleanLevelField(FourCC("ipv3"))
ABILITY_BLF_SHARED_SPELL_COOLDOWN = ConvertAbilityBooleanLevelField(FourCC("spb2"))
ABILITY_BLF_SLEEP_ONCE = ConvertAbilityBooleanLevelField(FourCC("sla1"))
ABILITY_BLF_ALLOW_ON_ANY_PLAYER_SLOT = ConvertAbilityBooleanLevelField(FourCC("sla2"))
ABILITY_BLF_DISABLE_OTHER_ABILITIES = ConvertAbilityBooleanLevelField(FourCC("Ncl5"))
ABILITY_BLF_ALLOW_BOUNTY = ConvertAbilityBooleanLevelField(FourCC("Ntm4"))
ABILITY_SLF_ICON_NORMAL = ConvertAbilityStringLevelField(FourCC("aart"))
ABILITY_SLF_CASTER = ConvertAbilityStringLevelField(FourCC("acat"))
ABILITY_SLF_TARGET = ConvertAbilityStringLevelField(FourCC("atat"))
ABILITY_SLF_SPECIAL = ConvertAbilityStringLevelField(FourCC("asat"))
ABILITY_SLF_EFFECT = ConvertAbilityStringLevelField(FourCC("aeat"))
ABILITY_SLF_AREA_EFFECT = ConvertAbilityStringLevelField(FourCC("aaea"))
ABILITY_SLF_LIGHTNING_EFFECTS = ConvertAbilityStringLevelField(FourCC("alig"))
ABILITY_SLF_MISSILE_ART = ConvertAbilityStringLevelField(FourCC("amat"))
ABILITY_SLF_TOOLTIP_LEARN = ConvertAbilityStringLevelField(FourCC("aret"))
ABILITY_SLF_TOOLTIP_LEARN_EXTENDED = ConvertAbilityStringLevelField(FourCC("arut"))
ABILITY_SLF_TOOLTIP_NORMAL = ConvertAbilityStringLevelField(FourCC("atp1"))
ABILITY_SLF_TOOLTIP_TURN_OFF = ConvertAbilityStringLevelField(FourCC("aut1"))
ABILITY_SLF_TOOLTIP_NORMAL_EXTENDED = ConvertAbilityStringLevelField(FourCC("aub1"))
ABILITY_SLF_TOOLTIP_TURN_OFF_EXTENDED = ConvertAbilityStringLevelField(FourCC("auu1"))
ABILITY_SLF_NORMAL_FORM_UNIT_EME1 = ConvertAbilityStringLevelField(FourCC("Eme1"))
ABILITY_SLF_SPAWNED_UNITS = ConvertAbilityStringLevelField(FourCC("Ndp1"))
ABILITY_SLF_ABILITY_FOR_UNIT_CREATION = ConvertAbilityStringLevelField(FourCC("Nrc1"))
ABILITY_SLF_NORMAL_FORM_UNIT_MIL1 = ConvertAbilityStringLevelField(FourCC("Mil1"))
ABILITY_SLF_ALTERNATE_FORM_UNIT_MIL2 = ConvertAbilityStringLevelField(FourCC("Mil2"))
ABILITY_SLF_BASE_ORDER_ID_ANS5 = ConvertAbilityStringLevelField(FourCC("Ans5"))
ABILITY_SLF_MORPH_UNITS_GROUND = ConvertAbilityStringLevelField(FourCC("Ply2"))
ABILITY_SLF_MORPH_UNITS_AIR = ConvertAbilityStringLevelField(FourCC("Ply3"))
ABILITY_SLF_MORPH_UNITS_AMPHIBIOUS = ConvertAbilityStringLevelField(FourCC("Ply4"))
ABILITY_SLF_MORPH_UNITS_WATER = ConvertAbilityStringLevelField(FourCC("Ply5"))
ABILITY_SLF_UNIT_TYPE_ONE = ConvertAbilityStringLevelField(FourCC("Rai3"))
ABILITY_SLF_UNIT_TYPE_TWO = ConvertAbilityStringLevelField(FourCC("Rai4"))
ABILITY_SLF_UNIT_TYPE_SOD2 = ConvertAbilityStringLevelField(FourCC("Sod2"))
ABILITY_SLF_SUMMON_1_UNIT_TYPE = ConvertAbilityStringLevelField(FourCC("Ist1"))
ABILITY_SLF_SUMMON_2_UNIT_TYPE = ConvertAbilityStringLevelField(FourCC("Ist2"))
ABILITY_SLF_RACE_TO_CONVERT = ConvertAbilityStringLevelField(FourCC("Ndc1"))
ABILITY_SLF_PARTNER_UNIT_TYPE = ConvertAbilityStringLevelField(FourCC("coa1"))
ABILITY_SLF_PARTNER_UNIT_TYPE_ONE = ConvertAbilityStringLevelField(FourCC("dcp1"))
ABILITY_SLF_PARTNER_UNIT_TYPE_TWO = ConvertAbilityStringLevelField(FourCC("dcp2"))
ABILITY_SLF_REQUIRED_UNIT_TYPE = ConvertAbilityStringLevelField(FourCC("tpi1"))
ABILITY_SLF_CONVERTED_UNIT_TYPE = ConvertAbilityStringLevelField(FourCC("tpi2"))
ABILITY_SLF_SPELL_LIST = ConvertAbilityStringLevelField(FourCC("spb1"))
ABILITY_SLF_BASE_ORDER_ID_SPB5 = ConvertAbilityStringLevelField(FourCC("spb5"))
ABILITY_SLF_BASE_ORDER_ID_NCL6 = ConvertAbilityStringLevelField(FourCC("Ncl6"))
ABILITY_SLF_ABILITY_UPGRADE_1 = ConvertAbilityStringLevelField(FourCC("Neg3"))
ABILITY_SLF_ABILITY_UPGRADE_2 = ConvertAbilityStringLevelField(FourCC("Neg4"))
ABILITY_SLF_ABILITY_UPGRADE_3 = ConvertAbilityStringLevelField(FourCC("Neg5"))
ABILITY_SLF_ABILITY_UPGRADE_4 = ConvertAbilityStringLevelField(FourCC("Neg6"))
ABILITY_SLF_SPAWN_UNIT_ID_NSY2 = ConvertAbilityStringLevelField(FourCC("Nsy2"))
ITEM_IF_LEVEL = ConvertItemIntegerField(FourCC("ilev"))
ITEM_IF_NUMBER_OF_CHARGES = ConvertItemIntegerField(FourCC("iuse"))
ITEM_IF_COOLDOWN_GROUP = ConvertItemIntegerField(FourCC("icid"))
ITEM_IF_MAX_HIT_POINTS = ConvertItemIntegerField(FourCC("ihtp"))
ITEM_IF_HIT_POINTS = ConvertItemIntegerField(FourCC("ihpc"))
ITEM_IF_PRIORITY = ConvertItemIntegerField(FourCC("ipri"))
ITEM_IF_ARMOR_TYPE = ConvertItemIntegerField(FourCC("iarm"))
ITEM_IF_TINTING_COLOR_RED = ConvertItemIntegerField(FourCC("iclr"))
ITEM_IF_TINTING_COLOR_GREEN = ConvertItemIntegerField(FourCC("iclg"))
ITEM_IF_TINTING_COLOR_BLUE = ConvertItemIntegerField(FourCC("iclb"))
ITEM_IF_TINTING_COLOR_ALPHA = ConvertItemIntegerField(FourCC("ical"))
ITEM_RF_SCALING_VALUE = ConvertItemRealField(FourCC("isca"))
ITEM_BF_DROPPED_WHEN_CARRIER_DIES = ConvertItemBooleanField(FourCC("idrp"))
ITEM_BF_CAN_BE_DROPPED = ConvertItemBooleanField(FourCC("idro"))
ITEM_BF_PERISHABLE = ConvertItemBooleanField(FourCC("iper"))
ITEM_BF_INCLUDE_AS_RANDOM_CHOICE = ConvertItemBooleanField(FourCC("iprn"))
ITEM_BF_USE_AUTOMATICALLY_WHEN_ACQUIRED = ConvertItemBooleanField(FourCC("ipow"))
ITEM_BF_CAN_BE_SOLD_TO_MERCHANTS = ConvertItemBooleanField(FourCC("ipaw"))
ITEM_BF_ACTIVELY_USED = ConvertItemBooleanField(FourCC("iusa"))
ITEM_SF_MODEL_USED = ConvertItemStringField(FourCC("ifil"))
UNIT_IF_DEFENSE_TYPE = ConvertUnitIntegerField(FourCC("udty"))
UNIT_IF_ARMOR_TYPE = ConvertUnitIntegerField(FourCC("uarm"))
UNIT_IF_LOOPING_FADE_IN_RATE = ConvertUnitIntegerField(FourCC("ulfi"))
UNIT_IF_LOOPING_FADE_OUT_RATE = ConvertUnitIntegerField(FourCC("ulfo"))
UNIT_IF_AGILITY = ConvertUnitIntegerField(FourCC("uagc"))
UNIT_IF_INTELLIGENCE = ConvertUnitIntegerField(FourCC("uinc"))
UNIT_IF_STRENGTH = ConvertUnitIntegerField(FourCC("ustc"))
UNIT_IF_AGILITY_PERMANENT = ConvertUnitIntegerField(FourCC("uagm"))
UNIT_IF_INTELLIGENCE_PERMANENT = ConvertUnitIntegerField(FourCC("uinm"))
UNIT_IF_STRENGTH_PERMANENT = ConvertUnitIntegerField(FourCC("ustm"))
UNIT_IF_AGILITY_WITH_BONUS = ConvertUnitIntegerField(FourCC("uagb"))
UNIT_IF_INTELLIGENCE_WITH_BONUS = ConvertUnitIntegerField(FourCC("uinb"))
UNIT_IF_STRENGTH_WITH_BONUS = ConvertUnitIntegerField(FourCC("ustb"))
UNIT_IF_GOLD_BOUNTY_AWARDED_NUMBER_OF_DICE = ConvertUnitIntegerField(FourCC("ubdi"))
UNIT_IF_GOLD_BOUNTY_AWARDED_BASE = ConvertUnitIntegerField(FourCC("ubba"))
UNIT_IF_GOLD_BOUNTY_AWARDED_SIDES_PER_DIE = ConvertUnitIntegerField(FourCC("ubsi"))
UNIT_IF_LUMBER_BOUNTY_AWARDED_NUMBER_OF_DICE = ConvertUnitIntegerField(FourCC("ulbd"))
UNIT_IF_LUMBER_BOUNTY_AWARDED_BASE = ConvertUnitIntegerField(FourCC("ulba"))
UNIT_IF_LUMBER_BOUNTY_AWARDED_SIDES_PER_DIE = ConvertUnitIntegerField(FourCC("ulbs"))
UNIT_IF_LEVEL = ConvertUnitIntegerField(FourCC("ulev"))
UNIT_IF_FORMATION_RANK = ConvertUnitIntegerField(FourCC("ufor"))
UNIT_IF_ORIENTATION_INTERPOLATION = ConvertUnitIntegerField(FourCC("uori"))
UNIT_IF_ELEVATION_SAMPLE_POINTS = ConvertUnitIntegerField(FourCC("uept"))
UNIT_IF_TINTING_COLOR_RED = ConvertUnitIntegerField(FourCC("uclr"))
UNIT_IF_TINTING_COLOR_GREEN = ConvertUnitIntegerField(FourCC("uclg"))
UNIT_IF_TINTING_COLOR_BLUE = ConvertUnitIntegerField(FourCC("uclb"))
UNIT_IF_TINTING_COLOR_ALPHA = ConvertUnitIntegerField(FourCC("ucal"))
UNIT_IF_MOVE_TYPE = ConvertUnitIntegerField(FourCC("umvt"))
UNIT_IF_TARGETED_AS = ConvertUnitIntegerField(FourCC("utar"))
UNIT_IF_UNIT_CLASSIFICATION = ConvertUnitIntegerField(FourCC("utyp"))
UNIT_IF_HIT_POINTS_REGENERATION_TYPE = ConvertUnitIntegerField(FourCC("uhrt"))
UNIT_IF_PLACEMENT_PREVENTED_BY = ConvertUnitIntegerField(FourCC("upar"))
UNIT_IF_PRIMARY_ATTRIBUTE = ConvertUnitIntegerField(FourCC("upra"))
UNIT_RF_STRENGTH_PER_LEVEL = ConvertUnitRealField(FourCC("ustp"))
UNIT_RF_AGILITY_PER_LEVEL = ConvertUnitRealField(FourCC("uagp"))
UNIT_RF_INTELLIGENCE_PER_LEVEL = ConvertUnitRealField(FourCC("uinp"))
UNIT_RF_HIT_POINTS_REGENERATION_RATE = ConvertUnitRealField(FourCC("uhpr"))
UNIT_RF_MANA_REGENERATION = ConvertUnitRealField(FourCC("umpr"))
UNIT_RF_DEATH_TIME = ConvertUnitRealField(FourCC("udtm"))
UNIT_RF_FLY_HEIGHT = ConvertUnitRealField(FourCC("ufyh"))
UNIT_RF_TURN_RATE = ConvertUnitRealField(FourCC("umvr"))
UNIT_RF_ELEVATION_SAMPLE_RADIUS = ConvertUnitRealField(FourCC("uerd"))
UNIT_RF_FOG_OF_WAR_SAMPLE_RADIUS = ConvertUnitRealField(FourCC("ufrd"))
UNIT_RF_MAXIMUM_PITCH_ANGLE_DEGREES = ConvertUnitRealField(FourCC("umxp"))
UNIT_RF_MAXIMUM_ROLL_ANGLE_DEGREES = ConvertUnitRealField(FourCC("umxr"))
UNIT_RF_SCALING_VALUE = ConvertUnitRealField(FourCC("usca"))
UNIT_RF_ANIMATION_RUN_SPEED = ConvertUnitRealField(FourCC("urun"))
UNIT_RF_SELECTION_SCALE = ConvertUnitRealField(FourCC("ussc"))
UNIT_RF_SELECTION_CIRCLE_HEIGHT = ConvertUnitRealField(FourCC("uslz"))
UNIT_RF_SHADOW_IMAGE_HEIGHT = ConvertUnitRealField(FourCC("ushh"))
UNIT_RF_SHADOW_IMAGE_WIDTH = ConvertUnitRealField(FourCC("ushw"))
UNIT_RF_SHADOW_IMAGE_CENTER_X = ConvertUnitRealField(FourCC("ushx"))
UNIT_RF_SHADOW_IMAGE_CENTER_Y = ConvertUnitRealField(FourCC("ushy"))
UNIT_RF_ANIMATION_WALK_SPEED = ConvertUnitRealField(FourCC("uwal"))
UNIT_RF_DEFENSE = ConvertUnitRealField(FourCC("udfc"))
UNIT_RF_SIGHT_RADIUS = ConvertUnitRealField(FourCC("usir"))
UNIT_RF_PRIORITY = ConvertUnitRealField(FourCC("upri"))
UNIT_RF_SPEED = ConvertUnitRealField(FourCC("umvc"))
UNIT_RF_OCCLUDER_HEIGHT = ConvertUnitRealField(FourCC("uocc"))
UNIT_RF_HP = ConvertUnitRealField(FourCC("uhpc"))
UNIT_RF_MANA = ConvertUnitRealField(FourCC("umpc"))
UNIT_RF_ACQUISITION_RANGE = ConvertUnitRealField(FourCC("uacq"))
UNIT_RF_CAST_BACK_SWING = ConvertUnitRealField(FourCC("ucbs"))
UNIT_RF_CAST_POINT = ConvertUnitRealField(FourCC("ucpt"))
UNIT_RF_MINIMUM_ATTACK_RANGE = ConvertUnitRealField(FourCC("uamn"))
UNIT_BF_RAISABLE = ConvertUnitBooleanField(FourCC("urai"))
UNIT_BF_DECAYABLE = ConvertUnitBooleanField(FourCC("udec"))
UNIT_BF_IS_A_BUILDING = ConvertUnitBooleanField(FourCC("ubdg"))
UNIT_BF_USE_EXTENDED_LINE_OF_SIGHT = ConvertUnitBooleanField(FourCC("ulos"))
UNIT_BF_NEUTRAL_BUILDING_SHOWS_MINIMAP_ICON = ConvertUnitBooleanField(FourCC("unbm"))
UNIT_BF_HERO_HIDE_HERO_INTERFACE_ICON = ConvertUnitBooleanField(FourCC("uhhb"))
UNIT_BF_HERO_HIDE_HERO_MINIMAP_DISPLAY = ConvertUnitBooleanField(FourCC("uhhm"))
UNIT_BF_HERO_HIDE_HERO_DEATH_MESSAGE = ConvertUnitBooleanField(FourCC("uhhd"))
UNIT_BF_HIDE_MINIMAP_DISPLAY = ConvertUnitBooleanField(FourCC("uhom"))
UNIT_BF_SCALE_PROJECTILES = ConvertUnitBooleanField(FourCC("uscb"))
UNIT_BF_SELECTION_CIRCLE_ON_WATER = ConvertUnitBooleanField(FourCC("usew"))
UNIT_BF_HAS_WATER_SHADOW = ConvertUnitBooleanField(FourCC("ushr"))
UNIT_SF_NAME = ConvertUnitStringField(FourCC("unam"))
UNIT_SF_PROPER_NAMES = ConvertUnitStringField(FourCC("upro"))
UNIT_SF_GROUND_TEXTURE = ConvertUnitStringField(FourCC("uubs"))
UNIT_SF_SHADOW_IMAGE_UNIT = ConvertUnitStringField(FourCC("ushu"))
UNIT_WEAPON_IF_ATTACK_DAMAGE_NUMBER_OF_DICE = ConvertUnitWeaponIntegerField(FourCC("ua1d"))
UNIT_WEAPON_IF_ATTACK_DAMAGE_BASE = ConvertUnitWeaponIntegerField(FourCC("ua1b"))
UNIT_WEAPON_IF_ATTACK_DAMAGE_SIDES_PER_DIE = ConvertUnitWeaponIntegerField(FourCC("ua1s"))
UNIT_WEAPON_IF_ATTACK_MAXIMUM_NUMBER_OF_TARGETS = ConvertUnitWeaponIntegerField(FourCC("utc1"))
UNIT_WEAPON_IF_ATTACK_ATTACK_TYPE = ConvertUnitWeaponIntegerField(FourCC("ua1t"))
UNIT_WEAPON_IF_ATTACK_WEAPON_SOUND = ConvertUnitWeaponIntegerField(FourCC("ucs1"))
UNIT_WEAPON_IF_ATTACK_AREA_OF_EFFECT_TARGETS = ConvertUnitWeaponIntegerField(FourCC("ua1p"))
UNIT_WEAPON_IF_ATTACK_TARGETS_ALLOWED = ConvertUnitWeaponIntegerField(FourCC("ua1g"))
UNIT_WEAPON_RF_ATTACK_BACKSWING_POINT = ConvertUnitWeaponRealField(FourCC("ubs1"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_POINT = ConvertUnitWeaponRealField(FourCC("udp1"))
UNIT_WEAPON_RF_ATTACK_BASE_COOLDOWN = ConvertUnitWeaponRealField(FourCC("ua1c"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_LOSS_FACTOR = ConvertUnitWeaponRealField(FourCC("udl1"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_MEDIUM = ConvertUnitWeaponRealField(FourCC("uhd1"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_FACTOR_SMALL = ConvertUnitWeaponRealField(FourCC("uqd1"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_DISTANCE = ConvertUnitWeaponRealField(FourCC("usd1"))
UNIT_WEAPON_RF_ATTACK_DAMAGE_SPILL_RADIUS = ConvertUnitWeaponRealField(FourCC("usr1"))
UNIT_WEAPON_RF_ATTACK_PROJECTILE_SPEED = ConvertUnitWeaponRealField(FourCC("ua1z"))
UNIT_WEAPON_RF_ATTACK_PROJECTILE_ARC = ConvertUnitWeaponRealField(FourCC("uma1"))
UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_FULL_DAMAGE = ConvertUnitWeaponRealField(FourCC("ua1f"))
UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_MEDIUM_DAMAGE = ConvertUnitWeaponRealField(FourCC("ua1h"))
UNIT_WEAPON_RF_ATTACK_AREA_OF_EFFECT_SMALL_DAMAGE = ConvertUnitWeaponRealField(FourCC("ua1q"))
UNIT_WEAPON_RF_ATTACK_RANGE = ConvertUnitWeaponRealField(FourCC("ua1r"))
UNIT_WEAPON_BF_ATTACK_SHOW_UI = ConvertUnitWeaponBooleanField(FourCC("uwu1"))
UNIT_WEAPON_BF_ATTACKS_ENABLED = ConvertUnitWeaponBooleanField(FourCC("uaen"))
UNIT_WEAPON_BF_ATTACK_PROJECTILE_HOMING_ENABLED = ConvertUnitWeaponBooleanField(FourCC("umh1"))
UNIT_WEAPON_SF_ATTACK_PROJECTILE_ART = ConvertUnitWeaponStringField(FourCC("ua1m"))
MOVE_TYPE_UNKNOWN = ConvertMoveType(0)
MOVE_TYPE_FOOT = ConvertMoveType(1)
MOVE_TYPE_FLY = ConvertMoveType(2)
MOVE_TYPE_HORSE = ConvertMoveType(4)
MOVE_TYPE_HOVER = ConvertMoveType(8)
MOVE_TYPE_FLOAT = ConvertMoveType(16)
MOVE_TYPE_AMPHIBIOUS = ConvertMoveType(32)
MOVE_TYPE_UNBUILDABLE = ConvertMoveType(64)
TARGET_FLAG_NONE = ConvertTargetFlag(1)
TARGET_FLAG_GROUND = ConvertTargetFlag(2)
TARGET_FLAG_AIR = ConvertTargetFlag(4)
TARGET_FLAG_STRUCTURE = ConvertTargetFlag(8)
TARGET_FLAG_WARD = ConvertTargetFlag(16)
TARGET_FLAG_ITEM = ConvertTargetFlag(32)
TARGET_FLAG_TREE = ConvertTargetFlag(64)
TARGET_FLAG_WALL = ConvertTargetFlag(128)
TARGET_FLAG_DEBRIS = ConvertTargetFlag(256)
TARGET_FLAG_DECORATION = ConvertTargetFlag(512)
TARGET_FLAG_BRIDGE = ConvertTargetFlag(1024)
DEFENSE_TYPE_LIGHT = ConvertDefenseType(0)
DEFENSE_TYPE_MEDIUM = ConvertDefenseType(1)
DEFENSE_TYPE_LARGE = ConvertDefenseType(2)
DEFENSE_TYPE_FORT = ConvertDefenseType(3)
DEFENSE_TYPE_NORMAL = ConvertDefenseType(4)
DEFENSE_TYPE_HERO = ConvertDefenseType(5)
DEFENSE_TYPE_DIVINE = ConvertDefenseType(6)
DEFENSE_TYPE_NONE = ConvertDefenseType(7)
HERO_ATTRIBUTE_STR = ConvertHeroAttribute(1)
HERO_ATTRIBUTE_INT = ConvertHeroAttribute(2)
HERO_ATTRIBUTE_AGI = ConvertHeroAttribute(3)
ARMOR_TYPE_WHOKNOWS = ConvertArmorType(0)
ARMOR_TYPE_FLESH = ConvertArmorType(1)
ARMOR_TYPE_METAL = ConvertArmorType(2)
ARMOR_TYPE_WOOD = ConvertArmorType(3)
ARMOR_TYPE_ETHREAL = ConvertArmorType(4)
ARMOR_TYPE_STONE = ConvertArmorType(5)
REGENERATION_TYPE_NONE = ConvertRegenType(0)
REGENERATION_TYPE_ALWAYS = ConvertRegenType(1)
REGENERATION_TYPE_BLIGHT = ConvertRegenType(2)
REGENERATION_TYPE_DAY = ConvertRegenType(3)
REGENERATION_TYPE_NIGHT = ConvertRegenType(4)
UNIT_CATEGORY_GIANT = ConvertUnitCategory(1)
UNIT_CATEGORY_UNDEAD = ConvertUnitCategory(2)
UNIT_CATEGORY_SUMMONED = ConvertUnitCategory(4)
UNIT_CATEGORY_MECHANICAL = ConvertUnitCategory(8)
UNIT_CATEGORY_PEON = ConvertUnitCategory(16)
UNIT_CATEGORY_SAPPER = ConvertUnitCategory(32)
UNIT_CATEGORY_TOWNHALL = ConvertUnitCategory(64)
UNIT_CATEGORY_ANCIENT = ConvertUnitCategory(128)
UNIT_CATEGORY_NEUTRAL = ConvertUnitCategory(256)
UNIT_CATEGORY_WARD = ConvertUnitCategory(512)
UNIT_CATEGORY_STANDON = ConvertUnitCategory(1024)
UNIT_CATEGORY_TAUREN = ConvertUnitCategory(2048)
PATHING_FLAG_UNWALKABLE = ConvertPathingFlag(2)
PATHING_FLAG_UNFLYABLE = ConvertPathingFlag(4)
PATHING_FLAG_UNBUILDABLE = ConvertPathingFlag(8)
PATHING_FLAG_UNPEONHARVEST = ConvertPathingFlag(16)
PATHING_FLAG_BLIGHTED = ConvertPathingFlag(32)
PATHING_FLAG_UNFLOATABLE = ConvertPathingFlag(64)
PATHING_FLAG_UNAMPHIBIOUS = ConvertPathingFlag(128)
PATHING_FLAG_UNITEMPLACABLE = ConvertPathingFlag(256)
Lua:
bj_PI = 3.14159
bj_E = 2.71828
bj_CELLWIDTH = 128.0
bj_CLIFFHEIGHT = 128.0
bj_UNIT_FACING = 270.0
bj_RADTODEG = 180.0 / bj_PI
bj_DEGTORAD = bj_PI / 180.0
bj_TEXT_DELAY_QUEST = 20.00
bj_TEXT_DELAY_QUESTUPDATE = 20.00
bj_TEXT_DELAY_QUESTDONE = 20.00
bj_TEXT_DELAY_QUESTFAILED = 20.00
bj_TEXT_DELAY_QUESTREQUIREMENT = 20.00
bj_TEXT_DELAY_MISSIONFAILED = 20.00
bj_TEXT_DELAY_ALWAYSHINT = 12.00
bj_TEXT_DELAY_HINT = 12.00
bj_TEXT_DELAY_SECRET = 10.00
bj_TEXT_DELAY_UNITACQUIRED = 15.00
bj_TEXT_DELAY_UNITAVAILABLE = 10.00
bj_TEXT_DELAY_ITEMACQUIRED = 10.00
bj_TEXT_DELAY_WARNING = 12.00
bj_QUEUE_DELAY_QUEST = 5.00
bj_QUEUE_DELAY_HINT = 5.00
bj_QUEUE_DELAY_SECRET = 3.00
bj_HANDICAP_EASY = 60.00
bj_HANDICAP_NORMAL = 90.00
bj_HANDICAPDAMAGE_EASY = 50.00
bj_HANDICAPDAMAGE_NORMAL = 90.00
bj_HANDICAPREVIVE_NOTHARD = 50.00
bj_GAME_STARTED_THRESHOLD = 0.01
bj_WAIT_FOR_COND_MIN_INTERVAL = 0.10
bj_POLLED_WAIT_INTERVAL = 0.10
bj_POLLED_WAIT_SKIP_THRESHOLD = 2.00
bj_MAX_INVENTORY = 6
bj_MAX_PLAYERS = GetBJMaxPlayers()
bj_PLAYER_NEUTRAL_VICTIM = GetBJPlayerNeutralVictim()
bj_PLAYER_NEUTRAL_EXTRA = GetBJPlayerNeutralExtra()
bj_MAX_PLAYER_SLOTS = GetBJMaxPlayerSlots()
bj_MAX_SKELETONS = 25
bj_MAX_STOCK_ITEM_SLOTS = 11
bj_MAX_STOCK_UNIT_SLOTS = 11
bj_MAX_ITEM_LEVEL = 10
bj_MAX_CHECKPOINTS = 5
bj_TOD_DAWN = 6.00
bj_TOD_DUSK = 18.00
bj_MELEE_STARTING_TOD = 8.00
bj_MELEE_STARTING_GOLD_V0 = 750
bj_MELEE_STARTING_GOLD_V1 = 500
bj_MELEE_STARTING_LUMBER_V0 = 200
bj_MELEE_STARTING_LUMBER_V1 = 150
bj_MELEE_STARTING_HERO_TOKENS = 1
bj_MELEE_HERO_LIMIT = 3
bj_MELEE_HERO_TYPE_LIMIT = 1
bj_MELEE_MINE_SEARCH_RADIUS = 2000.0
bj_MELEE_CLEAR_UNITS_RADIUS = 1500.0
bj_MELEE_CRIPPLE_TIMEOUT = 120.00
bj_MELEE_CRIPPLE_MSG_DURATION = 20.00
bj_MELEE_MAX_TWINKED_HEROES_V0 = 3
bj_MELEE_MAX_TWINKED_HEROES_V1 = 1
bj_CREEP_ITEM_DELAY = 0.50
bj_STOCK_RESTOCK_INITIAL_DELAY = 120.0
bj_STOCK_RESTOCK_INTERVAL = 30.0
bj_STOCK_MAX_ITERATIONS = 20
bj_MAX_DEST_IN_REGION_EVENTS = 64
bj_CAMERA_MIN_FARZ = 100
bj_CAMERA_DEFAULT_DISTANCE = 1650
bj_CAMERA_DEFAULT_FARZ = 5000
bj_CAMERA_DEFAULT_AOA = 304
bj_CAMERA_DEFAULT_FOV = 70
bj_CAMERA_DEFAULT_ROLL = 0
bj_CAMERA_DEFAULT_ROTATION = 90
bj_RESCUE_PING_TIME = 2.00
bj_NOTHING_SOUND_DURATION = 5.00
bj_TRANSMISSION_PING_TIME = 1.00
bj_TRANSMISSION_IND_RED = 255
bj_TRANSMISSION_IND_BLUE = 255
bj_TRANSMISSION_IND_GREEN = 255
bj_TRANSMISSION_IND_ALPHA = 255
bj_TRANSMISSION_PORT_HANGTIME = 1.50
bj_CINEMODE_INTERFACEFADE = 0.50
bj_CINEMODE_GAMESPEED = MAP_SPEED_NORMAL
bj_CINEMODE_VOLUME_UNITMOVEMENT = 0.40
bj_CINEMODE_VOLUME_UNITSOUNDS = 0.00
bj_CINEMODE_VOLUME_COMBAT = 0.40
bj_CINEMODE_VOLUME_SPELLS = 0.40
bj_CINEMODE_VOLUME_UI = 0.00
bj_CINEMODE_VOLUME_MUSIC = 0.55
bj_CINEMODE_VOLUME_AMBIENTSOUNDS = 1.00
bj_CINEMODE_VOLUME_FIRE = 0.60
bj_SPEECH_VOLUME_UNITMOVEMENT = 0.25
bj_SPEECH_VOLUME_UNITSOUNDS = 0.00
bj_SPEECH_VOLUME_COMBAT = 0.25
bj_SPEECH_VOLUME_SPELLS = 0.25
bj_SPEECH_VOLUME_UI = 0.00
bj_SPEECH_VOLUME_MUSIC = 0.55
bj_SPEECH_VOLUME_AMBIENTSOUNDS = 1.00
bj_SPEECH_VOLUME_FIRE = 0.60
bj_SMARTPAN_TRESHOLD_PAN = 500.0
bj_SMARTPAN_TRESHOLD_SNAP = 3500.0
bj_MAX_QUEUED_TRIGGERS = 100
bj_QUEUED_TRIGGER_TIMEOUT = 180.00
bj_CAMPAIGN_INDEX_T = 0
bj_CAMPAIGN_INDEX_H = 1
bj_CAMPAIGN_INDEX_U = 2
bj_CAMPAIGN_INDEX_O = 3
bj_CAMPAIGN_INDEX_N = 4
bj_CAMPAIGN_INDEX_XN = 5
bj_CAMPAIGN_INDEX_XH = 6
bj_CAMPAIGN_INDEX_XU = 7
bj_CAMPAIGN_INDEX_XO = 8
bj_CAMPAIGN_OFFSET_T = 0
bj_CAMPAIGN_OFFSET_H = 1
bj_CAMPAIGN_OFFSET_U = 2
bj_CAMPAIGN_OFFSET_O = 3
bj_CAMPAIGN_OFFSET_N = 4
bj_CAMPAIGN_OFFSET_XN = 5
bj_CAMPAIGN_OFFSET_XH = 6
bj_CAMPAIGN_OFFSET_XU = 7
bj_CAMPAIGN_OFFSET_XO = 8
bj_MISSION_INDEX_T00 = bj_CAMPAIGN_OFFSET_T * 1000 + 0
bj_MISSION_INDEX_T01 = bj_CAMPAIGN_OFFSET_T * 1000 + 1
bj_MISSION_INDEX_T02 = bj_CAMPAIGN_OFFSET_T * 1000 + 2
bj_MISSION_INDEX_T03 = bj_CAMPAIGN_OFFSET_T * 1000 + 3
bj_MISSION_INDEX_T04 = bj_CAMPAIGN_OFFSET_T * 1000 + 4
bj_MISSION_INDEX_H00 = bj_CAMPAIGN_OFFSET_H * 1000 + 0
bj_MISSION_INDEX_H01 = bj_CAMPAIGN_OFFSET_H * 1000 + 1
bj_MISSION_INDEX_H02 = bj_CAMPAIGN_OFFSET_H * 1000 + 2
bj_MISSION_INDEX_H03 = bj_CAMPAIGN_OFFSET_H * 1000 + 3
bj_MISSION_INDEX_H04 = bj_CAMPAIGN_OFFSET_H * 1000 + 4
bj_MISSION_INDEX_H05 = bj_CAMPAIGN_OFFSET_H * 1000 + 5
bj_MISSION_INDEX_H06 = bj_CAMPAIGN_OFFSET_H * 1000 + 6
bj_MISSION_INDEX_H07 = bj_CAMPAIGN_OFFSET_H * 1000 + 7
bj_MISSION_INDEX_H08 = bj_CAMPAIGN_OFFSET_H * 1000 + 8
bj_MISSION_INDEX_H09 = bj_CAMPAIGN_OFFSET_H * 1000 + 9
bj_MISSION_INDEX_H10 = bj_CAMPAIGN_OFFSET_H * 1000 + 10
bj_MISSION_INDEX_H11 = bj_CAMPAIGN_OFFSET_H * 1000 + 11
bj_MISSION_INDEX_U00 = bj_CAMPAIGN_OFFSET_U * 1000 + 0
bj_MISSION_INDEX_U01 = bj_CAMPAIGN_OFFSET_U * 1000 + 1
bj_MISSION_INDEX_U02 = bj_CAMPAIGN_OFFSET_U * 1000 + 2
bj_MISSION_INDEX_U03 = bj_CAMPAIGN_OFFSET_U * 1000 + 3
bj_MISSION_INDEX_U05 = bj_CAMPAIGN_OFFSET_U * 1000 + 4
bj_MISSION_INDEX_U07 = bj_CAMPAIGN_OFFSET_U * 1000 + 5
bj_MISSION_INDEX_U08 = bj_CAMPAIGN_OFFSET_U * 1000 + 6
bj_MISSION_INDEX_U09 = bj_CAMPAIGN_OFFSET_U * 1000 + 7
bj_MISSION_INDEX_U10 = bj_CAMPAIGN_OFFSET_U * 1000 + 8
bj_MISSION_INDEX_U11 = bj_CAMPAIGN_OFFSET_U * 1000 + 9
bj_MISSION_INDEX_O00 = bj_CAMPAIGN_OFFSET_O * 1000 + 0
bj_MISSION_INDEX_O01 = bj_CAMPAIGN_OFFSET_O * 1000 + 1
bj_MISSION_INDEX_O02 = bj_CAMPAIGN_OFFSET_O * 1000 + 2
bj_MISSION_INDEX_O03 = bj_CAMPAIGN_OFFSET_O * 1000 + 3
bj_MISSION_INDEX_O04 = bj_CAMPAIGN_OFFSET_O * 1000 + 4
bj_MISSION_INDEX_O05 = bj_CAMPAIGN_OFFSET_O * 1000 + 5
bj_MISSION_INDEX_O06 = bj_CAMPAIGN_OFFSET_O * 1000 + 6
bj_MISSION_INDEX_O07 = bj_CAMPAIGN_OFFSET_O * 1000 + 7
bj_MISSION_INDEX_O08 = bj_CAMPAIGN_OFFSET_O * 1000 + 8
bj_MISSION_INDEX_O09 = bj_CAMPAIGN_OFFSET_O * 1000 + 9
bj_MISSION_INDEX_O10 = bj_CAMPAIGN_OFFSET_O * 1000 + 10
bj_MISSION_INDEX_N00 = bj_CAMPAIGN_OFFSET_N * 1000 + 0
bj_MISSION_INDEX_N01 = bj_CAMPAIGN_OFFSET_N * 1000 + 1
bj_MISSION_INDEX_N02 = bj_CAMPAIGN_OFFSET_N * 1000 + 2
bj_MISSION_INDEX_N03 = bj_CAMPAIGN_OFFSET_N * 1000 + 3
bj_MISSION_INDEX_N04 = bj_CAMPAIGN_OFFSET_N * 1000 + 4
bj_MISSION_INDEX_N05 = bj_CAMPAIGN_OFFSET_N * 1000 + 5
bj_MISSION_INDEX_N06 = bj_CAMPAIGN_OFFSET_N * 1000 + 6
bj_MISSION_INDEX_N07 = bj_CAMPAIGN_OFFSET_N * 1000 + 7
bj_MISSION_INDEX_N08 = bj_CAMPAIGN_OFFSET_N * 1000 + 8
bj_MISSION_INDEX_N09 = bj_CAMPAIGN_OFFSET_N * 1000 + 9
bj_MISSION_INDEX_XN00 = bj_CAMPAIGN_OFFSET_XN * 1000 + 0
bj_MISSION_INDEX_XN01 = bj_CAMPAIGN_OFFSET_XN * 1000 + 1
bj_MISSION_INDEX_XN02 = bj_CAMPAIGN_OFFSET_XN * 1000 + 2
bj_MISSION_INDEX_XN03 = bj_CAMPAIGN_OFFSET_XN * 1000 + 3
bj_MISSION_INDEX_XN04 = bj_CAMPAIGN_OFFSET_XN * 1000 + 4
bj_MISSION_INDEX_XN05 = bj_CAMPAIGN_OFFSET_XN * 1000 + 5
bj_MISSION_INDEX_XN06 = bj_CAMPAIGN_OFFSET_XN * 1000 + 6
bj_MISSION_INDEX_XN07 = bj_CAMPAIGN_OFFSET_XN * 1000 + 7
bj_MISSION_INDEX_XN08 = bj_CAMPAIGN_OFFSET_XN * 1000 + 8
bj_MISSION_INDEX_XN09 = bj_CAMPAIGN_OFFSET_XN * 1000 + 9
bj_MISSION_INDEX_XN10 = bj_CAMPAIGN_OFFSET_XN * 1000 + 10
bj_MISSION_INDEX_XH00 = bj_CAMPAIGN_OFFSET_XH * 1000 + 0
bj_MISSION_INDEX_XH01 = bj_CAMPAIGN_OFFSET_XH * 1000 + 1
bj_MISSION_INDEX_XH02 = bj_CAMPAIGN_OFFSET_XH * 1000 + 2
bj_MISSION_INDEX_XH03 = bj_CAMPAIGN_OFFSET_XH * 1000 + 3
bj_MISSION_INDEX_XH04 = bj_CAMPAIGN_OFFSET_XH * 1000 + 4
bj_MISSION_INDEX_XH05 = bj_CAMPAIGN_OFFSET_XH * 1000 + 5
bj_MISSION_INDEX_XH06 = bj_CAMPAIGN_OFFSET_XH * 1000 + 6
bj_MISSION_INDEX_XH07 = bj_CAMPAIGN_OFFSET_XH * 1000 + 7
bj_MISSION_INDEX_XH08 = bj_CAMPAIGN_OFFSET_XH * 1000 + 8
bj_MISSION_INDEX_XH09 = bj_CAMPAIGN_OFFSET_XH * 1000 + 9
bj_MISSION_INDEX_XU00 = bj_CAMPAIGN_OFFSET_XU * 1000 + 0
bj_MISSION_INDEX_XU01 = bj_CAMPAIGN_OFFSET_XU * 1000 + 1
bj_MISSION_INDEX_XU02 = bj_CAMPAIGN_OFFSET_XU * 1000 + 2
bj_MISSION_INDEX_XU03 = bj_CAMPAIGN_OFFSET_XU * 1000 + 3
bj_MISSION_INDEX_XU04 = bj_CAMPAIGN_OFFSET_XU * 1000 + 4
bj_MISSION_INDEX_XU05 = bj_CAMPAIGN_OFFSET_XU * 1000 + 5
bj_MISSION_INDEX_XU06 = bj_CAMPAIGN_OFFSET_XU * 1000 + 6
bj_MISSION_INDEX_XU07 = bj_CAMPAIGN_OFFSET_XU * 1000 + 7
bj_MISSION_INDEX_XU08 = bj_CAMPAIGN_OFFSET_XU * 1000 + 8
bj_MISSION_INDEX_XU09 = bj_CAMPAIGN_OFFSET_XU * 1000 + 9
bj_MISSION_INDEX_XU10 = bj_CAMPAIGN_OFFSET_XU * 1000 + 10
bj_MISSION_INDEX_XU11 = bj_CAMPAIGN_OFFSET_XU * 1000 + 11
bj_MISSION_INDEX_XU12 = bj_CAMPAIGN_OFFSET_XU * 1000 + 12
bj_MISSION_INDEX_XU13 = bj_CAMPAIGN_OFFSET_XU * 1000 + 13
bj_MISSION_INDEX_XO00 = bj_CAMPAIGN_OFFSET_XO * 1000 + 0
bj_MISSION_INDEX_XO01 = bj_CAMPAIGN_OFFSET_XO * 1000 + 1
bj_MISSION_INDEX_XO02 = bj_CAMPAIGN_OFFSET_XO * 1000 + 2
bj_MISSION_INDEX_XO03 = bj_CAMPAIGN_OFFSET_XO * 1000 + 3
bj_CINEMATICINDEX_TOP = 0
bj_CINEMATICINDEX_HOP = 1
bj_CINEMATICINDEX_HED = 2
bj_CINEMATICINDEX_OOP = 3
bj_CINEMATICINDEX_OED = 4
bj_CINEMATICINDEX_UOP = 5
bj_CINEMATICINDEX_UED = 6
bj_CINEMATICINDEX_NOP = 7
bj_CINEMATICINDEX_NED = 8
bj_CINEMATICINDEX_XOP = 9
bj_CINEMATICINDEX_XED = 10
bj_ALLIANCE_UNALLIED = 0
bj_ALLIANCE_UNALLIED_VISION = 1
bj_ALLIANCE_ALLIED = 2
bj_ALLIANCE_ALLIED_VISION = 3
bj_ALLIANCE_ALLIED_UNITS = 4
bj_ALLIANCE_ALLIED_ADVUNITS = 5
bj_ALLIANCE_NEUTRAL = 6
bj_ALLIANCE_NEUTRAL_VISION = 7
bj_KEYEVENTTYPE_DEPRESS = 0
bj_KEYEVENTTYPE_RELEASE = 1
bj_KEYEVENTKEY_LEFT = 0
bj_KEYEVENTKEY_RIGHT = 1
bj_KEYEVENTKEY_DOWN = 2
bj_KEYEVENTKEY_UP = 3
bj_MOUSEEVENTTYPE_DOWN = 0
bj_MOUSEEVENTTYPE_UP = 1
bj_MOUSEEVENTTYPE_MOVE = 2
bj_TIMETYPE_ADD = 0
bj_TIMETYPE_SET = 1
bj_TIMETYPE_SUB = 2
bj_CAMERABOUNDS_ADJUST_ADD = 0
bj_CAMERABOUNDS_ADJUST_SUB = 1
bj_QUESTTYPE_REQ_DISCOVERED = 0
bj_QUESTTYPE_REQ_UNDISCOVERED = 1
bj_QUESTTYPE_OPT_DISCOVERED = 2
bj_QUESTTYPE_OPT_UNDISCOVERED = 3
bj_QUESTMESSAGE_DISCOVERED = 0
bj_QUESTMESSAGE_UPDATED = 1
bj_QUESTMESSAGE_COMPLETED = 2
bj_QUESTMESSAGE_FAILED = 3
bj_QUESTMESSAGE_REQUIREMENT = 4
bj_QUESTMESSAGE_MISSIONFAILED = 5
bj_QUESTMESSAGE_ALWAYSHINT = 6
bj_QUESTMESSAGE_HINT = 7
bj_QUESTMESSAGE_SECRET = 8
bj_QUESTMESSAGE_UNITACQUIRED = 9
bj_QUESTMESSAGE_UNITAVAILABLE = 10
bj_QUESTMESSAGE_ITEMACQUIRED = 11
bj_QUESTMESSAGE_WARNING = 12
bj_SORTTYPE_SORTBYVALUE = 0
bj_SORTTYPE_SORTBYPLAYER = 1
bj_SORTTYPE_SORTBYLABEL = 2
bj_CINEFADETYPE_FADEIN = 0
bj_CINEFADETYPE_FADEOUT = 1
bj_CINEFADETYPE_FADEOUTIN = 2
bj_REMOVEBUFFS_POSITIVE = 0
bj_REMOVEBUFFS_NEGATIVE = 1
bj_REMOVEBUFFS_ALL = 2
bj_REMOVEBUFFS_NONTLIFE = 3
bj_BUFF_POLARITY_POSITIVE = 0
bj_BUFF_POLARITY_NEGATIVE = 1
bj_BUFF_POLARITY_EITHER = 2
bj_BUFF_RESIST_MAGIC = 0
bj_BUFF_RESIST_PHYSICAL = 1
bj_BUFF_RESIST_EITHER = 2
bj_BUFF_RESIST_BOTH = 3
bj_HEROSTAT_STR = 0
bj_HEROSTAT_AGI = 1
bj_HEROSTAT_INT = 2
bj_MODIFYMETHOD_ADD = 0
bj_MODIFYMETHOD_SUB = 1
bj_MODIFYMETHOD_SET = 2
bj_UNIT_STATE_METHOD_ABSOLUTE = 0
bj_UNIT_STATE_METHOD_RELATIVE = 1
bj_UNIT_STATE_METHOD_DEFAULTS = 2
bj_UNIT_STATE_METHOD_MAXIMUM = 3
bj_GATEOPERATION_CLOSE = 0
bj_GATEOPERATION_OPEN = 1
bj_GATEOPERATION_DESTROY = 2
bj_GAMECACHE_BOOLEAN = 0
bj_GAMECACHE_INTEGER = 1
bj_GAMECACHE_REAL = 2
bj_GAMECACHE_UNIT = 3
bj_GAMECACHE_STRING = 4
bj_HASHTABLE_BOOLEAN = 0
bj_HASHTABLE_INTEGER = 1
bj_HASHTABLE_REAL = 2
bj_HASHTABLE_STRING = 3
bj_HASHTABLE_HANDLE = 4
bj_ITEM_STATUS_HIDDEN = 0
bj_ITEM_STATUS_OWNED = 1
bj_ITEM_STATUS_INVULNERABLE = 2
bj_ITEM_STATUS_POWERUP = 3
bj_ITEM_STATUS_SELLABLE = 4
bj_ITEM_STATUS_PAWNABLE = 5
bj_ITEMCODE_STATUS_POWERUP = 0
bj_ITEMCODE_STATUS_SELLABLE = 1
bj_ITEMCODE_STATUS_PAWNABLE = 2
bj_MINIMAPPINGSTYLE_SIMPLE = 0
bj_MINIMAPPINGSTYLE_FLASHY = 1
bj_MINIMAPPINGSTYLE_ATTACK = 2
bj_CAMPPINGSTYLE_PRIMARY = 0
bj_CAMPPINGSTYLE_PRIMARY_GREEN = 1
bj_CAMPPINGSTYLE_PRIMARY_RED = 2
bj_CAMPPINGSTYLE_BONUS = 3
bj_CAMPPINGSTYLE_TURNIN = 4
bj_CAMPPINGSTYLE_BOSS = 5
bj_CAMPPINGSTYLE_CONTROL_ALLY = 6
bj_CAMPPINGSTYLE_CONTROL_NEUTRAL = 7
bj_CAMPPINGSTYLE_CONTROL_ENEMY = 8
bj_CORPSE_MAX_DEATH_TIME = 8.00
bj_CORPSETYPE_FLESH = 0
bj_CORPSETYPE_BONE = 1
bj_ELEVATOR_BLOCKER_CODE = FourCC("DTep")
bj_ELEVATOR_CODE01 = FourCC("DTrf")
bj_ELEVATOR_CODE02 = FourCC("DTrx")
bj_ELEVATOR_WALL_TYPE_ALL = 0
bj_ELEVATOR_WALL_TYPE_EAST = 1
bj_ELEVATOR_WALL_TYPE_NORTH = 2
bj_ELEVATOR_WALL_TYPE_SOUTH = 3
bj_ELEVATOR_WALL_TYPE_WEST = 4
bj_FORCE_ALL_PLAYERS = nil
bj_FORCE_PLAYER = {}
bj_MELEE_MAX_TWINKED_HEROES = 0
bj_mapInitialPlayableArea = nil
bj_mapInitialCameraBounds = nil
bj_forLoopAIndex = 0
bj_forLoopBIndex = 0
bj_forLoopAIndexEnd = 0
bj_forLoopBIndexEnd = 0
bj_slotControlReady = false
bj_slotControlUsed = __jarray(false)
bj_slotControl = {}
bj_gameStartedTimer = nil
bj_gameStarted = false
bj_volumeGroupsTimer = CreateTimer()
bj_isSinglePlayer = false
bj_dncSoundsDay = nil
bj_dncSoundsNight = nil
bj_dayAmbientSound = nil
bj_nightAmbientSound = nil
bj_dncSoundsDawn = nil
bj_dncSoundsDusk = nil
bj_dawnSound = nil
bj_duskSound = nil
bj_useDawnDuskSounds = true
bj_dncIsDaytime = false
bj_rescueSound = nil
bj_questDiscoveredSound = nil
bj_questUpdatedSound = nil
bj_questCompletedSound = nil
bj_questFailedSound = nil
bj_questHintSound = nil
bj_questSecretSound = nil
bj_questItemAcquiredSound = nil
bj_questWarningSound = nil
bj_victoryDialogSound = nil
bj_defeatDialogSound = nil
bj_stockItemPurchased = nil
bj_stockUpdateTimer = nil
bj_stockAllowedPermanent = __jarray(false)
bj_stockAllowedCharged = __jarray(false)
bj_stockAllowedArtifact = __jarray(false)
bj_stockPickedItemLevel = 0
bj_stockPickedItemType = nil
bj_meleeVisibilityTrained = nil
bj_meleeVisibilityIsDay = true
bj_meleeGrantHeroItems = false
bj_meleeNearestMineToLoc = nil
bj_meleeNearestMine = nil
bj_meleeNearestMineDist = 0.00
bj_meleeGameOver = false
bj_meleeDefeated = __jarray(false)
bj_meleeVictoried = __jarray(false)
bj_ghoul = {}
bj_crippledTimer = {}
bj_crippledTimerWindows = {}
bj_playerIsCrippled = __jarray(false)
bj_playerIsExposed = __jarray(false)
bj_finishSoonAllExposed = false
bj_finishSoonTimerDialog = nil
bj_meleeTwinkedHeroes = __jarray(0)
bj_rescueUnitBehavior = nil
bj_rescueChangeColorUnit = true
bj_rescueChangeColorBldg = true
bj_cineSceneEndingTimer = nil
bj_cineSceneLastSound = nil
bj_cineSceneBeingSkipped = nil
bj_cineModePriorSpeed = MAP_SPEED_NORMAL
bj_cineModePriorFogSetting = false
bj_cineModePriorMaskSetting = false
bj_cineModeAlreadyIn = false
bj_cineModePriorDawnDusk = false
bj_cineModeSavedSeed = 0
bj_cineFadeFinishTimer = nil
bj_cineFadeContinueTimer = nil
bj_cineFadeContinueRed = 0.0
bj_cineFadeContinueGreen = 0.0
bj_cineFadeContinueBlue = 0.0
bj_cineFadeContinueTrans = 0.0
bj_cineFadeContinueDuration = 0.0
bj_cineFadeContinueTex = ""
bj_queuedExecTotal = 0
bj_queuedExecTriggers = {}
bj_queuedExecUseConds = __jarray(false)
bj_queuedExecTimeoutTimer = CreateTimer()
bj_queuedExecTimeout = nil
bj_destInRegionDiesCount = 0
bj_destInRegionDiesTrig = nil
bj_groupCountUnits = 0
bj_forceCountPlayers = 0
bj_groupEnumTypeId = 0
bj_groupEnumOwningPlayer = nil
bj_groupAddGroupDest = nil
bj_groupRemoveGroupDest = nil
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = nil
bj_groupLastCreatedDest = nil
bj_randomSubGroupGroup = nil
bj_randomSubGroupWant = 0
bj_randomSubGroupTotal = 0
bj_randomSubGroupChance = 0.0
bj_destRandomConsidered = 0
bj_destRandomCurrentPick = nil
bj_elevatorWallBlocker = nil
bj_elevatorNeighbor = nil
bj_itemRandomConsidered = 0
bj_itemRandomCurrentPick = nil
bj_forceRandomConsidered = 0
bj_forceRandomCurrentPick = nil
bj_makeUnitRescuableUnit = nil
bj_makeUnitRescuableFlag = true
bj_pauseAllUnitsFlag = true
bj_enumDestructableCenter = nil
bj_enumDestructableRadius = 0.0
bj_setPlayerTargetColor = nil
bj_isUnitGroupDeadResult = true
bj_isUnitGroupEmptyResult = true
bj_isUnitGroupInRectResult = true
bj_isUnitGroupInRectRect = nil
bj_changeLevelShowScores = false
bj_changeLevelMapName = ""
bj_suspendDecayFleshGroup = CreateGroup()
bj_suspendDecayBoneGroup = CreateGroup()
bj_delayedSuspendDecayTimer = CreateTimer()
bj_delayedSuspendDecayTrig = nil
bj_livingPlayerUnitsTypeId = 0
bj_lastDyingWidget = nil
bj_randDistCount = 0
bj_randDistID = __jarray(0)
bj_randDistChance = __jarray(0)
bj_lastCreatedUnit = nil
bj_lastCreatedItem = nil
bj_lastRemovedItem = nil
bj_lastHauntedGoldMine = nil
bj_lastCreatedDestructable = nil
bj_lastCreatedGroup = CreateGroup()
bj_lastCreatedFogModifier = nil
bj_lastCreatedEffect = nil
bj_lastCreatedWeatherEffect = nil
bj_lastCreatedTerrainDeformation = nil
bj_lastCreatedQuest = nil
bj_lastCreatedQuestItem = nil
bj_lastCreatedDefeatCondition = nil
bj_lastStartedTimer = CreateTimer()
bj_lastCreatedTimerDialog = nil
bj_lastCreatedLeaderboard = nil
bj_lastCreatedMultiboard = nil
bj_lastPlayedSound = nil
bj_lastPlayedMusic = ""
bj_lastTransmissionDuration = 0.0
bj_lastCreatedGameCache = nil
bj_lastCreatedHashtable = nil
bj_lastLoadedUnit = nil
bj_lastCreatedButton = nil
bj_lastReplacedUnit = nil
bj_lastCreatedTextTag = nil
bj_lastCreatedLightning = nil
bj_lastCreatedImage = nil
bj_lastCreatedUbersplat = nil
bj_lastCreatedMinimapIcon = nil
bj_lastCreatedCommandButtonEffect = nil
filterIssueHauntOrderAtLocBJ = nil
filterEnumDestructablesInCircleBJ = nil
filterGetUnitsInRectOfPlayer = nil
filterGetUnitsOfTypeIdAll = nil
filterGetUnitsOfPlayerAndTypeId = nil
filterMeleeTrainedUnitIsHeroBJ = nil
filterLivingPlayerUnitsOfTypeId = nil
bj_wantDestroyGroup = false
bj_lastInstObjFuncSuccessful = true
function BJDebugMsg(msg)
local i = 0

while (true) do
DisplayTimedTextToPlayer(Player(i), 0, 0, 60, msg)
i = i + 1
if (i == bj_MAX_PLAYERS) then break end
end
end

function RMinBJ(a, b)
if (a < b) then
return a
else
return b
end
end

function RMaxBJ(a, b)
if (a < b) then
return b
else
return a
end
end

function RAbsBJ(a)
if (a >= 0) then
return a
else
return -a
end
end

function RSignBJ(a)
if (a >= 0.0) then
return 1.0
else
return -1.0
end
end

function IMinBJ(a, b)
if (a < b) then
return a
else
return b
end
end

function IMaxBJ(a, b)
if (a < b) then
return b
else
return a
end
end

function IAbsBJ(a)
if (a >= 0) then
return a
else
return -a
end
end

function ISignBJ(a)
if (a >= 0) then
return 1
else
return -1
end
end

function SinBJ(degrees)
return Sin(degrees * bj_DEGTORAD)
end

function CosBJ(degrees)
return Cos(degrees * bj_DEGTORAD)
end

function TanBJ(degrees)
return Tan(degrees * bj_DEGTORAD)
end

function AsinBJ(degrees)
return Asin(degrees) * bj_RADTODEG
end

function AcosBJ(degrees)
return Acos(degrees) * bj_RADTODEG
end

function AtanBJ(degrees)
return Atan(degrees) * bj_RADTODEG
end

function Atan2BJ(y, x)
return Atan2(y, x) * bj_RADTODEG
end

function AngleBetweenPoints(locA, locB)
return bj_RADTODEG * Atan2(GetLocationY(locB) - GetLocationY(locA), GetLocationX(locB) - GetLocationX(locA))
end

function DistanceBetweenPoints(locA, locB)
local dx = GetLocationX(locB) - GetLocationX(locA)
local dy = GetLocationY(locB) - GetLocationY(locA)

return SquareRoot(dx * dx + dy * dy)
end

function PolarProjectionBJ(source, dist, angle)
local x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
local y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)

return Location(x, y)
end

function GetRandomDirectionDeg()
return GetRandomReal(0, 360)
end

function GetRandomPercentageBJ()
return GetRandomReal(0, 100)
end

function GetRandomLocInRect(whichRect)
return Location(GetRandomReal(GetRectMinX(whichRect), GetRectMaxX(whichRect)), GetRandomReal(GetRectMinY(whichRect), GetRectMaxY(whichRect)))
end

function ModuloInteger(dividend, divisor)
local modulus = dividend - (dividend // divisor) * divisor

if (modulus < 0) then
modulus = modulus + divisor
end
return modulus
end

function ModuloReal(dividend, divisor)
local modulus = dividend - I2R(R2I(dividend / divisor)) * divisor

if (modulus < 0) then
modulus = modulus + divisor
end
return modulus
end

function OffsetLocation(loc, dx, dy)
return Location(GetLocationX(loc) + dx, GetLocationY(loc) + dy)
end

function OffsetRectBJ(r, dx, dy)
return Rect(GetRectMinX(r) + dx, GetRectMinY(r) + dy, GetRectMaxX(r) + dx, GetRectMaxY(r) + dy)
end

function RectFromCenterSizeBJ(center, width, height)
local x = GetLocationX(center)
local y = GetLocationY(center)

return Rect(x - width * 0.5, y - height * 0.5, x + width * 0.5, y + height * 0.5)
end

function RectContainsCoords(r, x, y)
return ((GetRectMinX(r) <= x) and ((x <= GetRectMaxX(r)) and ((GetRectMinY(r) <= y) and (y <= GetRectMaxY(r)))))
end

function RectContainsLoc(r, loc)
return RectContainsCoords(r, GetLocationX(loc), GetLocationY(loc))
end

function RectContainsUnit(r, whichUnit)
return RectContainsCoords(r, GetUnitX(whichUnit), GetUnitY(whichUnit))
end

function RectContainsItem(whichItem, r)
if (whichItem == nil) then
return false
end
if (IsItemOwned(whichItem)) then
return false
end
return RectContainsCoords(r, GetItemX(whichItem), GetItemY(whichItem))
end

function ConditionalTriggerExecute(trig)
if TriggerEvaluate(trig) then
TriggerExecute(trig)
end
end

function TriggerExecuteBJ(trig, checkConditions)
if checkConditions then
if not (TriggerEvaluate(trig)) then
return false
end
end
TriggerExecute(trig)
return true
end

function PostTriggerExecuteBJ(trig, checkConditions)
if checkConditions then
if not (TriggerEvaluate(trig)) then
return false
end
end
TriggerRegisterTimerEvent(trig, 0, false)
return true
end

function QueuedTriggerCheck()
local s = "TrigQueue Check "
local i

i = 0
while (true) do
if (i >= bj_queuedExecTotal) then break end
s = s .. "q[" .. I2S(i) .. "]="
if (bj_queuedExecTriggers[i] == nil) then
s = s .. "null "
else
s = s .. "x "
end
i = i + 1
end
s = s .. "(" .. I2S(bj_queuedExecTotal) .. " total)"
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 600, s)
end

function QueuedTriggerGetIndex(trig)
local index = 0

while (true) do
if (index >= bj_queuedExecTotal) then break end
if (bj_queuedExecTriggers[index] == trig) then
return index
end
index = index + 1
end
return -1
end

function QueuedTriggerRemoveByIndex(trigIndex)
local index

if (trigIndex >= bj_queuedExecTotal) then
return false
end
bj_queuedExecTotal = bj_queuedExecTotal - 1
index = trigIndex
while (true) do
if (index >= bj_queuedExecTotal) then break end
bj_queuedExecTriggers[index] = bj_queuedExecTriggers[index + 1]
bj_queuedExecUseConds[index] = bj_queuedExecUseConds[index + 1]
index = index + 1
end
return true
end

function QueuedTriggerAttemptExec()
while (true) do
if (bj_queuedExecTotal == 0) then break end
if TriggerExecuteBJ(bj_queuedExecTriggers[0], bj_queuedExecUseConds[0]) then
TimerStart(bj_queuedExecTimeoutTimer, bj_QUEUED_TRIGGER_TIMEOUT, false, nil)
return true
end
QueuedTriggerRemoveByIndex(0)
end
return false
end

function QueuedTriggerAddBJ(trig, checkConditions)
if (bj_queuedExecTotal >= bj_MAX_QUEUED_TRIGGERS) then
return false
end
bj_queuedExecTriggers[bj_queuedExecTotal] = trig
bj_queuedExecUseConds[bj_queuedExecTotal] = checkConditions
bj_queuedExecTotal = bj_queuedExecTotal + 1
if (bj_queuedExecTotal == 1) then
QueuedTriggerAttemptExec()
end
return true
end

function QueuedTriggerRemoveBJ(trig)
local index
local trigIndex
local trigExecuted

trigIndex = QueuedTriggerGetIndex(trig)
if (trigIndex == -1) then
return
end
QueuedTriggerRemoveByIndex(trigIndex)
if (trigIndex == 0) then
PauseTimer(bj_queuedExecTimeoutTimer)
QueuedTriggerAttemptExec()
end
end

function QueuedTriggerDoneBJ()
local index

if (bj_queuedExecTotal <= 0) then
return
end
QueuedTriggerRemoveByIndex(0)
PauseTimer(bj_queuedExecTimeoutTimer)
QueuedTriggerAttemptExec()
end

function QueuedTriggerClearBJ()
PauseTimer(bj_queuedExecTimeoutTimer)
bj_queuedExecTotal = 0
end

function QueuedTriggerClearInactiveBJ()
bj_queuedExecTotal = IMinBJ(bj_queuedExecTotal, 1)
end

function QueuedTriggerCountBJ()
return bj_queuedExecTotal
end

function IsTriggerQueueEmptyBJ()
return bj_queuedExecTotal <= 0
end

function IsTriggerQueuedBJ(trig)
return QueuedTriggerGetIndex(trig) ~= -1
end

function GetForLoopIndexA()
return bj_forLoopAIndex
end

function SetForLoopIndexA(newIndex)
bj_forLoopAIndex = newIndex
end

function GetForLoopIndexB()
return bj_forLoopBIndex
end

function SetForLoopIndexB(newIndex)
bj_forLoopBIndex = newIndex
end

function PolledWait(duration)
local t
local timeRemaining

if (duration > 0) then
t = CreateTimer()
TimerStart(t, duration, false, nil)
while (true) do
timeRemaining = TimerGetRemaining(t)
if (timeRemaining <= 0) then break end
if (timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD) then
TriggerSleepAction(0.1 * timeRemaining)
else
TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
end
end
DestroyTimer(t)
end
end

function IntegerTertiaryOp(flag, valueA, valueB)
if flag then
return valueA
else
return valueB
end
end

function DoNothing()
end

function CommentString(commentString)
end

function StringIdentity(theString)
return GetLocalizedString(theString)
end

function GetBooleanAnd(valueA, valueB)
return (valueA and valueB)
end

function GetBooleanOr(valueA, valueB)
return (valueA or valueB)
end

function PercentToInt(percentage, max)
local realpercent = percentage * I2R(max) * 0.01
local result = MathRound(realpercent)

if (result < 0) then
result = 0
elseif (result > max) then
result = max
end
return result
end

function PercentTo255(percentage)
return PercentToInt(percentage, 255)
end

function GetTimeOfDay()
return GetFloatGameState(GAME_STATE_TIME_OF_DAY)
end

function SetTimeOfDay(whatTime)
SetFloatGameState(GAME_STATE_TIME_OF_DAY, whatTime)
end

function SetTimeOfDayScalePercentBJ(scalePercent)
SetTimeOfDayScale(scalePercent * 0.01)
end

function GetTimeOfDayScalePercentBJ()
return GetTimeOfDayScale() * 100
end

function PlaySound(soundName)
local soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")

StartSound(soundHandle)
KillSoundWhenDone(soundHandle)
end

function CompareLocationsBJ(A, B)
return (GetLocationX(A) == GetLocationX(B) and GetLocationY(A) == GetLocationY(B))
end

function CompareRectsBJ(A, B)
return (GetRectMinX(A) == GetRectMinX(B) and (GetRectMinY(A) == GetRectMinY(B) and (GetRectMaxX(A) == GetRectMaxX(B) and GetRectMaxY(A) == GetRectMaxY(B))))
end

function GetRectFromCircleBJ(center, radius)
local centerX = GetLocationX(center)
local centerY = GetLocationY(center)

return Rect(centerX - radius, centerY - radius, centerX + radius, centerY + radius)
end

function GetCurrentCameraSetup()
local theCam = CreateCameraSetup()
local duration = 0.0

CameraSetupSetField(theCam, CAMERA_FIELD_TARGET_DISTANCE, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_FARZ, GetCameraField(CAMERA_FIELD_FARZ), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_ZOFFSET, GetCameraField(CAMERA_FIELD_ZOFFSET), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_ANGLE_OF_ATTACK, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_FIELD_OF_VIEW, bj_RADTODEG * GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_ROLL, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROLL), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_ROTATION, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROTATION), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_PITCH, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_PITCH), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_YAW, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_YAW), duration)
CameraSetupSetField(theCam, CAMERA_FIELD_LOCAL_ROLL, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_ROLL), duration)
CameraSetupSetDestPosition(theCam, GetCameraTargetPositionX(), GetCameraTargetPositionY(), duration)
return theCam
end

function CameraSetupApplyForPlayer(doPan, whichSetup, whichPlayer, duration)
if (GetLocalPlayer() == whichPlayer) then
CameraSetupApplyForceDuration(whichSetup, doPan, duration)
end
end

function CameraSetupApplyForPlayerSmooth(doPan, whichSetup, whichPlayer, forcedDuration, easeInDuration, easeOutDuration, smoothFactor)
if (GetLocalPlayer() == whichPlayer) then
BlzCameraSetupApplyForceDurationSmooth(whichSetup, doPan, forcedDuration, easeInDuration, easeOutDuration, smoothFactor)
end
end

function CameraSetupGetFieldSwap(whichField, whichSetup)
return CameraSetupGetField(whichSetup, whichField)
end

function SetCameraFieldForPlayer(whichPlayer, whichField, value, duration)
if (GetLocalPlayer() == whichPlayer) then
SetCameraField(whichField, value, duration)
end
end

function SetCameraTargetControllerNoZForPlayer(whichPlayer, whichUnit, xoffset, yoffset, inheritOrientation)
if (GetLocalPlayer() == whichPlayer) then
SetCameraTargetController(whichUnit, xoffset, yoffset, inheritOrientation)
end
end

function SetCameraPositionForPlayer(whichPlayer, x, y)
if (GetLocalPlayer() == whichPlayer) then
SetCameraPosition(x, y)
end
end

function SetCameraPositionLocForPlayer(whichPlayer, loc)
if (GetLocalPlayer() == whichPlayer) then
SetCameraPosition(GetLocationX(loc), GetLocationY(loc))
end
end

function RotateCameraAroundLocBJ(degrees, loc, whichPlayer, duration)
if (GetLocalPlayer() == whichPlayer) then
SetCameraRotateMode(GetLocationX(loc), GetLocationY(loc), bj_DEGTORAD * degrees, duration)
end
end

function PanCameraToForPlayer(whichPlayer, x, y)
if (GetLocalPlayer() == whichPlayer) then
PanCameraTo(x, y)
end
end

function PanCameraToLocForPlayer(whichPlayer, loc)
if (GetLocalPlayer() == whichPlayer) then
PanCameraTo(GetLocationX(loc), GetLocationY(loc))
end
end

function PanCameraToTimedForPlayer(whichPlayer, x, y, duration)
if (GetLocalPlayer() == whichPlayer) then
PanCameraToTimed(x, y, duration)
end
end

function PanCameraToTimedLocForPlayer(whichPlayer, loc, duration)
if (GetLocalPlayer() == whichPlayer) then
PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
end
end

function PanCameraToTimedLocWithZForPlayer(whichPlayer, loc, zOffset, duration)
if (GetLocalPlayer() == whichPlayer) then
PanCameraToTimedWithZ(GetLocationX(loc), GetLocationY(loc), zOffset, duration)
end
end

function SmartCameraPanBJ(whichPlayer, loc, duration)
local dist
local cameraLoc = GetCameraTargetPositionLoc()

if (GetLocalPlayer() == whichPlayer) then
dist = DistanceBetweenPoints(loc, cameraLoc)
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
else
end
end
RemoveLocation(cameraLoc)
end

function SetCinematicCameraForPlayer(whichPlayer, cameraModelFile)
if (GetLocalPlayer() == whichPlayer) then
SetCinematicCamera(cameraModelFile)
end
end

function ResetToGameCameraForPlayer(whichPlayer, duration)
if (GetLocalPlayer() == whichPlayer) then
ResetToGameCamera(duration)
end
end

function CameraSetSourceNoiseForPlayer(whichPlayer, magnitude, velocity)
if (GetLocalPlayer() == whichPlayer) then
CameraSetSourceNoise(magnitude, velocity)
end
end

function CameraSetTargetNoiseForPlayer(whichPlayer, magnitude, velocity)
if (GetLocalPlayer() == whichPlayer) then
CameraSetTargetNoise(magnitude, velocity)
end
end

function CameraSetEQNoiseForPlayer(whichPlayer, magnitude)
local richter = magnitude

if (richter > 5.0) then
richter = 5.0
end
if (richter < 2.0) then
richter = 2.0
end
if (GetLocalPlayer() == whichPlayer) then
CameraSetTargetNoiseEx(magnitude * 2.0, magnitude * Pow(10, richter), true)
CameraSetSourceNoiseEx(magnitude * 2.0, magnitude * Pow(10, richter), true)
end
end

function CameraClearNoiseForPlayer(whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
CameraSetSourceNoise(0, 0)
CameraSetTargetNoise(0, 0)
end
end

function GetCurrentCameraBoundsMapRectBJ()
return Rect(GetCameraBoundMinX(), GetCameraBoundMinY(), GetCameraBoundMaxX(), GetCameraBoundMaxY())
end

function GetCameraBoundsMapRect()
return bj_mapInitialCameraBounds
end

function GetPlayableMapRect()
return bj_mapInitialPlayableArea
end

function GetEntireMapRect()
return GetWorldBounds()
end

function SetCameraBoundsToRect(r)
local minX = GetRectMinX(r)
local minY = GetRectMinY(r)
local maxX = GetRectMaxX(r)
local maxY = GetRectMaxY(r)

SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY)
end

function SetCameraBoundsToRectForPlayerBJ(whichPlayer, r)
if (GetLocalPlayer() == whichPlayer) then
SetCameraBoundsToRect(r)
end
end

function AdjustCameraBoundsBJ(adjustMethod, dxWest, dxEast, dyNorth, dySouth)
local minX = 0.0
local minY = 0.0
local maxX = 0.0
local maxY = 0.0
local scale = 0.0

if (adjustMethod == bj_CAMERABOUNDS_ADJUST_ADD) then
scale = 1.0
elseif (adjustMethod == bj_CAMERABOUNDS_ADJUST_SUB) then
scale = -1
else
return
end
minX = GetCameraBoundMinX() - scale * dxWest
maxX = GetCameraBoundMaxX() + scale * dxEast
minY = GetCameraBoundMinY() - scale * dySouth
maxY = GetCameraBoundMaxY() + scale * dyNorth
if (maxX < minX) then
minX = (minX + maxX) * 0.5
maxX = minX
end
if (maxY < minY) then
minY = (minY + maxY) * 0.5
maxY = minY
end
SetCameraBounds(minX, minY, minX, maxY, maxX, maxY, maxX, minY)
end

function AdjustCameraBoundsForPlayerBJ(adjustMethod, whichPlayer, dxWest, dxEast, dyNorth, dySouth)
if (GetLocalPlayer() == whichPlayer) then
AdjustCameraBoundsBJ(adjustMethod, dxWest, dxEast, dyNorth, dySouth)
end
end

function SetCameraQuickPositionForPlayer(whichPlayer, x, y)
if (GetLocalPlayer() == whichPlayer) then
SetCameraQuickPosition(x, y)
end
end

function SetCameraQuickPositionLocForPlayer(whichPlayer, loc)
if (GetLocalPlayer() == whichPlayer) then
SetCameraQuickPosition(GetLocationX(loc), GetLocationY(loc))
end
end

function SetCameraQuickPositionLoc(loc)
SetCameraQuickPosition(GetLocationX(loc), GetLocationY(loc))
end

function StopCameraForPlayerBJ(whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
StopCamera()
end
end

function SetCameraOrientControllerForPlayerBJ(whichPlayer, whichUnit, xoffset, yoffset)
if (GetLocalPlayer() == whichPlayer) then
SetCameraOrientController(whichUnit, xoffset, yoffset)
end
end

function CameraSetSmoothingFactorBJ(factor)
CameraSetSmoothingFactor(factor)
end

function CameraResetSmoothingFactorBJ()
CameraSetSmoothingFactor(0)
end

function DisplayTextToForce(toForce, message)
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
DisplayTextToPlayer(GetLocalPlayer(), 0, 0, message)
end
end

function DisplayTimedTextToForce(toForce, duration, message)
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, duration, message)
end
end

function ClearTextMessagesBJ(toForce)
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
ClearTextMessages()
end
end

function SubStringBJ(source, start, end_)
return SubString(source, start - 1, end_)
end

function GetHandleIdBJ(h)
return GetHandleId(h)
end

function StringHashBJ(s)
return StringHash(s)
end

function TriggerRegisterTimerEventPeriodic(trig, timeout)
return TriggerRegisterTimerEvent(trig, timeout, true)
end

function TriggerRegisterTimerEventSingle(trig, timeout)
return TriggerRegisterTimerEvent(trig, timeout, false)
end

function TriggerRegisterTimerExpireEventBJ(trig, t)
return TriggerRegisterTimerExpireEvent(trig, t)
end

function TriggerRegisterPlayerUnitEventSimple(trig, whichPlayer, whichEvent)
return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, whichEvent, nil)
end

function TriggerRegisterAnyUnitEventBJ(trig, whichEvent)
local index

index = 0
while (true) do
TriggerRegisterPlayerUnitEvent(trig, Player(index), whichEvent, nil)
index = index + 1
if (index == bj_MAX_PLAYER_SLOTS) then break end
end
end

function TriggerRegisterPlayerSelectionEventBJ(trig, whichPlayer, selected)
if selected then
return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, EVENT_PLAYER_UNIT_SELECTED, nil)
else
return TriggerRegisterPlayerUnitEvent(trig, whichPlayer, EVENT_PLAYER_UNIT_DESELECTED, nil)
end
end

function TriggerRegisterPlayerKeyEventBJ(trig, whichPlayer, keType, keKey)
if (keType == bj_KEYEVENTTYPE_DEPRESS) then
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
return nil
end
elseif (keType == bj_KEYEVENTTYPE_RELEASE) then
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
return nil
end
else
return nil
end
end

function TriggerRegisterPlayerMouseEventBJ(trig, whichPlayer, meType)
if (meType == bj_MOUSEEVENTTYPE_DOWN) then
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_DOWN)
elseif (meType == bj_MOUSEEVENTTYPE_UP) then
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_UP)
elseif (meType == bj_MOUSEEVENTTYPE_MOVE) then
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_MOUSE_MOVE)
else
return nil
end
end

function TriggerRegisterPlayerEventVictory(trig, whichPlayer)
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_VICTORY)
end

function TriggerRegisterPlayerEventDefeat(trig, whichPlayer)
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_DEFEAT)
end

function TriggerRegisterPlayerEventLeave(trig, whichPlayer)
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_LEAVE)
end

function TriggerRegisterPlayerEventAllianceChanged(trig, whichPlayer)
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ALLIANCE_CHANGED)
end

function TriggerRegisterPlayerEventEndCinematic(trig, whichPlayer)
return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_END_CINEMATIC)
end

function TriggerRegisterGameStateEventTimeOfDay(trig, opcode, limitval)
return TriggerRegisterGameStateEvent(trig, GAME_STATE_TIME_OF_DAY, opcode, limitval)
end

function TriggerRegisterEnterRegionSimple(trig, whichRegion)
return TriggerRegisterEnterRegion(trig, whichRegion, nil)
end

function TriggerRegisterLeaveRegionSimple(trig, whichRegion)
return TriggerRegisterLeaveRegion(trig, whichRegion, nil)
end

function TriggerRegisterEnterRectSimple(trig, r)
local rectRegion = CreateRegion()

RegionAddRect(rectRegion, r)
return TriggerRegisterEnterRegion(trig, rectRegion, nil)
end

function TriggerRegisterLeaveRectSimple(trig, r)
local rectRegion = CreateRegion()

RegionAddRect(rectRegion, r)
return TriggerRegisterLeaveRegion(trig, rectRegion, nil)
end

function TriggerRegisterDistanceBetweenUnits(trig, whichUnit, condition, range)
return TriggerRegisterUnitInRange(trig, whichUnit, range, condition)
end

function TriggerRegisterUnitInRangeSimple(trig, range, whichUnit)
return TriggerRegisterUnitInRange(trig, whichUnit, range, nil)
end

function TriggerRegisterUnitLifeEvent(trig, whichUnit, opcode, limitval)
return TriggerRegisterUnitStateEvent(trig, whichUnit, UNIT_STATE_LIFE, opcode, limitval)
end

function TriggerRegisterUnitManaEvent(trig, whichUnit, opcode, limitval)
return TriggerRegisterUnitStateEvent(trig, whichUnit, UNIT_STATE_MANA, opcode, limitval)
end

function TriggerRegisterDialogEventBJ(trig, whichDialog)
return TriggerRegisterDialogEvent(trig, whichDialog)
end

function TriggerRegisterShowSkillEventBJ(trig)
return TriggerRegisterGameEvent(trig, EVENT_GAME_SHOW_SKILL)
end

function TriggerRegisterBuildSubmenuEventBJ(trig)
return TriggerRegisterGameEvent(trig, EVENT_GAME_BUILD_SUBMENU)
end

function TriggerRegisterBuildCommandEventBJ(trig, unitId)
TriggerRegisterCommandEvent(trig, FourCC("ANbu"), UnitId2String(unitId))
TriggerRegisterCommandEvent(trig, FourCC("AHbu"), UnitId2String(unitId))
TriggerRegisterCommandEvent(trig, FourCC("AEbu"), UnitId2String(unitId))
TriggerRegisterCommandEvent(trig, FourCC("AObu"), UnitId2String(unitId))
TriggerRegisterCommandEvent(trig, FourCC("AUbu"), UnitId2String(unitId))
return TriggerRegisterCommandEvent(trig, FourCC("AGbu"), UnitId2String(unitId))
end

function TriggerRegisterTrainCommandEventBJ(trig, unitId)
return TriggerRegisterCommandEvent(trig, FourCC("Aque"), UnitId2String(unitId))
end

function TriggerRegisterUpgradeCommandEventBJ(trig, techId)
return TriggerRegisterUpgradeCommandEvent(trig, techId)
end

function TriggerRegisterCommonCommandEventBJ(trig, order)
return TriggerRegisterCommandEvent(trig, 0, order)
end

function TriggerRegisterGameLoadedEventBJ(trig)
return TriggerRegisterGameEvent(trig, EVENT_GAME_LOADED)
end

function TriggerRegisterGameSavedEventBJ(trig)
return TriggerRegisterGameEvent(trig, EVENT_GAME_SAVE)
end

function RegisterDestDeathInRegionEnum()
bj_destInRegionDiesCount = bj_destInRegionDiesCount + 1
if (bj_destInRegionDiesCount <= bj_MAX_DEST_IN_REGION_EVENTS) then
TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
end
end

function TriggerRegisterDestDeathInRegionEvent(trig, r)
bj_destInRegionDiesTrig = trig
bj_destInRegionDiesCount = 0
EnumDestructablesInRect(r, nil, RegisterDestDeathInRegionEnum)
end

function AddWeatherEffectSaveLast(where, effectID)
bj_lastCreatedWeatherEffect = AddWeatherEffect(where, effectID)
return bj_lastCreatedWeatherEffect
end

function GetLastCreatedWeatherEffect()
return bj_lastCreatedWeatherEffect
end

function RemoveWeatherEffectBJ(whichWeatherEffect)
RemoveWeatherEffect(whichWeatherEffect)
end

function TerrainDeformationCraterBJ(duration, permanent, where, radius, depth)
bj_lastCreatedTerrainDeformation = TerrainDeformCrater(GetLocationX(where), GetLocationY(where), radius, depth, R2I(duration * 1000), permanent)
return bj_lastCreatedTerrainDeformation
end

function TerrainDeformationRippleBJ(duration, limitNeg, where, startRadius, endRadius, depth, wavePeriod, waveWidth)
local spaceWave
local timeWave
local radiusRatio

if (endRadius <= 0 or (waveWidth <= 0 or wavePeriod <= 0)) then
return nil
end
timeWave = 2.0 * duration / wavePeriod
spaceWave = 2.0 * endRadius / waveWidth
radiusRatio = startRadius / endRadius
bj_lastCreatedTerrainDeformation = TerrainDeformRipple(GetLocationX(where), GetLocationY(where), endRadius, depth, R2I(duration * 1000), 1, spaceWave, timeWave, radiusRatio, limitNeg)
return bj_lastCreatedTerrainDeformation
end

function TerrainDeformationWaveBJ(duration, source, target, radius, depth, trailDelay)
local distance
local dirX
local dirY
local speed

distance = DistanceBetweenPoints(source, target)
if (distance == 0 or duration <= 0) then
return nil
end
dirX = (GetLocationX(target) - GetLocationX(source)) / distance
dirY = (GetLocationY(target) - GetLocationY(source)) / distance
speed = distance / duration
bj_lastCreatedTerrainDeformation = TerrainDeformWave(GetLocationX(source), GetLocationY(source), dirX, dirY, distance, speed, radius, depth, R2I(trailDelay * 1000), 1)
return bj_lastCreatedTerrainDeformation
end

function TerrainDeformationRandomBJ(duration, where, radius, minDelta, maxDelta, updateInterval)
bj_lastCreatedTerrainDeformation = TerrainDeformRandom(GetLocationX(where), GetLocationY(where), radius, minDelta, maxDelta, R2I(duration * 1000), R2I(updateInterval * 1000))
return bj_lastCreatedTerrainDeformation
end

function TerrainDeformationStopBJ(deformation, duration)
TerrainDeformStop(deformation, R2I(duration * 1000))
end

function GetLastCreatedTerrainDeformation()
return bj_lastCreatedTerrainDeformation
end

function AddLightningLoc(codeName, where1, where2)
bj_lastCreatedLightning = AddLightningEx(codeName, true, GetLocationX(where1), GetLocationY(where1), GetLocationZ(where1), GetLocationX(where2), GetLocationY(where2), GetLocationZ(where2))
return bj_lastCreatedLightning
end

function DestroyLightningBJ(whichBolt)
return DestroyLightning(whichBolt)
end

function MoveLightningLoc(whichBolt, where1, where2)
return MoveLightningEx(whichBolt, true, GetLocationX(where1), GetLocationY(where1), GetLocationZ(where1), GetLocationX(where2), GetLocationY(where2), GetLocationZ(where2))
end

function GetLightningColorABJ(whichBolt)
return GetLightningColorA(whichBolt)
end

function GetLightningColorRBJ(whichBolt)
return GetLightningColorR(whichBolt)
end

function GetLightningColorGBJ(whichBolt)
return GetLightningColorG(whichBolt)
end

function GetLightningColorBBJ(whichBolt)
return GetLightningColorB(whichBolt)
end

function SetLightningColorBJ(whichBolt, r, g, b, a)
return SetLightningColor(whichBolt, r, g, b, a)
end

function GetLastCreatedLightningBJ()
return bj_lastCreatedLightning
end

function GetAbilityEffectBJ(abilcode, t, index)
return GetAbilityEffectById(abilcode, t, index)
end

function GetAbilitySoundBJ(abilcode, t)
return GetAbilitySoundById(abilcode, t)
end

function GetTerrainCliffLevelBJ(where)
return GetTerrainCliffLevel(GetLocationX(where), GetLocationY(where))
end

function GetTerrainTypeBJ(where)
return GetTerrainType(GetLocationX(where), GetLocationY(where))
end

function GetTerrainVarianceBJ(where)
return GetTerrainVariance(GetLocationX(where), GetLocationY(where))
end

function SetTerrainTypeBJ(where, terrainType, variation, area, shape)
SetTerrainType(GetLocationX(where), GetLocationY(where), terrainType, variation, area, shape)
end

function IsTerrainPathableBJ(where, t)
return IsTerrainPathable(GetLocationX(where), GetLocationY(where), t)
end

function SetTerrainPathableBJ(where, t, flag)
SetTerrainPathable(GetLocationX(where), GetLocationY(where), t, flag)
end

function SetWaterBaseColorBJ(red, green, blue, transparency)
SetWaterBaseColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function CreateFogModifierRectSimple(whichPlayer, whichFogState, r, afterUnits)
bj_lastCreatedFogModifier = CreateFogModifierRect(whichPlayer, whichFogState, r, true, afterUnits)
return bj_lastCreatedFogModifier
end

function CreateFogModifierRadiusLocSimple(whichPlayer, whichFogState, center, radius, afterUnits)
bj_lastCreatedFogModifier = CreateFogModifierRadiusLoc(whichPlayer, whichFogState, center, radius, true, afterUnits)
return bj_lastCreatedFogModifier
end

function CreateFogModifierRectBJ(enabled, whichPlayer, whichFogState, r)
bj_lastCreatedFogModifier = CreateFogModifierRect(whichPlayer, whichFogState, r, true, false)
if enabled then
FogModifierStart(bj_lastCreatedFogModifier)
end
return bj_lastCreatedFogModifier
end

function CreateFogModifierRadiusLocBJ(enabled, whichPlayer, whichFogState, center, radius)
bj_lastCreatedFogModifier = CreateFogModifierRadiusLoc(whichPlayer, whichFogState, center, radius, true, false)
if enabled then
FogModifierStart(bj_lastCreatedFogModifier)
end
return bj_lastCreatedFogModifier
end

function GetLastCreatedFogModifier()
return bj_lastCreatedFogModifier
end

function FogEnableOn()
FogEnable(true)
end

function FogEnableOff()
FogEnable(false)
end

function FogMaskEnableOn()
FogMaskEnable(true)
end

function FogMaskEnableOff()
FogMaskEnable(false)
end

function UseTimeOfDayBJ(flag)
SuspendTimeOfDay(not flag)
end

function SetTerrainFogExBJ(style, zstart, zend, density, red, green, blue)
SetTerrainFogEx(style, zstart, zend, density, red * 0.01, green * 0.01, blue * 0.01)
end

function ResetTerrainFogBJ()
ResetTerrainFog()
end

function SetDoodadAnimationBJ(animName, doodadID, radius, center)
SetDoodadAnimation(GetLocationX(center), GetLocationY(center), radius, doodadID, false, animName, false)
end

function SetDoodadAnimationRectBJ(animName, doodadID, r)
SetDoodadAnimationRect(r, doodadID, animName, false)
end

function AddUnitAnimationPropertiesBJ(add, animProperties, whichUnit)
AddUnitAnimationProperties(whichUnit, animProperties, add)
end

function CreateImageBJ(file, size, where, zOffset, imageType)
bj_lastCreatedImage = CreateImage(file, size, size, size, GetLocationX(where), GetLocationY(where), zOffset, 0, 0, 0, imageType)
return bj_lastCreatedImage
end

function ShowImageBJ(flag, whichImage)
ShowImage(whichImage, flag)
end

function SetImagePositionBJ(whichImage, where, zOffset)
SetImagePosition(whichImage, GetLocationX(where), GetLocationY(where), zOffset)
end

function SetImageColorBJ(whichImage, red, green, blue, alpha)
SetImageColor(whichImage, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - alpha))
end

function GetLastCreatedImage()
return bj_lastCreatedImage
end

function CreateUbersplatBJ(where, name, red, green, blue, alpha, forcePaused, noBirthTime)
bj_lastCreatedUbersplat = CreateUbersplat(GetLocationX(where), GetLocationY(where), name, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - alpha), forcePaused, noBirthTime)
return bj_lastCreatedUbersplat
end

function ShowUbersplatBJ(flag, whichSplat)
ShowUbersplat(whichSplat, flag)
end

function GetLastCreatedUbersplat()
return bj_lastCreatedUbersplat
end

function GetLastCreatedMinimapIcon()
return bj_lastCreatedMinimapIcon
end

function CreateMinimapIconOnUnitBJ(whichUnit, red, green, blue, pingPath, fogVisibility)
bj_lastCreatedMinimapIcon = CreateMinimapIconOnUnit(whichUnit, red, green, blue, pingPath, fogVisibility)
return bj_lastCreatedMinimapIcon
end

function CreateMinimapIconAtLocBJ(where, red, green, blue, pingPath, fogVisibility)
bj_lastCreatedMinimapIcon = CreateMinimapIconAtLoc(where, red, green, blue, pingPath, fogVisibility)
return bj_lastCreatedMinimapIcon
end

function CreateMinimapIconBJ(x, y, red, green, blue, pingPath, fogVisibility)
bj_lastCreatedMinimapIcon = CreateMinimapIcon(x, y, red, green, blue, pingPath, fogVisibility)
return bj_lastCreatedMinimapIcon
end

function CampaignMinimapIconUnitBJ(whichUnit, style)
local red
local green
local blue
local path

if (style == bj_CAMPPINGSTYLE_PRIMARY) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_PRIMARY_GREEN) then
red = 0
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_PRIMARY_RED) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_BONUS) then
red = 255
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectiveBonus")
elseif (style == bj_CAMPPINGSTYLE_TURNIN) then
red = 255
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestTurnIn")
elseif (style == bj_CAMPPINGSTYLE_BOSS) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestBoss")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_ALLY) then
red = 0
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_NEUTRAL) then
red = 255
green = 255
blue = 255
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_ENEMY) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
end
CreateMinimapIconOnUnitBJ(whichUnit, red, green, blue, path, FOG_OF_WAR_MASKED)
SetMinimapIconOrphanDestroy(bj_lastCreatedMinimapIcon, true)
end

function CampaignMinimapIconLocBJ(where, style)
local red
local green
local blue
local path

if (style == bj_CAMPPINGSTYLE_PRIMARY) then
red = 0
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_PRIMARY_GREEN) then
red = 0
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_PRIMARY_RED) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectivePrimary")
elseif (style == bj_CAMPPINGSTYLE_BONUS) then
red = 255
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestObjectiveBonus")
elseif (style == bj_CAMPPINGSTYLE_TURNIN) then
red = 255
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestTurnIn")
elseif (style == bj_CAMPPINGSTYLE_BOSS) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestBoss")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_ALLY) then
red = 0
green = 255
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_NEUTRAL) then
red = 255
green = 255
blue = 255
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
elseif (style == bj_CAMPPINGSTYLE_CONTROL_ENEMY) then
red = 255
green = 0
blue = 0
path = SkinManagerGetLocalPath("MinimapQuestControlPoint")
end
CreateMinimapIconAtLocBJ(where, red, green, blue, path, FOG_OF_WAR_MASKED)
end

function PlaySoundBJ(soundHandle)
bj_lastPlayedSound = soundHandle
if (soundHandle ~= nil) then
StartSound(soundHandle)
end
end

function StopSoundBJ(soundHandle, fadeOut)
StopSound(soundHandle, false, fadeOut)
end

function SetSoundVolumeBJ(soundHandle, volumePercent)
SetSoundVolume(soundHandle, PercentToInt(volumePercent, 127))
end

function SetSoundOffsetBJ(newOffset, soundHandle)
SetSoundPlayPosition(soundHandle, R2I(newOffset * 1000))
end

function SetSoundDistanceCutoffBJ(soundHandle, cutoff)
SetSoundDistanceCutoff(soundHandle, cutoff)
end

function SetSoundPitchBJ(soundHandle, pitch)
SetSoundPitch(soundHandle, pitch)
end

function SetSoundPositionLocBJ(soundHandle, loc, z)
SetSoundPosition(soundHandle, GetLocationX(loc), GetLocationY(loc), z)
end

function AttachSoundToUnitBJ(soundHandle, whichUnit)
AttachSoundToUnit(soundHandle, whichUnit)
end

function SetSoundConeAnglesBJ(soundHandle, inside, outside, outsideVolumePercent)
SetSoundConeAngles(soundHandle, inside, outside, PercentToInt(outsideVolumePercent, 127))
end

function KillSoundWhenDoneBJ(soundHandle)
KillSoundWhenDone(soundHandle)
end

function PlaySoundAtPointBJ(soundHandle, volumePercent, loc, z)
SetSoundPositionLocBJ(soundHandle, loc, z)
SetSoundVolumeBJ(soundHandle, volumePercent)
PlaySoundBJ(soundHandle)
end

function PlaySoundOnUnitBJ(soundHandle, volumePercent, whichUnit)
AttachSoundToUnitBJ(soundHandle, whichUnit)
SetSoundVolumeBJ(soundHandle, volumePercent)
PlaySoundBJ(soundHandle)
end

function PlaySoundFromOffsetBJ(soundHandle, volumePercent, startingOffset)
SetSoundVolumeBJ(soundHandle, volumePercent)
PlaySoundBJ(soundHandle)
SetSoundOffsetBJ(startingOffset, soundHandle)
end

function PlayMusicBJ(musicFileName)
bj_lastPlayedMusic = musicFileName
PlayMusic(musicFileName)
end

function PlayMusicExBJ(musicFileName, startingOffset, fadeInTime)
bj_lastPlayedMusic = musicFileName
PlayMusicEx(musicFileName, R2I(startingOffset * 1000), R2I(fadeInTime * 1000))
end

function SetMusicOffsetBJ(newOffset)
SetMusicPlayPosition(R2I(newOffset * 1000))
end

function PlayThematicMusicBJ(musicName)
PlayThematicMusic(musicName)
end

function PlayThematicMusicExBJ(musicName, startingOffset)
PlayThematicMusicEx(musicName, R2I(startingOffset * 1000))
end

function SetThematicMusicOffsetBJ(newOffset)
SetThematicMusicPlayPosition(R2I(newOffset * 1000))
end

function EndThematicMusicBJ()
EndThematicMusic()
end

function StopMusicBJ(fadeOut)
StopMusic(fadeOut)
end

function ResumeMusicBJ()
ResumeMusic()
end

function SetMusicVolumeBJ(volumePercent)
SetMusicVolume(PercentToInt(volumePercent, 127))
end

function SetThematicMusicVolumeBJ(volumePercent)
SetThematicMusicVolume(PercentToInt(volumePercent, 127))
end

function GetSoundDurationBJ(soundHandle)
if (soundHandle == nil) then
return bj_NOTHING_SOUND_DURATION
else
return I2R(GetSoundDuration(soundHandle)) * 0.001
end
end

function GetSoundFileDurationBJ(musicFileName)
return I2R(GetSoundFileDuration(musicFileName)) * 0.001
end

function GetLastPlayedSound()
return bj_lastPlayedSound
end

function GetLastPlayedMusic()
return bj_lastPlayedMusic
end

function VolumeGroupSetVolumeBJ(vgroup, percent)
VolumeGroupSetVolume(vgroup, percent * 0.01)
end

function SetCineModeVolumeGroupsImmediateBJ()
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITMOVEMENT, bj_CINEMODE_VOLUME_UNITMOVEMENT)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITSOUNDS, bj_CINEMODE_VOLUME_UNITSOUNDS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_COMBAT, bj_CINEMODE_VOLUME_COMBAT)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_SPELLS, bj_CINEMODE_VOLUME_SPELLS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UI, bj_CINEMODE_VOLUME_UI)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_MUSIC, bj_CINEMODE_VOLUME_MUSIC)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_AMBIENTSOUNDS, bj_CINEMODE_VOLUME_AMBIENTSOUNDS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_FIRE, bj_CINEMODE_VOLUME_FIRE)
end

function SetCineModeVolumeGroupsBJ()
if bj_gameStarted then
SetCineModeVolumeGroupsImmediateBJ()
else
TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, SetCineModeVolumeGroupsImmediateBJ)
end
end

function SetSpeechVolumeGroupsImmediateBJ()
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITMOVEMENT, bj_SPEECH_VOLUME_UNITMOVEMENT)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UNITSOUNDS, bj_SPEECH_VOLUME_UNITSOUNDS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_COMBAT, bj_SPEECH_VOLUME_COMBAT)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_SPELLS, bj_SPEECH_VOLUME_SPELLS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_UI, bj_SPEECH_VOLUME_UI)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_MUSIC, bj_SPEECH_VOLUME_MUSIC)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_AMBIENTSOUNDS, bj_SPEECH_VOLUME_AMBIENTSOUNDS)
VolumeGroupSetVolume(SOUND_VOLUMEGROUP_FIRE, bj_SPEECH_VOLUME_FIRE)
end

function SetSpeechVolumeGroupsBJ()
if bj_gameStarted then
SetSpeechVolumeGroupsImmediateBJ()
else
TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, SetSpeechVolumeGroupsImmediateBJ)
end
end

function VolumeGroupResetImmediateBJ()
VolumeGroupReset()
end

function VolumeGroupResetBJ()
if bj_gameStarted then
VolumeGroupResetImmediateBJ()
else
TimerStart(bj_volumeGroupsTimer, bj_GAME_STARTED_THRESHOLD, false, VolumeGroupResetImmediateBJ)
end
end

function GetSoundIsPlayingBJ(soundHandle)
return (GetSoundIsLoading(soundHandle) or GetSoundIsPlaying(soundHandle))
end

function WaitForSoundBJ(soundHandle, offset)
TriggerWaitForSound(soundHandle, offset)
end

function SetMapMusicIndexedBJ(musicName, index)
SetMapMusic(musicName, false, index)
end

function SetMapMusicRandomBJ(musicName)
SetMapMusic(musicName, true, 0)
end

function ClearMapMusicBJ()
ClearMapMusic()
end

function SetStackedSoundBJ(add, soundHandle, r)
local width = GetRectMaxX(r) - GetRectMinX(r)
local height = GetRectMaxY(r) - GetRectMinY(r)

SetSoundPosition(soundHandle, GetRectCenterX(r), GetRectCenterY(r), 0)
if add then
RegisterStackedSound(soundHandle, true, width, height)
else
UnregisterStackedSound(soundHandle, true, width, height)
end
end

function StartSoundForPlayerBJ(whichPlayer, soundHandle)
if (whichPlayer == GetLocalPlayer()) then
StartSound(soundHandle)
end
end

function VolumeGroupSetVolumeForPlayerBJ(whichPlayer, vgroup, scale)
if (GetLocalPlayer() == whichPlayer) then
VolumeGroupSetVolume(vgroup, scale)
end
end

function EnableDawnDusk(flag)
bj_useDawnDuskSounds = flag
end

function IsDawnDuskEnabled()
return bj_useDawnDuskSounds
end

function SetAmbientDaySound(inLabel)
local ToD

if (bj_dayAmbientSound ~= nil) then
StopSound(bj_dayAmbientSound, true, true)
end
bj_dayAmbientSound = CreateMIDISound(inLabel, 20, 20)
ToD = GetTimeOfDay()
if (ToD >= bj_TOD_DAWN and ToD < bj_TOD_DUSK) then
StartSound(bj_dayAmbientSound)
end
end

function SetAmbientNightSound(inLabel)
local ToD

if (bj_nightAmbientSound ~= nil) then
StopSound(bj_nightAmbientSound, true, true)
end
bj_nightAmbientSound = CreateMIDISound(inLabel, 20, 20)
ToD = GetTimeOfDay()
if (ToD < bj_TOD_DAWN or ToD >= bj_TOD_DUSK) then
StartSound(bj_nightAmbientSound)
end
end

function AddSpecialEffectLocBJ(where, modelName)
bj_lastCreatedEffect = AddSpecialEffectLoc(modelName, where)
return bj_lastCreatedEffect
end

function AddSpecialEffectTargetUnitBJ(attachPointName, targetWidget, modelName)
bj_lastCreatedEffect = AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
return bj_lastCreatedEffect
end

function DestroyEffectBJ(whichEffect)
DestroyEffect(whichEffect)
end

function GetLastCreatedEffectBJ()
return bj_lastCreatedEffect
end

function CreateCommandButtonEffectBJ(abilityId, order)
bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(abilityId, order)
return bj_lastCreatedCommandButtonEffect
end

function CreateTrainCommandButtonEffectBJ(unitId)
bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(FourCC("Aque"), UnitId2String(unitId))
return bj_lastCreatedCommandButtonEffect
end

function CreateUpgradeCommandButtonEffectBJ(techId)
bj_lastCreatedCommandButtonEffect = CreateUpgradeCommandButtonEffect(techId)
return bj_lastCreatedCommandButtonEffect
end

function CreateCommonCommandButtonEffectBJ(order)
bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(0, order)
return bj_lastCreatedCommandButtonEffect
end

function CreateLearnCommandButtonEffectBJ(abilityId)
bj_lastCreatedCommandButtonEffect = CreateLearnCommandButtonEffect(abilityId)
return bj_lastCreatedCommandButtonEffect
end

function CreateBuildCommandButtonEffectBJ(unitId)
local r = GetPlayerRace(GetLocalPlayer())
local abilityId

if (r == RACE_HUMAN) then
abilityId = FourCC("AHbu")
elseif (r == RACE_ORC) then
abilityId = FourCC("AObu")
elseif (r == RACE_UNDEAD) then
abilityId = FourCC("AUbu")
elseif (r == RACE_NIGHTELF) then
abilityId = FourCC("AEbu")
else
abilityId = FourCC("ANbu")
end
bj_lastCreatedCommandButtonEffect = CreateCommandButtonEffect(abilityId, UnitId2String(unitId))
return bj_lastCreatedCommandButtonEffect
end

function GetLastCreatedCommandButtonEffectBJ()
return bj_lastCreatedCommandButtonEffect
end

function GetItemLoc(whichItem)
return Location(GetItemX(whichItem), GetItemY(whichItem))
end

function GetItemLifeBJ(whichWidget)
return GetWidgetLife(whichWidget)
end

function SetItemLifeBJ(whichWidget, life)
SetWidgetLife(whichWidget, life)
end

function AddHeroXPSwapped(xpToAdd, whichHero, showEyeCandy)
AddHeroXP(whichHero, xpToAdd, showEyeCandy)
end

function SetHeroLevelBJ(whichHero, newLevel, showEyeCandy)
local oldLevel = GetHeroLevel(whichHero)

if (newLevel > oldLevel) then
SetHeroLevel(whichHero, newLevel, showEyeCandy)
elseif (newLevel < oldLevel) then
UnitStripHeroLevel(whichHero, oldLevel - newLevel)
else
end
end

function DecUnitAbilityLevelSwapped(abilcode, whichUnit)
return DecUnitAbilityLevel(whichUnit, abilcode)
end

function IncUnitAbilityLevelSwapped(abilcode, whichUnit)
return IncUnitAbilityLevel(whichUnit, abilcode)
end

function SetUnitAbilityLevelSwapped(abilcode, whichUnit, level)
return SetUnitAbilityLevel(whichUnit, abilcode, level)
end

function GetUnitAbilityLevelSwapped(abilcode, whichUnit)
return GetUnitAbilityLevel(whichUnit, abilcode)
end

function UnitHasBuffBJ(whichUnit, buffcode)
return (GetUnitAbilityLevel(whichUnit, buffcode) > 0)
end

function UnitRemoveBuffBJ(buffcode, whichUnit)
return UnitRemoveAbility(whichUnit, buffcode)
end

function UnitAddItemSwapped(whichItem, whichHero)
return UnitAddItem(whichHero, whichItem)
end

function UnitAddItemByIdSwapped(itemId, whichHero)
bj_lastCreatedItem = CreateItem(itemId, GetUnitX(whichHero), GetUnitY(whichHero))
UnitAddItem(whichHero, bj_lastCreatedItem)
return bj_lastCreatedItem
end

function UnitRemoveItemSwapped(whichItem, whichHero)
bj_lastRemovedItem = whichItem
UnitRemoveItem(whichHero, whichItem)
end

function UnitRemoveItemFromSlotSwapped(itemSlot, whichHero)
bj_lastRemovedItem = UnitRemoveItemFromSlot(whichHero, itemSlot - 1)
return bj_lastRemovedItem
end

function CreateItemLoc(itemId, loc)
bj_lastCreatedItem = CreateItem(itemId, GetLocationX(loc), GetLocationY(loc))
return bj_lastCreatedItem
end

function GetLastCreatedItem()
return bj_lastCreatedItem
end

function GetLastRemovedItem()
return bj_lastRemovedItem
end

function SetItemPositionLoc(whichItem, loc)
SetItemPosition(whichItem, GetLocationX(loc), GetLocationY(loc))
end

function GetLearnedSkillBJ()
return GetLearnedSkill()
end

function SuspendHeroXPBJ(flag, whichHero)
SuspendHeroXP(whichHero, not flag)
end

function SetPlayerHandicapDamageBJ(whichPlayer, handicapPercent)
SetPlayerHandicapDamage(whichPlayer, handicapPercent * 0.01)
end

function GetPlayerHandicapDamageBJ(whichPlayer)
return GetPlayerHandicapDamage(whichPlayer) * 100
end

function SetPlayerHandicapReviveTimeBJ(whichPlayer, handicapPercent)
SetPlayerHandicapReviveTime(whichPlayer, handicapPercent * 0.01)
end

function GetPlayerHandicapReviveTimeBJ(whichPlayer)
return GetPlayerHandicapReviveTime(whichPlayer) * 100
end

function SetPlayerHandicapXPBJ(whichPlayer, handicapPercent)
SetPlayerHandicapXP(whichPlayer, handicapPercent * 0.01)
end

function GetPlayerHandicapXPBJ(whichPlayer)
return GetPlayerHandicapXP(whichPlayer) * 100
end

function SetPlayerHandicapBJ(whichPlayer, handicapPercent)
SetPlayerHandicap(whichPlayer, handicapPercent * 0.01)
end

function GetPlayerHandicapBJ(whichPlayer)
return GetPlayerHandicap(whichPlayer) * 100
end

function GetHeroStatBJ(whichStat, whichHero, includeBonuses)
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
return 0
end
end

function SetHeroStat(whichHero, whichStat, value)
if (value <= 0) then
return
end
if (whichStat == bj_HEROSTAT_STR) then
SetHeroStr(whichHero, value, true)
elseif (whichStat == bj_HEROSTAT_AGI) then
SetHeroAgi(whichHero, value, true)
elseif (whichStat == bj_HEROSTAT_INT) then
SetHeroInt(whichHero, value, true)
else
end
end

function ModifyHeroStat(whichStat, whichHero, modifyMethod, value)
if (modifyMethod == bj_MODIFYMETHOD_ADD) then
SetHeroStat(whichHero, whichStat, GetHeroStatBJ(whichStat, whichHero, false) + value)
elseif (modifyMethod == bj_MODIFYMETHOD_SUB) then
SetHeroStat(whichHero, whichStat, GetHeroStatBJ(whichStat, whichHero, false) - value)
elseif (modifyMethod == bj_MODIFYMETHOD_SET) then
SetHeroStat(whichHero, whichStat, value)
else
end
end

function ModifyHeroSkillPoints(whichHero, modifyMethod, value)
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
return false
end
end

function UnitDropItemPointBJ(whichUnit, whichItem, x, y)
return UnitDropItemPoint(whichUnit, whichItem, x, y)
end

function UnitDropItemPointLoc(whichUnit, whichItem, loc)
return UnitDropItemPoint(whichUnit, whichItem, GetLocationX(loc), GetLocationY(loc))
end

function UnitDropItemSlotBJ(whichUnit, whichItem, slot)
return UnitDropItemSlot(whichUnit, whichItem, slot - 1)
end

function UnitDropItemTargetBJ(whichUnit, whichItem, target)
return UnitDropItemTarget(whichUnit, whichItem, target)
end

function UnitUseItemDestructable(whichUnit, whichItem, target)
return UnitUseItemTarget(whichUnit, whichItem, target)
end

function UnitUseItemPointLoc(whichUnit, whichItem, loc)
return UnitUseItemPoint(whichUnit, whichItem, GetLocationX(loc), GetLocationY(loc))
end

function UnitItemInSlotBJ(whichUnit, itemSlot)
return UnitItemInSlot(whichUnit, itemSlot - 1)
end

function GetInventoryIndexOfItemTypeBJ(whichUnit, itemId)
local index
local indexItem

index = 0
while (true) do
indexItem = UnitItemInSlot(whichUnit, index)
if ((indexItem ~= nil) and (GetItemTypeId(indexItem) == itemId)) then
return index + 1
end
index = index + 1
if (index >= bj_MAX_INVENTORY) then break end
end
return 0
end

function GetItemOfTypeFromUnitBJ(whichUnit, itemId)
local index = GetInventoryIndexOfItemTypeBJ(whichUnit, itemId)

if (index == 0) then
return nil
else
return UnitItemInSlot(whichUnit, index - 1)
end
end

function UnitHasItemOfTypeBJ(whichUnit, itemId)
return GetInventoryIndexOfItemTypeBJ(whichUnit, itemId) > 0
end

function UnitInventoryCount(whichUnit)
local index = 0
local count = 0

while (true) do
if (UnitItemInSlot(whichUnit, index) ~= nil) then
count = count + 1
end
index = index + 1
if (index >= bj_MAX_INVENTORY) then break end
end
return count
end

function UnitInventorySizeBJ(whichUnit)
return UnitInventorySize(whichUnit)
end

function SetItemInvulnerableBJ(whichItem, flag)
SetItemInvulnerable(whichItem, flag)
end

function SetItemDropOnDeathBJ(whichItem, flag)
SetItemDropOnDeath(whichItem, flag)
end

function SetItemDroppableBJ(whichItem, flag)
SetItemDroppable(whichItem, flag)
end

function SetItemPlayerBJ(whichItem, whichPlayer, changeColor)
SetItemPlayer(whichItem, whichPlayer, changeColor)
end

function SetItemVisibleBJ(show, whichItem)
SetItemVisible(whichItem, show)
end

function IsItemHiddenBJ(whichItem)
return not IsItemVisible(whichItem)
end

function ChooseRandomItemBJ(level)
return ChooseRandomItem(level)
end

function ChooseRandomItemExBJ(level, whichType)
return ChooseRandomItemEx(whichType, level)
end

function ChooseRandomNPBuildingBJ()
return ChooseRandomNPBuilding()
end

function ChooseRandomCreepBJ(level)
return ChooseRandomCreep(level)
end

function EnumItemsInRectBJ(r, actionFunc)
EnumItemsInRect(r, nil, actionFunc)
end

function RandomItemInRectBJEnum()
bj_itemRandomConsidered = bj_itemRandomConsidered + 1
if (GetRandomInt(1, bj_itemRandomConsidered) == 1) then
bj_itemRandomCurrentPick = GetEnumItem()
end
end

function RandomItemInRectBJ(r, filter)
bj_itemRandomConsidered = 0
bj_itemRandomCurrentPick = nil
EnumItemsInRect(r, filter, RandomItemInRectBJEnum)
DestroyBoolExpr(filter)
return bj_itemRandomCurrentPick
end

function RandomItemInRectSimpleBJ(r)
return RandomItemInRectBJ(r, nil)
end

function CheckItemStatus(whichItem, status)
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
return false
end
end

function CheckItemcodeStatus(itemId, status)
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
return false
end
end

function UnitId2OrderIdBJ(unitId)
return unitId
end

function String2UnitIdBJ(unitIdString)
return UnitId(unitIdString)
end

function UnitId2StringBJ(unitId)
local unitString = UnitId2String(unitId)

if (unitString ~= "") then
return unitString
end
return ""
end

function String2OrderIdBJ(orderIdString)
local orderId

orderId = OrderId(orderIdString)
if (orderId ~= 0) then
return orderId
end
orderId = UnitId(orderIdString)
if (orderId ~= 0) then
return orderId
end
return 0
end

function OrderId2StringBJ(orderId)
local orderString

orderString = OrderId2String(orderId)
if (orderString ~= "") then
return orderString
end
orderString = UnitId2String(orderId)
if (orderString ~= "") then
return orderString
end
return ""
end

function GetIssuedOrderIdBJ()
return GetIssuedOrderId()
end

function GetKillingUnitBJ()
return GetKillingUnit()
end

function CreateUnitAtLocSaveLast(id, unitid, loc, face)
if (unitid == FourCC("ugol")) then
bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)
else
bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)
end
return bj_lastCreatedUnit
end

function GetLastCreatedUnit()
return bj_lastCreatedUnit
end

function CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, face)
GroupClear(bj_lastCreatedGroup)
while (true) do
count = count - 1
if (count < 0) then break end
CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
end
return bj_lastCreatedGroup
end

function CreateNUnitsAtLocFacingLocBJ(count, unitId, whichPlayer, loc, lookAt)
return CreateNUnitsAtLoc(count, unitId, whichPlayer, loc, AngleBetweenPoints(loc, lookAt))
end

function GetLastCreatedGroupEnum()
GroupAddUnit(bj_groupLastCreatedDest, GetEnumUnit())
end

function GetLastCreatedGroup()
bj_groupLastCreatedDest = CreateGroup()
ForGroup(bj_lastCreatedGroup, GetLastCreatedGroupEnum)
return bj_groupLastCreatedDest
end

function CreateCorpseLocBJ(unitid, whichPlayer, loc)
bj_lastCreatedUnit = CreateCorpse(whichPlayer, unitid, GetLocationX(loc), GetLocationY(loc), GetRandomReal(0, 360))
return bj_lastCreatedUnit
end

function UnitSuspendDecayBJ(suspend, whichUnit)
UnitSuspendDecay(whichUnit, suspend)
end

function DelayedSuspendDecayStopAnimEnum()
local enumUnit = GetEnumUnit()

if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then
SetUnitTimeScale(enumUnit, 0.0001)
end
end

function DelayedSuspendDecayBoneEnum()
local enumUnit = GetEnumUnit()

if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then
UnitSuspendDecay(enumUnit, true)
SetUnitTimeScale(enumUnit, 0.0001)
end
end

function DelayedSuspendDecayFleshEnum()
local enumUnit = GetEnumUnit()

if (GetUnitState(enumUnit, UNIT_STATE_LIFE) <= 0) then
UnitSuspendDecay(enumUnit, true)
SetUnitTimeScale(enumUnit, 10.0)
SetUnitAnimation(enumUnit, "decay flesh")
end
end

function DelayedSuspendDecay()
local boneGroup
local fleshGroup

boneGroup = bj_suspendDecayBoneGroup
fleshGroup = bj_suspendDecayFleshGroup
bj_suspendDecayBoneGroup = CreateGroup()
bj_suspendDecayFleshGroup = CreateGroup()
ForGroup(fleshGroup, DelayedSuspendDecayStopAnimEnum)
ForGroup(boneGroup, DelayedSuspendDecayStopAnimEnum)
TriggerSleepAction(bj_CORPSE_MAX_DEATH_TIME)
ForGroup(fleshGroup, DelayedSuspendDecayFleshEnum)
ForGroup(boneGroup, DelayedSuspendDecayBoneEnum)
TriggerSleepAction(0.05)
ForGroup(fleshGroup, DelayedSuspendDecayStopAnimEnum)
DestroyGroup(boneGroup)
DestroyGroup(fleshGroup)
end

function DelayedSuspendDecayCreate()
bj_delayedSuspendDecayTrig = CreateTrigger()
TriggerRegisterTimerExpireEvent(bj_delayedSuspendDecayTrig, bj_delayedSuspendDecayTimer)
TriggerAddAction(bj_delayedSuspendDecayTrig, DelayedSuspendDecay)
end

function CreatePermanentCorpseLocBJ(style, unitid, whichPlayer, loc, facing)
bj_lastCreatedUnit = CreateCorpse(whichPlayer, unitid, GetLocationX(loc), GetLocationY(loc), facing)
SetUnitBlendTime(bj_lastCreatedUnit, 0)
if (style == bj_CORPSETYPE_FLESH) then
SetUnitAnimation(bj_lastCreatedUnit, "decay flesh")
GroupAddUnit(bj_suspendDecayFleshGroup, bj_lastCreatedUnit)
elseif (style == bj_CORPSETYPE_BONE) then
SetUnitAnimation(bj_lastCreatedUnit, "decay bone")
GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit)
else
SetUnitAnimation(bj_lastCreatedUnit, "decay bone")
GroupAddUnit(bj_suspendDecayBoneGroup, bj_lastCreatedUnit)
end
TimerStart(bj_delayedSuspendDecayTimer, 0.05, false, nil)
return bj_lastCreatedUnit
end

function GetUnitStateSwap(whichState, whichUnit)
return GetUnitState(whichUnit, whichState)
end

function GetUnitStatePercent(whichUnit, whichState, whichMaxState)
local value = GetUnitState(whichUnit, whichState)
local maxValue = GetUnitState(whichUnit, whichMaxState)

if ((whichUnit == nil) or (maxValue == 0)) then
return 0.0
end
return value / maxValue * 100.0
end

function GetUnitLifePercent(whichUnit)
return GetUnitStatePercent(whichUnit, UNIT_STATE_LIFE, UNIT_STATE_MAX_LIFE)
end

function GetUnitManaPercent(whichUnit)
return GetUnitStatePercent(whichUnit, UNIT_STATE_MANA, UNIT_STATE_MAX_MANA)
end

function SelectUnitSingle(whichUnit)
ClearSelection()
SelectUnit(whichUnit, true)
end

function SelectGroupBJEnum()
SelectUnit(GetEnumUnit(), true)
end

function SelectGroupBJ(g)
ClearSelection()
ForGroup(g, SelectGroupBJEnum)
end

function SelectUnitAdd(whichUnit)
SelectUnit(whichUnit, true)
end

function SelectUnitRemove(whichUnit)
SelectUnit(whichUnit, false)
end

function ClearSelectionForPlayer(whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
ClearSelection()
end
end

function SelectUnitForPlayerSingle(whichUnit, whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
ClearSelection()
SelectUnit(whichUnit, true)
end
end

function SelectGroupForPlayerBJ(g, whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
ClearSelection()
ForGroup(g, SelectGroupBJEnum)
end
end

function SelectUnitAddForPlayer(whichUnit, whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
SelectUnit(whichUnit, true)
end
end

function SelectUnitRemoveForPlayer(whichUnit, whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
SelectUnit(whichUnit, false)
end
end

function SetUnitLifeBJ(whichUnit, newValue)
SetUnitState(whichUnit, UNIT_STATE_LIFE, RMaxBJ(0, newValue))
end

function SetUnitManaBJ(whichUnit, newValue)
SetUnitState(whichUnit, UNIT_STATE_MANA, RMaxBJ(0, newValue))
end

function SetUnitLifePercentBJ(whichUnit, percent)
SetUnitState(whichUnit, UNIT_STATE_LIFE, GetUnitState(whichUnit, UNIT_STATE_MAX_LIFE) * RMaxBJ(0, percent) * 0.01)
end

function SetUnitManaPercentBJ(whichUnit, percent)
SetUnitState(whichUnit, UNIT_STATE_MANA, GetUnitState(whichUnit, UNIT_STATE_MAX_MANA) * RMaxBJ(0, percent) * 0.01)
end

function IsUnitDeadBJ(whichUnit)
return GetUnitState(whichUnit, UNIT_STATE_LIFE) <= 0
end

function IsUnitAliveBJ(whichUnit)
return not IsUnitDeadBJ(whichUnit)
end

function IsUnitGroupDeadBJEnum()
if not IsUnitDeadBJ(GetEnumUnit()) then
bj_isUnitGroupDeadResult = false
end
end

function IsUnitGroupDeadBJ(g)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_isUnitGroupDeadResult = true
ForGroup(g, IsUnitGroupDeadBJEnum)
if (wantDestroy) then
DestroyGroup(g)
end
return bj_isUnitGroupDeadResult
end

function IsUnitGroupEmptyBJEnum()
bj_isUnitGroupEmptyResult = false
end

function IsUnitGroupEmptyBJ(g)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_isUnitGroupEmptyResult = true
ForGroup(g, IsUnitGroupEmptyBJEnum)
if (wantDestroy) then
DestroyGroup(g)
end
return bj_isUnitGroupEmptyResult
end

function IsUnitGroupInRectBJEnum()
if not RectContainsUnit(bj_isUnitGroupInRectRect, GetEnumUnit()) then
bj_isUnitGroupInRectResult = false
end
end

function IsUnitGroupInRectBJ(g, r)
bj_isUnitGroupInRectResult = true
bj_isUnitGroupInRectRect = r
ForGroup(g, IsUnitGroupInRectBJEnum)
return bj_isUnitGroupInRectResult
end

function IsUnitHiddenBJ(whichUnit)
return IsUnitHidden(whichUnit)
end

function ShowUnitHide(whichUnit)
ShowUnit(whichUnit, false)
end

function ShowUnitShow(whichUnit)
if (IsUnitType(whichUnit, UNIT_TYPE_HERO) and IsUnitDeadBJ(whichUnit)) then
return
end
ShowUnit(whichUnit, true)
end

function IssueHauntOrderAtLocBJFilter()
return GetUnitTypeId(GetFilterUnit()) == FourCC("ngol")
end

function IssueHauntOrderAtLocBJ(whichPeon, loc)
local g = nil
local goldMine = nil

g = CreateGroup()
GroupEnumUnitsInRangeOfLoc(g, loc, 2 * bj_CELLWIDTH, filterIssueHauntOrderAtLocBJ)
goldMine = FirstOfGroup(g)
DestroyGroup(g)
if (goldMine == nil) then
return false
end
return IssueTargetOrderById(whichPeon, FourCC("ugol"), goldMine)
end

function IssueBuildOrderByIdLocBJ(whichPeon, unitId, loc)
if (unitId == FourCC("ugol")) then
return IssueHauntOrderAtLocBJ(whichPeon, loc)
else
return IssueBuildOrderById(whichPeon, unitId, GetLocationX(loc), GetLocationY(loc))
end
end

function IssueTrainOrderByIdBJ(whichUnit, unitId)
return IssueImmediateOrderById(whichUnit, unitId)
end

function GroupTrainOrderByIdBJ(g, unitId)
return GroupImmediateOrderById(g, unitId)
end

function IssueUpgradeOrderByIdBJ(whichUnit, techId)
return IssueImmediateOrderById(whichUnit, techId)
end

function GetAttackedUnitBJ()
return GetTriggerUnit()
end

function SetUnitFlyHeightBJ(whichUnit, newHeight, rate)
SetUnitFlyHeight(whichUnit, newHeight, rate)
end

function SetUnitTurnSpeedBJ(whichUnit, turnSpeed)
SetUnitTurnSpeed(whichUnit, turnSpeed)
end

function SetUnitPropWindowBJ(whichUnit, propWindow)
local angle = propWindow

if (angle <= 0) then
angle = 1.0
elseif (angle >= 360) then
angle = 359.0
end
angle = angle * bj_DEGTORAD
SetUnitPropWindow(whichUnit, angle)
end

function GetUnitPropWindowBJ(whichUnit)
return GetUnitPropWindow(whichUnit) * bj_RADTODEG
end

function GetUnitDefaultPropWindowBJ(whichUnit)
return GetUnitDefaultPropWindow(whichUnit)
end

function SetUnitBlendTimeBJ(whichUnit, blendTime)
SetUnitBlendTime(whichUnit, blendTime)
end

function SetUnitAcquireRangeBJ(whichUnit, acquireRange)
SetUnitAcquireRange(whichUnit, acquireRange)
end

function UnitSetCanSleepBJ(whichUnit, canSleep)
UnitAddSleep(whichUnit, canSleep)
end

function UnitCanSleepBJ(whichUnit)
return UnitCanSleep(whichUnit)
end

function UnitWakeUpBJ(whichUnit)
UnitWakeUp(whichUnit)
end

function UnitIsSleepingBJ(whichUnit)
return UnitIsSleeping(whichUnit)
end

function WakePlayerUnitsEnum()
UnitWakeUp(GetEnumUnit())
end

function WakePlayerUnits(whichPlayer)
local g = CreateGroup()

GroupEnumUnitsOfPlayer(g, whichPlayer, nil)
ForGroup(g, WakePlayerUnitsEnum)
DestroyGroup(g)
end

function EnableCreepSleepBJ(enable)
SetPlayerState(Player(PLAYER_NEUTRAL_AGGRESSIVE), PLAYER_STATE_NO_CREEP_SLEEP, IntegerTertiaryOp(enable, 0, 1))
if (not enable) then
WakePlayerUnits(Player(PLAYER_NEUTRAL_AGGRESSIVE))
end
end

function UnitGenerateAlarms(whichUnit, generate)
return UnitIgnoreAlarm(whichUnit, not generate)
end

function DoesUnitGenerateAlarms(whichUnit)
return not UnitIgnoreAlarmToggled(whichUnit)
end

function PauseAllUnitsBJEnum()
PauseUnit(GetEnumUnit(), bj_pauseAllUnitsFlag)
end

function PauseAllUnitsBJ(pause)
local index
local indexPlayer
local g

bj_pauseAllUnitsFlag = pause
g = CreateGroup()
index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
PauseCompAI(indexPlayer, pause)
end
GroupEnumUnitsOfPlayer(g, indexPlayer, nil)
ForGroup(g, PauseAllUnitsBJEnum)
GroupClear(g)
index = index + 1
if (index == bj_MAX_PLAYER_SLOTS) then break end
end
DestroyGroup(g)
end

function PauseUnitBJ(pause, whichUnit)
PauseUnit(whichUnit, pause)
end

function IsUnitPausedBJ(whichUnit)
return IsUnitPaused(whichUnit)
end

function UnitPauseTimedLifeBJ(flag, whichUnit)
UnitPauseTimedLife(whichUnit, flag)
end

function UnitApplyTimedLifeBJ(duration, buffId, whichUnit)
UnitApplyTimedLife(whichUnit, buffId, duration)
end

function UnitShareVisionBJ(share, whichUnit, whichPlayer)
UnitShareVision(whichUnit, whichPlayer, share)
end

function UnitRemoveBuffsBJ(buffType, whichUnit)
if (buffType == bj_REMOVEBUFFS_POSITIVE) then
UnitRemoveBuffs(whichUnit, true, false)
elseif (buffType == bj_REMOVEBUFFS_NEGATIVE) then
UnitRemoveBuffs(whichUnit, false, true)
elseif (buffType == bj_REMOVEBUFFS_ALL) then
UnitRemoveBuffs(whichUnit, true, true)
elseif (buffType == bj_REMOVEBUFFS_NONTLIFE) then
UnitRemoveBuffsEx(whichUnit, true, true, false, false, false, true, false)
else
end
end

function UnitRemoveBuffsExBJ(polarity, resist, whichUnit, bTLife, bAura)
local bPos = ((polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_POSITIVE))
local bNeg = ((polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_NEGATIVE))
local bMagic = ((resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_MAGIC))
local bPhys = ((resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_PHYSICAL))

UnitRemoveBuffsEx(whichUnit, bPos, bNeg, bMagic, bPhys, bTLife, bAura, false)
end

function UnitCountBuffsExBJ(polarity, resist, whichUnit, bTLife, bAura)
local bPos = ((polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_POSITIVE))
local bNeg = ((polarity == bj_BUFF_POLARITY_EITHER) or (polarity == bj_BUFF_POLARITY_NEGATIVE))
local bMagic = ((resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_MAGIC))
local bPhys = ((resist == bj_BUFF_RESIST_BOTH) or (resist == bj_BUFF_RESIST_PHYSICAL))

return UnitCountBuffsEx(whichUnit, bPos, bNeg, bMagic, bPhys, bTLife, bAura, false)
end

function UnitRemoveAbilityBJ(abilityId, whichUnit)
return UnitRemoveAbility(whichUnit, abilityId)
end

function UnitAddAbilityBJ(abilityId, whichUnit)
return UnitAddAbility(whichUnit, abilityId)
end

function UnitRemoveTypeBJ(whichType, whichUnit)
return UnitRemoveType(whichUnit, whichType)
end

function UnitAddTypeBJ(whichType, whichUnit)
return UnitAddType(whichUnit, whichType)
end

function UnitMakeAbilityPermanentBJ(permanent, abilityId, whichUnit)
return UnitMakeAbilityPermanent(whichUnit, permanent, abilityId)
end

function SetUnitExplodedBJ(whichUnit, exploded)
SetUnitExploded(whichUnit, exploded)
end

function ExplodeUnitBJ(whichUnit)
SetUnitExploded(whichUnit, true)
KillUnit(whichUnit)
end

function GetTransportUnitBJ()
return GetTransportUnit()
end

function GetLoadedUnitBJ()
return GetLoadedUnit()
end

function IsUnitInTransportBJ(whichUnit, whichTransport)
return IsUnitInTransport(whichUnit, whichTransport)
end

function IsUnitLoadedBJ(whichUnit)
return IsUnitLoaded(whichUnit)
end

function IsUnitIllusionBJ(whichUnit)
return IsUnitIllusion(whichUnit)
end

function ReplaceUnitBJ(whichUnit, newUnitId, unitStateMethod)
local oldUnit = whichUnit
local newUnit
local wasHidden
local index
local indexItem
local oldRatio

if (oldUnit == nil) then
bj_lastReplacedUnit = oldUnit
return oldUnit
end
wasHidden = IsUnitHidden(oldUnit)
ShowUnit(oldUnit, false)
if (newUnitId == FourCC("ugol")) then
newUnit = CreateBlightedGoldmine(GetOwningPlayer(oldUnit), GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit))
else
newUnit = CreateUnit(GetOwningPlayer(oldUnit), newUnitId, GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit))
end
if (unitStateMethod == bj_UNIT_STATE_METHOD_RELATIVE) then
if (GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE) > 0) then
oldRatio = GetUnitState(oldUnit, UNIT_STATE_LIFE) / GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE)
SetUnitState(newUnit, UNIT_STATE_LIFE, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_LIFE))
end
if ((GetUnitState(oldUnit, UNIT_STATE_MAX_MANA) > 0) and (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) > 0)) then
oldRatio = GetUnitState(oldUnit, UNIT_STATE_MANA) / GetUnitState(oldUnit, UNIT_STATE_MAX_MANA)
SetUnitState(newUnit, UNIT_STATE_MANA, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_MANA))
end
elseif (unitStateMethod == bj_UNIT_STATE_METHOD_ABSOLUTE) then
SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(oldUnit, UNIT_STATE_LIFE))
if (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) > 0) then
SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(oldUnit, UNIT_STATE_MANA))
end
elseif (unitStateMethod == bj_UNIT_STATE_METHOD_DEFAULTS) then
elseif (unitStateMethod == bj_UNIT_STATE_METHOD_MAXIMUM) then
SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(newUnit, UNIT_STATE_MAX_LIFE))
SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(newUnit, UNIT_STATE_MAX_MANA))
else
end
SetResourceAmount(newUnit, GetResourceAmount(oldUnit))
if (IsUnitType(oldUnit, UNIT_TYPE_HERO) and IsUnitType(newUnit, UNIT_TYPE_HERO)) then
SetHeroXP(newUnit, GetHeroXP(oldUnit), false)
index = 0
while (true) do
indexItem = UnitItemInSlot(oldUnit, index)
if (indexItem ~= nil) then
UnitRemoveItem(oldUnit, indexItem)
UnitAddItem(newUnit, indexItem)
end
index = index + 1
if (index >= bj_MAX_INVENTORY) then break end
end
end
if wasHidden then
KillUnit(oldUnit)
RemoveUnit(oldUnit)
else
RemoveUnit(oldUnit)
end
bj_lastReplacedUnit = newUnit
return newUnit
end

function GetLastReplacedUnitBJ()
return bj_lastReplacedUnit
end

function SetUnitPositionLocFacingBJ(whichUnit, loc, facing)
SetUnitPositionLoc(whichUnit, loc)
SetUnitFacing(whichUnit, facing)
end

function SetUnitPositionLocFacingLocBJ(whichUnit, loc, lookAt)
SetUnitPositionLoc(whichUnit, loc)
SetUnitFacing(whichUnit, AngleBetweenPoints(loc, lookAt))
end

function AddItemToStockBJ(itemId, whichUnit, currentStock, stockMax)
AddItemToStock(whichUnit, itemId, currentStock, stockMax)
end

function AddUnitToStockBJ(unitId, whichUnit, currentStock, stockMax)
AddUnitToStock(whichUnit, unitId, currentStock, stockMax)
end

function RemoveItemFromStockBJ(itemId, whichUnit)
RemoveItemFromStock(whichUnit, itemId)
end

function RemoveUnitFromStockBJ(unitId, whichUnit)
RemoveUnitFromStock(whichUnit, unitId)
end

function SetUnitUseFoodBJ(enable, whichUnit)
SetUnitUseFood(whichUnit, enable)
end

function UnitDamagePointLoc(whichUnit, delay, radius, loc, amount, whichAttack, whichDamage)
return UnitDamagePoint(whichUnit, delay, radius, GetLocationX(loc), GetLocationY(loc), amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS)
end

function UnitDamageTargetBJ(whichUnit, target, amount, whichAttack, whichDamage)
return UnitDamageTarget(whichUnit, target, amount, true, false, whichAttack, whichDamage, WEAPON_TYPE_WHOKNOWS)
end

function CreateDestructableLoc(objectid, loc, facing, scale, variation)
bj_lastCreatedDestructable = CreateDestructable(objectid, GetLocationX(loc), GetLocationY(loc), facing, scale, variation)
return bj_lastCreatedDestructable
end

function CreateDeadDestructableLocBJ(objectid, loc, facing, scale, variation)
bj_lastCreatedDestructable = CreateDeadDestructable(objectid, GetLocationX(loc), GetLocationY(loc), facing, scale, variation)
return bj_lastCreatedDestructable
end

function GetLastCreatedDestructable()
return bj_lastCreatedDestructable
end

function ShowDestructableBJ(flag, d)
ShowDestructable(d, flag)
end

function SetDestructableInvulnerableBJ(d, flag)
SetDestructableInvulnerable(d, flag)
end

function IsDestructableInvulnerableBJ(d)
return IsDestructableInvulnerable(d)
end

function GetDestructableLoc(whichDestructable)
return Location(GetDestructableX(whichDestructable), GetDestructableY(whichDestructable))
end

function EnumDestructablesInRectAll(r, actionFunc)
EnumDestructablesInRect(r, nil, actionFunc)
end

function EnumDestructablesInCircleBJFilter()
local destLoc = GetDestructableLoc(GetFilterDestructable())
local result

result = DistanceBetweenPoints(destLoc, bj_enumDestructableCenter) <= bj_enumDestructableRadius
RemoveLocation(destLoc)
return result
end

function IsDestructableDeadBJ(d)
return GetDestructableLife(d) <= 0
end

function IsDestructableAliveBJ(d)
return not IsDestructableDeadBJ(d)
end

function RandomDestructableInRectBJEnum()
bj_destRandomConsidered = bj_destRandomConsidered + 1
if (GetRandomInt(1, bj_destRandomConsidered) == 1) then
bj_destRandomCurrentPick = GetEnumDestructable()
end
end

function RandomDestructableInRectBJ(r, filter)
bj_destRandomConsidered = 0
bj_destRandomCurrentPick = nil
EnumDestructablesInRect(r, filter, RandomDestructableInRectBJEnum)
DestroyBoolExpr(filter)
return bj_destRandomCurrentPick
end

function RandomDestructableInRectSimpleBJ(r)
return RandomDestructableInRectBJ(r, nil)
end

function EnumDestructablesInCircleBJ(radius, loc, actionFunc)
local r

if (radius >= 0) then
bj_enumDestructableCenter = loc
bj_enumDestructableRadius = radius
r = GetRectFromCircleBJ(loc, radius)
EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, actionFunc)
RemoveRect(r)
end
end

function SetDestructableLifePercentBJ(d, percent)
SetDestructableLife(d, GetDestructableMaxLife(d) * percent * 0.01)
end

function SetDestructableMaxLifeBJ(d, max)
SetDestructableMaxLife(d, max)
end

function ModifyGateBJ(gateOperation, d)
if (gateOperation == bj_GATEOPERATION_CLOSE) then
if (GetDestructableLife(d) <= 0) then
DestructableRestoreLife(d, GetDestructableMaxLife(d), true)
end
SetDestructableAnimation(d, "stand")
elseif (gateOperation == bj_GATEOPERATION_OPEN) then
if (GetDestructableLife(d) > 0) then
KillDestructable(d)
end
SetDestructableAnimation(d, "death alternate")
elseif (gateOperation == bj_GATEOPERATION_DESTROY) then
if (GetDestructableLife(d) > 0) then
KillDestructable(d)
end
SetDestructableAnimation(d, "death")
else
end
end

function GetElevatorHeight(d)
local height

height = 1 + R2I(GetDestructableOccluderHeight(d) / bj_CLIFFHEIGHT)
if ((height < 1) or (height > 3)) then
height = 1
end
return height
end

function ChangeElevatorHeight(d, newHeight)
local oldHeight

newHeight = IMaxBJ(1, newHeight)
newHeight = IMinBJ(3, newHeight)
oldHeight = GetElevatorHeight(d)
SetDestructableOccluderHeight(d, bj_CLIFFHEIGHT * (newHeight - 1))
if (newHeight == 1) then
if (oldHeight == 2) then
SetDestructableAnimation(d, "birth")
QueueDestructableAnimation(d, "stand")
elseif (oldHeight == 3) then
SetDestructableAnimation(d, "birth third")
QueueDestructableAnimation(d, "stand")
else
SetDestructableAnimation(d, "stand")
end
elseif (newHeight == 2) then
if (oldHeight == 1) then
SetDestructableAnimation(d, "death")
QueueDestructableAnimation(d, "stand second")
elseif (oldHeight == 3) then
SetDestructableAnimation(d, "birth second")
QueueDestructableAnimation(d, "stand second")
else
SetDestructableAnimation(d, "stand second")
end
elseif (newHeight == 3) then
if (oldHeight == 1) then
SetDestructableAnimation(d, "death third")
QueueDestructableAnimation(d, "stand third")
elseif (oldHeight == 2) then
SetDestructableAnimation(d, "death second")
QueueDestructableAnimation(d, "stand third")
else
SetDestructableAnimation(d, "stand third")
end
else
end
end

function NudgeUnitsInRectEnum()
local nudgee = GetEnumUnit()

SetUnitPosition(nudgee, GetUnitX(nudgee), GetUnitY(nudgee))
end

function NudgeItemsInRectEnum()
local nudgee = GetEnumItem()

SetItemPosition(nudgee, GetItemX(nudgee), GetItemY(nudgee))
end

function NudgeObjectsInRect(nudgeArea)
local g

g = CreateGroup()
GroupEnumUnitsInRect(g, nudgeArea, nil)
ForGroup(g, NudgeUnitsInRectEnum)
DestroyGroup(g)
EnumItemsInRect(nudgeArea, nil, NudgeItemsInRectEnum)
end

function NearbyElevatorExistsEnum()
local d = GetEnumDestructable()
local dType = GetDestructableTypeId(d)

if ((dType == bj_ELEVATOR_CODE01) or (dType == bj_ELEVATOR_CODE02)) then
bj_elevatorNeighbor = d
end
end

function NearbyElevatorExists(x, y)
local findThreshold = 32.0
local r

r = Rect(x - findThreshold, y - findThreshold, x + findThreshold, y + findThreshold)
bj_elevatorNeighbor = nil
EnumDestructablesInRect(r, nil, NearbyElevatorExistsEnum)
RemoveRect(r)
return bj_elevatorNeighbor ~= nil
end

function FindElevatorWallBlockerEnum()
bj_elevatorWallBlocker = GetEnumDestructable()
end

function ChangeElevatorWallBlocker(x, y, facing, open)
local blocker = nil
local findThreshold = 32.0
local nudgeLength = 4.25 * bj_CELLWIDTH
local nudgeWidth = 1.25 * bj_CELLWIDTH
local r

r = Rect(x - findThreshold, y - findThreshold, x + findThreshold, y + findThreshold)
bj_elevatorWallBlocker = nil
EnumDestructablesInRect(r, nil, FindElevatorWallBlockerEnum)
RemoveRect(r)
blocker = bj_elevatorWallBlocker
if (blocker == nil) then
blocker = CreateDeadDestructable(bj_ELEVATOR_BLOCKER_CODE, x, y, facing, 1, 0)
elseif (GetDestructableTypeId(blocker) ~= bj_ELEVATOR_BLOCKER_CODE) then
return
end
if (open) then
if (GetDestructableLife(blocker) > 0) then
KillDestructable(blocker)
end
else
if (GetDestructableLife(blocker) <= 0) then
DestructableRestoreLife(blocker, GetDestructableMaxLife(blocker), false)
end
if (facing == 0) then
r = Rect(x - nudgeWidth / 2, y - nudgeLength / 2, x + nudgeWidth / 2, y + nudgeLength / 2)
NudgeObjectsInRect(r)
RemoveRect(r)
elseif (facing == 90) then
r = Rect(x - nudgeLength / 2, y - nudgeWidth / 2, x + nudgeLength / 2, y + nudgeWidth / 2)
NudgeObjectsInRect(r)
RemoveRect(r)
else
end
end
end

function ChangeElevatorWalls(open, walls, d)
local x = GetDestructableX(d)
local y = GetDestructableY(d)
local distToBlocker = 192.0
local distToNeighbor = 256.0

if ((walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_EAST)) then
if (not NearbyElevatorExists(x + distToNeighbor, y)) then
ChangeElevatorWallBlocker(x + distToBlocker, y, 0, open)
end
end
if ((walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_NORTH)) then
if (not NearbyElevatorExists(x, y + distToNeighbor)) then
ChangeElevatorWallBlocker(x, y + distToBlocker, 90, open)
end
end
if ((walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_SOUTH)) then
if (not NearbyElevatorExists(x, y - distToNeighbor)) then
ChangeElevatorWallBlocker(x, y - distToBlocker, 90, open)
end
end
if ((walls == bj_ELEVATOR_WALL_TYPE_ALL) or (walls == bj_ELEVATOR_WALL_TYPE_WEST)) then
if (not NearbyElevatorExists(x - distToNeighbor, y)) then
ChangeElevatorWallBlocker(x - distToBlocker, y, 0, open)
end
end
end

function WaygateActivateBJ(activate, waygate)
WaygateActivate(waygate, activate)
end

function WaygateIsActiveBJ(waygate)
return WaygateIsActive(waygate)
end

function WaygateSetDestinationLocBJ(waygate, loc)
WaygateSetDestination(waygate, GetLocationX(loc), GetLocationY(loc))
end

function WaygateGetDestinationLocBJ(waygate)
return Location(WaygateGetDestinationX(waygate), WaygateGetDestinationY(waygate))
end

function UnitSetUsesAltIconBJ(flag, whichUnit)
UnitSetUsesAltIcon(whichUnit, flag)
end

function ForceUIKeyBJ(whichPlayer, key)
if (GetLocalPlayer() == whichPlayer) then
ForceUIKey(key)
end
end

function ForceUICancelBJ(whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
ForceUICancel()
end
end

function ForGroupBJ(whichGroup, callback)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
ForGroup(whichGroup, callback)
if (wantDestroy) then
DestroyGroup(whichGroup)
end
end

function GroupAddUnitSimple(whichUnit, whichGroup)
GroupAddUnit(whichGroup, whichUnit)
end

function GroupRemoveUnitSimple(whichUnit, whichGroup)
GroupRemoveUnit(whichGroup, whichUnit)
end

function GroupAddGroupEnum()
GroupAddUnit(bj_groupAddGroupDest, GetEnumUnit())
end

function GroupAddGroup(sourceGroup, destGroup)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_groupAddGroupDest = destGroup
ForGroup(sourceGroup, GroupAddGroupEnum)
if (wantDestroy) then
DestroyGroup(sourceGroup)
end
end

function GroupRemoveGroupEnum()
GroupRemoveUnit(bj_groupRemoveGroupDest, GetEnumUnit())
end

function GroupRemoveGroup(sourceGroup, destGroup)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_groupRemoveGroupDest = destGroup
ForGroup(sourceGroup, GroupRemoveGroupEnum)
if (wantDestroy) then
DestroyGroup(sourceGroup)
end
end

function ForceAddPlayerSimple(whichPlayer, whichForce)
ForceAddPlayer(whichForce, whichPlayer)
end

function ForceRemovePlayerSimple(whichPlayer, whichForce)
ForceRemovePlayer(whichForce, whichPlayer)
end

function GroupPickRandomUnitEnum()
bj_groupRandomConsidered = bj_groupRandomConsidered + 1
if (GetRandomInt(1, bj_groupRandomConsidered) == 1) then
bj_groupRandomCurrentPick = GetEnumUnit()
end
end

function GroupPickRandomUnit(whichGroup)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_groupRandomConsidered = 0
bj_groupRandomCurrentPick = nil
ForGroup(whichGroup, GroupPickRandomUnitEnum)
if (wantDestroy) then
DestroyGroup(whichGroup)
end
return bj_groupRandomCurrentPick
end

function ForcePickRandomPlayerEnum()
bj_forceRandomConsidered = bj_forceRandomConsidered + 1
if (GetRandomInt(1, bj_forceRandomConsidered) == 1) then
bj_forceRandomCurrentPick = GetEnumPlayer()
end
end

function ForcePickRandomPlayer(whichForce)
bj_forceRandomConsidered = 0
bj_forceRandomCurrentPick = nil
ForForce(whichForce, ForcePickRandomPlayerEnum)
return bj_forceRandomCurrentPick
end

function EnumUnitsSelected(whichPlayer, enumFilter, enumAction)
local g = CreateGroup()

SyncSelections()
GroupEnumUnitsSelected(g, whichPlayer, enumFilter)
DestroyBoolExpr(enumFilter)
ForGroup(g, enumAction)
DestroyGroup(g)
end

function GetUnitsInRectMatching(r, filter)
local g = CreateGroup()

GroupEnumUnitsInRect(g, r, filter)
DestroyBoolExpr(filter)
return g
end

function GetUnitsInRectAll(r)
return GetUnitsInRectMatching(r, nil)
end

function GetUnitsInRectOfPlayerFilter()
return GetOwningPlayer(GetFilterUnit()) == bj_groupEnumOwningPlayer
end

function GetUnitsInRectOfPlayer(r, whichPlayer)
local g = CreateGroup()

bj_groupEnumOwningPlayer = whichPlayer
GroupEnumUnitsInRect(g, r, filterGetUnitsInRectOfPlayer)
return g
end

function GetUnitsInRangeOfLocMatching(radius, whichLocation, filter)
local g = CreateGroup()

GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)
DestroyBoolExpr(filter)
return g
end

function GetUnitsInRangeOfLocAll(radius, whichLocation)
return GetUnitsInRangeOfLocMatching(radius, whichLocation, nil)
end

function GetUnitsOfTypeIdAllFilter()
return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId
end

function GetUnitsOfTypeIdAll(unitid)
local result = CreateGroup()
local g = CreateGroup()
local index

index = 0
while (true) do
bj_groupEnumTypeId = unitid
GroupClear(g)
GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll)
GroupAddGroup(g, result)
index = index + 1
if (index == bj_MAX_PLAYER_SLOTS) then break end
end
DestroyGroup(g)
return result
end

function GetUnitsOfPlayerMatching(whichPlayer, filter)
local g = CreateGroup()

GroupEnumUnitsOfPlayer(g, whichPlayer, filter)
DestroyBoolExpr(filter)
return g
end

function GetUnitsOfPlayerAll(whichPlayer)
return GetUnitsOfPlayerMatching(whichPlayer, nil)
end

function GetUnitsOfPlayerAndTypeIdFilter()
return GetUnitTypeId(GetFilterUnit()) == bj_groupEnumTypeId
end

function GetUnitsOfPlayerAndTypeId(whichPlayer, unitid)
local g = CreateGroup()

bj_groupEnumTypeId = unitid
GroupEnumUnitsOfPlayer(g, whichPlayer, filterGetUnitsOfPlayerAndTypeId)
return g
end

function GetUnitsSelectedAll(whichPlayer)
local g = CreateGroup()

SyncSelections()
GroupEnumUnitsSelected(g, whichPlayer, nil)
return g
end

function GetForceOfPlayer(whichPlayer)
local f = CreateForce()

ForceAddPlayer(f, whichPlayer)
return f
end

function GetPlayersAll()
return bj_FORCE_ALL_PLAYERS
end

function GetPlayersByMapControl(whichControl)
local f = CreateForce()
local playerIndex
local indexPlayer

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if GetPlayerController(indexPlayer) == whichControl then
ForceAddPlayer(f, indexPlayer)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYER_SLOTS) then break end
end
return f
end

function GetPlayersAllies(whichPlayer)
local f = CreateForce()

ForceEnumAllies(f, whichPlayer, nil)
return f
end

function GetPlayersEnemies(whichPlayer)
local f = CreateForce()

ForceEnumEnemies(f, whichPlayer, nil)
return f
end

function GetPlayersMatching(filter)
local f = CreateForce()

ForceEnumPlayers(f, filter)
DestroyBoolExpr(filter)
return f
end

function CountUnitsInGroupEnum()
bj_groupCountUnits = bj_groupCountUnits + 1
end

function CountUnitsInGroup(g)
local wantDestroy = bj_wantDestroyGroup

bj_wantDestroyGroup = false
bj_groupCountUnits = 0
ForGroup(g, CountUnitsInGroupEnum)
if (wantDestroy) then
DestroyGroup(g)
end
return bj_groupCountUnits
end

function CountPlayersInForceEnum()
bj_forceCountPlayers = bj_forceCountPlayers + 1
end

function CountPlayersInForceBJ(f)
bj_forceCountPlayers = 0
ForForce(f, CountPlayersInForceEnum)
return bj_forceCountPlayers
end

function GetRandomSubGroupEnum()
if (bj_randomSubGroupWant > 0) then
if ((bj_randomSubGroupWant >= bj_randomSubGroupTotal) or (GetRandomReal(0, 1) < bj_randomSubGroupChance)) then
GroupAddUnit(bj_randomSubGroupGroup, GetEnumUnit())
bj_randomSubGroupWant = bj_randomSubGroupWant - 1
end
end
bj_randomSubGroupTotal = bj_randomSubGroupTotal - 1
end

function GetRandomSubGroup(count, sourceGroup)
local g = CreateGroup()

bj_randomSubGroupGroup = g
bj_randomSubGroupWant = count
bj_randomSubGroupTotal = CountUnitsInGroup(sourceGroup)
if (bj_randomSubGroupWant <= 0 or bj_randomSubGroupTotal <= 0) then
return g
end
bj_randomSubGroupChance = I2R(bj_randomSubGroupWant) / I2R(bj_randomSubGroupTotal)
ForGroup(sourceGroup, GetRandomSubGroupEnum)
return g
end

function LivingPlayerUnitsOfTypeIdFilter()
local filterUnit = GetFilterUnit()

return (IsUnitAliveBJ(filterUnit) and GetUnitTypeId(filterUnit) == bj_livingPlayerUnitsTypeId)
end

function CountLivingPlayerUnitsOfTypeId(unitId, whichPlayer)
local g
local matchedCount

g = CreateGroup()
bj_livingPlayerUnitsTypeId = unitId
GroupEnumUnitsOfPlayer(g, whichPlayer, filterLivingPlayerUnitsOfTypeId)
matchedCount = CountUnitsInGroup(g)
DestroyGroup(g)
return matchedCount
end

function ResetUnitAnimation(whichUnit)
SetUnitAnimation(whichUnit, "stand")
end

function SetUnitTimeScalePercent(whichUnit, percentScale)
SetUnitTimeScale(whichUnit, percentScale * 0.01)
end

function SetUnitScalePercent(whichUnit, percentScaleX, percentScaleY, percentScaleZ)
SetUnitScale(whichUnit, percentScaleX * 0.01, percentScaleY * 0.01, percentScaleZ * 0.01)
end

function SetUnitVertexColorBJ(whichUnit, red, green, blue, transparency)
SetUnitVertexColor(whichUnit, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function UnitAddIndicatorBJ(whichUnit, red, green, blue, transparency)
AddIndicator(whichUnit, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function DestructableAddIndicatorBJ(whichDestructable, red, green, blue, transparency)
AddIndicator(whichDestructable, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function ItemAddIndicatorBJ(whichItem, red, green, blue, transparency)
AddIndicator(whichItem, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function SetUnitFacingToFaceLocTimed(whichUnit, target, duration)
local unitLoc = GetUnitLoc(whichUnit)

SetUnitFacingTimed(whichUnit, AngleBetweenPoints(unitLoc, target), duration)
RemoveLocation(unitLoc)
end

function SetUnitFacingToFaceUnitTimed(whichUnit, target, duration)
local unitLoc = GetUnitLoc(target)

SetUnitFacingToFaceLocTimed(whichUnit, unitLoc, duration)
RemoveLocation(unitLoc)
end

function QueueUnitAnimationBJ(whichUnit, whichAnimation)
QueueUnitAnimation(whichUnit, whichAnimation)
end

function SetDestructableAnimationBJ(d, whichAnimation)
SetDestructableAnimation(d, whichAnimation)
end

function QueueDestructableAnimationBJ(d, whichAnimation)
QueueDestructableAnimation(d, whichAnimation)
end

function SetDestAnimationSpeedPercent(d, percentScale)
SetDestructableAnimationSpeed(d, percentScale * 0.01)
end

function DialogDisplayBJ(flag, whichDialog, whichPlayer)
DialogDisplay(whichPlayer, whichDialog, flag)
end

function DialogSetMessageBJ(whichDialog, message)
DialogSetMessage(whichDialog, message)
end

function DialogAddButtonBJ(whichDialog, buttonText)
bj_lastCreatedButton = DialogAddButton(whichDialog, buttonText, 0)
return bj_lastCreatedButton
end

function DialogAddButtonWithHotkeyBJ(whichDialog, buttonText, hotkey)
bj_lastCreatedButton = DialogAddButton(whichDialog, buttonText, hotkey)
return bj_lastCreatedButton
end

function DialogClearBJ(whichDialog)
DialogClear(whichDialog)
end

function GetLastCreatedButtonBJ()
return bj_lastCreatedButton
end

function GetClickedButtonBJ()
return GetClickedButton()
end

function GetClickedDialogBJ()
return GetClickedDialog()
end

function SetPlayerAllianceBJ(sourcePlayer, whichAllianceSetting, value, otherPlayer)
if (sourcePlayer == otherPlayer) then
return
end
SetPlayerAlliance(sourcePlayer, otherPlayer, whichAllianceSetting, value)
end

function SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_REQUEST, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_HELP_RESPONSE, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_XP, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_SPELLS, flag)
end

function SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_VISION, flag)
end

function SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_CONTROL, flag)
end

function SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, flag)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, flag)
end

function SetPlayerAllianceStateBJ(sourcePlayer, otherPlayer, allianceState)
if (sourcePlayer == otherPlayer) then
return
end
if allianceState == bj_ALLIANCE_UNALLIED then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
elseif allianceState == bj_ALLIANCE_UNALLIED_VISION then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
elseif allianceState == bj_ALLIANCE_ALLIED then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
elseif allianceState == bj_ALLIANCE_ALLIED_VISION then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
elseif allianceState == bj_ALLIANCE_ALLIED_UNITS then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
elseif allianceState == bj_ALLIANCE_ALLIED_ADVUNITS then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, true)
elseif allianceState == bj_ALLIANCE_NEUTRAL then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, true)
elseif allianceState == bj_ALLIANCE_NEUTRAL_VISION then
SetPlayerAllianceStateAllyBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateVisionBJ(sourcePlayer, otherPlayer, true)
SetPlayerAllianceStateControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAllianceStateFullControlBJ(sourcePlayer, otherPlayer, false)
SetPlayerAlliance(sourcePlayer, otherPlayer, ALLIANCE_PASSIVE, true)
else
end
end

function SetForceAllianceStateBJ(sourceForce, targetForce, allianceState)
local sourceIndex
local targetIndex

sourceIndex = 0
while (true) do
if (sourceForce == bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(sourceIndex), sourceForce)) then
targetIndex = 0
while (true) do
if (targetForce == bj_FORCE_ALL_PLAYERS or IsPlayerInForce(Player(targetIndex), targetForce)) then
SetPlayerAllianceStateBJ(Player(sourceIndex), Player(targetIndex), allianceState)
end
targetIndex = targetIndex + 1
if (targetIndex == bj_MAX_PLAYER_SLOTS) then break end
end
end
sourceIndex = sourceIndex + 1
if (sourceIndex == bj_MAX_PLAYER_SLOTS) then break end
end
end

function PlayersAreCoAllied(playerA, playerB)
if (playerA == playerB) then
return true
end
if GetPlayerAlliance(playerA, playerB, ALLIANCE_PASSIVE) then
if GetPlayerAlliance(playerB, playerA, ALLIANCE_PASSIVE) then
return true
end
end
return false
end

function ShareEverythingWithTeamAI(whichPlayer)
local playerIndex
local indexPlayer

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer) and whichPlayer ~= indexPlayer) then
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_VISION, true)
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_CONTROL, true)
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
end
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
end

function ShareEverythingWithTeam(whichPlayer)
local playerIndex
local indexPlayer

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer) and whichPlayer ~= indexPlayer) then
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_VISION, true)
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_CONTROL, true)
SetPlayerAlliance(indexPlayer, whichPlayer, ALLIANCE_SHARED_CONTROL, true)
SetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
end

function ConfigureNeutralVictim()
local index
local indexPlayer
local neutralVictim = Player(bj_PLAYER_NEUTRAL_VICTIM)

index = 0
while (true) do
indexPlayer = Player(index)
SetPlayerAlliance(neutralVictim, indexPlayer, ALLIANCE_PASSIVE, true)
SetPlayerAlliance(indexPlayer, neutralVictim, ALLIANCE_PASSIVE, false)
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
indexPlayer = Player(PLAYER_NEUTRAL_AGGRESSIVE)
SetPlayerAlliance(neutralVictim, indexPlayer, ALLIANCE_PASSIVE, true)
SetPlayerAlliance(indexPlayer, neutralVictim, ALLIANCE_PASSIVE, true)
SetPlayerState(neutralVictim, PLAYER_STATE_GIVES_BOUNTY, 0)
end

function MakeUnitsPassiveForPlayerEnum()
SetUnitOwner(GetEnumUnit(), Player(bj_PLAYER_NEUTRAL_VICTIM), false)
end

function MakeUnitsPassiveForPlayer(whichPlayer)
local playerUnits = CreateGroup()

CachePlayerHeroData(whichPlayer)
GroupEnumUnitsOfPlayer(playerUnits, whichPlayer, nil)
ForGroup(playerUnits, MakeUnitsPassiveForPlayerEnum)
DestroyGroup(playerUnits)
end

function MakeUnitsPassiveForTeam(whichPlayer)
local playerIndex
local indexPlayer

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if PlayersAreCoAllied(whichPlayer, indexPlayer) then
MakeUnitsPassiveForPlayer(indexPlayer)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
end

function AllowVictoryDefeat(gameResult)
if (gameResult == PLAYER_GAME_RESULT_VICTORY) then
return not IsNoVictoryCheat()
end
if (gameResult == PLAYER_GAME_RESULT_DEFEAT) then
return not IsNoDefeatCheat()
end
if (gameResult == PLAYER_GAME_RESULT_NEUTRAL) then
return ((not IsNoVictoryCheat()) and (not IsNoDefeatCheat()))
end
return true
end

function EndGameBJ()
EndGame(true)
end

function MeleeVictoryDialogBJ(whichPlayer, leftGame)
local t = CreateTrigger()
local d = DialogCreate()
local formatString

if (leftGame) then
formatString = GetLocalizedString("PLAYER_LEFT_GAME")
else
formatString = GetLocalizedString("PLAYER_VICTORIOUS")
end
DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString)
DialogSetMessage(d, GetLocalizedString("GAMEOVER_VICTORY_MSG"))
DialogAddButton(d, GetLocalizedString("GAMEOVER_CONTINUE_GAME"), GetLocalizedHotkey("GAMEOVER_CONTINUE_GAME"))
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddQuitButton(d, true, GetLocalizedString("GAMEOVER_QUIT_GAME"), GetLocalizedHotkey("GAMEOVER_QUIT_GAME")))
DialogDisplay(whichPlayer, d, true)
StartSoundForPlayerBJ(whichPlayer, bj_victoryDialogSound)
end

function MeleeDefeatDialogBJ(whichPlayer, leftGame)
local t = CreateTrigger()
local d = DialogCreate()
local formatString

if (leftGame) then
formatString = GetLocalizedString("PLAYER_LEFT_GAME")
else
formatString = GetLocalizedString("PLAYER_DEFEATED")
end
DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, formatString)
DialogSetMessage(d, GetLocalizedString("GAMEOVER_DEFEAT_MSG"))
if (not bj_meleeGameOver and IsMapFlagSet(MAP_OBSERVERS_ON_DEATH)) then
DialogAddButton(d, GetLocalizedString("GAMEOVER_CONTINUE_OBSERVING"), GetLocalizedHotkey("GAMEOVER_CONTINUE_OBSERVING"))
end
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddQuitButton(d, true, GetLocalizedString("GAMEOVER_QUIT_GAME"), GetLocalizedHotkey("GAMEOVER_QUIT_GAME")))
DialogDisplay(whichPlayer, d, true)
StartSoundForPlayerBJ(whichPlayer, bj_defeatDialogSound)
end

function GameOverDialogBJ(whichPlayer, leftGame)
local t = CreateTrigger()
local d = DialogCreate()
local s

DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString("PLAYER_LEFT_GAME"))
if (GetIntegerGameState(GAME_STATE_DISCONNECTED) ~= 0) then
s = GetLocalizedString("GAMEOVER_DISCONNECTED")
else
s = GetLocalizedString("GAMEOVER_GAME_OVER")
end
DialogSetMessage(d, s)
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddQuitButton(d, true, GetLocalizedString("GAMEOVER_OK"), GetLocalizedHotkey("GAMEOVER_OK")))
DialogDisplay(whichPlayer, d, true)
StartSoundForPlayerBJ(whichPlayer, bj_defeatDialogSound)
end

function RemovePlayerPreserveUnitsBJ(whichPlayer, gameResult, leftGame)
if AllowVictoryDefeat(gameResult) then
RemovePlayer(whichPlayer, gameResult)
if (gameResult == PLAYER_GAME_RESULT_VICTORY) then
MeleeVictoryDialogBJ(whichPlayer, leftGame)
return
elseif (gameResult == PLAYER_GAME_RESULT_DEFEAT) then
MeleeDefeatDialogBJ(whichPlayer, leftGame)
else
GameOverDialogBJ(whichPlayer, leftGame)
end
end
end

function CustomVictoryOkBJ()
if bj_isSinglePlayer then
PauseGame(false)
SetGameDifficulty(GetDefaultDifficulty())
end
if (bj_changeLevelMapName == "") then
EndGame(bj_changeLevelShowScores)
else
ChangeLevel(bj_changeLevelMapName, bj_changeLevelShowScores)
end
end

function CustomVictoryQuitBJ()
if bj_isSinglePlayer then
PauseGame(false)
SetGameDifficulty(GetDefaultDifficulty())
end
EndGame(bj_changeLevelShowScores)
end

function CustomVictoryDialogBJ(whichPlayer)
local t = CreateTrigger()
local d = DialogCreate()

DialogSetMessage(d, GetLocalizedString("GAMEOVER_VICTORY_MSG"))
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_CONTINUE"), GetLocalizedHotkey("GAMEOVER_CONTINUE")))
TriggerAddAction(t, CustomVictoryOkBJ)
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_QUIT_MISSION"), GetLocalizedHotkey("GAMEOVER_QUIT_MISSION")))
TriggerAddAction(t, CustomVictoryQuitBJ)
if (GetLocalPlayer() == whichPlayer) then
EnableUserControl(true)
if bj_isSinglePlayer then
PauseGame(true)
end
EnableUserUI(false)
end
DialogDisplay(whichPlayer, d, true)
VolumeGroupSetVolumeForPlayerBJ(whichPlayer, SOUND_VOLUMEGROUP_UI, 1.0)
StartSoundForPlayerBJ(whichPlayer, bj_victoryDialogSound)
end

function CustomVictorySkipBJ(whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
if bj_isSinglePlayer then
SetGameDifficulty(GetDefaultDifficulty())
end
if (bj_changeLevelMapName == "") then
EndGame(bj_changeLevelShowScores)
else
ChangeLevel(bj_changeLevelMapName, bj_changeLevelShowScores)
end
end
end

function CustomVictoryBJ(whichPlayer, showDialog, showScores)
if AllowVictoryDefeat(PLAYER_GAME_RESULT_VICTORY) then
RemovePlayer(whichPlayer, PLAYER_GAME_RESULT_VICTORY)
if not bj_isSinglePlayer then
DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString("PLAYER_VICTORIOUS"))
end
if (GetPlayerController(whichPlayer) == MAP_CONTROL_USER) then
bj_changeLevelShowScores = showScores
if showDialog then
CustomVictoryDialogBJ(whichPlayer)
else
CustomVictorySkipBJ(whichPlayer)
end
end
end
end

function CustomDefeatRestartBJ()
PauseGame(false)
RestartGame(true)
end

function CustomDefeatReduceDifficultyBJ()
local diff = GetGameDifficulty()

PauseGame(false)
if (diff == MAP_DIFFICULTY_EASY) then
elseif (diff == MAP_DIFFICULTY_NORMAL) then
SetGameDifficulty(MAP_DIFFICULTY_EASY)
elseif (diff == MAP_DIFFICULTY_HARD) then
SetGameDifficulty(MAP_DIFFICULTY_NORMAL)
else
end
RestartGame(true)
end

function CustomDefeatLoadBJ()
PauseGame(false)
DisplayLoadDialog()
end

function CustomDefeatQuitBJ()
if bj_isSinglePlayer then
PauseGame(false)
end
SetGameDifficulty(GetDefaultDifficulty())
EndGame(true)
end

function CustomDefeatDialogBJ(whichPlayer, message)
local t = CreateTrigger()
local d = DialogCreate()

DialogSetMessage(d, message)
if bj_isSinglePlayer then
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_RESTART"), GetLocalizedHotkey("GAMEOVER_RESTART")))
TriggerAddAction(t, CustomDefeatRestartBJ)
if (GetGameDifficulty() ~= MAP_DIFFICULTY_EASY) then
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_REDUCE_DIFFICULTY"), GetLocalizedHotkey("GAMEOVER_REDUCE_DIFFICULTY")))
TriggerAddAction(t, CustomDefeatReduceDifficultyBJ)
end
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_LOAD"), GetLocalizedHotkey("GAMEOVER_LOAD")))
TriggerAddAction(t, CustomDefeatLoadBJ)
end
t = CreateTrigger()
TriggerRegisterDialogButtonEvent(t, DialogAddButton(d, GetLocalizedString("GAMEOVER_QUIT_MISSION"), GetLocalizedHotkey("GAMEOVER_QUIT_MISSION")))
TriggerAddAction(t, CustomDefeatQuitBJ)
if (GetLocalPlayer() == whichPlayer) then
EnableUserControl(true)
if bj_isSinglePlayer then
PauseGame(true)
end
EnableUserUI(false)
end
DialogDisplay(whichPlayer, d, true)
VolumeGroupSetVolumeForPlayerBJ(whichPlayer, SOUND_VOLUMEGROUP_UI, 1.0)
StartSoundForPlayerBJ(whichPlayer, bj_defeatDialogSound)
end

function CustomDefeatBJ(whichPlayer, message)
if AllowVictoryDefeat(PLAYER_GAME_RESULT_DEFEAT) then
RemovePlayer(whichPlayer, PLAYER_GAME_RESULT_DEFEAT)
if not bj_isSinglePlayer then
DisplayTimedTextFromPlayer(whichPlayer, 0, 0, 60, GetLocalizedString("PLAYER_DEFEATED"))
end
if (GetPlayerController(whichPlayer) == MAP_CONTROL_USER) then
CustomDefeatDialogBJ(whichPlayer, message)
end
end
end

function SetNextLevelBJ(nextLevel)
if (nextLevel == "") then
bj_changeLevelMapName = ""
else
bj_changeLevelMapName = nextLevel
end
end

function SetPlayerOnScoreScreenBJ(flag, whichPlayer)
SetPlayerOnScoreScreen(whichPlayer, flag)
end

function CreateQuestBJ(questType, title, description, iconPath)
local required = ((questType == bj_QUESTTYPE_REQ_DISCOVERED) or (questType == bj_QUESTTYPE_REQ_UNDISCOVERED))
local discovered = ((questType == bj_QUESTTYPE_REQ_DISCOVERED) or (questType == bj_QUESTTYPE_OPT_DISCOVERED))

bj_lastCreatedQuest = CreateQuest()
QuestSetTitle(bj_lastCreatedQuest, title)
QuestSetDescription(bj_lastCreatedQuest, description)
QuestSetIconPath(bj_lastCreatedQuest, iconPath)
QuestSetRequired(bj_lastCreatedQuest, required)
QuestSetDiscovered(bj_lastCreatedQuest, discovered)
QuestSetCompleted(bj_lastCreatedQuest, false)
return bj_lastCreatedQuest
end

function DestroyQuestBJ(whichQuest)
DestroyQuest(whichQuest)
end

function QuestSetEnabledBJ(enabled, whichQuest)
QuestSetEnabled(whichQuest, enabled)
end

function QuestSetTitleBJ(whichQuest, title)
QuestSetTitle(whichQuest, title)
end

function QuestSetDescriptionBJ(whichQuest, description)
QuestSetDescription(whichQuest, description)
end

function QuestSetCompletedBJ(whichQuest, completed)
QuestSetCompleted(whichQuest, completed)
end

function QuestSetFailedBJ(whichQuest, failed)
QuestSetFailed(whichQuest, failed)
end

function QuestSetDiscoveredBJ(whichQuest, discovered)
QuestSetDiscovered(whichQuest, discovered)
end

function GetLastCreatedQuestBJ()
return bj_lastCreatedQuest
end

function CreateQuestItemBJ(whichQuest, description)
bj_lastCreatedQuestItem = QuestCreateItem(whichQuest)
QuestItemSetDescription(bj_lastCreatedQuestItem, description)
QuestItemSetCompleted(bj_lastCreatedQuestItem, false)
return bj_lastCreatedQuestItem
end

function QuestItemSetDescriptionBJ(whichQuestItem, description)
QuestItemSetDescription(whichQuestItem, description)
end

function QuestItemSetCompletedBJ(whichQuestItem, completed)
QuestItemSetCompleted(whichQuestItem, completed)
end

function GetLastCreatedQuestItemBJ()
return bj_lastCreatedQuestItem
end

function CreateDefeatConditionBJ(description)
bj_lastCreatedDefeatCondition = CreateDefeatCondition()
DefeatConditionSetDescription(bj_lastCreatedDefeatCondition, description)
return bj_lastCreatedDefeatCondition
end

function DestroyDefeatConditionBJ(whichCondition)
DestroyDefeatCondition(whichCondition)
end

function DefeatConditionSetDescriptionBJ(whichCondition, description)
DefeatConditionSetDescription(whichCondition, description)
end

function GetLastCreatedDefeatConditionBJ()
return bj_lastCreatedDefeatCondition
end

function FlashQuestDialogButtonBJ()
FlashQuestDialogButton()
end

function QuestMessageBJ(f, messageType, message)
if (IsPlayerInForce(GetLocalPlayer(), f)) then
if (messageType == bj_QUESTMESSAGE_DISCOVERED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUEST, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUEST, message)
StartSound(bj_questDiscoveredSound)
FlashQuestDialogButton()
elseif (messageType == bj_QUESTMESSAGE_UPDATED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTUPDATE, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTUPDATE, message)
StartSound(bj_questUpdatedSound)
FlashQuestDialogButton()
elseif (messageType == bj_QUESTMESSAGE_COMPLETED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTDONE, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTDONE, message)
StartSound(bj_questCompletedSound)
FlashQuestDialogButton()
elseif (messageType == bj_QUESTMESSAGE_FAILED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTFAILED, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTFAILED, message)
StartSound(bj_questFailedSound)
FlashQuestDialogButton()
elseif (messageType == bj_QUESTMESSAGE_REQUIREMENT) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_QUESTREQUIREMENT, message)
elseif (messageType == bj_QUESTMESSAGE_MISSIONFAILED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_MISSIONFAILED, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_MISSIONFAILED, message)
StartSound(bj_questFailedSound)
elseif (messageType == bj_QUESTMESSAGE_HINT) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_HINT, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_HINT, message)
StartSound(bj_questHintSound)
elseif (messageType == bj_QUESTMESSAGE_ALWAYSHINT) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ALWAYSHINT, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ALWAYSHINT, message)
StartSound(bj_questHintSound)
elseif (messageType == bj_QUESTMESSAGE_SECRET) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_SECRET, message)
StartSound(bj_questSecretSound)
elseif (messageType == bj_QUESTMESSAGE_UNITACQUIRED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITACQUIRED, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITACQUIRED, message)
StartSound(bj_questHintSound)
elseif (messageType == bj_QUESTMESSAGE_UNITAVAILABLE) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITAVAILABLE, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_UNITAVAILABLE, message)
StartSound(bj_questHintSound)
elseif (messageType == bj_QUESTMESSAGE_ITEMACQUIRED) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ITEMACQUIRED, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_ITEMACQUIRED, message)
StartSound(bj_questItemAcquiredSound)
elseif (messageType == bj_QUESTMESSAGE_WARNING) then
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_WARNING, " ")
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_TEXT_DELAY_WARNING, message)
StartSound(bj_questWarningSound)
else
end
end
end

function StartTimerBJ(t, periodic, timeout)
bj_lastStartedTimer = t
TimerStart(t, timeout, periodic, nil)
return bj_lastStartedTimer
end

function CreateTimerBJ(periodic, timeout)
bj_lastStartedTimer = CreateTimer()
TimerStart(bj_lastStartedTimer, timeout, periodic, nil)
return bj_lastStartedTimer
end

function DestroyTimerBJ(whichTimer)
DestroyTimer(whichTimer)
end

function PauseTimerBJ(pause, whichTimer)
if pause then
PauseTimer(whichTimer)
else
ResumeTimer(whichTimer)
end
end

function GetLastCreatedTimerBJ()
return bj_lastStartedTimer
end

function CreateTimerDialogBJ(t, title)
bj_lastCreatedTimerDialog = CreateTimerDialog(t)
TimerDialogSetTitle(bj_lastCreatedTimerDialog, title)
TimerDialogDisplay(bj_lastCreatedTimerDialog, true)
return bj_lastCreatedTimerDialog
end

function DestroyTimerDialogBJ(td)
DestroyTimerDialog(td)
end

function TimerDialogSetTitleBJ(td, title)
TimerDialogSetTitle(td, title)
end

function TimerDialogSetTitleColorBJ(td, red, green, blue, transparency)
TimerDialogSetTitleColor(td, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function TimerDialogSetTimeColorBJ(td, red, green, blue, transparency)
TimerDialogSetTimeColor(td, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function TimerDialogSetSpeedBJ(td, speedMultFactor)
TimerDialogSetSpeed(td, speedMultFactor)
end

function TimerDialogDisplayForPlayerBJ(show, td, whichPlayer)
if (GetLocalPlayer() == whichPlayer) then
TimerDialogDisplay(td, show)
end
end

function TimerDialogDisplayBJ(show, td)
TimerDialogDisplay(td, show)
end

function GetLastCreatedTimerDialogBJ()
return bj_lastCreatedTimerDialog
end

function LeaderboardResizeBJ(lb)
local size = LeaderboardGetItemCount(lb)

if (LeaderboardGetLabelText(lb) == "") then
size = size - 1
end
LeaderboardSetSizeByItemCount(lb, size)
end

function LeaderboardSetPlayerItemValueBJ(whichPlayer, lb, val)
LeaderboardSetItemValue(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), val)
end

function LeaderboardSetPlayerItemLabelBJ(whichPlayer, lb, val)
LeaderboardSetItemLabel(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), val)
end

function LeaderboardSetPlayerItemStyleBJ(whichPlayer, lb, showLabel, showValue, showIcon)
LeaderboardSetItemStyle(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), showLabel, showValue, showIcon)
end

function LeaderboardSetPlayerItemLabelColorBJ(whichPlayer, lb, red, green, blue, transparency)
LeaderboardSetItemLabelColor(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function LeaderboardSetPlayerItemValueColorBJ(whichPlayer, lb, red, green, blue, transparency)
LeaderboardSetItemValueColor(lb, LeaderboardGetPlayerIndex(lb, whichPlayer), PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function LeaderboardSetLabelColorBJ(lb, red, green, blue, transparency)
LeaderboardSetLabelColor(lb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function LeaderboardSetValueColorBJ(lb, red, green, blue, transparency)
LeaderboardSetValueColor(lb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function LeaderboardSetLabelBJ(lb, label)
LeaderboardSetLabel(lb, label)
LeaderboardResizeBJ(lb)
end

function LeaderboardSetStyleBJ(lb, showLabel, showNames, showValues, showIcons)
LeaderboardSetStyle(lb, showLabel, showNames, showValues, showIcons)
end

function LeaderboardGetItemCountBJ(lb)
return LeaderboardGetItemCount(lb)
end

function LeaderboardHasPlayerItemBJ(lb, whichPlayer)
return LeaderboardHasPlayerItem(lb, whichPlayer)
end

function ForceSetLeaderboardBJ(lb, toForce)
local index
local indexPlayer

index = 0
while (true) do
indexPlayer = Player(index)
if IsPlayerInForce(indexPlayer, toForce) then
PlayerSetLeaderboard(indexPlayer, lb)
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function CreateLeaderboardBJ(toForce, label)
bj_lastCreatedLeaderboard = CreateLeaderboard()
LeaderboardSetLabel(bj_lastCreatedLeaderboard, label)
ForceSetLeaderboardBJ(bj_lastCreatedLeaderboard, toForce)
LeaderboardDisplay(bj_lastCreatedLeaderboard, true)
return bj_lastCreatedLeaderboard
end

function DestroyLeaderboardBJ(lb)
DestroyLeaderboard(lb)
end

function LeaderboardDisplayBJ(show, lb)
LeaderboardDisplay(lb, show)
end

function LeaderboardAddItemBJ(whichPlayer, lb, label, value)
if (LeaderboardHasPlayerItem(lb, whichPlayer)) then
LeaderboardRemovePlayerItem(lb, whichPlayer)
end
LeaderboardAddItem(lb, label, value, whichPlayer)
LeaderboardResizeBJ(lb)
end

function LeaderboardRemovePlayerItemBJ(whichPlayer, lb)
LeaderboardRemovePlayerItem(lb, whichPlayer)
LeaderboardResizeBJ(lb)
end

function LeaderboardSortItemsBJ(lb, sortType, ascending)
if (sortType == bj_SORTTYPE_SORTBYVALUE) then
LeaderboardSortItemsByValue(lb, ascending)
elseif (sortType == bj_SORTTYPE_SORTBYPLAYER) then
LeaderboardSortItemsByPlayer(lb, ascending)
elseif (sortType == bj_SORTTYPE_SORTBYLABEL) then
LeaderboardSortItemsByLabel(lb, ascending)
else
end
end

function LeaderboardSortItemsByPlayerBJ(lb, ascending)
LeaderboardSortItemsByPlayer(lb, ascending)
end

function LeaderboardSortItemsByLabelBJ(lb, ascending)
LeaderboardSortItemsByLabel(lb, ascending)
end

function LeaderboardGetPlayerIndexBJ(whichPlayer, lb)
return LeaderboardGetPlayerIndex(lb, whichPlayer) + 1
end

function LeaderboardGetIndexedPlayerBJ(position, lb)
local index
local indexPlayer

index = 0
while (true) do
indexPlayer = Player(index)
if (LeaderboardGetPlayerIndex(lb, indexPlayer) == position - 1) then
return indexPlayer
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
return Player(PLAYER_NEUTRAL_PASSIVE)
end

function PlayerGetLeaderboardBJ(whichPlayer)
return PlayerGetLeaderboard(whichPlayer)
end

function GetLastCreatedLeaderboard()
return bj_lastCreatedLeaderboard
end

function CreateMultiboardBJ(cols, rows, title)
bj_lastCreatedMultiboard = CreateMultiboard()
MultiboardSetRowCount(bj_lastCreatedMultiboard, rows)
MultiboardSetColumnCount(bj_lastCreatedMultiboard, cols)
MultiboardSetTitleText(bj_lastCreatedMultiboard, title)
MultiboardDisplay(bj_lastCreatedMultiboard, true)
return bj_lastCreatedMultiboard
end

function DestroyMultiboardBJ(mb)
DestroyMultiboard(mb)
end

function GetLastCreatedMultiboard()
return bj_lastCreatedMultiboard
end

function MultiboardDisplayBJ(show, mb)
MultiboardDisplay(mb, show)
end

function MultiboardMinimizeBJ(minimize, mb)
MultiboardMinimize(mb, minimize)
end

function MultiboardSetTitleTextColorBJ(mb, red, green, blue, transparency)
MultiboardSetTitleTextColor(mb, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function MultiboardAllowDisplayBJ(flag)
MultiboardSuppressDisplay(not flag)
end

function MultiboardSetItemStyleBJ(mb, col, row, showValue, showIcon)
local curRow = 0
local curCol = 0
local numRows = MultiboardGetRowCount(mb)
local numCols = MultiboardGetColumnCount(mb)
local mbitem = nil

while (true) do
curRow = curRow + 1
if (curRow > numRows) then break end
if (row == 0 or row == curRow) then
curCol = 0
while (true) do
curCol = curCol + 1
if (curCol > numCols) then break end
if (col == 0 or col == curCol) then
mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
MultiboardSetItemStyle(mbitem, showValue, showIcon)
MultiboardReleaseItem(mbitem)
end
end
end
end
end

function MultiboardSetItemValueBJ(mb, col, row, val)
local curRow = 0
local curCol = 0
local numRows = MultiboardGetRowCount(mb)
local numCols = MultiboardGetColumnCount(mb)
local mbitem = nil

while (true) do
curRow = curRow + 1
if (curRow > numRows) then break end
if (row == 0 or row == curRow) then
curCol = 0
while (true) do
curCol = curCol + 1
if (curCol > numCols) then break end
if (col == 0 or col == curCol) then
mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
MultiboardSetItemValue(mbitem, val)
MultiboardReleaseItem(mbitem)
end
end
end
end
end

function MultiboardSetItemColorBJ(mb, col, row, red, green, blue, transparency)
local curRow = 0
local curCol = 0
local numRows = MultiboardGetRowCount(mb)
local numCols = MultiboardGetColumnCount(mb)
local mbitem = nil

while (true) do
curRow = curRow + 1
if (curRow > numRows) then break end
if (row == 0 or row == curRow) then
curCol = 0
while (true) do
curCol = curCol + 1
if (curCol > numCols) then break end
if (col == 0 or col == curCol) then
mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
MultiboardSetItemValueColor(mbitem, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
MultiboardReleaseItem(mbitem)
end
end
end
end
end

function MultiboardSetItemWidthBJ(mb, col, row, width)
local curRow = 0
local curCol = 0
local numRows = MultiboardGetRowCount(mb)
local numCols = MultiboardGetColumnCount(mb)
local mbitem = nil

while (true) do
curRow = curRow + 1
if (curRow > numRows) then break end
if (row == 0 or row == curRow) then
curCol = 0
while (true) do
curCol = curCol + 1
if (curCol > numCols) then break end
if (col == 0 or col == curCol) then
mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
MultiboardSetItemWidth(mbitem, width / 100.0)
MultiboardReleaseItem(mbitem)
end
end
end
end
end

function MultiboardSetItemIconBJ(mb, col, row, iconFileName)
local curRow = 0
local curCol = 0
local numRows = MultiboardGetRowCount(mb)
local numCols = MultiboardGetColumnCount(mb)
local mbitem = nil

while (true) do
curRow = curRow + 1
if (curRow > numRows) then break end
if (row == 0 or row == curRow) then
curCol = 0
while (true) do
curCol = curCol + 1
if (curCol > numCols) then break end
if (col == 0 or col == curCol) then
mbitem = MultiboardGetItem(mb, curRow - 1, curCol - 1)
MultiboardSetItemIcon(mbitem, iconFileName)
MultiboardReleaseItem(mbitem)
end
end
end
end
end

function TextTagSize2Height(size)
return size * 0.023 / 10
end

function TextTagSpeed2Velocity(speed)
return speed * 0.071 / 128
end

function SetTextTagColorBJ(tt, red, green, blue, transparency)
SetTextTagColor(tt, PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - transparency))
end

function SetTextTagVelocityBJ(tt, speed, angle)
local vel = TextTagSpeed2Velocity(speed)
local xvel = vel * Cos(angle * bj_DEGTORAD)
local yvel = vel * Sin(angle * bj_DEGTORAD)

SetTextTagVelocity(tt, xvel, yvel)
end

function SetTextTagTextBJ(tt, s, size)
local textHeight = TextTagSize2Height(size)

SetTextTagText(tt, s, textHeight)
end

function SetTextTagPosBJ(tt, loc, zOffset)
SetTextTagPos(tt, GetLocationX(loc), GetLocationY(loc), zOffset)
end

function SetTextTagPosUnitBJ(tt, whichUnit, zOffset)
SetTextTagPosUnit(tt, whichUnit, zOffset)
end

function SetTextTagSuspendedBJ(tt, flag)
SetTextTagSuspended(tt, flag)
end

function SetTextTagPermanentBJ(tt, flag)
SetTextTagPermanent(tt, flag)
end

function SetTextTagAgeBJ(tt, age)
SetTextTagAge(tt, age)
end

function SetTextTagLifespanBJ(tt, lifespan)
SetTextTagLifespan(tt, lifespan)
end

function SetTextTagFadepointBJ(tt, fadepoint)
SetTextTagFadepoint(tt, fadepoint)
end

function CreateTextTagLocBJ(s, loc, zOffset, size, red, green, blue, transparency)
bj_lastCreatedTextTag = CreateTextTag()
SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
SetTextTagPosBJ(bj_lastCreatedTextTag, loc, zOffset)
SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)
return bj_lastCreatedTextTag
end

function CreateTextTagUnitBJ(s, whichUnit, zOffset, size, red, green, blue, transparency)
bj_lastCreatedTextTag = CreateTextTag()
SetTextTagTextBJ(bj_lastCreatedTextTag, s, size)
SetTextTagPosUnitBJ(bj_lastCreatedTextTag, whichUnit, zOffset)
SetTextTagColorBJ(bj_lastCreatedTextTag, red, green, blue, transparency)
return bj_lastCreatedTextTag
end

function DestroyTextTagBJ(tt)
DestroyTextTag(tt)
end

function ShowTextTagForceBJ(show, tt, whichForce)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
SetTextTagVisibility(tt, show)
end
end

function GetLastCreatedTextTag()
return bj_lastCreatedTextTag
end

function PauseGameOn()
PauseGame(true)
end

function PauseGameOff()
PauseGame(false)
end

function SetUserControlForceOn(whichForce)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
EnableUserControl(true)
end
end

function SetUserControlForceOff(whichForce)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
EnableUserControl(false)
end
end

function ShowInterfaceForceOn(whichForce, fadeDuration)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
ShowInterface(true, fadeDuration)
end
end

function ShowInterfaceForceOff(whichForce, fadeDuration)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
ShowInterface(false, fadeDuration)
end
end

function PingMinimapForForce(whichForce, x, y, duration)
if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
PingMinimap(x, y, duration)
end
end

function PingMinimapLocForForce(whichForce, loc, duration)
PingMinimapForForce(whichForce, GetLocationX(loc), GetLocationY(loc), duration)
end

function PingMinimapForPlayer(whichPlayer, x, y, duration)
if (GetLocalPlayer() == whichPlayer) then
PingMinimap(x, y, duration)
end
end

function PingMinimapLocForPlayer(whichPlayer, loc, duration)
PingMinimapForPlayer(whichPlayer, GetLocationX(loc), GetLocationY(loc), duration)
end

function PingMinimapForForceEx(whichForce, x, y, duration, style, red, green, blue)
local red255 = PercentTo255(red)
local green255 = PercentTo255(green)
local blue255 = PercentTo255(blue)

if (IsPlayerInForce(GetLocalPlayer(), whichForce)) then
if ((red255 == 255) and ((green255 == 0) and (blue255 == 0))) then
red255 = 254
end
if (style == bj_MINIMAPPINGSTYLE_SIMPLE) then
PingMinimapEx(x, y, duration, red255, green255, blue255, false)
elseif (style == bj_MINIMAPPINGSTYLE_FLASHY) then
PingMinimapEx(x, y, duration, red255, green255, blue255, true)
elseif (style == bj_MINIMAPPINGSTYLE_ATTACK) then
PingMinimapEx(x, y, duration, 255, 0, 0, false)
else
end
end
end

function PingMinimapLocForForceEx(whichForce, loc, duration, style, red, green, blue)
PingMinimapForForceEx(whichForce, GetLocationX(loc), GetLocationY(loc), duration, style, red, green, blue)
end

function EnableWorldFogBoundaryBJ(enable, f)
if (IsPlayerInForce(GetLocalPlayer(), f)) then
EnableWorldFogBoundary(enable)
end
end

function EnableOcclusionBJ(enable, f)
if (IsPlayerInForce(GetLocalPlayer(), f)) then
EnableOcclusion(enable)
end
end

function CancelCineSceneBJ()
StopSoundBJ(bj_cineSceneLastSound, true)
EndCinematicScene()
end

function TryInitCinematicBehaviorBJ()
local index

if (bj_cineSceneBeingSkipped == nil) then
bj_cineSceneBeingSkipped = CreateTrigger()
index = 0
while (true) do
TriggerRegisterPlayerEvent(bj_cineSceneBeingSkipped, Player(index), EVENT_PLAYER_END_CINEMATIC)
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
TriggerAddAction(bj_cineSceneBeingSkipped, CancelCineSceneBJ)
end
end

function SetCinematicSceneBJ(soundHandle, portraitUnitId, color, speakerTitle, text, sceneDuration, voiceoverDuration)
bj_cineSceneLastSound = soundHandle
SetCinematicScene(portraitUnitId, color, speakerTitle, text, sceneDuration, voiceoverDuration)
PlaySoundBJ(soundHandle)
end

function GetTransmissionDuration(soundHandle, timeType, timeVal)
local duration

if (timeType == bj_TIMETYPE_ADD) then
duration = GetSoundDurationBJ(soundHandle) + timeVal
elseif (timeType == bj_TIMETYPE_SET) then
duration = timeVal
elseif (timeType == bj_TIMETYPE_SUB) then
duration = GetSoundDurationBJ(soundHandle) - timeVal
else
duration = GetSoundDurationBJ(soundHandle)
end
if (duration < 0) then
duration = 0.0
end
return duration
end

function WaitTransmissionDuration(soundHandle, timeType, timeVal)
if (timeType == bj_TIMETYPE_SET) then
TriggerSleepAction(timeVal)
elseif (soundHandle == nil) then
TriggerSleepAction(bj_NOTHING_SOUND_DURATION)
elseif (timeType == bj_TIMETYPE_SUB) then
WaitForSoundBJ(soundHandle, timeVal)
elseif (timeType == bj_TIMETYPE_ADD) then
WaitForSoundBJ(soundHandle, 0)
TriggerSleepAction(timeVal)
else
end
end

function DoTransmissionBasicsXYBJ(unitId, color, x, y, soundHandle, unitName, message, duration)
SetCinematicSceneBJ(soundHandle, unitId, color, unitName, message, duration + bj_TRANSMISSION_PORT_HANGTIME, duration)
if (unitId ~= 0) then
PingMinimap(x, y, bj_TRANSMISSION_PING_TIME)
end
end

function TransmissionFromUnitWithNameBJ(toForce, whichUnit, unitName, soundHandle, message, timeType, timeVal, wait)
TryInitCinematicBehaviorBJ()
AttachSoundToUnit(soundHandle, whichUnit)
timeVal = RMaxBJ(timeVal, 0)
bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal)
bj_lastPlayedSound = soundHandle
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
if (whichUnit == nil) then
DoTransmissionBasicsXYBJ(0, PLAYER_COLOR_RED, 0, 0, soundHandle, unitName, message, bj_lastTransmissionDuration)
else
DoTransmissionBasicsXYBJ(GetUnitTypeId(whichUnit), GetPlayerColor(GetOwningPlayer(whichUnit)), GetUnitX(whichUnit), GetUnitY(whichUnit), soundHandle, unitName, message, bj_lastTransmissionDuration)
if (not IsUnitHidden(whichUnit)) then
UnitAddIndicator(whichUnit, bj_TRANSMISSION_IND_RED, bj_TRANSMISSION_IND_BLUE, bj_TRANSMISSION_IND_GREEN, bj_TRANSMISSION_IND_ALPHA)
end
end
end
if (wait and (bj_lastTransmissionDuration > 0)) then
WaitTransmissionDuration(soundHandle, timeType, timeVal)
end
end

function PlayDialogueFromSpeakerEx(toForce, speaker, speakerType, soundHandle, timeType, timeVal, wait)
if GetUnitTypeId(speaker) ~= speakerType then
if _DEBUG then
BJDebugMsg(("Attempted to play FacialAnimation with the wrong speaker UnitType - Param: " .. I2S(speakerType) .. " Runtime: " .. I2S(GetUnitTypeId(speaker))))
end
end
TryInitCinematicBehaviorBJ()
AttachSoundToUnit(soundHandle, speaker)
timeVal = RMaxBJ(timeVal, 0)
bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal)
bj_lastPlayedSound = soundHandle
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
SetCinematicSceneBJ(soundHandle, speakerType, GetPlayerColor(GetOwningPlayer(speaker)), GetLocalizedString(GetDialogueSpeakerNameKey(soundHandle)), GetLocalizedString(GetDialogueTextKey(soundHandle)), bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration)
end
if (wait and (bj_lastTransmissionDuration > 0)) then
WaitTransmissionDuration(soundHandle, timeType, timeVal)
end
return true
end

function PlayDialogueFromSpeakerTypeEx(toForce, fromPlayer, speakerType, loc, soundHandle, timeType, timeVal, wait)
TryInitCinematicBehaviorBJ()
timeVal = RMaxBJ(timeVal, 0)
bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal)
bj_lastPlayedSound = soundHandle
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
SetCinematicSceneBJ(soundHandle, speakerType, GetPlayerColor(fromPlayer), GetLocalizedString(GetDialogueSpeakerNameKey(soundHandle)), GetLocalizedString(GetDialogueTextKey(soundHandle)), bj_lastTransmissionDuration + bj_TRANSMISSION_PORT_HANGTIME, bj_lastTransmissionDuration)
if (speakerType ~= 0) then
PingMinimap(GetLocationX(loc), GetLocationY(loc), bj_TRANSMISSION_PING_TIME)
end
end
if (wait and (bj_lastTransmissionDuration > 0)) then
WaitTransmissionDuration(soundHandle, timeType, timeVal)
end
return true
end

function TransmissionFromUnitTypeWithNameBJ(toForce, fromPlayer, unitId, unitName, loc, soundHandle, message, timeType, timeVal, wait)
TryInitCinematicBehaviorBJ()
timeVal = RMaxBJ(timeVal, 0)
bj_lastTransmissionDuration = GetTransmissionDuration(soundHandle, timeType, timeVal)
bj_lastPlayedSound = soundHandle
if (IsPlayerInForce(GetLocalPlayer(), toForce)) then
DoTransmissionBasicsXYBJ(unitId, GetPlayerColor(fromPlayer), GetLocationX(loc), GetLocationY(loc), soundHandle, unitName, message, bj_lastTransmissionDuration)
end
if (wait and (bj_lastTransmissionDuration > 0)) then
WaitTransmissionDuration(soundHandle, timeType, timeVal)
end
end

function GetLastTransmissionDurationBJ()
return bj_lastTransmissionDuration
end

function ForceCinematicSubtitlesBJ(flag)
ForceCinematicSubtitles(flag)
end

function CinematicModeExBJ(cineMode, forForce, interfaceFadeTime)
if (not bj_gameStarted) then
interfaceFadeTime = 0.0
end
if (cineMode) then
if (not bj_cineModeAlreadyIn) then
SetCinematicAudio(true)
bj_cineModeAlreadyIn = true
bj_cineModePriorSpeed = GetGameSpeed()
bj_cineModePriorFogSetting = IsFogEnabled()
bj_cineModePriorMaskSetting = IsFogMaskEnabled()
bj_cineModePriorDawnDusk = IsDawnDuskEnabled()
bj_cineModeSavedSeed = GetRandomInt(0, 1000000)
end
if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
ClearTextMessages()
ShowInterface(false, interfaceFadeTime)
EnableUserControl(false)
EnableOcclusion(false)
SetCineModeVolumeGroupsBJ()
end
SetGameSpeed(bj_CINEMODE_GAMESPEED)
SetMapFlag(MAP_LOCK_SPEED, true)
FogMaskEnable(false)
FogEnable(false)
EnableWorldFogBoundary(false)
EnableDawnDusk(false)
SetRandomSeed(0)
else
bj_cineModeAlreadyIn = false
SetCinematicAudio(false)
if (IsPlayerInForce(GetLocalPlayer(), forForce)) then
ShowInterface(true, interfaceFadeTime)
EnableUserControl(true)
EnableOcclusion(true)
VolumeGroupReset()
EndThematicMusic()
CameraResetSmoothingFactorBJ()
end
SetMapFlag(MAP_LOCK_SPEED, false)
SetGameSpeed(bj_cineModePriorSpeed)
FogMaskEnable(bj_cineModePriorMaskSetting)
FogEnable(bj_cineModePriorFogSetting)
EnableWorldFogBoundary(true)
EnableDawnDusk(bj_cineModePriorDawnDusk)
SetRandomSeed(bj_cineModeSavedSeed)
end
end

function CinematicModeBJ(cineMode, forForce)
CinematicModeExBJ(cineMode, forForce, bj_CINEMODE_INTERFACEFADE)
end

function DisplayCineFilterBJ(flag)
DisplayCineFilter(flag)
end

function CinematicFadeCommonBJ(red, green, blue, duration, tex, startTrans, endTrans)
if (duration == 0) then
startTrans = endTrans
end
EnableUserUI(false)
SetCineFilterTexture(tex)
SetCineFilterBlendMode(BLEND_MODE_BLEND)
SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
SetCineFilterStartUV(0, 0, 1, 1)
SetCineFilterEndUV(0, 0, 1, 1)
SetCineFilterStartColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - startTrans))
SetCineFilterEndColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100.0 - endTrans))
SetCineFilterDuration(duration)
DisplayCineFilter(true)
end

function FinishCinematicFadeBJ()
DestroyTimer(bj_cineFadeFinishTimer)
bj_cineFadeFinishTimer = nil
DisplayCineFilter(false)
EnableUserUI(true)
end

function FinishCinematicFadeAfterBJ(duration)
bj_cineFadeFinishTimer = CreateTimer()
TimerStart(bj_cineFadeFinishTimer, duration, false, FinishCinematicFadeBJ)
end

function ContinueCinematicFadeBJ()
DestroyTimer(bj_cineFadeContinueTimer)
bj_cineFadeContinueTimer = nil
CinematicFadeCommonBJ(bj_cineFadeContinueRed, bj_cineFadeContinueGreen, bj_cineFadeContinueBlue, bj_cineFadeContinueDuration, bj_cineFadeContinueTex, bj_cineFadeContinueTrans, 100)
end

function ContinueCinematicFadeAfterBJ(duration, red, green, blue, trans, tex)
bj_cineFadeContinueRed = red
bj_cineFadeContinueGreen = green
bj_cineFadeContinueBlue = blue
bj_cineFadeContinueTrans = trans
bj_cineFadeContinueDuration = duration
bj_cineFadeContinueTex = tex
bj_cineFadeContinueTimer = CreateTimer()
TimerStart(bj_cineFadeContinueTimer, duration, false, ContinueCinematicFadeBJ)
end

function AbortCinematicFadeBJ()
if (bj_cineFadeContinueTimer ~= nil) then
DestroyTimer(bj_cineFadeContinueTimer)
end
if (bj_cineFadeFinishTimer ~= nil) then
DestroyTimer(bj_cineFadeFinishTimer)
end
end

function CinematicFadeBJ(fadetype, duration, tex, red, green, blue, trans)
if (fadetype == bj_CINEFADETYPE_FADEOUT) then
AbortCinematicFadeBJ()
CinematicFadeCommonBJ(red, green, blue, duration, tex, 100, trans)
elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
AbortCinematicFadeBJ()
CinematicFadeCommonBJ(red, green, blue, duration, tex, trans, 100)
FinishCinematicFadeAfterBJ(duration)
elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then
if (duration > 0) then
AbortCinematicFadeBJ()
CinematicFadeCommonBJ(red, green, blue, duration * 0.5, tex, 100, trans)
ContinueCinematicFadeAfterBJ(duration * 0.5, red, green, blue, trans, tex)
FinishCinematicFadeAfterBJ(duration)
end
else
end
end

function CinematicFilterGenericBJ(duration, bmode, tex, red0, green0, blue0, trans0, red1, green1, blue1, trans1)
AbortCinematicFadeBJ()
SetCineFilterTexture(tex)
SetCineFilterBlendMode(bmode)
SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
SetCineFilterStartUV(0, 0, 1, 1)
SetCineFilterEndUV(0, 0, 1, 1)
SetCineFilterStartColor(PercentTo255(red0), PercentTo255(green0), PercentTo255(blue0), PercentTo255(100.0 - trans0))
SetCineFilterEndColor(PercentTo255(red1), PercentTo255(green1), PercentTo255(blue1), PercentTo255(100.0 - trans1))
SetCineFilterDuration(duration)
DisplayCineFilter(true)
end

function RescueUnitBJ(whichUnit, rescuer, changeColor)
if (IsUnitDeadBJ(whichUnit) or (GetOwningPlayer(whichUnit) == rescuer)) then
return
end
StartSound(bj_rescueSound)
SetUnitOwner(whichUnit, rescuer, changeColor)
UnitAddIndicator(whichUnit, 0, 255, 0, 255)
PingMinimapForPlayer(rescuer, GetUnitX(whichUnit), GetUnitY(whichUnit), bj_RESCUE_PING_TIME)
end

function TriggerActionUnitRescuedBJ()
local theUnit = GetTriggerUnit()

if IsUnitType(theUnit, UNIT_TYPE_STRUCTURE) then
RescueUnitBJ(theUnit, GetOwningPlayer(GetRescuer()), bj_rescueChangeColorBldg)
else
RescueUnitBJ(theUnit, GetOwningPlayer(GetRescuer()), bj_rescueChangeColorUnit)
end
end

function TryInitRescuableTriggersBJ()
local index

if (bj_rescueUnitBehavior == nil) then
bj_rescueUnitBehavior = CreateTrigger()
index = 0
while (true) do
TriggerRegisterPlayerUnitEvent(bj_rescueUnitBehavior, Player(index), EVENT_PLAYER_UNIT_RESCUED, nil)
index = index + 1
if (index == bj_MAX_PLAYER_SLOTS) then break end
end
TriggerAddAction(bj_rescueUnitBehavior, TriggerActionUnitRescuedBJ)
end
end

function SetRescueUnitColorChangeBJ(changeColor)
bj_rescueChangeColorUnit = changeColor
end

function SetRescueBuildingColorChangeBJ(changeColor)
bj_rescueChangeColorBldg = changeColor
end

function MakeUnitRescuableToForceBJEnum()
TryInitRescuableTriggersBJ()
SetUnitRescuable(bj_makeUnitRescuableUnit, GetEnumPlayer(), bj_makeUnitRescuableFlag)
end

function MakeUnitRescuableToForceBJ(whichUnit, isRescuable, whichForce)
bj_makeUnitRescuableUnit = whichUnit
bj_makeUnitRescuableFlag = isRescuable
ForForce(whichForce, MakeUnitRescuableToForceBJEnum)
end

function InitRescuableBehaviorBJ()
local index

index = 0
while (true) do
if (GetPlayerController(Player(index)) == MAP_CONTROL_RESCUABLE) then
TryInitRescuableTriggersBJ()
return
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function SetPlayerTechResearchedSwap(techid, levels, whichPlayer)
SetPlayerTechResearched(whichPlayer, techid, levels)
end

function SetPlayerTechMaxAllowedSwap(techid, maximum, whichPlayer)
SetPlayerTechMaxAllowed(whichPlayer, techid, maximum)
end

function SetPlayerMaxHeroesAllowed(maximum, whichPlayer)
SetPlayerTechMaxAllowed(whichPlayer, FourCC("HERO"), maximum)
end

function GetPlayerTechCountSimple(techid, whichPlayer)
return GetPlayerTechCount(whichPlayer, techid, true)
end

function GetPlayerTechMaxAllowedSwap(techid, whichPlayer)
return GetPlayerTechMaxAllowed(whichPlayer, techid)
end

function SetPlayerAbilityAvailableBJ(avail, abilid, whichPlayer)
SetPlayerAbilityAvailable(whichPlayer, abilid, avail)
end

function SetCampaignMenuRaceBJ(campaignNumber)
if (campaignNumber == bj_CAMPAIGN_INDEX_T) then
SetCampaignMenuRace(RACE_OTHER)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_H) then
SetCampaignMenuRace(RACE_HUMAN)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_U) then
SetCampaignMenuRace(RACE_UNDEAD)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_O) then
SetCampaignMenuRace(RACE_ORC)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_N) then
SetCampaignMenuRace(RACE_NIGHTELF)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XN) then
SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XN)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XH) then
SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XH)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XU) then
SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XU)
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XO) then
SetCampaignMenuRaceEx(bj_CAMPAIGN_OFFSET_XO)
else
end
end

function SetMissionAvailableBJ(available, missionIndex)
local campaignNumber = missionIndex // 1000
local missionNumber = missionIndex - campaignNumber * 1000

SetMissionAvailable(campaignNumber, missionNumber, available)
end

function SetCampaignAvailableBJ(available, campaignNumber)
local campaignOffset

if (campaignNumber == bj_CAMPAIGN_INDEX_H) then
SetTutorialCleared(true)
end
if (campaignNumber == bj_CAMPAIGN_INDEX_XN) then
campaignOffset = bj_CAMPAIGN_OFFSET_XN
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XH) then
campaignOffset = bj_CAMPAIGN_OFFSET_XH
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XU) then
campaignOffset = bj_CAMPAIGN_OFFSET_XU
elseif (campaignNumber == bj_CAMPAIGN_INDEX_XO) then
campaignOffset = bj_CAMPAIGN_OFFSET_XO
else
campaignOffset = campaignNumber
end
SetCampaignAvailable(campaignOffset, available)
SetCampaignMenuRaceBJ(campaignNumber)
ForceCampaignSelectScreen()
end

function SetCinematicAvailableBJ(available, cinematicIndex)
if (cinematicIndex == bj_CINEMATICINDEX_TOP) then
SetOpCinematicAvailable(bj_CAMPAIGN_INDEX_T, available)
PlayCinematic("TutorialOp")
elseif (cinematicIndex == bj_CINEMATICINDEX_HOP) then
SetOpCinematicAvailable(bj_CAMPAIGN_INDEX_H, available)
PlayCinematic("HumanOp")
elseif (cinematicIndex == bj_CINEMATICINDEX_HED) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_H, available)
PlayCinematic("HumanEd")
elseif (cinematicIndex == bj_CINEMATICINDEX_OOP) then
SetOpCinematicAvailable(bj_CAMPAIGN_INDEX_O, available)
PlayCinematic("OrcOp")
elseif (cinematicIndex == bj_CINEMATICINDEX_OED) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_O, available)
PlayCinematic("OrcEd")
elseif (cinematicIndex == bj_CINEMATICINDEX_UOP) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_U, available)
PlayCinematic("UndeadOp")
elseif (cinematicIndex == bj_CINEMATICINDEX_UED) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_U, available)
PlayCinematic("UndeadEd")
elseif (cinematicIndex == bj_CINEMATICINDEX_NOP) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_N, available)
PlayCinematic("NightElfOp")
elseif (cinematicIndex == bj_CINEMATICINDEX_NED) then
SetEdCinematicAvailable(bj_CAMPAIGN_INDEX_N, available)
PlayCinematic("NightElfEd")
elseif (cinematicIndex == bj_CINEMATICINDEX_XOP) then
SetOpCinematicAvailable(bj_CAMPAIGN_OFFSET_XN, available)
elseif (cinematicIndex == bj_CINEMATICINDEX_XED) then
SetEdCinematicAvailable(bj_CAMPAIGN_OFFSET_XU, available)
PlayCinematic("OutroX")
else
end
end

function InitGameCacheBJ(campaignFile)
bj_lastCreatedGameCache = InitGameCache(campaignFile)
return bj_lastCreatedGameCache
end

function SaveGameCacheBJ(cache)
return SaveGameCache(cache)
end

function GetLastCreatedGameCacheBJ()
return bj_lastCreatedGameCache
end

function InitHashtableBJ()
bj_lastCreatedHashtable = InitHashtable()
return bj_lastCreatedHashtable
end

function GetLastCreatedHashtableBJ()
return bj_lastCreatedHashtable
end

function StoreRealBJ(value, key, missionKey, cache)
StoreReal(cache, missionKey, key, value)
end

function StoreIntegerBJ(value, key, missionKey, cache)
StoreInteger(cache, missionKey, key, value)
end

function StoreBooleanBJ(value, key, missionKey, cache)
StoreBoolean(cache, missionKey, key, value)
end

function StoreStringBJ(value, key, missionKey, cache)
return StoreString(cache, missionKey, key, value)
end

function StoreUnitBJ(whichUnit, key, missionKey, cache)
return StoreUnit(cache, missionKey, key, whichUnit)
end

function SaveRealBJ(value, key, missionKey, table)
SaveReal(table, missionKey, key, value)
end

function SaveIntegerBJ(value, key, missionKey, table)
SaveInteger(table, missionKey, key, value)
end

function SaveBooleanBJ(value, key, missionKey, table)
SaveBoolean(table, missionKey, key, value)
end

function SaveStringBJ(value, key, missionKey, table)
return SaveStr(table, missionKey, key, value)
end

function SavePlayerHandleBJ(whichPlayer, key, missionKey, table)
return SavePlayerHandle(table, missionKey, key, whichPlayer)
end

function SaveWidgetHandleBJ(whichWidget, key, missionKey, table)
return SaveWidgetHandle(table, missionKey, key, whichWidget)
end

function SaveDestructableHandleBJ(whichDestructable, key, missionKey, table)
return SaveDestructableHandle(table, missionKey, key, whichDestructable)
end

function SaveItemHandleBJ(whichItem, key, missionKey, table)
return SaveItemHandle(table, missionKey, key, whichItem)
end

function SaveUnitHandleBJ(whichUnit, key, missionKey, table)
return SaveUnitHandle(table, missionKey, key, whichUnit)
end

function SaveAbilityHandleBJ(whichAbility, key, missionKey, table)
return SaveAbilityHandle(table, missionKey, key, whichAbility)
end

function SaveTimerHandleBJ(whichTimer, key, missionKey, table)
return SaveTimerHandle(table, missionKey, key, whichTimer)
end

function SaveTriggerHandleBJ(whichTrigger, key, missionKey, table)
return SaveTriggerHandle(table, missionKey, key, whichTrigger)
end

function SaveTriggerConditionHandleBJ(whichTriggercondition, key, missionKey, table)
return SaveTriggerConditionHandle(table, missionKey, key, whichTriggercondition)
end

function SaveTriggerActionHandleBJ(whichTriggeraction, key, missionKey, table)
return SaveTriggerActionHandle(table, missionKey, key, whichTriggeraction)
end

function SaveTriggerEventHandleBJ(whichEvent, key, missionKey, table)
return SaveTriggerEventHandle(table, missionKey, key, whichEvent)
end

function SaveForceHandleBJ(whichForce, key, missionKey, table)
return SaveForceHandle(table, missionKey, key, whichForce)
end

function SaveGroupHandleBJ(whichGroup, key, missionKey, table)
return SaveGroupHandle(table, missionKey, key, whichGroup)
end

function SaveLocationHandleBJ(whichLocation, key, missionKey, table)
return SaveLocationHandle(table, missionKey, key, whichLocation)
end

function SaveRectHandleBJ(whichRect, key, missionKey, table)
return SaveRectHandle(table, missionKey, key, whichRect)
end

function SaveBooleanExprHandleBJ(whichBoolexpr, key, missionKey, table)
return SaveBooleanExprHandle(table, missionKey, key, whichBoolexpr)
end

function SaveSoundHandleBJ(whichSound, key, missionKey, table)
return SaveSoundHandle(table, missionKey, key, whichSound)
end

function SaveEffectHandleBJ(whichEffect, key, missionKey, table)
return SaveEffectHandle(table, missionKey, key, whichEffect)
end

function SaveUnitPoolHandleBJ(whichUnitpool, key, missionKey, table)
return SaveUnitPoolHandle(table, missionKey, key, whichUnitpool)
end

function SaveItemPoolHandleBJ(whichItempool, key, missionKey, table)
return SaveItemPoolHandle(table, missionKey, key, whichItempool)
end

function SaveQuestHandleBJ(whichQuest, key, missionKey, table)
return SaveQuestHandle(table, missionKey, key, whichQuest)
end

function SaveQuestItemHandleBJ(whichQuestitem, key, missionKey, table)
return SaveQuestItemHandle(table, missionKey, key, whichQuestitem)
end

function SaveDefeatConditionHandleBJ(whichDefeatcondition, key, missionKey, table)
return SaveDefeatConditionHandle(table, missionKey, key, whichDefeatcondition)
end

function SaveTimerDialogHandleBJ(whichTimerdialog, key, missionKey, table)
return SaveTimerDialogHandle(table, missionKey, key, whichTimerdialog)
end

function SaveLeaderboardHandleBJ(whichLeaderboard, key, missionKey, table)
return SaveLeaderboardHandle(table, missionKey, key, whichLeaderboard)
end

function SaveMultiboardHandleBJ(whichMultiboard, key, missionKey, table)
return SaveMultiboardHandle(table, missionKey, key, whichMultiboard)
end

function SaveMultiboardItemHandleBJ(whichMultiboarditem, key, missionKey, table)
return SaveMultiboardItemHandle(table, missionKey, key, whichMultiboarditem)
end

function SaveTrackableHandleBJ(whichTrackable, key, missionKey, table)
return SaveTrackableHandle(table, missionKey, key, whichTrackable)
end

function SaveDialogHandleBJ(whichDialog, key, missionKey, table)
return SaveDialogHandle(table, missionKey, key, whichDialog)
end

function SaveButtonHandleBJ(whichButton, key, missionKey, table)
return SaveButtonHandle(table, missionKey, key, whichButton)
end

function SaveTextTagHandleBJ(whichTexttag, key, missionKey, table)
return SaveTextTagHandle(table, missionKey, key, whichTexttag)
end

function SaveLightningHandleBJ(whichLightning, key, missionKey, table)
return SaveLightningHandle(table, missionKey, key, whichLightning)
end

function SaveImageHandleBJ(whichImage, key, missionKey, table)
return SaveImageHandle(table, missionKey, key, whichImage)
end

function SaveUbersplatHandleBJ(whichUbersplat, key, missionKey, table)
return SaveUbersplatHandle(table, missionKey, key, whichUbersplat)
end

function SaveRegionHandleBJ(whichRegion, key, missionKey, table)
return SaveRegionHandle(table, missionKey, key, whichRegion)
end

function SaveFogStateHandleBJ(whichFogState, key, missionKey, table)
return SaveFogStateHandle(table, missionKey, key, whichFogState)
end

function SaveFogModifierHandleBJ(whichFogModifier, key, missionKey, table)
return SaveFogModifierHandle(table, missionKey, key, whichFogModifier)
end

function SaveAgentHandleBJ(whichAgent, key, missionKey, table)
return SaveAgentHandle(table, missionKey, key, whichAgent)
end

function SaveHashtableHandleBJ(whichHashtable, key, missionKey, table)
return SaveHashtableHandle(table, missionKey, key, whichHashtable)
end

function GetStoredRealBJ(key, missionKey, cache)
return GetStoredReal(cache, missionKey, key)
end

function GetStoredIntegerBJ(key, missionKey, cache)
return GetStoredInteger(cache, missionKey, key)
end

function GetStoredBooleanBJ(key, missionKey, cache)
return GetStoredBoolean(cache, missionKey, key)
end

function GetStoredStringBJ(key, missionKey, cache)
local s

s = GetStoredString(cache, missionKey, key)
if (s == "") then
return ""
else
return s
end
end

function LoadRealBJ(key, missionKey, table)
return LoadReal(table, missionKey, key)
end

function LoadIntegerBJ(key, missionKey, table)
return LoadInteger(table, missionKey, key)
end

function LoadBooleanBJ(key, missionKey, table)
return LoadBoolean(table, missionKey, key)
end

function LoadStringBJ(key, missionKey, table)
local s

s = LoadStr(table, missionKey, key)
if (s == "") then
return ""
else
return s
end
end

function LoadPlayerHandleBJ(key, missionKey, table)
return LoadPlayerHandle(table, missionKey, key)
end

function LoadWidgetHandleBJ(key, missionKey, table)
return LoadWidgetHandle(table, missionKey, key)
end

function LoadDestructableHandleBJ(key, missionKey, table)
return LoadDestructableHandle(table, missionKey, key)
end

function LoadItemHandleBJ(key, missionKey, table)
return LoadItemHandle(table, missionKey, key)
end

function LoadUnitHandleBJ(key, missionKey, table)
return LoadUnitHandle(table, missionKey, key)
end

function LoadAbilityHandleBJ(key, missionKey, table)
return LoadAbilityHandle(table, missionKey, key)
end

function LoadTimerHandleBJ(key, missionKey, table)
return LoadTimerHandle(table, missionKey, key)
end

function LoadTriggerHandleBJ(key, missionKey, table)
return LoadTriggerHandle(table, missionKey, key)
end

function LoadTriggerConditionHandleBJ(key, missionKey, table)
return LoadTriggerConditionHandle(table, missionKey, key)
end

function LoadTriggerActionHandleBJ(key, missionKey, table)
return LoadTriggerActionHandle(table, missionKey, key)
end

function LoadTriggerEventHandleBJ(key, missionKey, table)
return LoadTriggerEventHandle(table, missionKey, key)
end

function LoadForceHandleBJ(key, missionKey, table)
return LoadForceHandle(table, missionKey, key)
end

function LoadGroupHandleBJ(key, missionKey, table)
return LoadGroupHandle(table, missionKey, key)
end

function LoadLocationHandleBJ(key, missionKey, table)
return LoadLocationHandle(table, missionKey, key)
end

function LoadRectHandleBJ(key, missionKey, table)
return LoadRectHandle(table, missionKey, key)
end

function LoadBooleanExprHandleBJ(key, missionKey, table)
return LoadBooleanExprHandle(table, missionKey, key)
end

function LoadSoundHandleBJ(key, missionKey, table)
return LoadSoundHandle(table, missionKey, key)
end

function LoadEffectHandleBJ(key, missionKey, table)
return LoadEffectHandle(table, missionKey, key)
end

function LoadUnitPoolHandleBJ(key, missionKey, table)
return LoadUnitPoolHandle(table, missionKey, key)
end

function LoadItemPoolHandleBJ(key, missionKey, table)
return LoadItemPoolHandle(table, missionKey, key)
end

function LoadQuestHandleBJ(key, missionKey, table)
return LoadQuestHandle(table, missionKey, key)
end

function LoadQuestItemHandleBJ(key, missionKey, table)
return LoadQuestItemHandle(table, missionKey, key)
end

function LoadDefeatConditionHandleBJ(key, missionKey, table)
return LoadDefeatConditionHandle(table, missionKey, key)
end

function LoadTimerDialogHandleBJ(key, missionKey, table)
return LoadTimerDialogHandle(table, missionKey, key)
end

function LoadLeaderboardHandleBJ(key, missionKey, table)
return LoadLeaderboardHandle(table, missionKey, key)
end

function LoadMultiboardHandleBJ(key, missionKey, table)
return LoadMultiboardHandle(table, missionKey, key)
end

function LoadMultiboardItemHandleBJ(key, missionKey, table)
return LoadMultiboardItemHandle(table, missionKey, key)
end

function LoadTrackableHandleBJ(key, missionKey, table)
return LoadTrackableHandle(table, missionKey, key)
end

function LoadDialogHandleBJ(key, missionKey, table)
return LoadDialogHandle(table, missionKey, key)
end

function LoadButtonHandleBJ(key, missionKey, table)
return LoadButtonHandle(table, missionKey, key)
end

function LoadTextTagHandleBJ(key, missionKey, table)
return LoadTextTagHandle(table, missionKey, key)
end

function LoadLightningHandleBJ(key, missionKey, table)
return LoadLightningHandle(table, missionKey, key)
end

function LoadImageHandleBJ(key, missionKey, table)
return LoadImageHandle(table, missionKey, key)
end

function LoadUbersplatHandleBJ(key, missionKey, table)
return LoadUbersplatHandle(table, missionKey, key)
end

function LoadRegionHandleBJ(key, missionKey, table)
return LoadRegionHandle(table, missionKey, key)
end

function LoadFogStateHandleBJ(key, missionKey, table)
return LoadFogStateHandle(table, missionKey, key)
end

function LoadFogModifierHandleBJ(key, missionKey, table)
return LoadFogModifierHandle(table, missionKey, key)
end

function LoadHashtableHandleBJ(key, missionKey, table)
return LoadHashtableHandle(table, missionKey, key)
end

function RestoreUnitLocFacingAngleBJ(key, missionKey, cache, forWhichPlayer, loc, facing)
bj_lastLoadedUnit = RestoreUnit(cache, missionKey, key, forWhichPlayer, GetLocationX(loc), GetLocationY(loc), facing)
return bj_lastLoadedUnit
end

function RestoreUnitLocFacingPointBJ(key, missionKey, cache, forWhichPlayer, loc, lookAt)
return RestoreUnitLocFacingAngleBJ(key, missionKey, cache, forWhichPlayer, loc, AngleBetweenPoints(loc, lookAt))
end

function GetLastRestoredUnitBJ()
return bj_lastLoadedUnit
end

function FlushGameCacheBJ(cache)
FlushGameCache(cache)
end

function FlushStoredMissionBJ(missionKey, cache)
FlushStoredMission(cache, missionKey)
end

function FlushParentHashtableBJ(table)
FlushParentHashtable(table)
end

function FlushChildHashtableBJ(missionKey, table)
FlushChildHashtable(table, missionKey)
end

function HaveStoredValue(key, valueType, missionKey, cache)
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
return false
end
end

function HaveSavedValue(key, valueType, missionKey, table)
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
return false
end
end

function ShowCustomCampaignButton(show, whichButton)
SetCustomCampaignButtonVisible(whichButton - 1, show)
end

function IsCustomCampaignButtonVisibile(whichButton)
return GetCustomCampaignButtonVisible(whichButton - 1)
end

function SaveGameCheckPointBJ(mapSaveName, doCheckpointHint)
SaveGameCheckpoint(mapSaveName, doCheckpointHint)
end

function LoadGameBJ(loadFileName, doScoreScreen)
LoadGame(loadFileName, doScoreScreen)
end

function SaveAndChangeLevelBJ(saveFileName, newLevel, doScoreScreen)
SaveGame(saveFileName)
ChangeLevel(newLevel, doScoreScreen)
end

function SaveAndLoadGameBJ(saveFileName, loadFileName, doScoreScreen)
SaveGame(saveFileName)
LoadGame(loadFileName, doScoreScreen)
end

function RenameSaveDirectoryBJ(sourceDirName, destDirName)
return RenameSaveDirectory(sourceDirName, destDirName)
end

function RemoveSaveDirectoryBJ(sourceDirName)
return RemoveSaveDirectory(sourceDirName)
end

function CopySaveGameBJ(sourceSaveName, destSaveName)
return CopySaveGame(sourceSaveName, destSaveName)
end

function GetPlayerStartLocationX(whichPlayer)
return GetStartLocationX(GetPlayerStartLocation(whichPlayer))
end

function GetPlayerStartLocationY(whichPlayer)
return GetStartLocationY(GetPlayerStartLocation(whichPlayer))
end

function GetPlayerStartLocationLoc(whichPlayer)
return GetStartLocationLoc(GetPlayerStartLocation(whichPlayer))
end

function GetRectCenter(whichRect)
return Location(GetRectCenterX(whichRect), GetRectCenterY(whichRect))
end

function IsPlayerSlotState(whichPlayer, whichState)
return GetPlayerSlotState(whichPlayer) == whichState
end

function GetFadeFromSeconds(seconds)
if (seconds ~= 0) then
return 128 // R2I(seconds)
end
return 10000
end

function GetFadeFromSecondsAsReal(seconds)
if (seconds ~= 0) then
return 128.00 / seconds
end
return 10000.00
end

function AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta)
SetPlayerState(whichPlayer, whichPlayerState, GetPlayerState(whichPlayer, whichPlayerState) + delta)
end

function AdjustPlayerStateBJ(delta, whichPlayer, whichPlayerState)
if (delta > 0) then
if (whichPlayerState == PLAYER_STATE_RESOURCE_GOLD) then
AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_GOLD_GATHERED, delta)
elseif (whichPlayerState == PLAYER_STATE_RESOURCE_LUMBER) then
AdjustPlayerStateSimpleBJ(whichPlayer, PLAYER_STATE_LUMBER_GATHERED, delta)
end
end
AdjustPlayerStateSimpleBJ(whichPlayer, whichPlayerState, delta)
end

function SetPlayerStateBJ(whichPlayer, whichPlayerState, value)
local oldValue = GetPlayerState(whichPlayer, whichPlayerState)

AdjustPlayerStateBJ(value - oldValue, whichPlayer, whichPlayerState)
end

function SetPlayerFlagBJ(whichPlayerFlag, flag, whichPlayer)
SetPlayerState(whichPlayer, whichPlayerFlag, IntegerTertiaryOp(flag, 1, 0))
end

function SetPlayerTaxRateBJ(rate, whichResource, sourcePlayer, otherPlayer)
SetPlayerTaxRate(sourcePlayer, otherPlayer, whichResource, rate)
end

function GetPlayerTaxRateBJ(whichResource, sourcePlayer, otherPlayer)
return GetPlayerTaxRate(sourcePlayer, otherPlayer, whichResource)
end

function IsPlayerFlagSetBJ(whichPlayerFlag, whichPlayer)
return GetPlayerState(whichPlayer, whichPlayerFlag) == 1
end

function AddResourceAmountBJ(delta, whichUnit)
AddResourceAmount(whichUnit, delta)
end

function GetConvertedPlayerId(whichPlayer)
return GetPlayerId(whichPlayer) + 1
end

function ConvertedPlayer(convertedPlayerId)
return Player(convertedPlayerId - 1)
end

function GetRectWidthBJ(r)
return GetRectMaxX(r) - GetRectMinX(r)
end

function GetRectHeightBJ(r)
return GetRectMaxY(r) - GetRectMinY(r)
end

function BlightGoldMineForPlayerBJ(goldMine, whichPlayer)
local mineX
local mineY
local mineGold
local newMine

if GetUnitTypeId(goldMine) ~= FourCC("ngol") then
return nil
end
mineX = GetUnitX(goldMine)
mineY = GetUnitY(goldMine)
mineGold = GetResourceAmount(goldMine)
RemoveUnit(goldMine)
newMine = CreateBlightedGoldmine(whichPlayer, mineX, mineY, bj_UNIT_FACING)
SetResourceAmount(newMine, mineGold)
return newMine
end

function BlightGoldMineForPlayer(goldMine, whichPlayer)
bj_lastHauntedGoldMine = BlightGoldMineForPlayerBJ(goldMine, whichPlayer)
return bj_lastHauntedGoldMine
end

function GetLastHauntedGoldMine()
return bj_lastHauntedGoldMine
end

function IsPointBlightedBJ(where)
return IsPointBlighted(GetLocationX(where), GetLocationY(where))
end

function SetPlayerColorBJEnum()
SetUnitColor(GetEnumUnit(), bj_setPlayerTargetColor)
end

function SetPlayerColorBJ(whichPlayer, color, changeExisting)
local g

SetPlayerColor(whichPlayer, color)
if changeExisting then
bj_setPlayerTargetColor = color
g = CreateGroup()
GroupEnumUnitsOfPlayer(g, whichPlayer, nil)
ForGroup(g, SetPlayerColorBJEnum)
DestroyGroup(g)
end
end

function SetPlayerUnitAvailableBJ(unitId, allowed, whichPlayer)
if allowed then
SetPlayerTechMaxAllowed(whichPlayer, unitId, -1)
else
SetPlayerTechMaxAllowed(whichPlayer, unitId, 0)
end
end

function LockGameSpeedBJ()
SetMapFlag(MAP_LOCK_SPEED, true)
end

function UnlockGameSpeedBJ()
SetMapFlag(MAP_LOCK_SPEED, false)
end

function IssueTargetOrderBJ(whichUnit, order, targetWidget)
return IssueTargetOrder(whichUnit, order, targetWidget)
end

function IssuePointOrderLocBJ(whichUnit, order, whichLocation)
return IssuePointOrderLoc(whichUnit, order, whichLocation)
end

function IssueTargetDestructableOrder(whichUnit, order, targetWidget)
return IssueTargetOrder(whichUnit, order, targetWidget)
end

function IssueTargetItemOrder(whichUnit, order, targetWidget)
return IssueTargetOrder(whichUnit, order, targetWidget)
end

function IssueImmediateOrderBJ(whichUnit, order)
return IssueImmediateOrder(whichUnit, order)
end

function GroupTargetOrderBJ(whichGroup, order, targetWidget)
return GroupTargetOrder(whichGroup, order, targetWidget)
end

function GroupPointOrderLocBJ(whichGroup, order, whichLocation)
return GroupPointOrderLoc(whichGroup, order, whichLocation)
end

function GroupImmediateOrderBJ(whichGroup, order)
return GroupImmediateOrder(whichGroup, order)
end

function GroupTargetDestructableOrder(whichGroup, order, targetWidget)
return GroupTargetOrder(whichGroup, order, targetWidget)
end

function GroupTargetItemOrder(whichGroup, order, targetWidget)
return GroupTargetOrder(whichGroup, order, targetWidget)
end

function GetDyingDestructable()
return GetTriggerDestructable()
end

function SetUnitRallyPoint(whichUnit, targPos)
IssuePointOrderLocBJ(whichUnit, "setrally", targPos)
end

function SetUnitRallyUnit(whichUnit, targUnit)
IssueTargetOrder(whichUnit, "setrally", targUnit)
end

function SetUnitRallyDestructable(whichUnit, targDest)
IssueTargetOrder(whichUnit, "setrally", targDest)
end

function SaveDyingWidget()
bj_lastDyingWidget = GetTriggerWidget()
end

function SetBlightRectBJ(addBlight, whichPlayer, r)
SetBlightRect(whichPlayer, r, addBlight)
end

function SetBlightRadiusLocBJ(addBlight, whichPlayer, loc, radius)
SetBlightLoc(whichPlayer, loc, radius, addBlight)
end

function GetAbilityName(abilcode)
return GetObjectName(abilcode)
end

function MeleeStartingVisibility()
SetFloatGameState(GAME_STATE_TIME_OF_DAY, bj_MELEE_STARTING_TOD)
end

function MeleeStartingResources()
local index
local indexPlayer
local v
local startingGold
local startingLumber

v = VersionGet()
if (v == VERSION_REIGN_OF_CHAOS) then
startingGold = bj_MELEE_STARTING_GOLD_V0
startingLumber = bj_MELEE_STARTING_LUMBER_V0
else
startingGold = bj_MELEE_STARTING_GOLD_V1
startingLumber = bj_MELEE_STARTING_LUMBER_V1
end
index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_GOLD, startingGold)
SetPlayerState(indexPlayer, PLAYER_STATE_RESOURCE_LUMBER, startingLumber)
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function ReducePlayerTechMaxAllowed(whichPlayer, techId, limit)
local oldMax = GetPlayerTechMaxAllowed(whichPlayer, techId)

if (oldMax < 0 or oldMax > limit) then
SetPlayerTechMaxAllowed(whichPlayer, techId, limit)
end
end

function MeleeStartingHeroLimit()
local index

index = 0
while (true) do
SetPlayerMaxHeroesAllowed(bj_MELEE_HERO_LIMIT, Player(index))
ReducePlayerTechMaxAllowed(Player(index), FourCC("Hamg"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Hmkg"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Hpal"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Hblm"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Obla"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ofar"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Otch"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Oshd"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Edem"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ekee"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Emoo"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ewar"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Udea"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Udre"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ulic"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ucrl"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Npbm"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nbrn"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nngs"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nplh"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nbst"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nalc"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Ntin"), bj_MELEE_HERO_TYPE_LIMIT)
ReducePlayerTechMaxAllowed(Player(index), FourCC("Nfir"), bj_MELEE_HERO_TYPE_LIMIT)
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function MeleeTrainedUnitIsHeroBJFilter()
return IsUnitType(GetFilterUnit(), UNIT_TYPE_HERO)
end

function MeleeGrantItemsToHero(whichUnit)
local owner = GetPlayerId(GetOwningPlayer(whichUnit))

if (bj_meleeTwinkedHeroes[owner] < bj_MELEE_MAX_TWINKED_HEROES) then
UnitAddItemById(whichUnit, FourCC("stwp"))
bj_meleeTwinkedHeroes[owner] = bj_meleeTwinkedHeroes[owner] + 1
end
end

function MeleeGrantItemsToTrainedHero()
MeleeGrantItemsToHero(GetTrainedUnit())
end

function MeleeGrantItemsToHiredHero()
MeleeGrantItemsToHero(GetSoldUnit())
end

function MeleeGrantHeroItems()
local index
local trig

index = 0
while (true) do
bj_meleeTwinkedHeroes[index] = 0
index = index + 1
if (index == bj_MAX_PLAYER_SLOTS) then break end
end
index = 0
while (true) do
trig = CreateTrigger()
TriggerRegisterPlayerUnitEvent(trig, Player(index), EVENT_PLAYER_UNIT_TRAIN_FINISH, filterMeleeTrainedUnitIsHeroBJ)
TriggerAddAction(trig, MeleeGrantItemsToTrainedHero)
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
trig = CreateTrigger()
TriggerRegisterPlayerUnitEvent(trig, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_SELL, filterMeleeTrainedUnitIsHeroBJ)
TriggerAddAction(trig, MeleeGrantItemsToHiredHero)
bj_meleeGrantHeroItems = true
end

function MeleeClearExcessUnit()
local theUnit = GetEnumUnit()
local owner = GetPlayerId(GetOwningPlayer(theUnit))

if (owner == PLAYER_NEUTRAL_AGGRESSIVE) then
RemoveUnit(GetEnumUnit())
elseif (owner == PLAYER_NEUTRAL_PASSIVE) then
if not IsUnitType(theUnit, UNIT_TYPE_STRUCTURE) then
RemoveUnit(GetEnumUnit())
end
end
end

function MeleeClearNearbyUnits(x, y, range)
local nearbyUnits

nearbyUnits = CreateGroup()
GroupEnumUnitsInRange(nearbyUnits, x, y, range, nil)
ForGroup(nearbyUnits, MeleeClearExcessUnit)
DestroyGroup(nearbyUnits)
end

function MeleeClearExcessUnits()
local index
local locX
local locY
local indexPlayer

index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
locX = GetStartLocationX(GetPlayerStartLocation(indexPlayer))
locY = GetStartLocationY(GetPlayerStartLocation(indexPlayer))
MeleeClearNearbyUnits(locX, locY, bj_MELEE_CLEAR_UNITS_RADIUS)
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function MeleeEnumFindNearestMine()
local enumUnit = GetEnumUnit()
local dist
local unitLoc

if (GetUnitTypeId(enumUnit) == FourCC("ngol")) then
unitLoc = GetUnitLoc(enumUnit)
dist = DistanceBetweenPoints(unitLoc, bj_meleeNearestMineToLoc)
RemoveLocation(unitLoc)
if ((bj_meleeNearestMineDist < 0) or (dist < bj_meleeNearestMineDist)) then
bj_meleeNearestMine = enumUnit
bj_meleeNearestMineDist = dist
end
end
end

function MeleeFindNearestMine(src, range)
local nearbyMines

bj_meleeNearestMine = nil
bj_meleeNearestMineDist = -1
bj_meleeNearestMineToLoc = src
nearbyMines = CreateGroup()
GroupEnumUnitsInRangeOfLoc(nearbyMines, src, range, nil)
ForGroup(nearbyMines, MeleeEnumFindNearestMine)
DestroyGroup(nearbyMines)
return bj_meleeNearestMine
end

function MeleeRandomHeroLoc(p, id1, id2, id3, id4, loc)
local hero = nil
local roll
local pick
local v

v = VersionGet()
if (v == VERSION_REIGN_OF_CHAOS) then
roll = GetRandomInt(1, 3)
else
roll = GetRandomInt(1, 4)
end
if roll == 1 then
pick = id1
elseif roll == 2 then
pick = id2
elseif roll == 3 then
pick = id3
elseif roll == 4 then
pick = id4
else
pick = id1
end
hero = CreateUnitAtLoc(p, pick, loc, bj_UNIT_FACING)
if bj_meleeGrantHeroItems then
MeleeGrantItemsToHero(hero)
end
return hero
end

function MeleeGetProjectedLoc(src, targ, distance, deltaAngle)
local srcX = GetLocationX(src)
local srcY = GetLocationY(src)
local direction = Atan2(GetLocationY(targ) - srcY, GetLocationX(targ) - srcX) + deltaAngle

return Location(srcX + distance * Cos(direction), srcY + distance * Sin(direction))
end

function MeleeGetNearestValueWithin(val, minVal, maxVal)
if (val < minVal) then
return minVal
elseif (val > maxVal) then
return maxVal
else
return val
end
end

function MeleeGetLocWithinRect(src, r)
local withinX = MeleeGetNearestValueWithin(GetLocationX(src), GetRectMinX(r), GetRectMaxX(r))
local withinY = MeleeGetNearestValueWithin(GetLocationY(src), GetRectMinY(r), GetRectMaxY(r))

return Location(withinX, withinY)
end

function MeleeStartingUnitsHuman(whichPlayer, startLoc, doHeroes, doCamera, doPreload)
local useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local unitSpacing = 64.00
local nearestMine
local nearMineLoc
local heroLoc
local peonX
local peonY
local townHall = nil

if (doPreload) then
Preloader("scripts\\HumanMelee.pld")
end
nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine ~= nil) then
townHall = CreateUnitAtLoc(whichPlayer, FourCC("htow"), startLoc, bj_UNIT_FACING)
nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
peonX = GetLocationX(nearMineLoc)
peonY = GetLocationY(nearMineLoc)
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
townHall = CreateUnitAtLoc(whichPlayer, FourCC("htow"), startLoc, bj_UNIT_FACING)
peonX = GetLocationX(startLoc)
peonY = GetLocationY(startLoc) - 224.00
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("hpea"), peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
end
if (townHall ~= nil) then
UnitAddAbilityBJ(FourCC("Amic"), townHall)
UnitMakeAbilityPermanentBJ(true, FourCC("Amic"), townHall)
end
if (doHeroes) then
if useRandomHero then
MeleeRandomHeroLoc(whichPlayer, FourCC("Hamg"), FourCC("Hmkg"), FourCC("Hpal"), FourCC("Hblm"), heroLoc)
else
SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
end
end
if (doCamera) then
SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
end
end

function MeleeStartingUnitsOrc(whichPlayer, startLoc, doHeroes, doCamera, doPreload)
local useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local unitSpacing = 64.00
local nearestMine
local nearMineLoc
local heroLoc
local peonX
local peonY

if (doPreload) then
Preloader("scripts\\OrcMelee.pld")
end
nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine ~= nil) then
CreateUnitAtLoc(whichPlayer, FourCC("ogre"), startLoc, bj_UNIT_FACING)
nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
peonX = GetLocationX(nearMineLoc)
peonY = GetLocationY(nearMineLoc)
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
CreateUnitAtLoc(whichPlayer, FourCC("ogre"), startLoc, bj_UNIT_FACING)
peonX = GetLocationX(startLoc)
peonY = GetLocationY(startLoc) - 224.00
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("opeo"), peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
end
if (doHeroes) then
if useRandomHero then
MeleeRandomHeroLoc(whichPlayer, FourCC("Obla"), FourCC("Ofar"), FourCC("Otch"), FourCC("Oshd"), heroLoc)
else
SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
end
end
if (doCamera) then
SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
end
end

function MeleeStartingUnitsUndead(whichPlayer, startLoc, doHeroes, doCamera, doPreload)
local useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local unitSpacing = 64.00
local nearestMine
local nearMineLoc
local nearTownLoc
local heroLoc
local peonX
local peonY
local ghoulX
local ghoulY

if (doPreload) then
Preloader("scripts\\UndeadMelee.pld")
end
nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine ~= nil) then
CreateUnitAtLoc(whichPlayer, FourCC("unpl"), startLoc, bj_UNIT_FACING)
nearestMine = BlightGoldMineForPlayerBJ(nearestMine, whichPlayer)
nearTownLoc = MeleeGetProjectedLoc(startLoc, GetUnitLoc(nearestMine), 288, 0)
ghoulX = GetLocationX(nearTownLoc)
ghoulY = GetLocationY(nearTownLoc)
bj_ghoul[GetPlayerId(whichPlayer)] = CreateUnit(whichPlayer, FourCC("ugho"), ghoulX + 0.00 * unitSpacing, ghoulY + 0.00 * unitSpacing, bj_UNIT_FACING)
nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
peonX = GetLocationX(nearMineLoc)
peonY = GetLocationY(nearMineLoc)
CreateUnit(whichPlayer, FourCC("uaco"), peonX + 0.00 * unitSpacing, peonY + 0.50 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("uaco"), peonX + 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("uaco"), peonX - 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
SetBlightLoc(whichPlayer, nearMineLoc, 768, true)
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
CreateUnitAtLoc(whichPlayer, FourCC("unpl"), startLoc, bj_UNIT_FACING)
peonX = GetLocationX(startLoc)
peonY = GetLocationY(startLoc) - 224.00
CreateUnit(whichPlayer, FourCC("uaco"), peonX - 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("uaco"), peonX - 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("uaco"), peonX + 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ugho"), peonX + 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
SetBlightLoc(whichPlayer, startLoc, 768, true)
heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
end
if (doHeroes) then
if useRandomHero then
MeleeRandomHeroLoc(whichPlayer, FourCC("Udea"), FourCC("Udre"), FourCC("Ulic"), FourCC("Ucrl"), heroLoc)
else
SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
end
end
if (doCamera) then
SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
end
end

function MeleeStartingUnitsNightElf(whichPlayer, startLoc, doHeroes, doCamera, doPreload)
local useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local unitSpacing = 64.00
local minTreeDist = 3.50 * bj_CELLWIDTH
local minWispDist = 1.75 * bj_CELLWIDTH
local nearestMine
local nearMineLoc
local wispLoc
local heroLoc
local peonX
local peonY
local tree

if (doPreload) then
Preloader("scripts\\NightElfMelee.pld")
end
nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine ~= nil) then
nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 650, 0)
nearMineLoc = MeleeGetLocWithinRect(nearMineLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minTreeDist))
tree = CreateUnitAtLoc(whichPlayer, FourCC("etol"), nearMineLoc, bj_UNIT_FACING)
IssueTargetOrder(tree, "entangleinstant", nearestMine)
wispLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
wispLoc = MeleeGetLocWithinRect(wispLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minWispDist))
peonX = GetLocationX(wispLoc)
peonY = GetLocationY(wispLoc)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX - 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
CreateUnitAtLoc(whichPlayer, FourCC("etol"), startLoc, bj_UNIT_FACING)
peonX = GetLocationX(startLoc)
peonY = GetLocationY(startLoc) - 224.00
CreateUnit(whichPlayer, FourCC("ewsp"), peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
CreateUnit(whichPlayer, FourCC("ewsp"), peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
end
if (doHeroes) then
if useRandomHero then
MeleeRandomHeroLoc(whichPlayer, FourCC("Edem"), FourCC("Ekee"), FourCC("Emoo"), FourCC("Ewar"), heroLoc)
else
SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
end
end
if (doCamera) then
SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
end
end

function MeleeStartingUnitsUnknownRace(whichPlayer, startLoc, doHeroes, doCamera, doPreload)
local index

if (doPreload) then
end
index = 0
while (true) do
CreateUnit(whichPlayer, FourCC("nshe"), GetLocationX(startLoc) + GetRandomReal(-256, 256), GetLocationY(startLoc) + GetRandomReal(-256, 256), GetRandomReal(0, 360))
index = index + 1
if (index == 12) then break end
end
if (doHeroes) then
SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
end
if (doCamera) then
SetCameraPositionLocForPlayer(whichPlayer, startLoc)
SetCameraQuickPositionLocForPlayer(whichPlayer, startLoc)
end
end

function MeleeStartingUnits()
local index
local indexPlayer
local indexStartLoc
local indexRace

Preloader("scripts\\SharedMelee.pld")
index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
indexStartLoc = GetStartLocationLoc(GetPlayerStartLocation(indexPlayer))
indexRace = GetPlayerRace(indexPlayer)
if (indexRace == RACE_HUMAN) then
MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_ORC) then
MeleeStartingUnitsOrc(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_UNDEAD) then
MeleeStartingUnitsUndead(indexPlayer, indexStartLoc, true, true, true)
elseif (indexRace == RACE_NIGHTELF) then
MeleeStartingUnitsNightElf(indexPlayer, indexStartLoc, true, true, true)
else
MeleeStartingUnitsUnknownRace(indexPlayer, indexStartLoc, true, true, true)
end
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function MeleeStartingUnitsForPlayer(whichRace, whichPlayer, loc, doHeroes)
if (whichRace == RACE_HUMAN) then
MeleeStartingUnitsHuman(whichPlayer, loc, doHeroes, false, false)
elseif (whichRace == RACE_ORC) then
MeleeStartingUnitsOrc(whichPlayer, loc, doHeroes, false, false)
elseif (whichRace == RACE_UNDEAD) then
MeleeStartingUnitsUndead(whichPlayer, loc, doHeroes, false, false)
elseif (whichRace == RACE_NIGHTELF) then
MeleeStartingUnitsNightElf(whichPlayer, loc, doHeroes, false, false)
else
end
end

function PickMeleeAI(num, s1, s2, s3)
local pick

if GetAIDifficulty(num) == AI_DIFFICULTY_NEWBIE then
StartMeleeAI(num, s1)
return
end
if s2 == "" then
pick = 1
elseif s3 == "" then
pick = GetRandomInt(1, 2)
else
pick = GetRandomInt(1, 3)
end
if pick == 1 then
StartMeleeAI(num, s1)
elseif pick == 2 then
StartMeleeAI(num, s2)
else
StartMeleeAI(num, s3)
end
end

function MeleeStartingAI()
local index
local indexPlayer
local indexRace

index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
indexRace = GetPlayerRace(indexPlayer)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
if (indexRace == RACE_HUMAN) then
PickMeleeAI(indexPlayer, "human.ai", "", "")
elseif (indexRace == RACE_ORC) then
PickMeleeAI(indexPlayer, "orc.ai", "", "")
elseif (indexRace == RACE_UNDEAD) then
PickMeleeAI(indexPlayer, "undead.ai", "", "")
RecycleGuardPosition(bj_ghoul[index])
elseif (indexRace == RACE_NIGHTELF) then
PickMeleeAI(indexPlayer, "elf.ai", "", "")
else
end
ShareEverythingWithTeamAI(indexPlayer)
end
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function LockGuardPosition(targ)
SetUnitCreepGuard(targ, true)
end

function MeleePlayerIsOpponent(playerIndex, opponentIndex)
local thePlayer = Player(playerIndex)
local theOpponent = Player(opponentIndex)

if (playerIndex == opponentIndex) then
return false
end
if (GetPlayerSlotState(theOpponent) ~= PLAYER_SLOT_STATE_PLAYING) then
return false
end
if (bj_meleeDefeated[opponentIndex]) then
return false
end
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
end
end
end
end
return true
end

function MeleeGetAllyStructureCount(whichPlayer)
local playerIndex
local buildingCount
local indexPlayer

buildingCount = 0
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
buildingCount = buildingCount + GetPlayerStructureCount(indexPlayer, true)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
return buildingCount
end

function MeleeGetAllyCount(whichPlayer)
local playerIndex
local playerCount
local indexPlayer

playerCount = 0
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer) and (not bj_meleeDefeated[playerIndex] and (whichPlayer ~= indexPlayer))) then
playerCount = playerCount + 1
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
return playerCount
end

function MeleeGetAllyKeyStructureCount(whichPlayer)
local playerIndex
local indexPlayer
local keyStructs

keyStructs = 0
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
keyStructs = keyStructs + BlzGetPlayerTownHallCount(indexPlayer)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
return keyStructs
end

function MeleeDoDrawEnum()
local thePlayer = GetEnumPlayer()

CachePlayerHeroData(thePlayer)
RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_TIE, false)
end

function MeleeDoVictoryEnum()
local thePlayer = GetEnumPlayer()
local playerIndex = GetPlayerId(thePlayer)

if (not bj_meleeVictoried[playerIndex]) then
bj_meleeVictoried[playerIndex] = true
CachePlayerHeroData(thePlayer)
RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_VICTORY, false)
end
end

function MeleeDoDefeat(whichPlayer)
bj_meleeDefeated[GetPlayerId(whichPlayer)] = true
RemovePlayerPreserveUnitsBJ(whichPlayer, PLAYER_GAME_RESULT_DEFEAT, false)
end

function MeleeDoDefeatEnum()
local thePlayer = GetEnumPlayer()

CachePlayerHeroData(thePlayer)
MakeUnitsPassiveForTeam(thePlayer)
MeleeDoDefeat(thePlayer)
end

function MeleeDoLeave(whichPlayer)
if (GetIntegerGameState(GAME_STATE_DISCONNECTED) ~= 0) then
GameOverDialogBJ(whichPlayer, true)
else
bj_meleeDefeated[GetPlayerId(whichPlayer)] = true
RemovePlayerPreserveUnitsBJ(whichPlayer, PLAYER_GAME_RESULT_DEFEAT, true)
end
end

function MeleeRemoveObservers()
local playerIndex
local indexPlayer

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (IsPlayerObserver(indexPlayer)) then
RemovePlayerPreserveUnitsBJ(indexPlayer, PLAYER_GAME_RESULT_NEUTRAL, false)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
end

function MeleeCheckForVictors()
local playerIndex
local opponentIndex
local opponentlessPlayers = CreateForce()
local gameOver = false

playerIndex = 0
while (true) do
if (not bj_meleeDefeated[playerIndex]) then
opponentIndex = 0
while (true) do
if MeleePlayerIsOpponent(playerIndex, opponentIndex) then
return CreateForce()
end
opponentIndex = opponentIndex + 1
if (opponentIndex == bj_MAX_PLAYERS) then break end
end
ForceAddPlayer(opponentlessPlayers, Player(playerIndex))
gameOver = true
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
bj_meleeGameOver = gameOver
return opponentlessPlayers
end

function MeleeCheckForLosersAndVictors()
local playerIndex
local indexPlayer
local defeatedPlayers = CreateForce()
local victoriousPlayers
local gameOver = false

if (bj_meleeGameOver) then
return
end
if (GetIntegerGameState(GAME_STATE_DISCONNECTED) ~= 0) then
bj_meleeGameOver = true
return
end
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (not bj_meleeDefeated[playerIndex] and not bj_meleeVictoried[playerIndex]) then
if (MeleeGetAllyStructureCount(indexPlayer) <= 0) then
ForceAddPlayer(defeatedPlayers, Player(playerIndex))
bj_meleeDefeated[playerIndex] = true
end
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
victoriousPlayers = MeleeCheckForVictors()
ForForce(defeatedPlayers, MeleeDoDefeatEnum)
ForForce(victoriousPlayers, MeleeDoVictoryEnum)
if (bj_meleeGameOver) then
MeleeRemoveObservers()
end
end

function MeleeGetCrippledWarningMessage(whichPlayer)
local 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
return ""
end
end

function MeleeGetCrippledTimerMessage(whichPlayer)
local 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
return ""
end
end

function MeleeGetCrippledRevealedMessage(whichPlayer)
return GetLocalizedString("CRIPPLE_REVEALING_PREFIX") .. GetPlayerName(whichPlayer) .. GetLocalizedString("CRIPPLE_REVEALING_POSTFIX")
end

function MeleeExposePlayer(whichPlayer, expose)
local playerIndex
local indexPlayer
local toExposeTo = CreateForce()

CripplePlayer(whichPlayer, toExposeTo, false)
bj_playerIsExposed[GetPlayerId(whichPlayer)] = expose
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if (not PlayersAreCoAllied(whichPlayer, indexPlayer)) then
ForceAddPlayer(toExposeTo, indexPlayer)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
CripplePlayer(whichPlayer, toExposeTo, expose)
DestroyForce(toExposeTo)
end

function MeleeExposeAllPlayers()
local playerIndex
local indexPlayer
local playerIndex2
local indexPlayer2
local toExposeTo = CreateForce()

playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
ForceClear(toExposeTo)
CripplePlayer(indexPlayer, toExposeTo, false)
playerIndex2 = 0
while (true) do
indexPlayer2 = Player(playerIndex2)
if playerIndex ~= playerIndex2 then
if (not PlayersAreCoAllied(indexPlayer, indexPlayer2)) then
ForceAddPlayer(toExposeTo, indexPlayer2)
end
end
playerIndex2 = playerIndex2 + 1
if (playerIndex2 == bj_MAX_PLAYERS) then break end
end
CripplePlayer(indexPlayer, toExposeTo, true)
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
DestroyForce(toExposeTo)
end

function MeleeCrippledPlayerTimeout()
local expiredTimer = GetExpiredTimer()
local playerIndex
local exposedPlayer

playerIndex = 0
while (true) do
if (bj_crippledTimer[playerIndex] == expiredTimer) then
if (true) then break end
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
if (playerIndex == bj_MAX_PLAYERS) then
return
end
exposedPlayer = Player(playerIndex)
if (GetLocalPlayer() == exposedPlayer) then
TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
end
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, MeleeGetCrippledRevealedMessage(exposedPlayer))
MeleeExposePlayer(exposedPlayer, true)
end

function MeleePlayerIsCrippled(whichPlayer)
local playerStructures = GetPlayerStructureCount(whichPlayer, true)
local playerKeyStructures = BlzGetPlayerTownHallCount(whichPlayer)

return ((playerStructures > 0) and (playerKeyStructures <= 0))
end

function MeleeCheckForCrippledPlayers()
local playerIndex
local indexPlayer
local crippledPlayers = CreateForce()
local isNowCrippled
local indexRace

if bj_finishSoonAllExposed then
return
end
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
isNowCrippled = MeleePlayerIsCrippled(indexPlayer)
if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then
bj_playerIsCrippled[playerIndex] = true
TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, MeleeCrippledPlayerTimeout)
if (GetLocalPlayer() == indexPlayer) then
TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true)
DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, MeleeGetCrippledWarningMessage(indexPlayer))
end
elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then
bj_playerIsCrippled[playerIndex] = false
PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
if (MeleeGetAllyStructureCount(indexPlayer) > 0) then
if (bj_playerIsExposed[playerIndex]) then
DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED"))
else
DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED"))
end
end
end
MeleeExposePlayer(indexPlayer, false)
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
end

function MeleeCheckLostUnit(lostUnit)
local lostUnitOwner = GetOwningPlayer(lostUnit)

if (GetPlayerStructureCount(lostUnitOwner, true) <= 0) then
MeleeCheckForLosersAndVictors()
end
MeleeCheckForCrippledPlayers()
end

function MeleeCheckAddedUnit(addedUnit)
local addedUnitOwner = GetOwningPlayer(addedUnit)

if (bj_playerIsCrippled[GetPlayerId(addedUnitOwner)]) then
MeleeCheckForCrippledPlayers()
end
end

function MeleeTriggerActionConstructCancel()
MeleeCheckLostUnit(GetCancelledStructure())
end

function MeleeTriggerActionUnitDeath()
if (IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE)) then
MeleeCheckLostUnit(GetDyingUnit())
end
end

function MeleeTriggerActionUnitConstructionStart()
MeleeCheckAddedUnit(GetConstructingStructure())
end

function MeleeTriggerActionPlayerDefeated()
local thePlayer = GetTriggerPlayer()

CachePlayerHeroData(thePlayer)
if (MeleeGetAllyCount(thePlayer) > 0) then
ShareEverythingWithTeam(thePlayer)
if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then
MeleeDoDefeat(thePlayer)
end
else
MakeUnitsPassiveForTeam(thePlayer)
if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then
MeleeDoDefeat(thePlayer)
end
end
MeleeCheckForLosersAndVictors()
end

function MeleeTriggerActionPlayerLeft()
local thePlayer = GetTriggerPlayer()

if (IsPlayerObserver(thePlayer)) then
RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_NEUTRAL, false)
return
end
CachePlayerHeroData(thePlayer)
if (MeleeGetAllyCount(thePlayer) > 0) then
ShareEverythingWithTeam(thePlayer)
MeleeDoLeave(thePlayer)
else
MakeUnitsPassiveForTeam(thePlayer)
MeleeDoLeave(thePlayer)
end
MeleeCheckForLosersAndVictors()
end

function MeleeTriggerActionAllianceChange()
MeleeCheckForLosersAndVictors()
MeleeCheckForCrippledPlayers()
end

function MeleeTriggerTournamentFinishSoon()
local playerIndex
local indexPlayer
local timeRemaining = GetTournamentFinishSoonTimeRemaining()

if not bj_finishSoonAllExposed then
bj_finishSoonAllExposed = true
playerIndex = 0
while (true) do
indexPlayer = Player(playerIndex)
if bj_playerIsCrippled[playerIndex] then
bj_playerIsCrippled[playerIndex] = false
PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
end
end
playerIndex = playerIndex + 1
if (playerIndex == bj_MAX_PLAYERS) then break end
end
MeleeExposeAllPlayers()
end
TimerDialogDisplay(bj_finishSoonTimerDialog, true)
TimerDialogSetRealTimeRemaining(bj_finishSoonTimerDialog, timeRemaining)
end

function MeleeWasUserPlayer(whichPlayer)
local slotState

if (GetPlayerController(whichPlayer) ~= MAP_CONTROL_USER) then
return false
end
slotState = GetPlayerSlotState(whichPlayer)
return (slotState == PLAYER_SLOT_STATE_PLAYING or slotState == PLAYER_SLOT_STATE_LEFT)
end

function MeleeTournamentFinishNowRuleA(multiplier)
local playerScore = __jarray(0)
local teamScore = __jarray(0)
local teamForce = {}
local teamCount
local index
local indexPlayer
local index2
local indexPlayer2
local bestTeam
local bestScore
local draw

index = 0
while (true) do
indexPlayer = Player(index)
if MeleeWasUserPlayer(indexPlayer) then
playerScore[index] = GetTournamentScore(indexPlayer)
if playerScore[index] <= 0 then
playerScore[index] = 1
end
else
playerScore[index] = 0
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
teamCount = 0
index = 0
while (true) do
if playerScore[index] ~= 0 then
indexPlayer = Player(index)
teamScore[teamCount] = 0
teamForce[teamCount] = CreateForce()
index2 = index
while (true) do
if playerScore[index2] ~= 0 then
indexPlayer2 = Player(index2)
if PlayersAreCoAllied(indexPlayer, indexPlayer2) then
teamScore[teamCount] = teamScore[teamCount] + playerScore[index2]
ForceAddPlayer(teamForce[teamCount], indexPlayer2)
playerScore[index2] = 0
end
end
index2 = index2 + 1
if (index2 == bj_MAX_PLAYERS) then break end
end
teamCount = teamCount + 1
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
bj_meleeGameOver = true
if teamCount ~= 0 then
bestTeam = -1
bestScore = -1
index = 0
while (true) do
if teamScore[index] > bestScore then
bestTeam = index
bestScore = teamScore[index]
end
index = index + 1
if (index == teamCount) then break end
end
draw = false
index = 0
while (true) do
if index ~= bestTeam then
if bestScore < (multiplier * teamScore[index]) then
draw = true
end
end
index = index + 1
if (index == teamCount) then break end
end
if draw then
index = 0
while (true) do
ForForce(teamForce[index], MeleeDoDrawEnum)
index = index + 1
if (index == teamCount) then break end
end
else
index = 0
while (true) do
if index ~= bestTeam then
ForForce(teamForce[index], MeleeDoDefeatEnum)
end
index = index + 1
if (index == teamCount) then break end
end
ForForce(teamForce[bestTeam], MeleeDoVictoryEnum)
end
end
end

function MeleeTriggerTournamentFinishNow()
local rule = GetTournamentFinishNowRule()

if bj_meleeGameOver then
return
end
if (rule == 1) then
MeleeTournamentFinishNowRuleA(1)
else
MeleeTournamentFinishNowRuleA(3)
end
MeleeRemoveObservers()
end

function MeleeInitVictoryDefeat()
local trig
local index
local indexPlayer

bj_finishSoonTimerDialog = CreateTimerDialog(nil)
trig = CreateTrigger()
TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_SOON)
TriggerAddAction(trig, MeleeTriggerTournamentFinishSoon)
trig = CreateTrigger()
TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_NOW)
TriggerAddAction(trig, MeleeTriggerTournamentFinishNow)
index = 0
while (true) do
indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
bj_meleeDefeated[index] = false
bj_meleeVictoried[index] = false
bj_playerIsCrippled[index] = false
bj_playerIsExposed[index] = false
bj_crippledTimer[index] = CreateTimer()
bj_crippledTimerWindows[index] = CreateTimerDialog(bj_crippledTimer[index])
TimerDialogSetTitle(bj_crippledTimerWindows[index], MeleeGetCrippledTimerMessage(indexPlayer))
trig = CreateTrigger()
TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL, nil)
TriggerAddAction(trig, MeleeTriggerActionConstructCancel)
trig = CreateTrigger()
TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_DEATH, nil)
TriggerAddAction(trig, MeleeTriggerActionUnitDeath)
trig = CreateTrigger()
TriggerRegisterPlayerUnitEvent(trig, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_START, nil)
TriggerAddAction(trig, MeleeTriggerActionUnitConstructionStart)
trig = CreateTrigger()
TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_DEFEAT)
TriggerAddAction(trig, MeleeTriggerActionPlayerDefeated)
trig = CreateTrigger()
TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
TriggerAddAction(trig, MeleeTriggerActionPlayerLeft)
trig = CreateTrigger()
TriggerRegisterPlayerAllianceChange(trig, indexPlayer, ALLIANCE_PASSIVE)
TriggerRegisterPlayerStateEvent(trig, indexPlayer, PLAYER_STATE_ALLIED_VICTORY, EQUAL, 1)
TriggerAddAction(trig, MeleeTriggerActionAllianceChange)
else
bj_meleeDefeated[index] = true
bj_meleeVictoried[index] = false
if (IsPlayerObserver(indexPlayer)) then
trig = CreateTrigger()
TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
TriggerAddAction(trig, MeleeTriggerActionPlayerLeft)
end
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
TimerStart(CreateTimer(), 2.0, false, MeleeTriggerActionAllianceChange)
end

function CheckInitPlayerSlotAvailability()
local index

if (not bj_slotControlReady) then
index = 0
while (true) do
bj_slotControlUsed[index] = false
bj_slotControl[index] = MAP_CONTROL_USER
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
bj_slotControlReady = true
end
end

function SetPlayerSlotAvailable(whichPlayer, control)
local playerIndex = GetPlayerId(whichPlayer)

CheckInitPlayerSlotAvailability()
bj_slotControlUsed[playerIndex] = true
bj_slotControl[playerIndex] = control
end

function TeamInitPlayerSlots(teamCount)
local index
local indexPlayer
local team

SetTeams(teamCount)
CheckInitPlayerSlotAvailability()
index = 0
team = 0
while (true) do
if (bj_slotControlUsed[index]) then
indexPlayer = Player(index)
SetPlayerTeam(indexPlayer, team)
team = team + 1
if (team >= teamCount) then
team = 0
end
end
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function MeleeInitPlayerSlots()
TeamInitPlayerSlots(bj_MAX_PLAYERS)
end

function FFAInitPlayerSlots()
TeamInitPlayerSlots(bj_MAX_PLAYERS)
end

function OneOnOneInitPlayerSlots()
SetTeams(2)
SetPlayers(2)
TeamInitPlayerSlots(2)
end

function InitGenericPlayerSlots()
local gType = GetGameTypeSelected()

if (gType == GAME_TYPE_MELEE) then
MeleeInitPlayerSlots()
elseif (gType == GAME_TYPE_FFA) then
FFAInitPlayerSlots()
elseif (gType == GAME_TYPE_USE_MAP_SETTINGS) then
elseif (gType == GAME_TYPE_ONE_ON_ONE) then
OneOnOneInitPlayerSlots()
elseif (gType == GAME_TYPE_TWO_TEAM_PLAY) then
TeamInitPlayerSlots(2)
elseif (gType == GAME_TYPE_THREE_TEAM_PLAY) then
TeamInitPlayerSlots(3)
elseif (gType == GAME_TYPE_FOUR_TEAM_PLAY) then
TeamInitPlayerSlots(4)
else
end
end

function SetDNCSoundsDawn()
if bj_useDawnDuskSounds then
StartSound(bj_dawnSound)
end
end

function SetDNCSoundsDusk()
if bj_useDawnDuskSounds then
StartSound(bj_duskSound)
end
end

function SetDNCSoundsDay()
local ToD = GetTimeOfDay()

if ((ToD >= bj_TOD_DAWN and ToD < bj_TOD_DUSK) and not bj_dncIsDaytime) then
bj_dncIsDaytime = true
StopSound(bj_nightAmbientSound, false, true)
StartSound(bj_dayAmbientSound)
end
end

function SetDNCSoundsNight()
local ToD = GetTimeOfDay()

if ((ToD < bj_TOD_DAWN or ToD >= bj_TOD_DUSK) and bj_dncIsDaytime) then
bj_dncIsDaytime = false
StopSound(bj_dayAmbientSound, false, true)
StartSound(bj_nightAmbientSound)
end
end

function InitDNCSounds()
bj_dawnSound = CreateSoundFromLabel("RoosterSound", false, false, false, 10000, 10000)
bj_duskSound = CreateSoundFromLabel("WolfSound", false, false, false, 10000, 10000)
bj_dncSoundsDawn = CreateTrigger()
TriggerRegisterGameStateEvent(bj_dncSoundsDawn, GAME_STATE_TIME_OF_DAY, EQUAL, bj_TOD_DAWN)
TriggerAddAction(bj_dncSoundsDawn, SetDNCSoundsDawn)
bj_dncSoundsDusk = CreateTrigger()
TriggerRegisterGameStateEvent(bj_dncSoundsDusk, GAME_STATE_TIME_OF_DAY, EQUAL, bj_TOD_DUSK)
TriggerAddAction(bj_dncSoundsDusk, SetDNCSoundsDusk)
bj_dncSoundsDay = CreateTrigger()
TriggerRegisterGameStateEvent(bj_dncSoundsDay, GAME_STATE_TIME_OF_DAY, GREATER_THAN_OR_EQUAL, bj_TOD_DAWN)
TriggerRegisterGameStateEvent(bj_dncSoundsDay, GAME_STATE_TIME_OF_DAY, LESS_THAN, bj_TOD_DUSK)
TriggerAddAction(bj_dncSoundsDay, SetDNCSoundsDay)
bj_dncSoundsNight = CreateTrigger()
TriggerRegisterGameStateEvent(bj_dncSoundsNight, GAME_STATE_TIME_OF_DAY, LESS_THAN, bj_TOD_DAWN)
TriggerRegisterGameStateEvent(bj_dncSoundsNight, GAME_STATE_TIME_OF_DAY, GREATER_THAN_OR_EQUAL, bj_TOD_DUSK)
TriggerAddAction(bj_dncSoundsNight, SetDNCSoundsNight)
end

function InitBlizzardGlobals()
local index
local userControlledPlayers
local v

filterIssueHauntOrderAtLocBJ = Filter(IssueHauntOrderAtLocBJFilter)
filterEnumDestructablesInCircleBJ = Filter(EnumDestructablesInCircleBJFilter)
filterGetUnitsInRectOfPlayer = Filter(GetUnitsInRectOfPlayerFilter)
filterGetUnitsOfTypeIdAll = Filter(GetUnitsOfTypeIdAllFilter)
filterGetUnitsOfPlayerAndTypeId = Filter(GetUnitsOfPlayerAndTypeIdFilter)
filterMeleeTrainedUnitIsHeroBJ = Filter(MeleeTrainedUnitIsHeroBJFilter)
filterLivingPlayerUnitsOfTypeId = Filter(LivingPlayerUnitsOfTypeIdFilter)
index = 0
while (true) do
if (index == bj_MAX_PLAYER_SLOTS) then break end
bj_FORCE_PLAYER[index] = CreateForce()
ForceAddPlayer(bj_FORCE_PLAYER[index], Player(index))
index = index + 1
end
bj_FORCE_ALL_PLAYERS = CreateForce()
ForceEnumPlayers(bj_FORCE_ALL_PLAYERS, nil)
bj_cineModePriorSpeed = GetGameSpeed()
bj_cineModePriorFogSetting = IsFogEnabled()
bj_cineModePriorMaskSetting = IsFogMaskEnabled()
index = 0
while (true) do
if (index >= bj_MAX_QUEUED_TRIGGERS) then break end
bj_queuedExecTriggers[index] = nil
bj_queuedExecUseConds[index] = false
index = index + 1
end
bj_isSinglePlayer = false
userControlledPlayers = 0
index = 0
while (true) do
if (index >= bj_MAX_PLAYERS) then break end
if (GetPlayerController(Player(index)) == MAP_CONTROL_USER and GetPlayerSlotState(Player(index)) == PLAYER_SLOT_STATE_PLAYING) then
userControlledPlayers = userControlledPlayers + 1
end
index = index + 1
end
bj_isSinglePlayer = (userControlledPlayers == 1)
bj_rescueSound = CreateSoundFromLabel("Rescue", false, false, false, 10000, 10000)
bj_questDiscoveredSound = CreateSoundFromLabel("QuestNew", false, false, false, 10000, 10000)
bj_questUpdatedSound = CreateSoundFromLabel("QuestUpdate", false, false, false, 10000, 10000)
bj_questCompletedSound = CreateSoundFromLabel("QuestCompleted", false, false, false, 10000, 10000)
bj_questFailedSound = CreateSoundFromLabel("QuestFailed", false, false, false, 10000, 10000)
bj_questHintSound = CreateSoundFromLabel("Hint", false, false, false, 10000, 10000)
bj_questSecretSound = CreateSoundFromLabel("SecretFound", false, false, false, 10000, 10000)
bj_questItemAcquiredSound = CreateSoundFromLabel("ItemReward", false, false, false, 10000, 10000)
bj_questWarningSound = CreateSoundFromLabel("Warning", false, false, false, 10000, 10000)
bj_victoryDialogSound = CreateSoundFromLabel("QuestCompleted", false, false, false, 10000, 10000)
bj_defeatDialogSound = CreateSoundFromLabel("QuestFailed", false, false, false, 10000, 10000)
DelayedSuspendDecayCreate()
v = VersionGet()
if (v == VERSION_REIGN_OF_CHAOS) then
bj_MELEE_MAX_TWINKED_HEROES = bj_MELEE_MAX_TWINKED_HEROES_V0
else
bj_MELEE_MAX_TWINKED_HEROES = bj_MELEE_MAX_TWINKED_HEROES_V1
end
end

function InitQueuedTriggers()
bj_queuedExecTimeout = CreateTrigger()
TriggerRegisterTimerExpireEvent(bj_queuedExecTimeout, bj_queuedExecTimeoutTimer)
TriggerAddAction(bj_queuedExecTimeout, QueuedTriggerDoneBJ)
end

function InitMapRects()
bj_mapInitialPlayableArea = Rect(GetCameraBoundMinX() - GetCameraMargin(CAMERA_MARGIN_LEFT), GetCameraBoundMinY() - GetCameraMargin(CAMERA_MARGIN_BOTTOM), GetCameraBoundMaxX() + GetCameraMargin(CAMERA_MARGIN_RIGHT), GetCameraBoundMaxY() + GetCameraMargin(CAMERA_MARGIN_TOP))
bj_mapInitialCameraBounds = GetCurrentCameraBoundsMapRectBJ()
end

function InitSummonableCaps()
local index

index = 0
while (true) do
if (not GetPlayerTechResearched(Player(index), FourCC("Rhrt"), true)) then
SetPlayerTechMaxAllowed(Player(index), FourCC("hrtt"), 0)
end
if (not GetPlayerTechResearched(Player(index), FourCC("Robk"), true)) then
SetPlayerTechMaxAllowed(Player(index), FourCC("otbk"), 0)
end
SetPlayerTechMaxAllowed(Player(index), FourCC("uske"), bj_MAX_SKELETONS)
index = index + 1
if (index == bj_MAX_PLAYERS) then break end
end
end

function UpdateStockAvailability(whichItem)
local iType = GetItemType(whichItem)
local iLevel = GetItemLevel(whichItem)

if (iType == ITEM_TYPE_PERMANENT) then
bj_stockAllowedPermanent[iLevel] = true
elseif (iType == ITEM_TYPE_CHARGED) then
bj_stockAllowedCharged[iLevel] = true
elseif (iType == ITEM_TYPE_ARTIFACT) then
bj_stockAllowedArtifact[iLevel] = true
else
end
end

function UpdateEachStockBuildingEnum()
local iteration = 0
local pickedItemId

while (true) do
pickedItemId = ChooseRandomItemEx(bj_stockPickedItemType, bj_stockPickedItemLevel)
if (IsItemIdSellable(pickedItemId)) then break end
iteration = iteration + 1
if (iteration > bj_STOCK_MAX_ITERATIONS) then
return
end
end
AddItemToStock(GetEnumUnit(), pickedItemId, 1, 1)
end

function UpdateEachStockBuilding(iType, iLevel)
local g

bj_stockPickedItemType = iType
bj_stockPickedItemLevel = iLevel
g = CreateGroup()
GroupEnumUnitsOfType(g, "marketplace", nil)
ForGroup(g, UpdateEachStockBuildingEnum)
DestroyGroup(g)
end

function PerformStockUpdates()
local pickedItemId
local pickedItemType
local pickedItemLevel = 0
local allowedCombinations = 0
local iLevel

iLevel = 1
while (true) do
if (bj_stockAllowedPermanent[iLevel]) then
allowedCombinations = allowedCombinations + 1
if (GetRandomInt(1, allowedCombinations) == 1) then
pickedItemType = ITEM_TYPE_PERMANENT
pickedItemLevel = iLevel
end
end
if (bj_stockAllowedCharged[iLevel]) then
allowedCombinations = allowedCombinations + 1
if (GetRandomInt(1, allowedCombinations) == 1) then
pickedItemType = ITEM_TYPE_CHARGED
pickedItemLevel = iLevel
end
end
if (bj_stockAllowedArtifact[iLevel]) then
allowedCombinations = allowedCombinations + 1
if (GetRandomInt(1, allowedCombinations) == 1) then
pickedItemType = ITEM_TYPE_ARTIFACT
pickedItemLevel = iLevel
end
end
iLevel = iLevel + 1
if (iLevel > bj_MAX_ITEM_LEVEL) then break end
end
if (allowedCombinations == 0) then
return
end
UpdateEachStockBuilding(pickedItemType, pickedItemLevel)
end

function StartStockUpdates()
PerformStockUpdates()
TimerStart(bj_stockUpdateTimer, bj_STOCK_RESTOCK_INTERVAL, true, PerformStockUpdates)
end

function RemovePurchasedItem()
RemoveItemFromStock(GetSellingUnit(), GetItemTypeId(GetSoldItem()))
end

function InitNeutralBuildings()
local iLevel

iLevel = 0
while (true) do
bj_stockAllowedPermanent[iLevel] = false
bj_stockAllowedCharged[iLevel] = false
bj_stockAllowedArtifact[iLevel] = false
iLevel = iLevel + 1
if (iLevel > bj_MAX_ITEM_LEVEL) then break end
end
SetAllItemTypeSlots(bj_MAX_STOCK_ITEM_SLOTS)
SetAllUnitTypeSlots(bj_MAX_STOCK_UNIT_SLOTS)
bj_stockUpdateTimer = CreateTimer()
TimerStart(bj_stockUpdateTimer, bj_STOCK_RESTOCK_INITIAL_DELAY, false, StartStockUpdates)
bj_stockItemPurchased = CreateTrigger()
TriggerRegisterPlayerUnitEvent(bj_stockItemPurchased, Player(PLAYER_NEUTRAL_PASSIVE), EVENT_PLAYER_UNIT_SELL_ITEM, nil)
TriggerAddAction(bj_stockItemPurchased, RemovePurchasedItem)
end

function MarkGameStarted()
bj_gameStarted = true
DestroyTimer(bj_gameStartedTimer)
end

function DetectGameStarted()
bj_gameStartedTimer = CreateTimer()
TimerStart(bj_gameStartedTimer, bj_GAME_STARTED_THRESHOLD, false, MarkGameStarted)
end

function InitBlizzard()
ConfigureNeutralVictim()
InitBlizzardGlobals()
InitQueuedTriggers()
InitRescuableBehaviorBJ()
InitDNCSounds()
InitMapRects()
InitSummonableCaps()
InitNeutralBuildings()
DetectGameStarted()
end

function RandomDistReset()
bj_randDistCount = 0
end

function RandomDistAddItem(inID, inChance)
bj_randDistID[bj_randDistCount] = inID
bj_randDistChance[bj_randDistCount] = inChance
bj_randDistCount = bj_randDistCount + 1
end

function RandomDistChoose()
local sum = 0
local chance = 0
local index
local foundID = -1
local done

if (bj_randDistCount == 0) then
return -1
end
index = 0
while (true) do
sum = sum + bj_randDistChance[index]
index = index + 1
if (index == bj_randDistCount) then break end
end
chance = GetRandomInt(1, sum)
index = 0
sum = 0
done = false
while (true) do
sum = sum + bj_randDistChance[index]
if (chance <= sum) then
foundID = bj_randDistID[index]
done = true
end
index = index + 1
if (index == bj_randDistCount) then
done = true
end
if (done == true) then break end
end
return foundID
end

function UnitDropItem(inUnit, inItemID)
local x
local y
local radius = 32.0
local unitX
local unitY
local droppedItem

if (inItemID == -1) then
return nil
end
unitX = GetUnitX(inUnit)
unitY = GetUnitY(inUnit)
x = GetRandomReal(unitX - radius, unitX + radius)
y = GetRandomReal(unitY - radius, unitY + radius)
droppedItem = CreateItem(inItemID, x, y)
SetItemDropID(droppedItem, GetUnitTypeId(inUnit))
UpdateStockAvailability(droppedItem)
return droppedItem
end

function WidgetDropItem(inWidget, inItemID)
local x
local y
local radius = 32.0
local widgetX
local widgetY

if (inItemID == -1) then
return nil
end
widgetX = GetWidgetX(inWidget)
widgetY = GetWidgetY(inWidget)
x = GetRandomReal(widgetX - radius, widgetX + radius)
y = GetRandomReal(widgetY - radius, widgetY + radius)
return CreateItem(inItemID, x, y)
end

function BlzIsLastInstanceObjectFunctionSuccessful()
return bj_lastInstObjFuncSuccessful
end

function BlzSetAbilityBooleanFieldBJ(whichAbility, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanField(whichAbility, whichField, value)
end

function BlzSetAbilityIntegerFieldBJ(whichAbility, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerField(whichAbility, whichField, value)
end

function BlzSetAbilityRealFieldBJ(whichAbility, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityRealField(whichAbility, whichField, value)
end

function BlzSetAbilityStringFieldBJ(whichAbility, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityStringField(whichAbility, whichField, value)
end

function BlzSetAbilityBooleanLevelFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanLevelField(whichAbility, whichField, level, value)
end

function BlzSetAbilityIntegerLevelFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerLevelField(whichAbility, whichField, level, value)
end

function BlzSetAbilityRealLevelFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityRealLevelField(whichAbility, whichField, level, value)
end

function BlzSetAbilityStringLevelFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityStringLevelField(whichAbility, whichField, level, value)
end

function BlzSetAbilityBooleanLevelArrayFieldBJ(whichAbility, whichField, level, index, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityBooleanLevelArrayField(whichAbility, whichField, level, index, value)
end

function BlzSetAbilityIntegerLevelArrayFieldBJ(whichAbility, whichField, level, index, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityIntegerLevelArrayField(whichAbility, whichField, level, index, value)
end

function BlzSetAbilityRealLevelArrayFieldBJ(whichAbility, whichField, level, index, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityRealLevelArrayField(whichAbility, whichField, level, index, value)
end

function BlzSetAbilityStringLevelArrayFieldBJ(whichAbility, whichField, level, index, value)
bj_lastInstObjFuncSuccessful = BlzSetAbilityStringLevelArrayField(whichAbility, whichField, level, index, value)
end

function BlzAddAbilityBooleanLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzAddAbilityBooleanLevelArrayField(whichAbility, whichField, level, value)
end

function BlzAddAbilityIntegerLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzAddAbilityIntegerLevelArrayField(whichAbility, whichField, level, value)
end

function BlzAddAbilityRealLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzAddAbilityRealLevelArrayField(whichAbility, whichField, level, value)
end

function BlzAddAbilityStringLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzAddAbilityStringLevelArrayField(whichAbility, whichField, level, value)
end

function BlzRemoveAbilityBooleanLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzRemoveAbilityBooleanLevelArrayField(whichAbility, whichField, level, value)
end

function BlzRemoveAbilityIntegerLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzRemoveAbilityIntegerLevelArrayField(whichAbility, whichField, level, value)
end

function BlzRemoveAbilityRealLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzRemoveAbilityRealLevelArrayField(whichAbility, whichField, level, value)
end

function BlzRemoveAbilityStringLevelArrayFieldBJ(whichAbility, whichField, level, value)
bj_lastInstObjFuncSuccessful = BlzRemoveAbilityStringLevelArrayField(whichAbility, whichField, level, value)
end

function BlzItemAddAbilityBJ(whichItem, abilCode)
bj_lastInstObjFuncSuccessful = BlzItemAddAbility(whichItem, abilCode)
end

function BlzItemRemoveAbilityBJ(whichItem, abilCode)
bj_lastInstObjFuncSuccessful = BlzItemRemoveAbility(whichItem, abilCode)
end

function BlzSetItemBooleanFieldBJ(whichItem, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetItemBooleanField(whichItem, whichField, value)
end

function BlzSetItemIntegerFieldBJ(whichItem, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetItemIntegerField(whichItem, whichField, value)
end

function BlzSetItemRealFieldBJ(whichItem, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetItemRealField(whichItem, whichField, value)
end

function BlzSetItemStringFieldBJ(whichItem, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetItemStringField(whichItem, whichField, value)
end

function BlzSetUnitBooleanFieldBJ(whichUnit, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitBooleanField(whichUnit, whichField, value)
end

function BlzSetUnitIntegerFieldBJ(whichUnit, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitIntegerField(whichUnit, whichField, value)
end

function BlzSetUnitRealFieldBJ(whichUnit, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitRealField(whichUnit, whichField, value)
end

function BlzSetUnitStringFieldBJ(whichUnit, whichField, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitStringField(whichUnit, whichField, value)
end

function BlzSetUnitWeaponBooleanFieldBJ(whichUnit, whichField, index, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponBooleanField(whichUnit, whichField, index, value)
end

function BlzSetUnitWeaponIntegerFieldBJ(whichUnit, whichField, index, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponIntegerField(whichUnit, whichField, index, value)
end

function BlzSetUnitWeaponRealFieldBJ(whichUnit, whichField, index, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponRealField(whichUnit, whichField, index, value)
end

function BlzSetUnitWeaponStringFieldBJ(whichUnit, whichField, index, value)
bj_lastInstObjFuncSuccessful = BlzSetUnitWeaponStringField(whichUnit, whichField, index, value)
end
Lua:
ARCHMAGE = FourCC("Hamg")
PALADIN = FourCC("Hpal")
MTN_KING = FourCC("Hmkg")
BLOOD_MAGE = FourCC("Hblm")
AVATAR = FourCC("AHav")
BASH = FourCC("AHbh")
THUNDER_BOLT = FourCC("AHtb")
THUNDER_CLAP = FourCC("AHtc")
DEVOTION_AURA = FourCC("AHad")
DIVINE_SHIELD = FourCC("AHds")
HOLY_BOLT = FourCC("AHhb")
RESURRECTION = FourCC("AHre")
BLIZZARD = FourCC("AHbz")
BRILLIANCE_AURA = FourCC("AHab")
MASS_TELEPORT = FourCC("AHmt")
WATER_ELEMENTAL = FourCC("AHwe")
BANISH = FourCC("AHbn")
FLAME_STRIKE = FourCC("AHfs")
SUMMON_PHOENIX = FourCC("AHpx")
SIPHON_MANA = FourCC("AHdr")
JAINA = FourCC("Hjai")
MURADIN = FourCC("Hmbr")
GARITHOS = FourCC("Hlgr")
KAEL = FourCC("Hkal")
COPTER = FourCC("hgyr")
GYRO = COPTER
ELEMENTAL = FourCC("hwat")
FOOTMAN = FourCC("hfoo")
FOOTMEN = FOOTMAN
GRYPHON = FourCC("hgry")
KNIGHT = FourCC("hkni")
MORTAR = FourCC("hmtm")
PEASANT = FourCC("hpea")
PRIEST = FourCC("hmpr")
RIFLEMAN = FourCC("hrif")
RIFLEMEN = RIFLEMAN
SORCERESS = FourCC("hsor")
TANK = FourCC("hmtt")
STEAM_TANK = TANK
ROCKET_TANK = FourCC("hrtt")
MILITIA = FourCC("hmil")
SPELL_BREAKER = FourCC("hspt")
HUMAN_DRAGON_HAWK = FourCC("hdhw")
BLOOD_PRIEST = FourCC("hbep")
BLOOD_SORCERESS = FourCC("hbes")
BLOOD_PEASANT = FourCC("nhew")
AVIARY = FourCC("hgra")
BARRACKS = FourCC("hbar")
BLACKSMITH = FourCC("hbla")
CANNON_TOWER = FourCC("hctw")
CASTLE = FourCC("hcas")
CHURCH = FourCC("htws")
MAGE_TOWER = CHURCH
GUARD_TOWER = FourCC("hgtw")
HOUSE = FourCC("hhou")
HUMAN_ALTAR = FourCC("halt")
KEEP = FourCC("hkee")
LUMBER_MILL = FourCC("hlum")
SANCTUM = FourCC("hars")
ARCANE_SANCTUM = SANCTUM
TOWN_HALL = FourCC("htow")
WATCH_TOWER = FourCC("hwtw")
WORKSHOP = FourCC("harm")
ARCANE_VAULT = FourCC("hvlt")
ARCANE_TOWER = FourCC("hatw")
UPG_MELEE = FourCC("Rhme")
UPG_RANGED = FourCC("Rhra")
UPG_ARTILLERY = FourCC("Rhaa")
UPG_ARMOR = FourCC("Rhar")
UPG_GOLD = FourCC("Rhmi")
UPG_MASONRY = FourCC("Rhac")
UPG_SIGHT = FourCC("Rhss")
UPG_DEFEND = FourCC("Rhde")
UPG_BREEDING = FourCC("Rhan")
UPG_PRAYING = FourCC("Rhpt")
UPG_SORCERY = FourCC("Rhst")
UPG_LEATHER = FourCC("Rhla")
UPG_GUN_RANGE = FourCC("Rhri")
UPG_WOOD = FourCC("Rhlh")
UPG_SENTINEL = FourCC("Rhse")
UPG_SCATTER = FourCC("Rhsr")
UPG_BOMBS = FourCC("Rhgb")
UPG_HAMMERS = FourCC("Rhhb")
UPG_CONT_MAGIC = FourCC("Rhss")
UPG_FRAGS = FourCC("Rhfs")
UPG_TANK = FourCC("Rhrt")
UPG_FLAK = FourCC("Rhfc")
UPG_CLOUD = FourCC("Rhcd")
BLADE_MASTER = FourCC("Obla")
FAR_SEER = FourCC("Ofar")
TAUREN_CHIEF = FourCC("Otch")
SHADOW_HUNTER = FourCC("Oshd")
GROM = FourCC("Ogrh")
THRALL = FourCC("Othr")
CRITICAL_STRIKE = FourCC("AOcr")
MIRROR_IMAGE = FourCC("AOmi")
BLADE_STORM = FourCC("AOww")
WIND_WALK = FourCC("AOwk")
CHAIN_LIGHTNING = FourCC("AOcl")
EARTHQUAKE = FourCC("AOeq")
FAR_SIGHT = FourCC("AOfs")
SPIRIT_WOLF = FourCC("AOsf")
ENDURANE_AURA = FourCC("AOae")
REINCARNATION = FourCC("AOre")
SHOCKWAVE = FourCC("AOsh")
WAR_STOMP = FourCC("AOws")
HEALING_WAVE = FourCC("AOhw")
HEX = FourCC("AOhx")
SERPENT_WARD = FourCC("AOsw")
VOODOO = FourCC("AOvd")
GUARDIAN = FourCC("oang")
CATAPULT = FourCC("ocat")
WITCH_DOCTOR = FourCC("odoc")
GRUNT = FourCC("ogru")
HEAD_HUNTER = FourCC("ohun")
BERSERKER = FourCC("otbk")
KODO_BEAST = FourCC("okod")
PEON = FourCC("opeo")
RAIDER = FourCC("orai")
SHAMAN = FourCC("oshm")
TAUREN = FourCC("otau")
WYVERN = FourCC("owyv")
BATRIDER = FourCC("otbr")
SPIRIT_WALKER = FourCC("ospw")
SPIRIT_WALKER_M = FourCC("ospm")
ORC_ALTAR = FourCC("oalt")
ORC_BARRACKS = FourCC("obar")
BESTIARY = FourCC("obea")
FORGE = FourCC("ofor")
FORTRESS = FourCC("ofrt")
GREAT_HALL = FourCC("ogre")
LODGE = FourCC("osld")
STRONGHOLD = FourCC("ostr")
BURROW = FourCC("otrb")
TOTEM = FourCC("otto")
ORC_WATCH_TOWER = FourCC("owtw")
VOODOO_LOUNGE = FourCC("ovln")
UPG_ORC_MELEE = FourCC("Rome")
UPG_ORC_RANGED = FourCC("Rora")
UPG_ORC_ARTILLERY = FourCC("Roaa")
UPG_ORC_ARMOR = FourCC("Roar")
UPG_ORC_WAR_DRUMS = FourCC("Rwdm")
UPG_ORC_PILLAGE = FourCC("Ropg")
UPG_ORC_BERSERK = FourCC("Robs")
UPG_ORC_PULVERIZE = FourCC("Rows")
UPG_ORC_ENSNARE = FourCC("Roen")
UPG_ORC_VENOM = FourCC("Rovs")
UPG_ORC_DOCS = FourCC("Rowd")
UPG_ORC_SHAMAN = FourCC("Rost")
UPG_ORC_SPIKES = FourCC("Rosp")
UPG_ORC_BURROWS = FourCC("Rorb")
UPG_ORC_REGEN = FourCC("Rotr")
UPG_ORC_FIRE = FourCC("Rolf")
UPG_ORC_SWALKER = FourCC("Rowt")
UPG_ORC_BERSERKER = FourCC("Robk")
UPG_ORC_NAPTHA = FourCC("Robf")
UPG_ORC_CHAOS = FourCC("Roch")
OGRE_MAGI = FourCC("nomg")
ORC_DRAGON = FourCC("nrwm")
SAPPER = FourCC("ngsp")
ZEPPLIN = FourCC("nzep")
ZEPPELIN = ZEPPLIN
W2_WARLOCK = FourCC("nw2w")
PIG_FARM = FourCC("npgf")
FOREST_TROLL = FourCC("nftr")
DRAGON_ROOST = FourCC("ndrb")
CHAOS_GRUNT = FourCC("nchg")
CHAOS_WARLOCK = FourCC("nchw")
CHAOS_RAIDER = FourCC("nchr")
CHAOS_PEON = FourCC("ncpn")
CHAOS_KODO = FourCC("nckb")
CHAOS_GROM = FourCC("Opgh")
CHAOS_BLADEMASTER = FourCC("Nbbc")
CHAOS_BURROW = FourCC("ocbw")
DEATH_KNIGHT = FourCC("Udea")
DREAD_LORD = FourCC("Udre")
LICH = FourCC("Ulic")
CRYPT_LORD = FourCC("Ucrl")
MALGANIS = FourCC("Umal")
TICHONDRIUS = FourCC("Utic")
PIT_LORD = FourCC("Npld")
DETHEROC = FourCC("Udth")
SLEEP = FourCC("AUsl")
VAMP_AURA = FourCC("AUav")
CARRION_SWARM = FourCC("AUcs")
INFERNO = FourCC("AUin")
DARK_RITUAL = FourCC("AUdr")
DEATH_DECAY = FourCC("AUdd")
FROST_ARMOR = FourCC("AUfu")
FROST_NOVA = FourCC("AUfn")
ANIM_DEAD = FourCC("AUan")
DEATH_COIL = FourCC("AUdc")
DEATH_PACT = FourCC("AUdp")
UNHOLY_AURA = FourCC("AUau")
CARRION_SCARAB = FourCC("AUcb")
IMPALE = FourCC("AUim")
LOCUST_SWARM = FourCC("AUls")
THORNY_SHIELD = FourCC("AUts")
ABOMINATION = FourCC("uabo")
ACOLYTE = FourCC("uaco")
BANSHEE = FourCC("uban")
PIT_FIEND = FourCC("ucry")
CRYPT_FIEND = PIT_FIEND
FROST_WYRM = FourCC("ufro")
GARGOYLE = FourCC("ugar")
GARGOYLE_MORPH = FourCC("ugrm")
GHOUL = FourCC("ugho")
MEAT_WAGON = FourCC("umtw")
NECRO = FourCC("unec")
SKEL_WARRIOR = FourCC("uske")
SHADE = FourCC("ushd")
UNDEAD_BARGE = FourCC("uarb")
OBSIDIAN_STATUE = FourCC("uobs")
OBS_STATUE = OBSIDIAN_STATUE
BLK_SPHINX = FourCC("ubsp")
UNDEAD_MINE = FourCC("ugol")
UNDEAD_ALTAR = FourCC("uaod")
BONEYARD = FourCC("ubon")
GARG_SPIRE = FourCC("ugsp")
NECROPOLIS_1 = FourCC("unpl")
NECROPOLIS_2 = FourCC("unp1")
NECROPOLIS_3 = FourCC("unp2")
SAC_PIT = FourCC("usap")
CRYPT = FourCC("usep")
SLAUGHTERHOUSE = FourCC("uslh")
DAMNED_TEMPLE = FourCC("utod")
ZIGGURAT_1 = FourCC("uzig")
ZIGGURAT_2 = FourCC("uzg1")
ZIGGURAT_FROST = FourCC("uzg2")
GRAVEYARD = FourCC("ugrv")
TOMB_OF_RELICS = FourCC("utom")
UPG_UNHOLY_STR = FourCC("Rume")
UPG_CR_ATTACK = FourCC("Rura")
UPG_UNHOLY_ARMOR = FourCC("Ruar")
UPG_CANNIBALIZE = FourCC("Ruac")
UPG_GHOUL_FRENZY = FourCC("Rugf")
UPG_FIEND_WEB = FourCC("Ruwb")
UPG_ABOM = FourCC("Ruab")
UPG_STONE_FORM = FourCC("Rusf")
UPG_NECROS = FourCC("Rune")
UPG_BANSHEE = FourCC("Ruba")
UPG_MEAT_WAGON = FourCC("Rump")
UPG_WYRM_BREATH = FourCC("Rufb")
UPG_SKEL_LIFE = FourCC("Rusl")
UPG_SKEL_MASTERY = FourCC("Rusm")
UPG_EXHUME = FourCC("Ruex")
UPG_SACRIFICE = FourCC("Rurs")
UPG_ABOM_EXPL = FourCC("Ruax")
UPG_CR_ARMOR = FourCC("Rucr")
UPG_PLAGUE = FourCC("Rupc")
UPG_BLK_SPHINX = FourCC("Rusp")
UPG_BURROWING = FourCC("Rubu")
DEMON_HUNTER = FourCC("Edem")
DEMON_HUNTER_M = FourCC("Edmm")
KEEPER = FourCC("Ekee")
MOON_CHICK = FourCC("Emoo")
MOON_BABE = MOON_CHICK
MOON_HONEY = MOON_CHICK
WARDEN = FourCC("Ewar")
SYLVANUS = FourCC("Hvwd")
CENARIUS = FourCC("Ecen")
ILLIDAN = FourCC("Eevi")
ILLIDAN_DEMON = FourCC("Eevm")
MAIEV = FourCC("Ewrd")
FORCE_NATURE = FourCC("AEfn")
ENT_ROOTS = FourCC("AEer")
THORNS_AURA = FourCC("AEah")
TRANQUILITY = FourCC("AEtq")
EVASION = FourCC("AEev")
IMMOLATION = FourCC("AEim")
MANA_BURN = FourCC("AEmb")
METAMORPHOSIS = FourCC("AEme")
SEARING_ARROWS = FourCC("AHfa")
SCOUT = FourCC("AEst")
STARFALL = FourCC("AEsf")
TRUESHOT = FourCC("AEar")
BLINK = FourCC("AEbl")
FAN_KNIVES = FourCC("AEfk")
SHADOW_TOUCH = FourCC("AEsh")
VENGEANCE = FourCC("AEsv")
WISP = FourCC("ewsp")
ARCHER = FourCC("earc")
DRUID_TALON = FourCC("edot")
DRUID_TALON_M = FourCC("edtm")
BALLISTA = FourCC("ebal")
DRUID_CLAW = FourCC("edoc")
DRUID_CLAW_M = FourCC("edcm")
DRYAD = FourCC("edry")
HIPPO = FourCC("ehip")
HIPPO_RIDER = FourCC("ehpr")
HUNTRESS = FourCC("esen")
CHIMAERA = FourCC("echm")
ENT = FourCC("efon")
MOUNTAIN_GIANT = FourCC("emtg")
FAERIE_DRAGON = FourCC("efdr")
HIGH_ARCHER = FourCC("nhea")
HIGH_FOOTMAN = FourCC("hcth")
HIGH_FOOTMEN = HIGH_FOOTMAN
HIGH_SWORDMAN = FourCC("hhes")
DRAGON_HAWK = FourCC("nws1")
CORRUPT_TREANT = FourCC("nenc")
POISON_TREANT = FourCC("nenp")
PLAGUE_TREANT = FourCC("nepl")
SHANDRIS = FourCC("eshd")
ANCIENT_LORE = FourCC("eaoe")
ANCIENT_WAR = FourCC("eaom")
ANCIENT_WIND = FourCC("eaow")
TREE_AGES = FourCC("etoa")
TREE_ETERNITY = FourCC("etoe")
TREE_LIFE = FourCC("etol")
ANCIENT_PROTECT = FourCC("etrp")
ELF_ALTAR = FourCC("eate")
BEAR_DEN = FourCC("edol")
CHIMAERA_ROOST = FourCC("edos")
HUNTERS_HALL = FourCC("edob")
MOON_WELL = FourCC("emow")
ELF_MINE = FourCC("egol")
DEN_OF_WONDERS = FourCC("eden")
ELF_FARM = FourCC("nefm")
ELF_GUARD_TOWER = FourCC("negt")
HIGH_SKY = FourCC("negm")
HIGH_EARTH = FourCC("negf")
HIGH_TOWER = FourCC("negt")
ELF_HIGH_BARRACKS = FourCC("nheb")
CORRUPT_LIFE = FourCC("nctl")
CORRUPT_AGES = FourCC("ncta")
CORRUPT_ETERNITY = FourCC("ncte")
CORRUPT_WELL = FourCC("ncmw")
CORRUPT_PROTECTOR = FourCC("ncap")
CORRUPT_WAR = FourCC("ncaw")
UPG_STR_MOON = FourCC("Resm")
UPG_STR_WILD = FourCC("Resw")
UPG_MOON_ARMOR = FourCC("Rema")
UPG_HIDES = FourCC("Rerh")
UPG_ULTRAVISION = FourCC("Reuv")
UPG_BLESSING = FourCC("Renb")
UPG_SCOUT = FourCC("Resc")
UPG_GLAIVE = FourCC("Remg")
UPG_BOWS = FourCC("Reib")
UPG_MARKSMAN = FourCC("Remk")
UPG_DRUID_TALON = FourCC("Redt")
UPG_DRUID_CLAW = FourCC("Redc")
UPG_ABOLISH = FourCC("Resi")
UPG_CHIM_ACID = FourCC("Recb")
UPG_HIPPO_TAME = FourCC("Reht")
UPG_BOLT = FourCC("Repd")
UPG_MARK_CLAW = FourCC("Reeb")
UPG_MARK_TALON = FourCC("Reec")
UPG_HARD_SKIN = FourCC("Rehs")
UPG_RESIST_SKIN = FourCC("Rers")
UPG_WELL_SPRING = FourCC("Rews")
DEMON_GATE = FourCC("ndmg")
FELLHOUND = FourCC("nfel")
INFERNAL = FourCC("ninf")
DOOMGUARD = FourCC("nbal")
SATYR = FourCC("nsty")
TRICKSTER = FourCC("nsat")
SHADOWDANCER = FourCC("nsts")
SOULSTEALER = FourCC("nstl")
HELLCALLER = FourCC("nsth")
SKEL_ARCHER = FourCC("nska")
SKEL_MARKSMAN = FourCC("nskm")
SKEL_BURNING = FourCC("nskf")
SKEL_GIANT = FourCC("nskg")
FURBOLG = FourCC("nfrl")
FURBOLG_TRACKER = FourCC("nfrb")
FURBOLG_SHAMAN = FourCC("nfrs")
FURBOLG_CHAMP = FourCC("nfrg")
FURBOLG_ELDER = FourCC("nfre")
NAGA_SORCERESS = FourCC("Nngs")
NAGA_VASHJ = FourCC("Hvsh")
NAGA_DRAGON = FourCC("nsnp")
NAGA_WITCH = FourCC("nnsw")
NAGA_SERPENT = FourCC("nwgs")
NAGA_HYDRA = FourCC("nhyc")
NAGA_SLAVE = FourCC("nmpe")
NAGA_SNAP_DRAGON = NAGA_DRAGON
NAGA_COUATL = NAGA_SERPENT
NAGA_SIREN = NAGA_WITCH
NAGA_MYRMIDON = FourCC("nmyr")
NAGA_REAVER = FourCC("nnmg")
NAGA_TURTLE = NAGA_HYDRA
NAGA_ROYAL = FourCC("nnrg")
NAGA_TEMPLE = FourCC("nntt")
NAGA_CORAL = FourCC("nnfm")
NAGA_SHRINE = FourCC("nnsa")
NAGA_SPAWNING = FourCC("nnsg")
NAGA_GUARDIAN = FourCC("nntg")
NAGA_ALTAR = FourCC("nnad")
UPG_NAGA_ARMOR = FourCC("Rnam")
UPG_NAGA_ATTACK = FourCC("Rnat")
UPG_NAGA_ABOLISH = FourCC("Rnsi")
UPG_SIREN = FourCC("Rnsw")
UPG_NAGA_ENSNARE = FourCC("Rnen")
M1 = 60
M2 = 2 * 60
M3 = 3 * 60
M4 = 4 * 60
M5 = 5 * 60
M6 = 6 * 60
M7 = 7 * 60
M8 = 8 * 60
M9 = 9 * 60
M10 = 10 * 60
M11 = 11 * 60
M12 = 12 * 60
M13 = 13 * 60
M14 = 14 * 60
M15 = 15 * 60
EASY = 1
NORMAL = 2
HARD = 3
INSANE = 4
MELEE_NEWBIE = 1
MELEE_NORMAL = 2
MELEE_INSANE = 3
ATTACK_CAPTAIN = 1
DEFENSE_CAPTAIN = 2
BOTH_CAPTAINS = 3
BUILD_UNIT = 1
BUILD_UPGRADE = 2
BUILD_EXPAND = 3
UPKEEP_TIER1 = 50
UPKEEP_TIER2 = 80
ai_player = nil
sleep_seconds = 0
total_gold = 0
total_wood = 0
gold_buffer = 0
difficulty = NORMAL
exp_seen = 0
racial_farm = FourCC("hhou")
hero_id = FourCC("Hamg")
hero_id2 = FourCC("Hmkg")
hero_id3 = FourCC("Hpal")
skill = __jarray(0)
skills1 = __jarray(0)
skills2 = __jarray(0)
skills3 = __jarray(0)
max_hero_level = 0
harass_qty = __jarray(0)
harass_max = __jarray(0)
harass_units = __jarray(0)
harass_length = 0
defense_qty = __jarray(0)
defense_units = __jarray(0)
defense_length = 0
build_qty = __jarray(0)
build_type = __jarray(0)
build_item = __jarray(0)
build_town = __jarray(0)
build_length = 0
campaign_gold_peons = 5
campaign_wood_peons = 3
campaign_basics_speed = 5
min_creeps = -1
max_creeps = -1
harvest_town1 = true
harvest_town2 = true
harvest_town3 = true
do_campaign_farms = true
two_heroes = false
allow_air_creeps = false
take_exp = false
allow_signal_abort = false
ready_for_zeppelin = true
get_zeppelin = false
build_campaign_attackers = true
do_debug_cheats = false
trace_on = true
zep_next_wave = false
form_group_timeouts = true
function PlayerEx(slot)
return Player(slot - 1)
end

function Trace(message)
if trace_on then
DisplayText(GetAiPlayer(), message)
end
end

function TraceI(message, val)
if trace_on then
DisplayTextI(GetAiPlayer(), message, val)
end
end

function TraceII(message, v1, v2)
if trace_on then
DisplayTextII(GetAiPlayer(), message, v1, v2)
end
end

function TraceIII(message, v1, v2, v3)
if trace_on then
DisplayTextIII(GetAiPlayer(), message, v1, v2, v3)
end
end

function InitAI()
ai_player = Player(GetAiPlayer())
sleep_seconds = 0
StopGathering()
end

function StandardAI(heroes, peons, attacks)
local isNewbie = (MeleeDifficulty() == MELEE_NEWBIE)

InitAI()
SetMeleeAI()
SetDefendPlayer(true)
SetGroupsFlee(not isNewbie)
SetHeroesBuyItems(not isNewbie)
SetHeroesFlee(true)
SetHeroesTakeItems(true)
SetIgnoreInjured(true)
SetPeonsRepair(true)
SetSmartArtillery(not isNewbie)
SetTargetHeroes(not isNewbie)
SetUnitsFlee(not isNewbie)
SetWatchMegaTargets(true)
CreateCaptains()
SetHeroLevels(heroes)
Sleep(0.1)
StartThread(peons)
StartThread(attacks)
end

function Min(A, B)
if A < B then
return A
else
return B
end
end

function Max(A, B)
if A > B then
return A
else
return B
end
end

function SetZepNextWave()
zep_next_wave = true
end

function SuicideSleep(seconds)
sleep_seconds = sleep_seconds - seconds
while (true) do
if (seconds <= 0) then break end
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
if seconds >= 5 then
Sleep(5)
seconds = seconds - 5
else
Sleep(seconds)
seconds = 0
end
end
end

function WaitForSignal()
local cmd
local display = false

while (true) do
if (CommandsWaiting() ~= 0) then break end
Trace("waiting for a signal to begin AI script...\n")
display = true
Sleep(2)
if (CommandsWaiting() ~= 0) then break end
Sleep(2)
if (CommandsWaiting() ~= 0) then break end
Sleep(2)
if (CommandsWaiting() ~= 0) then break end
Sleep(2)
if (CommandsWaiting() ~= 0) then break end
Sleep(2)
end
if display then
Trace("signal received, beginning AI script\n")
end
cmd = GetLastCommand()
PopLastCommand()
return cmd
end

function SetWoodPeons(count)
campaign_wood_peons = count
end

function SetGoldPeons(count)
campaign_gold_peons = count
end

function SetHarvestLumber(harvest)
if harvest then
campaign_wood_peons = 3
else
campaign_wood_peons = 0
end
end

function SetFormGroupTimeouts(state)
form_group_timeouts = state
end

function DoCampaignFarms(state)
do_campaign_farms = state
end

function GetMinorCreep()
return GetCreepCamp(0, 9, false)
end

function GetMajorCreep()
return GetCreepCamp(10, 100, allow_air_creeps)
end

function GetGold()
return GetPlayerState(ai_player, PLAYER_STATE_RESOURCE_GOLD)
end

function GetWood()
return GetPlayerState(ai_player, PLAYER_STATE_RESOURCE_LUMBER)
end

function InitBuildArray()
build_length = 0
end

function InitAssaultGroup()
harass_length = 0
end

function InitDefenseGroup()
defense_length = 0
end

function InitMeleeGroup()
InitAssaultGroup()
RemoveInjuries()
RemoveSiege()
end

function PrepFullSuicide()
InitAssaultGroup()
InitDefenseGroup()
campaign_gold_peons = 0
campaign_wood_peons = 0
end

function SetReplacements(easy, med, hard)
if difficulty == EASY then
SetReplacementCount(easy)
elseif difficulty == NORMAL then
SetReplacementCount(med)
else
SetReplacementCount(hard)
end
end

function StartTownBuilder(func)
StartThread(func)
end

function SetBuildAll(t, qty, unitid, town)
if qty > 0 then
build_qty[build_length] = qty
build_type[build_length] = t
build_item[build_length] = unitid
build_town[build_length] = town
build_length = build_length + 1
end
end

function SetBuildUnit(qty, unitid)
SetBuildAll(BUILD_UNIT, qty, unitid, -1)
end

function SetBuildNext(qty, unitid)
local has = GetUnitCount(unitid)

if has >= qty then
return
end
SetBuildAll(BUILD_UNIT, GetUnitCountDone(unitid) + 1, unitid, -1)
end

function SetBuildUnitEx(easy, med, hard, unitid)
if difficulty == EASY then
SetBuildAll(BUILD_UNIT, easy, unitid, -1)
elseif difficulty == NORMAL then
SetBuildAll(BUILD_UNIT, med, unitid, -1)
else
SetBuildAll(BUILD_UNIT, hard, unitid, -1)
end
end

function SecondaryTown(town, qty, unitid)
SetBuildAll(BUILD_UNIT, qty, unitid, town)
end

function SecTown(town, qty, unitid)
SetBuildAll(BUILD_UNIT, qty, unitid, town)
end

function SetBuildUpgr(qty, unitid)
if (MeleeDifficulty() ~= MELEE_NEWBIE or qty == 1) then
SetBuildAll(BUILD_UPGRADE, qty, unitid, -1)
end
end

function SetBuildUpgrEx(easy, med, hard, unitid)
if difficulty == EASY then
SetBuildAll(BUILD_UPGRADE, easy, unitid, -1)
elseif difficulty == NORMAL then
SetBuildAll(BUILD_UPGRADE, med, unitid, -1)
else
SetBuildAll(BUILD_UPGRADE, hard, unitid, -1)
end
end

function SetBuildExpa(qty, unitid)
SetBuildAll(BUILD_EXPAND, qty, unitid, -1)
end

function StartUpgrade(level, upgid)
local gold_cost
local wood_cost

if GetUpgradeLevel(upgid) >= level then
return true
end
gold_cost = GetUpgradeGoldCost(upgid)
if total_gold < gold_cost then
return false
end
wood_cost = GetUpgradeWoodCost(upgid)
if total_wood < wood_cost then
return false
end
return SetUpgrade(upgid)
end

function BuildFactory(unitid)
if (GetGold() > 1000 and GetWood() > 500) then
SetBuildUnit(2, unitid)
else
SetBuildUnit(1, unitid)
end
end

function HallsCompleted(unitid)
return GetUnitCount(unitid) == GetUnitCountDone(unitid)
end

function GuardSecondary(townid, qty, unitid)
if (TownHasHall(townid) and TownHasMine(townid)) then
SecondaryTown(townid, qty, unitid)
end
end

function GetUnitCountEx(unitid, only_done, townid)
if townid == -1 then
if only_done then
return GetUnitCountDone(unitid)
else
return GetUnitCount(unitid)
end
else
return GetTownUnitCount(unitid, townid, only_done)
end
end

function TownCountEx(unitid, only_done, townid)
local have_qty = GetUnitCountEx(unitid, only_done, townid)

if unitid == TOWN_HALL then
have_qty = have_qty + GetUnitCountEx(KEEP, false, townid) + GetUnitCountEx(CASTLE, false, townid)
elseif unitid == KEEP then
have_qty = have_qty + GetUnitCountEx(CASTLE, false, townid)
elseif unitid == WATCH_TOWER then
have_qty = have_qty + GetUnitCountEx(GUARD_TOWER, false, townid) + GetUnitCountEx(CANNON_TOWER, false, townid) + GetUnitCountEx(ARCANE_TOWER, false, townid)
elseif unitid == PEASANT then
have_qty = have_qty + GetUnitCountEx(MILITIA, false, townid)
elseif unitid == GREAT_HALL then
have_qty = have_qty + GetUnitCountEx(STRONGHOLD, false, townid) + GetUnitCountEx(FORTRESS, false, townid)
elseif unitid == STRONGHOLD then
have_qty = have_qty + GetUnitCountEx(FORTRESS, false, townid)
elseif unitid == HEAD_HUNTER then
have_qty = have_qty + GetUnitCountEx(BERSERKER, false, townid)
elseif unitid == SPIRIT_WALKER then
have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER_M, false, townid)
elseif unitid == SPIRIT_WALKER_M then
have_qty = have_qty + GetUnitCountEx(SPIRIT_WALKER, only_done, townid)
elseif unitid == NECROPOLIS_1 then
have_qty = have_qty + GetUnitCountEx(NECROPOLIS_2, false, townid) + GetUnitCountEx(NECROPOLIS_3, false, townid)
elseif unitid == NECROPOLIS_2 then
have_qty = have_qty + GetUnitCountEx(NECROPOLIS_3, false, townid)
elseif unitid == ZIGGURAT_1 then
have_qty = have_qty + GetUnitCountEx(ZIGGURAT_2, false, townid) + GetUnitCountEx(ZIGGURAT_FROST, false, townid)
elseif unitid == GARGOYLE then
have_qty = have_qty + GetUnitCountEx(GARGOYLE_MORPH, false, townid)
elseif unitid == TREE_LIFE then
have_qty = have_qty + GetUnitCountEx(TREE_AGES, false, townid) + GetUnitCountEx(TREE_ETERNITY, false, townid)
elseif unitid == TREE_AGES then
have_qty = have_qty + GetUnitCountEx(TREE_ETERNITY, false, townid)
elseif unitid == DRUID_TALON then
have_qty = have_qty + GetUnitCountEx(DRUID_TALON_M, false, townid)
elseif unitid == DRUID_TALON_M then
have_qty = have_qty + GetUnitCountEx(DRUID_TALON, only_done, townid)
elseif unitid == DRUID_CLAW then
have_qty = have_qty + GetUnitCountEx(DRUID_CLAW_M, false, townid)
elseif unitid == DRUID_CLAW_M then
have_qty = have_qty + GetUnitCountEx(DRUID_CLAW, only_done, townid)
elseif unitid == ILLIDAN then
have_qty = have_qty + GetUnitCountEx(ILLIDAN_DEMON, false, townid)
end
return have_qty
end

function TownCountDone(base)
return TownCountEx(base, true, -1)
end

function TownCount(base)
return TownCountEx(base, false, -1)
end

function BasicExpansion(build_it, unitid)
if (build_it and HallsCompleted(unitid)) then
SetBuildExpa(TownCount(unitid) + 1, unitid)
end
end

function UpgradeAll(baseid, newid)
SetBuildUnit(TownCountDone(baseid), newid)
end

function TownCountTown(base, townid)
return TownCountEx(base, false, townid)
end

function FoodPool(food, weak, id1, use1, strong, id2, use2)
if strong then
SetBuildUnit((food - use1 * TownCount(id1)) // use2, id2)
elseif weak then
SetBuildUnit((food - use2 * TownCount(id2)) // use1, id1)
end
end

function MeleeTownHall(townid, unitid)
if (TownHasMine(townid) and not TownHasHall(townid)) then
SecondaryTown(townid, 1, unitid)
end
end

function WaitForUnits(unitid, qty)
while (true) do
if (TownCountDone(unitid) == qty) then break end
Sleep(2)
end
end

function StartUnit(ask_qty, unitid, town)
local have_qty
local need_qty
local afford_gold
local afford_wood
local afford_qty
local gold_cost
local wood_cost

if town == -1 then
have_qty = TownCount(unitid)
else
have_qty = TownCountTown(unitid, town)
end
if have_qty >= ask_qty then
return true
end
need_qty = ask_qty - have_qty
gold_cost = GetUnitGoldCost(unitid)
wood_cost = GetUnitWoodCost(unitid)
if gold_cost == 0 then
afford_gold = need_qty
else
afford_gold = total_gold // gold_cost
end
if afford_gold < need_qty then
afford_qty = afford_gold
else
afford_qty = need_qty
end
if wood_cost == 0 then
afford_wood = need_qty
else
afford_wood = total_wood // wood_cost
end
if afford_wood < afford_qty then
afford_qty = afford_wood
end
if afford_qty < 1 then
return false
end
total_gold = total_gold - gold_cost * need_qty
total_wood = total_wood - wood_cost * need_qty
if total_gold < 0 then
total_gold = 0
end
if total_wood < 0 then
total_wood = 0
end
return SetProduce(afford_qty, unitid, town)
end

function WaitForTown(towns, townid)
local i = 0

while (true) do
Sleep(10)
if (TownCount(townid) >= towns) then break end
i = i + 1
if (i == 12) then break end
end
end

function StartExpansion(qty, hall)
local count
local town
local peon
local gold_cost

count = TownCount(hall)
if count >= qty then
return true
end
town = GetNextExpansion()
if town == -1 then
return true
end
take_exp = true
gold_cost = GetUnitGoldCost(hall)
if gold_cost > total_gold then
return false
end
total_gold = total_gold - gold_cost
if GetExpansionFoe() ~= nil then
return true
end
peon = GetExpansionPeon()
if peon ~= nil then
return SetExpansion(peon, hall)
end
return true
end

function OneBuildLoop()
local index = 0
local qty
local id
local tp

total_gold = GetGold() - gold_buffer
total_wood = GetWood()
while (true) do
if (index == build_length) then break end
qty = build_qty[index]
id = build_item[index]
tp = build_type[index]
if tp == BUILD_UNIT then
if not StartUnit(qty, id, build_town[index]) then
return
end
elseif tp == BUILD_UPGRADE then
StartUpgrade(qty, id)
else
if not StartExpansion(qty, id) then
return
end
end
index = index + 1
end
end

function StaggerSleep(base, spread)
Sleep(base + spread * I2R(GetAiPlayer()) / I2R(GetPlayers()))
end

function BuildLoop()
OneBuildLoop()
StaggerSleep(1, 2)
while (true) do
OneBuildLoop()
Sleep(2)
end
end

function StartBuildLoop()
StartThread(BuildLoop)
end

function SetInitialWave(seconds)
sleep_seconds = seconds
end

function AddSleepSeconds(seconds)
sleep_seconds = sleep_seconds + seconds
end

function SleepForever()
Trace("going to sleep forever\n")
while (true) do
Sleep(100)
end
end

function PlayGame()
StartBuildLoop()
SleepForever()
end

function ConvertNeeds(unitid)
if GetUnitCount(unitid) < 1 then
StartUnit(1, unitid, -1)
end
end

function Conversions(desire, unitid)
if GetUnitCount(unitid) >= desire then
return
end
if unitid == HIPPO_RIDER then
ConvertNeeds(ARCHER)
ConvertNeeds(HIPPO)
MergeUnits(desire, ARCHER, HIPPO, HIPPO_RIDER)
elseif unitid == BLK_SPHINX then
ConvertNeeds(OBS_STATUE)
ConvertUnits(desire, OBS_STATUE)
end
end

function SetAssaultGroup(qty, max, unitid)
Conversions(max, unitid)
if (qty <= 0 and TownCountDone(unitid) == 0) then
return
end
harass_qty[harass_length] = qty
harass_max[harass_length] = max
harass_units[harass_length] = unitid
harass_length = harass_length + 1
end

function Interleave3(e1, m1, h1, u1, e2, m2, h2, u2, e3, m3, h3, u3)
local i1 = 1
local i2 = 1
local i3 = 1
local q1
local q2
local q3

if difficulty == EASY then
q1 = e1
q2 = e2
q3 = e3
elseif difficulty == NORMAL then
q1 = m1
q2 = m2
q3 = m3
else
q1 = h1
q2 = h2
q3 = h3
end
while (true) do
if ((q1 <= 0 and (q2 <= 0 and q3 <= 0))) then break end
if q1 > 0 then
SetAssaultGroup(i1, i1, u1)
q1 = q1 - 1
i1 = i1 + 1
end
if q2 > 0 then
SetAssaultGroup(i2, i2, u2)
q2 = q2 - 1
i2 = i2 + 1
end
if q3 > 0 then
SetAssaultGroup(i3, i3, u3)
q3 = q3 - 1
i3 = i3 + 1
end
end
end

function SetMeleeGroup(unitid)
if unitid == hero_id then
SetAssaultGroup(1, 9, unitid)
else
SetAssaultGroup((TownCountDone(unitid) * 3) // 4, 20, unitid)
end
end

function CampaignDefender(level, qty, unitid)
if (qty > 0 and difficulty >= level) then
defense_qty[defense_length] = qty
defense_units[defense_length] = unitid
defense_length = defense_length + 1
Conversions(qty, unitid)
SetBuildUnit(qty, unitid)
end
end

function CampaignDefenderEx(easy, med, hard, unitid)
if difficulty == EASY then
CampaignDefender(EASY, easy, unitid)
elseif difficulty == NORMAL then
CampaignDefender(NORMAL, med, unitid)
else
CampaignDefender(HARD, hard, unitid)
end
end

function CampaignAttacker(level, qty, unitid)
if (qty > 0 and difficulty >= level) then
SetAssaultGroup(qty, qty, unitid)
end
end

function CampaignAttackerEx(easy, med, hard, unitid)
if difficulty == EASY then
CampaignAttacker(EASY, easy, unitid)
elseif difficulty == NORMAL then
CampaignAttacker(NORMAL, med, unitid)
else
CampaignAttacker(HARD, hard, unitid)
end
end

function FormGroup(seconds, testReady)
local index
local count
local unitid
local desire
local readyPercent

if testReady == true then
readyPercent = 50
Trace("forming group, requiring healthy guys\n")
else
readyPercent = 0
Trace("forming group, unit health not important\n")
end
Trace("trying to gather forces\n")
while (true) do
SuicideSleep(seconds)
InitAssault()
index = 0
while (true) do
if (index == harass_length) then break end
unitid = harass_units[index]
desire = harass_max[index]
count = TownCountDone(unitid)
Conversions(desire, unitid)
if count >= desire then
AddAssault(desire, unitid)
else
desire = harass_qty[index]
if count < desire then
AddAssault(desire, unitid)
else
AddAssault(count, unitid)
end
end
index = index + 1
end
if (form_group_timeouts and (sleep_seconds < -60)) then
Trace("exit form group -- timeout\n")
elseif CaptainInCombat(true) then
Trace("exit form group -- can't form while already in combat\n")
elseif (CaptainIsFull() and CaptainReadiness() >= readyPercent) then
Trace("exit form group -- ready\n")
end
if ((form_group_timeouts and (sleep_seconds < -60))) then break end
if (CaptainInCombat(true)) then break end
if ((CaptainIsFull() and CaptainReadiness() >= readyPercent)) then break end
end
end

function WavePrepare(unitid)
return GetUnitBuildTime(unitid)
end

function PrepTime()
local unitid
local missing
local prep
local count
local largest = 30
local index = 0

while (true) do
if (index == harass_length) then break end
unitid = harass_units[index]
missing = harass_qty[index] + IgnoredUnits(unitid) - TownCount(unitid)
prep = WavePrepare(unitid) * missing
if prep > largest then
largest = prep
end
index = index + 1
end
TraceI("next wave will require around %d seconds to build and gather\n", largest)
return largest
end

function PrepSuicideOnPlayer(seconds)
local wave_prep = PrepTime()
local save_length

save_length = harass_length
harass_length = 0
AddSleepSeconds(seconds)
if sleep_seconds - wave_prep > 0 then
TraceI("going to sleep for %d seconds before gathering next attack wave\n", sleep_seconds - wave_prep)
SuicideSleep(sleep_seconds - wave_prep)
end
Trace("preparing suicide attack wave\n")
harass_length = save_length
if harass_length < 1 then
Trace("ERROR - no units specificed, exiting early\n")
return false
end
return true
end

function SleepUntilAtGoal()
while (true) do
if (CaptainRetreating()) then break end
if (CaptainAtGoal()) then break end
if (CaptainIsHome()) then break end
if (CaptainIsEmpty()) then break end
SuicideSleep(3)
end
end

function SleepInCombat()
local count = 0

if _DEBUG then
Trace("SleepInCombat\n")
end
while (true) do
while (true) do
if (not CaptainInCombat(true)) then break end
if (CaptainIsEmpty()) then break end
SuicideSleep(1)
end
count = count + 1
if (count >= 8) then break end
end
if _DEBUG then
Trace("exit SleepInCombat\n")
end
end

function AttackMoveXYA(x, y)
if zep_next_wave then
LoadZepWave(x, y)
zep_next_wave = false
end
AttackMoveXY(x, y)
SleepUntilAtGoal()
SleepInCombat()
end

function SuicideOnPlayerWave()
Trace("waiting for attack wave to enter combat\n")
while (true) do
if (allow_signal_abort and CommandsWaiting() ~= 0) then
Trace("ABORT -- attack wave override\n")
end
if CaptainInCombat(true) then
Trace("done - captain has entered combat\n")
end
if CaptainIsEmpty() then
Trace("done - all units are dead\n")
end
if sleep_seconds < -300 then
Trace("done - timeout, took too long to reach engage the enemy\n")
end
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
if (CaptainInCombat(true)) then break end
if (CaptainIsEmpty()) then break end
SuicideSleep(10)
if (sleep_seconds < -300) then break end
end
Trace("waiting for attack wave to die\n")
while (true) do
if (allow_signal_abort and CommandsWaiting() ~= 0) then
Trace("ABORT - attack wave override\n")
end
if CaptainIsEmpty() then
Trace("done - all units are dead\n")
end
if sleep_seconds < -300 then
Trace("done - timeout, took too long to reach engage the enemy\n")
end
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
if (CaptainIsEmpty()) then break end
SuicideSleep(10)
if (sleep_seconds < -300) then break end
end
end

function CommonSuicideOnPlayer(standard, bldgs, seconds, p, x, y)
local save_peons

if not PrepSuicideOnPlayer(seconds) then
return
end
save_peons = campaign_wood_peons
campaign_wood_peons = 0
while (true) do
if (allow_signal_abort and CommandsWaiting() ~= 0) then
Trace("ABORT -- attack wave override\n")
end
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
while (true) do
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
FormGroup(5, true)
if (sleep_seconds <= 0) then break end
TraceI("waiting %d seconds before suicide\n", sleep_seconds)
end
if standard then
if bldgs then
if (SuicidePlayer(p, sleep_seconds >= -60)) then break end
else
if (SuicidePlayerUnits(p, sleep_seconds >= -60)) then break end
end
else
AttackMoveXYA(x, y)
end
TraceI("waiting %d seconds before timeout\n", 60 + sleep_seconds)
SuicideSleep(5)
end
campaign_wood_peons = save_peons
harass_length = 0
SuicideOnPlayerWave()
end

function SuicideOnPlayer(seconds, p)
CommonSuicideOnPlayer(true, true, seconds, p, 0, 0)
end

function SuicideOnUnits(seconds, p)
CommonSuicideOnPlayer(true, false, seconds, p, 0, 0)
end

function SuicideOnPoint(seconds, p, x, y)
CommonSuicideOnPlayer(false, false, seconds, p, x, y)
end

function SuicideUntilSignal(seconds, p)
local save
local wave_prep = PrepTime()

while (true) do
AddSleepSeconds(seconds)
if sleep_seconds - wave_prep > 0 then
SuicideSleep(sleep_seconds - wave_prep)
end
save = campaign_wood_peons
campaign_wood_peons = 0
while (true) do
while (true) do
FormGroup(5, true)
if (sleep_seconds <= 0) then break end
if (CommandsWaiting() ~= 0) then break end
end
if (SuicidePlayer(p, sleep_seconds >= -60)) then break end
if (CommandsWaiting() ~= 0) then break end
SuicideSleep(3)
end
campaign_wood_peons = save
while (true) do
if (CaptainIsEmpty()) then break end
if (CommandsWaiting() ~= 0) then break end
SuicideSleep(5)
end
if (CommandsWaiting() ~= 0) then break end
end
end

function SuicideOnce(easy, med, hard, unitid)
if difficulty == EASY then
SuicideUnit(easy, unitid)
elseif difficulty == NORMAL then
SuicideUnit(med, unitid)
else
SuicideUnit(hard, unitid)
end
end

function SuicideUnitA(unitid)
if unitid ~= 0 then
SuicideUnit(1, unitid)
end
Sleep(0.1)
end

function SuicideUnitB(unitid, playerid)
if unitid ~= 0 then
SuicideUnitEx(1, unitid, playerid)
end
Sleep(0.1)
end

function SuicideUnits(u1, u2, u3, u4, u5, u6, u7, u8, u9, uA)
Trace("MASS SUICIDE - this script is now technically done\n")
PrepFullSuicide()
while (true) do
SuicideUnitA(u1)
SuicideUnitA(u2)
SuicideUnitA(u3)
SuicideUnitA(u4)
SuicideUnitA(u5)
SuicideUnitA(u6)
SuicideUnitA(u7)
SuicideUnitA(u8)
SuicideUnitA(u9)
SuicideUnitA(uA)
end
end

function SuicideUnitsEx(playerid, u1, u2, u3, u4, u5, u6, u7, u8, u9, uA)
Trace("MASS SUICIDE - this script is now technically done\n")
PrepFullSuicide()
while (true) do
SuicideUnitB(u1, playerid)
SuicideUnitB(u2, playerid)
SuicideUnitB(u3, playerid)
SuicideUnitB(u4, playerid)
SuicideUnitB(u5, playerid)
SuicideUnitB(u6, playerid)
SuicideUnitB(u7, playerid)
SuicideUnitB(u8, playerid)
SuicideUnitB(u9, playerid)
SuicideUnitB(uA, playerid)
end
end

function SuicideOnPlayerEx(easy, med, hard, p)
if difficulty == EASY then
SuicideOnPlayer(easy, p)
elseif difficulty == NORMAL then
SuicideOnPlayer(med, p)
else
SuicideOnPlayer(hard, p)
end
end

function SuicideOnUnitsEx(easy, med, hard, p)
if difficulty == EASY then
SuicideOnUnits(easy, p)
elseif difficulty == NORMAL then
SuicideOnUnits(med, p)
else
SuicideOnUnits(hard, p)
end
end

function SuicideOnPointEx(easy, med, hard, p, x, y)
if difficulty == EASY then
SuicideOnPoint(easy, p, x, y)
elseif difficulty == NORMAL then
SuicideOnPoint(med, p, x, y)
else
SuicideOnPoint(hard, p, x, y)
end
end

function ForeverSuicideOnPlayer(seconds, p)
local length = harass_length

while (true) do
if ((allow_signal_abort and CommandsWaiting() ~= 0)) then break end
SuicideOnPlayer(seconds, p)
harass_length = length
end
end

function CommonSleepUntilTargetDead(target, reform)
while (true) do
if (CaptainRetreating()) then break end
if (CaptainReadinessHP() <= 40) then break end
if (not UnitAlive(target)) then break end
if ((UnitInvis(target) and not IsUnitDetected(target, ai_player))) then break end
if not TownThreatened() then
AttackMoveKill(target)
end
SuicideSleep(3)
if (reform and sleep_seconds < -40) then
if CaptainInCombat(true) then
sleep_seconds = sleep_seconds + 5
else
sleep_seconds = 0
FormGroup(1, false)
end
end
end
end

function SleepUntilTargetDead(target)
CommonSleepUntilTargetDead(target, false)
end

function ReformUntilTargetDead(target)
if _DEBUG then
Trace("ReformUntilTargetDead\n")
end
CommonSleepUntilTargetDead(target, true)
end

function AttackMoveKillA(target)
if target == nil then
SuicideSleep(3)
return
end
if _DEBUG then
Trace("AttackMoveKillA\n")
end
AttackMoveKill(target)
ReformUntilTargetDead(target)
SleepInCombat()
end

function MinorCreepAttack()
local target = GetMinorCreep()

SetAllianceTarget(target)
FormGroup(3, true)
AttackMoveKillA(target)
end

function MajorCreepAttack()
local target = GetMajorCreep()

SetAllianceTarget(target)
FormGroup(3, true)
AttackMoveKillA(target)
end

function CreepAttackEx()
local target = GetCreepCamp(min_creeps, max_creeps, allow_air_creeps)

SetAllianceTarget(target)
FormGroup(3, true)
AttackMoveKillA(target)
end

function AnyPlayerAttack()
local hall

hall = GetEnemyExpansion()
if hall == nil then
StartGetEnemyBase()
while (true) do
if (not WaitGetEnemyBase()) then break end
SuicideSleep(1)
end
hall = GetEnemyBase()
end
SetAllianceTarget(hall)
FormGroup(3, true)
AttackMoveKillA(hall)
end

function ExpansionAttack()
local creep = GetExpansionFoe()
local x

FormGroup(3, true)
if creep == nil then
x = GetExpansionX()
if x ~= -1 then
AttackMoveXYA(x, GetExpansionY())
end
else
AttackMoveKillA(creep)
end
end

function AddSiege()
SetAssaultGroup(0, 9, SHADE)
SetAssaultGroup(0, 9, MEAT_WAGON)
SetAssaultGroup(0, 9, MORTAR)
SetAssaultGroup(0, 9, TANK)
SetAssaultGroup(0, 9, BALLISTA)
SetAssaultGroup(0, 9, CATAPULT)
end

function GetAllyCount(whichPlayer)
local playerIndex = 0
local count = 0
local indexPlayer

while (true) do
indexPlayer = Player(playerIndex)
if whichPlayer ~= indexPlayer then
if GetPlayerAlliance(whichPlayer, indexPlayer, ALLIANCE_PASSIVE) then
if GetPlayerAlliance(indexPlayer, whichPlayer, ALLIANCE_PASSIVE) then
if GetPlayerStructureCount(indexPlayer, true) > 0 then
count = count + 1
end
end
end
end
playerIndex = playerIndex + 1
if (playerIndex == 12) then break end
end
return count
end

function SingleMeleeAttack(needs_exp, has_siege, major_ok, air_units)
local can_siege
local daytime
local hall
local mega
local creep
local common
local minimum
local allies

Trace("===SingleMeleeAttack===\n")
if TownThreatened() then
Trace("sleep 2, town threatened\n")
Sleep(2)
return
end
if (get_zeppelin and (GetGold() > 300 and GetWood() > 100)) then
Trace("purchase zep\n")
PurchaseZeppelin()
get_zeppelin = false
ready_for_zeppelin = false
return
end
ready_for_zeppelin = true
allies = GetAllyCount(ai_player) > 0
if (allies and MeleeDifficulty() ~= MELEE_NEWBIE) then
common = GetAllianceTarget()
if common ~= nil then
Trace("join ally force\n")
if GetMegaTarget() ~= nil then
AddSiege()
end
FormGroup(3, true)
AttackMoveKillA(common)
SetAllianceTarget(nil)
return
end
end
if needs_exp then
Trace("needs exp\n")
creep = GetExpansionFoe()
if creep ~= nil then
Trace("attack exp\n")
SetAllianceTarget(creep)
FormGroup(3, true)
AttackMoveKillA(creep)
Sleep(20)
take_exp = false
return
end
end
if MeleeDifficulty() ~= MELEE_NEWBIE then
mega = GetMegaTarget()
if mega ~= nil then
Trace("MEGA TARGET!!!\n")
AddSiege()
FormGroup(3, true)
AttackMoveKillA(mega)
return
end
end
hall = GetEnemyExpansion()
daytime = GetFloatGameState(GAME_STATE_TIME_OF_DAY)
can_siege = (has_siege and (air_units or (daytime >= 4 and daytime <= 12)))
if (hall ~= nil and (can_siege or not IsTowered(hall))) then
Trace("test player town attack\n")
if MeleeDifficulty() == MELEE_NEWBIE then
minimum = 3
elseif (allies and MeleeDifficulty() == MELEE_NORMAL) then
minimum = 1
else
minimum = 0
end
if exp_seen >= minimum then
Trace("do player town attack\n")
exp_seen = 0
AddSiege()
SetAllianceTarget(hall)
FormGroup(3, true)
AttackMoveKillA(hall)
return
end
exp_seen = exp_seen + 1
end
if can_siege then
Trace("attack player's town\n")
AddSiege()
AnyPlayerAttack()
return
end
if min_creeps ~= -1 then
TraceI("custom creep attack %d\n", max_creeps)
CreepAttackEx()
return
end
if major_ok then
Trace("major creep attack\n")
MajorCreepAttack()
return
end
Trace("minor creep attack\n")
MinorCreepAttack()
end

function GetZeppelin()
if ready_for_zeppelin then
get_zeppelin = true
end
end

function FoodUsed()
return GetPlayerState(ai_player, PLAYER_STATE_RESOURCE_FOOD_USED)
end

function FoodCap()
return GetPlayerState(ai_player, PLAYER_STATE_RESOURCE_FOOD_CAP)
end

function FoodSpace()
return FoodCap() - FoodUsed()
end

function FoodAvail(base)
return GetFoodMade(racial_farm) * TownCount(racial_farm) + GetFoodMade(base) * TownCount(base)
end

function BuildAttackers()
local index = 0
local unitid
local desire
local count

while (true) do
if (index == harass_length) then break end
unitid = harass_units[index]
desire = harass_qty[index] + IgnoredUnits(unitid)
count = TownCount(unitid)
if count ~= desire then
if not StartUnit(desire, unitid, -1) then
return
end
end
index = index + 1
end
end

function BuildDefenders()
local index = 0
local unitid
local qty

while (true) do
if (index == defense_length) then break end
unitid = defense_units[index]
qty = defense_qty[index]
Conversions(qty, unitid)
AddDefenders(qty, unitid)
index = index + 1
end
end

function CampaignBasicsA()
local food_each = GetFoodMade(racial_farm)
local on_wood

ClearHarvestAI()
if CaptainInCombat(false) then
on_wood = 0
else
on_wood = campaign_wood_peons
end
HarvestGold(0, campaign_gold_peons)
HarvestWood(0, on_wood)
if harvest_town1 then
HarvestGold(1, campaign_gold_peons)
HarvestWood(1, on_wood)
end
if harvest_town2 then
HarvestGold(2, campaign_gold_peons)
HarvestWood(2, on_wood)
end
if harvest_town3 then
HarvestGold(3, campaign_gold_peons)
HarvestWood(3, on_wood)
end
if (do_campaign_farms and FoodUsed() + food_each - 1 > food_each * (TownCount(racial_farm) + 1)) then
StartUnit(TownCount(racial_farm) + 1, racial_farm, -1)
end
if build_campaign_attackers then
BuildAttackers()
end
if not CaptainInCombat(false) then
BuildDefenders()
end
FillGuardPosts()
ReturnGuardPosts()
end

function CampaignBasics()
Sleep(1)
CampaignBasicsA()
StaggerSleep(1, 5)
while (true) do
CampaignBasicsA()
Sleep(campaign_basics_speed)
end
end

function CampaignAI(farms, heroes)
if GetGameDifficulty() == MAP_DIFFICULTY_EASY then
difficulty = EASY
SetTargetHeroes(false)
SetUnitsFlee(false)
elseif GetGameDifficulty() == MAP_DIFFICULTY_NORMAL then
difficulty = NORMAL
SetTargetHeroes(false)
SetUnitsFlee(false)
elseif GetGameDifficulty() == MAP_DIFFICULTY_HARD then
difficulty = HARD
SetPeonsRepair(true)
else
difficulty = INSANE
end
InitAI()
InitBuildArray()
InitAssaultGroup()
CreateCaptains()
SetNewHeroes(false)
if heroes ~= nil then
SetHeroLevels(heroes)
end
SetHeroesFlee(false)
SetGroupsFlee(false)
SetSlowChopping(true)
GroupTimedLife(false)
SetCampaignAI()
Sleep(0.1)
racial_farm = farms
StartThread(CampaignBasics)
StartBuildLoop()
end

function UnsummonAll()
local bldg

while (true) do
bldg = GetBuilding(ai_player)
if (bldg == nil) then break end
Unsummon(bldg)
Sleep(2)
end
end

function SkillArrays()
local level = GetHeroLevelAI()

if level > max_hero_level then
max_hero_level = level
end
if GetHeroId() == hero_id then
return skills1[level]
elseif GetHeroId() == hero_id2 then
return skills2[level]
else
return skills3[level]
end
end

function SetSkillArray(index, id)
local i = 1

if index == 1 then
if hero_id ~= id then
return
end
while (true) do
skills1[i] = skill[i]
if (i == 10) then break end
i = i + 1
end
elseif index == 2 then
if hero_id2 ~= id then
return
end
while (true) do
skills2[i] = skill[i]
if (i == 10) then break end
i = i + 1
end
else
if hero_id3 ~= id then
return
end
while (true) do
skills3[i] = skill[i]
if (i == 10) then break end
i = i + 1
end
end
end

function AwaitMeleeHeroes()
if GetUnitCountDone(hero_id2) > 0 then
two_heroes = true
end
while (true) do
if ((GetUnitCountDone(hero_id) > 0 and (take_exp or (not two_heroes or GetUnitCountDone(hero_id2) > 0)))) then break end
Sleep(1)
end
end

function PickMeleeHero(raceid)
local first
local second
local third
local last
local heroes = __jarray(0)

if raceid == RACE_HUMAN then
heroes[1] = ARCHMAGE
heroes[2] = MTN_KING
heroes[3] = PALADIN
heroes[4] = BLOOD_MAGE
elseif raceid == RACE_ORC then
heroes[1] = BLADE_MASTER
heroes[2] = FAR_SEER
heroes[3] = TAUREN_CHIEF
heroes[4] = SHADOW_HUNTER
elseif raceid == RACE_NIGHTELF then
heroes[1] = DEMON_HUNTER
heroes[2] = KEEPER
heroes[3] = MOON_BABE
heroes[4] = WARDEN
elseif raceid == RACE_UNDEAD then
heroes[1] = DEATH_KNIGHT
heroes[2] = DREAD_LORD
heroes[3] = LICH
heroes[4] = CRYPT_LORD
else
hero_id = 0
end
if VersionCompatible(VERSION_FROZEN_THRONE) then
last = 4
else
last = 3
end
first = GetRandomInt(1, last)
second = GetRandomInt(1, last - 1)
third = GetRandomInt(1, last - 2)
hero_id = heroes[first]
heroes[first] = heroes[last]
hero_id2 = heroes[second]
heroes[second] = heroes[last - 1]
hero_id3 = heroes[third]
return hero_id
end
 
Back
Top