• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Change unit's size after buff

Status
Not open for further replies.
Level 3
Joined
Apr 12, 2015
Messages
19
Hey guys
I have a problem with a custom ability. I made a costum ability with a damage counter for one unit type with the system GDD(http://www.hiveworkshop.com/forums/spells-569/gui-friendly-damage-detection-v1-2-1-a-149098/)
If this unit did 300 damage he will use the ability avatar. I want to change the size a bit more so I add "change size" to the trigger. But I want that he will become small agian after that transformation. I used "wait game-time" but it doesn't work.
Here is the trigger:
  • Transformation
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamageSource is alive) Not equal to (GDD_DamageSource has buff Avatar)
      • (Unit-type of GDD_DamageSource) Equal to Exmaple Unit
    • Actions
      • Custom script: set udg_damage1 = udg_damage1 + udg_GDD_Damage
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • damage1 Greater than or equal to (Real(damage2))
        • Then - Actions
          • Set loc = (Position of GDD_DamageSource)
          • Custom script: call CreateTextTagLocBJ( "|c00000064"+ I2S(udg_damage2) +"now!|r" , udg_loc, 0, 10, 100, 100, 100, 0 )
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Custom script: set udg_damage2 = udg_damage2+100
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • damage1 Greater than or equal to 300.00
        • Then - Actions
          • Unit - Add Avatar Unit to GDD_DamageSource
          • Unit - Order GDD_DamageSource to Human Mountain King - Activate Avatar
          • Animation - Change GDD_DamageSource's size to (500.00%, 100.00%, 100.00%) of its original size
          • Unit - Remove Avatar Unit from GDD_DamageSource
          • Unit - Reset ability cooldowns for GDD_DamageSource
          • Custom script: set udg_damage1 = 0
          • Custom script: set udg_damage2 = 0
          • Wait 20.00 game-time seconds
          • Animation - Change GDD_DamageSource's size to (100.00%, 100.00%, 100.00%) of its original size
        • Else - Actions
Is there maybe a way to make a trigger that change the size after the buff "Avatar" expired?
Another problem is that during the "Avatar" form I can not change the order if he started to attack an enemy.
I also put an example map with that trigger for trying out
 

Attachments

  • GDD Change size after buff.w3x
    25 KB · Views: 64
Level 24
Joined
Aug 1, 2013
Messages
4,657
If you want a 100% working buff then you can use my effect over time system (link in signature)
Create an eot of the same duration as in the avatar in the object editor and use the same buff as in the object editor
when that eot is destroyed, you reduce the size again
it works even if the buff is dispelled during the effect... im actually not sure if the spell immunity of avatar also blocks dispells though
 
Level 3
Joined
Apr 12, 2015
Messages
19
First thanks for your replies.

Use a timer instead. Start timer and then use the event timer expires in another trigger. Waits don't work well unless used properly.
There is a problem with that solution. This "avatar" buff should work for every type of this unit. So if I will create a new trigger with timer expired I have to choose one unit( for example I save that unit in a variable in the trigger before). I can't use DGG_Damage_Source like in the trigger before.
But If 10 units of that type get that buff one after another it wont work for all 10 units but only for the last unit who got the buff.


If you want a 100% working buff then you can use my effect over time system (link in signature)
Create an eot of the same duration as in the avatar in the object editor and use the same buff as in the object editor
when that eot is destroyed, you reduce the size again
it works even if the buff is dispelled during the effect... im actually not sure if the spell immunity of avatar also blocks dispells though
I have a problem with the installation of your system. I always get compile errors when I try to enable the trigger "EOT System":
"Line 388 expected a variable name"
...
 
Level 3
Joined
Apr 12, 2015
Messages
19
Another problem is that during the "Avatar" form I can not change the order if he started to attack an enemy.
How does Avatar and Bloodlust affect trigger modifications to unit scale? Maybe there is a conflict (one cancels out the other).
oh yeah you're right. If I change the ability I am able to order the unit during the buff. Is there another buff that increase damage, defense and hit points?

