• 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.

[Trigger] Why doesn't this trigger work?

Status
Not open for further replies.
Level 12
Joined
Apr 26, 2008
Messages
830
It summons the heroes, but it only changes the level for 1 hero, I want to level the hero each level from 1 to the destined level like 36, so it gains 1+1+1+1 .... until 36 I need to do this because it's important for my skill system...

  • SS Setup
    • Ereignisse
      • Zeit - Elapsed game time is 4.00 seconds
    • Bedingungen
    • Aktionen
      • -------- Paladin --------
      • Set SS_SpawnUnit[1] = Paladin
      • Set SS_SpawnLimit[1] = 4
      • Set SS_SpawnRegion[1] = (Center of PaladinRegion <gen>)
      • Set SS_SpawnDelay[1] = 2.00
      • Set SS_LevelMIN[1] = 2
      • Set SS_LevelMAX[1] = 6
      • -------- Archmage --------
      • Set SS_SpawnUnit[2] = Erzmagier
      • Set SS_SpawnLimit[2] = 3
      • Set SS_SpawnRegion[2] = (Center of ArchmageRegion <gen>)
      • Set SS_SpawnDelay[2] = 6.00
      • Set SS_LevelMIN[2] = 2
      • Set SS_LevelMAX[2] = 6
      • -------- Mountain King --------
      • Set SS_SpawnUnit[3] = Bergkönig
      • Set SS_SpawnLimit[3] = 5
      • Set SS_SpawnRegion[3] = (Center of MountainKingRegion <gen>)
      • Set SS_SpawnDelay[3] = 1.00
      • -------- Blood Mage --------
      • Set SS_SpawnUnit[4] = Blutmagier
      • Set SS_SpawnLimit[4] = 1
      • Set SS_SpawnRegion[4] = (Center of BloodMageRegion <gen>)
      • Set SS_SpawnDelay[4] = 4.00
      • Set SS_MaxSpawnUnitType = 4
      • For each (Integer LoopingInteger[1]) from 1 to SS_MaxSpawnUnitType, do (Actions)
        • Schleifen - Aktionen
          • Einheit - Create SS_SpawnLimit[LoopingInteger[1]] SS_SpawnUnit[LoopingInteger[1]] for Spieler 12 (Braun) at SS_SpawnRegion[LoopingInteger[1]] facing Vorgabe für Gebäude-Ausrichtung degrees
          • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
          • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
            • Schleifen - Aktionen
              • Held - Set (Last created unit) Hero-level to ((Hero level of (Last created unit)) + 1), Verbergen level-up graphics
      • Hashtabelle - Create a hashtable
      • Set SS_Hashtable = (Last created hashtable)
      • Set SS_Interval = 0.03
      • Auslöser - Add to SS Loop <gen> the event (Zeit - Every SS_Interval seconds of game time)
 
Level 5
Joined
Jun 16, 2004
Messages
108
Since you are creating more than one unit, you should be using something like this instead:
  • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
    • Loop - Actions
      • Hero - Set (Picked unit) Hero-level to (Hero level of (Picked unit)), Hide level-up graphics
When doing those GUI create calls with more than one unit, use the last created unit group to refer to the units created.

Also, I forgot to add a +1 to the above.
 
Last edited:
Level 12
Joined
Apr 26, 2008
Messages
830
Since you are creating more than one unit, you should be using something like this instead:
  • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
    • Loop - Actions
      • Hero - Set (Picked unit) Hero-level to (Hero level of (Picked unit)), Hide level-up graphics
When doing those GUI create calls with more than one unit, use the last created unit group to refer to the units created.

