Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Generate segmented shield data
- //start
- var n, n2, c1, c2, d1, d2, width, height, instance, inst, xa, ya, sprite;
- var left, right, up, down, u1, v1, total, s, dis, dir, temp_dir, inst_count;
- fly_dir = 0;
- total = 0;
- inst = noone;
- height = argument0;
- width = argument1;
- instance = argument3;
- switch (size_class) {
- case 0:
- size_class_pixel = 16;
- sprite = Shield_16_SPR;
- break;
- case 1:
- size_class_pixel = 24;
- sprite = Shield_24_SPR;
- break;
- case 2:
- size_class_pixel = 32;
- sprite = Shield_32_SPR;
- break;
- case 3:
- size_class_pixel = 48;
- sprite = Shield_48_SPR;
- break;
- case 4:
- size_class_pixel = 64;
- sprite = Shield_64_SPR;
- break;
- }
- if argument2 > 0 {
- d1[width + 6, height + 6] = -4;
- d2[width + 6, height + 6] = 0;
- c1[width + 6, height + 6] = 0;
- c2[width + 6, height + 6] = 0;
- n = 0;
- n2 = 0;
- while n < width + 6 { //clear tables
- while n2 < height + 6 {
- d1[n, n2] = -4;
- d2[n, n2] = 0;
- c1[n, n2] = 0;
- c2[n, n2] = 0;
- n2++;
- }
- n++;
- n2 = 0;
- } //clear tables end
- n = 0;
- n2 = 0;
- //////////////////////////
- while n < width { //clear tables
- while n2 < height {
- d1[n + 1, n2 + 1] = instance[#n, n2];
- if instance_exists(instance[#n, n2]) then c1[n + 1, n2 + 1] = 1;
- n2++;
- }
- n++;
- n2 = 0;
- } //clear tables end
- n = 0;
- n2 = 0;
- s = noone;
- while n < width + 2 { //clear tables
- while n2 < height + 2 {
- inst = d1[n, n2];
- if inst = 0 then {
- inst = noone;
- d1[n, n2] = noone;
- }
- if inst != noone {
- if instance_exists(inst) {
- up = c1[n, n2 - 1];
- down = c1[n, n2 + 1];
- left = c1[n - 1, n2];
- right = c1[n + 1, n2];
- if up = 0 then { /////
- inst_count = 0;
- if instance_exists(d1[n - 1, n2 - 1]) then inst_count++;
- if instance_exists(d1[n + 1, n2 - 1]) then inst_count++;
- if instance_exists(d1[n, n2 + 1 - 1]) then inst_count++;
- if instance_exists(d1[n, n2 - 1 - 1]) then inst_count++;
- if inst_count < 3 then {
- c1[n, n2 - 1] = 1;
- u1 = inst.x - lengthdir_x(size_class_pixel, image_angle + 90 + 90);
- v1 = inst.y - lengthdir_y(size_class_pixel, image_angle + 90 + 90);
- dis = point_distance(x, y, u1, v1);
- dir = point_direction(u1, v1, x, y) - image_angle;
- s = instance_create(x, y, Shield_Module_One);
- s.owner = id;
- s.angle_offset = dir;
- s.placement = dis;
- s.sprite_index = sprite;
- shield_instance_array[total] = s;
- c2[n, n2 - 1] = s;
- total++;
- }
- } ////////
- if down = 0 then { /////
- inst_count = 0;
- if instance_exists(d1[n - 1, n2 + 1]) then inst_count++;
- if instance_exists(d1[n + 1, n2 + 1]) then inst_count++;
- if instance_exists(d1[n, n2 + 1 + 1]) then inst_count++;
- if instance_exists(d1[n, n2 - 1 + 1]) then inst_count++;
- if inst_count < 3 then {
- c1[n, n2 + 1] = 1;
- u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 270 + 90);
- v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 270 + 90);
- dis = point_distance(x, y, u1, v1);
- dir = point_direction(u1, v1, x, y) - image_angle;
- s = instance_create(x, y, Shield_Module_One);
- s.owner = id;
- s.angle_offset = dir;
- s.placement = dis;
- s.sprite_index = sprite;
- shield_instance_array[total] = s;
- c2[n, n2 + 1] = s;
- total++;
- }
- } ////////
- if left = 0 then { /////
- inst_count = 0;
- if instance_exists(d1[n - 1 - 1, n2]) then inst_count++;
- if instance_exists(d1[n + 1 - 1, n2]) then inst_count++;
- if instance_exists(d1[n - 1, n2 + 1]) then inst_count++;
- if instance_exists(d1[n - 1, n2 - 1]) then inst_count++;
- if inst_count < 3 then {
- c1[n - 1, n2] = 1;
- u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 180 + 90);
- v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 180 + 90);
- dis = point_distance(x, y, u1, v1);
- dir = point_direction(u1, v1, x, y) - image_angle;
- s = instance_create(x, y, Shield_Module_One);
- s.owner = id;
- s.angle_offset = dir;
- s.placement = dis;
- s.sprite_index = sprite;
- shield_instance_array[total] = s;
- c2[n - 1, n2] = s;
- total++;
- }
- } ////////
- if right = 0 then { /////
- inst_count = 0;
- if instance_exists(d1[n - 1 + 1, n2]) then inst_count++;
- if instance_exists(d1[n + 1 + 1, n2]) then inst_count++;
- if instance_exists(d1[n + 1, n2 + 1]) then inst_count++;
- if instance_exists(d1[n + 1, n2 - 1]) then inst_count++;
- if inst_count < 3 then {
- c1[n + 1, n2] = 1;
- u1 = d1[n, n2].x - lengthdir_x(size_class_pixel, image_angle + 90);
- v1 = d1[n, n2].y - lengthdir_y(size_class_pixel, image_angle + 90);
- dis = point_distance(x, y, u1, v1);
- dir = point_direction(u1, v1, x, y) - image_angle;
- s = instance_create(x, y, Shield_Module_One);
- s.owner = id;
- s.angle_offset = dir;
- s.placement = dis;
- s.sprite_index = sprite;
- shield_instance_array[total] = s;
- c2[n + 1, n2] = s;
- total++;
- }
- } ////////
- }
- }
- n2++;
- }
- n++;
- n2 = 0;
- } //clear tables end
- n = 0;
- n2 = 0;
- var max_hp = shield_max / total;
- while n < total {
- shield_instance_array[n].max_hp = max_hp;
- shield_instance_array[n].hp = max_hp;
- n++;
- }
- shield_count = total;
- shield = 0;
- //////////////////////////
- } /// END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement