getting the level of a buff

Nivius

TH.net Regular
Reaction score
5
Change your Spiritual Aura trigger into this:

Code:
Spiritual Aura 
Events 
Conditions 
((Damage source) is A Hero) Equal to True 
Or - Any (Conditions) are true 
Conditions 
((Damage source) has buff Spiritual Aura (lvl1)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl2)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl3)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl4)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl5)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl6)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl7)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl8)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl9)) Equal to True 
Actions 
Unit - Set mana of (Damage source) to ((Mana of (Damage source)) + (((Damage taken) / 100.00) x [B](Level of *ability* for (Damage source))[/B]))

That doesn't matter.
that dont work. the ability is only gona exist on 1 unit and the ability is an aura. so i cannot use "(Level of *ability* for (Damage source))" as this indicates that the unit that does the damage have the ability. witch he prob do not have. if it was possible to make that line u made to instead somehow get the level of the skill to change the amount of mana stolen

I'm kinda starting to think if i cannot make the ability when leveled to put the level of the ability into an int and then i extract that value every time someone attack?

I'm still interested in a more effective code that works, also i kinda need to get it working for ranged units :)
 

Exide

I am amazingly focused right now!
Reaction score
448
As XeNiM666 already stated, you can:
GetUnitAbilityLevel( GetTriggerUnit(), buffcode )
To make it easy on you:

