Target Prediction Formula?

LurkerAspect

Now officially a Super Lurker
Reaction score
118
Haha lol I'm not being serious. Besides, the function I've put up there only uses the equations perkeyone gave me, the rest is freestyled.

Basically this equation (or at least my edition) can't seem to target a stopped target, ie. if the target is NOT moving, the projectile is never aimed at it for some reason.

Instantaneous speed is known as in science as the speed of an object at a single given moment in time, so in other words, the speed right at this instant. So, if I had a function which gave me the exact speed that a unit is moving at at any given time, then I could tweak the function to aim at the stopped target instead.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Ok, well sorry for "snapping" at you like that then XD
Wouldn't really have cared anyways :p

Anyways, maybe this little script can help you, it will update evey unit on the map's current speed (In 'units' per second):
JASS:
library UnitSpeed initializer Init requires TimerUtils, AIDS

    globals
        private constant real TRACK_PERIOD = 0.01
    endglobals
    
    private struct UnitSpeed extends array
        //! runtextmacro AIDS()
        
        timer trackTimer
        
        real unitX
        real unitY
        real currentSpeed
        
        private method AIDS_onCreate takes nothing returns nothing
            set trackTimer = NewTimer()
            set unitX = GetUnitX( unit )
            set unitY = GetUnitY( unit )
            set currentSpeed = 0
            
            call SetTimerData( trackTimer, this )
            call TimerStart( trackTimer, TRACK_PERIOD, true, function thistype.SpeedTracking )
        endmethod
        
        private static method SpeedTracking takes nothing returns nothing
            local thistype this = GetTimerData( GetExpiredTimer() )
            local real x = GetUnitX( unit )
            local real y = GetUnitY( unit )
            local real difx = x - unitX
            local real dify = y - unitY
            local real dist = SquareRoot( difx * difx + dify * dify )
            
            set currentSpeed = dist / TRACK_PERIOD
            set unitX = x
            set unitY = y
        endmethod
        
        private method AIDS_onDestroy takes nothing returns nothing
            call ReleaseTimer( trackTimer )
        endmethod
            
    endstruct        
    
endlibrary
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
Ok, well sorry for "snapping" at you like that then XD
Wouldn't really have cared anyways :p
Naw it doesn't bother me at all :) but I would never try to take someone else's system for any reason (at least not without asking them)

Thanks for all the help and I'll definitely make sure you are well credited in my upcoming map, which will be based mostly on this system!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top