• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Operation Limit?

Level 9
Joined
May 12, 2018
Messages
145
Hi, first of all, I don't know exactly about Operation Limit,
I am managing all events and their conditions in one trigger.
I did this because I've been pointed out about a problem that triggers with the same event are triggered at the same time.

JASS:
library iemdeathevent requires pathfinderfuse, treantlv5, goakdeath, w2raisedead, goblinlandmine, snaringtrap, vesselforsoul, vesselforsoulraise, forgesitedevastator, forgesiteinfernal, forgesitesoulrender, trolllumbermill
    globals
        trigger IEMDeathEvent
        private constant integer FOOD_MAX = 200
    endglobals
    
    private function IEMDeathEventChecker takes nothing returns boolean
        local boolean isLocust = true == (GetUnitAbilityLevel(udg_UDexUnits[udg_UDex], 'Aloc') >= 1)
        local unit target
        local unit source
        local integer utytarget
        local integer utysource
        local player ownersource
        local player ownertarget
        local integer size = 0
        local integer sizeB = 0
        local integer sizeC = 0
        local boolean isIllusion
        local boolean isSummoned
        local boolean isHero
        local boolean isAncient
        local boolean isMechanical
        local boolean isStructure
        local boolean isWardAir
        local boolean isNonCorpseUnit
        local integer t_shadowranger_x
        local VesselForSoul vfs
        local VesselForSoulRaise vfsr
        local ForgeSiteDevastator fsd
        local ForgeSiteInfernal fsi
        local ForgeSiteSoulrender fsr
        
        if not isLocust then
            set target = udg_UDexUnits[udg_UDex]
            set source = udg_KillerOfUnit[udg_UDex]
            set utytarget = udg_UnitTypeOf[udg_UDex]
            set utysource = GetUnitTypeId(source)
            set ownersource = GetOwningPlayer(source)
            set ownertarget = GetOwningPlayer(target)
            set isIllusion = true == IsUnitIllusion(target)
            set isSummoned = true == IsUnitType(target, UNIT_TYPE_SUMMONED)
            set isHero = true == IsUnitType(target, UNIT_TYPE_HERO)
            set isAncient = true == IsUnitType(target, UNIT_TYPE_ANCIENT)
            set isMechanical = true == IsUnitType(target, UNIT_TYPE_MECHANICAL)
            set isStructure = true == IsUnitType(target, UNIT_TYPE_STRUCTURE)
            set isWardAir = true == IsUnitInGroup(target, udg_WardAirStructure)
            set isNonCorpseUnit = true == IsUnitInGroup(target, udg_NonCorpseUnits)
            set vfs = VesselForSoul.struct[udg_UDex]
            set vfsr = VesselForSoulRaise.struct[udg_UDex]
            
            if VesselForSoul.struct[udg_UDex] != 0 and not isIllusion and not udg_IsUnitReincarnating[udg_UDex] and not isHero and not isSummoned then
                call VesselForSoulRaise.create(ownertarget, target)
            endif
            if VesselForSoulRaise.struct[udg_UDex] != 0 then
                call vfsr.destroy()
            endif

            if utytarget == UNIT_BLOODELF_HAWKRIDER and isIllusion and GetPlayerTechCount(ownertarget, UPG_BLOODELF_TRAIN_HAWK, true) >= 1 then
                call PathfinderFuse(ownertarget,target)
            elseif utytarget == 'e00D' and not isIllusion then
                call TreantLv5(target)
            elseif (utytarget == 'H000' or utytarget == 'H00J') and not isIllusion then
                call GoAKDeath(target)
            elseif source != null and GetPlayerTechCount(ownersource, UPG_OLDHORDE_RAISEDEAD, true) >= 1 and GetPlayerState(ownersource, PLAYER_STATE_RESOURCE_FOOD_USED) + GetUnitFoodUsed(target) < FOOD_MAX and not isNonCorpseUnit and not isIllusion and not isHero and not isAncient and not isSummoned and not isMechanical and not isWardAir and not udg_IsUnitReincarnating[udg_UDex] then
                if utysource == UNIT_OLDHORDE_WARLOCK or utysource == UNIT_OLDHORDE_WARLOCK_ALT or utysource == UNIT_OLDHORDE_DEATHKNIGHT or utysource == UNIT_FELBORN_WARLOCK or utysource == UNIT_FELBORN_WARLOCK_ALT or utysource == UNIT_FELBORN_DEATHKNIGHT then
                    call W2RaiseDead.create(ownersource,utytarget,target)
                elseif utysource == UNIT_OLDHORDE_FELHOUND or utysource == UNIT_OLDHORDE_FELGUARD or utysource == UNIT_OLDHORDE_SUCCUBUS or utysource == UNIT_OLDHORDE_VOIDWALKER or utysource == UNIT_OLDHORDE_DOOMGUARD then
                    call W2RaiseDead.create(ownersource,utytarget,target)
                elseif utysource == UNIT_FELBORN_FELHOUND or utysource == UNIT_FELBORN_FELGUARD or utysource == UNIT_FELBORN_SUCCUBUS or utysource == UNIT_FELBORN_VOIDWALKER or utysource == UNIT_FELBORN_DOOMGUARD then
                    call W2RaiseDead.create(ownersource,utytarget,target)
                endif
            elseif utytarget == UNIT_OLDHORDE_GOBLINLANDMINE and not isIllusion and not udg_IsUnitReincarnating[udg_UDex] and source == null then
                call GoblinLandMine(ownertarget,target)
            elseif utytarget == SUMMON_DREAMWALKER_SNARINGTRAP and not isIllusion and not udg_IsUnitReincarnating[udg_UDex] and source == null then
                call SnaringTrap(ownertarget,target)
            elseif utytarget == BUILD_DEMON_FORGE_DEVASTATOR then
                set fsd = ForgeSiteDevastator.struct[udg_UDex]
                call fsd.destroy()
            elseif utytarget == BUILD_DEMON_FORGE_INFERNAL then
                set fsi = ForgeSiteInfernal.struct[udg_UDex]
                call fsi.destroy()
            elseif utytarget == BUILD_DEMON_FORGE_SOULRENDER then
                set fsr = ForgeSiteSoulrender.struct[udg_UDex]
                call fsr.destroy()
            elseif utytarget == T_HERO_SHADOWRANGER_X_UNIT1 or utytarget == T_HERO_SHADOWRANGER_X_UNIT2 or utytarget == T_HERO_SHADOWRANGER_X_UNIT3 or utytarget == T_HERO_SHADOWRANGER_X_UNIT4 or utytarget == T_HERO_SHADOWRANGER_X_UNIT5 then
                set t_shadowranger_x = GetUnitAbilityLevel(target, T_HERO_SHADOWRANGER_X)
                if t_shadowranger_x >= 1 then
                    call THeroShadowRangerXDeath(ownertarget, target,t_shadowranger_x)
                endif
            elseif utytarget == BUILD_OLDHORDE_LUMBERMILL then
                call TrollLumberMillUpgradeReset(ownertarget)
            elseif utytarget == BUILD_UNDEAD_FARM or utytarget == BUILD_UNDEAD_FARMTOWER or utytarget == BUILD_UNDEAD_FARMTOWERFROST then
                call TUDBaseSupplyADeindex(ownertarget, target)
            elseif utytarget == BUILD_UNDEAD_HALL1 or utytarget == BUILD_UNDEAD_HALL2 or utytarget == BUILD_UNDEAD_HALL3 then
                call TUDBaseSupplyBDeindex(ownertarget, target)
            elseif utytarget == BUILD_CULT_FARM or utytarget == BUILD_CULT_FARM2 or utytarget == BUILD_CULT_FARM2TOWER then
                call TCTBaseSupplyADeindex(ownertarget, target)
            elseif utytarget == BUILD_CULT_HALL0 or utytarget == BUILD_CULT_HALL1 or utytarget == BUILD_CULT_HALL2 or utytarget == BUILD_CULT_HALL3 then
                call TCTBaseSupplyBDeindex(ownertarget, target)
            endif

            if not udg_IsUnitReincarnating[udg_UDex] then
                call GroupRemoveUnit(udg_NonCorpseUnits, target)
                call GroupRemoveUnit(udg_StatusResistanceUnits, target)
                call GroupRemoveUnit( udg_UnitGroupDamage[0] , target )
                if utytarget == UNIT_CULT_ZOMBIE or utytarget == UNIT_CULT_SKELETONWARRIOR or utytarget == UNIT_CULT_SKELETONARCHER or utytarget == UNIT_CULT_WORKERCULT or utytarget == UNIT_CULT_SKELETONMAGE then
                    if not isIllusion and not isSummoned then
                        call TCTUnitTier0A(ownertarget, target, utytarget)
                    endif
                endif
                if not isIllusion and not isMechanical and not isStructure and not isWardAir and not isSummoned and IsT_CT_UNIT_SPECT_A then
                    call TCultUnitSpectA(target)
                endif
                call GroupRemoveUnit(udg_SylvanasSecurityAcolytes, target)
                call GroupRemoveUnit(udg_SylvanasTownBUnitGroup, target)
                call GroupRemoveUnit(udg_P01Structures, target)
                call GroupRemoveUnit(udg_P05Structures, target)
                call GroupRemoveUnit(udg_P05HGMGroup, target)
                call GroupRemoveUnit(udg_P05WorkerGroup, target)
                call GroupRemoveUnit(udg_CaravanGuards1, target)
                call GroupRemoveUnit(udg_CaravanWagons1, target)
                call GroupRemoveUnit(udg_CaravanGuards2, target)
                call GroupRemoveUnit(udg_CaravanWagons2, target)
                call GroupRemoveUnit(udg_CaravanGuards3, target)
                call GroupRemoveUnit(udg_CaravanWagons3, target)
                call GroupRemoveUnit(udg_CaravanGuards4, target)
                call GroupRemoveUnit(udg_CaravanGuards4B, target)
                call GroupRemoveUnit(udg_CaravanWagons4, target)
                call GroupRemoveUnit(udg_CaravanGuards5, target)
                call GroupRemoveUnit(udg_CaravanGuards5B, target)
                call GroupRemoveUnit(udg_CaravanWagons5, target)
                call GroupRemoveUnit(udg_CaravanGuards6, target)
                call GroupRemoveUnit(udg_CaravanGuards6B, target)
                call GroupRemoveUnit(udg_CaravanWagons6, target)
                call GroupRemoveUnit(udg_P1Structures, target)
                if target == udg_SylvanasExpansionAcolyte then
                    set target = null
                elseif target == udg_P05BuildHGMWorker then
                    set udg_P05BuildHGMWorker = null
                endif
                if not udg_P01IsDead then
                    if ownertarget == Player(1) then
                        set size = BlzGroupGetSize(udg_P01Structures)
                        if size <= 0 then
                            set udg_P01IsDead = true
                            call CommandAI( Player(1), -1, 0 )
                        endif
                        set size = 0
                    endif
                endif
                if not udg_P05IsGone then
                    if ownertarget == Player(5) then
                        set size = BlzGroupGetSize(udg_P05Structures)
                        if size <= 0 then
                            set udg_P05IsGone = true
                            call CommandAI( Player(5), -1, 0 )
                        endif
                        set size = 0
                    endif
                endif
                if udg_GameIsStarted and not udg_IS_GAMEOVER then
                    if ownertarget == Player(0) then
                        set size = BlzGroupGetSize(udg_P1Structures)
                        if size <= 0 then
                            call TriggerExecute(gg_trg_P1Razed)
                        endif
                        set size = 0
                    endif
                endif
                if ownertarget == Player(2) then
                    if IsTriggerEnabled(gg_trg_Caravan1KeepMove) and udg_Caravan1SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons1)
                        if size <= 0 then
                            if not udg_Caravan1SaveBool then
                                set udg_Caravan1SaveBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                            endif
                            set sizeB = BlzGroupGetSize(udg_CaravanGuards1)
                            if sizeB <= 0 then
                                call DisableTrigger( gg_trg_Caravan1KeepMove )
                                call DisableTrigger( gg_trg_Caravan1Attacked )
                            endif
                            set sizeB = 0
                        endif
                        set size = 0
                    endif
                    if IsTriggerEnabled(gg_trg_Caravan2KeepMove) and udg_Caravan2SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons2)
                        if size <= 0 then
                            if not udg_Caravan2SaveBool then
                                set udg_Caravan2SaveBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                            endif
                            set sizeB = BlzGroupGetSize(udg_CaravanGuards2)
                            if sizeB <= 0 then
                                call DisableTrigger( gg_trg_Caravan2KeepMove )
                                call DisableTrigger( gg_trg_Caravan2Attacked )
                            endif
                            set sizeB = 0
                        endif
                        set size = 0
                    endif
                    if IsTriggerEnabled(gg_trg_Caravan3KeepMove) and udg_Caravan3SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons3)
                        if size <= 0 then
                            if not udg_Caravan3SaveBool then
                                set udg_Caravan3SaveBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                            endif
                            set sizeB = BlzGroupGetSize(udg_CaravanGuards3)
                            if sizeB <= 0 then
                                call DisableTrigger( gg_trg_Caravan3KeepMove )
                                call DisableTrigger( gg_trg_Caravan3Attacked )
                            endif
                            set sizeB = 0
                        endif
                        set size = 0
                    endif
                    if IsTriggerEnabled(gg_trg_Caravan4KeepMove) and udg_Caravan4SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons4)
                        if size <= 0 then
                            if not udg_Caravan4SaveBool then
                                set udg_Caravan4SaveBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                            endif
                            set sizeB = BlzGroupGetSize(udg_CaravanGuards4)
                            set sizeC = BlzGroupGetSize(udg_CaravanGuards4B)
                            if sizeB <= 0 and sizeC <= 0 then
                                call DisableTrigger( gg_trg_Caravan4KeepMove )
                                call DisableTrigger( gg_trg_Caravan4Attacked )
                            endif
                            set sizeB = 0
                            set sizeC = 0
                        endif
                        set size = 0
                    endif
                    if IsTriggerEnabled(gg_trg_Caravan5KeepMove) and udg_Caravan5SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons5)
                        if size <= 0 then
                            if not udg_Caravan5SaveBool then
                                set udg_Caravan5SaveBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                            endif
                            set sizeB = BlzGroupGetSize(udg_CaravanGuards5)
                            set sizeC = BlzGroupGetSize(udg_CaravanGuards5B)
                            if sizeB <= 0 and sizeC <= 0 then
                                call DisableTrigger( gg_trg_Caravan5KeepMove )
                                call DisableTrigger( gg_trg_Caravan5Attacked )
                            endif
                            set sizeB = 0
                            set sizeC = 0
                        endif
                        set size = 0
                    endif
                    if IsTriggerEnabled(gg_trg_Caravan6KeepMove) and udg_Caravan6SpawnDone then
                        set size = BlzGroupGetSize(udg_CaravanWagons6)
                        set sizeB = BlzGroupGetSize(udg_CaravanWagons5)
                        set sizeC = BlzGroupGetSize(udg_CaravanWagons4)
                        if size <= 0 and sizeB <= 0 and sizeC <= 0 and udg_CaravanLevel >= 6 then
                            if not udg_CaravanDestroyedBool then
                                set udg_CaravanDestroyedBool = true
                                call SaveGameCheckPointBJ( udg_S_MapTitle, true )
                                call ConditionalTriggerExecute( gg_trg_MainQuest0Completed )
                            endif
                        endif
                        set size = 0
                    endif
                    if udg_OptQuest01ConstOn then
                        if target == udg_OptQuest01Acolyte0 then
                            set udg_OptQuest01Acolyte0 = null
                            if udg_OptQuest01Crypt == null then
                                call ConditionalTriggerExecute( gg_trg_OptQuest01Fail )
                            endif
                        elseif target == udg_OptQuest01Acolyte1 then
                            set udg_OptQuest01Acolyte1 = null
                            if udg_OptQuest01Ziggurat == null then
                                
                            endif
                        elseif target == udg_OptQuest01Acolyte2 then
                            set udg_OptQuest01Acolyte2 = null
                            if udg_OptQuest01Graveyard == null then
                                call ConditionalTriggerExecute( gg_trg_OptQuest01Fail )
                            endif
                        elseif target == udg_OptQuest01Crypt then
                            set udg_OptQuest01Crypt = null
                            call ConditionalTriggerExecute( gg_trg_OptQuest01Fail )
                        elseif target == udg_OptQuest01Ziggurat then
                            set udg_OptQuest01FailedBoolZigdeath = true
                            set udg_OptQuest01Ziggurat = null
                        elseif target == udg_OptQuest01Graveyard then
                            set udg_OptQuest01Graveyard = null
                            call ConditionalTriggerExecute( gg_trg_OptQuest01Fail )
                        endif
                        if udg_OptQuest01Acolyte0 == null and udg_OptQuest01Acolyte1 == null and udg_OptQuest01Acolyte2 == null and udg_OptQuest01FailedBool then
                            set udg_OptQuest01ConstOn = false
                        endif
                    endif
                endif
            endif
        endif


        set ownertarget = null
        set ownersource = null
        set target = null
        set source = null
    
        return false
    endfunction
    
    public function onCreate takes nothing returns nothing
        set IEMDeathEvent = CreateTrigger()
        call TriggerRegisterVariableEvent( IEMDeathEvent, "udg_DeathEvent", EQUAL, 1.00 )
        call TriggerAddCondition( IEMDeathEvent, Condition( function IEMDeathEventChecker ) )
    endfunction