Code:
Spiritual Aura 
Events 
Conditions 
((Damage source) is A Hero) Equal to True 
Or - Any (Conditions) are true 
Conditions 
((Damage source) has buff Spiritual Aura (lvl1)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl2)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl3)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl4)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl5)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl6)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl7)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl8)) Equal to True 
((Damage source) has buff Spiritual Aura (lvl9)) Equal to True 
Actions 
Custom script   set udg_IntegerVariable = GetUnitAbilityLevel( GetEventDamageSource(), [B]buffcode[/B] )
Unit - Set mana of (Damage source) to ((Mana of (Damage source)) + (((Damage taken) / 100.00) x IntegerVariable)

Where buffcode = the rawcode of your buff. For example 'B001'
 

Nivius

TH.net Regular
Reaction score
5
im ust prob being an idiot now but i dont know anything avour custom scripts, anyway, this code i made gave me an error, it expected somthing and that disabled my trigger

Error:
Code:
trigger                 gg_trg_Spiritual_aura2     = null
endglobals

function InitGlobals takes nothing returns nothing
    local integer i = 0
    set udg_Temp_Group = CreateGroup()
    set i = 0
    loop
        exitwhen (i > 36)
        set udg_White_Pick_Taken[i] = 0
        set i = i + 1
    endloop

    set udg_Group = CreateGroup()
    set i = 0
    loop
        exitwhen (i > 1)
        set udg_Reincarnationlvl[i] = 0
        set i = i + 1
    endloop

    set udg_Repicktime = CreateTimer()
    set udg_Stopper = 0
    set udg_TEMPREAL = 0
    set udg_SlamVari = 0
    set udg_WSpiritualAuralvl = 0
    set i = 0
    loop
        exitwhen (i > 36)
        set udg_Black_Pick_Taken[i] = 0
        set i = i + 1
    endloop

    set udg_Loop = 0
    set udg_tmpInteger = 0
    set i = 0
    loop
        exitwhen (i > 2)
        set udg_playerrepick[i] = 0
        set i = i + 1
    endloop

    set udg_RepickLoop = 0
    set udg_DamageDealt = 0
    set udg_tempgroup = CreateGroup()
    set udg_IntegerVariable = 0
endfunction

function Trig_Spiritual_aura2_Conditions takes nothing returns boolean
    if ( not ( IsUnitType(GetEventDamageSource(), UNIT_TYPE_HERO) == true ) ) then
        return false
    endif
    if ( not ( UnitHasBuffBJ(GetEventDamageSource(), 'B00M') == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Spiritual_aura2_Actions takes nothing returns nothing
    set udg_IntegerVariable = GetUnitAbilityLevel( GetEventDamageSource(), B00M )
    call SetUnitManaBJ( GetEventDamageSource(), ( GetUnitStateSwap(UNIT_STATE_MANA, GetEventDamageSource()) + ( ( GetEventDamage() / 100.00 ) * udg_IntegerVariable ) ) )
endfunction

//===========================================================================
function InitTrig_Spiritual_aura2 takes nothing returns nothing
    set gg_trg_Spiritual_aura2 = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Spiritual_aura2, Condition( function Trig_Spiritual_aura2_Conditions ) )
    call TriggerAddAction( gg_trg_Spiritual_aura2, function Trig_Spiritual_aura2_Actions )
endfunction

code:
Trigger:
  • Spiritual aura2
    • Events
    • Conditions
      • ((Damage source) is A Hero) Equal to True
      • ((Damage source) has buff Spiritual Aura (lvl1)) Equal to True
    • Actions
      • Custom script: set udg_IntegerVariable = GetUnitAbilityLevel( GetEventDamageSource(), B00M )
      • Unit - Set mana of (Damage source) to ((Mana of (Damage source)) + (((Damage taken) / 100.00) x IntegerVariable))

IntegerVariable = real
i made the skill to only have buff lvl 1 (got 9 buffs for previous version of the skill)
also i connected the original activate spir aura trigger to this one.

whats the problem this time :(
 

Exide

I am amazingly focused right now!
Reaction score
448
You should use JASS-tags for JASS code.

I don't know what your first function (InitGlobals) does in this trigger, so I'm just gonna ignore it.
I took the rest of your trigger, optimized it, replaced the globals with locals, and fixed the typo error:

JASS:

function Trig_Spiritual_aura2_Conditions takes nothing returns boolean
    return (IsUnitType(GetEventDamageSource(), UNIT_TYPE_HERO) == true) and (GetUnitAbilityLevel(GetEventDamageSource(), 'B00M') > 0)
endfunction

function Trig_Spiritual_aura2_Actions takes nothing returns nothing
    local integer i = GetUnitAbilityLevel( GetEventDamageSource(), 'B00M')
    local unit u = GetEventDamageSource()
    local real managain = (GetEventDamage() / 100) * i
    
    call SetUnitState(u, UNIT_STATE_MANA, managain)
    
    set u = null
endfunction

//===========================================================================
function InitTrig_Spiritual_aura2 takes nothing returns nothing
    set gg_trg_Spiritual_aura2 = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Spiritual_aura2, Condition( function Trig_Spiritual_aura2_Conditions ) )
    call TriggerAddAction( gg_trg_Spiritual_aura2, function Trig_Spiritual_aura2_Actions )
endfunction


What you had done wrong: You wrote B00M, instead of 'B00M', for buffcode.
 

Nivius

TH.net Regular
Reaction score
5
You should use JASS-tags for JASS code.

I don't know what your first function (InitGlobals) does in this trigger, so I'm just gonna ignore it.
I took the rest of your trigger, optimized it, replaced the globals with locals, and fixed the typo error:

JASS:
function Trig_Spiritual_aura2_Conditions takes nothing returns boolean
    return (IsUnitType(GetEventDamageSource(), UNIT_TYPE_HERO) == true) and (GetUnitAbilityLevel(GetEventDamageSource(), 'B00M') > 0)
endfunction

function Trig_Spiritual_aura2_Actions takes nothing returns nothing
    local integer i = GetUnitAbilityLevel( GetEventDamageSource(), 'B00M')
    local unit u = GetEventDamageSource()
    local real managain = (GetEventDamage() / 100) * i
    
    call SetUnitState(u, UNIT_STATE_MANA, managain)
    
    set u = null
endfunction

//===========================================================================
function InitTrig_Spiritual_aura2 takes nothing returns nothing
    set gg_trg_Spiritual_aura2 = CreateTrigger(  )
    call TriggerAddCondition( gg_trg_Spiritual_aura2, Condition( function Trig_Spiritual_aura2_Conditions ) )
    call TriggerAddAction( gg_trg_Spiritual_aura2, function Trig_Spiritual_aura2_Actions )
endfunction


What you had done wrong: You wrote B00M, instead of 'B00M', for buffcode.
oh ^^ t, im gona test it, il be back whit edit to tell you how it whent

*edit*

now it dont work at all :/
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top