The[Knight] and K3T's Spawn System [1.1.0]
Trigger:
Custom Script:
Features:
I'd appreciate credits if used, but won't demand of it.
Also thanks to Ayanami for some bug assitance.
Trigger:
Trigger:
- ssVars
- Events
- Map initialization
- Conditions
- Actions
- -------- Spawn System [1.0.2] --------
- -------- popCap = Population limit for each player --------
- -------- playerCastleType = Unit type of the castles built by the player --------
- Set ss_popCap[1] = 50
- Set ss_playerCastleType[1] = Farm
- Set ss_popCap[2] = 50
- Set ss_playerCastleType[2] = No unit-type
- Set ss_popCap[3] = 50
- Set ss_playerCastleType[3] = No unit-type
- Set ss_popCap[4] = 50
- Set ss_playerCastleType[4] = No unit-type
- Set ss_popCap[5] = 50
- Set ss_playerCastleType[5] = No unit-type
- Set ss_popCap[6] = 50
- Set ss_playerCastleType[6] = No unit-type
- Set ss_popCap[7] = 50
- Set ss_playerCastleType[7] = No unit-type
- Set ss_popCap[8] = 50
- Set ss_playerCastleType[8] = No unit-type
- Set ss_popCap[9] = 50
- Set ss_playerCastleType[9] = No unit-type
- Set ss_popCap[10] = 50
- Set ss_playerCastleType[10] = No unit-type
- Set ss_popCap[11] = 50
- Set ss_playerCastleType[11] = No unit-type
- Set ss_popCap[12] = 50
- Set ss_playerCastleType[12] = No unit-type
- -------- Just in case you want it... --------
- Set ss_popCapsSharedWithTeam = False
- -------- Ability that disables spawns --------
- Set ss_disableSpawnAbility = Disable Spawn (Spawn System)
- -------- Ability that enables spawns --------
- Set ss_enableSpawnAbility = Enable Spawn (Spawn System)
- -------- DO NOT EDIT ANYTHING OUTSIDE OF THE BRACKETS < > </ > --------
- -------- <Spawn> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- -------- <Each Spawn Must Start With This> --------
- -------- True if you want people to be able to turn on/off their spawn. Good for population control --------
- Set ss_spawnEnableDisableFuncOn[ss_spawnCount] = True
- -------- Just incase you don't want it to be on as default --------
- Set ss_spawnEnabled[ss_spawnCount] = True
- -------- Rally functions - If a Rally Marker is set, the units will follow it --------
- Set ss_spawnBuildingRallyFuncOn[ss_spawnCount] = True
- -------- True if you want to show the floating text --------
- Set ss_spawnShowFloatingText[ss_spawnCount] = True
- -------- True if you want the map to ping each spawn --------
- Set ss_spawnPingEachSpawn[ss_spawnCount] = True
- -------- True if you want the base to be spell immune --------
- Set ss_spawnBuildingMagicImmune[ss_spawnCount] = True
- -------- Where units spawn at --------
- Set ss_spawnInThisRegion[ss_spawnCount] = SpawnRegion <gen>
- -------- True if you want units to spawn in random points in the region, false if you want them in the center --------
- Set ss_spawnWhere[ss_spawnCount] = False
- -------- Spawn base - this unit must be alive for units to spawn --------
- Set ss_spawnBase[ss_spawnCount] = Castle 0010 <gen>
- -------- True if this spawn base can be captured. If you do this, be sure to set the playerCastleType for anyone who might capture this, so their units spawn --------
- Set ss_spawnCaptureable[ss_spawnCount] = True
- -------- Unit Type of Castles (Units that determine the spawn level) --------
- Set ss_spawnCastleUnitType[ss_spawnCount] = Farm
- -------- Which way the units face after they're created --------
- Set ss_spawnUnitFacingDegrees[ss_spawnCount] = 0.00
- -------- Spawns every __ seconds --------
- Set ss_spawnSpawnEveryThisManySec[ss_spawnCount] = 10
- -------- This is the max number of castles that each spawn will require --------
- Set ss_spawnMaxCastles[ss_spawnCount] = 5
- -------- SPAWNS DO NOT STACK --------
- -------- <Spawn Set> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- Set ss_rectSpawnID[ss_rectCount] = ss_spawnCount
- -------- <Each Castle Level For Each Spawn Must Start With This> --------
- -------- How many castles must exist for this spawn. Note: Each Spawn Set must require at least 1 castle, maximum of 9 castles, nothing more, and nothing less than 1 --------
- Set ss_rectCastleRequirements[ss_rectCount] = 1
- -------- The units that will be spawned - you must have them in the region before the game starts --------
- Set ss_rectSpawnRect[ss_rectCount] = Spawn1 <gen>
- -------- </Each Castle Level For Each Spawn Must End With This> --------
- Set ss_rectCount = (ss_rectCount + 1)
- Else - Actions
- If - Conditions
- -------- </Spawn Set> --------
- -------- <Spawn Set> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- Set ss_rectSpawnID[ss_rectCount] = ss_spawnCount
- -------- <Each Castle Level For Each Spawn Must Start With This> --------
- Set ss_rectCastleRequirements[ss_rectCount] = 2
- Set ss_rectSpawnRect[ss_rectCount] = Spawn2 <gen>
- -------- </Each Castle Level For Each Spawn Must End With This> --------
- Set ss_rectCount = (ss_rectCount + 1)
- Else - Actions
- If - Conditions
- -------- </Spawn Set> --------
- -------- <Spawn Set> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- Set ss_rectSpawnID[ss_rectCount] = ss_spawnCount
- -------- <Each Castle Level For Each Spawn Must Start With This> --------
- Set ss_rectCastleRequirements[ss_rectCount] = 3
- Set ss_rectSpawnRect[ss_rectCount] = Spawn3 <gen>
- -------- </Each Castle Level For Each Spawn Must End With This> --------
- Set ss_rectCount = (ss_rectCount + 1)
- Else - Actions
- If - Conditions
- -------- </Spawn Set> --------
- -------- <Spawn Set> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- Set ss_rectSpawnID[ss_rectCount] = ss_spawnCount
- -------- <Each Castle Level For Each Spawn Must Start With This> --------
- Set ss_rectCastleRequirements[ss_rectCount] = 4
- Set ss_rectSpawnRect[ss_rectCount] = Spawn4 <gen>
- -------- </Each Castle Level For Each Spawn Must End With This> --------
- Set ss_rectCount = (ss_rectCount + 1)
- Else - Actions
- If - Conditions
- -------- </Spawn Set> --------
- -------- <Spawn Set> --------
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- True Equal to True
- Then - Actions
- Set ss_rectSpawnID[ss_rectCount] = ss_spawnCount
- -------- <Each Castle Level For Each Spawn Must Start With This> --------
- Set ss_rectCastleRequirements[ss_rectCount] = 5
- Set ss_rectSpawnRect[ss_rectCount] = Spawn5 <gen>
- -------- </Each Castle Level For Each Spawn Must End With This> --------
- Set ss_rectCount = (ss_rectCount + 1)
- Else - Actions
- If - Conditions
- -------- <Spawn Set> --------
- -------- </Each Spawn Must End With This> --------
- Set ss_spawnCount = (ss_spawnCount + 1)
- Else - Actions
- If - Conditions
- -------- </Spawn> --------
- -------- FYI - Once you call the setupSpawnSystem function, this trigger will be destroyed --------
- Custom script: call setupSpawnSystem()
- Events
Custom Script:
JASS:
library spawnSystem // [1.0.2]
globals
trigger eventEverySecond = CreateTrigger()
trigger eventBaseAttacked = CreateTrigger()
trigger eventBeginSpellCast = CreateTrigger()
integer udg_ss_loopA = 0
integer udg_ss_loopB = 0
integer udg_ss_intUnitTypes = 0
integer udg_ss_strA = 0
integer udg_ss_strB = 0
integer array udg_ss_pop
integer array udg_ss_spawnSpawnEveryThisManySecTemp
integer array udg_ss_unitTypes
string udg_ss_txtGrabFrom = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
string array udg_ss_unitTypeID
string array udg_ss_spawnSpawnStringA
string array udg_ss_spawnSpawnStringB
string array udg_ss_strCount
texttag array udg_ss_spawnFT
endglobals
function eventBeginSpellCast_Actions takes nothing returns nothing
local boolean found = false
local unit u = GetTriggerUnit()
if(GetSpellAbilityId() == udg_ss_enableSpawnAbility)then
call UnitRemoveAbility(u, udg_ss_enableSpawnAbility)
call UnitAddAbility(u, udg_ss_disableSpawnAbility)
set udg_ss_loopA = 0
loop
if(udg_ss_spawnBase[udg_ss_loopA] == u)then
set found = true
set udg_ss_spawnEnabled[udg_ss_loopA] = true
endif
set udg_ss_loopA = udg_ss_loopA + 1
exitwhen udg_ss_loopA == udg_ss_spawnCount+1 or found == true
endloop
else
if(GetSpellAbilityId() == udg_ss_disableSpawnAbility)then
call UnitRemoveAbility(u, udg_ss_disableSpawnAbility)
call UnitAddAbility(u, udg_ss_enableSpawnAbility)
set udg_ss_loopA = 0
loop
if(udg_ss_spawnBase[udg_ss_loopA] == u)then
set found = true
set udg_ss_spawnEnabled[udg_ss_loopA] = false
endif
set udg_ss_loopA = udg_ss_loopA + 1
exitwhen udg_ss_loopA == udg_ss_spawnCount+1 or found == true
endloop
endif
endif
set u = null
endfunction
function eventBaseAttacked_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
if(GetUnitState(u, UNIT_STATE_LIFE)/GetUnitState(u, UNIT_STATE_MAX_LIFE)*100 < 35)then
set udg_ss_spawnCastleUnitType[udg_ss_loopA] = udg_ss_playerCastleType[GetPlayerId(GetOwningPlayer(GetAttacker()))+1]
call SetUnitOwner(u, GetOwningPlayer(GetAttacker()), true)
call SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
call IssueTargetOrder(u, "setrally", u)
endif
set u = null
endfunction
function setupEachUnitType takes nothing returns nothing
local unit u = GetEnumUnit()
local integer ut = GetUnitTypeId(u)
local boolean found = false
set udg_ss_loopB = 0
loop
exitwhen udg_ss_loopB > udg_ss_intUnitTypes or found == true
if(ut == udg_ss_unitTypes[udg_ss_loopB]) then
set found = true
else
set udg_ss_loopB = udg_ss_loopB + 1
endif
endloop
if(found == false) then
set udg_ss_unitTypes[udg_ss_intUnitTypes] = ut
set udg_ss_unitTypeID[udg_ss_intUnitTypes] = SubString(udg_ss_txtGrabFrom, udg_ss_strA, udg_ss_strA+1) + SubString(udg_ss_txtGrabFrom, udg_ss_strB, udg_ss_strB+1)
set udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] + SubString(udg_ss_txtGrabFrom, udg_ss_strA, udg_ss_strA+1)
set udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] + SubString(udg_ss_txtGrabFrom, udg_ss_strB, udg_ss_strB+1)
if(udg_ss_strB == StringLength(udg_ss_txtGrabFrom)-1)then
set udg_ss_strB = 0
set udg_ss_strA = udg_ss_strA + 1
else
set udg_ss_strB = udg_ss_strB + 1
endif
set udg_ss_intUnitTypes = udg_ss_intUnitTypes + 1
else
set udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] + SubString(udg_ss_unitTypeID[udg_ss_loopB], 0, 1)
set udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] + SubString(udg_ss_unitTypeID[udg_ss_loopB], 1, 2)
endif
call RemoveUnit(u)
set u = null
endfunction
function findNumber takes integer cc, integer strA, integer strB returns integer
local integer x = 0
local boolean found = false
set udg_ss_loopB = 0
loop
exitwhen udg_ss_loopB > StringLength(udg_ss_spawnSpawnStringA[udg_ss_loopA])-1 or found == true
set x = S2I(SubString(udg_ss_spawnSpawnStringA[udg_ss_loopA], strA, strB))
if(x > 0 and x <= 9)then
set found = true
endif
set udg_ss_loopB = udg_ss_loopB + 1
endloop
if(cc == x or x == udg_ss_spawnMaxCastles[udg_ss_loopA])then
return strB
endif
return findNumber(cc, strA+1, strB+1)
endfunction
function moveUnitsAfterRally takes group ug returns nothing
if(GetUnitRallyUnit(udg_ss_spawnBase[udg_ss_loopA]) == null)then
call GroupPointOrderLoc(ug, "attack", GetUnitRallyPoint(udg_ss_spawnBase[udg_ss_loopA]))
else
if(not(GetUnitRallyUnit(udg_ss_spawnBase[udg_ss_loopA]) == udg_ss_spawnBase[udg_ss_loopA]))then
call GroupTargetOrder(ug, "move", GetUnitRallyUnit(udg_ss_spawnBase[udg_ss_loopA]))
endif
endif
endfunction
function eventEverySecond_Actions takes nothing returns nothing
local group ug = CreateGroup()
local player plyr = null
local boolean found = false
local integer ugc = 0
local real y = 0
local real x = 0
local integer index = 0
set udg_ss_loopA = 0
loop
exitwhen udg_ss_loopA > udg_ss_spawnCount-1
if(GetUnitState(udg_ss_spawnBase[udg_ss_loopA], UNIT_STATE_LIFE) > 0 and udg_ss_spawnEnabled[udg_ss_loopA] == true)then
set plyr = GetOwningPlayer(udg_ss_spawnBase[udg_ss_loopA])
set udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA] = udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA] - 1
if(udg_ss_spawnShowFloatingText[udg_ss_loopA] == true)then
call ShowTextTagForceBJ(false, udg_ss_spawnFT[udg_ss_loopA], GetPlayersAll())
if(GetLocalPlayer() == plyr)then
call SetTextTagVisibility(udg_ss_spawnFT[udg_ss_loopA], true)
endif
call SetTextTagText(udg_ss_spawnFT[udg_ss_loopA], udg_ss_strCount[udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA]], 8*0.023 / 10)
endif
if(udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA] == 0) then
set udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA] = udg_ss_spawnSpawnEveryThisManySec[udg_ss_loopA]
set index = findNumber(CountLivingPlayerUnitsOfTypeId(udg_ss_spawnCastleUnitType[udg_ss_loopA], plyr), 0, 1)
loop
set found = false
if(udg_ss_popCapsSharedWithTeam == true)then
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
set udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] = 0
exitwhen udg_ss_loopB == 12
endloop
endif
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
if(udg_ss_popCapsSharedWithTeam == false) then
set udg_ss_pop[udg_ss_loopB] = GetPlayerUnitCount(Player(udg_ss_loopB-1), false)
else
set udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] = udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] + GetPlayerUnitCount(Player(udg_ss_loopB-1), false)
endif
exitwhen udg_ss_loopB == 12
endloop
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
if(udg_ss_popCapsSharedWithTeam == false) then
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_USED, udg_ss_pop[udg_ss_loopB])
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_ss_popCap[udg_ss_loopB])
else
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_USED, udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))])
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_ss_popCap[1+GetPlayerTeam(Player(udg_ss_loopB-1))])
endif
exitwhen udg_ss_loopB == 12
endloop
if(udg_ss_popCapsSharedWithTeam == false) then
if(udg_ss_pop[1+GetPlayerId(plyr)] >= udg_ss_popCap[1+GetPlayerId(plyr)]) then
set found = true
call SetTextTagText(udg_ss_spawnFT[udg_ss_loopA], "At Pop Limit", 8*0.023 / 10)
endif
else
if(udg_ss_pop[1+GetPlayerTeam(plyr)] >= udg_ss_popCap[1+GetPlayerTeam(plyr)]) then
set found = true
call SetTextTagText(udg_ss_spawnFT[udg_ss_loopA], "At Pop Limit", 8*0.023 / 10)
endif
endif
if(found == false) then
set udg_ss_loopB = 0
loop
exitwhen found == true or udg_ss_loopB > udg_ss_intUnitTypes
if(udg_ss_unitTypeID[udg_ss_loopB] == SubString(udg_ss_spawnSpawnStringA[udg_ss_loopA], index, index+1) + SubString(udg_ss_spawnSpawnStringB[udg_ss_loopA], index, index+1))then
set found = true
else
set udg_ss_loopB = udg_ss_loopB + 1
endif
endloop
set found = false
if(udg_ss_spawnWhere[udg_ss_loopA] == true)then
set x = GetRandomReal(GetRectMinX(udg_ss_spawnInThisRegion[udg_ss_loopA]), GetRectMaxX(udg_ss_spawnInThisRegion[udg_ss_loopA]))
set y = GetRandomReal(GetRectMinY(udg_ss_spawnInThisRegion[udg_ss_loopA]), GetRectMaxY(udg_ss_spawnInThisRegion[udg_ss_loopA]))
else
set x = GetRectCenterX(udg_ss_spawnInThisRegion[udg_ss_loopA])
set y = GetRectCenterY(udg_ss_spawnInThisRegion[udg_ss_loopA])
endif
if(udg_ss_spawnBuildingRallyFuncOn[udg_ss_loopA] == true)then
call GroupAddUnit(ug, CreateUnit(plyr, udg_ss_unitTypes[udg_ss_loopB], x, y, udg_ss_spawnUnitFacingDegrees[udg_ss_loopA]))
set ugc = ugc+1
if(ugc == 12)then
call moveUnitsAfterRally(ug)
set ugc = 0
call GroupClear(ug)
endif
else
set bj_lastCreatedUnit = CreateUnit(plyr, udg_ss_unitTypes[udg_ss_loopB], x, y, udg_ss_spawnUnitFacingDegrees[udg_ss_loopA])
endif
if(udg_ss_spawnPingEachSpawn[udg_ss_loopA] == true) then
if (GetLocalPlayer() == plyr) then
call PingMinimap(x, y, 0.5)
endif
endif
set index = index+1
endif
exitwhen( not (S2I(SubString(udg_ss_spawnSpawnStringA[udg_ss_loopA], index, index+1)) == 0) or found == true)
endloop
if(not (ugc == 0))then
call moveUnitsAfterRally(ug)
set ugc = 0
call GroupClear(ug)
endif
endif
endif
set udg_ss_loopA = udg_ss_loopA + 1
endloop
if(udg_ss_popCapsSharedWithTeam == true)then
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
set udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] = 0
exitwhen udg_ss_loopB == 12
endloop
endif
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
if(udg_ss_popCapsSharedWithTeam == false) then
set udg_ss_pop[udg_ss_loopB] = GetPlayerUnitCount(Player(udg_ss_loopB-1), false)
else
set udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] = udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))] + GetPlayerUnitCount(Player(udg_ss_loopB-1), false)
endif
exitwhen udg_ss_loopB == 12
endloop
set udg_ss_loopB = 0
loop
set udg_ss_loopB = udg_ss_loopB + 1
if(udg_ss_popCapsSharedWithTeam == false) then
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_USED, udg_ss_pop[udg_ss_loopB])
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_ss_popCap[udg_ss_loopB])
else
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_USED, udg_ss_pop[1+GetPlayerTeam(Player(udg_ss_loopB-1))])
call SetPlayerState(Player(udg_ss_loopB-1), PLAYER_STATE_RESOURCE_FOOD_CAP, udg_ss_popCap[1+GetPlayerTeam(Player(udg_ss_loopB-1))])
endif
exitwhen udg_ss_loopB == 12
endloop
call DestroyGroup(ug)
set ug = null
set plyr = null
endfunction
function setupSpawnSystem takes nothing returns nothing
local group ug = null
local real x = 0
local real y = 0
local player plyr
local integer array z
set udg_ss_loopA = 0
call DestroyTrigger(gg_trg_ssVars)
loop
exitwhen udg_ss_loopA > udg_ss_rectCount-1
set ug = CreateGroup()
call GroupEnumUnitsInRect(ug, udg_ss_rectSpawnRect[udg_ss_loopA], null)
set udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringA[udg_ss_rectSpawnID[udg_ss_loopA]] + I2S(udg_ss_rectCastleRequirements[udg_ss_loopA])
set udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] = udg_ss_spawnSpawnStringB[udg_ss_rectSpawnID[udg_ss_loopA]] + I2S(udg_ss_rectCastleRequirements[udg_ss_loopA])
call ForGroup(ug , function setupEachUnitType )
call DestroyGroup(ug)
set ug = null
call RemoveRect(udg_ss_rectSpawnRect[udg_ss_loopA])
set udg_ss_loopA = udg_ss_loopA + 1
endloop
set udg_ss_loopA = 0
loop
set plyr = GetOwningPlayer(udg_ss_spawnBase[udg_ss_loopA])
set x = GetRectCenterX(udg_ss_spawnInThisRegion[udg_ss_loopA])
set y = GetRectCenterY(udg_ss_spawnInThisRegion[udg_ss_loopA])
if(udg_ss_spawnBuildingRallyFuncOn[udg_ss_loopA] == true) then
call UnitAddAbility(udg_ss_spawnBase[udg_ss_loopA], 039;ARal039; )
call IssueTargetOrder(udg_ss_spawnBase[udg_ss_loopA], "setrally", udg_ss_spawnBase[udg_ss_loopA])
endif
if(udg_ss_spawnCaptureable[udg_ss_loopA] == true) then
call TriggerRegisterUnitEvent( eventBaseAttacked, udg_ss_spawnBase[udg_ss_loopA], EVENT_UNIT_ATTACKED )
endif
if(udg_ss_spawnBuildingMagicImmune[udg_ss_loopA] == true) then
call UnitAddAbility(udg_ss_spawnBase[udg_ss_loopA], 039;ACmi039;)
endif
if(udg_ss_spawnShowFloatingText[udg_ss_loopA] == true) then
set udg_ss_spawnFT[udg_ss_loopA] = CreateTextTag()
call SetTextTagText(udg_ss_spawnFT[udg_ss_loopA], " ", 8 * 0.023 / 10)
call SetTextTagPos(udg_ss_spawnFT[udg_ss_loopA], x, y, 0)
call SetTextTagColor(udg_ss_spawnFT[udg_ss_loopA], 255, 255, 255, 0)
endif
if(udg_ss_spawnEnableDisableFuncOn[udg_ss_loopA] == true)then
call TriggerRegisterUnitEvent( eventBeginSpellCast, udg_ss_spawnBase[udg_ss_loopA], EVENT_UNIT_SPELL_CAST )
if(udg_ss_spawnEnabled[udg_ss_loopA] == true)then
call UnitAddAbility(udg_ss_spawnBase[udg_ss_loopA], udg_ss_disableSpawnAbility)
else
call UnitRemoveAbility(udg_ss_spawnBase[udg_ss_loopA], udg_ss_enableSpawnAbility)
endif
endif
set udg_ss_spawnSpawnEveryThisManySecTemp[udg_ss_loopA] = udg_ss_spawnSpawnEveryThisManySec[udg_ss_loopA]
set udg_ss_loopA = udg_ss_loopA + 1
exitwhen udg_ss_loopA > udg_ss_spawnCount-1
endloop
if(udg_ss_popCapsSharedWithTeam == true) then
set udg_ss_loopA = 0
loop
set udg_ss_loopA = udg_ss_loopA + 1
set z[udg_ss_loopA] = udg_ss_popCap[udg_ss_loopA]
set udg_ss_popCap[udg_ss_loopA] = 0
exitwhen udg_ss_loopA == 12
endloop
set udg_ss_loopA = 0
loop
set udg_ss_loopA = udg_ss_loopA + 1
set udg_ss_popCap[1+GetPlayerTeam(Player(udg_ss_loopA-1))] = udg_ss_popCap[1+GetPlayerTeam(Player(udg_ss_loopA-1))] + z[udg_ss_loopA]
exitwhen udg_ss_loopA == 12
endloop
endif
set udg_ss_loopA = 0
set udg_ss_loopB = 0
loop
if(udg_ss_spawnShowFloatingText[udg_ss_loopA] == true and udg_ss_spawnSpawnEveryThisManySec[udg_ss_loopA] > udg_ss_loopB)then
set udg_ss_loopB = udg_ss_spawnSpawnEveryThisManySec[udg_ss_loopA]
endif
set udg_ss_loopA = udg_ss_loopA + 1
exitwhen udg_ss_loopA == udg_ss_spawnCount
endloop
set udg_ss_loopA = 0
set udg_ss_strCount[0] = "Spawning"
loop
set udg_ss_loopA = udg_ss_loopA + 1
set udg_ss_strCount[udg_ss_loopA] = I2S(udg_ss_loopA)
exitwhen udg_ss_loopA == udg_ss_loopB
endloop
call TriggerRegisterTimerEvent( eventEverySecond, 1.00, true )
call TriggerAddAction( eventEverySecond, function eventEverySecond_Actions )
set plyr = null
call TriggerAddAction( eventBaseAttacked, function eventBaseAttacked_Actions )
call TriggerAddAction( eventBeginSpellCast, function eventBeginSpellCast_Actions )
endfunction
endlibrary
Features:
-Spawns units at periodic rates, leaklessly
-Created for maps that use Spawns corresponding to bases
-Sends spawned units to a Rally Point, if used
-Can add magic immunity to the base unit
-Sets a population cap for Player, or for Team
-You can Enable/Disable spawns using the corresponding base
-Includes floating text that displays the Spawn Countdown
-Extremely simple set up, all directions included
-Does not require any knowledge of Jass, does require NewGen & Helper
-Created for maps that use Spawns corresponding to bases
-Sends spawned units to a Rally Point, if used
-Can add magic immunity to the base unit
-Sets a population cap for Player, or for Team
-You can Enable/Disable spawns using the corresponding base
-Includes floating text that displays the Spawn Countdown
-Extremely simple set up, all directions included
-Does not require any knowledge of Jass, does require NewGen & Helper
I'd appreciate credits if used, but won't demand of it.
Also thanks to Ayanami for some bug assitance.