//Blaze's Bullet Color Plugin, taken straight from Kawaii Mod. Colors all projectiles with their team color.
//Requires new sprites for all projectiles, and their masks. Without the new masks, projectiles go through walls.
//If you are going to use this, do not replace the projectile sprites using something else.
//Instead, replace the ColorBlanks and Red/BlueBlades in the Images folder.
if !variable_global_exists("bulletColorChanged") global.bulletColorChanged = 0;
else global.bulletColorChanged = 1;
out("Blaze's Bullet Color Plugin");
if global.bulletColorChanged != 1 {
sprite[1] = RocketS; sprite[2] = ShotS; sprite[3] = BubbleS;
sprite[4] = NeedleS; sprite[5] = FlameS; sprite[6] = BladeProjectileS; sprite[7] = BladeProjectileS;
image[1] = "ColorRocket"; image[2] = "ColorShot"; image[3] = "ColorBubble";
image[4] = "ColorNeedle"; image[5] = "ColorFlame"; image[6] = "RedBlade"; image[7] = "BlueBlade";
mask[1] = "RocketMask"; mask[2] = "ShotMask"; mask[3] = "BubbleMask"; mask[4] = "NeedleMask";
mask[5] = "FlameMask"; mask[6] = "BladeMask2";

if file_exists("Plugins/Sprites/ColorShot.png") && file_exists("Plugins/Sprites/ColorRocket.png")
&& file_exists("Plugins/Sprites/ColorBubble.png") && file_exists("Plugins/Sprites/ColorFlame.png") 
&& file_exists("Plugins/Sprites/ColorNeedle.png") && file_exists("Plugins/Sprites/RedBlade.png")
&& file_exists("Plugins/Sprites/BlueBlade.png") && file_exists("Plugins/Sprites/ShotMask.png")
&& file_exists("Plugins/Sprites/RocketMask.png") && file_exists("Plugins/Sprites/BubbleMask.png") 
&& file_exists("Plugins/Sprites/BladeMask2.png") && file_exists("Plugins/Sprites/FlameMask.png")
&& file_exists("Plugins/Sprites/NeedleMask.png") {
xoff = sprite_get_xoffset(sprite[1]);
yoff = sprite_get_yoffset(sprite[1]);
global.RocketMask = sprite_add("Plugins/Sprites/" + mask[1] + ".png",1,false,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[2]);
yoff = sprite_get_yoffset(sprite[2]);
global.ShotMask = sprite_add("Plugins/Sprites/" + mask[2] + ".png",1,true,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[3]);
yoff = sprite_get_yoffset(sprite[3]);
global.BubbleMask = sprite_add("Plugins/Sprites/" + mask[3] + ".png",1,false,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[4]);
yoff = sprite_get_yoffset(sprite[4]);
global.NeedleMask = sprite_add("Plugins/Sprites/" + mask[4] + ".png",1,true,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[5]);
yoff = sprite_get_yoffset(sprite[5]);
global.FlameMask = sprite_add("Plugins/Sprites/" + mask[5] + ".png",1,true,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[6]);
yoff = sprite_get_yoffset(sprite[6]);
global.BladeMask2 = sprite_add("Plugins/Sprites/" + mask[6] + ".png",1,true,false,xoff,yoff);
xoff = sprite_get_xoffset(sprite[1]);
yoff = sprite_get_yoffset(sprite[1]);
sprite_replace(sprite[1],"Plugins/Sprites/" + string(image[1]) + ".png",2,true,false,xoff,yoff);
for (x = 2; x < 5; x += 1) {
xoff = sprite_get_xoffset(sprite[x]);
yoff = sprite_get_yoffset(sprite[x]);
sprite_replace(sprite[x],"Plugins/Sprites/" + string(image[x]) + ".png",3,true,false,xoff,yoff);
}
xoff = sprite_get_xoffset(sprite[5]);
yoff = sprite_get_yoffset(sprite[5]);
global.BlueFlameS = sprite_add("Plugins/Sprites/" + string(image[5]) + ".png",4,true,false,xoff,yoff);

xoff = sprite_get_xoffset(sprite[6]);
yoff = sprite_get_yoffset(sprite[6]);
global.RedBladeS = sprite_add("Plugins/Sprites/" + string(image[6]) + ".png",4,true,false,xoff,yoff);
global.BlueBladeS = sprite_add("Plugins/Sprites/" + string(image[7]) + ".png",4,true,false,xoff,yoff);

}else{
out("One of the files cannot be found!");
exit;
}

object_set_mask(Shot,global.ShotMask)
object_set_mask(Bubble,global.BubbleMask)
object_set_mask(Needle,global.NeedleMask)
object_set_mask(BladeB,global.BladeMask2)
object_set_mask(Rocket,global.RocketMask)
object_set_mask(Flame,global.FlameMask)

object_event_add(Shot,ev_draw,0,'draw_sprite_ext(sprite_index, team+1, x, y, 1, 1, image_angle, c_white, image_alpha);');
object_event_add(Bubble,ev_draw,0,'draw_sprite_ext(sprite_index, team+1, x, y, 1, 1, image_angle, c_white, image_alpha);');
object_event_add(Needle,ev_draw,0,'draw_sprite_ext(sprite_index, team+1, x, y, 1, 1, image_angle, c_white, image_alpha);');
object_event_add(BladeB,ev_draw,0,'if team == TEAM_RED sprite_index = global.RedBladeS;
else if team == TEAM_BLUE sprite_index = global.BlueBladeS;
draw_sprite_ext(sprite_index, image_index, x, y, 1, 1, image_angle, c_white, image_alpha);');
object_event_clear(Flame,ev_draw,0);
object_event_add(Flame,ev_draw,0,'if (sticksTo != -1) {
if (other.team == TEAM_BLUE) draw_sprite_ext(global.BlueFlameS, image_index,x,y,image_xscale,image_yscale,0,c_white,extinguish);
else draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, 0, c_white, extinguish);
}

else {
if (other.team == TEAM_BLUE) draw_sprite_ext(global.BlueFlameS, image_index,x,y,image_xscale,image_yscale,0,c_white,1);
else draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, 0, c_white, 1);
}');

}