SHARE
TWEET

Untitled

a guest Oct 2nd, 2016 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "zcommon.acs"
  2.  
  3. #define LSI_ltcnt 256
  4. #define LSI_ltcnth (LSI_ltcnt/2)
  5. #define LSI_ltcntq (LSI_ltcnt/4)
  6. #define LSI_ltcnt2 (LSI_ltcnt*2)
  7.  
  8. function int GetAlpha(int a1, int a2)
  9. {
  10.     return a2 * a1 / 255; // use like GetAlpha(multiplier, alpha)
  11. }
  12.  
  13. script "LightningSingleInstance" (int cx, int cy, int cz, int angle)
  14. {
  15.     //
  16.     bool ltsetup = false;
  17.    
  18.     //
  19.     int lt_circle[LSI_ltcntq]; // Z random.
  20.     int lt_circled[LSI_ltcntq]; // distance random.
  21.    
  22.     //
  23.     int lt_line[LSI_ltcntq]; // Z random
  24.     int lt_lined[LSI_ltcntq]; // perpendicular random whatever its called. relative X?
  25.    
  26.     //
  27.     int offset = cz;
  28.     int zoffs = 2.0;
  29.    
  30.     //
  31.     int anglep = angle+0.25; // this is the angle used to offset lightning by lined.
  32.    
  33.     // calculate line dx/dy/dz
  34.     int ldx = sin(anglep);
  35.     int ldy = cos(anglep);
  36.     int ldx2 = sin(angle);
  37.     int ldy2 = cos(angle);
  38.    
  39.     //
  40.     int up = 128;
  41.     int l;
  42.     for (int k = 0; k < up; k++)
  43.     {
  44.         int runalpha = 255 - (k * 255 / up);
  45.        
  46.         if (!ltsetup || (Timer()%4 == 0))
  47.         {
  48.             for (l = 0; l < LSI_ltcntq; l++)
  49.             {
  50.                 lt_circle[l] = Random(-3.0, 3.0);
  51.                 lt_circled[l] = Random(-2.0, 2.0);
  52.                 lt_line[l] = Random(-8.0, 8.0);
  53.                 lt_lined[l] = Random(-8.0, 8.0);
  54.             }
  55.         }
  56.        
  57.         int ltcircang = 65535/LSI_ltcnt;
  58.         int j;
  59.         for (j = 0; j < LSI_ltcnt; j++)
  60.         {
  61.             int ltc_curr = lt_circle[j/4];
  62.             int ltc_next = lt_circle[(j/4+1)%LSI_ltcntq];
  63.             int ltc_offs = j % 4;
  64.             int ltc = ltc_curr * (3-ltc_offs) / 3 + ltc_next * ltc_offs / 3;
  65.            
  66.             int ltc_currd = lt_circled[j/4];
  67.             int ltc_nextd = lt_circled[(j/4+1)%LSI_ltcntq];
  68.             int ltcd = ltc_currd * (3-ltc_offs) / 3 + ltc_nextd * ltc_offs / 3;
  69.            
  70.             // draw particle at this position.
  71.             int ltcx = FixedMul(sin(j*ltcircang), 32.0 + ltcd) + cx;
  72.             int ltcy = FixedMul(cos(j*ltcircang), 32.0 + ltcd) + cy;
  73.             int ltcz = k * zoffs + ltc + cz;
  74.            
  75.             //
  76.             if (j%2==0) SpawnParticle(0xFFFFFF, true, 1, 12, ltcx, ltcy, ltcz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 32), 0);
  77.             SpawnParticle(0xFFFFFF, true, 1, 3, ltcx, ltcy, ltcz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 255), 0);
  78.         }
  79.        
  80.         // now draw the lines!
  81.         for (j = 0; j < LSI_ltcnt2; j++)
  82.         {
  83.             int lt_curr = lt_line[j/8];
  84.             int lt_next = lt_line[(j/8+1)%LSI_ltcntq];
  85.             int lt_offs = j % 8;
  86.             int ltl = lt_curr * (7-lt_offs) / 7 + lt_next * lt_offs / 7;
  87.            
  88.             int lt_currd = lt_lined[j/8];
  89.             int lt_nextd = lt_lined[(j/8+1)%LSI_ltcntq];
  90.             int ltld = lt_currd * (7-lt_offs) / 7 + lt_nextd * lt_offs / 7;
  91.            
  92.             int ltx = cx + FixedMul(ldx, 32.0+(j<<16)/2) + FixedMul(ldx2, ltl);
  93.             int lty = cy + FixedMul(ldy, 32.0+(j<<16)/2) + FixedMul(ldy2, ltl);
  94.             int ltz = k * zoffs + ltld + cz;
  95.            
  96.             //
  97.             if (j%4==0) SpawnParticle(0xFFFFFF, true, 1, 24, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 16), 0);
  98.             if (j%2==0) SpawnParticle(0xFFFFFF, true, 1, 8, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 32), 0);
  99.             SpawnParticle(0xFFFFFF, true, 1, 3, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 255), 0);
  100.         }
  101.        
  102.         Delay(1);
  103.     }
  104. }
  105.  
  106. script "LightningSingle" (int tag)
  107. {
  108.     int cx = GetActorX(tag);
  109.     int cy = GetActorY(tag);
  110.     int cz = GetActorZ(tag)-304.0;
  111.     int angle = GetActorAngle(tag);
  112.    
  113.     while (true)
  114.     {
  115.         if (Timer()%35==0)
  116.             ACS_NamedExecuteWithResult("LightningSingleInstance", cx, cy, cz, angle);
  117.         Delay(1);
  118.     }
  119. }
  120.  
  121. script "Lightning" OPEN
  122. {
  123.     ACS_NamedExecuteWithResult("LightningSingle", 1, 0, 0, 0);
  124.     ACS_NamedExecuteWithResult("LightningSingle", 2, 0, 0, 0);
  125. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top