Loop Integer A Bug - Narrowed the bug but can't fix it

Kingdom

New Member
Reaction score
0
Hello.

My map has a multiboard and 19 heroes total, so far. Each hero has three tiers:
T1 = lv 1 to 10
T2 = lv 10 to 20
T3 = lv 20 to 30
Counting each tier, there's 57 heroes.

Now, i'm trying to do that for each tier, the hero's scorescreen icon on the multiboard is changed. If there's something i've learned from my map editing so far, is that variables makes EVERYTHING easier, so what i got on the map, is a "Set Variables" trigger that sets hero name, description, scorescreen icon, etc.

This is the set variables trigger, i edited it and filtered only the information i use on the trigger that switches the hero's icon on the Multiboard.
Code:
Set Variables
    Events
    Conditions
    Actions
        [B]Set Heroes_Number_of_Heroes = 19
        -------- Hero - Night Stalker --------
        Set Hero_Temp_ID = 1
        Set Hero_Name[Hero_Temp_ID] = Night Stalker
        Set Board_Hero_Icon_T1[Hero_Temp_ID] = ReplaceableTextures\CommandButtons\BTNArcher.blp
        Set Board_Hero_Icon_T2[Hero_Temp_ID] = ReplaceableTextures\CommandButtons\BTNSylvanusWindrunner.blp
        Set Board_Hero_Icon_T3[Hero_Temp_ID] = UI\Glues\ScoreScreen\scorescreen-hero-priestessofthemoon.blp[/B]
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Night Stalker <gen>
        Set Hero_T1[Hero_Temp_ID] = Night Stalker T1
        Set Hero_T2[Hero_Temp_ID] = Night Stalker T2
        Set Hero_T3[Hero_Temp_ID] = Night Stalker T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0058 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Ranged
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Agility
        Set Hero_Abilities[Hero_Temp_ID] = Arrow Barrage, Poison|n Arrow,Marksman Presence
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Warglaive Bearer --------
        ...
        ...
        Trigger - Turn off (This trigger)
The bold part of the text, is what isn't working. I mean, the icons itself are working, what's not working is this next code.


This is the code that makes the hero switch and changes it's icon on the scorescreen. I excluded the T2 evolve part cuz it won't matter for now.
Code:
Hero Evolve
    Events
        Unit - A unit Gains a level
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Hero level of (Triggering unit)) Equal to 10
                (Hero level of (Triggering unit)) Equal to 20
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero level of (Triggering unit)) Equal to 10
            Then - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                            Then - Actions
                                Unit - Pause (Triggering unit)
                                Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                                                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                                                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T2[(Integer A)]
                                        [B]Game - Display to (All players) the text: (String((Integer A)))[/B]
                                    Else - Actions
Everything on this trigger works, except the icon switch, that is below the "---- Team 1 ----" comment. Since the variable was correctly set on the "Set Variable" trigger, i figure the problem was on the "Integer A", so i used the text display function to display the integer that was returning from the "Integer A" and it returned 20 instead of 1.

Why isn't it returning 1? Why did it change from a few lines of code from 1 to 20? Why is it that if i change the variable "Heroes_Number_of_Heroes" from 19 to 20 (for example) on the "Set Variables" trigger, the number returned is 21 (always the variable +1)?

Since the hero is replaced correctly, that means the "Integer A" is 1 at least until this line:
Code:
Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana

Thanks in advance.
 

Sooda

Diversity enchants
Reaction score
318
> Why isn't it returning 1?

Means 'Unit-type of (Triggering unit)' is stored to Hero_T1[20] (Hero_T1[Hero_Temp_ID]). Check what unit type it is and if it matches with triggering unit type everything is correct.

> Why did it change from a few lines of code from 1 to 20?

Because you are using loop what runs (Heroes_Number_of_Heroes) 19 times. Check your 'Set Variables' trigger and make sure nothing modifies again 'Heroes_Number_of_Heroes' integer variable. Maybe some other trigger modifies that variable before 'Hero Evolve' trigger runs. Better display to screen 'Heroes_Number_of_Heroes' integer variable value, I bet it will show 20.

> Multiboard - Set the icon for (Last created multiboard)

Last created multiboard stays there until you create new multiboard, if you want to update specific multiboard store it to multiboard variable and use that instead.
Actually it would help if you will post fully 'Set Variables' trigger.
 

Kingdom

New Member
Reaction score
0
Thanks for the answer Sooda.

