So hi ppl. First I want to say I'm new to JASS (actually I started learning JASS yesterday). I want to make a spell, which gives a buff to the attacked unit, and lowers its armor. The spell is stackable (stacks 5 times). I actually am trying to give the attacked unit the ability, which targets Self, and lower its armor but :S little problem here.
Here's where I've come to:
That is my main trigger. As you see the attacker (h000) has 20% chance of stacking the ability on its enemy.
So what this is supposed to do is: when the function is called it checks whether and which buff the attacked unit has (I've made 5 spells and 5 buffs) and according to that give the unit the next "level" ability.
Up to here with the theory. What this does is give the unit like -3 armor, next time -6, then instead of -9, the unit gets 2 spells/2 buffs (-3 and -6 armor) and thats it. From here the buff starts acting stupid - from -3 to -6/-9 and that's it. -12 and -15 never get triggered.
If someone can help me it'll be very nice, cause I've been banging my head for quite some time, and redone the trigger several times in several different ways. Again - I'm a newb so pls don't flame me.
P.S. I hope I'm writting it the right forum section. If not - sorry
Here's where I've come to:
JASS:
function earthborerAcid_Actions takes nothing returns nothing
local integer rand=GetRandomInt(0,100)
call Msg("Acid_Actions has been called.")
set udg_unit=GetAttackedUnitBJ()
if (rand>=0) and (rand<=20) then
call earthborerAcid_GiveSpell()
endif
endfunction
function earthborerAcid_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker())=='h000'
endfunction
function InitTrig_earthborerAcid takes nothing returns nothing
local trigger myTrigger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(myTrigger, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition(myTrigger, Condition(function earthborerAcid_Conditions))
call TriggerAddAction(myTrigger, function earthborerAcid_Actions)
set myTrigger = null
endfunction
JASS:
function earthborerAcid_GiveSpell takes nothing returns nothing
call Msg("Acid GiveSpell has been called.")
if (UnitHasBuffBJ(udg_unit, 'B000')==false) then
call UnitAddAbility(udg_unit, 'A001')
call Msg("-3 triggered")
return
endif
if (UnitHasBuffBJ(udg_unit,'B000')==true) then
call UnitRemoveBuffBJ('B000',udg_unit)
call UnitRemoveAbility(udg_unit, 'A001')
call UnitAddAbility(udg_unit, 'A002')
call Msg("-6 triggered")
return
endif
if (UnitHasBuffBJ(udg_unit,'B001')==true) then
call UnitRemoveBuffBJ('B001',udg_unit)
call UnitRemoveAbility(udg_unit, 'A002')
call UnitAddAbility(udg_unit, 'A003')
call Msg("-9 triggered")
return
endif
if (UnitHasBuffBJ(udg_unit,'B002')==true) then
call UnitRemoveBuffBJ('B002',udg_unit)
call UnitRemoveAbility(udg_unit, 'A003')
call UnitAddAbility(udg_unit, 'A004')
call Msg("-12 triggered")
return
endif
if (UnitHasBuffBJ(udg_unit,'B003')==true) then
call UnitRemoveBuffBJ('B003',udg_unit)
call UnitRemoveAbility(udg_unit, 'A004')
call UnitAddAbility(udg_unit, 'A005')
call Msg("-15 triggered")
return
endif
endfunction
Up to here with the theory. What this does is give the unit like -3 armor, next time -6, then instead of -9, the unit gets 2 spells/2 buffs (-3 and -6 armor) and thats it. From here the buff starts acting stupid - from -3 to -6/-9 and that's it. -12 and -15 never get triggered.
If someone can help me it'll be very nice, cause I've been banging my head for quite some time, and redone the trigger several times in several different ways. Again - I'm a newb so pls don't flame me.
P.S. I hope I'm writting it the right forum section. If not - sorry
