Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Hero Size Increase after Level UP

Discussion in 'World Editor Help Zone' started by Mechcash, Aug 20, 2020.

  1. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    Hello guys,

    as mentioned in the title Iam looking for a way to increase the size of heroes every time they level up and also, if possible, reduce their movement speed with every level.

    I only found the following:

    • Untitled Trigger 002
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Animation - Change (Leveling Hero)'s size to (110.00%, 110.00%, 110.00%) of its original size


    the problem here is, that the size increase only happens once, I'd like to find a way where the hero grows with every level not just once.

    Thanks in advance.
     
  2. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,455
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    You have to set a variable, ex HERO_SIZE[1] = (HERO_SIZE[1] + 10)
    [With HERO_SIZE[X] being default 100.]
    And then set the fields to match.
     
  3. [db]east

    [db]east

    Joined:
    Feb 27, 2019
    Messages:
    144
    Resources:
    0
    Resources:
    0
    Alternatively

    Animation - Change (Triggering unit)'s size to ((90.00 + ((Real((Level of (Triggering unit)))) x 10.00))%, ((90.00 + ((Real((Level of (Triggering unit)))) x 10.00))%, ((90.00 + ((Real((Level of (Triggering unit)))) x 10.00))%) of its original size

    You could add an upgrade that increases movement speed to each hero and set the level to -1 each time the hero levels up. Starting the upgrade at max level.
     
  4. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    • Untitled Trigger 002
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Set VariableSet HERO_SIZE[1] = HERO_SIZE[(1 + 10)]


    iam not good with variables and kinda stuck. I made a custom variable but now I don't know where to go from here on.
     
  5. Devalut

    Devalut

    Joined:
    Feb 9, 2009
    Messages:
    1,455
    Resources:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    3
    Good so far, the array is incase you want more than 1 hero with it, so either remove it or set it to 1.

    upload_2020-8-20_11-55-48.png
    upload_2020-8-20_11-56-21.png
     
  6. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    • Untitled Trigger 002
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Set VariableSet HERO_SIZE[1] = 100.00
        • Animation - Change (Triggering unit)'s size to ((HERO_SIZE[1] + 30.00)%, (HERO_SIZE[1] + 30.00)%, (HERO_SIZE[1] + 30.00)%) of its original size


    I now have this. I know something is missing, but I dont know what xD The unit is still only growing once and then stays at that size after every consecutive level up. Could you help out ?
     
    Last edited: Aug 20, 2020
  7. J2Krauser

    J2Krauser

    Joined:
    Jul 31, 2020
    Messages:
    78
    Resources:
    0
    Resources:
    0
    I attached a GUI/MUI solution if you by chance want to make it MUI in the future. Well, as GUI as I was willing to let it be.
     

    Attached Files:

  8. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    Thank you! Say, is there a way to increase the size gained and the max level where the size gain stops? (can I go over level 10?). :)
     
  9. J2Krauser

    J2Krauser

    Joined:
    Jul 31, 2020
    Messages:
    78
    Resources:
    0
    Resources:
    0
    I didn't specify anything in regards to limiting it only up to level 10. If you go into Advanced → Gameplay Constants..., and scroll down till Hero Maximum Level to change it to whatever value you'd like, it'll just keep increasing the size up to that level. Also, generally speaking, the solution you see there is pretty barebones, and its implementation largely depends on the environment, as in, what exactly your map is like.
     
  10. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    Funny enough, now it seems like the heroes are shrinking on my map xD I tried to implement your triggers, but now the heroes shrink with their first level up, then they start growing ...do you have an idea what could cause this issue?
     
  11. J2Krauser

    J2Krauser

    Joined:
    Jul 31, 2020
    Messages:
    78
    Resources:
    0
    Resources:
    0
    Knowing what I created, the one thing that could cause heroes to become extremely tiny on their first level up would be the initialization going wrong. Because then their size would essentially go to 10% first, and start going up from there.
     
  12. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    541
    Resources:
    0
    Resources:
    0
    I think you don't know about somethings apart using triggers, I know @J2Krauser solved your problem, but I will say you what is wrong:
      • Animation - Change (Leveling Hero)'s size to (110.00%, 110.00%, 110.00%) of its original size
      only happen once because there it says "original size" not "actual size", and if this was the case, the unit will grow exponentially not linearly if this is you want.
    1. For you know "assing variable", you have to do something like this
      • Set Your_Variable=100
      And if you wanna make it increase linearly do:
      • Set Your_Variable=Your_Variable+10
      Here the variable becomes its previous value +10, exm: If Your_Variable is 100 now becomes 110, if it is 110 now becomes 120,if it is 120 now becomes 130. And if you wanna make it increase exponentially do:
      • Set Your_Variable=Your_Variable*1.10
      Here the variable becomes the 110% of its previous value, exm: If Your_Variable is 100 now becomes 110, if it is 110 now becomes 121, if it is 121 now becomes 133.1.
     
  13. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    Thank you for your help! I understand the problem, but I can't find a way to use the "current size" instead of the "original size". I tried to use your Variables, but it still uses the original size for growing.

    • Untitled Trigger 002
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Set VariableSet HERO_SIZE = 100.00
        • Set VariableSet HERO_SIZE_LINEAR = (HERO_SIZE + 10.00)
        • Animation - Change (Triggering unit)'s size to (HERO_SIZE_LINEAR%, HERO_SIZE_LINEAR%, HERO_SIZE_LINEAR%) of its original size


    Sorry to keeep on bothering you guys, it would be awesome to get this working.
     
  14. J2Krauser

    J2Krauser

    Joined:
    Jul 31, 2020
    Messages:
    78
    Resources:
    0
    Resources:
    0
    • Untitled Trigger 002
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Set VariableSet HERO_SIZE_LINEAR = 100.00
        • Set VariableSet HERO_SIZE_LINEAR = (HERO_SIZE_LINEAR + 10.00)
        • Animation - Change (Triggering unit)'s size to (HERO_SIZE_LINEAR%, HERO_SIZE_LINEAR%, HERO_SIZE_LINEAR%) of its original size


    And obviously you don't set HERO_SIZE_LINEAR back to 100 on every level up like it's shown in the trigger, you set it to 100 initially, and that's it. And this will only work for one hero unit.
     
  15. Whitewolf8

    Whitewolf8

    Joined:
    Aug 31, 2011
    Messages:
    289
    Resources:
    6
    Models:
    1
    Maps:
    4
    Tutorials:
    1
    Resources:
    6
    This should work, still a bit of a novice at leak checking so uh... keep that possibility in mind, maybe?
    • Melee Initialization
      • Events
        • Unit - A unit Gains a level
      • Conditions
        • (Hero level of (Triggering unit)) Less than or equal to 10
      • Actions
        • Set Real = (90.00 + (10.00 x (Real((Hero level of (Triggering unit))))))
        • Animation - Change (Triggering unit)'s size to (Real%, Real%, Real%) of its original size

    The condition is for checking when the growth will stop.
     
  16. Mechcash

    Mechcash

    Joined:
    May 30, 2018
    Messages:
    246
    Resources:
    0
    Resources:
    0
    This works like a charm, thank you very much :)!
     
  17. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    26,124
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I think the size action sets the models absolute scaling and not its relative scaling. As such if a hero is set to a scale of 200% in the object editor they will shrink on the first level up down to 110%.
     
  18. Uncle

    Uncle

    Joined:
    Aug 10, 2018
    Messages:
    2,362
    Resources:
    0
    Resources:
    0
    Yeah, you're correct.

    Luckily, with the recent patches (I think 1.31+) there's now the option to adjust a unit's Scaling Value directly, which resolves this issue.

    For anyone that's interested here's how you can do it:
    • Setup Base Scale
      • Events
        • Unit - A unit enters (Entire map)
      • Conditions
      • Actions
        • Set VariableSet cv = (Custom value of (Triggering unit))
        • Set VariableSet Scale_Base[cv] = (Unit: (Triggering unit)'s Real Field: Scaling Value ('usca'))
        • Set VariableSet Scale_Current[cv] = Scale_Base[cv]

    • Increase Size
      • Events
        • Unit - A unit Gains a level
      • Conditions
      • Actions
        • Set VariableSet cv = (Custom value of (Triggering unit))
        • Set VariableSet Scale_Current[cv] = (Scale_Current[cv] + 0.10)
        • Set VariableSet Scale_Percentage = (Scale_Current[cv] x 100.00)
        • Animation - Change (Triggering unit)'s size to (Scale_Percentage%, Scale_Percentage%, Scale_Percentage%) of its original size

    SomeUnit represents the unit that you want to reset the size of.
    • Reset Size
      • Events
        • Player - Player 1 (Red) types a chat message containing reset as An exact match
      • Conditions
      • Actions
        • Set VariableSet cv = (Custom value of SomeUnit)
        • Set VariableSet Scale_Current[cv] = Scale_Base[cv]
        • Set VariableSet Scale_Percentage = (Scale_Current[cv] x 100.00)
        • Animation - Change SomeUnit's size to (Scale_Percentage%, Scale_Percentage%, Scale_Percentage%) of its original size
    Variables: Scale_Base = Real (Array), Scale_Current = Real (Array), Scale_Percentage = Real

    Requires a Unit Indexer (link in my signature)

    How it works:
    When a unit enters the map we immediately save it's Scaling Value (This is the value listed in the Object Editor -> Paladin has a 1.20 scaling value for example) in the variable Scale_Base. This way we will always have access to that unit's base Scaling Value at any given time. Then we set Scale_Current to be equal to Scale_Base, this is the value that we increase/decrease whenever we want to re-size our unit. Note that you'll have to do this process differently for pre-placed units since they won't "Enter the map", Pick every unit in playable map area works.

    How the math works for scaling: 0.01 represents 1%, so increasing Scale_Current by 0.10 actually increases the unit's size by 10%. The Paladin has a base Scaling Value of 1.20, meaning he's actually 20% larger than his model's default size. If you increase 1.20 by 0.10 you get 1.30, which makes the Paladin 30% larger than his default size.

    You'll see that I multiply Scale_Current by 100.00, this is because Animation - Change Unit Size works with %, so if we plug in 1.30 the unit would actually shrink down to 1.30%. The solution, multiply the Scaling Value by 100.00 and use that value as the % instead.

    1.30*100.00 = 130.00, meaning our unit's size would be set to 130%.

    @Whitewolf8
    There's no leaks in your trigger.

    The common leaks occur when creating Points (Position of triggering unit, Target point of ability being cast, etc...), when creating Unit Groups (Pick every unit), and Player Groups (Pick every player). An exception for Player Groups is "Pick every player in All Players" as it doesn't leak.

    Special Effects leak too, so make sure to use "Destroy last created special effect" when using them. Setting the special effect as a variable and then destroying it at a later time works as well. This is true for the other types of leaks as well.

    So the main culprits will be Points, Groups, and Special Effects. If you don't see the words "Position", "Point", "Pick every unit/player", in your triggers then you're probably safe from leaks.

    Note that when cleaning up these leaks with Custom script, you'll see the terminology change. Points are considered Locations (call RemoveLocation) and Player Groups are considered Forces (call DestroyForce).
     

    Attached Files:

    Last edited: Aug 21, 2020
  19. HerlySQR

    HerlySQR

    Joined:
    Jun 26, 2020
    Messages:
    541
    Resources:
    0
    Resources:
    0
    • Set VariableSet HERO_SIZE = 100.00
    • Set VariableSet HERO_SIZE_LINEAR = (HERO_SIZE + 10.00)

    This is because you are using 2 different variables "HERO_SIZE" and "HERO_SIZE_LINEAR", the variable "HERO_SIZE" remains the same, because its not changing, therefore equally "HERO_SIZE_LINEAR", and with the action:
    • Set VariableSet HERO_SIZE = 100.00

    You are returning it to value 100 every time, the correct will be:
    Code (Text):
    Initial value HERO_SIZE = 100.00
    • Set VariableSet HERO_SIZE = (HERO_SIZE + 10.00)

    Now "HERO_SIZE" is changing.