Like this?
  • SS Setup
    • Ereignisse
      • Zeit - Elapsed game time is 4.00 seconds
    • Bedingungen
    • Aktionen
      • -------- Paladin --------
      • Set SS_SpawnUnit[1] = Paladin
      • Set SS_SpawnLimit[1] = 4
      • Set SS_SpawnRegion[1] = (Center of PaladinRegion <gen>)
      • Set SS_SpawnDelay[1] = 2.00
      • Set SS_LevelMIN[1] = 2
      • Set SS_LevelMAX[1] = 6
      • -------- Archmage --------
      • Set SS_SpawnUnit[2] = Erzmagier
      • Set SS_SpawnLimit[2] = 3
      • Set SS_SpawnRegion[2] = (Center of ArchmageRegion <gen>)
      • Set SS_SpawnDelay[2] = 6.00
      • Set SS_LevelMIN[2] = 2
      • Set SS_LevelMAX[2] = 6
      • -------- Mountain King --------
      • Set SS_SpawnUnit[3] = Bergkönig
      • Set SS_SpawnLimit[3] = 5
      • Set SS_SpawnRegion[3] = (Center of MountainKingRegion <gen>)
      • Set SS_SpawnDelay[3] = 1.00
      • -------- Blood Mage --------
      • Set SS_SpawnUnit[4] = Blutmagier
      • Set SS_SpawnLimit[4] = 1
      • Set SS_SpawnRegion[4] = (Center of BloodMageRegion <gen>)
      • Set SS_SpawnDelay[4] = 4.00
      • Set SS_MaxSpawnUnitType = 4
      • For each (Integer LoopingInteger[1]) from 1 to SS_MaxSpawnUnitType, do (Actions)
        • Schleifen - Aktionen
          • Einheit - Create SS_SpawnLimit[LoopingInteger[1]] SS_SpawnUnit[LoopingInteger[1]] for Spieler 12 (Braun) at SS_SpawnRegion[LoopingInteger[1]] facing Vorgabe für Gebäude-Ausrichtung degrees
          • Einheitengruppe - Add (Last created unit) to LevelGroup
          • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
          • Einheitengruppe - Pick every unit in LevelGroup and do (Actions)
            • Schleifen - Aktionen
              • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
                • Schleifen - Aktionen
                  • Held - Set (Last created unit) Hero-level to ((Hero level of (Last created unit)) + 1), Verbergen level-up graphics
      • Hashtabelle - Create a hashtable
      • Set SS_Hashtable = (Last created hashtable)
      • Set SS_Interval = 0.03
      • Auslöser - Add to SS Loop <gen> the event (Zeit - Every SS_Interval seconds of game time)
 
Level 5
Joined
Jun 16, 2004
Messages
108
No.
> Einheitengruppe - Add (Last created unit) to LevelGroup
Does not work because (Last created unit) only references one unit: the last created one.

You can pretty much directly paste in my post into the trigger you posted first.
  • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
    • Schleifen - Aktionen
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics
 
Level 12
Joined
Apr 26, 2008
Messages
830
No.
> Einheitengruppe - Add (Last created unit) to LevelGroup
Does not work because (Last created unit) only references one unit: the last created one.

You can pretty much directly paste in my post into the trigger you posted first.
  • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
    • Schleifen - Aktionen
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics

Hm i did but it just levels up 1 unit and it becomes level 10 somehow... i posted the map aswelll
 

Attachments

  • Spawning System2.w3x
    16.7 KB · Views: 46
Level 5
Joined
Jun 16, 2004
Messages
108
You used
  • Hero - Set (Last created unit) Hero-level to ((Hero level of (Last created unit)) + 1), Hide level-up graphics
Which is once again "last created unit". Keep in mind there is only one last created unit at any given time.
The correct action is
  • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics
You are also randoming on two different for loop indices here which is probably not intended
  • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
Also you do not set the min/max levels for the last two heroes.
 
Level 12
Joined
Apr 26, 2008
Messages
830
You used
  • Hero - Set (Last created unit) Hero-level to ((Hero level of (Last created unit)) + 1), Hide level-up graphics
Which is once again "last created unit". Keep in mind there is only one last created unit at any given time.
The correct action is
  • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics
You are also randoming on two different for loop indices here which is probably not intended
  • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
Also you do not set the min/max levels for the last two heroes.

I see , as for the last, it randomizes the level of the unit between MIN and MAX which i would like to be like that, how can i do it to let it be right? for every unit not just for one..
 
Level 5
Joined
Jun 16, 2004
Messages
108
I am not sure what you mean, but for this:
  • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
Notice that you are using LoopingInteger[2] when you are not even in a loop that uses LoopingInteger[2].

