1. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  2. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  3. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  4. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  5. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  6. Do you hear boss music? It's the 17th Mini Mapping Contest!
    Dismiss Notice
  7. 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.

[General] Hero costs

Discussion in 'World Editor Help Zone' started by Watcher, Mar 6, 2018.

  1. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Hi guys,

    How to make that 1st hero u create costs nothing, just like in the melee maps?

    PS: I removed "Create starting units trigger" for gameplay purposes
     
  2. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    Create starting units contains amongst many other code this line:
    call SetPlayerState(whichPlayer, PLAYER_STATE_RESOURCE_HERO_TOKENS, bj_MELEE_STARTING_HERO_TOKENS)

    Use a custom script inside a loop to apply it for every player:
    • For each (Integer A) from 0 to 11, do (Actions)
      • Loop - Actions
        • Custom script: call SetPlayerState(Player(bj_forLoopAIndex), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)
     
  3. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Can I use this custom script inside a player group loop, since I already have player group loop for some other stuffs?

    And I just have to replace "forLoopAIndex" with my variable or?
     
  4. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    605
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Yes, just don't forget the "udg_" before the nsan
     
  5. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    So I tried by typing this:

    "call SetPlayerState(Player(bj_udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
    "call SetPlayerState(Player(udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
    "call SetPlayerState(Force(udg_player_group), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"

    And every time it gives me "Expected a name" error

    Dunno what's wrong... :/
     
  6. Jampion

    Jampion

    JASS Reviewer

    Joined:
    Mar 25, 2016
    Messages:
    1,287
    Resources:
    0
    Resources:
    0
    The first argument must be a player expression. You can use a player variable, the Player(int) function to convert an integer to a player or the GetEnumPlayer() function to get the picked player.
    You said you want to use it in a player group, so you should use:

    "call SetPlayerState(GetEnumPlayer(), PLAYER_STATE_RESOURCE_HERO_TOKENS, 1)"
     
  7. DaneTheBeast

    DaneTheBeast

    Joined:
    Dec 11, 2014
    Messages:
    605
    Resources:
    1
    Maps:
    1
    Resources:
    1
    (Player(bj_udg_player_group) to (Player(udg_player_group)

    where udg_player_group is an integer

    Edit: Jampion explained it
     
    Last edited: Mar 7, 2018
  8. Watcher

    Watcher

    Joined:
    Aug 31, 2011
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Thank you guys, now it works! :D

    +rep for both