function RemoveUnitBuff takes integer id, integer index, boolean check returns nothing
local integer cv = GetUnitUserData( udg_Buff_Unit[id] )
local integer pl = GetPlayerId(GetOwningPlayer(udg_Buff_Unit[id])) + 1
local integer buffid
local real spd
local integer amount
local integer t
local integer i = 1
local integer times
local unit u = udg_Buff_Unit[id]
local integer diff
if not check then
set buffid = LoadInteger( udg_Buff_Index_Table, cv, index )
set amount = LoadInteger( udg_Buff_Amount, cv, buffid ) * - 1
set diff = amount
set t = LoadInteger( udg_Buff_Index_Table, cv, buffid )
if index != udg_Buff_Unit_Index[cv] then
call SaveInteger( udg_Buff_Index_Table, cv, index, LoadInteger( udg_Buff_Index_Table, cv, udg_Buff_Unit_Index[cv] ) )
endif
set udg_Buff_Unit_Index[cv] = udg_Buff_Unit_Index[cv] - 1
call DestroyEffect ( LoadEffectHandle(udg_Buff_EffectTable, cv, buffid))
call DisplayTextToPlayer( Player(0), 0, 0, "|cff00000ff2nd Remove:|r" + GetUnitName(udg_Buff_Unit[id]) + " id" + I2S(id) + " index" + I2S(index))
call SaveInteger( udg_Buff_Timer, cv, buffid, 0 )
call SaveInteger( udg_Buff_Amount, cv, buffid, 0 )
if buffid==1 then
call AddHPMP( true, amount, udg_Buff_Unit[id] )
elseif buffid==2 then
call AddHPMP( false, amount, udg_Buff_Unit[id] )
elseif buffid == 3 then
set udg_B_Crit[cv] = udg_B_Crit[cv] + diff
elseif buffid == 4 then
set udg_B_CritDmg[cv] = udg_B_CritDmg[cv] + diff
elseif buffid == 5 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 6 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 7 then
set udg_B_AttLv[cv] = udg_B_AttLv[cv] + diff
elseif buffid == 8 then
set udg_B_DefLv[cv] = udg_B_DefLv[cv] + diff
elseif buffid == 9 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 10 then
set udg_B_Eva[cv] = udg_B_Eva[cv] + diff
elseif buffid == 14 then
call UnitRemoveAbility( u, 'A01R' )
elseif buffid == 15 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 16 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 17 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 18 then
set udg_B_Ref[cv] = udg_B_Ref[cv] + diff
elseif buffid == 19 then
set udg_Global_MattackAddon[cv] = udg_Global_MattackAddon[cv] + diff
elseif buffid == 20 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 21 then
set udg_Global_ArmorBreak[cv] = udg_Global_ArmorBreak[cv] + diff
elseif buffid == 22 then
set udg_Global_LifeSteal[cv] = udg_Global_LifeSteal[cv] + diff
elseif buffid == 23 then
set udg_B_Crit[cv] = udg_B_Crit[cv] + diff
elseif buffid == 24 then
set udg_B_CritDmg[cv] = udg_B_CritDmg[cv] + diff
elseif buffid == 25 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 26 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 27 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 28 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 29 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 31 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 32 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 33 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 34 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 35 then
set udg_Global_MattackAddon[cv] = udg_Global_MattackAddon[cv] + diff
elseif buffid == 36 then
set udg_B_LS[cv] = udg_B_LS[cv] + diff
elseif buffid == 37 then
set udg_B_LS[cv] = udg_B_LS[cv] + diff
elseif buffid == 36 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 37 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 38 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 39 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 40 then
set udg_Global_Shield[cv] = 0
elseif buffid == 41 then
set udg_Soulburn_Caster[cv] = null
set udg_Soulburn_Damage[cv] = 0
elseif buffid == 42 then
set udg_Global_Exp_Buff[pl] = 0
elseif buffid == 43 then
set udg_Global_Exp_Red[pl] = udg_Global_Exp_Red[pl] + diff
elseif buffid == 44 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 45 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 59 then
set udg_Stat_AttackSpeed[pl] = udg_Stat_AttackSpeed[pl] + diff
call AddDMG(false, u)
endif
call SaveInteger( udg_Buff_Amount, cv, buffid, 0 )
if udg_Buff_Unit_Index[cv] == 0 then
set udg_Buff_Unit_Id[cv] = 0
if id != udg_Buff_Index then
set udg_Buff_Unit[id] = udg_Buff_Unit[udg_Buff_Index]
set udg_Buff_Unit_Id[GetUnitUserData(udg_Buff_Unit[id])] = id
call RemoveUnitBuff (id, 0, true)
else
endif
set udg_Buff_Index = udg_Buff_Index - 1
call FlushChildHashtable(udg_Buff_Index_Table, cv)
call FlushChildHashtable(udg_Buff_EffectTable, cv)
call FlushChildHashtable(udg_Buff_Timer, cv)
call FlushChildHashtable(udg_Buff_Amount, cv)
endif
else
loop
exitwhen id > udg_Buff_Index
set cv = GetUnitUserData( udg_Buff_Unit[id] )
loop
exitwhen i > udg_Buff_Unit_Index[cv]
set buffid = LoadInteger(udg_Buff_Index_Table, cv, i)
set times = LoadInteger(udg_Buff_Timer, cv, buffid)
call DisplayTextToPlayer( Player(0), 0, 0, "|cffffff00New unit:|r" + GetUnitName(udg_Buff_Unit[id]) + " index=" + I2S(id) + " buff id" + I2S(buffid) + " time" + I2S(times))
if times == 0 then
call DisplayTextToPlayer( Player(0), 0, 0, "|cffff00ffRemove:|r" + GetUnitName(udg_Buff_Unit[id]) + " index" + I2S(i))
call RemoveUnitBuff (id, i, false)
endif
set i = i + 1
endloop
set id = id + 1
endloop
endif
// call DisplayTextToPlayer( Player(0), 0, 0, "|cffffff00Remove buff a="+I2S(amount)+" array index" + I2S(udg_Buff_Index+1)+" C.Index" + I2S(id) +" buff index"+I2S(udg_Buff_Unit_Index[cv]) + " time" +I2S(t)+GetUnitName(u)+"|r")
set u = null
endfunction
function ClearUnitBuff takes integer id returns nothing
local unit u = udg_Buff_Unit[id]
local integer e
local integer v
local integer i = 0
local integer cv = GetUnitUserData(u)
local integer buffid
local integer po
local integer amount
local real spd
loop
exitwhen i > udg_Buff_Unit_Index[cv]
set buffid = LoadInteger(udg_Buff_Index_Table, cv, i)
call DisplayTextToPlayer( Player(0), 0, 0, "clearbuff from " + GetUnitName(u) + "unit index in unit array" + I2S(id) + " unit buff index" + I2S(i))
call RemoveUnitBuff (id, i, false)
set i = i + 1
endloop
endfunction
function UnitDeBuff takes unit u, boolean debuff returns nothing
local integer cv = GetUnitUserData(u)
local integer index = udg_Buff_Unit_Id[cv]
local integer i = 0
local integer buffid
local integer amount
loop
exitwhen i > udg_Buff_Unit_Index[cv]
set buffid = LoadInteger(udg_Buff_Index_Table, cv, i)
set amount = LoadInteger( udg_Buff_Amount, cv, buffid )
if debuff and amount > 0 then
call DestroyEffect(AddSpecialEffectTarget ("Abilities\\Spells\\Other\\Incinerate\\FireLordDeathExplode.mdl", u, "overhead" ))
call RemoveUnitBuff (index, i, false)
elseif not debuff and amount < 0 then
call DestroyEffect(AddSpecialEffectTarget ("Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdl", u, "overhead" ))
call RemoveUnitBuff (index, i, false)
endif
set i = i + 1
endloop
endfunction
function AddUnitBuff takes unit u, integer buffid, integer amount, integer dur, integer effectid, string apoint returns nothing
local integer cv = GetUnitUserData(u)
local integer times = LoadInteger( udg_Buff_Timer, cv, buffid )
local integer oldv = LoadInteger( udg_Buff_Amount, cv, buffid )
local integer diff = amount - oldv
local integer pl = GetPlayerId(GetOwningPlayer(u)) + 1
local real spd
if udg_Buff_Unit_Id[cv] == 0 then
set udg_Buff_Index = udg_Buff_Index + 1
set udg_Buff_Unit[udg_Buff_Index] = u
set udg_Buff_Unit_Id[cv] = udg_Buff_Index
endif
if times == 0 and LoadInteger( udg_Buff_Amount, cv, buffid ) == 0 then
set udg_Buff_Unit_Index[cv] = udg_Buff_Unit_Index[cv] + 1
call SaveInteger( udg_Buff_Index_Table, cv, udg_Buff_Unit_Index[cv], buffid )
if effectid > - 1 then
call SaveEffectHandle(udg_Buff_EffectTable, cv, buffid, AddSpecialEffectTarget( udg_Effects[effectid], u, apoint ))
endif
endif
call SaveInteger( udg_Buff_Amount, cv, buffid, amount )
call SaveInteger( udg_Buff_Timer, cv, buffid, dur )
// call DisplayTextToPlayer( Player(0), 0, 0, "dur=" + I2S(dur) + " amount="+I2S(amount)+" unit index in unit array" + I2S(udg_Buff_Index) +" unit buff index"+I2S(udg_Buff_Unit_Index[cv]))
if buffid == 1 and oldv == 0 then
call AddHPMP(true, amount, u)
elseif buffid == 2 and oldv == 0 then
call AddHPMP(false, amount, u)
elseif buffid == 3 then
set udg_B_Crit[cv] = udg_B_Crit[cv] + diff
elseif buffid == 4 then
set udg_B_CritDmg[cv] = udg_B_CritDmg[cv] + diff
elseif buffid == 5 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 6 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 7 then
set udg_B_AttLv[cv] = udg_B_AttLv[cv] + diff
elseif buffid == 8 then
set udg_B_DefLv[cv] = udg_B_DefLv[cv] + diff
elseif buffid == 9 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 10 then
set udg_B_Eva[cv] = udg_B_Eva[cv] + diff
elseif buffid == 14 then
if oldv == 0 then
call UnitAddAbility( u, 'A01R' )
endif
elseif buffid == 15 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 16 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 17 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 18 then
set udg_B_Ref[cv] = udg_B_Ref[cv] + diff
elseif buffid == 19 then
set udg_Global_MattackAddon[cv] = udg_Global_MattackAddon[cv] + diff
elseif buffid == 20 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 21 then
set udg_Global_ArmorBreak[cv] = udg_Global_ArmorBreak[cv] + diff
elseif buffid == 22 then
set udg_Global_LifeSteal[cv] = udg_Global_LifeSteal[cv] + diff
elseif buffid == 23 then
set udg_B_Crit[cv] = udg_B_Crit[cv] + diff
elseif buffid == 24 then
set udg_B_CritDmg[cv] = udg_B_CritDmg[cv] + diff
elseif buffid == 25 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 26 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 27 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 28 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 29 then
set udg_Global_IncDmg[cv] = udg_Global_IncDmg[cv] + diff
elseif buffid == 31 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 32 then
set udg_Global_DmgInc[cv] = udg_Global_DmgInc[cv] + diff
elseif buffid == 33 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 34 then
set udg_Global_DmgRed[cv] = udg_Global_DmgRed[cv] + diff
elseif buffid == 35 then
set udg_Global_MattackAddon[cv] = udg_Global_MattackAddon[cv] + diff
elseif buffid == 36 then
set udg_B_LS[cv] = udg_B_LS[cv] + diff
elseif buffid == 37 then
set udg_B_LS[cv] = udg_B_LS[cv] + diff
elseif buffid == 36 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 37 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 38 then
set spd = GetUnitMoveSpeed( u )
call SetUnitMoveSpeed( u, spd + diff )
elseif buffid == 39 then
set udg_B_Acc[cv] = udg_B_Acc[cv] + diff
elseif buffid == 40 then
//set udg_Global_Shield[cv] = 0
elseif buffid == 41 then
//set udg_Soulburn_Caster[cv] = null
//set udg_Soulburn_Damage[cv] = 0
elseif buffid == 42 then
set udg_Global_Exp_Buff[pl] = udg_Global_Exp_Buff[pl] + diff
elseif buffid == 43 then
set udg_Global_Exp_Red[pl] = udg_Global_Exp_Red[pl] + diff
elseif buffid == 44 then
set udg_B_Pdef[cv] = udg_B_Pdef[cv] + diff
elseif buffid == 45 then
set udg_B_Mdef[cv] = udg_B_Mdef[cv] + diff
elseif buffid == 59 then
set udg_Stat_AttackSpeed[pl] = udg_Stat_AttackSpeed[pl] + diff
call AddDMG(false, u)
endif
call DisplayTextToPlayer( Player(0), 0, 0, "|cffff0000b.id=" + I2S(buffid) + " diff=" + I2S(diff) + " array index" + I2S(udg_Buff_Index) + " b amount" + I2S(udg_Buff_Unit_Id[cv]) + "|r")
endfunction