HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Wait Until Condition?

08-13-2007, 01:43 PM#1
Demi666
is there another way to wait until has buff then his
Collapse JASS:
function Trig_Check_Func001001 takes nothing returns boolean
    return ( UnitHasBuffBJ(GetTriggerUnit(), 'BUau') == true )
endfunction

function Trig_Check_Actions takes nothing returns nothing
    loop
        exitwhen ( Trig_Check_Func001001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 0.30))
    endloop
endfunction
?

i got that by converting...

and in that case where do i put it in this code

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

function Trig_Spelll_Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local unit targget = GetSpellTargetUnit()
    local string effecttt = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeDamageTarget.mdl"
    local integer spell = 'A001'
    local integer damagee = 10*GetUnitAbilityLevel(caster, 'A000')
    local real speed = GetUnitMoveSpeed(targget)
    local real speeed = GetUnitDefaultMoveSpeed(targget)
    local integer i = 0
    local effect e
    
    
call SetUnitMoveSpeed(targget, speed*0.50)
call UnitAddAbility(targget,'A001')
call AddSpecialEffectTarget(effecttt,targget,"chest")
set e = AddSpecialEffectTarget(effecttt,targget,"chest")

loop
        exitwhen (i==5)
        set i = i+1
        call PolledWait(01.00)
        call UnitDamageTargetBJ( caster, targget, damagee, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE )
endloop

call SetUnitMoveSpeed(targget, speeed)
call DestroyEffect(e)
call DestroyEffectBJ( e )
set e = null
call UnitRemoveAbility(targget, 'A001')
set caster = null
set targget = null
set effecttt = null  
         
endfunction

//===========================================================================
function InitTrig_Spelll takes nothing returns nothing
    set gg_trg_Spelll = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Spelll, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Spelll, Condition( function Trig_Spelll_Conditions ) )
    call TriggerAddAction( gg_trg_Spelll, function Trig_Spelll_Actions )
endfunction

other words i need to know if its some easyier way to wait for a condition to happen?

EDIT

hmm.. i tested Trigger , code and something mroe and it still doesent show full code.. i will just write it instead.. sry

function Trig_Spelll_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'A000' ) ) then
return false
endif
return true
endfunction

function Trig_Spelll_Actions takes nothing returns nothing
local unit caster = GetTriggerUnit()
local unit targget = GetSpellTargetUnit()
local string effecttt = "Abilities\\Spells\\Human\\FlameStrike\\FlameStrikeDamageTarget.mdl"
local integer spell = 'A001'
local integer damagee = 10*GetUnitAbilityLevel(caster, 'A000')
local real speed = GetUnitMoveSpeed(targget)
local real speeed = GetUnitDefaultMoveSpeed(targget)
local integer i = 0
local effect e


call SetUnitMoveSpeed(targget, speed*0.50)
call UnitAddAbility(targget,'A001')
call AddSpecialEffectTarget(effecttt,targget,"chest")
set e = AddSpecialEffectTarget(effecttt,targget,"chest")

loop
exitwhen (i==5)
set i = i+1
call PolledWait(01.00)
call UnitDamageTargetBJ( caster, targget, damagee, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_FIRE )
endloop

call SetUnitMoveSpeed(targget, speeed)
call DestroyEffect(e)
call DestroyEffectBJ( e )
set e = null
call UnitRemoveAbility(targget, 'A001')
set caster = null
set targget = null
set effecttt = null

endfunction

//===========================================================================
function InitTrig_Spelll takes nothing returns nothing
set gg_trg_Spelll = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Spelll, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Spelll, Condition( function Trig_Spelll_Conditions ) )
call TriggerAddAction( gg_trg_Spelll, function Trig_Spelll_Actions )
endfunction
08-13-2007, 06:00 PM#2
Vexorian
wait until?

like:
Collapse JASS:
loop
    exitwhen ( ConditionIsTrue() )
    call TriggerSleepAction(0.)
 endloop
?
08-13-2007, 06:18 PM#3
cohadar
Quote:
Originally Posted by Vexorian
wait until?

like:
Collapse JASS:
loop
    exitwhen ( ConditionIsTrue() )
    call TriggerSleepAction(0.)
 endloop
?

Wouldn't this deadlock the game?
08-14-2007, 05:42 AM#4
fps-doug
no, because it has an exit condition, and triggersleep for 0 seconds still waits longer then 0 seconds, and because I do the exact same thing in my bomberman map (which im running into severe problems lately ), I know for a fact that that works.
08-16-2007, 10:36 PM#5
Vexorian
Quote:
Wouldn't this deadlock the game?
how would it?

Quote:
no, because it has an exit condition, and triggersleep for 0 seconds still waits longer then 0 seconds, and because I do the exact same thing in my bomberman map (which im running into severe problems lately ), I know for a fact that that works.

ok then.

If I am understanding you then you can just use a 0.5 timer and then execute the next code once the timer detects the condition is true.

It is fairly lame, but blizz never added such an useful thing...

Unless, of course your condition happens to be the value of a real variable, in that case you can use a trigger to detect the condition...

--
for some reason I didn't see your original code, it is actually good like that, you could use a timer to make it more accurate, but it is not that bad in its current state...
08-17-2007, 04:39 PM#6
fps-doug
the condition is a real, its when the life of the unit <= 0 (the bomb has expiration timer of 3 seconds, but its possible another bomb can blow it up before that so I just check its life). it works ok right now, but I know what you mean by having another trigger continue the rest of the work, or using a timer instead to evaulate the condition... its not a big deal, my problems come from figuring out how to add certain things into my map, like bouncing bombs.