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

How to measure the time of arrival of a projectile

Level 9
Joined
May 24, 2016
Messages
317
Hello, I'm using BPower's missile system, and I have an ability to throw snowball from a hero point to target point.

JASS:
call TriggerExecute( gg_trg_Missile_Configurate )
        set udg_Missile__Owner = GetOwningPlayer(c)
    set udg_Missile__Origin = GetUnitLoc(c)
    set udg_Missile__OriginZ = 70
    set udg_Missile__Impact = Location(x,y) //Get Spell target x and y 
    set udg_Missile__ImpactZ = 40.00

    set udg_Missile__Speed = 600 
    if LVL == 1 then
    set udg_Missile__Scale = 1.25
    elseif LVL == 2 then 
    set udg_Missile__Scale = 1.45
    else
    set udg_Missile__Scale = 1.65
    endif

        set udg_Missile__Arc = 55
    set udg_Missile__Collision = 108.00
    set udg_Missile__Height = 800
    set udg_Missile__Damage = mp //its damage actually
    

    set udg_Missile__Model = "war3mapImported\\FrostOrb.mdx"
    udg_Missile__OnRemove= gg_trg_LichFrostNova
        set udg_Missile__Data = GetPlayerId(GetOwningPlayer(c))
Since it's not a homing projectile, I believe there's a way to measure a time projectile takes to reach the target point. I want to give special effect to target x y right before missile actually reaches the target point.
 
Level 9
Joined
May 24, 2016
Messages
317
d = vt, so t = <distance to target>/<missile speed>.

d = sqrt((y-launchY) x (y-launchY) + (x-launchX) x (x-launchX))
v = 600 or some function of missile speed (600) and arc (55), but I suspect it's a constant ground speed in the system.
My man, thx you. Wish I was studying math properly.
Can I able to edit that formula, so I could predict when missile lands 2 seconds earlier? So they could see warning effect at the target point.
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,725
My man, thx you. Wish I was studying math properly.
Can I able to edit that formula, so I could predict when missile lands 2 seconds earlier? So they could see warning effect at the target point.
Once you've determined your time variable, subtract 2 from it, and use that as the duration of a timer. Once said timer expires you can create your special effect.

Just make sure that the value isn't negative. Starting a timer with a negative value will crash the game afaik.
  • -------- Do some math to calculate Time --------
  • Set Variable DelayBeforeEffect = (Time - 2.00)
  • If DelayBeforeEffect is Less than 0.00 then Set Variable DelayBeforeEffect = 0.00
  • Countdown Timer - Start EffectTimer as a One-shot timer that will expire after DelayBeforeEffect seconds
 
Last edited:
Level 9
Joined
May 24, 2016
Messages
317
Once you've determined your time variable, subtract 2 from it, and use that as the duration of a timer. Once said timer expires you can create your special effect.

Just make sure that the value isn't negative. Starting a timer with a negative value will crash the game afaik.
  • -------- Do some math to calculate Time --------
  • Set Variable DelayBeforeEffect = (Time - 2.00)
  • If DelayBeforeEffect is Less than 0.00 then Set Variable DelayBeforeEffect = 0.00
  • Countdown Timer - Start EffectTimer as a One-shot timer that will expire after DelayBeforeEffect seconds
Thx you. You prevented my map from sudden crahes. Never thought about running timer with negative values consequences.

SOLVED.
 
Level 9
Joined
May 24, 2016
Messages
317
Once you've determined your time variable, subtract 2 from it, and use that as the duration of a timer. Once said timer expires you can create your special effect.

Just make sure that the value isn't negative. Starting a timer with a negative value will crash the game afaik.
  • -------- Do some math to calculate Time --------
  • Set Variable DelayBeforeEffect = (Time - 2.00)
  • If DelayBeforeEffect is Less than 0.00 then Set Variable DelayBeforeEffect = 0.00
  • Countdown Timer - Start EffectTimer as a One-shot timer that will expire after DelayBeforeEffect seconds
Uncle, my next question is pretty simple so I dont wanna overspam question section

What's the point of function SetTextTagPermanent? F.e if you do not set lifespam for textag, would not it remain permament anyway? And what will happen if you give lifespam for textag and set permament as false for it?
 

Uncle

Warcraft Moderator
Level 66
Joined
Aug 10, 2018
Messages
6,725
Uncle, my next question is pretty simple so I dont wanna overspam question section

What's the point of function SetTextTagPermanent? F.e if you do not set lifespam for textag, would not it remain permament anyway? And what will happen if you give lifespam for textag and set permament as false for it?
They're permanent by default which prevents Lifespan from destroying them.

If you disable the permanence then the Text Tag will be destroyed after it's Lifespan expires.

I suppose there could be some situations where it's useful. Like you periodically apply Lifespans to an ever changing Array of Text Tags, and control which ones get destroyed by toggling their permanence. But it does seem a bit odd to me, if you give a Text Tag a Lifespan then clearly you want it destroyed, so why add an extra step?
 
Last edited:
Level 9
Joined
May 24, 2016
Messages
317
They're permanent by default which prevents Lifespan from destroying them.

If you disable the permanence then the Text Tag will be destroyed after it's Lifespan expires.

I suppose there could be some situations where it's useful. Like you periodically apply Lifespans to an ever changing Array of Text Tags, and control which ones get destroyed by toggling their permanence. But it does seem a bit odd to me, if you give a Text Tag a Lifespan then clearly you want it destroyed, so why add an extra step?
Uncle please help me more

The problem that my "constant" textag are not showing through the fog of war.


JASS:
set tx = CreateTextTag() //local texttag tx
call SetTextTagColor(tx, 255, 225, 200, 250) //250
            call SetTextTagTexBtJ(tx, "bla bla bla ", 12) //0.014
            call SetTextTagPos(tx, -680, 3857, 0)
// call SetTextTagPermanent(tx, FALSE)
set tx = CreateTextTag() //local texttag tx
call SetTextTagColor(tx, 255, 225, 200, 250) //250
            call SetTextTagTexBtJ(tx, "bla bla bla2 ", 12) //0.014
            call SetTextTagPos(tx, -980, 4857, 0)
// call SetTextTagPermanent(tx, FALSE)
 
Last edited:
Top