//TESH.scrollpos=0
//TESH.alwaysfold=0
function Juggernaut_ChargeSwap takes unit jugg_unit returns nothing
local integer i
set i = 0
loop
exitwhen i > 15
call UnitRemoveAbility(jugg_unit, udg_JuggCharge[i])
set i = i + 1
endloop
set i = 0
endfunction
Name | Type | is_array | initial_value |
AfterDamageEvent | real | No | |
AOEDamageEvent | real | No | |
Chaos | integer | Yes | |
Chaos_Off | boolean | Yes | |
Chaos_Player | player | Yes | |
Chaos_Time | real | Yes | |
ClearDamageEvent | trigger | No | |
DAMAGE_FACTOR_BRACERS | real | No | |
DAMAGE_FACTOR_ELUNES | real | No | |
DAMAGE_FACTOR_ETHEREAL | real | No | |
DamageBlockingAbility | abilcode | No | |
DamageEvent | real | No | |
DamageEventAmount | real | No | |
DamageEventAOE | integer | No | |
DamageEventAOEGroup | group | No | |
DamageEventLevel | integer | No | |
DamageEventOverride | boolean | No | |
DamageEventPrevAmt | real | No | |
DamageEventSource | unit | No | |
DamageEventsWasted | integer | No | |
DamageEventTarget | unit | No | |
DamageEventTrigger | trigger | No | |
DamageEventType | integer | No | |
DamageModifierEvent | real | No | |
DamageTypeBlocked | integer | No | |
DamageTypeCriticalStrike | integer | No | |
DamageTypeExplosive | integer | No | |
DamageTypeHeal | integer | No | |
DamageTypeReduced | integer | No | |
DmgEvBracers | itemcode | No | |
DmgEvRecursionN | integer | No | |
DmgEvRunning | boolean | No | |
DmgEvStarted | boolean | No | |
DmgEvTimer | timer | No | |
DmgEvTrig | trigger | No | |
EnhancedDamageTarget | unit | No | |
HideDamageFrom | boolean | Yes | |
IsDamageSpell | boolean | No | |
JuggCharge | abilcode | Yes | |
LastDamageHP | real | No | |
LastDmgPrevAmount | real | Yes | |
LastDmgPrevType | integer | Yes | |
LastDmgSource | unit | Yes | |
LastDmgTarget | unit | Yes | |
LastDmgValue | real | Yes | |
LastDmgWasSpell | boolean | Yes | |
NextDamageOverride | boolean | No | |
NextDamageType | integer | No | |
NSeal | integer | Yes | |
NSeal_BloodM | boolean | Yes | |
NSeal_Off | boolean | Yes | |
NSeal_Picked | unit | Yes | |
NSeal_Point | location | Yes | |
NSeal_Target | unit | Yes | |
NSeal_Time | real | Yes | |
PlayList | string | No | |
RockS | integer | Yes | |
RockS_Off | boolean | Yes | |
RockS_RemAttacks | integer | Yes | |
RockS_Target | unit | Yes | |
RockS_Time | real | Yes | |
SpellDamageAbility | abilcode | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UnitDamageRegistered | boolean | Yes | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes |
//TESH.scrollpos=0
//TESH.alwaysfold=0
library HumanSetup initializer Init requires CustomRaceSystem
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Human",RACE_HUMAN,1.0)
call c.setTownHall('htow') // Town Hall
call c.addWorkerType('hpea',c.NEAR_MINE,5) // Peasant
call c.addHeroType('Hpal') // Paladin
call c.addHeroType('Hamg') // Archmage
call c.addHeroType('Hmkg') // Mountain King
call c.addHeroType('Hblm') // Blood Mage
call c.setAIScript("human.ai")
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library OrcSetup initializer Init requires CustomRaceSystem
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Orc",RACE_ORC,1.0)
call c.setTownHall('ogre') // Great Hall
call c.addWorkerType('opeo',c.NEAR_MINE,5) // Peon
call c.addHeroType('Obla') // Blademaster
call c.addHeroType('Ofar') // Far Seer
call c.addHeroType('Otch') // Tauren Chieftain
call c.addHeroType('Oshd') // Shadow Hunter
call c.setAIScript("orc.ai")
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library UndeadSetup initializer Init requires CustomRaceSystem
private function WorkerHideToggle takes nothing returns nothing
call ShowUnit(GetEnumUnit(),IsUnitHidden(GetEnumUnit()))
endfunction
private function HauntGoldMine takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call ForGroup(workers,function WorkerHideToggle)
call BlightGoldMineForPlayerBJ(goldmine,play)
call ForGroup(workers,function WorkerHideToggle)
call DestroyGroup(workers)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Undead",RACE_UNDEAD,1.0)
call c.setTownHall('unpl') // Necropolis
call c.addWorkerType('uaco',c.NEAR_MINE,3) // Acolyte
call c.addWorkerType('ugho',c.NEAR_HALL,1) // Ghoul
call c.addHeroType('Udea') // Death Knight
call c.addHeroType('Ulic') // Lich
call c.addHeroType('Udre') // Dreadlord
call c.addHeroType('Ucrl') // Crypt Lord
call c.setCallback(CustomRaceCall.HauntGoldMine)
call c.setAIScript("undead.ai")
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library NightElfSetup initializer Init requires CustomRaceSystem
private function EntangleGoldMine takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
call SetUnitPosition(townhall,GetUnitX(goldmine),GetUnitY(goldmine))
call IssueTargetOrder(townhall, "entangleinstant", goldmine)
call DestroyGroup(workers)
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Night Elf",RACE_NIGHTELF,1.0)
call c.setTownHall('etol') // Tree of Life
call c.addWorkerType('ewsp',c.NEAR_MINE,5) // Wisp
call c.addHeroType('Ekee') // Keeper of the Grove
call c.addHeroType('Emoo') // Priestess of the Moon
call c.addHeroType('Edem') // Demon Hunter
call c.addHeroType('Ewar') // Warden
call c.setCallback(CustomRaceCall.EntangleGoldMine)
call c.setAIScript("elf.ai")
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library WarsongSetup initializer Init requires CustomRaceSystem
private function WarsongConfig takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
if (GetLocalPlayer() == play) then
call ClearMapMusicBJ()
call StopMusicBJ(false)
set udg_PlayList = "Music\\Warsong1.mp3;Music\\Warsong2.mp3;Music\\Warsong3.mp3"
call PlayMusic(udg_PlayList)
endif
endfunction
private function Init takes nothing returns nothing
local CustomRace c = CustomRace.create("Warsong Clan",RACE_ORC,0.9)
call c.setTownHall('w019') // War Halls
call c.addWorkerType('w000',c.NEAR_MINE,4) // Gatherer
call c.addWorkerType('w003',c.NEAR_HALL,1) // Pathfinder
call c.addHeroType('W017') // Grom
call c.setCallback(CustomRaceCall.WarsongConfig)
call c.setAIScript("warsong.ai")
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
//==============================================================================
// Custom Race System by Archmage Owenalacaster
//==============================================================================
//
// Purpose:
// - Creates the starting units for custom races and replaces the standard
// Melee Initialization trigger. Custom races are selected by race and
// handicap.
//
// Usage:
// - Register a new custom race with CustomRace.create(name, RACE, handicap)
// Handicaps: Valid handicap values are 1.0, 0.9, 0.8, 0.7, 0.6 and 0.5.
// - Register a new custom race for all handicaps of a single race with
// CustomRace.createAll(name, RACE)
// - Extend the registration of a race with c.register(RACE, handicap)
// - Set the townhall type with c.setTownHall(unitid)
// - Add a new worker type with c.addWorkerType(unitid, priority, qty)
// Priorities: c.NEAR_MINE spawns workers near the mine, where workers
// typically spawn.
// c.NEAR_HALL spawns workers near the town hall, where
// Ghouls spawn.
// - Add a random hero type with c.addHeroType(unitid)
// - Set the ai script used by computer players with c.setAIScript(stringpath)
// - Set a callback function with c.setCallback(CustomRaceCall.function)
// Callbacks: The callback is executed after all the starting units for a
// player are created, and its purpose is to provide enhanced
// initial behaviour for a race. A good example of this with the
// standard races would be the Undead Goldmine Haunting and
// Night Elves Goldmine Entangling.
// The callback function passes as arguments all the units
// generated in addition to the nearest goldmine detected.
// Please note that if a random hero is not created, the last
// argument will have a null value, so always do a check.
// - Get a player's custom race name string with GetPlayerCustomRaceName(player)
//
// Notes:
// - Supports a maximum of 24 custom races.
// - Maximum for worker and hero types are configurable.
//
// Requirements:
// - JassHelper version 0.9.E.0 or newer (older versions may still work).
//
// Installation:
// - Create a new trigger called CustomRaceSystem.
// - Convert it to custom text and replace all the code with this code.
//
// Special Thanks:
// - Alevice: He practically co-wrote the code.
// - cosmicat: His formula for circular unit formation.
// Co-developing the single-array registry.
//
//==============================================================================
library CustomRaceSystem initializer Init
//===========================================================================
// CONFIGURATION SECTION
//===========================================================================
globals
// Unit Type Constants
private constant integer MAX_WORKERTYPES = 4
private constant integer MAX_HEROTYPES = 4
endglobals
//===========================================================================
// END CONFIGURATION SECTION
//===========================================================================
function interface CustomRaceCall takes player play, group workers, unit goldmine, unit townhall, unit randhero returns nothing
private function r2S takes race r returns string
if r == RACE_HUMAN then
return "Human"
elseif r == RACE_ORC then
return "Orc"
elseif r == RACE_UNDEAD then
return "Undead"
elseif r == RACE_NIGHTELF then
return "Night Elf"
endif
return "Unknown"
endfunction
private function r2I takes race r returns integer
if r == RACE_HUMAN then
return 1
elseif r == RACE_ORC then
return 2
elseif r == RACE_UNDEAD then
return 3
elseif r == RACE_NIGHTELF then
return 4
endif
return 5
endfunction
globals
// Victory Defeat Variables
private string array KEY_STRUCTURE
private integer KEY_STRUCTURE_COUNT = 0
endglobals
//===========================================================================
// STRUCT DATA
//===========================================================================
private keyword createStartingUnits
struct CustomRace
string name
// Town Hall Variable
integer townhallType = 0
//string townhallName
// Town Hall name is not currently supported.
// Worker Variables
integer totalWorkerTypes = 0
integer array workerType[MAX_WORKERTYPES]
integer array workerPriority[MAX_WORKERTYPES]
integer array workerQty[MAX_WORKERTYPES]
// Random Hero Variables
integer totalHeroTypes = 0
integer array heroType[MAX_HEROTYPES]
// AI Script Directory String Variable
string aiscript = ""
// Callback Variable
private CustomRaceCall c
// Registry Variable
static integer array REGISTRY
// Spawn Priority Variables
static integer NEAR_MINE = 0
static integer NEAR_HALL = 1
static method get takes race r, real h returns CustomRace
return CustomRace(.REGISTRY[((r2I(r)-1)*6)+(10-R2I(h*10.))])
endmethod
method register takes race r, real h returns boolean
local CustomRace c = CustomRace.get(r,h)
if c != 0 then
debug call BJDebugMsg("|cffff0000Registration of "+.name+" failed due to conflict with "+c.name+" registered for "+r2S(r)+" race Handicap "+R2S(h))
return false
endif
set .REGISTRY[((r2I(r)-1)*6)+(10-R2I(h*10.))] = integer(this)
return true
endmethod
static method create takes string name, race r, real h returns CustomRace
local CustomRace c = CustomRace.allocate()
set c.name = name
if not c.register(r,h) then
call c.destroy()
return 0
endif
return c
endmethod
static method createAll takes string name, race r returns CustomRace
local CustomRace c = CustomRace.allocate()
set c.name = name
if not c.register(r,1.0) and not c.register(r,0.9) and not c.register(r,0.8) and not c.register(r,0.7) and not c.register(r,0.6) and not c.register(r,0.5) then
call c.destroy()
return 0
endif
return c
endmethod
method setTownHall takes integer hallid returns nothing
set .townhallType = hallid
set KEY_STRUCTURE[KEY_STRUCTURE_COUNT] = UnitId2String(hallid)
set KEY_STRUCTURE_COUNT = KEY_STRUCTURE_COUNT+1
endmethod
method addWorkerType takes integer workerid, integer priority, integer quantity returns nothing
set .workerType[.totalWorkerTypes] = workerid
set .workerPriority[.totalWorkerTypes] = priority
set .workerQty[.totalWorkerTypes] = quantity
set .totalWorkerTypes = .totalWorkerTypes+1
endmethod
method addHeroType takes integer heroid returns nothing
local integer i = 0
set .heroType[.totalHeroTypes] = heroid
set .totalHeroTypes = .totalHeroTypes+1
loop
call SetPlayerTechMaxAllowed(Player(i),heroid,1)
set i = i+1
exitwhen i == bj_MAX_PLAYERS
endloop
endmethod
private method getRandomHeroType takes nothing returns integer
local integer randomindex = GetRandomInt(0,.totalHeroTypes-1)
return .heroType[randomindex]
endmethod
method setAIScript takes string s returns nothing
set .aiscript = s
endmethod
method setCallback takes CustomRaceCall callb returns nothing
set .c = callb
endmethod
private method createRandomHero takes player p, location loc returns unit
local unit h = CreateUnitAtLoc(p, .getRandomHeroType(), loc, bj_UNIT_FACING)
if bj_meleeGrantHeroItems then
call MeleeGrantItemsToHero(h)
endif
return h
endmethod
method createStartingUnits takes player p returns nothing
local location startLoc = GetPlayerStartLocationLoc(p)
local location nearMineLoc = startLoc
local location nearTownLoc = startLoc
local location spawnLoc = startLoc
local location heroLoc = startLoc
local unit nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
local unit myTownhall = null
local unit myRandHero = null
local group workerGroup = CreateGroup()
local integer workertypeindex = 0
local integer workerqty = 0
local integer spawnPriority = 0
if nearestMine != null then
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine),startLoc,320,0)
set nearTownLoc = MeleeGetProjectedLoc(startLoc,GetUnitLoc(nearestMine),288,0)
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine),startLoc,384,45)
endif
set myTownhall = CreateUnitAtLoc(p,.townhallType,startLoc,bj_UNIT_FACING)
loop
exitwhen workertypeindex == .totalWorkerTypes
set spawnPriority = .workerPriority[workertypeindex]
if (spawnPriority==.NEAR_HALL) then
set spawnLoc = nearTownLoc
elseif(spawnPriority==.NEAR_MINE) then
set spawnLoc = nearMineLoc
endif
loop
call GroupAddUnit(workerGroup, CreateUnitAtLoc(p,.workerType[workertypeindex],PolarProjectionBJ(spawnLoc,65,(I2R(workerqty)*(360.00 / I2R(.workerQty[workertypeindex]))) + 90),bj_UNIT_FACING))
set workerqty = workerqty + 1
exitwhen workerqty >= .workerQty[workertypeindex]
endloop
call RemoveLocation(spawnLoc)
set workerqty = 0
set workertypeindex = workertypeindex+1
endloop
if (IsMapFlagSet(MAP_RANDOM_HERO) and .totalHeroTypes>0 ) then
set myRandHero = .createRandomHero(p,heroLoc)
else
call SetPlayerState(p,PLAYER_STATE_RESOURCE_HERO_TOKENS,bj_MELEE_STARTING_HERO_TOKENS)
endif
if(.c!=0) then
call .c.evaluate(p,workerGroup,nearestMine,myTownhall,myRandHero)
else
call DestroyGroup(workerGroup)
endif
if nearMineLoc != startLoc then
call RemoveLocation(nearMineLoc)
call RemoveLocation(nearTownLoc)
call RemoveLocation(heroLoc)
endif
call RemoveLocation(startLoc)
set startLoc = null
set nearMineLoc = null
set nearTownLoc = null
set spawnLoc = null
set heroLoc = null
set nearestMine = null
set myTownhall = null
set myRandHero = null
set workerGroup = null
endmethod
endstruct
globals
private string array PLAYER_RACE
endglobals
function GetPlayerCustomRaceName takes player p returns string
return PLAYER_RACE[GetPlayerId(p)]
endfunction
//===========================================================================
// UNIT CREATION SECTION
//===========================================================================
private function CreateStartingUnitsForAllPlayers takes nothing returns nothing
local integer index = 0
local player indexPlayer
local race playerRace
local CustomRace c
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set playerRace = GetPlayerRace(indexPlayer)
set c = CustomRace.get(playerRace,GetPlayerHandicap(indexPlayer)+0.01)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_USER or (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER and c.aiscript != "" )) and c != 0 then
set PLAYER_RACE[index] = c.name
call c.createStartingUnits(indexPlayer)
elseif playerRace == RACE_HUMAN then
call MeleeStartingUnitsHuman(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_ORC then
call MeleeStartingUnitsOrc(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_NIGHTELF then
call MeleeStartingUnitsNightElf(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
elseif playerRace == RACE_UNDEAD then
call MeleeStartingUnitsUndead(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
else
call MeleeStartingUnitsUnknownRace(indexPlayer,GetStartLocationLoc(GetPlayerStartLocation(indexPlayer)),true,true,true)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// CUSTOM MELEE AI SECTION
//===========================================================================
private function CustomMeleeStartingAI takes nothing returns nothing
local integer index = 0
local player indexPlayer
local race indexRace
local CustomRace c
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set indexRace = GetPlayerRace(indexPlayer)
set c = CustomRace.get(indexRace,GetPlayerHandicap(indexPlayer)+0.01)
call SetPlayerHandicap(indexPlayer,1.0)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
// Run a race-specific melee AI script.
if c != 0 and c.aiscript != "" then
call StartMeleeAI(indexPlayer, c.aiscript)
elseif (indexRace == RACE_HUMAN) then
call PickMeleeAI(indexPlayer, "human.ai", null, null)
elseif (indexRace == RACE_ORC) then
call PickMeleeAI(indexPlayer, "orc.ai", null, null)
elseif (indexRace == RACE_UNDEAD) then
call PickMeleeAI(indexPlayer, "undead.ai", null, null)
call RecycleGuardPosition(bj_ghoul[index])
elseif (indexRace == RACE_NIGHTELF) then
call PickMeleeAI(indexPlayer, "elf.ai", null, null)
else
// Unrecognized race.
endif
call ShareEverythingWithTeamAI(indexPlayer)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// VICTORY DEFEAT SECTION
//===========================================================================
private function CustomGetAllyKeyStructureCount takes player whichPlayer returns integer
local integer i = 0
local integer keyStructs = 0
local integer playerIndex = 0
local player indexPlayer
loop
set indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "townhall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "greathall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "necropolis", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "treeoflife", true, true)
loop
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, KEY_STRUCTURE[i], true, true)
set i = i+1
exitwhen i == KEY_STRUCTURE_COUNT
endloop
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return keyStructs
endfunction
private function CustomPlayerIsCrippled takes player whichPlayer returns boolean
local integer allyStructures = MeleeGetAllyStructureCount(whichPlayer)
local integer allyKeyStructures = CustomGetAllyKeyStructureCount(whichPlayer)
return (allyStructures > 0) and (allyKeyStructures <= 0)
endfunction
private function CustomCheckForCrippledPlayers takes nothing returns nothing
local integer playerIndex
local player indexPlayer
local boolean isNowCrippled
call MeleeCheckForLosersAndVictors()
if bj_finishSoonAllExposed then
return
endif
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
set isNowCrippled = CustomPlayerIsCrippled(indexPlayer)
if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then
set bj_playerIsCrippled[playerIndex] = true
call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout)
if (GetLocalPlayer() == indexPlayer) then
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true)
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_WARNING_HUMAN"))
endif
elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then
set bj_playerIsCrippled[playerIndex] = false
call PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
if (MeleeGetAllyStructureCount(indexPlayer) > 0) then
if (bj_playerIsExposed[playerIndex]) then
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED"))
else
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED"))
endif
endif
endif
call MeleeExposePlayer(indexPlayer, false)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
endfunction
private function CustomInitVictoryDefeat takes nothing returns nothing
local trigger checker = CreateTrigger()
local trigger trig
local integer index
local player indexPlayer
set bj_finishSoonTimerDialog = CreateTimerDialog(null)
call TriggerAddAction(checker, function CustomCheckForCrippledPlayers)
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_SOON)
call TriggerAddAction(trig, function MeleeTriggerTournamentFinishSoon)
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig, EVENT_GAME_TOURNAMENT_FINISH_NOW)
call TriggerAddAction(trig, function MeleeTriggerTournamentFinishNow)
set index = 0
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set bj_meleeDefeated[index] = false
set bj_meleeVictoried[index] = false
set bj_playerIsCrippled[index] = false
set bj_playerIsExposed[index] = false
set bj_crippledTimer[index] = CreateTimer()
set bj_crippledTimerWindows[index] = CreateTimerDialog(bj_crippledTimer[index])
call TimerDialogSetTitle(bj_crippledTimerWindows[index], MeleeGetCrippledTimerMessage(indexPlayer))
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL, null)
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(checker, indexPlayer, EVENT_PLAYER_UNIT_CONSTRUCT_START, null)
call TriggerRegisterPlayerAllianceChange(checker, indexPlayer, ALLIANCE_PASSIVE)
call TriggerRegisterPlayerStateEvent(checker, indexPlayer, PLAYER_STATE_ALLIED_VICTORY, EQUAL, 1)
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_DEFEAT)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerDefeated)
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft)
else
set bj_meleeDefeated[index] = true
set bj_meleeVictoried[index] = false
if (IsPlayerObserver(indexPlayer)) then
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig, function MeleeTriggerActionPlayerLeft)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
call TimerStart(CreateTimer(), 2.0, false, function CustomCheckForCrippledPlayers)
endfunction
private function TimerAction takes nothing returns nothing
call SetFloatGameState(GAME_STATE_TIME_OF_DAY, bj_MELEE_STARTING_TOD)
call MeleeStartingHeroLimit()
call MeleeGrantHeroItems()
call MeleeStartingResources()
call MeleeClearExcessUnits()
call CreateStartingUnitsForAllPlayers()
call CustomMeleeStartingAI()
call CustomInitVictoryDefeat()
call DestroyTimer(GetExpiredTimer())
endfunction
private function Init takes nothing returns nothing
call TimerStart(CreateTimer(),0,false,function TimerAction)
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
//===========================================================================
// Damage Engine lets you detect, amplify, block or nullify damage. It even
// lets you detect if the damage was physical or from a spell. Just reference
// DamageEventAmount/Source/Target or the boolean IsDamageSpell, to get the
// necessary damage event data.
//
// - Detect damage: use the event "DamageEvent Equal to 1.00"
// - To change damage before it's dealt: use the event "DamageModifierEvent Equal to 1.00"
// - Detect damage after it was applied, use the event "AfterDamageEvent Equal to 1.00"
// - Detect spell damage: use the condition "IsDamageSpell Equal to True"
// - Detect zero-damage: use the event "DamageEvent Equal to 2.00" (an AfterDamageEvent will not fire for this)
//
// You can specify the DamageEventType before dealing triggered damage. To prevent an already-improbable error, I recommend running the trigger "ClearDamageEvent (Checking Conditions)" after dealing triggered damage from within a damage event:
// - Set NextDamageType = DamageTypeWhatever
// - Unit - Cause...
// - Trigger - Run ClearDamageEvent (Checking Conditions)
//
// You can modify the DamageEventAmount and the DamageEventType from a "DamageModifierEvent Equal to 1.00" trigger.
// - If the amount is modified to negative, it will count as a heal.
// - If the amount is set to 0, no damage will be dealt.
//
// If you need to reference the original in-game damage, use the variable "DamageEventPrevAmt".
//
//===========================================================================
// Programming note about "integer i" and "udg_DmgEvRecursionN": integer i
// ranges from -1 upwards. "udg_DmgEvRecursionN" ranges from 0 upwards.
// "integer i" is always 1 less than "udg_DmgEvRecursionN"
//
function DmgEvResetVars takes nothing returns nothing
local integer i = udg_DmgEvRecursionN - 2
set udg_DmgEvRecursionN = i + 1
if i >= 0 then
set udg_DamageEventPrevAmt = udg_LastDmgPrevAmount[i]
set udg_DamageEventAmount = udg_LastDmgValue[i]
set udg_DamageEventSource = udg_LastDmgSource[i]
set udg_DamageEventTarget = udg_LastDmgTarget[i]
set udg_IsDamageSpell = udg_LastDmgWasSpell[i]
set udg_DamageEventType = udg_LastDmgPrevType[i]
endif
endfunction
function CheckDamagedLifeEvent takes boolean clear returns nothing
if clear then
set udg_NextDamageOverride = false
set udg_NextDamageType = 0
endif
if udg_DmgEvTrig != null then
call DestroyTrigger(udg_DmgEvTrig)
set udg_DmgEvTrig = null
if udg_IsDamageSpell then
call SetWidgetLife(udg_DamageEventTarget, RMaxBJ(udg_LastDamageHP, 0.41))
if udg_LastDamageHP <= 0.405 then
if udg_DamageEventType < 0 then
call SetUnitExploded(udg_DamageEventTarget, true)
endif
//Kill the unit
call DisableTrigger(udg_DamageEventTrigger)
call UnitDamageTarget(udg_DamageEventSource, udg_DamageEventTarget, -999, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(udg_DamageEventTrigger)
endif
elseif GetUnitAbilityLevel(udg_DamageEventTarget, udg_DamageBlockingAbility) > 0 then
call UnitRemoveAbility(udg_DamageEventTarget, udg_DamageBlockingAbility)
call SetWidgetLife(udg_DamageEventTarget, udg_LastDamageHP)
endif
if udg_DamageEventAmount != 0.00 and not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_AfterDamageEvent = 0.00
set udg_AfterDamageEvent = 1.00
set udg_AfterDamageEvent = 0.00
endif
call DmgEvResetVars()
endif
endfunction
function DmgEvOnAOEEnd takes nothing returns nothing
if udg_DamageEventAOE > 1 then
set udg_AOEDamageEvent = 0.00
set udg_AOEDamageEvent = 1.00
set udg_AOEDamageEvent = 0.00
set udg_DamageEventAOE = 1
endif
set udg_DamageEventLevel = 1
set udg_EnhancedDamageTarget = null
call GroupClear(udg_DamageEventAOEGroup)
endfunction
function DmgEvOnExpire takes nothing returns nothing
set udg_DmgEvStarted = false
call CheckDamagedLifeEvent(true)
//Reset things so they don't perpetuate for AoE/Level target detection
call DmgEvOnAOEEnd()
set udg_DamageEventTarget = null
set udg_DamageEventSource = null
endfunction
function PreCheckDamagedLifeEvent takes nothing returns boolean
call CheckDamagedLifeEvent(true)
return false
endfunction
function OnUnitDamage takes nothing returns boolean
local boolean override = udg_DamageEventOverride
local integer i
local integer e = udg_DamageEventLevel
local integer a = udg_DamageEventAOE
local string s
local real prevAmount
local real life
local real prevLife
local unit u
local unit f
call CheckDamagedLifeEvent(false) //in case the unit state event failed and the 0.00 second timer hasn't yet expired
set i = udg_DmgEvRecursionN - 1 //Had to be moved here due to false recursion tracking
if i < 0 then
//Added 25 July 2017 to detect AOE damage or multiple single-target damage
set u = udg_DamageEventTarget
set f = udg_DamageEventSource
elseif i < 16 then
set udg_LastDmgPrevAmount[i]= udg_DamageEventPrevAmt
set udg_LastDmgValue[i] = udg_DamageEventAmount
set udg_LastDmgSource[i] = udg_DamageEventSource
set udg_LastDmgTarget[i] = udg_DamageEventTarget
set udg_LastDmgWasSpell[i] = udg_IsDamageSpell
set udg_LastDmgPrevType[i] = udg_DamageEventType
else
set s = "WARNING: Recursion error when dealing damage! Make sure when you deal damage from within a DamageEvent trigger, do it like this:\n\n"
set s = s + "Trigger - Turn off (This Trigger)\n"
set s = s + "Unit - Cause...\n"
set s = s + "Trigger - Turn on (This Trigger)"
//Delete the next couple of lines to disable the in-game recursion crash warnings
call ClearTextMessages()
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0.00, 0.00, 999.00, s)
return false
endif
set udg_DmgEvRecursionN = i + 2
set prevAmount = GetEventDamage()
set udg_DamageEventTarget = GetTriggerUnit()
set udg_DamageEventSource = GetEventDamageSource()
set udg_DamageEventAmount = prevAmount
set udg_DamageEventType = udg_NextDamageType
set udg_NextDamageType = 0
set udg_DamageEventOverride = udg_NextDamageOverride
set udg_NextDamageOverride = false
if i < 0 then
//Added 25 July 2017 to detect AOE damage or multiple single-target damage
if udg_DamageEventType == 0 then
if f == udg_DamageEventSource then
//Source has damaged more than once
if IsUnitInGroup(udg_DamageEventTarget, udg_DamageEventAOEGroup) then
//Added 5 August 2017 to improve tracking of enhanced damage against, say, Pulverize
set udg_DamageEventLevel = udg_DamageEventLevel + 1
set udg_EnhancedDamageTarget = udg_DamageEventTarget
else
//Multiple targets hit by this source - flag as AOE
set udg_DamageEventAOE = udg_DamageEventAOE + 1
endif
else
//New damage source - unflag everything
set u = udg_DamageEventSource
set udg_DamageEventSource = f
call DmgEvOnAOEEnd()
set udg_DamageEventSource = u
endif
call GroupAddUnit(udg_DamageEventAOEGroup, udg_DamageEventTarget)
endif
if not udg_DmgEvStarted then
set udg_DmgEvStarted = true
call TimerStart(udg_DmgEvTimer, 0.00, false, function DmgEvOnExpire)
endif
endif
if prevAmount == 0.00 then
if not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_DamageEventPrevAmt = 0.00
set udg_DamageEvent = 0.00
set udg_DamageEvent = 2.00
set udg_DamageEvent = 0.00
endif
call DmgEvResetVars()
else
set u = udg_DamageEventTarget
set udg_IsDamageSpell = prevAmount < 0.00
if udg_IsDamageSpell then
set prevAmount = -udg_DamageEventAmount
set life = 1.00
if IsUnitType(u, UNIT_TYPE_ETHEREAL) and not IsUnitType(u, UNIT_TYPE_HERO) then
set life = life*udg_DAMAGE_FACTOR_ETHEREAL //1.67
endif
if GetUnitAbilityLevel(u, 'Aegr') > 0 then
set life = life*udg_DAMAGE_FACTOR_ELUNES //0.80
endif
if udg_DmgEvBracers != 0 and IsUnitType(u, UNIT_TYPE_HERO) then
//Inline of UnitHasItemOfTypeBJ without the potential handle ID leak.
set i = 6
loop
set i = i - 1
if GetItemTypeId(UnitItemInSlot(u, i)) == udg_DmgEvBracers then
set life = life*udg_DAMAGE_FACTOR_BRACERS //0.67
exitwhen true
endif
exitwhen i == 0
endloop
endif
set udg_DamageEventAmount = prevAmount*life
endif
set udg_DamageEventPrevAmt = prevAmount
set udg_DamageModifierEvent = 0.00
if not udg_DamageEventOverride then
set udg_DamageModifierEvent = 1.00
if not udg_DamageEventOverride then
set udg_DamageModifierEvent = 2.00
set udg_DamageModifierEvent = 3.00
endif
endif
set udg_DamageEventOverride = override
if udg_DamageEventAmount > 0.00 then
set udg_DamageModifierEvent = 4.00
endif
set udg_DamageModifierEvent = 0.00
if not udg_HideDamageFrom[GetUnitUserData(udg_DamageEventSource)] then
set udg_DamageEvent = 0.00
set udg_DamageEvent = 1.00
set udg_DamageEvent = 0.00
endif
call CheckDamagedLifeEvent(true) //in case the unit state event failed from a recursive damage event
//All events have run and the damage amount is finalized.
set life = GetWidgetLife(u)
set udg_DmgEvTrig = CreateTrigger()
call TriggerAddCondition(udg_DmgEvTrig, Filter(function PreCheckDamagedLifeEvent))
if not udg_IsDamageSpell then
if udg_DamageEventAmount != prevAmount then
set life = life + prevAmount - udg_DamageEventAmount
if GetUnitState(u, UNIT_STATE_MAX_LIFE) < life then
set udg_LastDamageHP = life - prevAmount
call UnitAddAbility(u, udg_DamageBlockingAbility)
endif
call SetWidgetLife(u, RMaxBJ(life, 0.42))
endif
call TriggerRegisterUnitStateEvent(udg_DmgEvTrig, u, UNIT_STATE_LIFE, LESS_THAN, RMaxBJ(0.41, life - prevAmount/2.00))
else
set udg_LastDamageHP = GetUnitState(u, UNIT_STATE_MAX_LIFE)
set prevLife = life
if life + prevAmount*0.75 > udg_LastDamageHP then
set life = RMaxBJ(udg_LastDamageHP - prevAmount/2.00, 1.00)
call SetWidgetLife(u, life)
set life = (life + udg_LastDamageHP)/2.00
else
set life = life + prevAmount*0.50
endif
set udg_LastDamageHP = prevLife - (prevAmount - (prevAmount - udg_DamageEventAmount))
call TriggerRegisterUnitStateEvent(udg_DmgEvTrig, u, UNIT_STATE_LIFE, GREATER_THAN, life)
endif
endif
set u = null
set f = null
return false
endfunction
function CreateDmgEvTrg takes nothing returns nothing
set udg_DamageEventTrigger = CreateTrigger()
call TriggerAddCondition(udg_DamageEventTrigger, Filter(function OnUnitDamage))
endfunction
function SetupDmgEv takes nothing returns boolean
local integer i = udg_UDex
local unit u
if udg_UnitIndexEvent == 1.00 then
set u = udg_UDexUnits[i]
if GetUnitAbilityLevel(u, 'Aloc') == 0 and TriggerEvaluate(gg_trg_Damage_Engine_Config) then
set udg_UnitDamageRegistered[i] = true
call TriggerRegisterUnitEvent(udg_DamageEventTrigger, u, EVENT_UNIT_DAMAGED)
call UnitAddAbility(u, udg_SpellDamageAbility)
call UnitMakeAbilityPermanent(u, true, udg_SpellDamageAbility)
endif
set u = null
else
set udg_HideDamageFrom[i] = false
if udg_UnitDamageRegistered[i] then
set udg_UnitDamageRegistered[i] = false
set udg_DamageEventsWasted = udg_DamageEventsWasted + 1
if udg_DamageEventsWasted == 32 then //After 32 registered units have been removed...
set udg_DamageEventsWasted = 0
//Rebuild the mass EVENT_UNIT_DAMAGED trigger:
call DestroyTrigger(udg_DamageEventTrigger)
call CreateDmgEvTrg()
set i = udg_UDexNext[0]
loop
exitwhen i == 0
if udg_UnitDamageRegistered[i] then
call TriggerRegisterUnitEvent(udg_DamageEventTrigger, udg_UDexUnits[i], EVENT_UNIT_DAMAGED)
endif
set i = udg_UDexNext[i]
endloop
endif
endif
endif
return false
endfunction
//===========================================================================
function InitTrig_Damage_Engine takes nothing returns nothing
local unit u = CreateUnit(Player(bj_PLAYER_NEUTRAL_EXTRA), 'uloc', 0, 0, 0)
local integer i = bj_MAX_PLAYERS //Fixed in 3.8
//Create this trigger with UnitIndexEvents in order add and remove units
//as they are created or removed.
local trigger t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 2.00)
call TriggerAddCondition(t, Filter(function SetupDmgEv))
set t = null
//Run the configuration trigger to set all configurables:
if gg_trg_Damage_Engine_Config == null then
//It's possible this InitTrig_ function ran first, in which case use ExecuteFunc.
call ExecuteFunc("Trig_Damage_Engine_Config_Actions")
else
call TriggerExecute(gg_trg_Damage_Engine_Config)
endif
//Create trigger for storing all EVENT_UNIT_DAMAGED events.
call CreateDmgEvTrg()
//Create GUI-friendly trigger for cleaning up after UnitDamageTarget.
set udg_ClearDamageEvent = CreateTrigger()
call TriggerAddCondition(udg_ClearDamageEvent, Filter(function PreCheckDamagedLifeEvent))
//Disable SpellDamageAbility for every player.
loop
set i = i - 1
call SetPlayerAbilityAvailable(Player(i), udg_SpellDamageAbility, false)
exitwhen i == 0
endloop
//Preload abilities.
call UnitAddAbility(u, udg_DamageBlockingAbility)
call UnitAddAbility(u, udg_SpellDamageAbility)
call RemoveUnit(u)
set u = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function DamageModifiers_Conditions takes nothing returns boolean
return (IsUnitDeadBJ(udg_DamageEventSource) == false) and (IsUnitDeadBJ(udg_DamageEventTarget) == false)
endfunction
function DamageModifiers_Actions takes nothing returns nothing
local unit attacker = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local real damage_amount = udg_DamageEventAmount
if (GetUnitAbilityLevel(target, 'A005') >= 1) and (udg_IsDamageSpell == false) then
set damage_amount = (damage_amount * (1 + ((GetUnitAbilityLevel(target, 'A008') - 1) * 5) / 100))
endif
if (GetUnitAbilityLevel(attacker, 'A009') >= 1) and (IsUnitType(target, UNIT_TYPE_FLYING) == true) and (GetPlayerTechCountSimple('R003', GetOwningPlayer(attacker)) >= 1) then
set damage_amount = (damage_amount * 1.35)
endif
if ((UnitHasBuffBJ(target, 'B007') == true) or (UnitHasBuffBJ(target, 'B00D') == true)) and (udg_IsDamageSpell == true) then
set damage_amount = (damage_amount * 1.5)
endif
if (UnitHasBuffBJ(attacker, 'B005') == true) or (UnitHasBuffBJ(attacker, 'B00B') == true) then
set damage_amount = (udg_DamageEventAmount * 1.30)
endif
if (UnitHasBuffBJ(target, 'B005') == true) or (UnitHasBuffBJ(attacker, 'B00B') == true) then
set damage_amount = (udg_DamageEventAmount * 1.30)
endif
if (UnitHasBuffBJ(target, 'B004') == true) or (UnitHasBuffBJ(target, 'B00A') == true) then
set damage_amount = (damage_amount * 0.25)
endif
set udg_DamageEventAmount = damage_amount
set attacker = null
set target = null
set damage_amount = 0
endfunction
function InitTrig_Damage_Modifiers takes nothing returns nothing
local trigger trg_DM = CreateTrigger()
call TriggerRegisterVariableEvent(trg_DM, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_DM, Condition(function DamageModifiers_Conditions))
call TriggerAddAction(trg_DM, function DamageModifiers_Actions)
set trg_DM = null
endfunction
//TESH.scrollpos=17
//TESH.alwaysfold=0
function Battlefury_Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(udg_DamageEventSource, 'A000') >= 1) and (IsUnitEnemy(udg_DamageEventTarget, GetOwningPlayer(udg_DamageEventSource)))
endfunction
function Battlefury_Actions takes nothing returns nothing
local unit attacker = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local unit dummy
local unit picked
local location attacker_position = GetUnitLoc(attacker)
local group nearby_allies = CreateGroup()
local integer count = 5
local real percentage
call GroupEnumUnitsInRangeOfLoc(nearby_allies, attacker_position, 300.0, null)
loop
set picked = FirstOfGroup(nearby_allies)
exitwhen (picked == null) or (count == 0)
if (GetOwningPlayer(picked) == GetOwningPlayer(attacker)) and (GetUnitAbilityLevel(picked, 'A000') >= 1) and (picked != attacker) then
set count = count - 1
endif
call GroupRemoveUnit(nearby_allies, picked)
endloop
set percentage = 10 + ((5 - count) * 3)
if (GetRandomInt(1, 100) <= percentage) then
set dummy = CreateUnit(GetOwningPlayer(attacker), 'h000', GetLocationX(attacker_position), GetLocationY(attacker_position), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A004')
call SetUnitAbilityLevel(dummy, 'A004', (GetPlayerTechCountSimple('R005', GetOwningPlayer(attacker))) + 1)
call IssueTargetOrder(dummy, "unholyfrenzy", attacker)
set dummy = null
endif
call RemoveLocation(attacker_position)
call DestroyGroup(nearby_allies)
set attacker = null
set target = null
set dummy = null
set picked = null
set attacker_position = null
set nearby_allies = null
set count = 0
set percentage = 0
endfunction
function InitTrig_Battlefury takes nothing returns nothing
local trigger trg_Battlefury = CreateTrigger()
call TriggerRegisterVariableEvent(trg_Battlefury, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_Battlefury, Condition(function Battlefury_Conditions))
call TriggerAddAction(trg_Battlefury, function Battlefury_Actions)
set trg_Battlefury = null
endfunction
//TESH.scrollpos=1
//TESH.alwaysfold=0
function BattlefuryOD_Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(GetDyingUnit(), 'A000') >= 1)
endfunction
function BattlefuryOD_Actions takes nothing returns nothing
local unit dying = GetDyingUnit()
local unit dummy
local location dying_position = GetUnitLoc(dying)
set dummy = CreateUnit(GetOwningPlayer(dying), 'h000', GetLocationX(dying_position), GetLocationY(dying_position), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A003')
call SetUnitAbilityLevel(dummy, 'A003', (GetPlayerTechCountSimple('R005', GetOwningPlayer(dying))) + 1)
call IssueImmediateOrder(dummy, "roar")
set dummy = null
call DestroyEffect(AddSpecialEffectLoc("war3mapImported\\BattleCryCaster.mdx", dying_position))
call RemoveLocation(dying_position)
set dying = null
set dummy = null
set dying_position = null
endfunction
function InitTrig_Battlefury_on_Death takes nothing returns nothing
local trigger trg_BattlefuryOD = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_BattlefuryOD, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(trg_BattlefuryOD, Condition(function BattlefuryOD_Conditions))
call TriggerAddAction(trg_BattlefuryOD, function BattlefuryOD_Actions)
set trg_BattlefuryOD = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function WarTrance_Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(udg_DamageEventTarget, 'A005') >= 1) and (GetPlayerTechCountSimple('R002', GetOwningPlayer(udg_DamageEventTarget)) >= 1) and (GetUnitAbilityLevel(udg_DamageEventTarget, 'A008') < 7)
endfunction
function WarTrance_Actions takes nothing returns nothing
local unit trance_unit = udg_DamageEventTarget
local effect healing_effect = AddSpecialEffectTargetUnitBJ("overhead", trance_unit, "war3mapImported\\FirstAid.mdx")
local integer trance_level
local real duration = 13
local real remaining_time
local timer loop_timer
set trance_level = GetUnitAbilityLevel(trance_unit, 'A008')
call SetUnitAbilityLevel(trance_unit, 'A008', (trance_level + 1))
set loop_timer = CreateTimer()
call TimerStart(loop_timer, duration, false, null)
loop
set remaining_time = TimerGetRemaining(loop_timer)
exitwhen (IsUnitDeadBJ(trance_unit) == true) or (remaining_time <= 0)
if (remaining_time > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * remaining_time)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(loop_timer)
if (IsUnitAliveBJ(trance_unit) == true) and (remaining_time <= 0) then
set trance_level = (GetUnitAbilityLevel(trance_unit, 'A008') - 1)
call SetUnitAbilityLevel(trance_unit, 'A008', trance_level)
endif
call DestroyEffect(healing_effect)
set trance_unit = null
set healing_effect = null
set trance_level = 0
set duration = 0
set remaining_time = 0
set loop_timer = null
endfunction
function InitTrig_War_Trance takes nothing returns nothing
local trigger trg_WarTrance = CreateTrigger()
call TriggerRegisterVariableEvent(trg_WarTrance, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_WarTrance, Condition(function WarTrance_Conditions))
call TriggerAddAction(trg_WarTrance, function WarTrance_Actions)
set trg_WarTrance = null
endfunction
//TESH.scrollpos=2
//TESH.alwaysfold=0
function JavCamo_Conditions takes nothing returns boolean
return (GetResearched() == 'R003')
endfunction
function JavCamo_Actions takes nothing returns nothing
local player owner = GetOwningPlayer(GetResearchingUnit())
local unit picked
local group javelineers = CreateGroup()
call GroupEnumUnitsInRect(javelineers, GetEntireMapRect(), null)
loop
set picked = FirstOfGroup(javelineers)
exitwhen (picked == null)
if (GetOwningPlayer(picked) == owner) and ((GetUnitTypeId(picked) == 'w007') or (GetUnitTypeId(picked) == 'w008')) then
call UnitAddAbility(picked, 'A007')
endif
call GroupRemoveUnit(javelineers, picked)
endloop
call DestroyGroup(javelineers)
set owner = null
set picked = null
set javelineers = null
endfunction
function InitTrig_Jav_Camouflage takes nothing returns nothing
local trigger trg_Camo = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Camo, EVENT_PLAYER_UNIT_RESEARCH_FINISH)
call TriggerAddCondition(trg_Camo, Condition(function JavCamo_Conditions))
call TriggerAddAction(trg_Camo, function JavCamo_Actions)
set trg_Camo = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function JavCamoOT_Conditions takes nothing returns boolean
return ((GetUnitTypeId(GetTrainedUnit()) == 'w007') or (GetUnitTypeId(GetTrainedUnit()) == 'w008')) and (GetPlayerTechCountSimple('R003', GetOwningPlayer(GetTrainedUnit())) >= 1)
endfunction
function JavCamoOT_Actions takes nothing returns nothing
local unit trained = GetTrainedUnit()
call UnitAddAbility(trained, 'A007')
set trained = null
endfunction
function InitTrig_Jav_Camo_on_Training takes nothing returns nothing
local trigger trg_CamoOT = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_CamoOT, EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddCondition(trg_CamoOT, Condition(function JavCamoOT_Conditions))
call TriggerAddAction(trg_CamoOT, function JavCamoOT_Actions)
set trg_CamoOT = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Wolves_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00A')
endfunction
function Wolves_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit dummy
local unit picked
local location caster_position = GetUnitLoc(caster)
local group enemies = CreateGroup()
local integer count = 1
local real damage_amount
call GroupEnumUnitsInRangeOfLoc(enemies, caster_position, 220.0, null)
loop
set picked = FirstOfGroup(enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(picked, GetOwningPlayer(caster)) == true) and (IsUnitDeadBJ(picked) == false) and (IsUnitType(picked, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(picked, UNIT_TYPE_FLYING) == false) then
set damage_amount = (28 + GetRandomReal(0,5))
call UnitDamageTarget(caster, picked, damage_amount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", picked, "Abilities\\Spells\\Other\\Stampede\\MissileDeath.mdl"))
set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetLocationX(caster_position), GetLocationY(caster_position), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A00B')
call IssueTargetOrder(dummy, "cripple", picked)
set dummy = null
set count = count - 1
endif
call GroupRemoveUnit(enemies, picked)
endloop
call RemoveLocation(caster_position)
call DestroyGroup(enemies)
set caster = null
set dummy = null
set picked = null
set caster_position = null
set enemies = null
set count = 0
set damage_amount = 0
endfunction
function InitTrig_Enraged_Wolves takes nothing returns nothing
local trigger trg_Wolves = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Wolves, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Wolves, Condition(function Wolves_Conditions))
call TriggerAddAction(trg_Wolves, function Wolves_Actions)
set trg_Wolves = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Seal_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00C') or (GetSpellAbilityId() == 'A00P')
endfunction
function Seal_Actions takes nothing returns nothing
if ((UnitHasBuffBJ(GetSpellTargetUnit(), 'B003') == true) or (UnitHasBuffBJ(GetSpellTargetUnit(), 'B009') == true)) then
set udg_NSeal[3] = 1
loop
exitwhen udg_NSeal[3] > udg_NSeal[2]
if (GetSpellTargetUnit() == udg_NSeal_Target[udg_NSeal[3]]) then
set udg_NSeal_Time[udg_NSeal[3]] = 0
endif
set udg_NSeal[3] = udg_NSeal[3] + 1
endloop
endif
if (udg_NSeal[1] == 0) then
call EnableTrigger(gg_trg_Nature_Seal_Loop)
endif
set udg_NSeal[1] = (udg_NSeal[1] + 1)
set udg_NSeal[2] = (udg_NSeal[2] + 1)
set udg_NSeal_Off[udg_NSeal[2]] = false
set udg_NSeal_Target[udg_NSeal[2]] = GetSpellTargetUnit()
set udg_NSeal_Time[udg_NSeal[2]] = 30
if (GetSpellAbilityId() == 'A00P') then
set udg_NSeal_BloodM[udg_NSeal[2]] = true
else
set udg_NSeal_BloodM[udg_NSeal[2]] = false
endif
endfunction
function InitTrig_Nature_Seal takes nothing returns nothing
local trigger trg_Seal = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Seal, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Seal, Condition(function Seal_Conditions))
call TriggerAddAction(trg_Seal, function Seal_Actions)
set trg_Seal = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function SealLoop_Actions takes nothing returns nothing
local unit target
local unit picked
local location target_position
local group picked_group
local integer count
set udg_NSeal[3] = 1
loop
exitwhen udg_NSeal[3] > udg_NSeal[2]
if (udg_NSeal_Off[udg_NSeal[3]] == false) then
set udg_NSeal_Time[udg_NSeal[3]] = (udg_NSeal_Time[udg_NSeal[3]] - 1)
if (udg_NSeal_Time[udg_NSeal[3]] <= 0) or ((UnitHasBuffBJ(udg_NSeal_Target[udg_NSeal[3]], 'B003') == false) and (UnitHasBuffBJ(udg_NSeal_Target[udg_NSeal[3]], 'B009') == false)) then
set udg_NSeal[1] = (udg_NSeal[1] - 1)
set udg_NSeal_Off[udg_NSeal[3]] = true
set udg_NSeal_BloodM[udg_NSeal[3]] = false
set udg_NSeal_Target[udg_NSeal[3]] = null
if (udg_NSeal[1] == 0) then
set udg_NSeal[2] = 0
call DisableTrigger(GetTriggeringTrigger())
endif
else
set target = udg_NSeal_Target[udg_NSeal[3]]
set target_position = GetUnitLoc(target)
set picked_group = CreateGroup()
if (udg_NSeal_BloodM[udg_NSeal[3]] == true) then
set count = 6
call GroupEnumUnitsInRangeOfLoc(picked_group, target_position, 400.0, null)
loop
set picked = FirstOfGroup(picked_group)
exitwhen (picked == null) or (count == 0)
if (GetOwningPlayer(picked) == GetOwningPlayer(target)) and (UnitHasBuffBJ(picked, 'B009') == true) and (picked != target) then
set count = count - 1
endif
call GroupRemoveUnit(picked_group, picked)
endloop
call SetUnitLifeBJ(target, (GetUnitStateSwap(UNIT_STATE_LIFE, target) + (8 + (1 * (6 - count)))))
else
set count = 5
call GroupEnumUnitsInRangeOfLoc(picked_group, target_position, 400.0, null)
loop
set picked = FirstOfGroup(picked_group)
exitwhen (picked == null) or (count == 0)
if (GetOwningPlayer(picked) == GetOwningPlayer(target)) and (UnitHasBuffBJ(picked, 'B003') == true) and (picked != target) then
set count = count - 1
endif
call GroupRemoveUnit(picked_group, picked)
endloop
call SetUnitLifeBJ(target, (GetUnitStateSwap(UNIT_STATE_LIFE, target) + (7 + (1 * (5 - count)))))
endif
call RemoveLocation(target_position)
call DestroyGroup(picked_group)
set target = null
set picked = null
set target_position = null
set picked_group = null
set count = 0
endif
endif
set target = null
set picked = null
set target_position = null
set picked_group = null
set count = 0
set udg_NSeal[3] = udg_NSeal[3] + 1
endloop
endfunction
function InitTrig_Nature_Seal_Loop takes nothing returns nothing
set gg_trg_Nature_Seal_Loop = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(gg_trg_Nature_Seal_Loop, 1)
call TriggerAddAction(gg_trg_Nature_Seal_Loop, function SealLoop_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function RockShield_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00D') or (GetSpellAbilityId() == 'A00Q')
endfunction
function RockShield_Actions takes nothing returns nothing
if (udg_RockS[1] == 0) then
call EnableTrigger(gg_trg_Rock_Shield_Loop)
endif
set udg_RockS[1] = (udg_RockS[1] + 1)
set udg_RockS[2] = (udg_RockS[2] + 1)
set udg_RockS_Off[udg_RockS[2]] = false
set udg_RockS_Target[udg_RockS[2]] = GetSpellTargetUnit()
set udg_RockS_Time[udg_RockS[2]] = 40
if (GetSpellAbilityId() == 'A00Q') then
set udg_RockS_RemAttacks[udg_RockS[2]] = 7
else
set udg_RockS_RemAttacks[udg_RockS[2]] = 5
endif
endfunction
function InitTrig_Rock_Shield takes nothing returns nothing
local trigger trg_Rock = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Rock, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Rock, Condition(function RockShield_Conditions))
call TriggerAddAction(trg_Rock, function RockShield_Actions)
set trg_Rock = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function RockShieldLoop_Actions takes nothing returns nothing
set udg_RockS[3] = 1
loop
exitwhen udg_RockS[3] > udg_RockS[2]
if (udg_RockS_Off[udg_RockS[3]] == false) then
set udg_RockS_Time[udg_RockS[3]] = (udg_RockS_Time[udg_RockS[3]] - 0.2)
if (udg_RockS_Time[udg_RockS[3]] <= 0) or (udg_RockS_RemAttacks[udg_RockS[3]] <= 0) or ((UnitHasBuffBJ(udg_RockS_Target[udg_RockS[3]], 'B004') == false) and (UnitHasBuffBJ(udg_RockS_Target[udg_RockS[3]], 'B00A') == false)) then
set udg_RockS[1] = (udg_RockS[1] - 1)
set udg_RockS_Off[udg_RockS[3]] = true
set udg_RockS_Target[udg_RockS[3]] = null
set udg_RockS_RemAttacks[udg_RockS[3]] = 0
if (udg_RockS[1] == 0) then
set udg_RockS[2] = 0
call DisableTrigger(GetTriggeringTrigger())
endif
endif
endif
set udg_RockS[3] = udg_RockS[3] + 1
endloop
endfunction
function InitTrig_Rock_Shield_Loop takes nothing returns nothing
set gg_trg_Rock_Shield_Loop = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(gg_trg_Rock_Shield_Loop, 0.2)
call TriggerAddAction(gg_trg_Rock_Shield_Loop, function RockShieldLoop_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function RockShieldDmg_Conditions takes nothing returns boolean
return (UnitHasBuffBJ(udg_DamageEventTarget, 'B004') == true) or (UnitHasBuffBJ(udg_DamageEventTarget, 'B00A') == true)
endfunction
function RockShieldDmg_Actions takes nothing returns nothing
local unit target = udg_DamageEventTarget
local boolean is_unit = false
set udg_RockS[3] = 1
loop
exitwhen (udg_RockS[3] > udg_RockS[2]) or (is_unit == true)
if (udg_RockS_Off[udg_RockS[3]] == false) and (udg_RockS_RemAttacks[udg_RockS[3]] > 0) and (udg_RockS_Target[udg_RockS[3]] == target) then
set udg_RockS_RemAttacks[udg_RockS[3]] = (udg_RockS_RemAttacks[udg_RockS[3]] - 1)
set is_unit = true
if (udg_RockS_RemAttacks[udg_RockS[3]] <= 0) then
call UnitRemoveBuffBJ('B004', target)
call UnitRemoveBuffBJ('B00A', target)
endif
endif
set udg_RockS[3] = udg_RockS[3] + 1
endloop
set target = null
set is_unit = false
endfunction
function InitTrig_Rock_Shield_on_Damage takes nothing returns nothing
local trigger trg_RockDmg = CreateTrigger()
call TriggerRegisterVariableEvent(trg_RockDmg, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_RockDmg, Condition(function RockShieldDmg_Conditions))
call TriggerAddAction(trg_RockDmg, function RockShieldDmg_Actions)
set trg_RockDmg = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Bloodrage_Conditions takes nothing returns boolean
return (UnitHasBuffBJ(GetKillingUnit(), 'B00B') == true)
endfunction
function Bloodrage_Actions takes nothing returns nothing
local unit killer = GetKillingUnit()
if (UnitHasBuffBJ(killer, 'B00B') == true) then
call SetUnitLifeBJ(killer, (GetUnitStateSwap(UNIT_STATE_LIFE, killer) + (GetUnitStateSwap(UNIT_STATE_MAX_LIFE, killer) * 0.15)))
endif
set killer = null
endfunction
function InitTrig_Bloodrage takes nothing returns nothing
local trigger trg_Bloodrage = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Bloodrage, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(trg_Bloodrage, Condition(function Bloodrage_Conditions))
call TriggerAddAction(trg_Bloodrage, function Bloodrage_Actions)
set trg_Bloodrage = null
endfunction
//TESH.scrollpos=16
//TESH.alwaysfold=0
function Spellhunt_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00T')
endfunction
function Spellhunt_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local unit picked
local location target_position = GetUnitLoc(target)
local group enemies = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(enemies, target_position, 300.0, null)
loop
set picked = FirstOfGroup(enemies)
exitwhen (picked == null)
if (IsUnitEnemy(picked, GetOwningPlayer(caster)) == true) and (GetUnitStateSwap(UNIT_STATE_MAX_MANA, picked) > 0) then
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", picked, "Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl"))
call SetUnitManaBJ(picked, (GetUnitStateSwap(UNIT_STATE_MANA, picked) - 40))
endif
call GroupRemoveUnit(enemies, picked)
endloop
call RemoveLocation(target_position)
call DestroyGroup(enemies)
set caster = null
set target = null
set picked = null
set target_position = null
set enemies = null
endfunction
function InitTrig_Spellhunt takes nothing returns nothing
local trigger trg_Spellhunt = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Spellhunt, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Spellhunt, Condition(function Spellhunt_Conditions))
call TriggerAddAction(trg_Spellhunt, function Spellhunt_Actions)
set trg_Spellhunt = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function SpiritMark_Conditions takes nothing returns boolean
return (UnitHasBuffBJ(udg_DamageEventTarget, 'B008') == true) or (UnitHasBuffBJ(udg_DamageEventTarget, 'B00E') == true)
endfunction
function SpiritMark_Actions takes nothing returns nothing
local unit attacker = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local unit picked
local location target_position = GetUnitLoc(target)
local group picked_group = CreateGroup()
local real damage_amount
if (UnitHasBuffBJ(udg_DamageEventTarget, 'B008') == true) then
set damage_amount = (udg_DamageEventAmount * 0.25)
else
set damage_amount = (udg_DamageEventAmount * 0.35)
endif
call GroupEnumUnitsInRangeOfLoc(picked_group, target_position, 350.0, null)
loop
set picked = FirstOfGroup(picked_group)
exitwhen (picked == null)
if (IsUnitEnemy(picked, GetOwningPlayer(attacker)) == true) and (IsUnitDeadBJ(picked) == false) and (picked != target) then
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(attacker, picked, damage_amount, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
call EnableTrigger(GetTriggeringTrigger())
endif
call GroupRemoveUnit(picked_group, picked)
endloop
call RemoveLocation(target_position)
call DestroyGroup(picked_group)
set attacker = null
set target = null
set picked = null
set target_position = null
set picked_group = null
set damage_amount = 0
endfunction
function InitTrig_Spirit_Mark takes nothing returns nothing
local trigger trg_Spirit = CreateTrigger()
call TriggerRegisterVariableEvent(trg_Spirit, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_Spirit, Condition(function SpiritMark_Conditions))
call TriggerAddAction(trg_Spirit, function SpiritMark_Actions)
set trg_Spirit = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Juggernaut_Conditions takes nothing returns boolean
return ((GetUnitAbilityLevel(udg_DamageEventSource, 'A00W') >= 1) or (GetUnitAbilityLevel(udg_DamageEventTarget, 'A00W') >= 1)) and (GetRandomInt(1, 100) <= 18)
endfunction
function Juggernaut_Actions takes nothing returns nothing
local unit jugg_unit
local effect jugg_effect
local integer ability_level
local real duration
local real remaining_time
local timer loop_timer
if (GetUnitAbilityLevel(udg_DamageEventSource, 'A00W') >= 1) then
set jugg_unit = udg_DamageEventSource
else
set jugg_unit = udg_DamageEventTarget
endif
set ability_level = GetUnitAbilityLevel(jugg_unit, 'A01F')
if (GetUnitAbilityLevel(jugg_unit, 'A00W') >= 1) and (ability_level <= 15) then
call SetUnitAbilityLevel(jugg_unit, 'A01F', (ability_level + 1))
call SetUnitAbilityLevel(jugg_unit, 'A01G', (ability_level + 1))
call Juggernaut_ChargeSwap(jugg_unit)
call UnitAddAbility(jugg_unit, udg_JuggCharge[ability_level])
set jugg_effect = AddSpecialEffectTargetUnitBJ("overhead", jugg_unit, "war3mapImported\\Juggernaut.mdx")
endif
set duration = (20 + (GetUnitAbilityLevel(udg_DamageEventSource, 'A01M') * 10))
set loop_timer = CreateTimer()
call TimerStart(loop_timer, duration, false, null)
loop
set remaining_time = TimerGetRemaining(loop_timer)
exitwhen (IsUnitDeadBJ(jugg_unit) == true) or (remaining_time <= 0) or (GetUnitAbilityLevel(jugg_unit, 'A01F') == 1)
if (remaining_time > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * remaining_time)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(loop_timer)
if (IsUnitAliveBJ(jugg_unit) == true) and (remaining_time <= 0) and (GetUnitAbilityLevel(jugg_unit, 'A01F') > 1) then
set ability_level = (GetUnitAbilityLevel(jugg_unit, 'A01F') - 1)
call SetUnitAbilityLevel(jugg_unit, 'A01F', ability_level)
call SetUnitAbilityLevel(jugg_unit, 'A01G', ability_level)
call Juggernaut_ChargeSwap(jugg_unit)
call UnitAddAbility(jugg_unit, udg_JuggCharge[ability_level - 1])
endif
call DestroyEffect(jugg_effect)
set jugg_unit = null
set jugg_effect = null
set ability_level = 0
set duration = 0
set remaining_time = 0
set loop_timer = null
endfunction
function InitTrig_Juggernaut takes nothing returns nothing
local trigger trg_Jugg = CreateTrigger()
call TriggerRegisterVariableEvent(trg_Jugg, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_Jugg, Condition(function Juggernaut_Conditions))
call TriggerAddAction(trg_Jugg, function Juggernaut_Actions)
set trg_Jugg = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function JuggernautOR_Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(GetRevivingUnit(), 'A00W') >= 1)
endfunction
function JuggernautOR_Actions takes nothing returns nothing
local unit reviving_hero = GetRevivingUnit()
call SetUnitAbilityLevel(reviving_hero, 'A01F', 1)
call SetUnitAbilityLevel(reviving_hero, 'A01G', 1)
call Juggernaut_ChargeSwap(reviving_hero)
call UnitAddAbility(reviving_hero, udg_JuggCharge[0])
set reviving_hero = null
endfunction
function InitTrig_Juggernaut_on_Revive takes nothing returns nothing
local trigger trg_JuggOR = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_JuggOR, EVENT_PLAYER_HERO_REVIVE_FINISH)
call TriggerAddCondition(trg_JuggOR, Condition(function JuggernautOR_Conditions))
call TriggerAddAction(trg_JuggOR, function JuggernautOR_Actions)
set trg_JuggOR = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function DeadlySpin_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A00Y')
endfunction
function DeadlySpin_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit picked
local location caster_position = GetUnitLoc(caster)
local group enemies = CreateGroup()
local integer count = 4
local integer ability_level = GetUnitAbilityLevel(caster, 'A00Y')
local real damage_amount
local real duration = 0.25
local real remaining_time
local timer loop_timer
local texttag critical_text
local boolean double_spin = false
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", caster, "war3mapImported\\CullingSlashRed.mdx"))
call GroupEnumUnitsInRangeOfLoc(enemies, caster_position, 300.0, null)
loop
set picked = FirstOfGroup(enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(picked, GetOwningPlayer(caster)) == true) and (IsUnitDeadBJ(picked) == false) and (IsUnitType(picked, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(picked, UNIT_TYPE_FLYING) == false) then
set damage_amount = (10 + (I2R(ability_level) * 30) + (GetUnitAbilityLevel(caster, 'A01F') * 5))
if (GetRandomInt(1, 100) <= (GetUnitAbilityLevel(caster, 'A01G') * 3)) and (GetUnitAbilityLevel(caster, 'A01F') > 1) then
set damage_amount = (damage_amount * (1 + (GetUnitAbilityLevel(caster, 'A01G') * 0.1)))
if (GetUnitAbilityLevel(caster, 'A01F') >= 11) then
set double_spin = true
endif
set critical_text = CreateTextTagUnitBJ(I2S(R2I(damage_amount)), picked, 20, 10, 100, 0, 0, 0)
call SetTextTagPermanentBJ(critical_text, false)
call SetTextTagVelocityBJ(critical_text, 64.0, 90.0)
call SetTextTagLifespanBJ(critical_text, 2.0)
call SetTextTagFadepointBJ(critical_text, 1.0)
set critical_text = null
endif
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", picked, "war3mapImported\\FatalWoundV2.mdx"))
call UnitDamageTarget(caster, picked, damage_amount, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_MAGIC, null)
set damage_amount = 0
set count = count - 1
endif
call GroupRemoveUnit(enemies, picked)
endloop
call DestroyGroup(enemies)
if (double_spin == true) then
set count = 4
set loop_timer = CreateTimer()
call TimerStart(loop_timer, duration, false, null)
loop
set remaining_time = TimerGetRemaining(loop_timer)
exitwhen (IsUnitDeadBJ(caster) == true) or (remaining_time <= 0)
if (remaining_time > bj_POLLED_WAIT_SKIP_THRESHOLD) then
call TriggerSleepAction(0.1 * remaining_time)
else
call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
endif
endloop
call DestroyTimer(loop_timer)
if (IsUnitAliveBJ(caster) == true) and (remaining_time <= 0) then
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", caster, "war3mapImported\\CullingSlashRed.mdx"))
set enemies = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(enemies, caster_position, 300.0, null)
loop
set picked = FirstOfGroup(enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(picked, GetOwningPlayer(caster)) == true) and (IsUnitDeadBJ(picked) == false) and (IsUnitType(picked, UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(picked, UNIT_TYPE_FLYING) == false) then
set damage_amount = (5 + (I2R(ability_level) * 15))
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", picked, "war3mapImported\\FatalWoundV2.mdx"))
call UnitDamageTarget(caster, picked, damage_amount, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
set damage_amount = 0
set count = count - 1
endif
call GroupRemoveUnit(enemies, picked)
endloop
call DestroyGroup(enemies)
endif
endif
if (GetUnitAbilityLevel(caster, 'A01F') > 1) and (GetUnitAbilityLevel(caster, 'A01M') < 1) then
call SetUnitAbilityLevel(caster, 'A01F', 1)
call SetUnitAbilityLevel(caster, 'A01G', 1)
call Juggernaut_ChargeSwap(caster)
call UnitAddAbility(caster, udg_JuggCharge[0])
else
if (GetUnitAbilityLevel(caster, 'A01F') > 1) and (GetUnitAbilityLevel(caster, 'A01M') >= 1) and (GetRandomInt(1, 100) < 85) then
call SetUnitAbilityLevel(caster, 'A01F', 1)
call SetUnitAbilityLevel(caster, 'A01G', 1)
call Juggernaut_ChargeSwap(caster)
call UnitAddAbility(caster, udg_JuggCharge[0])
endif
endif
call RemoveLocation(caster_position)
set caster = null
set picked = null
set caster_position = null
set enemies = null
set count = 0
set ability_level = 0
set damage_amount = 0
set duration = 0
set remaining_time = 0
set loop_timer = null
set critical_text = null
set double_spin = false
endfunction
function InitTrig_Deadly_Spin takes nothing returns nothing
local trigger trg_Spin = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Spin, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Spin, Condition(function DeadlySpin_Conditions))
call TriggerAddAction(trg_Spin, function DeadlySpin_Actions)
set trg_Spin = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function Shout_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A01H')
endfunction
function Shout_Actions takes nothing returns nothing
local unit caster = GetSpellAbilityUnit()
local unit dummy
local unit picked
local location caster_position = GetUnitLoc(caster)
local group enemies = CreateGroup()
local real aoe
if (GetUnitAbilityLevel(caster, 'A01F') >= 11) then
set aoe = 625
else
set aoe = 400
endif
call GroupEnumUnitsInRangeOfLoc(enemies, caster_position, aoe, null)
loop
set picked = FirstOfGroup(enemies)
exitwhen (picked == null)
if (IsUnitEnemy(picked, GetOwningPlayer(caster)) == true) and (IsUnitDeadBJ(picked) == false) and (IsUnitType(picked, UNIT_TYPE_STRUCTURE) == false) then
set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetLocationX(GetUnitLoc(picked)), GetLocationY(GetUnitLoc(picked)), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A01I')
call SetUnitAbilityLevel(dummy, 'A01I', 2)
call IssueTargetOrder(dummy, "thunderbolt", picked)
set dummy = null
if (GetUnitAbilityLevel(caster, 'A01F') >= 2) then
set dummy = CreateUnit(GetOwningPlayer(caster), 'h000', GetLocationX(GetUnitLoc(picked)), GetLocationY(GetUnitLoc(picked)), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A01J')
call SetUnitAbilityLevel(dummy, 'A01J', GetUnitAbilityLevel(caster, 'A01F') - 1)
call IssueTargetOrder(dummy, "drunkenhaze", picked)
set dummy = null
endif
endif
call GroupRemoveUnit(enemies, picked)
endloop
call DestroyGroup(enemies)
if (GetUnitAbilityLevel(caster, 'A01F') > 1) and (GetUnitAbilityLevel(caster, 'A01M') < 1) then
call SetUnitAbilityLevel(caster, 'A01F', 1)
call SetUnitAbilityLevel(caster, 'A01G', 1)
call Juggernaut_ChargeSwap(caster)
call UnitAddAbility(caster, udg_JuggCharge[0])
else
if (GetUnitAbilityLevel(caster, 'A01F') > 1) and (GetUnitAbilityLevel(caster, 'A01M') >= 1) and (GetRandomInt(1, 100) < 85) then
call SetUnitAbilityLevel(caster, 'A01F', 1)
call SetUnitAbilityLevel(caster, 'A01G', 1)
call Juggernaut_ChargeSwap(caster)
call UnitAddAbility(caster, udg_JuggCharge[0])
endif
endif
set caster = null
set dummy = null
set picked = null
set caster_position = null
set enemies = null
set aoe = 0
endfunction
function InitTrig_Intimidating_Shout takes nothing returns nothing
local trigger trg_Shout = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Shout, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(trg_Shout, Condition(function Shout_Conditions))
call TriggerAddAction(trg_Shout, function Shout_Actions)
set trg_Shout = null
endfunction
//TESH.scrollpos=1
//TESH.alwaysfold=0
function ShoutOD_Conditions takes nothing returns boolean
return ((UnitHasBuffBJ(udg_DamageEventTarget, 'B00G') == true) or (UnitHasBuffBJ(udg_DamageEventTarget, 'B00F') == true) or (UnitHasBuffBJ(udg_DamageEventTarget, 'B00H') == true)) and (GetUnitAbilityLevel(udg_DamageEventSource, 'A01H') >= 1)
endfunction
function ShoutOD_Actions takes nothing returns nothing
local unit attacker = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local real damage_amount
set damage_amount = (4 + (GetUnitAbilityLevel(attacker, 'A01H') * 6))
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(attacker, target, damage_amount, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(GetTriggeringTrigger())
set attacker = null
set target = null
set damage_amount = 0
endfunction
function InitTrig_Intimidating_Shout_on_Damage takes nothing returns nothing
local trigger trg_ShoutOD = CreateTrigger()
call TriggerRegisterVariableEvent(trg_ShoutOD, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_ShoutOD, Condition(function ShoutOD_Conditions))
call TriggerAddAction(trg_ShoutOD, function ShoutOD_Actions)
set trg_ShoutOD = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function HowlingAxe_Conditions takes nothing returns boolean
return (GetUnitAbilityLevel(udg_DamageEventSource, 'A01K') >= 1)
endfunction
function HowlingAxe_Actions takes nothing returns nothing
local unit attacker = udg_DamageEventSource
local unit target = udg_DamageEventTarget
local unit dummy
if (GetRandomInt(1, 100) <= (GetUnitAbilityLevel(attacker, 'A01K') * 6)) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) then
set dummy = CreateUnit(GetOwningPlayer(attacker), 'h000', GetLocationX(GetUnitLoc(target)), GetLocationY(GetUnitLoc(target)), 270)
call UnitApplyTimedLife(dummy, 'BTLF', 1.0)
call UnitAddAbility(dummy, 'A01L')
call IssueTargetOrder(dummy, "drunkenhaze", target)
set dummy = null
endif
if (GetUnitAbilityLevel(attacker, 'A01F') >= 2) and (GetRandomReal(1, 100) <= (GetUnitAbilityLevel(attacker, 'A01F') * 0.4)) and (IsUnitType(target, UNIT_TYPE_STRUCTURE) == false) and (IsUnitType(target, UNIT_TYPE_HERO) == false) and (GetUnitLevel(target) <= 7) then
call UnitRemoveBuffs(target, true, true)
call DestroyEffect(AddSpecialEffectTargetUnitBJ("chest", target, "war3mapImported\\CoupdeGrace.mdx"))
call DisableTrigger(GetTriggeringTrigger())
call UnitDamageTarget(attacker, target, 100000000, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, null)
call EnableTrigger(GetTriggeringTrigger())
if (GetUnitAbilityLevel(attacker, 'A01F') < 11) then
call SetUnitAbilityLevel(attacker, 'A01F', 1)
call SetUnitAbilityLevel(attacker, 'A01G', 1)
call Juggernaut_ChargeSwap(attacker)
call UnitAddAbility(attacker, udg_JuggCharge[0])
endif
endif
set attacker = null
set target = null
set dummy = null
endfunction
function InitTrig_Howling_Axe takes nothing returns nothing
local trigger trg_HA = CreateTrigger()
call TriggerRegisterVariableEvent(trg_HA, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_HA, Condition(function HowlingAxe_Conditions))
call TriggerAddAction(trg_HA, function HowlingAxe_Actions)
set trg_HA = null
endfunction
//TESH.scrollpos=4
//TESH.alwaysfold=0
function Chaos_Conditions takes nothing returns boolean
return (GetResearched() == 'R001')
endfunction
function Chaos_Actions takes nothing returns nothing
local player owner = GetOwningPlayer(GetResearchingUnit())
local group group_temp = CreateGroup()
local unit grom
call GroupEnumUnitsInRect(group_temp, GetEntireMapRect(), null)
loop
set grom = FirstOfGroup(group_temp)
exitwhen (grom == null)
if (GetOwningPlayer(grom) == owner) and (GetUnitTypeId(grom) == 'W017') then
call UnitAddAbility(grom, 'A00O')
call UnitRemoveAbility(grom, 'A00O')
call UnitAddAbility(grom, 'A00X')
call SetUnitAbilityLevel(grom, 'A01F', 1)
call SetUnitAbilityLevel(grom, 'A01G', 1)
call Juggernaut_ChargeSwap(grom)
call UnitAddAbility(grom, udg_JuggCharge[0])
endif
call GroupRemoveUnit(group_temp, grom)
endloop
call SetPlayerTechResearchedSwap('R00E', 1, owner)
call SetPlayerTechResearchedSwap('R00F', 1, owner)
call SetPlayerTechResearchedSwap('R00G', 1, owner)
call SetPlayerTechResearchedSwap('R00H', 1, owner)
call SetPlayerTechResearchedSwap('R00I', 1, owner)
call SetPlayerTechResearchedSwap('R00J', 1, owner)
call SetPlayerTechResearchedSwap('R00K', 1, owner)
call SetPlayerTechResearchedSwap('R00L', 1, owner)
if (udg_Chaos[1] == 0) then
call EnableTrigger(gg_trg_Chaos_Javelineers)
endif
set udg_Chaos[1] = (udg_Chaos[1] + 1)
set udg_Chaos[2] = (udg_Chaos[2] + 1)
set udg_Chaos_Off[udg_Chaos[2]] = false
set udg_Chaos_Player[udg_Chaos[2]] = owner
set udg_Chaos_Time[udg_Chaos[2]] = 0.5
call DestroyGroup(group_temp)
set owner = null
set group_temp = null
set grom = null
endfunction
function InitTrig_Chaos_Orcs takes nothing returns nothing
local trigger trg_Chaos = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_Chaos, EVENT_PLAYER_UNIT_RESEARCH_FINISH)
call TriggerAddCondition(trg_Chaos, Condition(function Chaos_Conditions))
call TriggerAddAction(trg_Chaos, function Chaos_Actions)
set trg_Chaos = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ChaosJav_Actions takes nothing returns nothing
local player owner
local unit picked
local group javelineers = CreateGroup()
set udg_Chaos[3] = 1
loop
exitwhen udg_Chaos[3] > udg_Chaos[2]
if (udg_Chaos_Off[udg_Chaos[3]] == false) then
set udg_Chaos_Time[udg_Chaos[3]] = (udg_Chaos_Time[udg_Chaos[3]] - 0.5)
if (udg_Chaos_Time[udg_Chaos[3]] <= 0) then
set owner = udg_Chaos_Player[udg_Chaos[3]]
call GroupEnumUnitsInRect(javelineers, GetEntireMapRect(), null)
loop
set picked = FirstOfGroup(javelineers)
exitwhen (picked == null)
if (GetOwningPlayer(picked) == owner) and (GetUnitTypeId(picked) == 'w008') and (GetPlayerTechCountSimple('R003', GetOwningPlayer(picked)) >= 1) then
call UnitAddAbility(picked, 'A007')
endif
call GroupRemoveUnit(javelineers, picked)
endloop
call DestroyGroup(javelineers)
set udg_Chaos[1] = (udg_Chaos[1] - 1)
set udg_Chaos_Off[udg_Chaos[3]] = true
set udg_Chaos_Player[udg_Chaos[3]] = null
if (udg_Chaos[1] == 0) then
set udg_Chaos[2] = 0
call DisableTrigger(GetTriggeringTrigger())
endif
endif
endif
set udg_Chaos[3] = udg_Chaos[3] + 1
endloop
set owner = null
set picked = null
set javelineers = null
endfunction
function InitTrig_Chaos_Javelineers takes nothing returns nothing
set gg_trg_Chaos_Javelineers = CreateTrigger()
call TriggerRegisterTimerEventPeriodic(gg_trg_Chaos_Javelineers, 0.5)
call TriggerAddAction(gg_trg_Chaos_Javelineers, function ChaosJav_Actions)
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function GromOR_Conditions takes nothing returns boolean
return (GetUnitTypeId(GetRevivingUnit()) == 'W017') and (GetPlayerTechCountSimple('R001', GetOwningPlayer(GetRevivingUnit())) >= 1)
endfunction
function GromOR_Actions takes nothing returns nothing
local unit grom = GetRevivingUnit()
call UnitAddAbility(grom, 'A00O')
call UnitRemoveAbility(grom, 'A00O')
call UnitAddAbility(grom, 'A00X')
call SetUnitAbilityLevel(grom, 'A01F', 1)
call SetUnitAbilityLevel(grom, 'A01G', 1)
call Juggernaut_ChargeSwap(grom)
call UnitAddAbility(grom, udg_JuggCharge[0])
set grom = null
endfunction
function InitTrig_Grom_on_Revive takes nothing returns nothing
local trigger trg_GoR = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_GoR, EVENT_PLAYER_HERO_REVIVE_FINISH)
call TriggerAddCondition(trg_GoR, Condition(function GromOR_Conditions))
call TriggerAddAction(trg_GoR, function GromOR_Actions)
set trg_GoR = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ShadowMastery_Conditions takes nothing returns boolean
return (GetResearched() == 'R00C')
endfunction
function ShadowMastery_Actions takes nothing returns nothing
local player owner = GetOwningPlayer(GetResearchingUnit())
call SetPlayerTechResearchedSwap('R00N', 1, owner)
call SetPlayerTechResearchedSwap('R00O', 1, owner)
set owner = null
endfunction
function InitTrig_Shadow_Mastery takes nothing returns nothing
local trigger trg_SM = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_SM, EVENT_PLAYER_UNIT_RESEARCH_FINISH)
call TriggerAddCondition(trg_SM, Condition(function ShadowMastery_Conditions))
call TriggerAddAction(trg_SM, function ShadowMastery_Actions)
set trg_SM = null
endfunction
//TESH.scrollpos=25
//TESH.alwaysfold=0
function SpinAI_1_Conditions takes nothing returns boolean
return ((GetUnitAbilityLevel(GetAttacker(), 'A00Y') >= 1) and (GetPlayerController(GetOwningPlayer(GetAttacker())) == MAP_CONTROL_COMPUTER)) or ((GetUnitAbilityLevel(GetAttackedUnitBJ(), 'A00Y') >= 1) and (GetPlayerController(GetOwningPlayer(GetAttackedUnitBJ())) == MAP_CONTROL_COMPUTER))
endfunction
function SpinAI_1_Actions takes nothing returns nothing
local unit ai_unit
local unit enemy
local unit picked
local player ai_player
local location ai_unit_position
local group nearby_enemies = CreateGroup()
local integer count = 2
local boolean is_attacker = false
if (GetUnitAbilityLevel(GetAttacker(), 'A00Y') >= 1) then
set ai_unit = GetAttacker()
set enemy = GetAttackedUnitBJ()
set is_attacker = true
else
set ai_unit = GetAttackedUnitBJ()
set enemy = GetAttacker()
endif
set ai_player = GetOwningPlayer(ai_unit)
set ai_unit_position = GetUnitLoc(ai_unit)
call GroupEnumUnitsInRangeOfLoc(nearby_enemies, ai_unit_position, 300.0, null)
loop
set picked = FirstOfGroup(nearby_enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(enemy, ai_player) == true) then
set count = count - 1
endif
call GroupRemoveUnit(nearby_enemies, picked)
endloop
if (GetUnitStateSwap(UNIT_STATE_MANA, ai_unit) > 100) and ((GetUnitLifePercent(ai_unit) > 10) and (is_attacker == true)) and (IsUnitEnemy(enemy, ai_player) == true) and ((count <= 0) or ((GetUnitLifePercent(enemy) >= 30.00) and (GetUnitStateSwap(UNIT_STATE_LIFE, enemy) >= 300)) or (IsUnitType(enemy, UNIT_TYPE_HERO) == true)) and (IsUnitDeadBJ(enemy) == false) and ((GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) or (GetRandomReal(1, 100) <= ((100 - GetUnitLifePercent(enemy)) / (10 / GetUnitAbilityLevel(ai_unit, 'A01F'))))) then
call IssueImmediateOrder(ai_unit, "whirlwind")
endif
call RemoveLocation(ai_unit_position)
call DestroyGroup(nearby_enemies)
set ai_unit = null
set enemy = null
set picked = null
set ai_player = null
set ai_unit_position = null
set nearby_enemies = null
set count = 0
set is_attacker = false
endfunction
function InitTrig_AI_Spin_1 takes nothing returns nothing
local trigger trg_SpinAI_1 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_SpinAI_1, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(trg_SpinAI_1, Condition(function SpinAI_1_Conditions))
call TriggerAddAction(trg_SpinAI_1, function SpinAI_1_Actions)
set trg_SpinAI_1 = null
endfunction
//TESH.scrollpos=30
//TESH.alwaysfold=0
function SpinAI_2_Conditions takes nothing returns boolean
return ((GetUnitAbilityLevel(udg_DamageEventSource, 'A00Y') >= 1) and (GetPlayerController(GetOwningPlayer(udg_DamageEventSource)) == MAP_CONTROL_COMPUTER)) or ((GetUnitAbilityLevel(udg_DamageEventTarget, 'A00Y') >= 1) and (GetPlayerController(GetOwningPlayer(udg_DamageEventTarget)) == MAP_CONTROL_COMPUTER))
endfunction
function SpinAI_2_Actions takes nothing returns nothing
local unit ai_unit
local unit enemy
local unit picked
local player ai_player
local location ai_unit_position
local group nearby_enemies = CreateGroup()
local integer count = 2
local boolean is_attacker = false
if (GetUnitAbilityLevel(udg_DamageEventSource, 'A00Y') >= 1) then
set ai_unit = udg_DamageEventSource
set enemy = udg_DamageEventTarget
set is_attacker = true
else
set ai_unit = udg_DamageEventTarget
set enemy = udg_DamageEventSource
endif
set ai_player = GetOwningPlayer(ai_unit)
set ai_unit_position = GetUnitLoc(ai_unit)
call GroupEnumUnitsInRangeOfLoc(nearby_enemies, ai_unit_position, 300.0, null)
loop
set picked = FirstOfGroup(nearby_enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(enemy, ai_player) == true) then
set count = count - 1
endif
call GroupRemoveUnit(nearby_enemies, picked)
endloop
if (GetUnitStateSwap(UNIT_STATE_MANA, ai_unit) > 100) and ((GetUnitLifePercent(ai_unit) > 10) and (is_attacker == true)) and (IsUnitEnemy(enemy, ai_player) == true) and ((count <= 0) or ((GetUnitLifePercent(enemy) >= 30.00) and (GetUnitStateSwap(UNIT_STATE_LIFE, enemy) >= 300)) or (IsUnitType(enemy, UNIT_TYPE_HERO) == true)) and (IsUnitDeadBJ(enemy) == false) and ((GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) or (GetRandomReal(1, 100) <= ((100 - GetUnitLifePercent(enemy)) / (10 / GetUnitAbilityLevel(ai_unit, 'A01F'))))) then
call IssueImmediateOrder(ai_unit, "whirlwind")
endif
call RemoveLocation(ai_unit_position)
call DestroyGroup(nearby_enemies)
set ai_unit = null
set enemy = null
set picked = null
set ai_player = null
set ai_unit_position = null
set nearby_enemies = null
set count = 0
set is_attacker = false
endfunction
function InitTrig_AI_Spin_2 takes nothing returns nothing
local trigger trg_SpinAI_2 = CreateTrigger()
call TriggerRegisterVariableEvent(trg_SpinAI_2, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_SpinAI_2, Condition(function SpinAI_2_Conditions))
call TriggerAddAction(trg_SpinAI_2, function SpinAI_2_Actions)
set trg_SpinAI_2 = null
endfunction
//TESH.scrollpos=29
//TESH.alwaysfold=0
function ShoutAI_1_Conditions takes nothing returns boolean
return ((GetUnitAbilityLevel(GetAttacker(), 'A01H') >= 1) and (GetPlayerController(GetOwningPlayer(GetAttacker())) == MAP_CONTROL_COMPUTER)) or ((GetUnitAbilityLevel(GetAttackedUnitBJ(), 'A01H') >= 1) and (GetPlayerController(GetOwningPlayer(GetAttackedUnitBJ())) == MAP_CONTROL_COMPUTER))
endfunction
function ShoutAI_1_Actions takes nothing returns nothing
local unit ai_unit
local unit enemy
local unit picked
local player ai_player
local location ai_unit_position
local group nearby_enemies = CreateGroup()
local integer count = 2
local real aoe
local boolean is_attacker = false
if (GetUnitAbilityLevel(GetAttacker(), 'A01H') >= 1) then
set ai_unit = GetAttacker()
set enemy = GetAttackedUnitBJ()
set is_attacker = true
else
set ai_unit = GetAttackedUnitBJ()
set enemy = GetAttacker()
endif
set ai_player = GetOwningPlayer(ai_unit)
set ai_unit_position = GetUnitLoc(ai_unit)
if (GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) then
set aoe = 575
else
set aoe = 350
endif
call GroupEnumUnitsInRangeOfLoc(nearby_enemies, ai_unit_position, aoe, null)
loop
set picked = FirstOfGroup(nearby_enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(enemy, ai_player) == true) then
set count = count - 1
endif
call GroupRemoveUnit(nearby_enemies, picked)
endloop
if (GetUnitStateSwap(UNIT_STATE_MANA, ai_unit) > 120) and ((GetUnitLifePercent(ai_unit) > 10) and (is_attacker == true)) and (IsUnitEnemy(enemy, ai_player) == true) and ((count <= 0) or ((GetUnitLifePercent(enemy) >= 30.00) and (GetUnitStateSwap(UNIT_STATE_LIFE, enemy) >= 300)) or (IsUnitType(enemy, UNIT_TYPE_HERO) == true)) and (IsUnitDeadBJ(enemy) == false) and ((GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) or (GetRandomReal(1, 100) <= ((100 - GetUnitLifePercent(enemy)) / (10 / GetUnitAbilityLevel(ai_unit, 'A01F'))))) then
call IssueImmediateOrder(ai_unit, "roar")
endif
call RemoveLocation(ai_unit_position)
call DestroyGroup(nearby_enemies)
set ai_unit = null
set enemy = null
set picked = null
set ai_player = null
set ai_unit_position = null
set nearby_enemies = null
set count = 0
set aoe = 0
set is_attacker = false
endfunction
function InitTrig_AI_Shout_1 takes nothing returns nothing
local trigger trg_ShoutAI_1 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(trg_ShoutAI_1, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(trg_ShoutAI_1, Condition(function ShoutAI_1_Conditions))
call TriggerAddAction(trg_ShoutAI_1, function ShoutAI_1_Actions)
set trg_ShoutAI_1 = null
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function ShoutAI_2_Conditions takes nothing returns boolean
return ((GetUnitAbilityLevel(udg_DamageEventSource, 'A01H') >= 1) and (GetPlayerController(GetOwningPlayer(udg_DamageEventSource)) == MAP_CONTROL_COMPUTER)) or ((GetUnitAbilityLevel(udg_DamageEventTarget, 'A01H') >= 1) and (GetPlayerController(GetOwningPlayer(udg_DamageEventTarget)) == MAP_CONTROL_COMPUTER))
endfunction
function ShoutAI_2_Actions takes nothing returns nothing
local unit ai_unit
local unit enemy
local unit picked
local player ai_player
local location ai_unit_position
local group nearby_enemies = CreateGroup()
local integer count = 2
local real aoe
local boolean is_attacker = false
if (GetUnitAbilityLevel(udg_DamageEventSource, 'A01H') >= 1) then
set ai_unit = udg_DamageEventSource
set enemy = udg_DamageEventTarget
set is_attacker = true
else
set ai_unit = udg_DamageEventTarget
set enemy = udg_DamageEventSource
endif
set ai_player = GetOwningPlayer(ai_unit)
set ai_unit_position = GetUnitLoc(ai_unit)
if (GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) then
set aoe = 575
else
set aoe = 350
endif
call GroupEnumUnitsInRangeOfLoc(nearby_enemies, ai_unit_position, aoe, null)
loop
set picked = FirstOfGroup(nearby_enemies)
exitwhen (picked == null) or (count == 0)
if (IsUnitEnemy(enemy, ai_player) == true) then
set count = count - 1
endif
call GroupRemoveUnit(nearby_enemies, picked)
endloop
if (GetUnitStateSwap(UNIT_STATE_MANA, ai_unit) > 120) and ((GetUnitLifePercent(ai_unit) > 10) and (is_attacker == true)) and (IsUnitEnemy(enemy, ai_player) == true) and ((count <= 0) or ((GetUnitLifePercent(enemy) >= 30.00) and (GetUnitStateSwap(UNIT_STATE_LIFE, enemy) >= 300)) or (IsUnitType(enemy, UNIT_TYPE_HERO) == true)) and (IsUnitDeadBJ(enemy) == false) and ((GetUnitAbilityLevel(ai_unit, 'A01F') >= 11) or (GetRandomReal(1, 100) <= ((100 - GetUnitLifePercent(enemy)) / (10 / GetUnitAbilityLevel(ai_unit, 'A01F'))))) then
call IssueImmediateOrder(ai_unit, "roar")
endif
call RemoveLocation(ai_unit_position)
call DestroyGroup(nearby_enemies)
set ai_unit = null
set enemy = null
set picked = null
set ai_player = null
set ai_unit_position = null
set nearby_enemies = null
set count = 0
set aoe = 0
set is_attacker = false
endfunction
function InitTrig_AI_Shout_2 takes nothing returns nothing
local trigger trg_ShoutAI_2 = CreateTrigger()
call TriggerRegisterVariableEvent(trg_ShoutAI_2, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(trg_ShoutAI_2, Condition(function ShoutAI_2_Conditions))
call TriggerAddAction(trg_ShoutAI_2, function ShoutAI_2_Actions)
set trg_ShoutAI_2 = null
endfunction