What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[CR] Cast Spell at Position; Calculating Position

randomstraw

Community Developer
Joined
Jul 17, 2012
Messages
1,611
Reaction score
10
Lets say i am a Spectral Thrower, and i want to always aim at the position furthest away, to keep the spread of my Spectrals at a minimum, essentially shotgunning near mobs.

the black dot is me, the red dots are enemies, the ourter circle is my projectile range - the purple ones (i guess it was purple, maybe its blue, dunno) are the desired positions to cast my spell at, using the pressShift = true.

my mind is currently around different stuff, has anyone an idea how to start this? ;)


ww3if1e.png
 
This!

My idea would be:

After you now your Spectral Throw Range, wether by calculating it or just a plain variable, lets say it is 40 yards.

Maybe using vectors who are based on distance and angle, if a monster is at 20? degrees direction you would always cast at 20? degrees and 40 yards distance even though the monster was in a closer distance.

Basically you would be interested only on the angle and not the actual distance of the monster since the distance will be always your max Spectral Throw distance. Obviously you still had to do some handling since sometimes that position is not clickable.
 
You can do this easily actually, but you'll need to check for input errors caused by clicking "off screen"

Sorry, this is in 3D (as I'm working on something related to it), but this is easily changed to 2D.

Code:
        public Vector3 GetPositionFacing(Vector3 start, Vector3 target, float distance)        {
            var dir = target - start;
            dir.Normalize();


            return start + (dir * distance);
        }
 
Back
Top