But I still have the problem with changing the units size after that buff.
Maybe a bit weird question: Can I declare one local variable for two triggers? That this local variable is accessible for two triggers. So that I save the unit who changes the size in this local variable and set a timer - And in the other trigger I change this unit's size after timer expired
In other words: Can I save all units who changed their size into their own variable accessible for two triggers?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,229
Maybe a bit weird question: Can I declare one local variable for two triggers?
A local variable has a life cycle equal to that of the function call. The variable is de-allocated once the function returns. This is the case for all local variables in most languages.

That this local variable is accessible for two triggers.
JASS does not support references to variables so no it is not possible.

Can I save all units who changed their size into their own variable accessible for two triggers?
Yes you can by using an instancing system. You can pass the instance (index integer) between the two triggers. The vJASS struct is an example of an instancing system with regard to the compiled script it produces. This works up to 8192 instances simultaneously, with more having a performance penalty. After the instance is no longer required you recycle the index so unless all 8192 instances exist at the same time there is no chance of any error.

You could also use hashtables to get a virtually infinite instancing however it is slightly slower and will degrade in performance anyway for large numbers of stored mappings.
 
Level 3
Joined
Apr 12, 2015
Messages
19
The vJASS struct is an example of an instancing system with regard to the compiled script it produces.
How do I use structs? Is a struct comparable with an array?
I tried out to solve it with arrays and I have a strange problem now. Only the first two times the units who gets the buff will be small again. Here is the changed trigger:

  • Transformation
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
      • (GDD_DamageSource is alive) Not equal to (GDD_DamageSource has buff Avatar)
      • (Unit-type of GDD_DamageSource) Equal to Exmaple Unit
    • Actions
      • Custom script: set udg_damage1 = udg_damage1 + udg_GDD_Damage
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • damage1 Greater than or equal to (Real(damage2))
        • Then - Actions
          • Set loc = (Position of GDD_DamageSource)
          • Custom script: call CreateTextTagLocBJ( "|c00000064"+ I2S(udg_damage2) +"now!|r" , udg_loc, 0, 10, 100, 100, 100, 0 )
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Set the velocity of (Last created floating text) to 15.00 towards 90.00 degrees
          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
          • Custom script: set udg_damage2 = udg_damage2+100
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • damage1 Greater than or equal to 300.00
        • Then - Actions
          • Unit - Add Avatar Unit to GDD_DamageSource
          • Unit - Order GDD_DamageSource to Human Mountain King - Activate Avatar
          • Animation - Change GDD_DamageSource's size to (500.00%, 100.00%, 100.00%) of its original size
          • Unit - Remove Avatar Unit from GDD_DamageSource
          • Unit - Reset ability cooldowns for GDD_DamageSource
          • Custom script: set udg_damage1 = 0
          • Custom script: set udg_damage2 = 0
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Buff_i Equal to 50
            • Then - Actions
              • Custom script: set udg_Buff_i = 0
            • Else - Actions
          • Set Unit_Example[Buff_i] = GDD_DamageSource
          • Countdown Timer - Start Buff_Timer[Buff_i] as a One-shot timer that will expire in 19.70 seconds
          • Trigger - Add to Timer <gen> the event (Time - Buff_Timer[Buff_i] expires)
          • Custom script: set udg_Buff_i = udg_Buff_i +1
        • Else - Actions
  • Timer
    • Events
    • Conditions
    • Actions
      • Animation - Change Unit_Example[Buff_i2]'s size to (100.00%, 100.00%, 100.00%) of its original size
      • Custom script: set udg_Buff_i2 = udg_Buff_i2 +1
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Buff_i2 Equal to 50
        • Then - Actions
          • Custom script: set udg_Buff_i2 = 0
        • Else - Actions
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,229
Firstly you leak timer expiry events. Secondly your index recycle system is inefficient and bug prone. Thirdly I do not see where you create the timers to start in the first place (probably why it breaks after array index 2, a 1 sized GUI timer array).

Structs in vJASS simulate parallel arrays to hold data with an index recycle system. What you get is an array index which can be used to get all related data from each separate parallel array. This index can be recycled by deallocating it, usually placing it in some form of list. New indexes can be obtained via create, either removing from the recycle list or adding to end of the allocated index range.
 
Status
Not open for further replies.
Top