- Joined
- May 4, 2007
- Messages
- 2,260
Hi guys, I am making a pure JASS trigger for a campaign. Thing is I have a bug. This trigger selects all units withing a unit group every second and then makes 3 checks:
- if unit has buff and is alive, we deal 50 damage
- If unit is dead, we pick all unit around it that are alive, and we damage them
- if unit does not have bug, we remove it from group
I have a problem on point 2, it works bad if I remove the if... and I want it to work without any flaws. Help please ?
- if unit has buff and is alive, we deal 50 damage
- If unit is dead, we pick all unit around it that are alive, and we damage them
- if unit does not have bug, we remove it from group
I have a problem on point 2, it works bad if I remove the if... and I want it to work without any flaws. Help please ?
JASS:
//!=======================================================!\\
//!=======================SETUP START=====================!\\
//!=======================================================!\\
constant function buffID takes nothing returns integer
return 'BNba' //the rawcode of the buff of the spell (black arrow)
endfunction
constant function lifeDamage takes nothing returns integer
return 50 //the amount of life the unit will lose
endfunction
constant function manaLoss takes nothing returns integer
return 50 //the amount of mana the unit will lose
endfunction
constant function text takes nothing returns string
return "50" //the text that will appear each second the unit loses hp and mana
endfunction
constant function red takes nothing returns integer
return 0 //the RGB red color of the text, from 0 to 255
endfunction
constant function green takes nothing returns integer
return 255 //the RGB green color of the text, from 0 to 255
endfunction
constant function blue takes nothing returns integer
return 0 //the RGB blue color of the text, from 0 to 255
endfunction
constant function time takes nothing returns real
return 2.0 //the amount of time the text will appear
endfunction
constant function AOE takes nothing returns integer
return 200 //the area of effect of the explosion
endfunction
constant function damageExplosion takes nothing returns integer
return 250 //the damage the spell will cause
endfunction
constant function ef takes nothing returns string
//the string of the effect. All effects have a string path, which you can see
//this way you can use hidden effects !
return "Abilities\\Spells\\Undead\\DeathPact\\DeathPactTarget.mdl"
endfunction
constant function textExplosion takes nothing returns string
return "250 !" //the text that will appear when unit is damaged
endfunction
constant function redExplosion takes nothing returns integer
return 0 //the RGB red color of the text, from 0 to 255
endfunction
constant function greenExplosion takes nothing returns integer
return 0 //the RGB green color of the text, from 0 to 255
endfunction
constant function blueExplosion takes nothing returns integer
return 255 //the RGB blue color of the text, from 0 to 255
endfunction
constant function timeExplosion takes nothing returns real
return 2.0 //the amount of time the text will appear
endfunction
//!=======================================================!\\
//!=======================SETUP END=======================!\\
//!=======================================================!\\
//=================================================================
function copyGroup takes group g returns group
set bj_groupAddGroupDest = CreateGroup()
call ForGroup(g, function GroupAddGroupEnum)
return bj_groupAddGroupDest
endfunction
//=================================================================
function Damager_Actions takes nothing returns nothing
local group g = CreateGroup()
local unit vic
local group explosion = CreateGroup()
local unit f
local texttag t
local effect effExplosion
set g = copyGroup(udg_Abadon)
loop
set vic = FirstOfGroup(g)
exitwhen(vic == null)
if (UnitHasBuffBJ(vic, buffID()) and (GetWidgetLife(vic) > 0.405)) then
call SetWidgetLife(vic, GetWidgetLife(vic) - lifeDamage())
call SetUnitState(vic, UNIT_STATE_MANA, GetUnitState(vic, UNIT_STATE_MANA) - manaLoss())
set t = CreateTextTag()
call SetTextTagText(t, text(), .023 )
call SetTextTagPosUnit( t, vic, 0 )
call SetTextTagColor( t, red(), green(), blue(), 255 )
call SetTextTagPermanent(t, false)
call SetTextTagVelocity( t, 0, .0277 )
call SetTextTagLifespan(t, time())
elseif (GetWidgetLife(vic) <= 0.405) then
call GroupEnumUnitsInRange( explosion, GetUnitX( vic ), GetUnitY( vic ), AOE(), Filter(null) )
loop
set f = FirstOfGroup(explosion)
exitwhen(f == null)
if ((GetWidgetLife(f) > 0.405) == true) then
set effExplosion = AddSpecialEffect(ef(), GetUnitX(f), GetUnitY(f))
set t = CreateTextTag()
call SetTextTagText(t, textExplosion(), .023 )
call SetTextTagPosUnit( t, vic, 0 )
call SetTextTagColor( t, redExplosion(), greenExplosion(), blueExplosion(), 255 )
call SetTextTagPermanent(t, false)
call SetTextTagVelocity( t, 0, .0277 )
call SetTextTagLifespan(t, timeExplosion())
call SetWidgetLife(vic, GetWidgetLife(vic) - damageExplosion())
call GroupRemoveUnit(explosion, f)
call DestroyEffect(effExplosion)
endif
endloop
call GroupRemoveUnit(udg_Abadon, vic)
else
call GroupRemoveUnit(udg_Abadon, vic)
endif
call GroupRemoveUnit(g, vic)
endloop
call DestroyGroup(explosion)
call DestroyGroup(g)
set g = null
set explosion = null
set t = null
set effExplosion = null
endfunction
//===========================================================================
function InitTrig_Damager takes nothing returns nothing
set gg_trg_Damager = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_Damager, 1.0 )
call TriggerAddAction( gg_trg_Damager, function Damager_Actions )
endfunction