Guest User

Untitled

a guest
Dec 6th, 2016
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "zcommon.acs"
  2. #include "Funcs.acs"
  3.  
  4.  
  5. #define x 0
  6. #define y 1
  7. #define z 2
  8. #define w 3
  9. //#define p_used 3
  10.  
  11.  
  12. #define startpoint 0
  13. #define endpoint 1
  14.  
  15. function int bellscale_i (int cur, int maxamount)
  16. {
  17. int ret = 4.0;
  18. cur = itof(cur);
  19. maxamount= itof(maxamount);
  20.  
  21. ret = fixedmul(ret,fixeddiv(cur,maxamount));
  22. ret = fixedmul(ret,1.0-fixeddiv(cur,maxamount));
  23. //printbold(s:"bellscale_i: " ,f:ret);
  24. return ret;
  25. }
  26.  
  27. script "spawnbolt" (void)
  28. {
  29. int nodes1[512][3];
  30.  
  31. int max_node_offset_xy = 15.0; //maximum randomized node offset
  32. int max_node_offset_z = 10.0;
  33. int node_sparsity = 30.0; // distance between nodes
  34. int maxrange = 768.0;
  35.  
  36. int base_xyoffset = 10.0;
  37. int base_zoffset = 10.0;
  38.  
  39. int base_angle = getactorangle(0);
  40. int base_pitch = getactorpitch(0);
  41. 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));
  42. 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));
  43. int start_z = getactorz(0) - fixedmul(cos(base_pitch),base_zoffset) + getactorviewheight(0);
  44.  
  45. int pufftid = unusedtid(1000,5000);
  46.  
  47.  
  48.  
  49. lineattack(0,base_angle,base_pitch,0,"lpuff",0,maxrange,FHF_NORANDOMPUFFZ ,pufftid);
  50. int puff_x = getactorx(pufftid);
  51. int puff_y = getactory(pufftid);
  52. int puff_z = getactorz(pufftid);
  53. int puffdist = distance(start_x, start_y, start_z, puff_x, puff_y, puff_z);
  54. int dist = puffdist;
  55. int nodecount = ftoi(fixeddiv(dist,node_sparsity));
  56.  
  57. for(int i = 0; i<=nodecount; i++) //generate nodes
  58. {
  59. 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)));
  60. 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)));
  61. 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));
  62. nodes1[i][w] = 1;
  63. }
  64. for(int j = 0; j < nodecount;j++)//spawn particles between nodes
  65. {
  66.  
  67. int xdif = nodes1[j+1][x] - nodes1[j][x] ;
  68. int ydif = nodes1[j+1][y] - nodes1[j][y] ;
  69. int zdif = nodes1[j+1][z] - nodes1[j][z] ;
  70. int t_dist3 = magnitudethree_f(xdif,ydif,zdif);
  71. int t_dist2 = magnitudetwo_f(xdif,ydif);
  72. int t_angle = vectorangle(xdif, ydif);
  73. int t_pitch = vectorangle(t_dist2,zdif);
  74.  
  75. boltfunc_ang_fractal
  76. (
  77. nodes1[j][x],
  78. nodes1[j][y],
  79. nodes1[j][z],
  80. t_angle, //XY angle to next point
  81. t_pitch, //Z angle to next point
  82. t_dist3, //distance to next point
  83. 75, //fork chance
  84. 4, //maximum forks
  85. 0.00007, //radius
  86. 0x7FFFFFF, //color
  87. 255 //alpha
  88. );
  89. }
  90. }
  91.  
  92.  
  93. 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)
  94. {
  95. int bolt_sparsity = 0.25; //distance between bolt particles
  96. //int bolt_radius = 0.00004;
  97. int bolt_time = 5; //time in tics that the bolt stays
  98. int bolt_tics = ftoi(fixeddiv(dist,bolt_sparsity));
  99.  
  100. for(int k = 0; k<=bolt_tics;k++)
  101. {
  102. spawnparticle
  103. (
  104. color,1,bolt_time,bolt_radius,
  105. start_x + (k*fixedmul(cos(vang),fixedmul(cos(ang),bolt_sparsity))),
  106. start_y + (k*fixedmul(cos(vang),fixedmul(sin(ang),bolt_sparsity))),
  107. start_z + (k*fixedmul(sin(vang),bolt_sparsity)),
  108. 0,0,0,0,0,0,
  109. alpha
  110. );
  111. }
  112. for(int i = 0; i<=maxforks; i++)
  113. {
  114. if(random(0,100)<= forkchance)
  115. {
  116. boltfunc_ang_fractal
  117. (
  118. start_x+(bolt_tics*fixedmul(cos(vang),fixedmul(cos(ang),bolt_sparsity))),
  119. start_y+(bolt_tics*fixedmul(cos(vang),fixedmul(sin(ang),bolt_sparsity))),
  120. start_z+(bolt_tics*fixedmul(sin(vang),bolt_sparsity)),
  121. ang+random(-0.1,0.1),
  122. vang+random(-0.1,0.1),
  123. fixedmul(dist, random(0.5,0.75)),
  124. forkchance-25,
  125. maxforks-1,
  126. /*bolt_radius*/ 0.00004,
  127. color - 0x7424200,
  128. 255
  129. );
  130. }
  131. }
  132. }
RAW Paste Data