- Joined
- Sep 2, 2005
- Messages
- 1,029
OK. so what I want to do it I want to make a function, with the same name as an existing blizzard function, so when the blizzard function gets called, it uses mine instead as it's more locally defined. I can't remember for the life of me what it's called but we did it all the time in java and vb.net.
I want to have my map use a custom MeleeStartingUnits function, which can be called from a standard melee init gui thing.
There's my code. I had to rename MeleestartingUnits to MeleeStartingUnits2 so I could save. I'd rather use the default call in init instead of having to call a different function. Any advice?
I want to have my map use a custom MeleeStartingUnits function, which can be called from a standard melee init gui thing.
JASS:
function MeleeStartingUnitsEnt 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 location wispLoc
local location heroLoc
local real peonX
local real peonY
local unit seed
if (doPreload) then
//call Preloader( "scripts\\NightElfMelee.pld" )
endif
// Spawn Seed of Rebirth at the start location.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc)
set seed = CreateUnitAtLoc(whichPlayer, 'e000', startLoc, bj_UNIT_FACING)
// Set random hero spawn point to be just south of the start location.
set heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
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)
endif
endif
if (doCamera) then
// Center the camera on the initial Wisps.
call SetCameraPositionForPlayer(whichPlayer, peonX, peonY)
call SetCameraQuickPositionForPlayer(whichPlayer, peonX, peonY)
endif
set seed = null
endfunction
function MeleeStartingUnits2 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))
// Create initial starting units
call MeleeStartingUnitsEnt(indexPlayer, indexStartLoc, true, true, true)
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
There's my code. I had to rename MeleestartingUnits to MeleeStartingUnits2 so I could save. I'd rather use the default call in init instead of having to call a different function. Any advice?
Last edited: