Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.15 KB | None | 0 0
  1. // Generate segmented shield data
  2. //start
  3. var n, n2, c1, c2, d1, d2, width, height, instance, inst, xa, ya, sprite;
  4. var left, right, up, down, u1, v1, total, s, dis, dir, temp_dir, inst_count;
  5. fly_dir = 0;
  6. total = 0;
  7. inst = noone;
  8. height = argument0;
  9. width = argument1;
  10. instance = argument3;
  11.  
  12. switch (size_class) {
  13. case 0:
  14. size_class_pixel = 16;
  15. sprite = Shield_16_SPR;
  16. break;
  17. case 1:
  18. size_class_pixel = 24;
  19. sprite = Shield_24_SPR;
  20. break;
  21. case 2:
  22. size_class_pixel = 32;
  23. sprite = Shield_32_SPR;
  24. break;
  25. case 3:
  26. size_class_pixel = 48;
  27. sprite = Shield_48_SPR;
  28. break;
  29. case 4:
  30. size_class_pixel = 64;
  31. sprite = Shield_64_SPR;
  32. break;
  33. }
  34.  
  35.  
  36.  
  37.  
  38. if argument2 > 0 {
  39. d1[width + 6, height + 6] = -4;
  40. d2[width + 6, height + 6] = 0;
  41. c1[width + 6, height + 6] = 0;
  42. c2[width + 6, height + 6] = 0;
  43. n = 0;
  44. n2 = 0;
  45. while n < width + 6 { //clear tables
  46. while n2 < height + 6 {
  47. d1[n, n2] = -4;
  48. d2[n, n2] = 0;
  49. c1[n, n2] = 0;
  50. c2[n, n2] = 0;
  51. n2++;
  52. }
  53. n++;
  54. n2 = 0;
  55. } //clear tables end
  56. n = 0;
  57. n2 = 0;
  58. //////////////////////////
  59. while n < width { //clear tables
  60. while n2 < height {
  61. d1[n + 1, n2 + 1] = instance[#n, n2];
  62. if instance_exists(instance[#n, n2]) then c1[n + 1, n2 + 1] = 1;
  63. n2++;
  64. }
  65. n++;
  66. n2 = 0;
  67. } //clear tables end
  68. n = 0;
  69. n2 = 0;
  70. s = noone;
  71.  
  72.  
  73.  
  74. while n < width + 2 { //clear tables
  75. while n2 < height + 2 {
  76.  
  77. inst = d1[n, n2];
  78. if inst = 0 then {
  79. inst = noone;
  80. d1[n, n2] = noone;
  81. }
  82.  
  83.  
  84. if inst != noone {
  85. if instance_exists(inst) {
  86. up = c1[n, n2 - 1];
  87. down = c1[n, n2 + 1];
  88. left = c1[n - 1, n2];
  89. right = c1[n + 1, n2];
  90.  
  91. if up = 0 then { /////
  92. inst_count = 0;
  93. if instance_exists(d1[n - 1, n2 - 1]) then inst_count++;
  94. if instance_exists(d1[n + 1, n2 - 1]) then inst_count++;
  95. if instance_exists(d1[n, n2 + 1 - 1]) then inst_count++;
  96. if instance_exists(d1[n, n2 - 1 - 1]) then inst_count++;
  97. if inst_count < 3 then {
  98. c1[n, n2 - 1] = 1;
  99. u1 = inst.x - lengthdir_x(size_class_pixel, image_angle + 90 + 90);
  100. v1 = inst.y - lengthdir_y(size_class_pixel, image_angle + 90 + 90);
  101. dis = point_distance(x, y, u1, v1);
  102. dir = point_direction(u1, v1, x, y) - image_angle;
  103. s = instance_create(x, y, Shield_Module_One);
  104. s.owner = id;
  105. s.angle_offset = dir;
  106. s.placement = dis;
  107. s.sprite_index = sprite;
  108. shield_instance_array[total] = s;
  109. c2[n, n2 - 1] = s;
  110. total++;
  111. }
  112. } ////////
  113.  
  114. if down = 0 then { /////
  115.  
  116. inst_count = 0;
  117. if instance_exists(d1[n - 1, n2 + 1]) then inst_count++;
  118. if instance_exists(d1[n + 1, n2 + 1]) then inst_count++;
  119. if instance_exists(d1[n, n2 + 1 + 1]) then inst_count++;
  120. if instance_exists(d1[n, n2 - 1 + 1]) then inst_count++;
  121. if inst_count < 3 then {
  122. c1[n, n2 + 1] = 1;
  123. u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 270 + 90);
  124. v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 270 + 90);
  125. dis = point_distance(x, y, u1, v1);
  126. dir = point_direction(u1, v1, x, y) - image_angle;
  127. s = instance_create(x, y, Shield_Module_One);
  128. s.owner = id;
  129. s.angle_offset = dir;
  130. s.placement = dis;
  131. s.sprite_index = sprite;
  132. shield_instance_array[total] = s;
  133. c2[n, n2 + 1] = s;
  134. total++;
  135. }
  136. } ////////
  137.  
  138. if left = 0 then { /////
  139.  
  140. inst_count = 0;
  141. if instance_exists(d1[n - 1 - 1, n2]) then inst_count++;
  142. if instance_exists(d1[n + 1 - 1, n2]) then inst_count++;
  143. if instance_exists(d1[n - 1, n2 + 1]) then inst_count++;
  144. if instance_exists(d1[n - 1, n2 - 1]) then inst_count++;
  145. if inst_count < 3 then {
  146. c1[n - 1, n2] = 1;
  147. u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 180 + 90);
  148. v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 180 + 90);
  149. dis = point_distance(x, y, u1, v1);
  150. dir = point_direction(u1, v1, x, y) - image_angle;
  151. s = instance_create(x, y, Shield_Module_One);
  152. s.owner = id;
  153. s.angle_offset = dir;
  154. s.placement = dis;
  155. s.sprite_index = sprite;
  156. shield_instance_array[total] = s;
  157. c2[n - 1, n2] = s;
  158. total++;
  159. }
  160. } ////////
  161.  
  162.  
  163. if right = 0 then { /////
  164.  
  165. inst_count = 0;
  166. if instance_exists(d1[n - 1 + 1, n2]) then inst_count++;
  167. if instance_exists(d1[n + 1 + 1, n2]) then inst_count++;
  168. if instance_exists(d1[n + 1, n2 + 1]) then inst_count++;
  169. if instance_exists(d1[n + 1, n2 - 1]) then inst_count++;
  170. if inst_count < 3 then {
  171.  
  172. c1[n + 1, n2] = 1;
  173. u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 90);
  174. v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 90);
  175. dis = point_distance(x, y, u1, v1);
  176. dir = point_direction(u1, v1, x, y) - image_angle;
  177. s = instance_create(x, y, Shield_Module_One);
  178. s.owner = id;
  179. s.angle_offset = dir;
  180. s.placement = dis;
  181. s.sprite_index = sprite;
  182. shield_instance_array[total] = s;
  183. c2[n + 1, n2] = s;
  184. total++;
  185. }
  186. } ////////
  187.  
  188.  
  189. }
  190. }
  191.  
  192.  
  193.  
  194. n2++;
  195. }
  196. n++;
  197. n2 = 0;
  198. } //clear tables end
  199. n = 0;
  200. n2 = 0;
  201. var max_hp = shield_max / total;
  202. while n < total {
  203. shield_instance_array[n].max_hp = max_hp;
  204. shield_instance_array[n].hp = max_hp;
  205. n++;
  206. }
  207. shield_count = total;
  208. shield = 0;
  209.  
  210.  
  211.  
  212.  
  213. //////////////////////////
  214.  
  215. } /// END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement