• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

How to make a unit bigger every second?

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2008
Messages
253
I am wondering how I can make a unit get bigger every second, just like the EMP spell of invoker (in dota) but I can't figure out how :sad:
 
Level 17
Joined
Jun 12, 2007
Messages
1,261
This is basicly what u need.

  • GROW BABY GROW
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Blizzard
    • Actions
      • Animation - Change (Casting unit)'s size to (101.00%, 101.00%, 101.00%) of its original size
      • Wait 2.00 seconds
      • Animation - Change (Casting unit)'s size to (102.00%, 102.00%, 102.00%) of its original size
      • Wait 2.00 seconds
      • Animation - Change (Casting unit)'s size to (103.00%, 103.00%, 103.00%) of its original size
      • Wait 2.00 seconds
      • Animation - Change (Casting unit)'s size to (104.00%, 104.00%, 104.00%) of its original size
      • Wait 10.00 seconds
      • Animation - Change (Casting unit)'s size to (100.00%, 100.00%, 100.00%) of its original size
This is a realy basic trigger though, I gues it could be done in a better way but I don't know about it.
U can use this for starters and throw in special effects and I gues you need to store the unit into a variable to make it a good spell. :grin:
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
This is not a better solution, just corrected the one above:
  • Enlarge Unit
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Blizzard
    • Actions
      • Custom Script: local unit tempUnit = GetSpellAbilityUnit()
      • Custom Script: local real scale
      • For each (Integer A) from 1 to 5
        • Loop - Actions
          • Custom Script: set scale = 100 + ( I2R ( GetForLoopIndexA() ) * 10 )
          • Custom Script: call SetUnitScalePercent( tempUnit, scale, scale, scale )
          • Wait 1.00 seconds
It works for one unit at time
 
Last edited:
Level 17
Joined
Jun 12, 2007
Messages
1,261
Whoa that kinda looks realy complicated, could you like explain it a bit?
What the custum scripts do?

Btw, I can edit my version a bit so it works for multiple heroes/ but only for one per player.
This is the version that has a variable.

  • Grow Red
    • Events
      • Unit - A unit owned by Player 1 (Red) Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Blizzard
    • Actions
      • Set PlayerRedHero = (Casting unit)
      • Animation - Change PlayerRedHero's size to (101.00%, 101.00%, 101.00%) of its original size
      • Wait 2.00 seconds
      • Animation - Change PlayerRedHero's size to (102.00%, 102.00%, 102.00%) of its original size
      • Wait 2.00 seconds
      • Animation - Change PlayerRedHero's size to (103.00%, 103.00%, 103.00%) of its original size
      • Wait 10.00 seconds
      • Animation - Change PlayerRedHero's size to (100.00%, 100.00%, 100.00%) of its original size
Now you have to make one of these for each player.
You can like assign the variable to the unit when it's trained aswell and do it with the second and thrid hero aswell, but that is only if you are planning to have more then 1 hero I gues.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
The scripts create local variables for the casting unit, and the percentage size.
Then the cycle enlarges the unit five times, increasing the size a bit every time. "call SetUnitScalePercent()" is equivalent of "Animation - set unit size" and it's parameters are:
1. the casting unit, stored in local variable (tempUnit)
2.-4. unit new size (scale), calculated by the formula (100 + 10*A) (FOR cycle runs five times, each time increasing A by 1)

Your version would definitely work, too, but you have to write "Set unit size" and "wait" three times, which just isn't nice :grin:.
 
Level 5
Joined
Feb 5, 2008
Messages
109
  • grow
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your Ability
    • Actions
      • Custom script: local real udg_real
      • Set real = 100.00
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set real = (real + 1.00)
          • Animation - Change (Triggering unit)'s size to (real%, real%, real%) of its original size
          • Wait 1.00 seconds
That's the way I would do it. I also tested it and it works. =)

You don't need a local variable for the unit since triggering unit always refers to the unit actually casting the spell.
Define a normal real variable (in this example called "real") first, then you just need one custom script line declaring the global variable to be local (udg_ is the prefix for global variables).
You can also replace the "from 1 to 5" to "from 1 to (Level of (Ability being cast) for (Triggering unit))" so it grows more depending on the level of the ability for the unit.

Note: If you cast your ability multiple times, the unit's size will always be set to it's original size and be increased again.
 
Last edited:
Level 7
Joined
Jul 9, 2008
Messages
253
Ok, thanks for all the responds (and they are great) but is it also possible to cast a spell, create a dummy unit (like a ball or something) and make that one bigger every second?
 
Level 5
Joined
Feb 5, 2008
Messages
109
No big difference, but you need a local unit variable.

  • grow
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your Ability
    • Actions
      • Custom script: local real udg_real
      • Custom script: local unit udg_unit
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Preset for building adjustment degrees
      • Set unit = (Last created unit)
      • Set real = 100.00
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set real = (real + 1.00)
          • Animation - Change unit's size to (real%, real%, real%) of its original size
          • Wait 1.00 seconds
If you want to prevent memory leaks, you'll have to edit it a bit, but I think you can do this on your on. (use this tutorial or search via google)
 
Level 7
Joined
Jul 9, 2008
Messages
253
When i first looked at it i thought; this is going to be it! So i made it, pressed the test button, used the spell and BOOM, fatal error >_>
 
Level 5
Joined
Feb 5, 2008
Messages
109
Wow, that's kind of ... w000000t? I mean I just changed a few lines, so I didn't test that one too. Let's see ...

[edit] Obviously it's because of defining the local unit variable. I fixed it by using custom script, but don't ask me why this works ... Now you don't need a global unit variable. I also changed the additional size so you can see whether it works.

But I found out that the dummies grow sometimes more, sometimes less. Professional help is needed.

  • grow
    • Events
      • Unit - A unit starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your Ability
    • Actions
      • Custom script: local real udg_real
      • Custom script: local unit u
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Preset for building adjustment degrees
      • Custom script: set u = GetLastCreatedUnit()
      • Set real = 100.00
      • For each (Integer A) from 1 to 5, do (Actions)
        • Loop - Actions
          • Set real = (real + 10.00)
          • Custom script: call SetUnitScalePercent( u, udg_real, udg_real, udg_real )
          • Wait 1.00 seconds
 
Last edited:
Status
Not open for further replies.
Top