Triggered Auras

emootootoo

Top Banana
Reaction score
51
So I've been thinking of several ways to do custom auras, but they all seem to be pretty dodgy (never made 'em before).

I really can't be bothered doing it the ways I have thought of so far. So is there some easy way I am overlooking?

Basically all my aura has to do is give +spell damage and +% mana regen, both of which are variables stored on the heroes affected by the aura (the aura only affects heroes).

So is there some retardedly easy method I have not thought of, or is this going to be shitty and tedious.

The fact that I'm altering variables instead of just adding/removing abilities is what makes it the most tedious...
 

Fluffball

Well-Known Member
Reaction score
35
Well... auras usually give buffs right? So all you have to do is a If/Then/Else for each spell.

Or, if you are even lazier, you don't have to. (Unless you want a different value for different spells) Just make one trigger, asking whether the unit has the buff, and if it does do (More) damage to a target or (Less) damage to an area. Hope this helps.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
Check out Flare's Custom Auras, not sure if it's what you're searching for but it does the trick.
 

emootootoo

Top Banana
Reaction score
51
I thought you couldn't determine the level of a buff?

I already know how to make the aura, I just want to know the easiest way to know what level aura is currently active on separate units. This will allow me to change the bonuses they get accordingly.

I know I can use a dummy ability that is given to a unit whenever it comes in range of the hero, and level it accordingly, and if there is another aura active that is a higher level it doesn't do anything, if there is a lower one it levels it up. Then I can have the timer going that checks units without the buff in the group and removing the bonuses depending on the level of the ability.

Problems: would be 2 casters nearby, higher level one walks away, you still have the buff, so you keep the higher level aura because you don't ever lose your buff.

if I was to alter mana as a percentage, I would not know the exact amount of mana to remove because they may have gained or lost mana during the duration of the aura.

So this rules out using % on variables that can change from outside influences, which is bad.

So yeah, this is what is bugging me, it just seems like I'm overthinking it, or maybe I'm not.

Edit: so far my best solution is using a separate timer for each hero with the skill, but I also have to store units in an array instead of a group if I want to use % bonuses it would seem. My map will be too big for storing the mana amount using a units handle id with an array.

My half assed attempt. Still doesn't remember unique numbers for each unit though. This just adds +5 int (int being spell damage in my map) per level of the aura. Definately much more efficient ways to do this, but meh, I don't give a shit. :) This wouldn't be useful to anyone since it uses a fair bit of code specific to my map.

JASS:
scope Warmth
    globals
        private constant integer casterId   = 'H001'
        private constant integer auraId     = 'A004'
        private constant integer auraDummyId= 'A009'
        private constant integer buffId     = 'B000'
        private constant boolean stacks     = false
        private constant real    radius     = 732 // +32 range for center of units
        private integer data
        private group   g = CreateGroup()
        private group   noStack = CreateGroup()
    endglobals
    
    private struct Aura
        unit caster
        integer auraLevel
        integer cAuraLevel
        integer levelDiff = 0
        group leechers = CreateGroup()
    endstruct
        
    private function AuraBonuses takes unit u, integer dat, integer level, boolean add returns nothing
        local Attributes a = GetHeroUserData(u)
        local Aura d = dat
        local integer i = 1
        if not(add) then
            set i = -1
        endif
        ///////Insert Bonuses Below Here (Per level)//////
        
        call SetHeroInt(u,GetHeroInt(u,false)+2*level*i,true) // 2 Spell Damage (int) per level
        
        ///////////////////End Bonuses//////////////
    endfunction

////////////////////////////////NOTHING BELOW HERE NEEDS EDITING////////////////////////////////////
        
    private function AuraConditions takes nothing returns boolean
        return GetUnitTypeId(GetTriggerUnit()) == casterId
    endfunction

    private function AuraCallback takes nothing returns nothing
        local Aura d = data
        local unit u = GetEnumUnit()
        if d.cAuraLevel < GetUnitAbilityLevel(u,auraDummyId) then
            call GroupRemoveUnit(d.leechers,u)
        else
            if d.levelDiff > 0 then
                call AuraBonuses(u,d,d.levelDiff,true)
                call SetUnitAbilityLevel(u,auraDummyId,d.auraLevel)
            endif
            if IsUnitInGroup(u,g) == false and GetUnitState(u,UNIT_STATE_LIFE) > 0.45 then
                call AuraBonuses(u,d,d.auraLevel,false)
                call GroupRemoveUnit(d.leechers,u)
                if not(stacks) then // if stacking is off ...
                    call GroupRemoveUnit(noStack,u)
                endif
            endif
        endif
        set u = null
    endfunction
    
    private function AuraBuffFilter takes nothing returns boolean
        return GetUnitAbilityLevel(GetFilterUnit(),buffId) > 0 and IsUnitEnemy(GetFilterUnit(),FilterPlayer) == false and GetUnitState(GetFilterUnit(),UNIT_STATE_LIFE) > 0.45
    endfunction
    
    private function AuraCore takes nothing returns nothing
        local Aura d = ABCT_GetData()
        local integer level = GetHeroLevel(d.caster)/2
        local unit u
        //Spell Damage Level Update
        if level > d.auraLevel then
            set d.levelDiff = level - d.auraLevel
            set d.auraLevel = level
        endif
        set FilterPlayer = GetOwningPlayer(d.caster)
        set data = d
        call GroupEnumUnitsInRange(g,GetUnitX(d.caster),GetUnitY(d.caster),radius,Condition(function AuraBuffFilter))
        call ForGroup(d.leechers,function AuraCallback)
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            if IsUnitInGroup(u,d.leechers) == false and IsUnitInGroup(u,noStack) == false then
                call GroupAddUnit(d.leechers,u)
                if not(stacks) then // stacking or no stacking
                    call AuraBonuses(u,d,d.auraLevel,true)
                    call GroupAddUnit(noStack,u)
                    call UnitAddAbility(u,auraDummyId)
                    call SetUnitAbilityLevel(u,auraDummyId,d.auraLevel)
                endif
            endif
            if stacks == false and IsUnitInGroup(u,d.leechers) == false and IsUnitInGroup(u,noStack) == true and d.auraLevel > GetUnitAbilityLevel(u,auraDummyId) then
                call GroupAddUnit(d.leechers,u)
                call AuraBonuses(u,d,d.auraLevel - GetUnitAbilityLevel(u,auraDummyId),true)
                call SetUnitAbilityLevel(u,auraDummyId,d.auraLevel)
            endif
            call GroupRemoveUnit(g,u)
        endloop
        set d.levelDiff = 0
        set d.cAuraLevel = d.auraLevel
    endfunction

    private function AuraActions takes nothing returns nothing
        local Aura d = Aura.create()
        local integer level = GetHeroLevel(d.caster)
        set d.caster = GetTriggerUnit()
        if level > 1 then
            set d.auraLevel = level/2
        else
            set d.auraLevel = 1
        endif
        call ABCT_Start(function AuraCore,d,1.5)
    endfunction

    function InitTrig_Warmth takes nothing returns nothing
        set gg_trg_Warmth = CreateTrigger()
        call TriggerRegisterEnterRectSimple(gg_trg_Warmth,GetPlayableMapRect())
        call TriggerAddCondition(gg_trg_Warmth,Condition(function AuraConditions))
        call TriggerAddAction(gg_trg_Warmth,function AuraActions)
    endfunction
endscope
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top