1. The contestants were to create water structures for the 20th Terraining Contest. Choose one in the public poll!
    Dismiss Notice
  2. Join other hivers in a friendly concept-art contest. The contestants have to create a genie coming out of its container. We wish you the best of luck!
    Dismiss Notice
  3. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  4. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  5. Check out the Staff job openings thread.
    Dismiss Notice

Level up hero using JASS

Discussion in 'Triggers & Scripts' started by FRENGERS, Apr 11, 2016.

  1. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    It has more than one hero :D :D
     
  2. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    • LevelUp Command
      • Events
        • Player - Player 1 (Red) types a chat message containing /levelup as An exact match
        • Player - Player 2 (Blue) types a chat message containing /levelup as An exact match
        • Player - Player 3 (Teal) types a chat message containing /levelup as An exact match
        • Etc...
      • Conditions
      • Actions
        • Set TempGroups[0] = (Units currently selected by (Triggering player))
        • Unit Group - Pick every unit in TempGroups[0] and do (Actions)
          • Loop - Actions
            • Set TempUnits[0] = (Picked unit)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • (TempUnits[0] is A Hero) Equal to True
              • Then - Actions
                • Hero - Set TempUnits[0] Hero-level to ((Hero level of TempUnits[0]) + 1), Show level-up graphics
              • Else - Actions
        • Custom script: call DestroyGroup(udg_TempGroups[0])


    This trigger will levelup all selected heroes.
    You can add a check that the owner of the selected unit is equal to the triggering player, but that is merely optional.

    There is no drawback from using GUI in this case except hyper-efficiency and the events (they can be made easily as generic player writes a string in JASS).
    Maybe the reputation as scripter is at stake but I doubt that anyone except yourself cares.
     
  3. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    It's been solved, but is my code above optimal??
     
  4. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    "No, I want it to level up selected Hero (if you can)"
    Optimal is hard to say in programming.
    But good enough is something that both are in this case.
     
  5. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    I mean, does it lacking?? (check every 0.1 second)
     
  6. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    lagging or leaking?
    Neither.
    Also, you dont check it every 0.1 second.
    You check it every time you write /levelup... which you cant write 10 times a second.
     
  7. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    oh lol sorry, didn't post it
    It's HERE
     
  8. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    Well... first of all, that is definately not what this thread was about.
    Secondly, you leak a unit group of all units on the map per 0.1 interval... which is horrible to even think about.
    And next to that, I assume that you are spamming creep respawns as soon as someone dies... I assume that that is not how it is supposed to be in every single way that I can see your code.
     
  9. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    haha yeah, wrong topic. Sorry.
    I was not focus, I think you were commenting on those thread, but it's not haha.
    lol

    Now, how about this??
    This works, but I dunno if there's any lacking :/ :/
    Code (vJASS):

    call TriggerRegisterAnyUnitEventBJ(THIS, EVENT_PLAYER_UNIT_DEATH)
     
     
  10. Wietlol

    Wietlol

    Joined:
    Aug 1, 2013
    Messages:
    4,653
    Resources:
    3
    Spells:
    3
    Resources:
    3
    I dont know how the system should be used but I assume that you shouldnt group all units in the entire map.

    Just do the Go function as action of the trigger and use the death event indeed.

    At least that is my guess.
     
  11. FRENGERS

    FRENGERS

    Joined:
    Aug 4, 2012
    Messages:
    971
    Resources:
    4
    Icons:
    3
    Maps:
    1
    Resources:
    4
    Alright, that makes sense now.
    I used those current code and I got this result: sometimes the hero won't revive.