• 🏆 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!

[Trigger] MUI Countdown Timer

Status
Not open for further replies.
Level 19
Joined
Apr 21, 2013
Messages
1,194
Alright, I wanted to recreate Tyrael's spell from HOTS on Wc3. Everything was fine until I got stuck in the timer issue.

Here's how the spell should work:
1) Tyrael throws his sword to a point. (First loop to send an effect along the path between Tyrael and target point)
2) The sword spawns on the target point, a damage is done in an AoE. (After loop effects)
3) The ability will go into phase two: Tyrael's sword throwing ability changes with a Teleport ability, he can use this spell within the limited time to blink to the sword's location. If he doesn't blink back within the given time, sword disappears, and the sword throwing ability comes back, while the teleport ability goes away as well.

Here are my triggers, they might be a bit unorganised rn.


  • HCNS Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set HCNS_AbilityID = Holy Clash
      • Set HCNS_Blink = Teleport
      • -------- Set Sword Type To be Thrown --------
      • Set HCNS_DummySwordType = HCNS Dummy Sword
      • Set HCNS_DummyThrowEffectType = HCNS Dummy Throw Effect
      • Set HCNS_SwordThrowSpeed = (750.00 x 0.03)
      • Set HCNS_SwordImpactDmgEffectType = Abilities\Spells\Demon\DarkPortal\DarkPortalTarget.mdl
      • Set HCNS_AoE = 350.00
      • Set HCNS_SwordImpactDamage[1] = 90.00
      • Set HCNS_SwordImpactDamage[2] = 150.00
      • Set HCNS_SwordImpactDamage[3] = 225.00
      • Set HCNS_SwordImpactDamageType = Divine
      • Set HCNS_SwordImpactAttackType = Magic
      • Set HCNS_SwordExpirationTimer[1] = 5.00
      • Set HCNS_SwordExpirationTimer[2] = 6.00
      • Set HCNS_SwordExpirationTimer[3] = 7.00



  • HCNS Execution
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to HCNS_AbilityID
    • Actions
      • Set HCNS_Index = (HCNS_Index + 1)
      • Set HCNS_Caster[HCNS_Index] = (Triggering unit)
      • Set HCNS_CurrentLvl[HCNS_Index] = (Level of HCNS_AbilityID for HCNS_Caster[HCNS_Index])
      • -------- Get the angle and distance between points --------
      • Set HCNS_tempLoc1 = (Position of HCNS_Caster[HCNS_Index])
      • Set HCNS_tempLoc2 = (Target point of ability being cast)
      • Set HCNS_Angle[HCNS_Index] = (Angle from HCNS_tempLoc1 to HCNS_tempLoc2)
      • Set HCNS_Distance[HCNS_Index] = (Distance between HCNS_tempLoc1 and HCNS_tempLoc2)
      • Unit - Create 1 HCNS_DummyThrowEffectType for (Owner of HCNS_Caster[HCNS_Index]) at HCNS_tempLoc1 facing HCNS_Angle[HCNS_Index] degrees
      • Set HCNS_DummyThrowEffect[HCNS_Index] = (Last created unit)
      • Set HCNS_DistanceTraveled[HCNS_Index] = 0.00
      • Custom script: call RemoveLocation(udg_HCNS_tempLoc1)
      • Custom script: call RemoveLocation(udg_HCNS_tempLoc2)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • HCNS_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on HCNS Loop <gen>
        • Else - Actions



  • HCNS Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer HCNS_LoopInteger) from 1 to HCNS_Index, do (Actions)
        • Loop - Actions
          • Set HCNS_tempLoc1 = (Position of HCNS_DummyThrowEffect[HCNS_LoopInteger])
          • Set HCNS_tempLoc2 = (HCNS_tempLoc1 offset by HCNS_SwordThrowSpeed towards HCNS_Angle[HCNS_LoopInteger] degrees)
          • Unit - Move HCNS_DummyThrowEffect[HCNS_LoopInteger] instantly to HCNS_tempLoc2
          • Set HCNS_DistanceTraveled[HCNS_LoopInteger] = (HCNS_DistanceTraveled[HCNS_LoopInteger] + HCNS_SwordThrowSpeed)
          • Custom script: call RemoveLocation(udg_HCNS_tempLoc1)
          • Custom script: call RemoveLocation(udg_HCNS_tempLoc2)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • HCNS_DistanceTraveled[HCNS_LoopInteger] Greater than or equal to HCNS_Distance[HCNS_LoopInteger]
            • Then - Actions
              • Set HCNS_tempLoc1 = (Position of HCNS_DummyThrowEffect[HCNS_LoopInteger])
              • Special Effect - Create a special effect at HCNS_tempLoc1 using HCNS_SwordImpactDmgEffectType
              • Special Effect - Destroy (Last created special effect)
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within HCNS_AoE of HCNS_tempLoc1) and do (Actions)
                • Loop - Actions
                  • Set HCNS_tempUnit = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • And - All (Conditions) are true
                        • Conditions
                          • (HCNS_tempUnit is alive) Equal to True
                          • (HCNS_tempUnit belongs to an ally of (Owner of HCNS_Caster[HCNS_LoopInteger])) Equal to False
                          • (HCNS_tempUnit is Magic Immune) Equal to False
                    • Then - Actions
                      • Unit - Cause HCNS_Caster[HCNS_LoopInteger] to damage HCNS_tempUnit, dealing HCNS_SwordImpactDamage[HCNS_CurrentLvl[HCNS_LoopInteger]] damage of attack type HCNS_SwordImpactAttackType and damage type HCNS_SwordImpactDamageType
                    • Else - Actions
              • Unit - Create 1 HCNS_DummySwordType for (Owner of HCNS_Caster[HCNS_LoopInteger]) at HCNS_tempLoc1 facing Default building facing degrees
              • Set HCNS_DummySword[HCNS_LoopInteger] = (Last created unit)
              • Unit - Add a HCNS_SwordExpirationTimer[HCNS_CurrentLvl[HCNS_LoopInteger]] second Generic expiration timer to HCNS_DummySword[HCNS_LoopInteger]
              • Unit - Remove HCNS_AbilityID from HCNS_Caster[HCNS_LoopInteger]
              • Unit - Add HCNS_Blink to HCNS_Caster[HCNS_LoopInteger]
              • Countdown Timer - Start HCNS_CountdownForTP[HCNS_LoopInteger] as a One-shot timer that will expire in HCNS_SwordExpirationTimer[HCNS_CurrentLvl[HCNS_LoopInteger]] seconds
              • Unit - Kill HCNS_DummyThrowEffect[HCNS_LoopInteger]
              • Trigger - Turn off (This trigger)
              • Set HCNS_Angle[HCNS_LoopInteger] = HCNS_Angle[HCNS_Index]
              • Set HCNS_Caster[HCNS_LoopInteger] = HCNS_Caster[HCNS_Index]
              • Set HCNS_CurrentLvl[HCNS_LoopInteger] = HCNS_CurrentLvl[HCNS_Index]
              • Set HCNS_Distance[HCNS_LoopInteger] = HCNS_Distance[HCNS_Index]
              • Set HCNS_DistanceTraveled[HCNS_LoopInteger] = HCNS_DistanceTraveled[HCNS_Index]
              • Set HCNS_Index = (HCNS_Index - 1)
              • Set HCNS_LoopInteger = (HCNS_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • HCNS_Index Equal to 0
                • Then - Actions
                • Else - Actions
            • Else - Actions



I disabled the last lines after Trigger - Turn off (This trigger)


  • HCNSCountdownExpire
    • Events
    • Conditions
    • Actions


This method doesn't work bcz I can't choose the event as this; "
Time - HCNS_CountdownForTP[HCNS_LoopInteger] expires" somehow HCNS_LoopInteger doesn't show up in there.




SO, how should I approach this system? I need a timer for each instance, but I couldn't find a way. Any help would be appreciated.
 
Level 11
Joined
Aug 6, 2009
Messages
697
  • Actions
    • -------- Add this event to your trigger, though since you deallocate, it wont be able to find the right unit. --------
    • Trigger - Add to (This trigger) the event (Time - HCNS_CountdownForTP[HCNS_LoopInteger] expires)
    • -------- I suggest using reals as a timer instead. --------
    • -------- Spell Startup Trigger, or your config --------
    • Set HCNS_BlinkTimer[HCNS_Index] = 1.00
    • -------- End --------
    • -------- Spell Loop Trigger --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • HCNS_BlinkTimer[HCNS_LoopInteger] Greater than 0.00
      • Then - Actions
        • Set HCNS_BlinkTimer[HCNS_LoopInteger] = (HCNS_BlinkTimer[HCNS_LoopInteger] - 0.03)
      • Else - Actions
        • -------- Actions here --------
    • -------- End --------
 
Status
Not open for further replies.
Top