endlibrary

While testing the map, I saw a problem that certain actions weren't running, so I thought through the Operation Limit that I've seen before on Hive.
Do these long scripts reach Operation Limits easily?

What is the exact way to renew Operation Limit? If I create a new trigger with the same event, will it be resolved?
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
I am managing all events and their conditions in one trigger.
I personally think this is a terrible idea prone to developing other issues and can make troubleshooting/testing annoyingly difficult. You should not need to do this; a few dozen triggers firing and immediately getting filtered out by their conditions is not something you should ever worry about. That’s actually the point of conditions, in face, since they’re more than just an if block that gates the rest of the trigger.
triggers with the same event are triggered at the same time.
That is not correct. There is a trigger queue; all triggers with the same event are added to the queue and executed sequentially. Any new triggers triggered by any of these queued triggers’ actions will ‘gain priority’ and immediately begin execution until it finishes or is itself interrupted by something else. All interrupted triggers will resume execution in the opposite order the interruption occurred, like a stack.

I do not know what governs the initial order for triggers that share an event, but this should not usually be an issue you have to worry about.
Do these long scripts reach Operation Limits easily?
Not what you have shown there. OP limit is something you can reach only by abusing/misusing nested loops. It used to be about 30k operations but now it’s at least 300k or higher (someone corrected me on this speculation recently but I don’t remember who). You will never hit that doing stuff like this.
What is the exact way to renew Operation Limit? If I create a new trigger with the same event, will it be resolved?
Each trigger should be its own thread but that doesn’t really solve any issues here, since I don’t think you’re hitting it. You would manually start a new thread using ExecuteFunc() or the vJASS .execute() method. Running another trigger from within a first trigger does not start a new thread and won’t be the same thing.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I agree with what Pyro said, but I want to add one thing.

The "A unit Dies" Event breaks the rules of the trigger queue. So if for example you would kill a unit while a trigger is running:
  • TriggerA
    • Actions
      • Set TempPoint = (Center of RegionX)
      • Unit - Kill (Some unit)
      • Unit - Create 1 Footman at TempPoint
  • TriggerB
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Dying unit))
The final result of TriggerA running is this:
  • Actions
    • Set TempPoint = (Center of RegionX)
    • Unit - Kill (Some unit)
    • Set TempPoint = (Position of (Dying unit))
    • Unit - Create 1 Footman at TempPoint
This would cause the Footman to be created at the position of the dying unit rather than the center of RegionX as intended. Normally, you would expect TriggerB to be put on the trigger queue and execute later but for some reason this isn't the case for this particular Event.

But the solution is simple:
Use unique variables in any triggers that rely on this Event. If you're coding then you have easy access to local variables so this shouldn't be a problem.
 
Top