//TESH.scrollpos=69
//TESH.alwaysfold=0
//===========================================================================
// Replaces a gold mine with a blighted gold mine for the given player.
//
//===========================================================================
// Starting Units for Custom Players
// - 1 Tier1 Hall, placed at start location
// - 5 Gold Workers, placed between start location and nearest gold mine
//
function MeleeStartingUnitsCustom takes player whichPlayer, location startLoc, boolean doHeroes, boolean doCamera, boolean doPreload, integer whichRace returns nothing
local boolean useRandomHero = IsMapFlagSet(MAP_RANDOM_HERO)
local real unitSpacing = 64.00
local unit nearestMine
local unit tree
local location nearMineLoc
local location nearTownLoc
local location exactMineLoc
local location heroLoc
local real peonX
local real peonY
local real ghoulX
local real ghoulY
local integer mineGold
local unit newMine
set nearestMine = MeleeFindNearestMine(startLoc, bj_MELEE_MINE_SEARCH_RADIUS)
if (nearestMine != null) then
set nearMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 320, 0)
set peonX = GetLocationX(nearMineLoc)
set peonY = GetLocationY(nearMineLoc)
if (udg_UnitType_Goldmine[whichRace] != null) then
if (udg_UnitType_Goldmine[whichRace] == udg_UnitType_TownhallT1[whichRace]) then
// Replace the nearest gold mine with a Tier1 Hall.
// Save the Gold Mine's properties and remove it.
set exactMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 0, 0)
set mineGold = GetResourceAmount(nearestMine)
call RemoveUnit(nearestMine)
// Create a Tier1 Hall to replace the Gold Mine.
set nearestMine = CreateUnitAtLoc(whichPlayer, udg_UnitType_TownhallT1[whichRace], exactMineLoc, bj_UNIT_FACING)
call SetResourceAmount(nearestMine, mineGold)
else
// Replace the nearest gold mine with a new version.
// Replace the nearest gold mine with a Tier1 Hall.
// Save the Gold Mine's properties and remove it.
set exactMineLoc = MeleeGetProjectedLoc(GetUnitLoc(nearestMine), startLoc, 0, 0)
set mineGold = GetResourceAmount(nearestMine)
call RemoveUnit(nearestMine)
// Create a Tier1 Hall to replace the Gold Mine.
set nearestMine = CreateUnitAtLoc(whichPlayer, udg_UnitType_Goldmine[whichRace], exactMineLoc, bj_UNIT_FACING)
call SetResourceAmount(nearestMine, mineGold)
// Spawn Tier1 Hall at the start location.
call CreateUnitAtLoc(whichPlayer, udg_UnitType_TownhallT1[whichRace], startLoc, bj_UNIT_FACING)
endif
else
if (udg_HallEntanglesGoldmine[whichRace] == true) then
// Spawn Tier1 Hall near goldmine.
set tree = CreateUnitAtLoc(whichPlayer, udg_UnitType_TownhallT1[whichRace], nearMineLoc, bj_UNIT_FACING)
call IssueTargetOrder(tree, "entangleinstant", nearestMine)
else
// Spawn Tier1 Hall at the start location.
call CreateUnitAtLoc(whichPlayer, udg_UnitType_TownhallT1[whichRace], startLoc, bj_UNIT_FACING)
endif
endif
// Spawn Gold Workers near the mine.
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX + 0.00 * unitSpacing, peonY + 1.00 * unitSpacing, bj_UNIT_FACING)
if (udg_UnitType_SecondaryWorker[whichRace] != null) then
// Spawn Ghoul near the Tier1 Hall.
set nearTownLoc = MeleeGetProjectedLoc(startLoc, GetUnitLoc(nearestMine), 288, 0)
set ghoulX = GetLocationX(nearTownLoc)
set ghoulY = GetLocationY(nearTownLoc)
call CreateUnit(whichPlayer, udg_UnitType_SecondaryWorker[whichRace], ghoulX + 0.60 * unitSpacing, ghoulY - 1.00 * unitSpacing, bj_UNIT_FACING)
endif
if (udg_StartsWithBlight[whichRace] == true) then
// Create a patch of blight around the start location.
call SetBlightLoc(whichPlayer,startLoc, 768, true)
endif
// 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 Tier1 Hall at the start location.
call CreateUnitAtLoc(whichPlayer, udg_UnitType_TownhallT1[whichRace], startLoc, bj_UNIT_FACING)
// Spawn Gold Workers directly south of the Tier1 Hall.
set peonX = GetLocationX(startLoc)
set peonY = GetLocationY(startLoc) - 224.00
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX + 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX + 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX + 0.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
if (udg_UnitType_SecondaryWorker[whichRace] != null) then
// Spawn Ghoul near the Tier1 Hall.
call CreateUnit(whichPlayer, udg_UnitType_SecondaryWorker[whichRace], peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
else
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX - 1.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
call CreateUnit(whichPlayer, udg_UnitType_PrimaryWorker[whichRace], peonX - 2.00 * unitSpacing, peonY + 0.00 * unitSpacing, bj_UNIT_FACING)
endif
if (udg_StartsWithBlight[whichRace] == true) then
// Create a patch of blight around the start location.
call SetBlightLoc(whichPlayer,startLoc, 768, true)
endif
// 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, udg_UnitType_Hero1[whichRace], udg_UnitType_Hero2[whichRace], udg_UnitType_Hero3[whichRace], udg_UnitType_Hero4[whichRace], 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
//===========================================================================
function AlteredMeleeStartingUnits 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 (udg_RaceChosen[GetConvertedPlayerId(indexPlayer)] == 1) then
call MeleeStartingUnitsHuman(indexPlayer, indexStartLoc, true, true, true)
elseif (udg_RaceChosen[GetConvertedPlayerId(indexPlayer)] == 2) then
call MeleeStartingUnitsOrc(indexPlayer, indexStartLoc, true, true, true)
elseif (udg_RaceChosen[GetConvertedPlayerId(indexPlayer)] == 3) then
call MeleeStartingUnitsUndead(indexPlayer, indexStartLoc, true, true, true)
elseif (udg_RaceChosen[GetConvertedPlayerId(indexPlayer)] == 4) then
call MeleeStartingUnitsNightElf(indexPlayer, indexStartLoc, true, true, true)
else
call MeleeStartingUnitsCustom(indexPlayer, indexStartLoc, true, true, true, udg_RaceChosen[GetConvertedPlayerId(indexPlayer)])
endif
endif
set index = index + 1
exitwhen index == bj_MAX_PLAYERS
endloop
endfunction
//***************************************************************************
//*
//* Altered Melee Template Victory / Defeat Conditions
//*
//***************************************************************************
//===========================================================================
// Count buildings currently owned by all allies, including the player themself.
//
function AlteredMeleeGetAllyStructureCount takes player whichPlayer returns integer
local integer playerIndex
local integer buildingCount
local player indexPlayer
// Count the number of buildings controlled by all not-yet-defeated co-allies.
set buildingCount = 0
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
// uncomment to cause defeat even if you have control of ally structures, but yours have been nixed
//if (PlayersAreCoAllied(whichPlayer, indexPlayer) and not bj_meleeDefeated[playerIndex]) then
if (PlayersAreCoAllied(whichPlayer, indexPlayer)) then
set buildingCount = buildingCount + GetPlayerStructureCount(indexPlayer, true)
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return buildingCount
endfunction
//===========================================================================
// Counts key structures owned by a player and his or her allies, including
// structures currently upgrading or under construction.
//
// Key structures: Town Hall, Great Hall, Tree of Life, Necropolis
//
function AlteredMeleeGetAllyKeyStructureCount takes player whichPlayer returns integer
local integer playerIndex
local player indexPlayer
local integer keyStructs
local integer raceIndex
// 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 + GetPlayerTypedUnitCount(indexPlayer, "townhall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "greathall", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "treeoflife", true, true)
set keyStructs = keyStructs + GetPlayerTypedUnitCount(indexPlayer, "necropolis", true, true)
set raceIndex = 5
loop
set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId(udg_UnitType_TownhallT1[raceIndex], indexPlayer)
set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId(udg_UnitType_TownhallT2[raceIndex], indexPlayer)
set keyStructs = keyStructs + CountLivingPlayerUnitsOfTypeId(udg_UnitType_TownhallT3[raceIndex], indexPlayer)
set raceIndex = raceIndex + 1
exitwhen raceIndex == (udg_NumOfRaceChoices + 1)
endloop
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
return keyStructs
endfunction
//===========================================================================
// Test each player to determine if anyone has been defeated.
//
function AlteredMeleeCheckForLosersAndVictors takes nothing returns nothing
local integer playerIndex
local player indexPlayer
local force defeatedPlayers = CreateForce()
local force victoriousPlayers
local boolean gameOver = false
// If the game is already over, do nothing
if (bj_meleeGameOver) then
return
endif
// If the game was disconnected then it is over, in this case we
// don't want to report results for anyone as they will most likely
// conflict with the actual game results
if (GetIntegerGameState(GAME_STATE_DISCONNECTED) != 0) then
set bj_meleeGameOver = true
return
endif
// Check each player to see if he or she has been defeated yet.
set playerIndex = 0
loop
set indexPlayer = Player(playerIndex)
if (not bj_meleeDefeated[playerIndex] and not bj_meleeVictoried[playerIndex]) then
//call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, "Player"+I2S(playerIndex)+" has "+I2S(AlteredMeleeGetAllyStructureCount(indexPlayer))+" ally buildings.")
if (AlteredMeleeGetAllyStructureCount(indexPlayer) <= 0) then
// Keep track of each defeated player so that we can give
// them a defeat later.
call ForceAddPlayer(defeatedPlayers, Player(playerIndex))
// Set their defeated flag now so MeleeCheckForVictors
// can detect victors.
set bj_meleeDefeated[playerIndex] = true
endif
endif
set playerIndex = playerIndex + 1
exitwhen playerIndex == bj_MAX_PLAYERS
endloop
// Now that the defeated flags are set, check if there are any victors
set victoriousPlayers = MeleeCheckForVictors()
// Defeat all defeated players
call ForForce(defeatedPlayers, function MeleeDoDefeatEnum)
// Give victory to all victorious players
call ForForce(victoriousPlayers, function MeleeDoVictoryEnum)
// If the game is over we should remove all observers
if (bj_meleeGameOver) then
call MeleeRemoveObservers()
endif
endfunction
//===========================================================================
// Returns a race-specific "build X or be revealed" message.
//
function AlteredMeleeGetCrippledWarningMessage takes player whichPlayer returns string
if (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 1) then
return GetLocalizedString("CRIPPLE_WARNING_HUMAN")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 2) then
return GetLocalizedString("CRIPPLE_WARNING_ORC")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 3) then
return GetLocalizedString("CRIPPLE_WARNING_NIGHTELF")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 4) then
return GetLocalizedString("CRIPPLE_WARNING_UNDEAD")
else
return udg_RevealMessage[udg_RaceChosen[GetConvertedPlayerId(whichPlayer)]]
endif
endfunction
//===========================================================================
// Returns a race-specific "build X" label for cripple timers.
//
function AlteredMeleeGetCrippledTimerMessage takes player whichPlayer returns string
if (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 1) then
return GetLocalizedString("CRIPPLE_TIMER_HUMAN")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 2) then
return GetLocalizedString("CRIPPLE_TIMER_ORC")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 3) then
return GetLocalizedString("CRIPPLE_TIMER_NIGHTELF")
elseif (udg_RaceChosen[GetConvertedPlayerId(whichPlayer )] == 4) then
return GetLocalizedString("CRIPPLE_TIMER_UNDEAD")
else
return udg_BuildWindow[udg_RaceChosen[GetConvertedPlayerId(whichPlayer)]]
endif
endfunction
//===========================================================================
function AlteredMeleePlayerIsCrippled takes player whichPlayer returns boolean
local integer allyStructures = AlteredMeleeGetAllyStructureCount(whichPlayer)
local integer allyKeyStructures = AlteredMeleeGetAllyKeyStructureCount(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 AlteredMeleeCheckForCrippledPlayers 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 = AlteredMeleePlayerIsCrippled(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, AlteredMeleeGetCrippledWarningMessage(indexPlayer))
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 (AlteredMeleeGetAllyStructureCount(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 AlteredMeleeCheckLostUnit 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 AlteredMeleeCheckForLosersAndVictors()
endif
// Check if the lost unit has crippled or uncrippled the player.
// (A team with 0 units is dead, and thus considered uncrippled.)
call AlteredMeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
// Determine if the gained unit should result in any defeats, victories,
// or cripple-status changes.
//
function AlteredMeleeCheckAddedUnit 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 AlteredMeleeCheckForCrippledPlayers()
endif
endfunction
//===========================================================================
function AlteredMeleeTriggerActionConstructCancel takes nothing returns nothing
call AlteredMeleeCheckLostUnit(GetCancelledStructure())
endfunction
//===========================================================================
function AlteredMeleeTriggerActionUnitDeath takes nothing returns nothing
if (IsUnitType(GetDyingUnit(), UNIT_TYPE_STRUCTURE)) then
call AlteredMeleeCheckLostUnit(GetDyingUnit())
endif
endfunction
//===========================================================================
function AlteredMeleeTriggerActionUnitConstructionStart takes nothing returns nothing
call AlteredMeleeCheckAddedUnit(GetConstructingStructure())
endfunction
//===========================================================================
function AlteredMeleeTriggerActionPlayerDefeated takes nothing returns nothing
local player thePlayer = GetTriggerPlayer()
call CachePlayerHeroData(thePlayer)
if (MeleeGetAllyCount(thePlayer) > 0) then
// If at least one ally is still alive and kicking, share units with
// them and proceed with death.
call ShareEverythingWithTeam(thePlayer)
if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then
call MeleeDoDefeat(thePlayer)
endif
else
// If no living allies remain, swap all units and buildings over to
// neutral_passive and proceed with death.
call MakeUnitsPassiveForTeam(thePlayer)
if (not bj_meleeDefeated[GetPlayerId(thePlayer)]) then
call MeleeDoDefeat(thePlayer)
endif
endif
call AlteredMeleeCheckForLosersAndVictors()
endfunction
//===========================================================================
function AlteredMeleeTriggerActionPlayerLeft takes nothing returns nothing
local player thePlayer = GetTriggerPlayer()
// Just show game over for observers when they leave
if (IsPlayerObserver(thePlayer)) then
call RemovePlayerPreserveUnitsBJ(thePlayer, PLAYER_GAME_RESULT_NEUTRAL, false)
return
endif
call CachePlayerHeroData(thePlayer)
// This is the same as defeat except the player generates the message
// "player left the game" as opposed to "player was defeated".
if (MeleeGetAllyCount(thePlayer) > 0) then
// If at least one ally is still alive and kicking, share units with
// them and proceed with death.
call ShareEverythingWithTeam(thePlayer)
call MeleeDoLeave(thePlayer)
else
// If no living allies remain, swap all units and buildings over to
// neutral_passive and proceed with death.
call MakeUnitsPassiveForTeam(thePlayer)
call MeleeDoLeave(thePlayer)
endif
call AlteredMeleeCheckForLosersAndVictors()
endfunction
//===========================================================================
function AlteredMeleeTriggerActionAllianceChange takes nothing returns nothing
call AlteredMeleeCheckForLosersAndVictors()
call AlteredMeleeCheckForCrippledPlayers()
endfunction
//===========================================================================
function AlteredMeleeInitVictoryDefeat 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], AlteredMeleeGetCrippledTimerMessage(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 AlteredMeleeTriggerActionConstructCancel)
// 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 AlteredMeleeTriggerActionUnitDeath)
// 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 AlteredMeleeTriggerActionUnitConstructionStart)
// Set a trigger to fire whenever this player defeats-out
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_DEFEAT)
call TriggerAddAction(trig, function AlteredMeleeTriggerActionPlayerDefeated)
// Set a trigger to fire whenever this player leaves
set trig = CreateTrigger()
call TriggerRegisterPlayerEvent(trig, indexPlayer, EVENT_PLAYER_LEAVE)
call TriggerAddAction(trig, function AlteredMeleeTriggerActionPlayerLeft)
// 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 AlteredMeleeTriggerActionAllianceChange)
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 AlteredMeleeTriggerActionPlayerLeft)
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 AlteredMeleeTriggerActionAllianceChange)
endfunction
Name | Type | is_array | initial_value |
BuildWindow | string | Yes | |
Conscription | integer | Yes | 6 |
DamageBlockingAbility | abilcode | No | |
DamageEvent | real | No | |
DamageEventAmount | real | No | |
DamageEventExplodesUnit | boolean | No | |
DamageEventOverride | boolean | No | |
DamageEventPrevAmt | real | No | |
DamageEventSource | unit | No | |
DamageEventsWasted | integer | No | |
DamageEventTarget | unit | No | |
DamageEventTrigger | trigger | No | |
DamageEventType | integer | No | |
DamageModifierEvent | real | No | |
DamageTypeDOT | integer | No | |
DamageTypeRanged | integer | No | |
DamageTypeSpell | integer | No | |
DemoVelocity | real | No | |
DmgEvLife | real | No | |
DmgEvN | integer | No | |
DmgEvStack | unit | Yes | |
DmgEvTimer | timer | No | |
DmgTypPrev | integer | No | |
HallEntanglesGoldmine | boolean | Yes | |
ItemDrop | integer | No | |
Necro_Upgrades_Int | integer | Yes | |
NumOfPlayerSlots | integer | No | |
NumOfRaceChoices | integer | No | |
Point | location | No | |
RaceChoices | dialog | No | |
RaceChosen | integer | Yes | |
RaceDraenei | button | No | |
RaceHuman | button | No | |
RaceNaga | button | No | |
RaceNightElf | button | No | |
RaceOrc | button | No | |
RaceUndead | button | No | |
RevealMessage | string | Yes | |
StartsWithBlight | boolean | Yes | |
TempUnit | unit | No | |
TempX | real | No | |
TempY | real | No | |
TmpGroup | group | No | |
tmpHypCoord | integer | No | |
tmpPoint | location | No | |
tmpXcoord | integer | No | |
tmpYcoord | integer | No | |
UDex | integer | No | |
UDexGen | integer | No | |
UDexNext | integer | Yes | |
UDexPrev | integer | Yes | |
UDexRecycle | integer | No | |
UDexUnits | unit | Yes | |
UDexWasted | integer | No | |
UMovNext | integer | Yes | |
UMovPrev | integer | Yes | |
UnitDamageRegistered | boolean | Yes | |
UnitIndexerEnabled | boolean | No | |
UnitIndexEvent | real | No | |
UnitIndexLock | integer | Yes | |
UnitMoving | boolean | Yes | |
UnitMovingEvent | real | No | |
UnitMovingX | real | Yes | |
UnitMovingY | real | Yes | |
UnitType_Goldmine | unitcode | Yes | |
UnitType_Hero1 | unitcode | Yes | |
UnitType_Hero2 | unitcode | Yes | |
UnitType_Hero3 | unitcode | Yes | |
UnitType_Hero4 | unitcode | Yes | |
UnitType_PrimaryWorker | unitcode | Yes | |
UnitType_SecondaryWorker | unitcode | Yes | |
UnitType_TownhallT1 | unitcode | Yes | |
UnitType_TownhallT2 | unitcode | Yes | |
UnitType_TownhallT3 | unitcode | Yes |
//TESH.scrollpos=60
//TESH.alwaysfold=0
library_once GroupUtils
//******************************************************************************
//* BY: Rising_Dusk
//*
//* This library is a simple implementation of a stack for groups that need to
//* be in the user's control for greater than an instant of time. Additionally,
//* this library provides a single, global group variable for use with user-end
//* enumerations. It is important to note that users should not be calling
//* DestroyGroup() on the global group, since then it may not exist for when it
//* it is next needed.
//*
//* The group stack removes the need for destroying groups and replaces it with
//* a recycling method.
//* function NewGroup takes nothing returns group
//* function ReleaseGroup takes group g returns boolean
//* function GroupRefresh takes group g returns nothing
//*
//* NewGroup grabs a currently unused group from the stack or creates one if the
//* stack is empty. You can use this group however you'd like, but always
//* remember to call ReleaseGroup on it when you are done with it. If you don't
//* release it, it will 'leak' and your stack may eventually overflow if you
//* keep doing that.
//*
//* GroupRefresh cleans a group of any shadow references which may be clogging
//* its hash table. If you remove a unit from the game who is a member of a unit
//* group, it will 'effectively' remove the unit from the group, but leave a
//* shadow in its place. Calling GroupRefresh on a group will clean up any
//* shadow references that may exist within it.
//*
globals
//* Group for use with all instant enumerations
group ENUM_GROUP = CreateGroup()
//* Temporary references for GroupRefresh
private boolean Flag = false
private group Refr = null
//* Assorted constants
private constant integer MAX_HANDLE_COUNT = 408000
private constant integer MIN_HANDLE_ID = 0x100000
//* Arrays and counter for the group stack
private group array Groups
private integer array Status[MAX_HANDLE_COUNT]
private integer Count = 0
endglobals
private function AddEx takes nothing returns nothing
if Flag then
call GroupClear(Refr)
set Flag = false
endif
call GroupAddUnit(Refr, GetEnumUnit())
endfunction
function GroupRefresh takes group g returns nothing
set Flag = true
set Refr = g
call ForGroup(Refr, function AddEx)
if Flag then
call GroupClear(g)
endif
endfunction
function NewGroup takes nothing returns group
if Count == 0 then
set Groups[0] = CreateGroup()
else
set Count = Count - 1
endif
set Status[GetHandleId(Groups[Count])-MIN_HANDLE_ID] = 1
return Groups[Count]
endfunction
function ReleaseGroup takes group g returns boolean
local integer stat = Status[GetHandleId(g)-MIN_HANDLE_ID]
if g == null then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Null groups cannot be released")
return false
elseif stat == 0 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Group not part of stack")
return false
elseif stat == 2 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Groups cannot be multiply released")
return false
elseif Count == 8191 then
debug call BJDebugMsg(SCOPE_PREFIX+"Error: Max groups achieved, destroying group")
call DestroyGroup(g)
return false
endif
call GroupClear(g)
set Groups[Count] = g
set Count = Count + 1
set Status[GetHandleId(g)-MIN_HANDLE_ID] = 2
return true
endfunction
endlibrary
//TESH.scrollpos=0
//TESH.alwaysfold=0
library_once TimerUtils initializer init
//*********************************************************************
//* TimerUtils (Blue flavor for 1.23b or later)
//* ----------
//*
//* To implement it , create a custom text trigger called TimerUtils
//* and paste the contents of this script there.
//*
//* To copy from a map to another, copy the trigger holding this
//* library to your map.
//*
//* (requires vJass) More scripts: htt://www.wc3campaigns.net
//*
//* For your timer needs:
//* * Attaching
//* * Recycling (with double-free protection)
//*
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
//* ReleaseTimer(t) : Relese a timer (alt to DestroyTimer)
//* SetTimerData(t,2) : Attach value 2 to timer
//* GetTimerData(t) : Get the timer's value.
//* You can assume a timer's value is 0
//* after NewTimer.
//*
//* Blue Flavor: Slower than the red flavor, it got a 408000 handle id
//* limit, which means that if more than 408000 handle ids
//* are used in your map, TimerUtils might fail, this
//* value is quite big and it is much bigger than the
//* timer limit in Red flavor.
//*
//********************************************************************
//==================================================================================================
globals
private hashtable hasht //I <3 blizz
endglobals
//It is dependent on jasshelper's recent inlining optimization in order to perform correctly.
function SetTimerData takes timer t, integer value returns nothing
call SaveInteger(hasht,0, GetHandleId(t), value)
endfunction
function GetTimerData takes timer t returns integer
return LoadInteger(hasht, 0, GetHandleId(t))
endfunction
//==========================================================================================
globals
private timer array tT
private integer tN = 0
private constant integer HELD=0x28829022
//use a totally random number here, the more improbable someone uses it, the better.
endglobals
//==========================================================================================
function NewTimer takes nothing returns timer
if (tN==0) then
set tT[0]=CreateTimer()
else
set tN=tN-1
endif
call SetTimerData(tT[tN],0)
return tT[tN]
endfunction
//==========================================================================================
function ReleaseTimer takes timer t returns nothing
if(t==null) then
debug call BJDebugMsg("Warning: attempt to release a null timer")
return
endif
if (tN==8191) then
debug call BJDebugMsg("Warning: Timer stack is full, destroying timer!!")
//stack is full, the map already has much more troubles than the chance of bug
call DestroyTimer(t)
else
call PauseTimer(t)
if(GetTimerData(t)==HELD) then
debug call BJDebugMsg("Warning: ReleaseTimer: Double free!")
return
endif
call SetTimerData(t,HELD)
set tT[tN]=t
set tN=tN+1
endif
endfunction
private function init takes nothing returns nothing
set hasht = InitHashtable()
endfunction
endlibrary
//TESH.scrollpos=172
//TESH.alwaysfold=0
library SquadSystem requires GroupUtils, TimerUtils
// ****************************************************
// Advanced Squad Master System - Scripted by Sourc[e]x
// ****************************************************
//
// Item bugfix version 2
// ****************************************************
globals
// Constants
private constant integer MAX_SQUAD_SIZE = 10
private constant integer MAX_SQUADS = 35000
// Helpers
private constant integer ORDER_TYPE_NOTARGET = 0
private constant integer ORDER_TYPE_POINT = 1
private constant integer ORDER_TYPE_WIDGET = 2
private key SQUAD_ID
// System Globals
private hashtable Table = InitHashtable ( )
private group Squad = CreateGroup ( )
private trigger OrderTrig = CreateTrigger ( )
private trigger ItemTrig1 = CreateTrigger ( )
private trigger ItemTrig2 = CreateTrigger ( )
private trigger ItemTrig3 = CreateTrigger ( )
private squad SQUAD
private integer ItemType = 0
endglobals
function IsUnitInSquad takes unit u returns boolean
return IsUnitInGroup ( u, Squad )
endfunction
function GetUnitSquad takes unit u returns squad
return squad ( LoadInteger ( Table, GetHandleId ( u ), SQUAD_ID ) )
endfunction
function IsUnitSquadLeader takes unit u returns boolean
return squad ( LoadInteger ( Table, GetHandleId ( u ), SQUAD_ID ) ).leader == u
endfunction
function GetInventoryIndexOfItemType takes unit whichUnit, integer itemId returns integer
local integer index = 0
local item indexItem
loop
set indexItem = UnitItemInSlot ( whichUnit, index )
if indexItem != null and GetItemTypeId ( indexItem ) == itemId then
set indexItem = null
return index
endif
set index = index + 1
exitwhen index >= 6
endloop
set indexItem = null
return 6
endfunction
function UnitRemoveAlltems takes unit u returns nothing
local integer i = 6
call DisableTrigger ( ItemTrig3 )
call DisableTrigger ( ItemTrig2 )
loop
set i = i - 1
exitwhen i < 0
call RemoveItem ( UnitItemInSlot ( u, i ) )
endloop
call EnableTrigger ( ItemTrig3 )
call EnableTrigger ( ItemTrig2 )
endfunction
struct squad [MAX_SQUADS]
group all = null
unit leader = null
private integer current_order = 851972
private real current_x = 0
private real current_y = 0
private widget current_w = null
private integer ordertype = ORDER_TYPE_NOTARGET
integer array deadId [ MAX_SQUAD_SIZE ]
integer array player [ MAX_SQUAD_SIZE ]
integer count = 0
private integer RegenAura = 0
private real RegenTime = 0
private string RegenSFX = ""
private timer Timer = null
private static boolean resurrected
// ==============================================
// Enumerating methods
private static method hideCallback takes nothing returns nothing
if not IsUnitLoaded ( GetEnumUnit ( ) ) then
call ShowUnit ( GetEnumUnit ( ), false )
endif
endmethod
private static method showCallback takes nothing returns nothing
local unit u = GetEnumUnit ( )
if u != SQUAD.leader then
call ShowUnit ( u, true )
call SetUnitPosition ( u, GetUnitX ( SQUAD.leader ), GetUnitY ( SQUAD.leader ) )
endif
set u = null
endmethod
private static method killAllCallback takes nothing returns nothing
call KillUnit ( GetEnumUnit ( ) )
endmethod
private static method giveItemCallback takes nothing returns nothing
if GetEnumUnit ( ) != GetManipulatingUnit ( ) then
call UnitAddItem ( GetEnumUnit ( ), CreateItem ( ItemType, 0, 0 ) )
endif
endmethod
private static method removeItemCallback takes nothing returns nothing
if GetEnumUnit ( ) != GetManipulatingUnit ( ) then
call RemoveItem ( UnitItemInSlot ( GetEnumUnit ( ), GetInventoryIndexOfItemType ( GetEnumUnit ( ), ItemType ) ) )
endif
endmethod
private static method useItemCallback takes nothing returns nothing
local unit u = GetEnumUnit ( )
local item i
if u != GetManipulatingUnit ( ) then
set i = UnitItemInSlot ( u, GetInventoryIndexOfItemType ( u, ItemType ) )
call UnitUseItem ( u, i )
call UnitUseItemPoint ( u, i, GetUnitX ( GetManipulatingUnit ( ) ), GetUnitY ( GetManipulatingUnit ( ) ) )
set i = null
endif
set u = null
endmethod
private static method RegenEnum takes nothing returns nothing
if not thistype.resurrected and GetUnitAbilityLevel ( GetEnumUnit ( ), SQUAD.RegenAura ) > 0 then
set thistype.resurrected = true
call SQUAD.resurrect.execute ( )
endif
endmethod
private static method RegenCallback takes nothing returns nothing
local squad this = GetTimerData ( GetExpiredTimer ( ) )
set thistype.resurrected = false
set SQUAD = this
call ForGroup ( this.all, function thistype.RegenEnum )
endmethod
// ==============================================
// Ordering methods
method issueImmediateOrder takes integer order returns nothing
set this.ordertype = ORDER_TYPE_NOTARGET
set this.current_order = order
call DisableTrigger ( OrderTrig )
call GroupImmediateOrderById ( this.all, order )
call EnableTrigger ( OrderTrig )
endmethod
method issuePointOrder takes integer order, real x, real y returns nothing
set this.ordertype = ORDER_TYPE_POINT
set this.current_order = order
set this.current_x = x
set this.current_y = y
call DisableTrigger ( OrderTrig )
call GroupPointOrderById ( this.all, order, x, y )
call EnableTrigger ( OrderTrig )
endmethod
method issueTargetOrder takes integer order, widget target returns nothing
set this.ordertype = ORDER_TYPE_WIDGET
set this.current_order = order
set this.current_w = target
call DisableTrigger ( OrderTrig )
call GroupTargetOrderById ( this.all, order, target )
call EnableTrigger ( OrderTrig )
endmethod
method issueLastOrder takes nothing returns nothing
if this.ordertype == ORDER_TYPE_NOTARGET then
call this.issueImmediateOrder ( this.current_order )
elseif this.ordertype == ORDER_TYPE_POINT then
call this.issuePointOrder ( this.current_order, this.current_x, this.current_y )
elseif this.ordertype == ORDER_TYPE_WIDGET then
call this.issueTargetOrder ( this.current_order, this.current_w )
endif
endmethod
// ==============================================
// Squad manipulation methods
method remove takes unit u returns nothing
local boolean b
local player p
local unit n
if IsUnitInGroup ( u, this.all ) then
call GroupRemoveUnit ( this.all, u )
call GroupRemoveUnit ( Squad, u )
call FlushChildHashtable ( Table, GetHandleId ( u ) )
set n = FirstOfGroup ( this.all )
if u == this.leader and n != null then
set p = GetOwningPlayer ( this.leader )
set b = IsUnitSelected ( this.leader, p )
call SetUnitOwner ( n, p, true )
call SetResourceAmount ( n, GetResourceAmount ( this.leader ) )
//call SetUnitUseFood ( n, true )
set this.leader = n
debug BJDebugMsg ("Squad System: New squad leader chosen")
if b and GetLocalPlayer ( ) == p then
call SelectUnit ( this.leader, true )
endif
endif
endif
set n = null
endmethod
method add takes unit u returns nothing
call GroupAddUnit ( this.all, u )
call GroupAddUnit ( Squad, u )
call SaveInteger ( Table, GetHandleId ( u ), SQUAD_ID, integer(this) )
call RemoveGuardPosition ( u )
if this.leader == null then
set this.leader = u
debug BJDebugMsg ("Squad System: New squad leader chosen")
endif
call this.cloneLeaderItems.execute ( u )
endmethod
method hide takes boolean flag returns nothing
if flag then
call ForGroup ( this.all, function squad.hideCallback )
else
set SQUAD = this
call ForGroup ( this.all, function squad.showCallback )
endif
endmethod
method killAll takes nothing returns nothing
call ForGroup ( this.all, function squad.killAllCallback )
endmethod
method cloneLeaderItems takes unit target returns nothing
local integer i = 6
local item u = null
call DisableTrigger ( ItemTrig1 )
loop
set i = i - 1
exitwhen i < 0
set u = UnitItemInSlot ( this.leader, i )
if u != null then
call UnitAddItem ( target, CreateItem ( GetItemTypeId ( u ), 0, 0 ) )
endif
endloop
call EnableTrigger ( ItemTrig1 )
set u = null
endmethod
method setRegeneration takes integer BuffTypeId, real frequence, string sfx returns nothing
set this.Timer = NewTimer ( )
set this.RegenAura = BuffTypeId
set this.RegenSFX = sfx
call SetTimerData ( this.Timer, integer(this) )
call TimerStart ( this.Timer, frequence, true, function thistype.RegenCallback )
endmethod
method resurrect takes nothing returns nothing
local unit u
if this.count > 0 then
set this.count = this.count - 1
set u = CreateUnit ( Player ( this.player [ this.count ] ), this.deadId [ this.count ], GetUnitX ( this.leader ), GetUnitY ( this.leader ), 270 )
call this.add ( u )
call DestroyEffect ( AddSpecialEffect ( this.RegenSFX, GetUnitX ( u ), GetUnitY ( u ) ) )
call this.issueLastOrder ( )
set u = null
debug BJDebugMsg ("Squad System: A unit was resurrected")
endif
endmethod
// ==============================================
// Default methods
static method create takes nothing returns squad
local squad this = squad.allocate ( )
set this.all = NewGroup ( )
debug call BJDebugMsg ( "Squad created: " + I2S ( integer(this) ) )
return this
endmethod
method onDestroy takes nothing returns nothing
debug call BJDebugMsg ( "Squad destroyed: " + I2S ( integer(this) ) )
call ReleaseGroup ( this.all )
if this.Timer != null then
call ReleaseTimer ( this.Timer )
endif
endmethod
// ==============================================
// Trigger-related methods
private static method onUnitDeath takes nothing returns nothing
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) then
set this = GetUnitSquad ( u )
set this.deadId [this.count] = GetUnitTypeId ( u )
if u == this.leader then
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( u ) ) + 1
else
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( u ) )
endif
set this.count = this.count + 1
call this.remove ( u )
call UnitRemoveAlltems ( u )
if FirstOfGroup ( this.all ) == null then
call this.destroy ( )
endif
endif
set u = null
endmethod
private static method onUnitOrder takes nothing returns boolean
local unit u = GetTriggerUnit ( )
local eventid id = GetTriggerEventId ( )
if IsUnitInSquad ( u ) and IsUnitSquadLeader ( u ) then
if id == EVENT_PLAYER_UNIT_ISSUED_ORDER then
call GetUnitSquad ( u ).issueImmediateOrder ( GetIssuedOrderId ( ) )
elseif id == EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER then
call GetUnitSquad ( u ).issuePointOrder ( GetIssuedOrderId ( ), GetOrderPointX ( ), GetOrderPointY ( ) )
else
call GetUnitSquad ( u ).issueTargetOrder ( GetIssuedOrderId ( ), GetOrderTarget ( ) )
endif
endif
set u = null
set id = null
return false
endmethod
private static method onUnitLoad takes nothing returns nothing
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) and IsUnitSquadLeader ( u ) then
set this = GetUnitSquad ( u )
call this.hide ( true )
loop
exitwhen not IsUnitLoaded ( u ) or this == null
call TriggerSleepAction ( 0.1 )
endloop
if IsUnitHidden ( this.leader ) then
call this.killAll ( )
else
call this.hide ( false )
endif
endif
set u = null
endmethod
private static method onUnitSelect takes nothing returns boolean
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) and not IsUnitSquadLeader ( u ) then
set this = GetUnitSquad ( u )
if GetOwningPlayer ( this.leader ) == GetTriggerPlayer ( ) and GetLocalPlayer ( ) == GetTriggerPlayer ( ) then
call SelectUnit ( u, false )
call SelectUnit ( this.leader, true )
endif
endif
set u = null
return false
endmethod
private static method onItemPickup takes nothing returns boolean
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) then
set this = GetUnitSquad ( u )
set ItemType = GetItemTypeId ( GetManipulatedItem ( ) )
call DisableTrigger ( ItemTrig1 )
call ForGroup ( this.all, function squad.giveItemCallback )
call EnableTrigger ( ItemTrig1 )
endif
set u = null
return false
endmethod
private static method onItemDropped takes nothing returns boolean
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) then
set this = GetUnitSquad ( u )
set ItemType = GetItemTypeId ( GetManipulatedItem ( ) )
call DisableTrigger ( ItemTrig2 )
call ForGroup ( this.all, function squad.removeItemCallback )
call EnableTrigger ( ItemTrig2 )
endif
set u = null
return false
endmethod
private static method onItemUsed takes nothing returns boolean
local unit u = GetTriggerUnit ( )
local squad this
if IsUnitInSquad ( u ) then
set this = GetUnitSquad ( u )
set ItemType = GetItemTypeId ( GetManipulatedItem ( ) )
call DisableTrigger ( ItemTrig3 )
call DisableTrigger ( ItemTrig2 )
call ForGroup ( this.all, function squad.useItemCallback )
call EnableTrigger ( ItemTrig3 )
call EnableTrigger ( ItemTrig2 )
endif
set u = null
return false
endmethod
// ==============================================
// Initializer
private static method onInit takes nothing returns nothing
local trigger t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction ( t, function squad.onUnitDeath )
set t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_LOADED )
call TriggerAddAction ( t, function squad.onUnitLoad )
set t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_SELECTED )
call TriggerAddCondition ( t, Condition ( function squad.onUnitSelect ) )
set t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddCondition ( t, Condition ( function squad.onItemPickup ) )
set ItemTrig1 = t
set t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_DROP_ITEM )
call TriggerAddCondition ( t, Condition ( function squad.onItemDropped ) )
set ItemTrig2 = t
set t = CreateTrigger ( )
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_USE_ITEM )
call TriggerAddCondition ( t, Condition ( function squad.onItemUsed ) )
set ItemTrig3 = t
call TriggerRegisterAnyUnitEventBJ ( OrderTrig, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerRegisterAnyUnitEventBJ ( OrderTrig, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ ( OrderTrig, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerAddCondition ( OrderTrig, Condition ( function squad.onUnitOrder ) )
endmethod
endstruct
endlibrary
//TESH.scrollpos=12
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SkeletonWarriorSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'u000' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 8.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=7
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SkeletonArcherSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n000' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 8.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=9
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SkeletonDeathKnightSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'u002' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 14.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=7
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SkeletalBatSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'u003' // This squad's unit type
private constant integer SQUAD_SIZE = 8 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 8.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=7
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope BoneHorrorSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'u004' // This squad's unit type
private constant integer SQUAD_SIZE = 3 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 5.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=4
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope BoneHorrorBurrowedSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'u00G' // This squad's unit type
private constant integer SQUAD_SIZE = 3 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00K' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 30.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Undead\\RaiseSkeletonWarrior\\RaiseSkeleton.mdl"
private constant boolean STARTUP_CLEAN = true // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=5
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope ConscriptionSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h00E' // This squad's unit type
private constant integer SQUAD_SIZE = 8 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 12.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope MilitiaBowmanSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n001' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 12.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=0
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope MilitiaFootmanSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h000' // This squad's unit type
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = true // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 12.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
local integer size = udg_Conscription[GetPlayerId(GetOwningPlayer(e)) + 1]
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= size
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= size
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=9
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope MilitiaCavalrySquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n002' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 18.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=9
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope ManAtArmsSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h001' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 12.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=12
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope TemplarSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h003' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 22.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=12
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope PegasusRiderSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h002' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 22.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope MageSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'h005' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B00J' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 15.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope WolfSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n005' // This squad's unit type
private constant integer SQUAD_SIZE = 6 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 10.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope WereWolfSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n006' // This squad's unit type
private constant integer SQUAD_SIZE = 4 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 10.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SpiderSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n007' // This squad's unit type
private constant integer SQUAD_SIZE = 8 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 10.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=6
//TESH.alwaysfold=0
// ========================================================
// Dummy script for dummies
//
// For each new squad type, copy this trigger,
// rename the scope name and change the constant variables
// ========================================================
// __________
scope SpittingSpiderSquad initializer init
// ^^^^^^^^^^
// scope name
globals
// Configureable constants
private constant integer UNIT_TYPE_ID = 'n008' // This squad's unit type
private constant integer SQUAD_SIZE = 4 // Number of units in this squad, counting the leader. Cannot be above "MAX_SQUAD_SIZE" in the SquadSystem main script. Doing so WILL cause resurrection bugs.
private constant boolean INIT_SQUAD = true // Initialize pre-placed units into squads?
private constant boolean AUTO_CREATE = false // Automatically creates a squad when a unit of this type 'UNIT_TYPE_ID' enters the map.
private constant integer REGEN_BUFF_ID = 'B001' // Id of the regeneration buff. Leave 0 to disable regeneration
private constant real REGEN_RATE = 10.00 // How long it takes to regenerate a unit.
private constant string REGEN_EFFECT = "Abilities\\Spells\\Other\\Transmute\\PileofGold.mdl"
private constant boolean STARTUP_CLEAN = false // When true, this will wipe out all the squad members of the squad, leaving only the leader.
// End of configureable constants
private trigger trig=null
endglobals
private function Cond takes nothing returns boolean
return GetUnitTypeId ( GetTrainedUnit ( ) ) == UNIT_TYPE_ID
endfunction
private function Create takes unit e returns squad
local squad this = squad.create ( )
local integer i = 1
local unit u
call this.add ( e )
call DisableTrigger ( trig )
if STARTUP_CLEAN then
loop
set this.player [this.count] = GetPlayerId ( GetOwningPlayer ( e ) ) + 1
set this.deadId [this.count] = UNIT_TYPE_ID
set this.count = this.count + 1
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
else
loop
set u = CreateUnit ( Player ( GetPlayerId ( GetOwningPlayer ( e ) ) + 1 ), GetUnitTypeId ( e ), GetUnitX ( e ), GetUnitY ( e ), 270 )
//call SetUnitUseFood ( u, false )
call this.add ( u )
set i = i + 1
exitwhen i >= SQUAD_SIZE
endloop
endif
call EnableTrigger ( trig )
set u = null
return this
endfunction
private function Actions takes nothing returns nothing
local unit u = GetUnitRallyUnit ( GetTriggerUnit ( ) )
local location l = GetUnitRallyPoint ( GetTriggerUnit ( ) )
local squad this = Create ( GetTrainedUnit ( ) )
if u != null and u != GetTriggerUnit ( ) then
call this.issueTargetOrder ( 851986, u )
elseif l != null then
call this.issuePointOrder ( 851986, GetLocationX ( l ), GetLocationY ( l ) )
endif
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
call RemoveLocation ( l )
set l = null
set u = null
endfunction
private function InitSquads takes nothing returns boolean
local squad this
if GetUnitTypeId ( GetFilterUnit ( ) ) == UNIT_TYPE_ID then
set this = Create ( GetFilterUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
return false
endfunction
private function onMapEnter takes nothing returns nothing
local squad this
call TriggerSleepAction ( 0 )
if GetUnitTypeId ( GetTriggerUnit ( ) ) == UNIT_TYPE_ID and not IsUnitInSquad ( GetTriggerUnit ( ) ) then
set this = Create ( GetTriggerUnit ( ) )
if REGEN_BUFF_ID != 0 then
call this.setRegeneration ( REGEN_BUFF_ID, REGEN_RATE, REGEN_EFFECT )
endif
endif
endfunction
private function init takes nothing returns nothing
local trigger t = CreateTrigger( )
local region r
call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddCondition( t, Condition ( function Cond ) )
call TriggerAddAction( t, function Actions )
if INIT_SQUAD then
call GroupEnumUnitsInRect ( ENUM_GROUP, bj_mapInitialPlayableArea, Filter ( function InitSquads ) )
endif
if AUTO_CREATE then
set r = CreateRegion ( )
call RegionAddRect ( r, bj_mapInitialPlayableArea )
set trig = CreateTrigger ( )
call TriggerRegisterEnterRegion ( trig, r, null )
call TriggerAddAction ( trig, function onMapEnter )
endif
endfunction
endscope
//TESH.scrollpos=3
//TESH.alwaysfold=0
library BuffAbilityLink initializer init
globals
private constant real TICK = 0.50 // How ofter the system checks for buff-ability links
private group all = CreateGroup ( )
private rect map = null
private balink array Links
private integer LinkN = 0
endglobals
struct balink
integer buffId = 0
integer abilId = 0
static method create takes integer buffId, integer abilId returns thistype
local thistype this = thistype.allocate ( )
set this.buffId = buffId
set this.abilId = abilId
set Links [ LinkN ] = this
set LinkN = LinkN + 1
return this
endmethod
endstruct
private function Enumeration takes nothing returns boolean
local integer i = LinkN
local unit u = GetFilterUnit ( )
loop
set i = i - 1
exitwhen i < 0
if GetUnitAbilityLevel ( u, Links [ i ].buffId ) > 0 then
call UnitAddAbility ( u, Links [ i ].abilId )
else
call UnitRemoveAbility ( u, Links [ i ].abilId )
endif
endloop
set u = null
return false
endfunction
private function Iteration takes nothing returns nothing
call GroupEnumUnitsInRect ( all, map, Filter ( function Enumeration ) )
endfunction
private function init takes nothing returns nothing
set map = GetWorldBounds ( )
call TimerStart ( CreateTimer ( ), TICK, true, function Iteration )
endfunction
endlibrary