A non Incrementing Problem

Somatic

You can change this now in User CP.
Reaction score
84
I am making a spell which once casted, will cause enemies in the region to be added with the ability "Fatigue" Based off Tornado (Slow Aura). And when 4 seconds is hit, it will increases the level of that added ability by 1, to a maximun of 5 and then removed from the targeted unit. But after working so long i cant seem to fix it at all.

Problem Faced : Units does get the Spell added, but the level does not get increased.

Could anyone here kindly look at it and see for any mistake? Thx. Its kinda basic jass ill say, coz im just starting to get familar with this whole thing. im foreign to terms of Katana Vars Handler. Cs Cache, VJass, Struct and Global thingi. Thanks :cool:

JASS:
function Trig_Fatigue_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A05L' ) ) then
        return false
    endif
    return true
endfunction

constant function Max_Count takes nothing returns integer
    return 5
endfunction

function Fatigue_Enemy takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
endfunction

function Fatigue_Check takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetFilterUnit(), 'B01N') == true ) ) then
        return false
    endif
    return true
endfunction

function Fatigue_Count takes integer Count returns boolean
    if ( not ( Count >= 5 ) ) then
        return false
    endif
    return true
endfunction

function Int_Check takes unit f returns integer
    local integer Count = ( GetUnitAbilityLevelSwapped('A05W', f) + 1 )
    return Count
endfunction

function FunctionB takes nothing returns nothing
    local unit f = GetEnumUnit()
    local integer Count = Max_Count()
    if ( Fatigue_Count(Count))then
        call SetUnitAbilityLevelSwapped( 'A05W', f, Int_Check(f) )
    else
         call UnitRemoveAbilityBJ( 'A05W', f)
    endif
endfunction

function Trig_Fatigue_Actions takes nothing returns nothing
    local unit f    
    local integer Count
    local unit Caster = GetSpellAbilityUnit()
    local location Temp_Point = GetSpellTargetLoc()
    local group Temp_Group = CreateGroup()
    local group Temp_Group2 = CreateGroup()
    local real cx = GetLocationX(Temp_Point)
    local real cy = GetLocationY(Temp_Point)
    call GroupEnumUnitsInRange(Temp_Group, cx, cy, 250, Condition(function Fatigue_Enemy))
        loop
            set f = FirstOfGroup(Temp_Group)
            exitwhen f == null
            call UnitAddAbilityBJ( 'A05W', f )
            call GroupRemoveUnit(Temp_Group,f)
        endloop
    set Count = 1
    loop
        exitwhen Count < 5
        call GroupEnumUnitsInRange(Temp_Group2, cx, cy, 5000, Condition(function Fatigue_Check))
        call ForGroup(Temp_Group2,function FunctionB)
        call TriggerSleepAction( 4.00 )
      endloop
    set Caster = null
    set f = null
    call DestroyGroup (Temp_Group)
    call RemoveLocation(Temp_Point)
endfunction

//===========================================================================
function InitTrig_Fatigue takes nothing returns nothing
    set gg_trg_Fatigue = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Fatigue, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Fatigue, Condition( function Trig_Fatigue_Conditions ) )
    call TriggerAddAction( gg_trg_Fatigue, function Trig_Fatigue_Actions )
endfunction
 

SFilip

Gone but not forgotten
Reaction score
634
Well I'm pretty sure that the ability you're trying to use is simply not levelable - this is known to be the case for most item abilities and passives like permanent immolation. Solution: you probably have to use a separate ability per level or maybe find an alternative (in this case endurance aura will probably do fine).

Now as for the code - some quick things I noticed:
Code:
function Fatigue_Check takes nothing returns boolean
    if ( not ( UnitHasBuffBJ(GetFilterUnit(), 'B01N') == true ) ) then
        return false
    endif
    return true
endfunction
Conditions like this can simply be
Code:
function Fatigue_Check takes nothing returns boolean
    return UnitHasBuffBJ(GetFilterUnit(), 'B01N')
endfunction
Using a separate function for an if is not needed - you can turn
if ( Fatigue_Count(Count))then
into
if Count >= 5 then
and afterwards completely remove Fatigue_Count.
Also you should consider cleaning those BJs - functions that end with BJ and Swapped are usually slower wrappers for actual natives, should be always avoided.
 

Somatic

You can change this now in User CP.
Reaction score
84
Its possible to level that ability. But the problem is that i need to have a method of doing it by triggering it. Its easy in GUI, but i wanted to make it Leakless nonetheless and also praticing Jass scripting.

Ill try those enhancement. But because what i want to do is adding the ability to slow enemies, and making it such that it works even on spell invul Creatures. And if using Endurance Aura it would add an extra ability to that unit. Which is something im avoiding so far.

:( You are right, i get a fatal error instead....
 
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