Exponetial Slide Function

SouLEDGE

Damn you advanced calculus
Reaction score
75
Okay, so I have my spell: Impale shot
The caster targets a unit and impales him with a rope spear(spear rope? spear attached to a rope:p) and yanks the unit towards the caster.
Achieved with few simple slide triggers but I want to know if it's possible to use an exponential function for the distance the unit moves each time the periodic event fires off... hope that made sense to anyone.

Basically the unit is going to slow down the closer he gets to his destination.
I thought of: f(x)= -2^x+c . X and Y > 0. Y would be the distance the unit moves and X the periodic event time. Honestly I suck at math, so I can't figure out how to use this function for the distance.

Any help would be appreciated
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Assuming:

Max range of spell == 1000.00
Max speed of pull == 600.00
Min speed of pull == 100.00

JASS:
globals
     private constant real MAXRange = 1000.00
     private constant real MAXSpeed = 600.00
     private constant real MINRange = 0.00
     private constant real MINSpeed = 100.00

     //Don't change unless you know what you are doing..
     private constant real gradient = (MAXRange - MINRange) / (MAXSpeed - MINSpeed)
     private constant real Constant = MAXRange - (MAXSpeed * gradient)
endglobals

//Then, to find your 'speed based on distance'
function Something takes nothing returns nothing
     real CasterX
     real CasterY
     real EnemyX
     real EnemyY
     real Distance
     real dx
     real dy
     real Speed

     set dx = CasterX - EnemyX
     set dy = CasterY - EnemyY
     set Distance = SquareRoot( dx * dx + dy * dy )
     
     set Speed = (Distance - Constant) / gradient

      //Tada!! You haz your speed!
endfunction


You can change the values however you want, I suppose.
If anything doesn't work, tell me =x
(Untested)

[EDIT]
But that will make the enemy slow down at a constant rate..
Do you really want it to be exponential?
 

SouLEDGE

Damn you advanced calculus
Reaction score
75
I think it will give it a better feel, because this is a far ranged spell.
You don't want your target to come flying at you from 3000 distance away then suddenly stop in your face:p
Will test tomorrow though...need sleep
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top