Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "zcommon.acs"
- #include "Funcs.acs"
- #define x 0
- #define y 1
- #define z 2
- #define w 3
- //#define p_used 3
- #define startpoint 0
- #define endpoint 1
- function int bellscale_i (int cur, int maxamount)
- {
- int ret = 4.0;
- cur = itof(cur);
- maxamount= itof(maxamount);
- ret = fixedmul(ret,fixeddiv(cur,maxamount));
- ret = fixedmul(ret,1.0-fixeddiv(cur,maxamount));
- //printbold(s:"bellscale_i: " ,f:ret);
- return ret;
- }
- script "spawnbolt" (void)
- {
- int nodes1[512][3];
- int max_node_offset_xy = 15.0; //maximum randomized node offset
- int max_node_offset_z = 10.0;
- int node_sparsity = 30.0; // distance between nodes
- int maxrange = 768.0;
- int base_xyoffset = 10.0;
- int base_zoffset = 10.0;
- int base_angle = getactorangle(0);
- int base_pitch = getactorpitch(0);
- int start_x = getactorx(0) + fixedmul(cos(base_pitch),fixedmul(cos(base_angle),10.0)) - fixedmul(sin(base_pitch),fixedmul(cos(base_angle),base_zoffset));
- int start_y = getactory(0) + fixedmul(cos(base_pitch),fixedmul(sin(base_angle),10.0)) - fixedmul(sin(base_pitch),fixedmul(sin(base_angle),base_zoffset));
- int start_z = getactorz(0) - fixedmul(cos(base_pitch),base_zoffset) + getactorviewheight(0);
- int pufftid = unusedtid(1000,5000);
- lineattack(0,base_angle,base_pitch,0,"lpuff",0,maxrange,FHF_NORANDOMPUFFZ ,pufftid);
- int puff_x = getactorx(pufftid);
- int puff_y = getactory(pufftid);
- int puff_z = getactorz(pufftid);
- int puffdist = distance(start_x, start_y, start_z, puff_x, puff_y, puff_z);
- int dist = puffdist;
- int nodecount = ftoi(fixeddiv(dist,node_sparsity));
- for(int i = 0; i<=nodecount; i++) //generate nodes
- {
- nodes1[i][x] = start_x + fixedmul(bellscale_i(i,nodecount),random(-max_node_offset_xy,max_node_offset_xy)) + (i*fixedmul(fixedmul(cos(base_angle),node_sparsity),cos(base_pitch)));
- nodes1[i][y] = start_y + fixedmul(bellscale_i(i,nodecount),random(-max_node_offset_xy,max_node_offset_xy)) (i*fixedmul(fixedmul(sin(base_angle),node_sparsity),cos(base_pitch)));
- nodes1[i][z] = start_z + fixedmul(bellscale_i(i,nodecount),random(-max_node_offset_z,max_node_offset_z)) + (i*fixedmul(sin(-base_pitch),node_sparsity));
- nodes1[i][w] = 1;
- }
- for(int j = 0; j < nodecount;j++)//spawn particles between nodes
- {
- int xdif = nodes1[j+1][x] - nodes1[j][x] ;
- int ydif = nodes1[j+1][y] - nodes1[j][y] ;
- int zdif = nodes1[j+1][z] - nodes1[j][z] ;
- int t_dist3 = magnitudethree_f(xdif,ydif,zdif);
- int t_dist2 = magnitudetwo_f(xdif,ydif);
- int t_angle = vectorangle(xdif, ydif);
- int t_pitch = vectorangle(t_dist2,zdif);
- boltfunc_ang_fractal
- (
- nodes1[j][x],
- nodes1[j][y],
- nodes1[j][z],
- t_angle, //XY angle to next point
- t_pitch, //Z angle to next point
- t_dist3, //distance to next point
- 75, //fork chance
- 4, //maximum forks
- 0.00007, //radius
- 0x7FFFFFF, //color
- 255 //alpha
- );
- }
- }
- function void boltfunc_ang_fractal (int start_x, int start_y, int start_z, int ang, int vang, int dist, int forkchance, int maxforks, int bolt_radius, int color, int alpha)
- {
- int bolt_sparsity = 0.25; //distance between bolt particles
- //int bolt_radius = 0.00004;
- int bolt_time = 5; //time in tics that the bolt stays
- int bolt_tics = ftoi(fixeddiv(dist,bolt_sparsity));
- for(int k = 0; k<=bolt_tics;k++)
- {
- spawnparticle
- (
- color,1,bolt_time,bolt_radius,
- start_x + (k*fixedmul(cos(vang),fixedmul(cos(ang),bolt_sparsity))),
- start_y + (k*fixedmul(cos(vang),fixedmul(sin(ang),bolt_sparsity))),
- start_z + (k*fixedmul(sin(vang),bolt_sparsity)),
- 0,0,0,0,0,0,
- alpha
- );
- }
- for(int i = 0; i<=maxforks; i++)
- {
- if(random(0,100)<= forkchance)
- {
- boltfunc_ang_fractal
- (
- start_x+(bolt_tics*fixedmul(cos(vang),fixedmul(cos(ang),bolt_sparsity))),
- start_y+(bolt_tics*fixedmul(cos(vang),fixedmul(sin(ang),bolt_sparsity))),
- start_z+(bolt_tics*fixedmul(sin(vang),bolt_sparsity)),
- ang+random(-0.1,0.1),
- vang+random(-0.1,0.1),
- fixedmul(dist, random(0.5,0.75)),
- forkchance-25,
- maxforks-1,
- /*bolt_radius*/ 0.00004,
- color - 0x7424200,
- 255
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement