Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "zcommon.acs"
- #define LSI_ltcnt 256
- #define LSI_ltcnth (LSI_ltcnt/2)
- #define LSI_ltcntq (LSI_ltcnt/4)
- #define LSI_ltcnt2 (LSI_ltcnt*2)
- function int GetAlpha(int a1, int a2)
- {
- return a2 * a1 / 255; // use like GetAlpha(multiplier, alpha)
- }
- script "LightningSingleInstance" (int cx, int cy, int cz, int angle)
- {
- //
- bool ltsetup = false;
- //
- int lt_circle[LSI_ltcntq]; // Z random.
- int lt_circled[LSI_ltcntq]; // distance random.
- //
- int lt_line[LSI_ltcntq]; // Z random
- int lt_lined[LSI_ltcntq]; // perpendicular random whatever its called. relative X?
- //
- int offset = cz;
- int zoffs = 2.0;
- //
- int anglep = angle+0.25; // this is the angle used to offset lightning by lined.
- // calculate line dx/dy/dz
- int ldx = sin(anglep);
- int ldy = cos(anglep);
- int ldx2 = sin(angle);
- int ldy2 = cos(angle);
- //
- int up = 128;
- int l;
- for (int k = 0; k < up; k++)
- {
- int runalpha = 255 - (k * 255 / up);
- if (!ltsetup || (Timer()%4 == 0))
- {
- for (l = 0; l < LSI_ltcntq; l++)
- {
- lt_circle[l] = Random(-3.0, 3.0);
- lt_circled[l] = Random(-2.0, 2.0);
- lt_line[l] = Random(-8.0, 8.0);
- lt_lined[l] = Random(-8.0, 8.0);
- }
- }
- int ltcircang = 65535/LSI_ltcnt;
- int j;
- for (j = 0; j < LSI_ltcnt; j++)
- {
- int ltc_curr = lt_circle[j/4];
- int ltc_next = lt_circle[(j/4+1)%LSI_ltcntq];
- int ltc_offs = j % 4;
- int ltc = ltc_curr * (3-ltc_offs) / 3 + ltc_next * ltc_offs / 3;
- int ltc_currd = lt_circled[j/4];
- int ltc_nextd = lt_circled[(j/4+1)%LSI_ltcntq];
- int ltcd = ltc_currd * (3-ltc_offs) / 3 + ltc_nextd * ltc_offs / 3;
- // draw particle at this position.
- int ltcx = FixedMul(sin(j*ltcircang), 32.0 + ltcd) + cx;
- int ltcy = FixedMul(cos(j*ltcircang), 32.0 + ltcd) + cy;
- int ltcz = k * zoffs + ltc + cz;
- //
- if (j%2==0) SpawnParticle(0xFFFFFF, true, 1, 12, ltcx, ltcy, ltcz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 32), 0);
- SpawnParticle(0xFFFFFF, true, 1, 3, ltcx, ltcy, ltcz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 255), 0);
- }
- // now draw the lines!
- for (j = 0; j < LSI_ltcnt2; j++)
- {
- int lt_curr = lt_line[j/8];
- int lt_next = lt_line[(j/8+1)%LSI_ltcntq];
- int lt_offs = j % 8;
- int ltl = lt_curr * (7-lt_offs) / 7 + lt_next * lt_offs / 7;
- int lt_currd = lt_lined[j/8];
- int lt_nextd = lt_lined[(j/8+1)%LSI_ltcntq];
- int ltld = lt_currd * (7-lt_offs) / 7 + lt_nextd * lt_offs / 7;
- int ltx = cx + FixedMul(ldx, 32.0+(j<<16)/2) + FixedMul(ldx2, ltl);
- int lty = cy + FixedMul(ldy, 32.0+(j<<16)/2) + FixedMul(ldy2, ltl);
- int ltz = k * zoffs + ltld + cz;
- //
- if (j%4==0) SpawnParticle(0xFFFFFF, true, 1, 24, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 16), 0);
- if (j%2==0) SpawnParticle(0xFFFFFF, true, 1, 8, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 32), 0);
- SpawnParticle(0xFFFFFF, true, 1, 3, ltx, lty, ltz, 0, 0, 0, 0, 0, 0, GetAlpha(runalpha, 255), 0);
- }
- Delay(1);
- }
- }
- script "LightningSingle" (int tag)
- {
- int cx = GetActorX(tag);
- int cy = GetActorY(tag);
- int cz = GetActorZ(tag)-304.0;
- int angle = GetActorAngle(tag);
- while (true)
- {
- if (Timer()%35==0)
- ACS_NamedExecuteWithResult("LightningSingleInstance", cx, cy, cz, angle);
- Delay(1);
- }
- }
- script "Lightning" OPEN
- {
- ACS_NamedExecuteWithResult("LightningSingle", 1, 0, 0, 0);
- ACS_NamedExecuteWithResult("LightningSingle", 2, 0, 0, 0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement