• 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 Info] How to select the player variables

Status
Not open for further replies.
Level 6
Joined
Mar 24, 2013
Messages
170
Hi, im creating new maps and dont know how to use player variable there is no option in editor, what i want to achieve is to assing the owner of unit to the respective player.

EG:
-Owner of killing unit == Player 1 or player variable 1.

Need info, can you help me..
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
There is no such thing as a "player variable". All players are represented as an integer (int) representing their slot number. The first human player and test player is player 1. The last one I recall is number 15. Number 0 is reserved for a neutral non-human player. The constant of -1 is used by some natives to represent "any player" while in others where that does not make sense it will throw an out of bounds error. Any other integer value is invalid when used as a player.

To test ownership of a unit you can either use an integer comparison to compare the owner player number with an integer expression for a single player test or you can use a boolean comparison to test if the owner of the unit is inside a player group for a multiple player comparison.
 
Level 6
Joined
Mar 24, 2013
Messages
170
To test ownership of a unit you can either use an integer comparison to compare the owner player number with an integer expression for a single player test or you can use a boolean comparison to test if the owner of the unit is inside a player group for a multiple player comparison.

Ok thanks for your help, can you give me some example, dont understand very well which values to use (owner of unit??)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
The following GUI shows how one could do it.
Code:
    Conditions
        (Owner of (Killing unit)) == 1
This could easily be modified to use an integer variable.
Code:
    Conditions
        (Owner of (Killing unit)) == anintvar

Below is the following Galaxy text this produces...
Code:
    // Conditions
    if (testConds) {
        if (!((UnitGetOwner(libNtve_gf_KillingUnit()) == lv_anintvar))) {
            return false;
        }
    }

Do note that to make the condition you will need to select "Comparison" as the route element. You can then select any type as the first argument, in this case an integer. The second argument has to always be the same type as the first argument.
 
Status
Not open for further replies.
Top