I've checked the "Heroes_Number_of_Heroes" variable during the evolve using the display text function, the result is correct, the variable is set to 19 during the whole loop. The problem is on the integer itself.

Here's the complete two triggers:
Code:
Hero Evolve
    Events
        Unit - A unit Gains a level
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Hero level of (Triggering unit)) Equal to 10
                (Hero level of (Triggering unit)) Equal to 20
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero level of (Triggering unit)) Equal to 10
            Then - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                            Then - Actions
                                Unit - Pause (Triggering unit)
                                Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                                                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                                                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 4 (Purple)
                                                (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
                                                (Owner of (Triggering unit)) Equal to Player 6 (Orange)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 3) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 7 (Green)
                                                (Owner of (Triggering unit)) Equal to Player 8 (Pink)
                                                (Owner of (Triggering unit)) Equal to Player 9 (Gray)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 5) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                            Else - Actions
            Else - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T2[(Integer A)]
                            Then - Actions
                                Unit - Pause (Triggering unit)
                                Unit - Replace (Triggering unit) with a Hero_T3[(Integer A)] using The old unit's relative life and mana
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Triggering player) Equal to Player 1 (Red)
                                                (Triggering player) Equal to Player 2 (Blue)
                                                (Triggering player) Equal to Player 3 (Teal)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T3[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Triggering player) Equal to Player 4 (Purple)
                                                (Triggering player) Equal to Player 5 (Yellow)
                                                (Triggering player) Equal to Player 6 (Orange)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 3) to Board_Hero_Icon_T3[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Triggering player) Equal to Player 7 (Green)
                                                (Triggering player) Equal to Player 8 (Pink)
                                                (Triggering player) Equal to Player 9 (Gray)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 5) to Board_Hero_Icon_T3[(Integer A)]
                                    Else - Actions
                            Else - Actions

