Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1.  
  2. for (%i = 0; %i < %numProjectiles; %i++)
  3. {
  4. if (%this.projectileSpread)
  5. {
  6. // We'll need to "skew" this projectile a little bit. We start by
  7. // getting the straight ahead aiming point of the gun
  8. %vec = %obj.getMuzzleVector(%slot);
  9.  
  10. // Then we'll create a spread matrix by randomly generating x, y, and z
  11. // points in a circle
  12. %matrix = "";
  13. for(%j = 0; %j < 3; %j++)
  14. %matrix = %matrix @ (getRandom() - 0.5) * 2 * 3.1415926 @ " ";
  15. %mat = MatrixCreateFromEuler(%matrix);
  16.  
  17. // Which we'll use to alter the projectile's initial vector with
  18. %muzzleVector = MatrixMulVector(%mat, %vec);
  19. %muzzleVector = VectorScale(VectorNormalize(%muzzleVector),%this.projectileSpread);
  20. }
  21. else
  22. {
  23. // Weapon projectile doesn't have a spread factor so we fire it using
  24. // the straight ahead aiming point of the gun
  25. %muzzleVector = %obj.getMuzzleVector(%slot);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement