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

Need Help with Creating Variables

Status
Not open for further replies.
Level 2
Joined
Oct 18, 2011
Messages
16
Is there a better way to create just one variable for many units? I found that I have to create a new variable for each unit in the game, but is there a simpler way to do this?

Example: I have a trigger that awards certain abilities every 5 levels that are gained by certain hero's. But I have had to create a new variable for each hero I have made, this is very tedious.
 
Level 7
Joined
Apr 1, 2010
Messages
289
you could do this
  • Help
    • Events
      • Unit - A unit Gains a level
    • Conditions
    • Actions
      • if level of Trggering unit = 5
      • then
      • else
you could do this for them, and you could also check to see which hero they are by comparing their unit type.
 
Level 2
Joined
Oct 18, 2011
Messages
16
Yes I have done that already and it does work. But will it work if more than one unit gains a level at the same time? Will the game assign the same variable to more than one unit? Or would this require the use of arrays? By the way, I have no clue what an array is lol.
 
Level 12
Joined
Oct 16, 2010
Messages
680
actually there is no way that two heroes levels at the very same time (actually there is nothing that a computer does in the same time)
even if it looks like, they reach the higher level after each other

and because of that the trigger will work any time

and arrays are indexed variables that can store many of the SAME type objects
 
Level 12
Joined
Oct 16, 2010
Messages
680
the array in the WE is basically that, 2D...

thats not true... two dimensional arrays basically have 2 indexes
like in almost every programming language

if i say set array[2][0] = 4 (perhaps this option is not available in this way in WE)
than it is what it looks like
1st box of 3rd row
[ ][ ][ ]
[ ][ ][ ]
[4][ ][ ]

arrays in WE are not like this.. those are just lines
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
(actually there is nothing that a computer does in the same time)
Correct for like 20 years ago, incorrect now. Computers have multi core processors which run parallel threads at the same time on the same clock. Graphic cards are separate processors that are massivly parallel and run on a separate clock. Computers do a lot in parallel at the same time.

Even WC3 has 30 odd threads in it of which atleast 2 must be running at some point in time if you have a dual core processor. WC3 does run primarilly on 1 thread though which is why you can not get 2 things occuring at exactly the same time in the game itself so you were correct in respect to that.
 
Level 2
Joined
Oct 18, 2011
Messages
16
You know I just tested this level up trigger I and I learned that you actually do have to create many variables. If two units level up at the same time then the wrong unit is going to get the ability, even if you set a specific condition.
 
Level 7
Joined
Jan 29, 2010
Messages
213
You know I just tested this level up trigger I and I learned that you actually do have to create many variables. If two units level up at the same time then the wrong unit is going to get the ability, even if you set a specific condition.

No it can't be true, you made somewhere a mistake...
Please add here your triggers that we can solve your problem easier. :)
 
Level 2
Joined
Oct 18, 2011
Messages
16
Good news everyone! I've got internet at my house again!

Now I can post the trigger... thanks for being patient.

  • Level 5 Through 9
    • Events
      • Unit - A unit Gains a level
    • Conditions
      • ((Level of (Triggering unit)) Greater than or equal to 5) and ((Hero level of (Triggering unit)) Less than or equal to 9)
    • Actions
      • Set O = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Death Knight Tank
        • Then - Actions
          • Unit - Remove Death and Decay (N) from O
          • Wait 0.02 seconds
          • Unit - Add Death and Decay (N) to O
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Grom Hellscream
        • Then - Actions
          • Unit - Remove Icy Talons from O
          • Wait 0.02 seconds
          • Unit - Add Icy Talons to O
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Captain Bitchenstein
              • (Unit-type of O) Equal to Muradin Bronzebeard
              • (Unit-type of O) Equal to Horde Warrior
              • (Unit-type of O) Equal to Druid Tank
        • Then - Actions
          • Unit - Remove Rage from O
          • Wait 0.02 seconds
          • Unit - Add Rage to O
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Horde Rogue
              • (Unit-type of O) Equal to Alliance Rogue
        • Then - Actions
          • Unit - Remove Energy from O
          • Wait 0.02 seconds
          • Unit - Add Energy to O
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Alliance Hunter
              • (Unit-type of O) Equal to Horde Hunter
        • Then - Actions
          • Unit - Remove Focus from O
          • Wait 0.02 seconds
          • Unit - Add Focus to O
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of O) Equal to Paladin Tank
              • (Unit-type of O) Equal to Arthas II
              • (Unit-type of O) Equal to Halahk the Lifebringer
              • (Unit-type of O) Equal to Horde Warlock
              • (Unit-type of O) Equal to Shaman Healer
              • (Unit-type of O) Equal to Heal Bot 1000
              • (Unit-type of (Triggering unit)) Equal to Horde Mage
              • (Unit-type of (Triggering unit)) Equal to Jaina
        • Then - Actions
          • Unit - Remove Spirit Gem from O
          • Wait 0.02 seconds
          • Unit - Add Spirit Gem to O
        • Else - Actions
As some of you might notice, I am making a WoWish map.

Oh and please tell me my trigger is wrong. I hope it is lol.
 
You don't need to store triggering unit into variable, use it like that. It will work even with waits, also wait 0.something (if you need really small time interval) usually don't work, but simple wait 0.00 can sometimes fix your problem. For example try to instantly move unit to some point when unit cast spell. it won't work, if you add wait 0.00 sec trigger action there it will without delay.
 
Status
Not open for further replies.
Top