• 🏆 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 increase Avatar ability Size

Status
Not open for further replies.
Level 4
Joined
Oct 9, 2013
Messages
84
Hello guys, alright, what I wanna do is to increase the size of the Avatar ability, it seems that I can increase the size that the ability of bloodlust gives but thing is, bloodlust ability increases speed only and not hp nor attack damage, so I wish to find a way to increase the size of the Avatar ability, but in Trigger editor I dont know how to do that.
 
Level 21
Joined
Nov 4, 2013
Messages
2,017
It's under Animation. It's called Animation - Change Unit Size and that's how it displays:

  • Animation - Change (Triggering unit)'s size to (100.00%, 100.00%, 100.00%) of its original size
Just change the 100.00% to higher values. Use an event and condition where you detect when the unit casts Avatar then use this action. Wait until the duration of Avatar ends and then set the size back to 100.00%.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Alas it is not that simple. For if two abilities change size (think of HotS shrink) then that would bug. You need a unit size management system to make sure that when a size change source expires, the unit gets set to the size it should be factoring in all size modifiers the unit has.

You will also need the system to handle "blend" so that the unit does not pop to full size but instead grows to it over time (like bloodlust and Avatar).
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
When the ability is cast, you increase the size by lets say 50%. (=150% or *1.5)
Then you add that unit to a unit group.
Every 0.03 seconds, you check if that unit still has the buff.
If not, reduce the size by 50% (divided by 1.5 NOT multiplied by 0.5)
Or just change it back to 100% of original size.

However, DSG made a good point.
If there are no other size changing abilities then this simple solution works.
If there are, then you do need something to use these methods better.

