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

[Solved] Variables and units dying

Status
Not open for further replies.
  • Untitled Trigger 003
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Warrior Bug
    • Actions
      • Set bugs = (bugs + 1)
      • If (bugs Equal to 20) then do (Game - Display to (All players) the text: Fleet: This is flee...) else do (Do nothing)
So it's basically when 20 of the unit type die the game message is supposed to happen but it hasn't happened. I don't know what's wrong with it. I made an integer type variable with no array and I put an initial value of 20.
 
Level 3
Joined
Mar 20, 2011
Messages
35
not sure if this is what you want or not but triggering unit reffers to the unit killing the dying unit I believe. so if im right just change your condition to
  • (Unit-type of (Dying unit)) Equal to Footman
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
I made an integer type variable with no array and I put an initial value of 20.
There, you answered your own question...
It does not work because it never is equal to 20. Well acutually I lie, just it will fire after you kill 2^32 or 4,294,967,296 of that unit type (due to integer variable overflow). The game will however most likly have crashed by then due to underlying platform and engine instabilities so as far as you are concerned it is never.

Basically
map starts
bugs = 20
unit of type bugs dies
bugs = 21
if bugs equals 20 do something but it is not so skip.
unit of type bugs dies
bugs = 22
if bugs equals 20 do something but it is not so skip.
etc...

Try giving it an innitial value of 0. That way it should reach a value of 20 after 20 kills.

In GUI, initial value means the value the variable will be given when the map session initializes. Array size for arrays just means the number of indicies (starting at index 0) are givien the initial value. Both are entirly optional if you are going to store stuff. You may need them for some types of object which GUI lacks constructors for or if you want to make your life easier.

Integers are 32bit numbers signed via two's compliment. This gives them a range between -2^31 and +2^31-1. Arrays are dynamic arrays meaning they allocate extra space as needed giving an effective logical index value range of 0 to 8190 inclusive (apparently array index 8191 has problems so it is short of 2^13 indicies).
 
Level 3
Joined
Mar 20, 2011
Messages
35
Oh yeah sorry I was thinking event Unit takes damage, and the triggering unit refers to the damaged unit.
 
There, you answered your own question...
It does not work because it never is equal to 20. Well acutually I lie, just it will fire after you kill 2^32 or 4,294,967,296 of that unit type (due to integer variable overflow). The game will however most likly have crashed by then due to underlying platform and engine instabilities so as far as you are concerned it is never.

Basically
map starts
bugs = 20
unit of type bugs dies
bugs = 21
if bugs equals 20 do something but it is not so skip.
unit of type bugs dies
bugs = 22
if bugs equals 20 do something but it is not so skip.
etc...

Try giving it an innitial value of 0. That way it should reach a value of 20 after 20 kills.

In GUI, initial value means the value the variable will be given when the map session initializes. Array size for arrays just means the number of indicies (starting at index 0) are givien the initial value. Both are entirly optional if you are going to store stuff. You may need them for some types of object which GUI lacks constructors for or if you want to make your life easier.

Integers are 32bit numbers signed via two's compliment. This gives them a range between -2^31 and +2^31-1. Arrays are dynamic arrays meaning they allocate extra space as needed giving an effective logical index value range of 0 to 8190 inclusive (apparently array index 8191 has problems so it is short of 2^13 indicies).
Ah I get understand it now. Thanks a lot. Now it works perfectly.
 
Status
Not open for further replies.
Top