To make all your heroes level up, you simply have to use the actions I have been pasting for the past three posts, which most recently is this:
  • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
    • Schleifen - Aktionen
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics
I decided to make the modifications and upload them, maybe that will help.
 

Attachments

  • Spawning System2.w3x
    16.5 KB · Views: 74
Level 12
Joined
Apr 26, 2008
Messages
830
I am not sure what you mean, but for this:
  • Set SS_LevelEND[LoopingInteger[1]] = (Random integer number between SS_LevelMIN[LoopingInteger[1]] and SS_LevelMAX[LoopingInteger[2]])
Notice that you are using LoopingInteger[2] when you are not even in a loop that uses LoopingInteger[2].

To make all your heroes level up, you simply have to use the actions I have been pasting for the past three posts, which most recently is this:
  • For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
    • Schleifen - Aktionen
      • Unit Group - Pick every unit in (Last created unit group) and do (Actions)
        • Loop - Actions
          • Hero - Set (Picked unit) Hero-level to ((Hero level of (Picked unit)) + 1), Hide level-up graphics
I decided to make the modifications and upload them, maybe that will help.

With this i want to get a random number between the MIN and MAX for example MIn is lvl 3 and max is lvl 7, the units will be spawned with a random level so each unit has a random level, so level end would be for example lvl 5.
 
Level 5
Joined
Jun 16, 2004
Messages
108
Then put the random number action inside the unit group loop so that it runs once per unit, then move the for loop loop inside the unit group loop as well, then move the hero level action inside the for loop.
 
Level 12
Joined
Apr 26, 2008
Messages
830
Then put the random number action inside the unit group loop so that it runs once per unit, then move the for loop loop inside the unit group loop as well, then move the hero level action inside the for loop.

dont get it can you show it in triggers?
If i move the random number inside this trigger won't work
For each (Integer LoopingInteger[2]) from 1 to SS_LevelEND[LoopingInteger[1]], do (Actions)
 
Level 5
Joined
Jun 16, 2004
Messages
108
Perhaps this is more of what you want (attached).
I gave the last two heroes a levelmin / levelmax of 2 and 6 like the first two. Note that this means the minimum level you will see is 3, and the maximum is 7.
 

Attachments

  • Spawning System2.w3x
    16.7 KB · Views: 49
Level 33
Joined
Mar 27, 2008
Messages
8,035
You have to manually loop it per unit to create the unit.
What my system does is actually creates a Unit Group at once, for example, Paladin is spawned 4 at once and you want each of this 4 units has different level ranging from MIN ~ MAX, right ?

Therefore, you have to do a loop within a loop.

The first loop is for Unit-Type check, then next loop is to create units individually and use the (Last created unit) to refer to the each individual unit that is created.
 
Level 12
Joined
Apr 26, 2008
Messages
830
Perhaps this is more of what you want (attached).
I gave the last two heroes a levelmin / levelmax of 2 and 6 like the first two. Note that this means the minimum level you will see is 3, and the maximum is 7.

That's exactly the way i wanted it, but i wanted to ask you two another think what happens if i add multiple types of heroes for another region for example. i create 4 mountain kings for region 1 then i create another 4 mountain kings but this time for region 2? then i create 2 mountain kings for region 3 and so on.., does te trigger still work then?
 
Level 5
Joined
Jun 16, 2004
Messages
108
It should work fine as long as you take care to form the actions right. Remember that when you create more than 1 unit with the GUI create unit action, you need to use "last created group" in a unit group loop to refer to each unit, referring to each unit as "picked unit" in the unit group loop.

When you create only 1 unit with a create unit call then you can use "last created unit" with no problem.

Well if you have trouble you can always post again.
 
Level 12
Joined
Apr 26, 2008
Messages
830
It should work fine as long as you take care to form the actions right. Remember that when you create more than 1 unit with the GUI create unit action, you need to use "last created group" in a unit group loop to refer to each unit, referring to each unit as "picked unit" in the unit group loop.

When you create only 1 unit with a create unit call then you can use "last created unit" with no problem.

Well if you have trouble you can always post again.

Got 65 instances so far and it works well, just a little lagg in the beginning but it's normal..
 
Status
Not open for further replies.
Top