HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Set ability level not working

05-29-2005, 01:07 AM#1
EdwardSwolenToe
Ok Long story short, im making a system that uses 10 item hp bonus abilities to precicely give units more hp like the bonusmod although i was unable to download it so i made one. Its still in progress so thats why the code seems a bit out of place and messy.

Code:
  
function Trig_Untitled_Trigger_003_Conditions takes nothing returns boolean
   if ( not ( GetSpellAbilityId() == 'A03L' ) ) then
       return false
   endif
   return true
endfunction

function addhp takes integer int, unit u returns nothing
       if (  GetUnitAbilityLevelSwapped('A03O', u) >= 1 ) then
       if ( GetUnitAbilityLevelSwapped('A03N', u) >= 1 ) then
           if ( GetUnitAbilityLevelSwapped('A03P', u) >= 1 ) then
               if ( GetUnitAbilityLevelSwapped('A03Q', u) >= 1  ) then
                   if (GetUnitAbilityLevelSwapped('A03R', u) >= 1  ) then
                       call UnitAddAbilityBJ( 'A03R', u )
                   else
                       call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_1797" )
                   endif
               else
                   call UnitAddAbilityBJ( 'A03Q',u )
                   call SetUnitAbilityLevelSwapped( 'A03Q', u, 5 )
               endif
           else
               call UnitAddAbilityBJ( 'A03P', u )
               call SetUnitAbilityLevelSwapped( 'A03P', u, 5 )
           endif
       else
           call UnitAddAbilityBJ( 'A03N', u )
           call SetUnitAbilityLevelSwapped( 'A03N', u, 5 )
           call DisplayTextToForce( GetPlayersAll(), "lvl2" )
       endif
   else
       call UnitAddAbilityBJ( 'A03O', u )
       call PolledWait(0.5)
       call SetUnitAbilityLevelSwapped( 'A03O', udg_UnitVar2, 5 )
       call DisplayTextToForce( GetPlayersAll(), "lvl1" )
  endif
endfunction

function Trig_Untitled_Trigger_003_Actions takes nothing returns nothing
   local real r
   local integer i = 10
   local integer Looper = 9
   local real o
   local integer y
   local integer array l
   local integer health = 0

   set l[1] = 'A03O'
   set l[2] = 'A03N'
   set l[3] = 'A03P'
   set l[4] = 'A03Q'
   set l[5] = 'A03R'
   set udg_UnitVar2 = GetSpellTargetUnit()
   set udg_UnitVar = GetSpellAbilityUnit()
   set r = (GetUnitStateSwap(UNIT_STATE_LIFE, udg_UnitVar))
   set health = R2I(GetUnitStateSwap(UNIT_STATE_LIFE, udg_UnitVar))
   set i = 9
   loop
       exitwhen i < 0 
       set o = health / (Pow(2, i))
       if(o >= 1) then
       set y = R2I(o)
       call DisplayTextToForce( GetPlayersAll(),"Y=    "+ I2S(y) )
       set health = health - R2I(Pow(2, i))
       loop
       exitwhen y <= 0
       call DisplayTextToForce( GetPlayersAll(), "add" )
       call addhp(5,udg_UnitVar2)
       set y = y - 1
       endloop
       call DisplayTextToForce( GetPlayersAll(), I2S(i) )
       call PolledWait(3)
       else
       call DoNothing()
       endif
       set i = i - 1
   endloop

endfunction

//===========================================================================
function InitTrig_Jump_Copy takes nothing returns nothing
   set gg_trg_Jump_Copy = CreateTrigger(  )
   call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump_Copy, EVENT_PLAYER_UNIT_SPELL_CAST )
   call TriggerAddCondition( gg_trg_Jump_Copy, Condition( function Trig_Untitled_Trigger_003_Conditions ) )
   call TriggerAddAction( gg_trg_Jump_Copy, function Trig_Untitled_Trigger_003_Actions )
endfunction 




Ok this is my trigger. The function addhp checks for the unit if it has the ability, then adds it and then sets the appropriate level (hp)
Now why the hell doesnt it do that?

When i use the spell, i can see the units hp going up by ones. i.e 1000 > 1001 > 1002 > 1003.

This means it keeps adding the ability, with the default level 1 (1 hp) but it just doesnt want to set the level of the spell to anything but 1. As you can see ive changed all the values to 5, and it still wont work.
This code has taken me ages to create, and something as simple as this is biting my ass. Anyone know why? It works with another trigger, but this process it wont work.
05-29-2005, 01:54 AM#2
StealthFox
Lord Vexorian has it in his InvX system. Find one of his posts and download it from there.
05-29-2005, 03:03 AM#3
Guest
Yeah but id rather make my own and have it working.
05-29-2005, 03:05 AM#4
EdwardSwolenToe
yeah but id rather make my own and have it working.
05-29-2005, 07:35 AM#5
Captain Griffen
Sure that set ability level works with item abilities?
05-29-2005, 08:42 AM#6
Guest
i made a second trigger. What it does it when i type in "lol" it adds the same item ability and then sets the level to 5. It is practically the same shit as this but for some reason this doesnt work ><
05-29-2005, 09:47 AM#7
Anitarf
Some item abilities are bugged when you try to level them. I remember having a ring-of-regeneration-ability based skill for my hero and despite the fact that the game thought it was at level 3, it still used it's level 1 stats (I figured that out by timing how long it took the hero to regenerate 100 hp). I fixed the problem by using multiple single level abilities stored in an ability array.
05-29-2005, 09:56 AM#8
Guest
but then how is it done in the bonusmod?
05-29-2005, 10:29 AM#9
Anitarf
As far as I know, with a combination of single level abilites.