//===========================================================================
// Customised Blizzard.j excerpt! ( define Jass2 functions that need to be in every map script )
//===========================================================================
function Custom_MeleeStartingHeroLimit takes nothing returns nothing
local integer index
set index = 0
loop
// max heroes per player
call SetPlayerMaxHeroesAllowed(bj_MELEE_HERO_LIMIT, Player(index))
// each player is restricted to a limit per hero type as well
// Lordaeron Human Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Hamg', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hmkg', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hpal', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hblm', bj_MELEE_HERO_TYPE_LIMIT)
//Blood Elf Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'E00E', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'H049', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'H020', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'N03J', bj_MELEE_HERO_TYPE_LIMIT)
//Stormwind Human Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Hart', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hdgo', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Harf', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hant', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hhkl', bj_MELEE_HERO_TYPE_LIMIT)
//Dwarf Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Hmbr', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hvwd', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hjai', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hlgr', bj_MELEE_HERO_TYPE_LIMIT)
//Kul'tiras Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Hapm', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Odrt', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hpb1', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hgam', bj_MELEE_HERO_TYPE_LIMIT)
//Orc Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Obla', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ofar', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Otch', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Oshd', bj_MELEE_HERO_TYPE_LIMIT)
//Chaos Orc Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Nbbc', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Opgh', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Othr', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Orkn', bj_MELEE_HERO_TYPE_LIMIT)
//Undead Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Edem', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ekee', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Emoo', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ewar', bj_MELEE_HERO_TYPE_LIMIT)
//Demon Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Npld', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nklj', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Usyl', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Uanb', bj_MELEE_HERO_TYPE_LIMIT)
//Black Empire Heroes
//Shadow Elf Heroes
//Night Elf Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Udea', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Udre', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ulic', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ucrl', bj_MELEE_HERO_TYPE_LIMIT)
//Naga Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Hkal', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Eevi', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ocbh', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Hvsh', bj_MELEE_HERO_TYPE_LIMIT)
//Corrupt Night Elf Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'O03D', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nmag', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ekgg', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Efur', bj_MELEE_HERO_TYPE_LIMIT)
//Neutral Heroes
call ReducePlayerTechMaxAllowed(Player(index), 'Npbm', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nbrn', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nngs', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nplh', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nbst', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nalc', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Ntin', bj_MELEE_HERO_TYPE_LIMIT)
call ReducePlayerTechMaxAllowed(Player(index), 'Nfir', bj_MELEE_HERO_TYPE_LIMIT)
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// Starting Units for Human Players
// - 1 Town Hall, placed at start location
// - 5 Peasants, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsHuman takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
local unit townHall = null
if (doPreload) then
call Preloader( "scripts\\HumanMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'htow', startLoc, bj_UNIT_FACING)
// Spawn Peasants near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'hpea', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'htow', startLoc, bj_UNIT_FACING)
// Spawn Peasants directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'hpea', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'hpea', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (townHall != null) then
call UnitAddAbilityBJ('Amic', townHall)
call UnitMakeAbilityPermanentBJ(true, 'Amic', townHall)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Hamg', 'Hmkg', 'Hpal', 'Hblm', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peasants.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Blood Elf Players
// - 1 Vestibule, placed at start location
// - 5 Engineers, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsBloodElf takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
local unit townHall = null
if (doPreload) then
call Preloader( "scripts\\HumanMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h01V', startLoc, bj_UNIT_FACING)
// Spawn Peasants near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'h000', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h01V', startLoc, bj_UNIT_FACING)
// Spawn Peasants directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'h000', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h000', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'E00E', 'H049', 'H020', 'N03J', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peasants.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Stormwind Human Players
// - 1 Municipal Centers, placed at start location
// - 5 Bucolics, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsStormwind takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
local unit townHall = null
if (doPreload) then
call Preloader( "scripts\\HumanMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0CT', startLoc, bj_UNIT_FACING)
// Spawn Peasants near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'h0C2', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0CT', startLoc, bj_UNIT_FACING)
// Spawn Peasants directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'h0C2', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C2', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Hart', 'Hdgo', 'Harf', 'Hant', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peasants.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Dwarf Players
// - 1 Compound, placed at start location
// - 5 Miners, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsDwarf takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
local unit townHall = null
if (doPreload) then
call Preloader( "scripts\\HumanMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0D6', startLoc, bj_UNIT_FACING)
// Spawn Peasants near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'h0C7', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0D6', startLoc, bj_UNIT_FACING)
// Spawn Peasants directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'h0C7', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C7', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Hmbr', 'Hvwd', 'Hjai', 'Hlgr', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peasants.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Kul'tiras Players
// - 1 Port Town, placed at start location
// - 5 Sailors, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsKulTiras takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
local unit townHall = null
if (doPreload) then
call Preloader( "scripts\\HumanMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0D7', startLoc, bj_UNIT_FACING)
// Spawn Peasants near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'h0C8', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Town Hall at the start location.
set townHall = CreateUnitAtLoc(whichPlayer, 'h0D7', startLoc, bj_UNIT_FACING)
// Spawn Peasants directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'h0C8', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'h0C8', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Hapm', 'Odrt', 'Hpb1', 'Hgam', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peasants.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Orc Players
// - 1 Great Hall, placed at start location
// - 5 Peons, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsOrc takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\OrcMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'ogre', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'opeo', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'ogre', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'opeo', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'opeo', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Obla', 'Ofar', 'Otch', 'Oshd', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Chaos Orc Players
// - 1 Chaos Orc Hall, placed at start location
// - 5 Chaos Orc Peons, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsChaosOrc takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\OrcMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o02Y', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'ncpn', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o02Y', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'ncpn', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ncpn', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Nbbc', 'Opgh', 'Othr', 'Orkn', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Undead Players
// - 1 Necropolis, placed at start location
// - 1 Haunted Gold Mine, placed on nearest gold mine
// - 3 Acolytes, placed between start location and nearest gold mine
// - 1 Ghoul, placed between start location and nearest gold mine
// - Blight, centered on nearest gold mine, spread across a "large area"
//
function Custom_MeleeStartingUnitsUndead takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location nearTownLoc
local location heroLoc
local real peonX
local real peonY
local real ghoulX
local real ghoulY
if (doPreload) then
call Preloader( "scripts\\UndeadMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Necropolis at the start location.
call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING)
// Replace the nearest gold mine with a blighted version.
set nearestMine = BlightGoldMineForPlayerBJ(nearestMine, whichPlayer)
// Spawn Ghoul near the Necropolis.
set nearTownLoc = MeleeGetProjectedLoc(startLoc, GetUnitLoc(nearestMine), 288, 0)
set ghoulX = GetLocationX(nearTownLoc)
set ghoulY = GetLocationY(nearTownLoc)
set bj_ghoul[GetPlayerId(whichPlayer)] = CreateUnit(whichPlayer, 'ugho', ghoulX + 0.00 * unitSpacing, ghoulY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Spawn Acolytes near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.00 * unitSpacing, peonY + 0.50 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX - 0.65 * unitSpacing, peonY - 0.50 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the gold mine.
call SetBlightLoc(whichPlayer,nearMineLoc, 768, true)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Necropolis at the start location.
call CreateUnitAtLoc(whichPlayer, 'unpl', startLoc, bj_UNIT_FACING)
// Spawn Acolytes and Ghoul directly south of the Necropolis.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'uaco', peonX - 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX - 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'uaco', peonX + 0.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ugho', peonX + 1.50 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the start location.
call SetBlightLoc(whichPlayer,startLoc, 768, true)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Udea', 'Udre', 'Ulic', 'Ucrl', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Acolytes.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Demon Players
// - 1 Demon Hall, placed at start location
// - 5 Demon Slaves, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsDemon takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location nearTownLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\UndeadMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o00W', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'u00Z', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the gold mine.
call SetBlightLoc(whichPlayer,nearMineLoc, 768, true)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o00W', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'u00Z', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'u00Z', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Create a patch of blight around the start location.
call SetBlightLoc(whichPlayer,startLoc, 768, true)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Npld', 'Nklj', 'Usyl', 'Uanb', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Night Elf Players
// - 1 Tree of Life, placed by nearest gold mine, already entangled
// - 5 Wisps, placed between Tree of Life and nearest gold mine
//
function Custom_MeleeStartingUnitsNightElf takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local real minTreeDist = 3.50 * bj_CELLWIDTH
local real minWispDist = 1.75 * bj_CELLWIDTH
local unit nearestMine
local location nearMineLoc
local location wispLoc
local location heroLoc
local real peonX
local real peonY
local unit tree
if (doPreload) then
call Preloader( "scripts\\NightElfMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Tree of Life near the mine and have it entangle the mine.
// Project the Tree's coordinates from the gold mine, and then snap
// the X and Y values to within minTreeDist of the Gold Mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 650, 0)
set nearMineLoc = MeleeGetLocWithinRect(nearMineLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minTreeDist))
set tree = CreateUnitAtLoc(whichPlayer, 'etol', nearMineLoc, bj_UNIT_FACING)
call IssueTargetOrder(tree, "entangleinstant", nearestMine)
// Spawn Wisps at the start location.
set wispLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set wispLoc = MeleeGetLocWithinRect(wispLoc, GetRectFromCircleBJ(GetUnitLoc(nearestMine), minWispDist))
set peonX = GetLocationX(wispLoc)
set peonY = GetLocationY(wispLoc)
call CreateUnit(whichPlayer, 'ewsp', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX + 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX - 0.58 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Tree of Life at the start location.
call CreateUnitAtLoc(whichPlayer, 'etol', startLoc, bj_UNIT_FACING)
// Spawn Wisps directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'ewsp', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'ewsp', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Edem', 'Ekee', 'Emoo', 'Ewar', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Wisps.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Naga Players
// - 1 Temple of Streams, placed at start location
// - 5 Mur'gul Slaves, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsNaga takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\NightElfMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nntt', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'nmpe', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nntt', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'nmpe', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'nmpe', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'Hkal', 'Eevi', 'Ocbh', 'Hvsh', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Corrupt Night Elf Players
// - 1 Tree of Corruption, placed at start location
// - 3 Satyr Helots, placed between start location and nearest gold mine
// - 2 Vile Souls, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsCorruptNightElf takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\NightElfMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nctl', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'o03N', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e02H', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e02H', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nctl', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'o03N', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e02H', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e02H', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'O03D', 'Nmag', 'Ekgg', 'Efur', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for AI Corrupt Night Elf Players
// - 1 Tree of Corruption, placed at start location
// - 3 Satyr Helots, placed between start location and nearest gold mine
// - 2 Vile Souls (AI), placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsCorruptNightElfAI takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\NightElfMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nctl', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'o03N', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e038', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e038', peonX - 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'nctl', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'o03N', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o03N', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e038', peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'e038', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'O03D', 'Nmag', 'Ekgg', 'Efur', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Conglomeration of cReeps and Enemies Everywhere Practising vengeance, or CREEP Players
// - 1 Creep Camp, placed at start location
// - 3 Drudges, placed between start location and nearest gold mine
//
function Custom_MeleeStartingUnitsCREEP takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local location nearMineLoc
local location heroLoc
local real peonX
local real peonY
if (doPreload) then
call Preloader( "scripts\\NightElfMelee.pld" )
endif
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o03W', startLoc, bj_UNIT_FACING)
// Spawn Peons near the mine.
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
call CreateUnit(whichPlayer, 'o003', peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o003', peonX - 1.00 * unitSpacing, peonY + 0.15 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o003', peonX + 0.60 * unitSpacing, peonY - 1.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be off to the side of the start location.
set heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 384, 45)
else
// Spawn Great Hall at the start location.
call CreateUnitAtLoc(whichPlayer, 'o03W', startLoc, bj_UNIT_FACING)
// Spawn Peons directly south of the town hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, 'o003', peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o003', peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, 'o003', peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
endif
if (doHeroes) then
// If the "Random Hero" option is set, start the player with a random hero.
// Otherwise, give them a "free hero" token.
if useRandomHero then
call MeleeRandomHeroLoc(whichPlayer, 'ncnk', 'ngnv', 'ndtw', 'nhrq', heroLoc)
else
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
endif
if (doCamera) then
// Center the camera on the initial Peons.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
endfunction
//===========================================================================
// Starting Units for Players Whose Race is Unknown
// - 12 Sheep, placed randomly around the start location
//
function Custom_MeleeStartingUnitsUnknownRace takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload returns nothing
local integer index
if (doPreload) then
endif
set index = 0
loop
call CreateUnit(whichPlayer, 'nshe', GetLocationX(startLoc) + GetRandomReal(-256, 256), GetLocationY(startLoc) + GetRandomReal(-256, 256), GetRandomReal(0, 360))
set index = index + 1
exitwhen index == 12
endloop
if (doHeroes) then
// Give them a "free hero" token, out of pity.
call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)
endif
if (doCamera) then
// Center the camera on the initial sheep.
call SetCameraPositionLocForPlayer(whichPlayer, startLoc)
call SetCameraQuickPositionLocForPlayer(whichPlayer, startLoc)
endif
endfunction
//===========================================================================
function Custom_MeleeStartingUnits takes nothing returns nothing
local integer index
local player indexPlayer
local location indexStartLoc
local race indexRace
call Preloader( "scripts\\SharedMelee.pld" )
set index = 0
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set indexStartLoc = GetStartLocationLoc(GetPlayerStartLocation(indexPlayer))
set indexRace = GetPlayerRace(indexPlayer)
// Create initial race-specific starting units
if (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM) and (GetPlayerHandicap (indexPlayer) <= 0.90 )) then
call Custom_MeleeStartingUnitsCREEP(indexPlayer, indexStartLoc, true, true, true)
call SetPlayerFlagBJ( PLAYER_STATE_GIVES_BOUNTY, true, indexPlayer )
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
elseif (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM) and (GetRandomInt(1, 13) == 13 )) then
call Custom_MeleeStartingUnitsCREEP(indexPlayer, indexStartLoc, true, true, true)
call SetPlayerFlagBJ( PLAYER_STATE_GIVES_BOUNTY, true, indexPlayer )
call PickMeleeAI(indexPlayer, "creep.ai", null, null)
elseif (indexRace == RACE_HUMAN) then
if (GetPlayerHandicap (indexPlayer) <= 0.60 ) then
call Custom_MeleeStartingUnitsKulTiras(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
elseif (GetPlayerHandicap (indexPlayer) <= 0.70 ) then
call Custom_MeleeStartingUnitsDwarf(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
elseif (GetPlayerHandicap (indexPlayer) <= 0.80 ) then
call Custom_MeleeStartingUnitsStormwind(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
elseif (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call Custom_MeleeStartingUnitsBloodElf(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
else
if (GetRandomInt(1, 5) != 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
call Custom_MeleeStartingUnitsBloodElf(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "bloodelf.ai", null, null)
endif
else
call Custom_MeleeStartingUnitsStormwind(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "stormwind.ai", null, null)
endif
endif
else
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
call Custom_MeleeStartingUnitsDwarf(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "dwarf.ai", null, null)
endif
else
call Custom_MeleeStartingUnitsKulTiras(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "kultiras.ai", null, null)
endif
endif
endif
else
call Custom_MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true)
endif
endif
elseif (indexRace == RACE_ORC) then
if (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call Custom_MeleeStartingUnitsChaosOrc(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
else
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
call Custom_MeleeStartingUnitsChaosOrc(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "chaosorc.ai", null, null)
endif
else
call Custom_MeleeStartingUnitsOrc(indexPlayer, indexStartLoc, true, true, true)
endif
endif
elseif (indexRace == RACE_UNDEAD) then
if (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call Custom_MeleeStartingUnitsDemon(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
else
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
call Custom_MeleeStartingUnitsDemon(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "demon.ai", null, null)
endif
else
call Custom_MeleeStartingUnitsUndead(indexPlayer, indexStartLoc, true, true, true)
endif
endif
elseif (indexRace == RACE_NIGHTELF) then
if (GetPlayerHandicap (indexPlayer) <= 0.80 ) then
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call Custom_MeleeStartingUnitsCorruptNightElfAI(indexPlayer, indexStartLoc, true, true, true)
call SetPlayerHandicap(indexPlayer, 1.00)
else
call Custom_MeleeStartingUnitsCorruptNightElf(indexPlayer, indexStartLoc, true, true, true)
endif
elseif (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call Custom_MeleeStartingUnitsNaga(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) != MAP_CONTROL_COMPUTER) then
call SetPlayerHandicap(indexPlayer, 1.00)
endif
else
if (GetRandomInt(1, 3) != 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
if (GetRandomInt(1, 2) == 1 ) and (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM)) then
call Custom_MeleeStartingUnitsNaga(indexPlayer, indexStartLoc, true, true, true)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call PickMeleeAI(indexPlayer, "naga.ai", null, null)
endif
else
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
call Custom_MeleeStartingUnitsCorruptNightElfAI(indexPlayer, indexStartLoc, true, true, true)
call PickMeleeAI(indexPlayer, "corruptelf.ai", null, null)
else
call Custom_MeleeStartingUnitsCorruptNightElf(indexPlayer, indexStartLoc, true, true, true)
endif
endif
else
call Custom_MeleeStartingUnitsNightElf(indexPlayer, indexStartLoc, true, true, true)
endif
endif
else
call MeleeStartingUnitsUnknownRace(indexPlayer, indexStartLoc, true, true, true)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
function Custom_MeleeStartingAI takes nothing returns nothing
local integer index
local player indexPlayer
local race indexRace
set index = 0
loop
set indexPlayer = Player(index)
if (GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING) then
set indexRace = GetPlayerRace(indexPlayer)
if (GetPlayerController(indexPlayer) == MAP_CONTROL_COMPUTER) then
// Run a race-specific melee AI script.
if (IsPlayerRacePrefSet(indexPlayer, RACE_PREF_RANDOM) and (GetPlayerHandicap (indexPlayer) <= 0.90 )) then
call PickMeleeAI(indexPlayer, "creep.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
elseif (indexRace == RACE_HUMAN) then
if (GetPlayerHandicap (indexPlayer) <= 0.60 ) then
call PickMeleeAI(indexPlayer, "kultiras.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
elseif (GetPlayerHandicap (indexPlayer) <= 0.70 ) then
call PickMeleeAI(indexPlayer, "dwarf.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
elseif (GetPlayerHandicap (indexPlayer) <= 0.80 ) then
call PickMeleeAI(indexPlayer, "stormwind.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
elseif (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call PickMeleeAI(indexPlayer, "bloodelf.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
else
call PickMeleeAI(indexPlayer, "human.ai", null, null)
endif
elseif (indexRace == RACE_ORC) then
if (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call PickMeleeAI(indexPlayer, "chaosorc.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
else
call PickMeleeAI(indexPlayer, "orc.ai", null, null)
endif
elseif (indexRace == RACE_UNDEAD) then
if (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call PickMeleeAI(indexPlayer, "demon.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
else
call PickMeleeAI(indexPlayer, "undead.ai", null, null)
endif
call RecycleGuardPosition(bj_ghoul[index])
elseif (indexRace == RACE_NIGHTELF) then
if (GetPlayerHandicap (indexPlayer) <= 0.80 ) then
call PickMeleeAI(indexPlayer, "corruptelf.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
elseif (GetPlayerHandicap (indexPlayer) <= 0.90 ) then
call PickMeleeAI(indexPlayer, "naga.ai", null, null)
call SetPlayerHandicap(indexPlayer, 1.00)
else
call PickMeleeAI(indexPlayer, "elf.ai", null, null)
endif
else
// Unrecognized race.
endif
call ShareEverythingWithTeamAI(indexPlayer)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// Counts key structures owned by a player and his or her allies, including
// structures currently upgrading or under construction.
//
// Key structures: Town Hall, Vestibule, Municipal Center, Compound, Port Town, Great Hall, Chaos Orc Hall, Tree of Life, Temple of Streams, Tree of Corruption, Necropolis, Demon Hall
//
function LivingPlayerHallsFilter takes nothing returns boolean
return (IsUnitAliveBJ(GetFilterUnit()) and IsUnitType(GetFilterUnit(),UNIT_TYPE_TOWNHALL))
endfunction
function CountLivingPlayerTownHalls takes player whichPlayer returns integer
local group g
local integer matchedCount
local boolexpr b=Filter(function LivingPlayerHallsFilter)
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, whichPlayer, b)
set matchedCount = CountUnitsInGroup(g)
call DestroyGroup(g)
call DestroyBoolExpr(b)
set b=null
set g=null
return matchedCount
endfunction
function Custom_MeleeGetAllyKeyStructureCount takes player whichPlayer returns integer
local integer playerIndex
local player indexPlayer
local integer keyStructs
// Count the number of buildings controlled by all not-yet-defeated co-allies.
set keyStructs = 0
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
set keyStructs = keyStructs + CountLivingPlayerTownHalls(indexPlayer)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return keyStructs
endfunction
//===========================================================================
function Custom_MeleePlayerIsCrippled takes player whichPlayer returns boolean
local integer allyStructures = MeleeGetAllyStructureCount(whichPlayer)
local integer allyKeyStructures = Custom_MeleeGetAllyKeyStructureCount(whichPlayer)
// Dead teams are not considered to be crippled.
return (allyStructures > 0) and (allyKeyStructures <= 0)
endfunction
//===========================================================================
// Test each player to determine if anyone has become crippled.
//
function Custom_MeleeCheckForCrippledPlayers takes nothing returns nothing
local integer playerIndex
local player indexPlayer
local force crippledPlayers = CreateForce()
local boolean isNowCrippled
local race indexRace
// The "finish soon" exposure of all players overrides any "crippled" exposure
if bj_finishSoonAllExposed then
return
endif
// Check each player to see if he or she has been crippled or uncrippled.
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
set isNowCrippled = Custom_MeleePlayerIsCrippled(indexPlayer)
if (not bj_playerIsCrippled[playerIndex] and isNowCrippled) then
// Player became crippled; start their cripple timer.
set bj_playerIsCrippled[playerIndex] = true
call TimerStart(bj_crippledTimer[playerIndex], bj_MELEE_CRIPPLE_TIMEOUT, false, function MeleeCrippledPlayerTimeout)
if (GetLocalPlayer() == indexPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
// Show the timer window.
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], true)
// Display a warning message.
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, "|cffffcc00"+udg_RevealWarning+"|r")
endif
elseif (bj_playerIsCrippled[playerIndex] and not isNowCrippled) then
// Player became uncrippled; stop their cripple timer.
set bj_playerIsCrippled[playerIndex] = false
call PauseTimer(bj_crippledTimer[playerIndex])
if (GetLocalPlayer() == indexPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
// Hide the timer window for this player.
call TimerDialogDisplay(bj_crippledTimerWindows[playerIndex], false)
// Display a confirmation message if the player's team is still alive.
if (MeleeGetAllyStructureCount(indexPlayer) > 0) then
if (bj_playerIsExposed[playerIndex]) then
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNREVEALED"))
else
call DisplayTimedTextToPlayer(indexPlayer, 0, 0, bj_MELEE_CRIPPLE_MSG_DURATION, GetLocalizedString("CRIPPLE_UNCRIPPLED"))
endif
endif
endif
// If the player granted shared vision, deny that vision now.
call MeleeExposePlayer(indexPlayer, false)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
endfunction
//===========================================================================
// Determine if the lost unit should result in any defeats or victories.
//
function Custom_MeleeCheckLostUnit takes unit lostUnit returns nothing
local player lostUnitOwner = GetOwningPlayer(lostUnit)
// We only need to check for mortality if this was the last building.
if (GetPlayerStructureCount(lostUnitOwner, true) <= 0) then
call MeleeCheckForLosersAndVictors()
endif
// Check if the lost unit has crippled or uncrippled the player.
// (A team with 0 units is dead, and thus considered uncrippled.)
call Custom_MeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
// Determine if the gained unit should result in any defeats, victories,
// or cripple-status changes.
//
function Custom_MeleeCheckAddedUnit takes unit addedUnit returns nothing
local player addedUnitOwner = GetOwningPlayer(addedUnit)
// If the player was crippled, this unit may have uncrippled him/her.
if (bj_playerIsCrippled[GetPlayerId(addedUnitOwner)]) then
call Custom_MeleeCheckForCrippledPlayers()
endif
endfunction
//===========================================================================
function Custom_MeleeTriggerActionConstructCancel takes nothing returns nothing
call Custom_MeleeCheckLostUnit(GetCancelledStructure())
endfunction
//===========================================================================
function Custom_MeleeTriggerActionUnitDeath takes nothing returns nothing
if (IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE)) then
call Custom_MeleeCheckLostUnit(GetDyingUnit())
endif
endfunction
//===========================================================================
function Custom_MeleeTriggerActionUnitConstructionStart takes nothing returns nothing
call Custom_MeleeCheckAddedUnit(GetConstructingStructure())
endfunction
//===========================================================================
function Custom_MeleeTriggerActionAllianceChange takes nothing returns nothing
call MeleeCheckForLosersAndVictors()
call Custom_MeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
function MeleeInitVictoryDefeatCustomized takes nothing returns nothing
local trigger trig
local integer index
local player indexPlayer
// Create a timer window for the "finish soon" timeout period, it has no timer
// because it is driven by real time (outside of the game state to avoid desyncs)
set bj_finishSoonTimerDialog = CreateTimerDialog(null)
// Set a trigger to fire when we receive a "finish soon" game event
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig , EVENT_GAME_TOURNAMENT_FINISH_SOON)
call TriggerAddAction(trig , function MeleeTriggerTournamentFinishSoon)
// Set a trigger to fire when we receive a "finish now" game event
set trig = CreateTrigger()
call TriggerRegisterGameEvent(trig , EVENT_GAME_TOURNAMENT_FINISH_NOW)
call TriggerAddAction(trig , function MeleeTriggerTournamentFinishNow)
// Set up each player's mortality code.
set index = 0
loop
set indexPlayer = Player(index)
// Make sure this player slot is playing.
if ( GetPlayerSlotState(indexPlayer) == PLAYER_SLOT_STATE_PLAYING ) then
set bj_meleeDefeated[index]=false
set bj_meleeVictoried[index]=false
// Create a timer and timer window in case the player is crippled.
set bj_playerIsCrippled[index]=false
set bj_playerIsExposed[index]=false
set bj_crippledTimer[index]=CreateTimer()
set bj_crippledTimerWindows[index]=CreateTimerDialog(bj_crippledTimer[index])
call TimerDialogSetTitle(bj_crippledTimerWindows[index] , MeleeGetCrippledTimerMessage(indexPlayer))
// Set a trigger to fire whenever a building is cancelled for this player.
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_CONSTRUCT_CANCEL , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionConstructCancel)
// Set a trigger to fire whenever a unit dies for this player.
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_DEATH , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionUnitDeath)
// Set a trigger to fire whenever a unit begins construction for this player
set trig = CreateTrigger()
call TriggerRegisterPlayerUnitEvent(trig , indexPlayer , EVENT_PLAYER_UNIT_CONSTRUCT_START , null)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionUnitConstructionStart)
// Set a trigger to fire whenever this player defeats-out
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig , indexPlayer , EVENT_PLAYER_DEFEAT)
call TriggerAddAction(trig , function MeleeTriggerActionPlayerDefeated)
// Set a trigger to fire whenever this player leaves
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig , indexPlayer , EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig , function MeleeTriggerActionPlayerLeft)
// Set a trigger to fire whenever this player changes his/her alliances.
set trig = CreateTrigger()
call TriggerRegisterPlayerAllianceChange(trig , indexPlayer , ALLIANCE_PASSIVE)
call TriggerRegisterPlayerStateEvent(trig , indexPlayer , PLAYER_STATE_ALLIED_VICTORY , EQUAL , 1)
call TriggerAddAction(trig , function Custom_MeleeTriggerActionAllianceChange)
else
set bj_meleeDefeated[index]=true
set bj_meleeVictoried[index]=false
// Handle leave events for observers
if ( IsPlayerObserver(indexPlayer) ) then
// Set a trigger to fire whenever this player leaves
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig , indexPlayer , EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig , function MeleeTriggerActionPlayerLeft)
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
// Test for victory / defeat at startup, in case the user has already won / lost.
// Allow for a short time to pass first, so that the map can finish loading.
call TimerStart(CreateTimer() , 2.0 , false , function Custom_MeleeTriggerActionAllianceChange)
endfunction
Name | Type | is_array | initial_value |
AB_Effects1 | modelfile | Yes | |
AB_Point3 | location | No | |
AB_Temp | integer | No | |
AbsorbTreeGroup | group | No | |
AdraToxoUnitGroup | group | No | |
AffinityVoidGroup | group | No | |
AfterDamageEvent | real | No | |
AMSAmount | real | Yes | |
AOEDamageEvent | real | No | |
ApostateGroup | group | No | |
ArmourSlayerGroup | group | No | |
ASA_Ability | abilcode | No | |
ASA_Group | group | No | |
ASA_LifeUse | real | No | |
AssassinGroup | group | No | |
AstroPlateGroup | group | No | |
AuraMasteryGroup | group | No | |
Avatar2Group | group | No | |
BarbarianGroup | group | No | |
BlackDragonGroup | group | No | |
BlessingOfMightGroup | group | No | |
BloodWardenGroup | group | No | |
BreakerRuneGroup | group | No | |
BrightlanceGroup | group | No | |
BurningBladeGroup | group | No | |
CargoEvent | real | No | |
CargoTransportGroup | group | Yes | |
CargoTransportUnit | unit | Yes | |
CenturionGroup | group | No | |
ChancellorHeroGroup | group | No | |
CheckDeathInList | boolean | Yes | |
CheckDeathList | integer | Yes | |
CheckDeathTimer | timer | No | |
ClearDamageEvent | trigger | No | |
CrashLightningGroup | group | No | |
CreepTempGroup | group | No | |
CreepTempLoc | location | No | |
CS | integervar | No | |
CS_Attacked | unit | Yes | |
CS_Attacking | unit | Yes | |
CS_Chance | integer | No | |
CS_Damage | real | Yes | |
CS_Dummy | unit | Yes | |
CS_Group | group | Yes | |
CS_Jumps | integer | Yes | |
CS_LEVEL | integer | No | |
CS_Off | boolean | Yes | |
CS_Point | location | Yes | |
CS_Skip | integer | No | |
CS_SpecialEffect | effect | Yes | |
CS_Speed | real | Yes | |
CS_Times | integer | No | |
CSmCaster | unit | 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 | |
DamageGroup | group | No | |
DamageModifierEvent | real | No | |
DamageTypeBlocked | integer | No | |
DamageTypeCriticalStrike | integer | No | |
DamageTypeExplosive | integer | No | |
DamageTypeHeal | integer | No | |
DamageTypeReduced | integer | No | |
DarkSpikesTauGroup | group | No | |
DeathEvent | real | No | |
DeathTimer | timer | No | |
DefiledWaterGroup | group | No | |
DetectRemoveAbility | abilcode | No | |
DetectTransformAbility | abilcode | No | |
DevilishPowerGroup | group | No | |
DmgEvBracers | itemcode | No | |
DmgEvMana | real | No | |
DmgEvManaMult | real | No | |
DmgEvMSlvl | integer | No | |
DmgEvRecursionN | integer | No | |
DmgEvRunning | boolean | No | |
DmgEvStarted | boolean | No | |
DmgEvTimer | timer | No | |
DmgEvTrig | trigger | No | |
DragonGroup | group | No | |
DragoonGroup | group | No | |
DummyUnit | unit | No | |
EmberKnightGroup | group | No | |
EnhancedDamageTarget | unit | No | |
ExecutionerGroup | group | No | |
FaithfulGroup | group | No | |
FelcrusherGroup | group | No | |
GDD__Integers | integer | Yes | |
GDD__LeftMapGroup | group | No | |
GDD__TriggerArray | trigger | Yes | |
GDD__UnitArray | unit | Yes | |
GDD_Damage | real | No | |
GDD_DamagedUnit | unit | No | |
GDD_DamageSource | unit | No | |
GDD_Event | real | No | |
GoliathGroup | group | No | |
HideDamageFrom | boolean | Yes | |
IsDamageSpell | boolean | No | |
IsUnitAlive | boolean | Yes | |
IsUnitBeingUnloaded | boolean | Yes | |
IsUnitNew | boolean | Yes | |
IsUnitPreplaced | boolean | Yes | |
IsUnitReincarnating | boolean | Yes | |
IsUnitRemoved | boolean | Yes | |
IsUnitTransforming | boolean | Yes | |
Jab_Caster | unit | No | |
Jab_Mod | integer | No | |
JabDamage | integer | No | |
JustCastSpell | group | No | |
KB_Angle | real | Yes | |
KB_Casters | unit | Yes | |
KB_CountBuffs | integer | No | |
KB_DestroyTrees | boolean | Yes | |
KB_EffectCounter | integer | Yes | |
KB_EffectCounter2 | integer | Yes | |
KB_EffectPoint | location | No | |
KB_Effects_1 | string | Yes | |
KB_Effects_2 | string | Yes | |
KB_GeneralIntegers | integervar | Yes | |
KB_Group | group | No | |
KB_KnockbackedUnits | group | No | |
KB_Levels | integer | Yes | |
KB_MaxDistance | real | Yes | |
KB_ReachedDistance | real | Yes | |
KB_ReducedReal | real | No | |
KB_ReduceSpeedReal | real | Yes | |
KB_SpecificSpeed | real | Yes | |
KB_StartPositions | location | Yes | |
KB_TempPoint | location | Yes | |
KB_TempReal | real | No | |
KB_TotalKnockUnits | integer | No | |
KB_Units | unit | Yes | |
KBA_Caster | unit | No | |
KBA_DestroyTrees | boolean | No | |
KBA_DistancePerLevel | real | No | |
KBA_Level | integer | No | |
KBA_ManaLeak | integer | No | |
KBA_SpecialEffects | string | Yes | |
KBA_Speed | real | No | |
KBA_StartingPosition | location | No | |
KBA_TargetUnit | unit | No | |
KillerOfUnit | unit | Yes | |
LastDamageHP | real | No | |
LastDmgPrevAmount | real | Yes | |
LastDmgPrevType | integer | Yes | |
LastDmgSource | unit | Yes | |
LastDmgTarget | unit | Yes | |
LastDmgValue | real | Yes | |
LastDmgWasSpell | boolean | Yes | |
LastStandGroup | group | No | |
LD_Ability | abilcode | No | |
LD_AbilityDrain | abilcode | No | |
LD_Life | integer | No | |
LD_SearchRange | integer | No | |
locCaster | location | No | |
MagiDummyGroup | group | No | |
MainStructureGroup | group | No | |
MCGroupCount | integer | Yes | |
MCRIndex | integer | No | |
MCS_AttachmentPoint1 | string | No | |
MCS_AttachmentPoint2 | string | No | |
MCS_Caster1 | unit | No | |
MCS_Caster2 | unit | Yes | |
MCS_curDuration | real | Yes | |
MCS_Deadboolean | boolean | Yes | |
MCS_Duration1 | real | No | |
MCS_Duration2 | real | Yes | |
MCS_Integer | integer | Yes | |
MCS_MindControlledGroup | group | No | |
MCS_Player | player | Yes | |
MCS_SfxAtEndString | string | No | |
MCS_SfxAtEndString2 | string | Yes | |
MCS_SfxAtStartString | modelfile | No | |
MCS_SfxContinous1 | effect | Yes | |
MCS_SfxContinous1String | string | No | |
MCS_SfxContinous2 | effect | Yes | |
MCS_SfxContinous2String | string | No | |
MCS_Target1 | unit | No | |
MCS_Target2 | unit | Yes | |
MCWIndex | integer | No | |
MiasmaDeltaGroup | group | No | |
NebulasHasteGroup | group | No | |
NextDamageOverride | boolean | No | |
NextDamageType | integer | No | |
OncomingStormGroup | group | No | |
p | location | No | |
P_Manaend | real | No | |
P_Manastart | real | No | |
P_Manatotal | real | No | |
ParagonAuraGroup | group | No | |
PartisanGroup | group | No | |
PassGroup | group | No | |
PentaAuraGroup | group | No | |
PurgatoryGroup | group | No | |
RectorGroup | group | No | |
RevealWarning | string | No | You will be revealed to your opponents unless you build a town hall type building. |
SalamderLGroup | group | No | |
SearingLight_Caster | unit | No | |
SearingLight_Mod | integer | No | |
SharpshooterGroup | group | No | |
ShellRuneGroup | group | No | |
ShellRuneMDGroup | group | No | |
ShifterGroup | group | No | |
SOC_Angle | real | Yes | |
SOC_AngleInteger | integer | Yes | |
SOC_AOE | real | No | |
SOC_Caster | unit | Yes | |
SOC_CasterPoint | location | Yes | |
SOC_Hit | group | Yes | |
SOC_Index | integer | Yes | |
SOC_Integer | integer | Yes | |
SOC_IntegerEnd | integer | No | |
SOC_KBCasterPoint | location | Yes | |
SOC_Range | real | No | |
SolidityAuraGroup | group | No | |
SoulStone1Group | group | No | |
SoulStone2Group | group | No | |
SoulStone3Group | group | No | |
SpellDamageAbility | abilcode | No | |
StarBinderHeroGroup | group | No | |
StoneformDwarfGroup | group | No | |
StormstriderGroup | group | No | |
SummonerOfUnit | unit | Yes | |
targetPoint | location | No | |
Temp_Group_1 | group | No | |
Temp_Int | integer | No | |
Temp_Point | location | No | |
Temp_Unit | unit | No | |
Temp_UnitGroup | group | No | |
tempAngle_Real | real | No | |
tempCaster | unit | No | |
tempDamage_Scaling_Total | real | No | |
tempDamage_Total | real | No | |
tempDuration_Total | real | No | |
TempForce | force | No | |
TempGroup | group | No | |
tempGroup | group | No | |
TempGroupArray | group | Yes | |
tempInt_Counter | integer | No | |
tempInt_Counter_2 | integer | No | |
TempInteger | integer | Yes | |
tempItem | item | No | |
tempKey | integer | No | |
tempLevel | real | No | |
TempLoc | location | No | |
tempPickedUnit | unit | No | |
TempPoint | location | No | |
tempPoint_Target | location | No | |
tempPoint_Temp | location | No | |
tempPoint_Whirlpool | location | No | |
tempPull_Intensity_Total | real | No | |
tempRange_Total | real | No | |
TempUnit | unit | No | |
TorrentialFlameGroup | group | No | |
u | unit | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexLastRecycled | integer | No | |
UDexMax | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UmbralBloodGroup | group | No | |
UMovNext | integer | Yes | |
UMovPrev | integer | Yes | |
UnholyPresenceGroup | group | No | |
UnitDamageRegistered | boolean | Yes | |
UnitInAction | boolean | Yes | |
UnitInActionEvent | real | No | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitMovementInterval | real | No | |
UnitMoving | boolean | Yes | |
UnitMovingEvent | real | No | |
UnitMovingX | real | Yes | |
UnitMovingY | real | Yes | |
UnitTypeEvent | real | No | |
UnitTypeOf | unitcode | Yes | |
VenomSwipeCaster | group | No | |
VoidElvenGroup | group | No | |
VoyagerGroup | group | No | |
WarlordGroup | group | No | |
WarlordGroupAcro | group | No | |
WarmasterAuraGroup | group | No | |
WitherHeartGroup | group | No | |
WorldMaxX | real | No | |
WorldMaxY | real | No | |
WP_Ability_Order | string | No | |
WP_Attack_Type | attacktype | No | |
WP_Damage_Base | real | No | |
WP_Damage_Bonus | real | No | |
WP_Damage_Scaling_Base | real | No | |
WP_Damage_Scaling_Bonus | real | No | |
WP_Damage_Scaling_Max | real | No | |
WP_Damage_Type | damagetype | No | |
WP_Dummy_Loop | unit | No | |
WP_Dummy_Scale_Factor | real | No | |
WP_Dummy_Whirlpool | unit | No | |
WP_Duration_Base | real | No | |
WP_Duration_Bonus | real | No | |
WP_Duration_Max | real | No | |
WP_Effect_Center | string | No | |
WP_Effect_Hit | string | No | |
WP_Group_Counter | integer | No | |
WP_Hashtable | hashtable | No | |
WP_Interval_Integer | integer | No | |
WP_Loop_Group | group | No | |
WP_Pull_Intensity_Base | real | No | |
WP_Pull_Intensity_Bonus | real | No | |
WP_Pull_Intensity_Max | real | No | |
WP_Pull_Interval | integer | No | |
WP_Range_Base | real | No | |
WP_Range_Bonus | real | No | |
WP_Range_Max | real | No | |
WP_Spell_ID | abilcode | No | |
WP_Spell_ID_2 | abilcode | No | |
WP_Unit_Type_Dummy | unitcode | No | |
WP_Unit_Type_Whirl_Dummy | unitcode | No | |
WP_Unit_Type_Whirl_Dummy_2 | unitcode | No | |
ZerglingCounter | integer | Yes | |
ZerglingDyingUnit | unit | No | |
ZerglingRallyPoint | unit | No | |
ZerglingTrainedUnit | unit | No | |
ZerglingTrainerPoint | location | No |
//===========================================================================
function UnitEventDestroyGroup takes integer i returns nothing
if udg_CargoTransportGroup[i] != null then
call DestroyGroup(udg_CargoTransportGroup[i])
set udg_CargoTransportGroup[i] = null
endif
endfunction
function UnitEventCheckAfter takes nothing returns nothing
local integer i = 0
loop
set i = udg_CheckDeathList[i]
exitwhen i == 0
if udg_IsUnitNew[i] then
//The unit was just created.
set udg_IsUnitNew[i] = false
elseif udg_IsUnitTransforming[i] then
//Added 21 July 2017 to fix the issue re-adding this ability in the same instant
set udg_UDex = i
set udg_UnitTypeEvent = 0.00
set udg_UnitTypeEvent = 1.00
set udg_UnitTypeOf[i] = GetUnitTypeId(udg_UDexUnits[i]) //Set this afterward to give the user extra reference
set udg_IsUnitTransforming[i] = false
call UnitAddAbility(udg_UDexUnits[i], udg_DetectTransformAbility)
elseif udg_IsUnitAlive[i] then
//The unit has started reincarnating.
set udg_IsUnitReincarnating[i] = true
set udg_IsUnitAlive[i] = false
set udg_UDex = i
set udg_DeathEvent = 0.50
set udg_DeathEvent = 0.00
endif
set udg_CheckDeathInList[i] = false
endloop
//Empty the list
set udg_CheckDeathList[0] = 0
endfunction
function UnitEventCheckAfterProxy takes integer i returns nothing
if udg_CheckDeathList[0] == 0 then
call TimerStart(udg_CheckDeathTimer, 0.00, false, function UnitEventCheckAfter)
endif
if not udg_CheckDeathInList[i] then
set udg_CheckDeathList[i] = udg_CheckDeathList[0]
set udg_CheckDeathList[0] = i
set udg_CheckDeathInList[i] = true
endif
endfunction
function UnitEventOnUnload takes nothing returns nothing
local integer i = udg_UDex
call GroupRemoveUnit(udg_CargoTransportGroup[GetUnitUserData(udg_CargoTransportUnit[i])], udg_UDexUnits[i])
set udg_IsUnitBeingUnloaded[i] = true
set udg_CargoEvent = 0.00
set udg_CargoEvent = 2.00
set udg_CargoEvent = 0.00
set udg_IsUnitBeingUnloaded[i] = false
if not IsUnitLoaded(udg_UDexUnits[i]) or IsUnitType(udg_CargoTransportUnit[i], UNIT_TYPE_DEAD) or GetUnitTypeId(udg_CargoTransportUnit[i]) == 0 then
set udg_CargoTransportUnit[i] = null
endif
endfunction
function UnitEventOnDeath takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_UDex != 0 then
set udg_KillerOfUnit[udg_UDex] = GetKillingUnit() //Added 29 May 2017 for GIMLI_2
set udg_IsUnitAlive[udg_UDex] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
set udg_KillerOfUnit[udg_UDex] = null
if udg_CargoTransportUnit[udg_UDex] != null then
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnOrder takes nothing returns boolean
local integer pdex = udg_UDex
local unit u = GetFilterUnit()
local integer i = GetUnitUserData(u)
if i > 0 then
set udg_UDex = i
if GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
if not udg_IsUnitRemoved[i] then
set udg_IsUnitRemoved[i] = true
set udg_IsUnitAlive[i] = false
set udg_SummonerOfUnit[i] = null
//For backwards-compatibility:
set udg_DeathEvent = 0.00
set udg_DeathEvent = 3.00
set udg_DeathEvent = 0.00
//Fire deindex event for UDex:
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 2.00
set udg_UnitIndexEvent = 0.00
set udg_UDexNext[udg_UDexPrev[i]] = udg_UDexNext[i]
set udg_UDexPrev[udg_UDexNext[i]] = udg_UDexPrev[i]
// Recycle the index for later use
set udg_UDexUnits[i] = null
set udg_UDexPrev[i] = udg_UDexLastRecycled
set udg_UDexLastRecycled = i
call UnitEventDestroyGroup(i)
endif
elseif not udg_IsUnitAlive[i] then
if not IsUnitType(u, UNIT_TYPE_DEAD) then
set udg_IsUnitAlive[i] = true
set udg_DeathEvent = 0.00
set udg_DeathEvent = 2.00
set udg_DeathEvent = 0.00
set udg_IsUnitReincarnating[i] = false
endif
elseif IsUnitType(u, UNIT_TYPE_DEAD) then
if udg_IsUnitNew[i] then
//This unit was created as a corpse.
set udg_IsUnitAlive[i] = false
set udg_DeathEvent = 0.00
set udg_DeathEvent = 1.00
set udg_DeathEvent = 0.00
elseif udg_CargoTransportUnit[i] == null or not IsUnitType(u, UNIT_TYPE_HERO) then
//The unit may have just started reincarnating.
call UnitEventCheckAfterProxy(i)
endif
elseif GetUnitAbilityLevel(u, udg_DetectTransformAbility) == 0 and not udg_IsUnitTransforming[i] then
set udg_IsUnitTransforming[i] = true
call UnitEventCheckAfterProxy(i) //This block has been updated on 21 July 2017
endif
if udg_CargoTransportUnit[i] != null and not udg_IsUnitBeingUnloaded[i] and not IsUnitLoaded(u) or IsUnitType(u, UNIT_TYPE_DEAD) then
call UnitEventOnUnload()
endif
set udg_UDex = pdex
endif
set u = null
return false
endfunction
function UnitEventOnSummon takes nothing returns boolean
local integer pdex = udg_UDex
set udg_UDex = GetUnitUserData(GetTriggerUnit())
if udg_IsUnitNew[udg_UDex] then
set udg_SummonerOfUnit[udg_UDex] = GetSummoningUnit()
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 0.50
set udg_UnitIndexEvent = 0.00
endif
set udg_UDex = pdex
return false
endfunction
function UnitEventOnLoad takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = GetUnitUserData(GetTriggerUnit())
local integer index
if i != 0 then
set udg_UDex = i
if udg_CargoTransportUnit[i] != null then
call UnitEventOnUnload()
endif
//Loaded corpses do not issue an order when unloaded, therefore must
//use the enter-region event method taken from Jesus4Lyf's Transport.
if not udg_IsUnitAlive[i] then
call SetUnitX(udg_UDexUnits[i], udg_WorldMaxX)
call SetUnitY(udg_UDexUnits[i], udg_WorldMaxY)
endif
set udg_CargoTransportUnit[i] = GetTransportUnit()
set index = GetUnitUserData(udg_CargoTransportUnit[i])
if udg_CargoTransportGroup[index] == null then
set udg_CargoTransportGroup[index] = CreateGroup()
endif
call GroupAddUnit(udg_CargoTransportGroup[index], udg_UDexUnits[i])
set udg_CargoEvent = 0.00
set udg_CargoEvent = 1.00
set udg_CargoEvent = 0.00
set udg_UDex = pdex
endif
return false
endfunction
function UnitEventEnter takes nothing returns boolean
local integer pdex = udg_UDex
local integer i = udg_UDexLastRecycled
local unit u = GetFilterUnit()
if udg_UnitIndexerEnabled and GetUnitAbilityLevel(u, udg_DetectRemoveAbility) == 0 then
//Generate a unique integer index for this unit
if i == 0 then
set i = udg_UDexMax + 1
set udg_UDexMax = i
else
set udg_UDexLastRecycled = udg_UDexPrev[i]
endif
//Link index to unit, unit to index
set udg_UDexUnits[i] = u
call SetUnitUserData(u, i)
//For backwards-compatibility, add the unit to a linked list
set udg_UDexNext[i] = udg_UDexNext[0]
set udg_UDexPrev[udg_UDexNext[0]] = i
set udg_UDexNext[0] = i
set udg_UDexPrev[i] = 0
set udg_CheckDeathInList[i] = false
call UnitAddAbility(u, udg_DetectRemoveAbility)
call UnitMakeAbilityPermanent(u, true, udg_DetectRemoveAbility)
call UnitAddAbility(u, udg_DetectTransformAbility)
set udg_UnitTypeOf[i] = GetUnitTypeId(u)
set udg_IsUnitNew[i] = true
set udg_IsUnitAlive[i] = true
set udg_IsUnitRemoved[i] = false
set udg_IsUnitReincarnating[i] = false
set udg_IsUnitPreplaced[i] = udg_IsUnitPreplaced[0] //Added 29 May 2017 for Spellbound
call UnitEventCheckAfterProxy(i)
//Fire index event for UDex
set udg_UDex = i
set udg_UnitIndexEvent = 0.00
set udg_UnitIndexEvent = 1.00
set udg_UnitIndexEvent = 0.00
else
set udg_UDex = GetUnitUserData(u)
if udg_CargoTransportUnit[udg_UDex] != null and not IsUnitLoaded(u) then
//The unit was dead, but has re-entered the map.
call UnitEventOnUnload()
endif
endif
set udg_UDex = pdex
set u = null
return false
endfunction
//===========================================================================
function UnitEventInit takes nothing returns nothing
local integer i = bj_MAX_PLAYER_SLOTS //update to make it work with 1.29
local player p
local trigger t = CreateTrigger()
local trigger load = CreateTrigger()
local trigger death = CreateTrigger()
local trigger summon = CreateTrigger()
local rect r = GetWorldBounds()
local region re = CreateRegion()
local boolexpr enterB = Filter(function UnitEventEnter)
local boolexpr orderB = Filter(function UnitEventOnOrder)
set udg_WorldMaxX = GetRectMaxX(r)
set udg_WorldMaxY = GetRectMaxY(r)
call RegionAddRect(re, r)
call RemoveRect(r)
call UnitEventDestroyGroup(0)
call UnitEventDestroyGroup(1)
set udg_CheckDeathList[0] = 0
set udg_UnitIndexerEnabled = true
call TriggerRegisterEnterRegion(CreateTrigger(), re, enterB)
call TriggerAddCondition(load, Filter(function UnitEventOnLoad))
call TriggerAddCondition(death, Filter(function UnitEventOnDeath))
call TriggerAddCondition(summon, Filter(function UnitEventOnSummon))
loop
set i = i - 1
set p = Player(i)
call SetPlayerAbilityAvailable(p, udg_DetectRemoveAbility, false)
call SetPlayerAbilityAvailable(p, udg_DetectTransformAbility, false)
call TriggerRegisterPlayerUnitEvent(summon, p, EVENT_PLAYER_UNIT_SUMMON, null)
call TriggerRegisterPlayerUnitEvent(t, p, EVENT_PLAYER_UNIT_ISSUED_ORDER, orderB)
call TriggerRegisterPlayerUnitEvent(death, p, EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(load, p, EVENT_PLAYER_UNIT_LOADED, null)
call GroupEnumUnitsOfPlayer(bj_lastCreatedGroup, p, enterB)
exitwhen i == 0
endloop
set summon = null
set death = null
set load = null
set re = null
set enterB = null
set orderB = null
set p = null
set r = null
set t = null
endfunction
function InitTrig_Unit_Event takes nothing returns nothing
endfunction
//TESH.scrollpos=12
//TESH.alwaysfold=0
constant function GetAMSBuffId takes nothing returns integer
return 'Bams'
endfunction
constant function GetAMSAbilId takes nothing returns integer
return 'A0QJ'
endfunction
constant function GetAMSShieldVal takes nothing returns real
return 300.00
endfunction
function Trig_Anti_Magic_Shield_Fix_Actions takes nothing returns nothing
local integer id = GetUnitUserData(udg_DamageEventTarget)
local real shield = udg_AMSAmount[id]- udg_DamageEventAmount
if shield <= 0.00 then
set udg_DamageEventAmount = -shield
set shield = 0.00
call UnitRemoveAbility(udg_DamageEventTarget, GetAMSBuffId())
else
set udg_DamageEventAmount = 0.00
if udg_DamageEventType == 0 then
set udg_DamageEventType = udg_DamageTypeBlocked
endif
endif
set udg_AMSAmount[id] = shield
endfunction
function Trig_Anti_Magic_Shield_Fix_Conditions takes nothing returns boolean
if udg_IsDamageSpell then
if GetUnitAbilityLevel(udg_DamageEventTarget, GetAMSBuffId()) > 0 then
call Trig_Anti_Magic_Shield_Fix_Actions()
else
set udg_AMSAmount[GetUnitUserData(udg_DamageEventTarget)] = 0.00
endif
endif
return false
endfunction
function AMS_Refresh_Conditions takes nothing returns boolean
if GetSpellAbilityId() == GetAMSAbilId() then
set udg_AMSAmount[GetUnitUserData(GetSpellTargetUnit())] = GetAMSShieldVal()
endif
return false
endfunction
function InitTrig_Anti_Magic_Shield_Fix takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_DamageModifierEvent", EQUAL, 4.00)
call TriggerAddCondition(t, Condition(function Trig_Anti_Magic_Shield_Fix_Conditions))
set t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Filter(function AMS_Refresh_Conditions))
endfunction
//TESH.scrollpos=0
//TESH.alwaysfold=0
function IsUnitMovementTracked takes integer i returns boolean
return udg_UMovPrev[i] != 0 or udg_UMovNext[0] == i
endfunction
function UnitMovementRegister takes nothing returns boolean
local integer i = udg_UDex
if not IsUnitMovementTracked(i) and TriggerEvaluate(gg_trg_Is_Unit_Moving_Config) then
set udg_UMovPrev[udg_UMovNext[0]] = i
set udg_UMovNext[i] = udg_UMovNext[0]
set udg_UMovNext[0] = i
set udg_UnitMovingX[i] = GetUnitX(udg_UDexUnits[i])
set udg_UnitMovingY[i] = GetUnitY(udg_UDexUnits[i])
endif
return false
endfunction
function UnitMovementUnregister takes nothing returns boolean
local integer i = udg_UDex
if IsUnitMovementTracked(i) then
set udg_UnitMoving[i] = false
set udg_UMovNext[udg_UMovPrev[i]] = udg_UMovNext[i]
set udg_UMovPrev[udg_UMovNext[i]] = udg_UMovPrev[i]
set udg_UMovPrev[i] = 0
endif
return false
endfunction
function RunUnitMovementEvent takes integer i, real e returns nothing
local integer pdex = udg_UDex
if e == 1.00 then
set udg_UnitMoving[i] = true
else
set udg_UnitMoving[i] = false
endif
set udg_UDex = i
set udg_UnitMovingEvent = e
set udg_UnitMovingEvent = 0.00
set udg_UDex = pdex
endfunction
//===========================================================================
// This function runs periodically to check if units are actually moving.
//
function UnitMovementTracker takes nothing returns nothing
local integer i = 0
local integer n
local real x
local real y
loop
set i = udg_UMovNext[i]
exitwhen i == 0
set x = GetUnitX(udg_UDexUnits[i])
set y = GetUnitY(udg_UDexUnits[i])
if x != udg_UnitMovingX[i] or y != udg_UnitMovingY[i] then
set udg_UnitMovingX[i] = x
set udg_UnitMovingY[i] = y
if not udg_UnitMoving[i] then
if GetUnitTypeId(udg_UDexUnits[i]) != 0 then
call RunUnitMovementEvent(i, 1.00)
else
set n = udg_UDex
set udg_UDex = i
set i = udg_UMovPrev[i] //avoid skipping checks
call UnitMovementUnregister()
set udg_UDex = n
endif
endif
elseif udg_UnitMoving[i] then
call RunUnitMovementEvent(i, 2.00)
endif
endloop
endfunction
//===========================================================================
function InitTrig_Is_Unit_Moving takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
call TriggerAddCondition(t, Filter(function UnitMovementRegister))
set t = CreateTrigger()
call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 2.00)
call TriggerAddCondition(t, Filter(function UnitMovementUnregister))
if gg_trg_Is_Unit_Moving_Config != null then
call TriggerExecute(gg_trg_Is_Unit_Moving_Config)
else
call ExecuteFunc("Trig_Is_Unit_Moving_Config_Actions")
endif
call TimerStart(CreateTimer(), udg_UnitMovementInterval, true, function UnitMovementTracker)
endfunction
// GUI-Friendly Damage Detection -- v1.2.1 -- by Weep
// http:// www.thehelper.net/forums/showthread.php?t=137957
//
// Requires: only this trigger and its variables.
//
// -- What? --
// This snippet provides a leak-free, GUI-friendly implementation of an "any unit takes
// damage" event. It requires no JASS knowledge to use.
//
// It uses the Game - Value Of Real Variable event as its method of activating other
// triggers, and passes the event responses through a few globals.
//
// -- Why? --
// The traditional GUI method of setting up a trigger than runs when any unit is damaged
// leaks trigger events. This snippet is easy to implement and removes the need to do
// you own GUI damage detection setup.
//
// -- How To Implement --
// 0. Before you copy triggers that use GDD into a new map, you need to copy over GDD
// with its GDD Variable Creator trigger, or there will be a problem: the variables
// won't be automatically created correctly.
//
// 1. Be sure "Automatically create unknown variables while pasting trigger data" is
// enabled in the World Editor general preferences.
// 2. Copy this trigger category ("GDD") and paste it into your map.
// (Alternately: create the variables listed in the globals block below, create a
// trigger named "GUI Friendly Damage Detection", and paste in this entire text.)
// 3. Create your damage triggers using Game - Value Of Real Variable as the event,
// select GDD_Event as the variable, and leave the rest of the settings to the default
// "becomes Equal to 0.00".
// The event responses are the following variables:
// GDD_Damage is the amount of damage, replacing Event Response - Damage Taken.
// GDD_DamagedUnit is the damaged unit, replacing Event Response - Triggering Unit.
// Triggering Unit can still be used, if you need to use waits.
// Read the -- Notes -- section below for more info.
// GDD_DamageSource is the damaging unit, replacing Event Response - Damage Source.
//
// -- Notes --
// GDD's event response variables are not wait-safe; you can't use them after a wait in
// a trigger. If you need to use waits, Triggering Unit (a.k.a. GetTriggerUnit()) can
// be used in place of GDD_DamageSource. There is no usable wait-safe equivalent to
// Event Damage or Damage Source; you'll need to save the values yourself.
//
// Don't write any values to the variables used as the event responses, or it will mess
// up any other triggers using this snippet for their triggering. Only use their values.
//
// This uses arrays, so can detect damage for a maximum of 8190 units at a time, and
// cleans up data at a rate of 33.33 per second, by default. This should be enough for
// most maps, but if you want to change the rate, change the value returned in the
// GDD_RecycleRate function at the top of the code, below.
//
// By default, GDD will not register units that have Locust at the moment of their
// entering the game, and will not recognize when they take damage (which can only
// happen if the Locust ability is later removed from the unit.) To allow a unit to have
// Locust yet still cause GDD damage events if Locust is removed, you can either design
// the unit to not have Locust by default and add it via triggers after creation, or
// edit the GDD_Filter function at the top of the code, below.
//
// -- Credits --
// Captain Griffin on wc3c.net for the research and concept of GroupRefresh.
//
// Credit in your map not needed, but please include this README.
//
// -- Version History --
// 1.2.1: Minor code cleaning. Added configuration functions. Updated documentation.
// 1.2.0: Made this snippet work properly with recursive damage.
// 1.1.1: Added a check in order to not index units with the Locust ability (dummy units).
// If you wish to check for damage taken by a unit that is unselectable, do not
// give the unit-type Locust in the object editor; instead, add the Locust ability
// 'Aloc' via a trigger after its creation, then remove it.
// 1.1.0: Added a check in case a unit gets moved out of the map and back.
// 1.0.0: First release.
//===================================================================
// Configurables.
function GDD_RecycleRate takes nothing returns real //The rate at which the system checks units to see if they've been removed from the game
return 0.03
endfunction
function GDD_Filter takes unit u returns boolean //The condition a unit has to pass to have it registered for damage detection
return GetUnitAbilityLevel(u, 'Aloc') == 0 //By default, the system ignores Locust units, because they normally can't take damage anyway
endfunction
//===================================================================
// This is just for reference.
// If you use JassHelper, you could uncomment this section instead of creating the variables in the trigger editor.
// globals
// real udg_GDD_Event = 0.
// real udg_GDD_Damage = 0.
// unit udg_GDD_DamagedUnit
// unit udg_GDD_DamageSource
// trigger array udg_GDD__TriggerArray
// integer array udg_GDD__Integers
// unit array udg_GDD__UnitArray
// group udg_GDD__LeftMapGroup = CreateGroup()
// endglobals
//===================================================================
// System code follows. Don't touch!
function GDD_Event takes nothing returns boolean
local unit damagedcache = udg_GDD_DamagedUnit
local unit damagingcache = udg_GDD_DamageSource
local real damagecache = udg_GDD_Damage
set udg_GDD_DamagedUnit = GetTriggerUnit()
set udg_GDD_DamageSource = GetEventDamageSource()
set udg_GDD_Damage = GetEventDamage()
set udg_GDD_Event = 1.
set udg_GDD_Event = 0.
set udg_GDD_DamagedUnit = damagedcache
set udg_GDD_DamageSource = damagingcache
set udg_GDD_Damage = damagecache
set damagedcache = null
set damagingcache = null
return false
endfunction
function GDD_AddDetection takes nothing returns boolean
// if(udg_GDD__Integers[0] > 8190) then
// call BJDebugMsg("GDD: Too many damage events! Decrease number of units present in the map or increase recycle rate.")
// ***Recycle rate is specified in the GDD_RecycleRate function at the top of the code. Smaller is faster.***
// return
// endif
if(IsUnitInGroup(GetFilterUnit(), udg_GDD__LeftMapGroup)) then
call GroupRemoveUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
elseif(GDD_Filter(GetFilterUnit())) then
set udg_GDD__Integers[0] = udg_GDD__Integers[0]+1
set udg_GDD__UnitArray[udg_GDD__Integers[0]] = GetFilterUnit()
set udg_GDD__TriggerArray[udg_GDD__Integers[0]] = CreateTrigger()
call TriggerRegisterUnitEvent(udg_GDD__TriggerArray[udg_GDD__Integers[0]], udg_GDD__UnitArray[udg_GDD__Integers[0]], EVENT_UNIT_DAMAGED)
call TriggerAddCondition(udg_GDD__TriggerArray[udg_GDD__Integers[0]], Condition(function GDD_Event))
endif
return false
endfunction
function GDD_PreplacedDetection takes nothing returns nothing
local group g = CreateGroup()
local integer i = 0
loop
call GroupEnumUnitsOfPlayer(g, Player(i), Condition(function GDD_AddDetection))
set i = i+1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
call DestroyGroup(g)
set g = null
endfunction
function GDD_GroupRefresh takes nothing returns nothing
// Based on GroupRefresh by Captain Griffen on wc3c.net
if (bj_slotControlUsed[5063] == true) then
call GroupClear(udg_GDD__LeftMapGroup)
set bj_slotControlUsed[5063] = false
endif
call GroupAddUnit(udg_GDD__LeftMapGroup, GetEnumUnit())
endfunction
function GDD_Recycle takes nothing returns nothing
if(udg_GDD__Integers[0] <= 0) then
return
elseif(udg_GDD__Integers[1] <= 0) then
set udg_GDD__Integers[1] = udg_GDD__Integers[0]
endif
if(GetUnitTypeId(udg_GDD__UnitArray[udg_GDD__Integers[1]]) == 0) then
call DestroyTrigger(udg_GDD__TriggerArray[udg_GDD__Integers[1]])
set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = null
set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = udg_GDD__TriggerArray[udg_GDD__Integers[0]]
set udg_GDD__UnitArray[udg_GDD__Integers[1]] = udg_GDD__UnitArray[udg_GDD__Integers[0]]
set udg_GDD__UnitArray[udg_GDD__Integers[0]] = null
set udg_GDD__Integers[0] = udg_GDD__Integers[0]-1
endif
set udg_GDD__Integers[1] = udg_GDD__Integers[1]-1
endfunction
function GDD_LeaveMap takes nothing returns boolean
local boolean cached = bj_slotControlUsed[5063]
if(udg_GDD__Integers[2] < 64) then
set udg_GDD__Integers[2] = udg_GDD__Integers[2]+1
else
set bj_slotControlUsed[5063] = true
call ForGroup(udg_GDD__LeftMapGroup, function GDD_GroupRefresh)
set udg_GDD__Integers[2] = 0
endif
call GroupAddUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
set bj_slotControlUsed[5063] = cached
return false
endfunction
// ===========================================================================
function InitTrig_GUI_Friendly_Damage_Detection takes nothing returns nothing
local region r = CreateRegion()
call RegionAddRect(r, GetWorldBounds())
call TriggerRegisterEnterRegion(CreateTrigger(), r, Condition(function GDD_AddDetection))
call TriggerRegisterLeaveRegion(CreateTrigger(), r, Condition(function GDD_LeaveMap))
call GDD_PreplacedDetection()
call TimerStart(CreateTimer(), GDD_RecycleRate(), true, function GDD_Recycle)
set r = null
endfunction
//TESH.scrollpos=2
//TESH.alwaysfold=0
//===========================================================================
// Trigger: Incineration
// Script Author: Razorclaw X (http://www.campaigncreations.org)
// Info: Mass Flame Strike, so to speak
// Caster: Flame Snapper
//===========================================================================
function Trig_CleansingFires_Conditions takes nothing returns boolean
return ( GetSpellAbilityId() == 'A16V' )
endfunction
function Trig_CleansingFires_Actions takes nothing returns nothing
local unit Caster = GetSpellAbilityUnit()
local player Owner = GetOwningPlayer(Caster)
local location CasterLoc = GetUnitLoc(Caster)
local integer i = 0
local integer MaxRaised = 9
local string spell = "flamestrike"
local real radius = 700
local unit Target
local group TargetGroup
local location TempPoint
set TargetGroup = GetUnitsInRangeOfLocAll(radius, CasterLoc)
loop
set Target = FirstOfGroup(TargetGroup)
exitwhen Target == null
if ( IsUnitEnemy(Target, Owner) ) then
set TempPoint = GetUnitLoc(Target)
call CreateNUnitsAtLocFacingLocBJ( 1, 'h0AC' , Owner, TempPoint, TempPoint )
call UnitApplyTimedLife( GetLastCreatedUnit(), 1, 5)
call UnitAddAbilityBJ( 'ANfs', GetLastCreatedUnit() )
call SetUnitPathing( GetLastCreatedUnit(), false )
call IssueTargetOrderBJ( GetLastCreatedUnit(), spell, Target )
call RemoveLocation( TempPoint )
set i = i + 1
endif
call GroupRemoveUnitSimple( Target, TargetGroup )
call TriggerSleepAction( 0.1 )
exitwhen i > MaxRaised
endloop
call RemoveLocation(TempPoint)
call DestroyGroup(TargetGroup)
call RemoveLocation(CasterLoc)
set Owner=null
set TargetGroup=null
set CasterLoc=null
set TempPoint=null
endfunction
//===========================================================================
function InitTrig_CleansingFires takes nothing returns nothing
local integer j = 0
set gg_trg_CleansingFires = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CleansingFires, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_CleansingFires, Condition( function Trig_CleansingFires_Conditions ) )
call TriggerAddAction( gg_trg_CleansingFires, function Trig_CleansingFires_Actions )
endfunction