Advertisement
Chronos_Ouroboros

A_BFGItemSpray

Dec 13th, 2018
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1.     void A_BFGItemSpray(class<Inventory> itemType, int itemCount = 1, int numrays = 40, double ang = 90, double distance = 16*64, double vrange = 32, int flags = 0)
  2.     {
  3.         FTranslatedLineTarget t;
  4.  
  5.         // validate parameters
  6.         if (spraytype == null) return;
  7.         if (itemCount == 0) return;
  8.         if (numrays <= 0) numrays = 40;
  9.         if (ang == 0) ang = 90.;
  10.         if (distance <= 0) distance = 16 * 64;
  11.         if (vrange == 0) vrange = 32.;
  12.  
  13.         // [XA] Set the originator of the rays to the projectile (self) if
  14.         //      the new flag is set, else set it to the player (target)
  15.         Actor originator = (flags & BFGF_MISSILEORIGIN) ? self : target;
  16.  
  17.         // [RH] Don't crash if no target
  18.         if (!originator)
  19.             return;
  20.  
  21.         // offset angles from its attack ang
  22.         for (int i = 0; i < numrays; i++) {
  23.             double an = angle - ang / 2 + ang / numrays*i;
  24.  
  25.             originator.AimLineAttack (an, distance, t, vrange);
  26.  
  27.             if (t.linetarget != null) {
  28.                 if (itemCount > 0)
  29.                     t.linetarget.GiveInventory (itemType, itemCount);
  30.                 else
  31.                     t.linetarget.TakeInventory (itemType, itemCount);
  32.             }
  33.         }
  34.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement