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

[Unit] Takes damage Question

Status
Not open for further replies.
You can do this:
  • Trigger1
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Source Of Power
  • Actions
    • Set Caster = (Triggering unit)
    • Trigger - Add to Trigger2 <gen> the event (Unit - (Target unit of ability being cast) takes damage)
  • Trigger2
  • Events
  • Conditions
    • (Damage source) Equal to Caster
  • Actions
    • //Actions here
This is not MUI though, but I can see some waits in your trigger, so that doesn't seem to be a problem :)
 
No, you don't need to set a variable for the Countdown Timer action. Starting it will fire it up normally, something that doesn't happen in Jass. In Jass, you need to firstly create your timer and then start it:
JASS:
local timer t = CreateTimer()
call StartTimer (t, 0, false, function BlaBla)
set t = null

Expiration of the timer doesn't automatically remove the leak, you need the
JASS:
call DestroyTimer (GetExpiredTimer())
line.

So, in GUI, if you use "Countdown Timer - Start Timer1...", without declaring that Timer1's variable (e.g. Set Timer1 = (Last started timer)), in the trigger that checks when the timer expires (Time - Timer1 expires), you will not need the 'call DestroyTimer()' action, but if you indeed declared a variable for that, you will need it.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Is that even possible to create Countdown Timer WITHOUT declaring variables ???
I'm quite dazed at the moment =.=''
If you can, please show me a trigger that (declare variable and use it and clean it) AND (does not declare any variable but can use the Countdown Timer and doesn't need to clean a leak from it)
Thanks ;D
(You must spread more!) grrrr
 
Like I said, yes, global timer variables don't need to be declared, since there is no "CreateTimer()" equivalent for GUI.

Case 1: Declare variables
  • Trigger1
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • Countdown Timer - Start Timer1 as a One-shot timer that will expire in 20.00 seconds
    • Set Timer1 = (Last started timer)
  • Trigger2
  • Events
    • Time - Timer1 expires
  • Conditions
  • Actions
    • Custom script: call DestroyTimer (udg_Timer1)
Honestly? You don't have to do that. You declare the timer for nothing, but, you need this method, if you want to refer to this timer in another trigger.

Case 2: Free start

  • Trigger1
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
  • Actions
    • Countdown Timer - Start Timer1 as a One-shot timer that will expire in 20.00 seconds
  • Trigger2
  • Events
    • Time - Timer1 expires
  • Conditions
  • Actions
    • //Random Actions here
See? Their only difference is the fact that the variable is set. If it is set, you need to destroy it in the expiration of the timer.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Haha I was looking for that WORD !
"I want to know WHAT commands that needs to be typed so that the Timer is cleaned"

What about this timer ?
Should it be cleaned as your trigger above ?
Because, I used a checking condition, so do I need to clean the Timer every X seconds ?
Because I didn't set the variable for X per second

  • Soul Steal Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • -------- Checking both conditions --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Target has buff Drain Life (Target)) Equal to True
              • (Integer((Remaining time for Duration))) Not equal to 0
        • Then - Actions
          • -------- Damage/Heal calculations --------
          • Unit - Set life of Caster to ((Life of Caster) + (((Real((Level of Soul Steal for Caster))) x (Real((Level of Target)))) + ((Real((Level of Soul Steal for Caster))) x ((Real((Level of Caster))) / 15.00))))
          • Unit - Set life of Target to ((Life of Target) - (((Real((Level of Soul Steal for Caster))) x (Real((Level of Target)))) + ((Real((Level of Soul Steal for Caster))) x ((Real((Level of Caster))) / 15.00))))
        • Else - Actions
          • -------- Stop the caster from stealing excess HP even when the Timer runs out --------
          • Unit - Order Caster to Move To StopLifeSteal
          • Custom script: call RemoveLocation(udg_StopLifeSteal)
          • Custom script: call RemoveLocation(udg_TargetLoc)
          • Custom script: call RemoveLocation(udg_CasterLoc)
          • Trigger - Turn off (This trigger)
Hope you understand what is my question ;D
 
No, of course not, destroying one timer will stop its effect; plus, that condition doesn't leak.
By the way, you have a wrong condition there; it should be Remaining time Greater than 0.
If you just used Countdown Timer - Start timer, then you don't need the custom script leak removal. If you did, then, in the Else - Actions, you will need it.

Finally, this:
  • If - Conditions
    • (Target has buff Drain Life (Target)) Equal to True
    • (Integer((Remaining time for Duration))) Greater than 0
is equal to yours:
  • If - Conditions
    • And - All (Conditions) are true
      • Conditions
        • (Target has buff Drain Life (Target)) Equal to True
        • (Integer((Remaining time for Duration))) Not equal to 0
By default, subconditions are "and".
 
Status
Not open for further replies.
Top