DOWNLOAD

Spoiler: From the readme included in the pk3

///////about the function

Function uses smart brute force to figure out when a projectile fired at a target will hit a target based upon the target's current speed (if at all) and thus the heading it will need to hit it.

Can also fire at a random angle between the angle for for the intercept vector and the target's current position for a randomized (and less predictable) firing and also so it looks more natural for monsters.

Will stop trying to figure out the time of impact if it would take longer than 400 tics (~11.5 seconds) to hit, both because it's a waste of computation and in most cases would look dumb since the monster would usually turn around and fire in a direction nowhere near the player.

The function arguments:

stid = shooter tid*

ttid = target tid*

spd = speed of projectile (in fixed point)

xoff = xoffset from shooter used in projectile origin (fixed point)

yoff = same thing but with y

zoff = same thing but with z

ptype = string projectile actor

axoff = xoffset from shooter applied after projectile angle and speeds are calculated (fixed point)

ayoff = same but with y, azoff = same but with z

angoff = angle offset applied after projectile angle is calculated**

rand = bool if should use a random angle in between the calculated intercept angle and present angle instead of intercept angle***

input_t = t (time in tics, fixed point, where projectile and target are predicted to collide) to use instead of calculated intercept angle****

*Don't need to be specified, as it will get them anyway if they're left at 0 so long as script activator is the shooter, otherwise tids are required

**For instance a mancubus's angled shot

***see included png for visual explanation

****useful for firing multiple projectiles with the same randomized intercept angle, like for instance the mancubus

Function returns t (the time in fixed point tics where the projectile and target are predicted to collide), which can be used to do such things as fire multiple projectiles with the same randomized intercept angle

///////Credits

commonFuncs.h by ijon tichy, updated by marrub and Kyle873

mathFuncs.h thrown together by scroton but all of it was code already used by real coding languages that just happened to not be in acs, so don't credit scroton

the rest of the crap by scroton