I just made this one... might be a pretty naive approach but it works... kind of.
JASS:
library ussSystem uses timerIndex
    //Requires:
    //  - Unit Indexer (Bribe)
    //  - TimerUtils (Vexorian)
    //  - TimerIndex (Wietlol)
    
    globals
        real USS_PERIOD_INTERVAL = 0.03
        
        real array unitSize_X
        real array unitSize_Y
        real array unitSize_Z
        
        unit array USS_TargetedUnit
        real array USS_SizeStep_X
        real array USS_SizeStep_Y
        real array USS_SizeStep_Z
        real array USS_RemainingTime
    endglobals
    
    function UnitChangeSize takes unit whichUnit, real sizeFactor_X, real sizeFactor_Y, real sizeFactor_Z returns nothing
        local integer id = GetUnitUserData(whichUnit)
        set unitSize_X[id] = unitSize_X[id] * sizeFactor_X
        set unitSize_Y[id] = unitSize_Y[id] * sizeFactor_Y
        set unitSize_Z[id] = unitSize_Z[id] * sizeFactor_Z
        call SetUnitScale(whichUnit, unitSize_X[id], unitSize_Y[id], unitSize_Z[id])
    endfunction
    function UnitChangeSizeSimple takes unit whichUnit, real sizeFactor returns nothing
        call UnitChangeSize(whichUnit, sizeFactor, sizeFactor, sizeFactor)
    endfunction
    
    function UnitSetSize takes unit whichUnit, real size_X, real size_Y, real size_Z returns nothing
        local integer id = GetUnitUserData(whichUnit)
        set unitSize_X[id] = size_X
        set unitSize_Y[id] = size_Y
        set unitSize_Z[id] = size_Z
        call SetUnitScale(whichUnit, size_X, size_Y, size_Z)
    endfunction
    function UnitSetSizeSimple takes unit whichUnit, real size returns nothing
        call UnitSetSize(whichUnit, size, size, size)
    endfunction
    
    function UnitChangeSize_Callback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer timerId = GetTimerData(t)
        
        call UnitChangeSize(USS_TargetedUnit[timerId], USS_SizeStep_X[timerId], USS_SizeStep_Y[timerId], USS_SizeStep_Z[timerId])
        set USS_RemainingTime[timerId] = USS_RemainingTime[timerId] - USS_PERIOD_INTERVAL
        
        if USS_RemainingTime[timerId] <= 0. then
            call ReleaseIndexedTimer(t)
        endif
        set t = null
    endfunction
    function UnitChangeSize_Period takes unit whichUnit, real sizeFactor_X, real sizeFactor_Y, real sizeFactor_Z, real duration returns nothing
        local timer t = NewIndexedTimer()
        local integer timerId = GetTimerData(t)
        local integer steps = R2I(duration/USS_PERIOD_INTERVAL)
        local real power = 1./I2R(steps)
        
        set USS_RemainingTime[timerId] = duration - ModuloReal(duration, USS_PERIOD_INTERVAL)
        set USS_SizeStep_X[timerId] = Pow(sizeFactor_X, power)
        set USS_SizeStep_Y[timerId] = Pow(sizeFactor_Y, power)
        set USS_SizeStep_Z[timerId] = Pow(sizeFactor_Z, power)
        set USS_TargetedUnit[timerId] = whichUnit
        
        call TimerStart(t, USS_PERIOD_INTERVAL, true, function UnitChangeSize_Callback)
        set t = null
    endfunction
    function UnitChangeSizeSimple_Period takes unit whichUnit, real sizeFactor, real duration returns nothing
        call UnitChangeSize_Period(whichUnit, sizeFactor, sizeFactor, sizeFactor, duration)
    endfunction
    
    function UnitSetSize_Callback takes nothing returns nothing
        local timer t = GetExpiredTimer()
        local integer timerId = GetTimerData(t)
        
        call UnitChangeSize(USS_TargetedUnit[timerId], USS_SizeStep_X[timerId], USS_SizeStep_Y[timerId], USS_SizeStep_Z[timerId])
        set USS_RemainingTime[timerId] = USS_RemainingTime[timerId] - USS_PERIOD_INTERVAL
        
        if USS_RemainingTime[timerId] < 0. then
            call ReleaseIndexedTimer(t)
        endif
        set t = null
    endfunction
    function UnitSetSize_Period takes unit whichUnit, real sizeFactor_X, real sizeFactor_Y, real sizeFactor_Z, real duration returns nothing
        local timer t = NewIndexedTimer()
        local integer timerId = GetTimerData(t)
        local integer unitId = GetUnitUserData(whichUnit)
        local integer steps = R2I(duration/USS_PERIOD_INTERVAL)
        local real power = 1./I2R(steps)
        
        set USS_RemainingTime[timerId] = duration - ModuloReal(duration, USS_PERIOD_INTERVAL)
        set USS_SizeStep_X[timerId] = Pow(sizeFactor_X/unitSize_X[unitId], power)
        set USS_SizeStep_Y[timerId] = Pow(sizeFactor_Y/unitSize_Y[unitId], power)
        set USS_SizeStep_Z[timerId] = Pow(sizeFactor_Z/unitSize_Z[unitId], power)
        set USS_TargetedUnit[timerId] = whichUnit
        
        call TimerStart(t, USS_PERIOD_INTERVAL, true, function UnitSetSize_Callback)
        set t = null
    endfunction
    function UnitSetSizeSimple_Period takes unit whichUnit, real sizeFactor, real duration returns nothing
        call UnitSetSize_Period(whichUnit, sizeFactor, sizeFactor, sizeFactor, duration)
    endfunction
    
endlibrary

//System-only function.
function UnitCreated takes nothing returns boolean
    local integer id = GetUnitUserData(udg_UDexUnits[udg_UDex])
    set unitSize_X[id] = 1.
    set unitSize_Y[id] = 1.
    set unitSize_Z[id] = 1.
    return false
endfunction

//===========================================================================
function InitTrig_USS_System takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterVariableEvent(t, "udg_UnitIndexEvent", EQUAL, 1.00)
    call TriggerAddCondition(t, Filter(function UnitCreated))
endfunction

I have added a test map with examples and the required libraries as an attachment.
It should be easy to use for everyone that is familiar with JASS or custom scripts.
For everyone else... good luck :D
Nah, I tried to make it as easy as possible.

(I assume that it is pretty impossible to get 100% accuracy on the periodical changes but I think that I got close enough to make it good.)
 

Attachments

  • Unit Size System 0.1.w3x
    27.3 KB · Views: 55
Level 24
Joined
Aug 1, 2013
Messages
4,657
But that doesnt allow you to remove it on dispels.
You still need the buff check (which can make the duration infinite because you already know when it ends) so you dont really use the TimedUnitScale.
However the GetUnitScale would indeed be very usefull in here.
 
Status
Not open for further replies.
Top