Code:
Set Variables
    Events
    Conditions
    Actions
        Set Player_Color[1] = |c00ff0000
        Set Player_Color[2] = |c000000ff
        Set Player_Color[3] = |c0000ffff
        Set Player_Color[4] = |c00800080
        Set Player_Color[5] = |c00ffff00
        Set Player_Color[6] = |c00ff8000
        Set Player_Color[7] = |c0000ff00
        Set Player_Color[8] = |c00ff00ff
        Set Player_Color[9] = |c00C0C0C0
        Set Player_Color[10] = |c007EBFF1
        Set Player_Color[11] = |c00008000
        Set Player_Color[12] = |c00804040
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                ((Player((Integer A))) slot status) Equal to Is playing
                                ((Player((Integer A))) controller) Equal to User
                    Then - Actions
                        Set Player_Color2[(Integer A)] = ((Name of (Player((Integer A)))) + |r)
                    Else - Actions
                        Set Player_Color2[(Integer A)] = (------ + |r)
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        And - All (Conditions) are true
                            Conditions
                                ((Player((Integer A))) slot status) Equal to Is playing
                                ((Player((Integer A))) controller) Equal to User
                    Then - Actions
                        Set Player_Color3[(Integer A)] = (Name of (Player((Integer A))))
                    Else - Actions
                        Set Player_Color3[(Integer A)] = ------
        Set Dialog_Button[1] = Yes, i want this hero!
        Set Dialog_Button[2] = No, i don't want this hero!
        Set Heroes_Number_of_Heroes = 19
        -------- Hero - Night Stalker --------
        Set Hero_Temp_ID = 1
        Set Hero_Name[Hero_Temp_ID] = Night Stalker
        Set Board_Hero_Icon_T1[Hero_Temp_ID] = ReplaceableTextures\CommandButtons\BTNArcher.blp
        Set Board_Hero_Icon_T2[Hero_Temp_ID] = ReplaceableTextures\CommandButtons\BTNSylvanusWindrunner.blp
        Set Board_Hero_Icon_T3[Hero_Temp_ID] = UI\Glues\ScoreScreen\scorescreen-hero-priestessofthemoon.blp
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Night Stalker <gen>
        Set Hero_T1[Hero_Temp_ID] = Night Stalker T1
        Set Hero_T2[Hero_Temp_ID] = Night Stalker T2
        Set Hero_T3[Hero_Temp_ID] = Night Stalker T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0058 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Ranged
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Agility
        Set Hero_Abilities[Hero_Temp_ID] = Arrow Barrage, Poison|n Arrow,Marksman Presence
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Warglaive Bearer --------
        Set Hero_Temp_ID = 2
        Set Hero_Name[Hero_Temp_ID] = Warglaive Bearer
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Warglaive Bearer <gen>
        Set Hero_T1[Hero_Temp_ID] = Warglaive Bearer T1
        Set Hero_T2[Hero_Temp_ID] = Warglaive Bearer T2
        Set Hero_T3[Hero_Temp_ID] = Warglaive Bearer T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0059 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Melee
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Agility
        Set Hero_Abilities[Hero_Temp_ID] = Mana Burn, Immolation,|nEvasion and Metamorphosis
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Blood Elf Lieutenant --------
        Set Hero_Temp_ID = 5
        Set Hero_Name[Hero_Temp_ID] = Blood Elf Lieutenant
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Blood Elf Lieutenant <gen>
        Set Hero_T1[Hero_Temp_ID] = Blood Elf Lieutenant T1
        Set Hero_T2[Hero_Temp_ID] = Blood Elf Lieutenant T2
        Set Hero_T3[Hero_Temp_ID] = Blood Elf Lieutenant T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0062 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Ranged
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Agility
        Set Hero_Abilities[Hero_Temp_ID] = Mana Burn, Immolation,|nEvasion and Metamorphosis
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Dwarven Defender --------
        Set Hero_Temp_ID = 6
        Set Hero_Name[Hero_Temp_ID] = Dwarven Defender
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Dwarven Defender <gen>
        Set Hero_T1[Hero_Temp_ID] = Dwarven Defender T1
        Set Hero_T2[Hero_Temp_ID] = Dwarven Defender T2
        Set Hero_T3[Hero_Temp_ID] = Dwarven Defender T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0063 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Melee
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Strength
        Set Hero_Abilities[Hero_Temp_ID] = Mana Burn, Immolation,|nEvasion and Metamorphosis
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Imperial Guard --------
        Set Hero_Temp_ID = 9
        Set Hero_Name[Hero_Temp_ID] = Imperial Guard
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Imperial Guard <gen>
        Set Hero_T1[Hero_Temp_ID] = Imperial Guard T1
        Set Hero_T2[Hero_Temp_ID] = Imperial Guard T2
        Set Hero_T3[Hero_Temp_ID] = Imperial Guard T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0066 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Melee
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Strength
        Set Hero_Abilities[Hero_Temp_ID] = Mana Burn, Immolation,|nEvasion and Metamorphosis
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        -------- Hero - Troll Sorceror --------
        Set Hero_Temp_ID = 15
        Set Hero_Name[Hero_Temp_ID] = Troll Sorceror
        Set Hero_Region_Pick[Hero_Temp_ID] = Hero Troll Sorceror <gen>
        Set Hero_T1[Hero_Temp_ID] = Troll Sorceror T1
        Set Hero_T2[Hero_Temp_ID] = Troll Sorceror T2
        Set Hero_T3[Hero_Temp_ID] = Troll Sorceror T3
        Set Hero_CircleOfPower[Hero_Temp_ID] = Select Hero 0072 <gen>
        Set Hero_Attack_Type[Hero_Temp_ID] = Ranged
        Set Hero_Primary_Atribute[Hero_Temp_ID] = Intellect
        Set Hero_Abilities[Hero_Temp_ID] = Mana Burn, Immolation,|nEvasion and Metamorphosis
        Set Hero_Description[Hero_Temp_ID] = (|cff32cd32 + (Hero_Name[Hero_Temp_ID] + (|r|n|n + (|cffff0000 + (Attack Type: + (|r  + (Hero_Attack_Type[Hero_Temp_ID] + (|n + (|cffff0000 + (Primary Attribute: + (|r  + (Hero_Primary_Atribute[Hero_Temp_ID] + (|n + (|cffff0000 + (Abilities: + (|r  + Hero_Abi
        Trigger - Turn off (This trigger)

Thanks in advance.

EDIT: Yes, i still didn't set all the variables to all the 19 heroes.
 

Kingdom

New Member
Reaction score
0
OK, i did some filtering. This is the new trigger i did to print the "Integer A", the results are quite interesting:
Code:
Hero Evolve
    Events
        Unit - A unit Gains a level
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Hero level of (Triggering unit)) Equal to 10
                (Hero level of (Triggering unit)) Equal to 20
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero level of (Triggering unit)) Equal to 10
            Then - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        [B]Game - Display to (All players) the text: (String((Integer A)))[/B]
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                            Then - Actions
                                [B]Game - Display to (All players) the text: (Match on loop number  + (String((Integer A))))[/B]
                                Unit - Pause (Triggering unit)
                                Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                                                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                                                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                                    Then - Actions
                                       [B] Game - Display to (All players) the text: (Getting info from loop number  + (String((Integer A))))[/B]
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 4 (Purple)
                                                (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
                                                (Owner of (Triggering unit)) Equal to Player 6 (Orange)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 3) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 7 (Green)
                                                (Owner of (Triggering unit)) Equal to Player 8 (Pink)
                                                (Owner of (Triggering unit)) Equal to Player 9 (Gray)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 5) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                            Else - Actions
            Else - Actions

OK, now with those display text functions, this was printed on the game:

Code:
1
Match on loop number 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Getting info from loop number 20

Any ideas?

Thanks again!
 

Kingdom

New Member
Reaction score
0
It runs with the initialization trigger, this way i can load the map the way i want:

Code:
Init
    Events
        Map initialization
    Conditions
    Actions
        Cinematic - Turn cinematic mode On for (All players)
        Game - Set the time of day to 6.00
        Player Group - Pick every player in (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing))) and do (Camera - Pan camera for (Picked player) to (Center of Wisp Spawn <gen>) over 0.00 seconds)
        Game - Display to (All players) for 4.00 seconds the text: Wait for the map to...
        Wait 0.10 seconds
        [B]Trigger - Run Set Variables <gen> (ignoring conditions)[/B]
        Wait 5.00 seconds
        ...

I did the following change to show more messages to try narrowing down what's happening:
Code:
Hero Evolve
    Events
        Unit - A unit Gains a level
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Hero level of (Triggering unit)) Equal to 10
                (Hero level of (Triggering unit)) Equal to 20
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero level of (Triggering unit)) Equal to 10
            Then - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        Game - Display to (All players) the text: (String((Integer A)))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                            Then - Actions
                                Game - Display to (All players) the text: (Match on loop number  + (String((Integer A))))
                                Unit - Pause (Triggering unit)
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                [B]Game - Display to (All players) the text: (During Evolve:  + (String((Integer A))))[/B]
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                                                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                                                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                                    Then - Actions
                                        Game - Display to (All players) the text: (Getting info from loop number  + (String((Integer A))))
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 4 (Purple)
                                                (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
                                                (Owner of (Triggering unit)) Equal to Player 6 (Orange)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 3) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 7 (Green)
                                                (Owner of (Triggering unit)) Equal to Player 8 (Pink)
                                                (Owner of (Triggering unit)) Equal to Player 9 (Gray)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 5) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                            Else - Actions
            Else - Actions
            ...
Now, those bold display text function shows the same result for Integer A: 20

Thanks.
 

Kingdom

New Member
Reaction score
0
OK, i found what's bugging and from what i can see, it's not really a programming bug. Check this out:
Code:
Hero Evolve
    Events
        Unit - A unit Gains a level
    Conditions
        Or - Any (Conditions) are true
            Conditions
                (Hero level of (Triggering unit)) Equal to 10
                (Hero level of (Triggering unit)) Equal to 20
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Hero level of (Triggering unit)) Equal to 10
            Then - Actions
                For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
                    Loop - Actions
                        Game - Display to (All players) the text: (String((Integer A)))
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                            Then - Actions
                                Unit - Pause (Triggering unit)
                                [B]Unit - Replace (Triggering unit) with a Hero_T2[(Integer A)] using The old unit's relative life and mana[/B]
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                                Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                                Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                                Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                                Game - Display to (All players) the text: (Getting Info:  + (String((Integer A))))
                                -------- Team 1 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 1 (Red)
                                                (Owner of (Triggering unit)) Equal to Player 2 (Blue)
                                                (Owner of (Triggering unit)) Equal to Player 3 (Teal)
                                    Then - Actions
                                        Game - Display to (All players) the text: (Getting Info 2:  + (String((Integer A))))
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 1) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 4 (Purple)
                                                (Owner of (Triggering unit)) Equal to Player 5 (Yellow)
                                                (Owner of (Triggering unit)) Equal to Player 6 (Orange)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 3) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                                -------- Team 2 --------
                                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    If - Conditions
                                        Or - Any (Conditions) are true
                                            Conditions
                                                (Owner of (Triggering unit)) Equal to Player 7 (Green)
                                                (Owner of (Triggering unit)) Equal to Player 8 (Pink)
                                                (Owner of (Triggering unit)) Equal to Player 9 (Gray)
                                    Then - Actions
                                        Multiboard - Set the icon for (Last created multiboard) item in column 1, row ((Player number of (Owner of (Triggering unit))) + 5) to Board_Hero_Icon_T2[(Integer A)]
                                    Else - Actions
                            Else - Actions
            Else - Actions
So this is the partial code, and on bold is the function that changes the variable from 1 to 20. I found this out by disabling function by function to narrow EXACTLY where it was being changed.

Now, the reason this changes the "Integer A" from 1 to 20 is outside my knowledge. Anyone has any idea why?

Thanks.
 

Kingdom

New Member
Reaction score
0
Since nobody has any idea what's going on, i'm in a personal quest.

Well, i do know a workaround to the bug i've shown so far. But now, i got another bug and this brings me the question in the end of this post. First, i'll show a new bug i found:
Code:
Hero Evolve T1
    Events
        Unit - A unit Gains a level
    Conditions
        (Level of (Triggering unit)) Equal to 10
    Actions
        For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                    Then - Actions
                        Set Evolve_Int_Temp = (Integer A)
                        Unit - Replace (Triggering unit) with a Hero_T2[Evolve_Int_Temp] using The old unit's relative life and mana
                    Else - Actions
        Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
        Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
        Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
        [B]Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))[/B]
This trigger is ridiculous and it's a small version of the triggers i posted above. OK, when this trigger is executed, it will print the following to the user:

has evolved into
PLAYER NAME has evolved into HERO NAME


Yes, it displays the message TWO times to the user for some weird reason. Anyways, ignoring the bug, in the first time, as you can see above, the message won't get the variables but on the second message, it does returns the correct variables.
Now if i do this:
Code:
Hero Evolve T1
    Events
        Unit - A unit Gains a level
    Conditions
        (Level of (Triggering unit)) Equal to 10
    Actions
        For each (Integer A) from 1 to Heroes_Number_of_Heroes, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Unit-type of (Triggering unit)) Equal to Hero_T1[(Integer A)]
                    Then - Actions
                        Set Evolve_Int_Temp = (Integer A)
                        Unit - Replace (Triggering unit) with a Hero_T2[Evolve_Int_Temp] using The old unit's relative life and mana
                        Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\NightElf\Blink\BlinkCaster.mdl
                        Selection - Add (Last replaced unit) to selection for (Owner of (Triggering unit))
                        Special Effect - Create a special effect attached to the overhead of (Last replaced unit) using Abilities\Spells\Human\HolyBolt\HolyBoltSpecialArt.mdl
                        Game - Display to (All players) the text: ((|cffff0000 + ((Name of (Owner of (Last replaced unit))) + |r )) + (has evolved into  + (|cff32cd32 + ((Name of (Last replaced unit)) + |r))))
                    Else - Actions
It will only display the correct message, with the PLAYER NAME and HERO NAME.

Questions:
1- Is there an executing order when dealing with loops? I mean, does it execute the rest of the trigger before executing the loop?
2- Why the message is displayed twice on the first trigger?

I'm going crazy with this, so ANYTHING is helpful.
Thanks in advance!
 

trb92

Throwing science at the wall to see what sticks
Reaction score
142
>2- Why the message is displayed twice on the first trigger?
Well, that's kind of complex. I'll explain it here:

Your using the replace function.
Code:
Unit - Replace (Triggering unit) with a Footman using The old unit's relative life and mana
Just with the units changed. Now, I convert that function to JASS and I get



No, you don't need to understand JASS to understand me. Just stick with me, you get that. Anyway, I check exactly what the ReplaceUnitBJ function does.

JASS:
function ReplaceUnitBJ takes unit whichUnit, integer newUnitId, integer unitStateMethod returns unit
    local unit    oldUnit = whichUnit
    local unit    newUnit
    local boolean wasHidden
    local integer index
    local item    indexItem
    local real    oldRatio

    // If we have bogus data, don&#039;t attempt the replace.
    if (oldUnit == null) then
        set bj_lastReplacedUnit = oldUnit
        return oldUnit
    endif

    // Hide the original unit.
    set wasHidden = IsUnitHidden(oldUnit)
    call ShowUnit(oldUnit, false)

    // Create the replacement unit.
    if (newUnitId == &#039;ugol&#039;) then
        set newUnit = CreateBlightedGoldmine(GetOwningPlayer(oldUnit), GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit))
    else
        set newUnit = CreateUnit(GetOwningPlayer(oldUnit), newUnitId, GetUnitX(oldUnit), GetUnitY(oldUnit), GetUnitFacing(oldUnit))
    endif

    // Set the unit&#039;s life and mana according to the requested method.
    if (unitStateMethod == bj_UNIT_STATE_METHOD_RELATIVE) then
        // Set the replacement&#039;s current/max life ratio to that of the old unit.
        // If both units have mana, do the same for mana.
        if (GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE) &gt; 0) then
            set oldRatio = GetUnitState(oldUnit, UNIT_STATE_LIFE) / GetUnitState(oldUnit, UNIT_STATE_MAX_LIFE)
            call SetUnitState(newUnit, UNIT_STATE_LIFE, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_LIFE))
        endif

        if (GetUnitState(oldUnit, UNIT_STATE_MAX_MANA) &gt; 0) and (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) &gt; 0) then
            set oldRatio = GetUnitState(oldUnit, UNIT_STATE_MANA) / GetUnitState(oldUnit, UNIT_STATE_MAX_MANA)
            call SetUnitState(newUnit, UNIT_STATE_MANA, oldRatio * GetUnitState(newUnit, UNIT_STATE_MAX_MANA))
        endif
    elseif (unitStateMethod == bj_UNIT_STATE_METHOD_ABSOLUTE) then
        // Set the replacement&#039;s current life to that of the old unit.
        // If the new unit has mana, do the same for mana.
        call SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(oldUnit, UNIT_STATE_LIFE))
        if (GetUnitState(newUnit, UNIT_STATE_MAX_MANA) &gt; 0) then
            call SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(oldUnit, UNIT_STATE_MANA))
        endif
    elseif (unitStateMethod == bj_UNIT_STATE_METHOD_DEFAULTS) then
        // The newly created unit should already have default life and mana.
    elseif (unitStateMethod == bj_UNIT_STATE_METHOD_MAXIMUM) then
        // Use max life and mana.
        call SetUnitState(newUnit, UNIT_STATE_LIFE, GetUnitState(newUnit, UNIT_STATE_MAX_LIFE))
        call SetUnitState(newUnit, UNIT_STATE_MANA, GetUnitState(newUnit, UNIT_STATE_MAX_MANA))
    else
        // Unrecognized unit state method - ignore the request.
    endif

    // Mirror properties of the old unit onto the new unit.
    //call PauseUnit(newUnit, IsUnitPaused(oldUnit))
    call SetResourceAmount(newUnit, GetResourceAmount(oldUnit))

    // If both the old and new units are heroes, handle their hero info.
    if (IsUnitType(oldUnit, UNIT_TYPE_HERO) and IsUnitType(newUnit, UNIT_TYPE_HERO)) then
        call SetHeroXP(newUnit, GetHeroXP(oldUnit), false)

        set index = 0
        loop
            set indexItem = UnitItemInSlot(oldUnit, index)
            if (indexItem != null) then
                call UnitRemoveItem(oldUnit, indexItem)
                call UnitAddItem(newUnit, indexItem)
            endif

            set index = index + 1
            exitwhen index &gt;= bj_MAX_INVENTORY
        endloop
    endif

    // Remove or kill the original unit.  It is sometimes unsafe to remove
    // hidden units, so kill the original unit if it was previously hidden.
    if wasHidden then
        call KillUnit(oldUnit)
        call RemoveUnit(oldUnit)
    else
        call RemoveUnit(oldUnit)
    endif

    set bj_lastReplacedUnit = newUnit
    return newUnit
endfunction

Really, the only important part of that entire blob of JASS right now is this line
JASS:
call SetHeroXP(newUnit, GetHeroXP(oldUnit), false)


That increases the hero EXP, which increases the level, which will bring the level of the hero to the 10 or 20 required to fire the trigger. That's why the message shows twice.

>1- Is there an executing order when dealing with loops? I mean, does it execute the rest of the trigger before executing the loop?
Loops execute at their place in the trigger. So if you have
Code:
Untitled Trigger 001
    Events
    Conditions
    Actions
        Actions before loop
         For each (Integer A) from 1 to 10, do (Actions)
            Loop - Actions
        Actions after loop
The loop's actions will execute after the actions before it, but before the actions after it. It executes just how it looks.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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