• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Wait Unit Condition Problem

Status
Not open for further replies.
Level 4
Joined
Aug 20, 2004
Messages
65
I've never used the action "wait until condition" before, but I thought I could use it for a spell I want in a map. The idea is a spear that banishes the target on impact. Here is the trigger.
  • New Spectral Dagger
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spectral Spear (New)
    • Actions
      • Set Temp_Point = (Position of (Target unit of ability being cast))
      • Unit - Create 1 DaggerCaster for (Owner of (Casting unit)) at Temp_Point facing (Facing of (Casting unit)) degrees
      • Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Spectral Banish (Neutral Hostile) to (Last created unit)
      • Unit - Set level of Spectral Banish (Neutral Hostile) for (Last created unit) to (Level of Spectral Spear (New) for (Casting unit))
      • Wait until (((Target unit of ability being cast) has buff Spectral Spear ) Equal to True), checking every (0.10 - 0.09) seconds
      • Unit - Order (Last created unit) to Human Blood Mage - Banish (Target unit of ability being cast)
      • Unit - Cause (Casting unit) to damage (Target unit of ability being cast), dealing (60.00 + (0.00 + (40.00 x (Real((Level of Spectral Spear for (Casting unit))))))) damage of attack type Spells and damage type Normal
      • Custom script: call RemoveLocation (udg_Temp_Point)
Not only is there a delay in the banishment of the target (despite trying to check every .01 seconds), but sometimes the banish is never even cast (it appears that if I order the casting unit to move before the spear hits, the trigger won't fire, even though the target gets the buff) Also, I'm not sure if this creates memory leaks or would cause lag in an online game. I know people always say not to use "wait" functions - does it apply to this type as well?
 
Level 4
Joined
Aug 20, 2004
Messages
65
I can't set the spell to fire after a set time because what if the unit is standing closer to the target, or the target is moving?

So any time I use a 'wait' I can't use 'target unit of ability being cast' or anything like that again?
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
I know jass is a bit much, but here it is! Just convert your trigger to custom text, delete the text, and then copy this text in the empty window. (GUI would be more complicated for this!)

JASS:
function Trig_New_Spectral_Dagger_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000' // insert the ability id here between ' '
endfunction

function Trig_New_Spectral_Dagger_Actions takes nothing returns nothing

    local unit caster       = GetTriggerUnit()
    local unit targ         = GetSpellTargetUnit()
    local real x            = GetUnitX(caster)
    local real y            = GetUnitY(caster)
    local real z            = GetUnitFacing(caster)
    local unit daggercast   = CreateUnit(GetOwningPlayer(caster),'h000',x,y,z) // create the dagger caster
    local integer SPEAR_LVL = GetUnitAbilityLevel(caster,'A000')
    
    set z                   = I2R(60+(40*SPEAR_LVL))

    // manage the units life time and ability
    call UnitApplyTimedLife(daggercast,'BTLF',10.00)
    call UnitAddAbility(daggercast,'A001')
    call SetUnitAbilityLevel(daggercast,'A001',SPEAR_LVL)
    
    // loop
    loop 
        exitwhen GetUnitAbilityLevel(targ,'B000') > 0
        call TriggerSleepAction(0.20)
    endloop
    
    // effects
    call UnitDamageTarget(caster,targ,z,true,false,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
    call IssueTargetOrder(daggercast,"banish",targ)
    
    // free memory
    set caster = null
    set daggercast = null
    set targ = null

endfunction

//===========================================================================
function InitTrig_New_Spectral_Dagger takes nothing returns nothing
    set gg_trg_New_Spectral_Dagger = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_New_Spectral_Dagger, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_New_Spectral_Dagger, Condition( function Trig_New_Spectral_Dagger_Conditions ) )
    call TriggerAddAction( gg_trg_New_Spectral_Dagger, function Trig_New_Spectral_Dagger_Actions )
endfunction

I KNOW, its not very good to use the loop with waits instead of a timer to handle the wait duration, but i dont have enough time at the moment :D

Importatn to use
Just change 'A000' to the ability id of the Spear ability, look at the object editor and press STR + D to see it.

Change 'A001' to the ability id of the banish ability

Change 'h000' to the unit id of the dummy unit "DaggerCaster", that you can find in the OE

Change 'B000' to the buff id, that you want to wait for.

I hope, it works.
 
Level 7
Joined
Jul 12, 2008
Messages
295
No the minimum check is 0.1 seconds so first of all set your units into variables i think that will do the trick. BTW who casts the banish your hero or your dummy? Explain a little more. If it is your dummy i think the trigger is wrong. Reply here i'll think of something else
 

Rmx

Rmx

Level 19
Joined
Aug 27, 2007
Messages
1,164
The minimum chek is 0.27 seconds For waits BUT for Timer it's 0.01 seconds And put ur units into a variabel set X = Casting unit and Y = Targeted Unit And then Put the wait action on 0.27 seconds cheking K , , , After all this Set the Position of Targeted Unit then Create the dummy unit and hide him and put a Expiration Timer on him After that , , , , order him to banish Targeted unit ,,,,, then Remove The location ( LEAKS ) and null the X and Y that's all ....................Or u can create a TIMER every 0.01 But i think for ur experience in GUI that's the best way for u CONTACT ME IF U HAVE any Questions ^^
 
Status
Not open for further replies.
Top