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

Variable array trigger bugging up

Status
Not open for further replies.
Level 5
Joined
Mar 21, 2007
Messages
155
Hello, i'm trying to give everybody a tech level in my game, they start with tech level 10, and every time they tech up, (type in the command "tec up", and have the money required e.c.t.) thier tech level increases by 10. These are my triggers, players are differed by arrays, but in game they seem to bug up a lot, e.g. when a trigger comes up that looks at the tech level and sees if they can do this (e.g like increase a units hp and attack), its quite odd and unstable, can anybody shed some light? Ty. Sorry for the spam

Max Unit level = my tec level
Player = Player 1, 2 e.c.t.
player = just keeps a number at the start of all my triggers that call the tech variable, to see which player is the one who started the trigger

My initialization trigger, sets the variables
  • initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Player[1] = Player 1 (Red)
      • Set Player[2] = Player 2 (Blue)
      • Set Player[3] = Player 3 (Teal)
      • Set Player[4] = Player 4 (Purple)
      • Set Player[5] = Player 5 (Yellow)
      • Set Player[6] = Player 6 (Orange)
      • Set Player[7] = Player 7 (Green)
      • Set Player[8] = Player 8 (Pink)
      • Set Player[9] = Player 9 (Gray)
      • Set Player[10] = Player 10 (Light Blue)
      • Set Player[11] = Player 11 (Dark Green)
      • Set Player[12] = Player 12 (Brown)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set Max_Unit_Level[(Integer A)] = 10
MY Tech up trigger
  • teching up
    • Events
      • Player - Player 1 (Red) types a chat message containing -tec up as An exact match (and so on with all the other players)
    • Conditions
    • Actions
      • For each (Integer B) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering player) Equal to Player[(Integer A)]
            • Then - Actions
              • Set player = (Integer A)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering player) Current gold) Greater than or equal to (Max_Unit_Level[player] x 10)
          • ((Triggering player) Current lumber) Greater than or equal to (Max_Unit_Level[player] x 10)
        • Then - Actions
          • Player - Set (Triggering player) Current gold to (((Triggering player) Current gold) - (Max_Unit_Level[player] x 10))
          • Player - Set (Triggering player) Current lumber to (((Triggering player) Current lumber) - (Max_Unit_Level[player] x 10))
          • Set Max_Unit_Level[player] = (Max_Unit_Level[player] + 10)
          • Game - Display to (All players) for 10.00 seconds the text: ((Name of (Owner of (Triggering unit))) + ( has teched up, his tec level is now + (String(Max_Unit_Level[player]))))
        • Else - Actions
          • Game - Display to (Player group((Triggering player))) for 10.00 seconds the text: You don't have enou...
And part of my trigger that refers to the tech up, once again reduced for the anti spam
  • units power up
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Gain Power (normal)
          • (Ability being cast) Equal to Gain Power (dmg)
          • (Ability being cast) Equal to Gain Power (TANK)
          • (Ability being cast) Equal to Gain Power (archer)
          • (Ability being cast) Equal to Gain Power (wall)
    • Actions
      • 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
              • (Owner of (Triggering unit)) Equal to Player[(Integer A)]
            • Then - Actions
              • Set player = (Integer A)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Ability being cast) Equal to Gain Power (normal)
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to Gain Power (normal)
              • ((Owner of (Triggering unit)) Current gold) Greater than or equal to 10
              • ((Owner of (Triggering unit)) Current lumber) Greater than or equal to 10
              • (Integer((Max life of (Triggering unit)))) Less than (Max_Unit_Level[player] x 100)
            • Then - Actions
              • Player - Set (Owner of (Triggering unit)) Current gold to (((Owner of (Triggering unit)) Current gold) - 10)
              • Player - Set (Owner of (Triggering unit)) Current lumber to (((Owner of (Triggering unit)) Current lumber) - 10)
              • Unit - Add Inventory (6 slot) to (Triggering unit)
              • Hero - Create Unit Power up (20) and give it to (Triggering unit)
              • Hero - Order (Triggering unit) to use (Last created item)
              • Hero - Create Unit HP up (100) and give it to (Triggering unit)
              • Hero - Order (Triggering unit) to use (Last created item)
              • Unit - Remove Inventory (6 slot) from (Triggering unit)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Owner of (Triggering unit)) Current gold) Less than 10
                  • ((Owner of (Triggering unit)) Current lumber) Less than 10
                • Then - Actions
                  • Floating Text - Create floating text that reads You do not have eno... above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
                  • Floating Text - Change (Last created floating text): Disable permanence
                  • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Integer((Max life of (Triggering unit)))) Greater than or equal to (Max_Unit_Level[player] x 100)
                    • Then - Actions
                      • Floating Text - Create floating text that reads (You need to Upgrade your Tech)
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                    • Else - Actions
        • Else - Actions
Ty again, and sorry for the long spam
 
What Eleandor means is, why do use that player array? You can just do
  • Untitled MyTrig
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to (Player((Integer A)))
            • Then - Actions
              • blah blah
            • Else - Actions
      • blah blah
 
Level 5
Joined
Mar 21, 2007
Messages
155
What Eleandor means is, why do use that player array?

Please look at my current trigger carefully:slp:, because if you look at the start of all my trigs, i use that player player array to set my variable "player" which is an integer, and which defines for the rest of that trigger which player (i.e. player 1) my "Max_Unit_Level" or that players tec level, but is this a sort of leaky way to do it? Or could anyone suggest to do something diffrent?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Technacilly storing players in an array might be faster than using the native? As I thought native calls were slower than array look ups. I am not entirly sure so I would like an opinion from another expert.

Even if it is not, it probably is faster than the GUI way as that leads to a function with does a mathimatical opperation on a native.
 
Technacilly storing players in an array might be faster than using the native? As I thought native calls were slower than array look ups. I am not entirly sure so I would like an opinion from another expert.
True, storing them in an array would be faster, but efficiency is not needed here... In this case it just makes the triggers more confusing.
A waste of a variable array!? I'm not even going to ask.

So are you saying that if i use the function "Convert Player index to Player" instead of My variable integer "player" and my variable player "Player" that my problem will be fixed?
No. That will not fix your problem, but will make the triggers a bit easier to read, therefore you may be able to solve your problem more easily...
 
Level 5
Joined
Mar 21, 2007
Messages
155
Ok many things guys

1: Ty for your feedback, although you never really answered my question ;)

2: I've just spotted that in my "teching up" trigger, i have used (Integer B), not (Integer A) which i should have used to properly define my "player" variable, and it thus carried over form the next player, causing my random leak. Sorry for the fuss =p

3: retarded thing is i spotted this by the time i made a much more stable and complex system of teching up -.-. Oh well this is out there, and is perfectly stable for anyone who wishes to use it, just reference would be nice =)

4: Element of water, do you have a problem reading or seeing more than 2 variables in 1 trigger? Upgrade your brains RAM =P
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Every player array is 8192 bytes (I guess they used a 1 byte integer, if they used anything else then it's x2 bigger or more).

Is that better then calling? Who knows.
Does it matter? No.

Simple things like this don't freaking matter, so it's another 8 kilobytes, so it's another few calls, who the hell cares?
The computers this days are too powerful to care about this crap anyways, so just make your code neat.
 
Status
Not open for further replies.
Top