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

Is there a leak that need to be cleared?

Status
Not open for further replies.
Level 13
Joined
Aug 19, 2014
Messages
1,111
Hello guys I just wanna ask if there is a leak that needed to be cleared.


Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to |cffadff2fBinding Shot|r
Actions
-------- ------------------------------------------------------------------------------------------------- --------
-------- Getting the Spell constants --------
-------- ------------------------------------------------------------------------------------------------- --------
Set Temp_Unit = (Triggering unit)
Set Temp_Target = (Target unit of ability being cast)
Set Temp_Ability_Level = (Level of (Ability being cast) for Temp_Unit)
-------- ------------------------------------------------------------------------------------------------- --------
-------- Setting the Spell values --------
-------- ------------------------------------------------------------------------------------------------- --------
Set Temp_Base_Damage = 10.00
Set Temp_Total_Damage = (Temp_Base_Damage x (Real(Temp_Ability_Level)))
-------- ------------------------------------------------------------------------------------------------- --------
Unit - Cause Temp_Unit to damage Temp_Target, dealing Temp_Total_Damage damage of attack type Pierce and damage type Normal
-------- ------------------------------------------------------------------------------------------------- --------
-------- Clearing leaks --------


The trigger is simple, its just an ensnare ability with damage. The damage is kinda faster than the missile, so the unit receives damage before the missile hits him. Any idea to fix that without making the missile speed faster?
 
Level 17
Joined
Dec 11, 2014
Messages
2,004
Hello guys I just wanna ask if there is a leak that needed to be cleared.


Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to |cffadff2fBinding Shot|r
Actions
-------- ------------------------------------------------------------------------------------------------- --------
-------- Getting the Spell constants --------
-------- ------------------------------------------------------------------------------------------------- --------
Set Temp_Unit = (Triggering unit)
Set Temp_Target = (Target unit of ability being cast)
Set Temp_Ability_Level = (Level of (Ability being cast) for Temp_Unit)
-------- ------------------------------------------------------------------------------------------------- --------
-------- Setting the Spell values --------
-------- ------------------------------------------------------------------------------------------------- --------
Set Temp_Base_Damage = 10.00
Set Temp_Total_Damage = (Temp_Base_Damage x (Real(Temp_Ability_Level)))
-------- ------------------------------------------------------------------------------------------------- --------
Unit - Cause Temp_Unit to damage Temp_Target, dealing Temp_Total_Damage damage of attack type Pierce and damage type Normal
-------- ------------------------------------------------------------------------------------------------- --------
-------- Clearing leaks --------
Please put them in Trigger wraps.

The damage is kinda faster than the missile, so the unit receives damage before the missile hits him. Any idea to fix that without making the missile speed faster?

Chaosy Answered to your problem in a Similar Question. (~5 Threads down)

I think I know an OK way to do this without advanced systems.

Check missile speed in object editor.
When storm bolt (any missile spell) is cast start a timer that lasts for distance to target / missile speed. When timer ends, do stuff.

The only issue here is that if the unit moves it will be slightly invalid.
 
If your missile isn't terribly slow, you can also just use a fixed delay for dealing the damage, like 0.5 seconds.
It doesn't really matter if the damage is perfectly on time or not. That there is a visual delay is what matters. Just take the average time the missile would need to hit the target.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Waiting normal doesnt use game time but real life time (but still inaccurate)
You can place this function in the header or inside a library and use that one instead:
JASS:
    function WaitGameTime takes real duration returns nothing
        local timer t
        local real  timeRemaining
        
        if duration > 0 then
            set t = CreateTimer()
            call TimerStart(t, duration, false, null)
            loop
                set timeRemaining = TimerGetRemaining(t)
                exitwhen timeRemaining <= 0
                
                if timeRemaining > bj_POLLED_WAIT_SKIP_THRESHOLD then
                    call TriggerSleepAction(0.1 * timeRemaining)
                else
                    call TriggerSleepAction(bj_POLLED_WAIT_INTERVAL)
                endif
            endloop
            call DestroyTimer(t)
            set t = null
        endif
    endfunction
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
no
the timer variable t is uninitialized (which is pretty dangerous in JASS but that doesnt matter) anyway, if it succeeds the if statement, then it gets created and therefor has to be destroyed and nulled
so it is not necessary to have outside of the if statement and is even better.
for the nullification of the variable it doesnt matter but if I place the DestroyTimer() outside the if block, it can and will crash the code if the duration is lower than or equal to 0
 
Status
Not open for further replies.
Top