1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Need Info] How to select the player variables

Discussion in 'StarCraft II Modding' started by salvadorc17, Mar 3, 2016.

  1. salvadorc17

    salvadorc17

    Joined:
    Mar 24, 2013
    Messages:
    166
    Resources:
    0
    Resources:
    0
    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..
     
  2. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,596
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    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.
     
  3. salvadorc17

    salvadorc17

    Joined:
    Mar 24, 2013
    Messages:
    166
    Resources:
    0
    Resources:
    0
    Ok thanks for your help, can you give me some example, dont understand very well which values to use (owner of unit??)
     
  4. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,596
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    The following GUI shows how one could do it.
    Code (Text):

        Conditions
            (Owner of (Killing unit)) == 1
     
    This could easily be modified to use an integer variable.
    Code (Text):

        Conditions
            (Owner of (Killing unit)) == anintvar
     
    Below is the following Galaxy text this produces...
    Code (Text):

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