CustomMeleeSetup = {
unitSpacing = 64.00,
minTreeDist = 3.50,
minWispDist = 1.75,
}
do
CustomMelee.addTownHallId('htow', 'hkee', 'hcas',
'ogre', 'ostr', 'ofrt',
'unpl', 'unp1', 'unp2',
'etol', 'etoa', 'etoe')
-- Starting Base Layouts.
local funcs = CustomMeleeSetup
funcs.human_id = CustomMelee.addRaceFaction(RACE_HUMAN, "Alliance")
funcs.orc_id = CustomMelee.addRaceFaction(RACE_ORC, "Horde")
funcs.undead_id = CustomMelee.addRaceFaction(RACE_UNDEAD, "Scourge")
funcs.elf_id = CustomMelee.addRaceFaction(RACE_NIGHTELF, "Sentinel")
funcs.demon_id = CustomMelee.addRaceFaction(RACE_DEMON, "normal")
funcs.other_id = CustomMelee.addRaceFaction(RACE_OTHER, "normal")
funcs.def = function(whichplayer, startloc, hallId, peonId)
if type(hallId) == 'string' then hallId = FourCC(hallId) end
if type(peonId) == 'string' then peonId = FourCC(peonId) end
local nearestMine = MeleeFindNearestMine(startloc, bj_MELEE_MINE_SEARCH_RADIUS)
local peonX
local peonY
local heroLoc
local townHall
if (nearestMine ~= nil) then
-- Spawn Town Hall at the start location.
townHall = CreateUnitAtLoc(whichplayer, hallId, startloc, bj_UNIT_FACING)
-- Spawn Peasants near the mine.
local mineLoc = GetUnitLoc(nearestMine)
local nearMineLoc = MeleeGetProjectedLoc(mineLoc, startloc, 320, 0)
peonX, peonY = GetLocationX(nearMineLoc), GetLocationY(nearMineLoc)
CreateUnit(whichplayer, peonId, peonX + 0.00 * funcs.unitSpacing, peonY + 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX + 1.00 * funcs.unitSpacing, peonY + 0.15 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX - 1.00 * funcs.unitSpacing, peonY + 0.15 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX + 0.60 * funcs.unitSpacing, peonY - 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX - 0.60 * funcs.unitSpacing, peonY - 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Set random hero spawn point to be off to the side of the start location.
heroLoc = MeleeGetProjectedLoc(mineLoc, startloc, 384, 45)
RemoveLocation(mineLoc)
RemoveLocation(nearMineLoc)
else
-- Spawn Town Hall at the start location.
townHall = CreateUnitAtLoc(whichplayer, hallId, startloc, bj_UNIT_FACING)
-- Spawn Peasants directly south of the town hall.
peonX = GetLocationX(startloc)
peonY = GetLocationY(startloc) - 224.00
CreateUnit(whichplayer, peonId, peonX + 2.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX + 1.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX + 0.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX - 1.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, peonId, peonX - 2.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Set random hero spawn point to be just south of the start location.
heroLoc = Location(peonX, peonY - 2.00 * funcs.unitSpacing)
end
return peonX, peonY, heroLoc, townHall, nearestMine
end
funcs.def_human = function(whichplayer, startloc, doheroes, docamera, dopreload)
if (dopreload) then
Preloader("scripts\\HumanMelee.pld")
end
local peonX, peonY, heroLoc, townHall = funcs.def(whichplayer, startloc, 'htow', 'hpea')
if (townHall ~= nil) then
UnitAddAbility(townHall, FourCC('Amic'))
UnitMakeAbilityPermanent(townHall, true, FourCC('Amic'))
end
return peonX, peonY, heroLoc
end
funcs.def_orc = function(whichplayer, startloc, doheroes, docamera, dopreload)
if (dopreload) then
Preloader("scripts\\OrcMelee.pld")
end
local peonX, peonY, heroLoc = funcs.def(whichplayer, startloc, 'ogre', 'opeo')
return peonX, peonY, heroLoc
end
funcs.def_nightelf = function(whichplayer, startloc, doheroes, docamera, dopreload)
if (dopreload) then
Preloader( "scripts\\NightElfMelee.pld" )
end
local townhall
local nearestMine = MeleeFindNearestMine(startloc, bj_MELEE_MINE_SEARCH_RADIUS)
local heroLoc
local peonX
local peonY
if (nearestMine ~= nil) 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.
local mineLoc = GetUnitLoc(nearestMine)
local nearMineLoc = MeleeGetProjectedLoc(mineLoc, startloc, 650, 0)
nearMineLoc = MeleeGetLocWithinRect(nearMineLoc, GetRectFromCircleBJ(mineLoc, funcs.minTreeDist))
townhall = CreateUnitAtLoc(whichplayer, FourCC('etol'), nearMineLoc, bj_UNIT_FACING)
IssueTargetOrder(townhall, "entangleinstant", nearestMine)
-- Spawn Wisps at the start location.
local wispLoc = MeleeGetProjectedLoc(mineLoc, startloc, 280, 0)
wispLoc = MeleeGetLocWithinRect(wispLoc, GetRectFromCircleBJ(mineLoc, funcs.minWispDist))
peonX = GetLocationX(wispLoc)
peonY = GetLocationY(wispLoc)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 0.00 * funcs.unitSpacing, peonY + 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 1.00 * funcs.unitSpacing, peonY + 0.15 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX - 1.00 * funcs.unitSpacing, peonY + 0.15 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 0.58 * funcs.unitSpacing, peonY - 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX - 0.58 * funcs.unitSpacing, peonY - 1.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Set random hero spawn point to be off to the side of the start location.
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startloc, 384, 45)
else
-- Spawn Tree of Life at the start location.
CreateUnitAtLoc(whichplayer, FourCC('etol'), startloc, bj_UNIT_FACING)
-- Spawn Wisps directly south of the town hall.
peonX = GetLocationX(startloc)
peonY = GetLocationY(startloc) - 224.00
CreateUnit(whichplayer, FourCC('ewsp'), peonX - 2.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX - 1.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 0.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 1.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ewsp'), peonX + 2.00 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Set random hero spawn point to be just south of the start location.
heroLoc = Location(peonX, peonY - 2.00 * funcs.unitSpacing)
end
return peonX, peonY, heroLoc
end
funcs.def_undead = function(whichplayer, startloc, doheroes, docamera, dopreload)
if (dopreload) then
Preloader("scripts\\UndeadMelee.pld")
end
local peonX, peonY, heroLoc
local nearestMine = MeleeFindNearestMine(startloc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine ~= nil) then
-- Spawn Necropolis at the start location.
CreateUnitAtLoc(whichplayer, FourCC('unpl'), startloc, bj_UNIT_FACING)
-- Replace the nearest gold mine with a blighted version.
nearestMine = BlightGoldMineForPlayerBJ(nearestMine, whichplayer)
local mineLoc = GetUnitLoc(nearestMine)
-- Spawn Ghoul near the Necropolis.
nearTownLoc = MeleeGetProjectedLoc(startloc, mineLoc, 288, 0)
ghoulX = GetLocationX(nearTownLoc)
ghoulY = GetLocationY(nearTownLoc)
bj_ghoul[GetPlayerId(whichplayer)] = CreateUnit(whichplayer, FourCC('ugho'), ghoulX + 0.00 * funcs.unitSpacing, ghoulY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Spawn Acolytes near the mine.
nearMineLoc = MeleeGetProjectedLoc(mineLoc, startloc, 320, 0)
peonX = GetLocationX(nearMineLoc)
peonY = GetLocationY(nearMineLoc)
CreateUnit(whichplayer, FourCC('uaco'), peonX + 0.00 * funcs.unitSpacing, peonY + 0.50 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('uaco'), peonX + 0.65 * funcs.unitSpacing, peonY - 0.50 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('uaco'), peonX - 0.65 * funcs.unitSpacing, peonY - 0.50 * funcs.unitSpacing, bj_UNIT_FACING)
-- Create a patch of blight around the gold mine.
SetBlightLoc(whichplayer,nearMineLoc, 768, true)
-- Set random hero spawn point to be off to the side of the start location.
heroLoc = MeleeGetProjectedLoc(mineLoc, startloc, 384, 45)
RemoveLocation(mineLoc)
RemoveLocation(nearTownLoc)
else
-- Spawn Necropolis at the start location.
CreateUnitAtLoc(whichplayer, FourCC('unpl'), startloc, bj_UNIT_FACING)
-- Spawn Acolytes and Ghoul directly south of the Necropolis.
peonX = GetLocationX(startloc)
peonY = GetLocationY(startloc) - 224.00
CreateUnit(whichplayer, FourCC('uaco'), peonX - 1.50 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('uaco'), peonX - 0.50 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('uaco'), peonX + 0.50 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
CreateUnit(whichplayer, FourCC('ugho'), peonX + 1.50 * funcs.unitSpacing, peonY + 0.00 * funcs.unitSpacing, bj_UNIT_FACING)
-- Create a patch of blight around the start location.
SetBlightLoc(whichplayer,startloc, 768, true)
-- Set random hero spawn point to be just south of the start location.
heroLoc = Location(peonX, peonY - 2.00 * funcs.unitSpacing)
end
return peonX, peonY, heroLoc
end
funcs.def_human = CustomMelee.finalizeSetupFunction(RACE_HUMAN, "Alliance", funcs.def_human)
funcs.def_orc = CustomMelee.finalizeSetupFunction(RACE_ORC, "Horde", funcs.def_orc)
funcs.def_undead = CustomMelee.finalizeSetupFunction(RACE_UNDEAD, "Scourge", funcs.def_undead)
funcs.def_nightelf = CustomMelee.finalizeSetupFunction(RACE_NIGHTELF, "Sentinel", funcs.def_nightelf)
funcs.def_demon = MeleeStartingUnitsUnknownRace
funcs.def_other = MeleeStartingUnitsUnknownRace
CustomMelee.raceFactionSetup(RACE_HUMAN, "Alliance", funcs.def_human)
CustomMelee.raceFactionSetup(RACE_ORC, "Horde", funcs.def_orc)
CustomMelee.raceFactionSetup(RACE_UNDEAD, "Scourge", funcs.def_undead)
CustomMelee.raceFactionSetup(RACE_NIGHTELF, "Sentinel", funcs.def_nightelf)
CustomMelee.raceFactionSetup(RACE_DEMON, "normal", funcs.def_demon)
CustomMelee.raceFactionSetup(RACE_OTHER, "normal", funcs.def_other)
CustomMelee.setRaceFactionAI(RACE_HUMAN, "Alliance", "human.ai")
CustomMelee.setRaceFactionAI(RACE_ORC, "Horde", "orc.ai")
CustomMelee.setRaceFactionAI(RACE_UNDEAD, "Scourge", "undead.ai")
CustomMelee.setRaceFactionAI(RACE_NIGHTELF, "Sentinel", "elf.ai")
-- Registering Hero Ids.
-- Human
CustomMelee.addHeroId('Hamg', RACE_HUMAN, funcs.human_id)
CustomMelee.addHeroId('Hmkg', RACE_HUMAN, funcs.human_id)
CustomMelee.addHeroId('Hpal', RACE_HUMAN, funcs.human_id)
CustomMelee.addHeroId('Hblm', RACE_HUMAN, funcs.human_id)
-- Orc
CustomMelee.addHeroId('Obla', RACE_ORC, funcs.orc_id)
CustomMelee.addHeroId('Ofar', RACE_ORC, funcs.orc_id)
CustomMelee.addHeroId('Otch', RACE_ORC, funcs.orc_id)
CustomMelee.addHeroId('Oshd', RACE_ORC, funcs.orc_id)
-- Night Elf
CustomMelee.addHeroId('Edem', RACE_NIGHTELF, funcs.nightelf_id)
CustomMelee.addHeroId('Ekee', RACE_NIGHTELF, funcs.nightelf_id)
CustomMelee.addHeroId('Emoo', RACE_NIGHTELF, funcs.nightelf_id)
CustomMelee.addHeroId('Ewar', RACE_NIGHTELF, funcs.nightelf_id)
-- Undead
CustomMelee.addHeroId('Udea', RACE_UNDEAD, funcs.undead_id)
CustomMelee.addHeroId('Udre', RACE_UNDEAD, funcs.undead_id)
CustomMelee.addHeroId('Ulic', RACE_UNDEAD, funcs.undead_id)
CustomMelee.addHeroId('Ucrl', RACE_UNDEAD, funcs.undead_id)
-- Neutrals
CustomMelee.addHeroId('Npbm', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nbrn', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nngs', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nplh', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nbst', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nalc', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Ntin', RACE_OTHER, funcs.other_id)
CustomMelee.addHeroId('Nfir', RACE_OTHER, funcs.other_id)
end