MeleeStartingUnitsOrc
- Parameters
-
whichPlayer player
startLoc location
doHeroes boolean
doCamera boolean
doPreload boolean
- comment
- bug
Leaks.
Uncleared handle variables:
nearestMine
nearMineLoc
heroLoc
In Jass you must set local variables that hold agents (or any child type) to
null
at the end of functions to avoid reference counter leaks.Objects not removed (e.g. RemoveLocation):
- Loc, Loc
nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine)
- Loc, Loc
heroLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine)
- Loc
heroLoc = Location(peonX, peonY - 2.00 * unitSpacing)
- patch
1.00
- Source
- Blizzard.j
- return type
nothing
- Source code
function 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