Unit Count

Astarael

New Member
Reaction score
0
I have an issue as always lolz.
The issue of today is; i want to make a trigger that pretty much does this:
Every 2 minutes of game time, it will grant every player (except brown) 1 lumber, or energy in this case, for every unit (I want the unit to be a cold fusion reactor) that they own. However! Very similar to vampirism beast.
Can anyone help me?
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
first, you need to store your units (reactors) into unit group variable
whenever player builds a reactor store it to the unit group
then for each integer (A) from 1 to number of units in (your group) do actions:
loop
give 1 lumber to player that owns the group (make unit groups as arrays)
 

Sevion

The DIY Ninja
Reaction score
413
Try:

Code:
Events:
    Every 120 seconds of game time
Conditions:
Actions:
    For ever Integer A from 1 to 11 do (Multiple actions):
        Set Temp_Group = Units In (Entire Map) matching ((Picked Unit) belongs to Player(Integer A) And (Unit-Type of (Picked Unit) is Cold Fusion Reactor))
    Unit Group - Pick ever unit in Temp_Group and do (Multiple actions):
        Player - Add 1 lumber to (Player (Integer A))'s Current lumber
    call DestroyGroup(udg_Temp_Group) <-- OR EGUI - Destroy Temp_Group

It was free handed so it's not exact.
 

Kazuga

Let the game begin...
Reaction score
110
Think this will do the trick:
Code:
Untitled Trigger 004
    Events
        Time - Every 120.00 seconds of game time
    Conditions
    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
                        (Color of (Player((Integer A)))) Not equal to Brown
                    Then - Actions
                        Set UnitGroup = (Units owned by (Player((Integer A))) of type Footman)
                        Player - Add (Number of units in UnitGroup) to (Player((Integer A))) Current lumber
                        Custom script: call DestroyGroup(udg_UnitGroup)
                    Else - Actions
Just change Footman to your unit.
 

Astarael

New Member
Reaction score
0
Kazuga, can u pls state all variables that i need to create myself in your trigger? i've got no clue how to do it otherwise
 

Kazuga

Let the game begin...
Reaction score
110
Why would you do a loop from 1 to 12? Just do 1 to 11.....
Does it really matter..? Also I didn't remember if brown was the last color or not.

Edit:
>Kazuga, can u pls state all variables that i need to create myself in your trigger? i've got no clue how to do it otherwise
It's one unit group variable named UnitGroup.
 

Astarael

New Member
Reaction score
0
Omgsh this is needlessly annoying, whenever i do:

Code:
Custom script:   call DestroyGroup (udg_Reactors)

Then it comes up with an error every time and disables the trigger.
 

Kazuga

Let the game begin...
Reaction score
110
That would be because you misspell something. Are you sure it's the correct variable name?
 

Astarael

New Member
Reaction score
0
Yep. It also does it with maps i get from resource websites, when i copy the code over, it works in one map, and doesn't in the other. its infuriating me Roar! and i've made sure countless times that i have all the variables and units required.
 

Astarael

New Member
Reaction score
0
Mmm... odd... it says expected an array index, i hav no idea wat that does QQ
I just type [1] after it and it stopped crying.
Can someone pls explain to me how these arrays work?
 

Sevion

The DIY Ninja
Reaction score
413
Then that means you need it to be an array.... but why do you have it as an array in the first place? Both of our triggers don't need an array...

And don't double post.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Arrays are ways of storing many things into one variable, for example...


Hero[1] - This is a unit array, it can hold one unit per array number.
 

Kazuga

Let the game begin...
Reaction score
110
Arrays is the size of the variable. Let's say your creating a unit variable called Dummy. This can now store one unit data inside of it. But what if you want more variables with the same name? Then you make it into an array, meaning that it can contain more unit data. If you give it the size of 5, then it can store up to 5 different unit datas.
Dummy array [5]:
Dummy[1]
Dummy[2]
Dummy[3]
Dummy[4]
Dummy[5]
I'm not the best at explaining and I know I found it difficult to understand in the beginning to.. But simply all array does is setting the size of a variable. If it's not an array then it has the size of 1 and can contain one value only. If it has a bigger value it can contain that much different values.

(Though it is possible that the array starts and counts 0, not fully sure.)

Edit:
Beaten twice^^
 

Sevion

The DIY Ninja
Reaction score
413
You don't have to give it a size unless you're doing it in a struct, I think it was struct at least....

And that's in vJASS anyways. I doubt he's using vJASS if he's coding it in GUI.
 

Kazuga

Let the game begin...
Reaction score
110
You don't have to give it a size unless you're doing it in a struct, I think it was struct at least....

And that's in vJASS anyways. I doubt he's using vJASS if he's coding it in GUI.
Still, he wanted to know what arrays are. And arrays are used in all programming languages.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top