About Projectile Intercept Function

Mar 30th, 2015
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////about the function
  3. 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.
  4. 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.
  5. 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.
  7. The function arguments:
  9. stid = shooter tid*
  10. ttid = target tid*
  11. spd = speed of projectile (in fixed point)
  12. xoff = xoffset from shooter used in projectile origin (fixed point)
  13. yoff = same thing but with y
  14. zoff = same thing but with z
  15. ptype = string projectile actor
  16. axoff = xoffset from shooter applied after projectile angle and speeds are calculated (fixed point)
  17. ayoff = same but with y, azoff = same but with z
  18. angoff = angle offset applied after projectile angle is calculated**
  19. rand = bool if should use a random angle in between the calculated intercept angle and present angle instead of intercept angle***
  20. input_t = t (time in tics, fixed point, where projectile and target are predicted to collide) to use instead of calculated intercept angle****
  22. *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
  23. **For instance a mancubus's angled shot
  24. ***see included png for visual explanation
  25. ****useful for firing multiple projectiles with the same randomized intercept angle, like for instance the mancubus
  27. 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
RAW Paste Data