• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] WaitForCondition

Status
Not open for further replies.
Level 5
Joined
Mar 30, 2006
Messages
60
Hi,

got a problem with a spell:

Spell Effect:

Frost Lance hits enemy -> Enemy Frozen -> enemy vertex coloring to bluish color -> buff wears off -> unit gets back normal vertex color

Should be MUI, and I created the spell this way (most basic I think)

Code:
IceBolt
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        (Ability being cast) Equal to Ice Bolt (Magistrix)
    Actions
        Custom script:   local unit udg_TempUnit = GetSpellTargetUnit()
        Wait until ((TempUnit has buff Ice Bolt ) Equal to True), checking every 0.10 seconds
        Animation - Change TempUnit's vertex coloring to (0.00%, 25.00%, 85.00%) with 1.00% transparency
        Wait until ((TempUnit has buff Ice Bolt ) Equal to False), checking every 0.10 seconds
        Animation - Change TempUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
        Custom script:   set udg_TempUnit = null

However, the trigger fires and TempUnit is set (I checked by debugging), but the Vertex Color is not changed. The spell is based off Stormbolt.

Any halp plox?
 
Shadowed Locals can not be used in conditions/enumerations, they are outsourced into subfunctions in which the local shadow is not existing instead the global is used.

Example:
  • Nahkampf-Initialisierung
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: local unit udg_u = GetTriggerUnit()
      • Wait until ((u is alive) Equal to True), checking every 1.00 seconds
becomes this:
as one might see the is alive thing is outsourced and there is no local unit udg_u in the outsourced condition, therefore uses the global value.
JASS:
function Trig_Nahkampf_Initialisierung_Func002001 takes nothing returns boolean
    return ( IsUnitAliveBJ(udg_u) == true )
endfunction

function Trig_Nahkampf_Initialisierung_Actions takes nothing returns nothing
    local unit udg_u = GetTriggerUnit()
    loop
        exitwhen ( Trig_Nahkampf_Initialisierung_Func002001() )
        call TriggerSleepAction(RMaxBJ(bj_WAIT_FOR_COND_MIN_INTERVAL, 1))
    endloop
endfunction

//===========================================================================
function InitTrig_Nahkampf_Initialisierung takes nothing returns nothing
    set gg_trg_Nahkampf_Initialisierung = CreateTrigger(  )
    call TriggerAddAction( gg_trg_Nahkampf_Initialisierung, function Trig_Nahkampf_Initialisierung_Actions )
endfunction
 
Level 5
Joined
Mar 30, 2006
Messages
60
So, in order to get this working I need to use my usual buff detection system to change the vertex coloring.

spell cast -> add target to unitgroupX
periodic event - every 0.1s of gametime -> pick all units from unitgroupX -> if unit has buff change vertex color, if not remove vertex color

... or do I have an alternative?
 
There are always alternatives. Some ways and your option is valid too.
  1. do what Chaosy said: mimic the wait for condition with an loop and inside the loop do the condition yourself but make sure that the loop variable is local and you do not use locals inside conditions, which is overall a little bit tricky.
  2. Cause you use a stun spell you could use the stun event, this is sometimes not safe (when restuning stuned units).

    • Stunned
      • Events
        • Unit - A unit Is issued an order targeting an object
      • Conditions
      • Actions
        • Custom script: set udg_Id = GetIssuedOrderId()
        • -------- The OrderId 851973 = stun --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Id Equal to 851973
          • Then - Actions
            • -------- The unit hasn't the buff when gaining the order --------
            • -------- triggering unit is safe over waits, does not work if your stun dur is lower then 0.3 seconds --------
            • Wait 0.01 seconds
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Triggering unit) has buff frost (Pause)) Equal to True
              • Then - Actions
                • Animation - Change (Triggering unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 50.00% transparency
                • Wait until (((Triggering unit) has buff frost (Pause)) Equal to False), checking every 0.50 seconds
                • Animation - Change (Triggering unit)'s vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Else - Actions
          • Else - Actions
  3. calculate the missles position and do the effect when it should reach the target.
 
Level 5
Joined
Mar 30, 2006
Messages
60
just to put a result to this thread (for future searching etc) that's how I did it. The advantage is that I can put other frost based abilities in there - I'm using this for 2 abilities now.

short desc:

1) Casting the spell adds unit to unit group
2) Unit group is checked periodically, and if the units inside have the stun/frost buff
3) if the unit has the buff vertex color is changed and unit is removed from unit group 1 and added to 2nd unit group
4) 2nd unit group checks if the buff is gone - if gone the unit is removed from the group and vertex color is reverted

Init:

  • IceBolt
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ice Bolt (Magistrix)
    • Actions
      • Unit Group - Add (Target unit of ability being cast) to UGFrostGroup
Trigger 2

  • Frost Group
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in UGFrostGroup and do (Actions)
        • Loop - Actions
          • Set UGUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (UGUnit has buff Slowed) Equal to True
                  • (UGUnit has buff Ice Bolt ) Equal to True
            • Then - Actions
              • Animation - Change UGUnit's vertex coloring to (35.00%, 55.00%, 100.00%) with 0.00% transparency
              • Unit Group - Remove UGUnit from UGFrostGroup
              • Unit Group - Add UGUnit to UGFrostGroup2
            • Else - Actions
      • Unit Group - Pick every unit in UGFrostGroup2 and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (TempUnit has buff Slowed) Equal to True
                  • (TempUnit has buff Ice Bolt ) Equal to True
            • Then - Actions
            • Else - Actions
              • Animation - Change TempUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with 0.00% transparency
              • Unit Group - Remove TempUnit from UGFrostGroup2
 
Status
Not open for further replies.
Top