System Spawn System

TheKnight

New Member
Reaction score
1
The[Knight] and K3T's Spawn System [1.1.0]

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
          • -------- </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
          • -------- </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
          • -------- </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
          • -------- </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
          • -------- <Spawn Set> --------
          • -------- </Each Spawn Must End With This> --------
          • Set ss_spawnCount = (ss_spawnCount + 1)
        • Else - Actions
      • -------- </Spawn> --------
      • -------- FYI - Once you call the setupSpawnSystem function, this trigger will be destroyed --------
      • Custom script: call setupSpawnSystem()

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], 'ARal' )
                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], 'ACmi')
            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

I'd appreciate credits if used, but won't demand of it.
Also thanks to Ayanami for some bug assitance.
 

Attachments

  • SpawnSystem[1.1.0].w3x
    40.7 KB · Views: 296

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
First of all, fix your code's readability first.
Second, cover your code.
Third, update the post at here.
 

TheKnight

New Member
Reaction score
1
I'm gonna be completely honest, I have no idea how to Cover or fix the code's readability.
I did not do the code, K3T did, and he has quit now and I talk to him about once a month so he's not going to be of much help.
I've no knowledge of them either, but if youd care to point me in the right direction or get me started, I'll try and do it
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top