#“Œ•û’e–‹•—[Player]
#ScriptVersion[2]
#Menu[Zengar A]
#Text[Zengar A: Danmaku Dodger Lunacy
Nintendonut888 support: Concentrated Attack Type)
"New, complex strategies? Hah! My only strategy: 
Dodge everything that comes at me!"
Shot: Fortuna Star
Spellcard: Mercy Killing - Phantasmic Spark
Deathbomb: Last Moment - No Border Between Us]
#ReplayName[Zengar A]

script_player_main{
#include_function ".\library01.txt"
let zen = GetCurrentScriptDirectory~"zengar.png";
let part = GetCurrentScriptDirectory~"AlphaParticle.png";
let boom = GetCurrentScriptDirectory~"splode.png";
let count=-1;
let drawc = 0;
let i=0;
let alphavalue = 255;
let se = GetCurrentScriptDirectory~"PlayerShot.wav";
let totaloptions = 0;
let arbitrarynumber = 0;
let al = 5;
let spi = rand_int(0, 359);
let spinn = 103;

let trackx;
let tracky;
let tracklives;
let trackbombs;
let trackpower;
let threwitems = false;
let givebackpower;

task Hitbox{
	let alph = 15;
	let spin = rand_int(0, 359);
	let spinner = 103;
	let hitbox = Obj_Create(OBJ_SHOT);
	Obj_SetSpeed(hitbox,0);
	Obj_SetCollisionToPlayer(hitbox, false);
	ObjShot_SetBombResist(hitbox, true);
	ObjShot_SetGraphic(hitbox, 4);
	while(!Obj_BeDeleted(hitbox)){
	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
		if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD){
			if(GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD){   
				Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY+1);
			}else if(GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD){  
				Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY-2);
			}else{
				Obj_SetPosition(hitbox, GetPlayerX+1, GetPlayerY);}
		}else if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD){
            if(GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD){
				Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY+1);
            }else if(GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD){
				Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY-2);
            }else{        
				Obj_SetPosition(hitbox, GetPlayerX-2, GetPlayerY);
			}
		}else if(GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD){
			Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY+1);
		}else if(GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD){
			Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY-2);
		}else{
			Obj_SetPosition(hitbox, GetPlayerX, GetPlayerY);
		}
	}else{
		Obj_Delete(hitbox);
		}
		if(alph<255){
		alph+=30;}
		spin+=spinner;
		if(spinner>3){
			spinner-=5;
			}
		if(spin>=360){
			spin-=360;
			}
		Obj_SetAngle(hitbox, spin);
		Obj_SetAlpha(hitbox, alph);
		yield;
	}
	Obj_Delete(hitbox);
}

task Option{
  let osc = 0;
  let count2 = 0;
  let an = rand_int(0, 360);
  let rad = 8;
  let x = 0;
  let y = 0;
  let xx = GetPlayerX;
  let yy = GetPlayerY;
  let objoption=Obj_Create(OBJ_EFFECT);
  ObjEffect_SetTexture(objoption,zen);
  ObjEffect_SetRenderState(objoption,ALPHA);
  ObjEffect_SetPrimitiveType(objoption,PRIMITIVE_TRIANGLEFAN);
  ObjEffect_CreateVertex(objoption,4);
  ObjEffect_SetVertexUV(objoption,0,0,242);
  ObjEffect_SetVertexUV(objoption,1,14,242); 
  ObjEffect_SetVertexUV(objoption,2,14,256);
  ObjEffect_SetVertexUV(objoption,3,0,256);
    while(!Obj_BeDeleted(objoption)){
	if(totaloptions==1){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX;
			y = GetPlayerY + 30;
			if(count%16==1){
				flower(xx, yy, 265);
				flower(xx, yy, 275);
				}
			}else{
			x = GetPlayerX;
			y = GetPlayerY + 30;
			if(count%16==1){
				flower(xx, yy, 240);
				flower(xx, yy, 300);
				}
			}
		}
	if(totaloptions==2){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX - 10;
			y = GetPlayerY + 20;
			if(count%16==1){
				flower(xx, yy, 255);
				flower(xx, yy, 265);
				}
			}else{
			x = GetPlayerX - 26;
			y = GetPlayerY + 2;
			if(count%16==1){
				flower(xx, yy, 238);
				flower(xx, yy, 258);
				}
			}
		}
	if(totaloptions==3){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX - 13;
			y = GetPlayerY + 18;
			if(count%16==1){
				flower(xx, yy, 250);
				flower(xx, yy, 260);
				}
			}else{
			x = GetPlayerX - 25;
			y = GetPlayerY - 12;
			if(count%16==1){
				flower(xx, yy, 250);
				flower(xx, yy, 230);
				}
			}
		}
	if(totaloptions==4){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX - 22;
			y = GetPlayerY - 8;
			if(count%16==1){
				flower(xx, yy, 260);
				flower(xx, yy, 230);
				}
			}else{
			x = GetPlayerX - 27;
			y = GetPlayerY + 15;
			if(count%16==1){
				flower(xx, yy, 240);
				flower(xx, yy, 225);
				}
			}
		}
		count2++;
		if(count2%40<20){
			osc+=0.075;
		}
		if(count2%40>=20){
			osc-=0.075;
		}
	
	if((((x - xx)^2 + (y - yy)^2)^0.5)<=1){
		xx = x;
		yy = y;
	}else{
		let an = atan2(y - yy, x - xx);
		xx+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*cos(an);
		yy+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*sin(an);
		}
	an+=6;
	ObjEffect_SetVertexXY(objoption, 0, xx + (rad + osc)*cos(an) - osc, yy + (rad + osc)*sin(an));
	ObjEffect_SetVertexXY(objoption, 1, xx + (rad + osc)*cos(an + 90) - osc, yy + (rad + osc)*sin(an + 90));
	ObjEffect_SetVertexXY(objoption, 2, xx + (rad + osc)*cos(an + 180) - osc, yy + (rad + osc)*sin(an + 180));
	ObjEffect_SetVertexXY(objoption, 3, xx + (rad + osc)*cos(an + 270) - osc, yy + (rad + osc)*sin(an + 270));
	yield;
	if(totaloptions==0){
		Obj_Delete(objoption);
		}
	}
}
task Option2{
  let osc = 0;
  let count2 = 0;
  let an = rand_int(0, 360);
  let rad = 8;
  let x = 0;
  let y = 0;
  let xx = GetPlayerX;
  let yy = GetPlayerY;
  let objoption=Obj_Create(OBJ_EFFECT);
  ObjEffect_SetTexture(objoption,zen);
  ObjEffect_SetRenderState(objoption,ALPHA);
  ObjEffect_SetPrimitiveType(objoption,PRIMITIVE_TRIANGLEFAN);
  ObjEffect_CreateVertex(objoption,4);
  ObjEffect_SetVertexUV(objoption,0,0,242);
  ObjEffect_SetVertexUV(objoption,1,14,242); 
  ObjEffect_SetVertexUV(objoption,2,14,256);
  ObjEffect_SetVertexUV(objoption,3,0,256);
    while(!Obj_BeDeleted(objoption)){
	if(totaloptions==2){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX + 10;
			y = GetPlayerY + 20;
			if(count%16==1){
				flower(xx, yy, 285);
				flower(xx, yy, 275);
				}
			}else{
			x = GetPlayerX + 26;
			y = GetPlayerY + 2;
			if(count%16==1){
				flower(xx, yy, 302);
				flower(xx, yy, 282);
				}
			}
		}
	if(totaloptions==3){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX + 13;
			y = GetPlayerY + 18;
			if(count%16==1){
				flower(xx, yy, 280);
				flower(xx, yy, 290);
				}
			}else{
			x = GetPlayerX + 25;
			y = GetPlayerY - 12;
			if(count%16==1){
				flower(xx, yy, 390);
				flower(xx, yy, 310);
				}
			}
		}
	if(totaloptions==4){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX + 22;
			y = GetPlayerY - 8;
			if(count%16==1){
				flower(xx, yy, 310);
				flower(xx, yy, 280);
				}
			}else{
			x = GetPlayerX + 27;
			y = GetPlayerY + 15;
			if(count%16==1){
				flower(xx, yy, 300);
				flower(xx, yy, 315);
				}
			}
		}
		count2++;
		if(count2%40<20){
			osc+=0.075;
		}
		if(count2%40>=20){
			osc-=0.075;
		}
	if((((x - xx)^2 + (y - yy)^2)^0.5)<=1){
		xx = x;
		yy = y;
	}else{
		let an = atan2(y - yy, x - xx);
		xx+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*cos(an);
		yy+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*sin(an);
		}
	an+=6;
	ObjEffect_SetVertexXY(objoption, 0, xx + (rad + osc)*cos(an) - osc, yy + (rad + osc)*sin(an));
	ObjEffect_SetVertexXY(objoption, 1, xx + (rad + osc)*cos(an + 90) - osc, yy + (rad + osc)*sin(an + 90));
	ObjEffect_SetVertexXY(objoption, 2, xx + (rad + osc)*cos(an + 180) - osc, yy + (rad + osc)*sin(an + 180));
	ObjEffect_SetVertexXY(objoption, 3, xx + (rad + osc)*cos(an + 270) - osc, yy + (rad + osc)*sin(an + 270));
	yield;
	if(totaloptions<=1){
		Obj_Delete(objoption);
		}
	}
}
task Option3{
  let osc = 0;
  let count2 = 0;
  let an = rand_int(0, 360);
  let rad = 8;
  let x = 0;
  let y = 0;
  let xx = GetPlayerX;
  let yy = GetPlayerY;
  let objoption=Obj_Create(OBJ_EFFECT);
  ObjEffect_SetTexture(objoption,zen);
  ObjEffect_SetRenderState(objoption,ALPHA);
  ObjEffect_SetPrimitiveType(objoption,PRIMITIVE_TRIANGLEFAN);
  ObjEffect_CreateVertex(objoption,4);
  ObjEffect_SetVertexUV(objoption,0,0,242);
  ObjEffect_SetVertexUV(objoption,1,14,242); 
  ObjEffect_SetVertexUV(objoption,2,14,256);
  ObjEffect_SetVertexUV(objoption,3,0,256);
    while(!Obj_BeDeleted(objoption)){
	if(totaloptions==3){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX;
			y = GetPlayerY + 22;
			if(count%16==1){
				flower(xx, yy, 270);
				}
			}else{
			x = GetPlayerX;
			y = GetPlayerY + 22;
			if(count%16==1){
				flower(xx, yy, 270);
				}
			}
		}
	if(totaloptions==4){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX - 10;
			y = GetPlayerY - 17;
			if(count%16==1){
				flower(xx, yy, 268);
				}
			}else{
			x = GetPlayerX - 18;
			y = GetPlayerY - 18;
			if(count%16==1){
				flower(xx, yy, 260);
				}
			}
		}
		count2++;
		if(count2%40<20){
			osc+=0.075;
		}
		if(count2%40>=20){
			osc-=0.075;
		}
	if((((x - xx)^2 + (y - yy)^2)^0.5)<=1){
		xx = x;
		yy = y;
	}else{
		let an = atan2(y - yy, x - xx);
		xx+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*cos(an);
		yy+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*sin(an);
		}
	an+=6;
	ObjEffect_SetVertexXY(objoption, 0, xx + (rad + osc)*cos(an) - osc, yy + (rad + osc)*sin(an));
	ObjEffect_SetVertexXY(objoption, 1, xx + (rad + osc)*cos(an + 90) - osc, yy + (rad + osc)*sin(an + 90));
	ObjEffect_SetVertexXY(objoption, 2, xx + (rad + osc)*cos(an + 180) - osc, yy + (rad + osc)*sin(an + 180));
	ObjEffect_SetVertexXY(objoption, 3, xx + (rad + osc)*cos(an + 270) - osc, yy + (rad + osc)*sin(an + 270));
	yield;
	if(totaloptions<=2){
		Obj_Delete(objoption);
		}
	}
}
task Option4{
  let osc = 0;
  let count2 = 0;
  let an = rand_int(0, 360);
  let rad = 8;
  let x = 0;
  let y = 0;
  let xx = GetPlayerX;
  let yy = GetPlayerY;
  let objoption=Obj_Create(OBJ_EFFECT);
  ObjEffect_SetTexture(objoption,zen);
  ObjEffect_SetRenderState(objoption,ALPHA);
  ObjEffect_SetPrimitiveType(objoption,PRIMITIVE_TRIANGLEFAN);
  ObjEffect_CreateVertex(objoption,4);
  ObjEffect_SetVertexUV(objoption,0,0,242);
  ObjEffect_SetVertexUV(objoption,1,14,242); 
  ObjEffect_SetVertexUV(objoption,2,14,256);
  ObjEffect_SetVertexUV(objoption,3,0,256);
    while(!Obj_BeDeleted(objoption)){
	if(totaloptions==4){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
			x = GetPlayerX + 10;
			y = GetPlayerY - 17;
			if(count%16==1){
				flower(xx, yy, 272);
				}
		}else{
			x = GetPlayerX + 18;
			y = GetPlayerY - 18;
			if(count%16==1){
				flower(xx, yy, 280);
				}
			}
		}
		count2++;
		if(count2%40<20){
			osc+=0.075;
		}
		if(count2%40>=20){
			osc-=0.075;
		}
	an+=6;
	if((((x - xx)^2 + (y - yy)^2)^0.5)<=1){
		xx = x;
		yy = y;
	}else{
		let an = atan2(y - yy, x - xx);
		xx+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*cos(an);
		yy+=((((x - xx)^2 + (y - yy)^2)^0.5)/2)*sin(an);
		}
	ObjEffect_SetVertexXY(objoption, 0, xx + (rad + osc)*cos(an) - osc, yy + (rad + osc)*sin(an));
	ObjEffect_SetVertexXY(objoption, 1, xx + (rad + osc)*cos(an + 90) - osc, yy + (rad + osc)*sin(an + 90));
	ObjEffect_SetVertexXY(objoption, 2, xx + (rad + osc)*cos(an + 180) - osc, yy + (rad + osc)*sin(an + 180));
	ObjEffect_SetVertexXY(objoption, 3, xx + (rad + osc)*cos(an + 270) - osc, yy + (rad + osc)*sin(an + 270));
	yield;
	if(totaloptions<=3){
		Obj_Delete(objoption);
		}
	}
}

function shot(a, x){
	let obj = Obj_Create(OBJ_SHOT);
	let y = GetPlayerY - 8;
	Obj_SetPosition(obj, GetPlayerX + x, y);
	ObjShot_SetGraphic(obj, 1);
	Obj_SetAngle(obj, a);
	ObjShot_SetDamage(obj, 2);
	ObjShot_SetPenetration(obj, 1);
	Obj_SetSpeed(obj, 23);
	}
	
task flower(x, y, angle){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj, x, y);
	Obj_SetSpeed(obj, 3);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, 5);
	ObjShot_SetDamage(obj, 2);
	ObjShot_SetPenetration(obj, 1);
	while(!Obj_BeDeleted(obj)){
		Obj_SetSpeed(obj, Obj_GetSpeed(obj) + 0.2);
		x = Obj_GetX(obj);
		y = Obj_GetY(obj);
		yield;
	}
	if(x>0 && x<448 && y>0){
	loop(8){
		Glitter(x, y, rand(0, 360));
		}
	splode(x, y);
		let enemy = 0;
		let ex = 0;
		let ey = 0;
		let q = 0;
		ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
			if(q<1){
				enemy = EnumEnemyGetID(i);
				ex = GetEnemyInfo(enemy, ENEMY_X);
				ey = GetEnemyInfo(enemy, ENEMY_Y);
				if(((x - ex)^2 + (y - ey)^2)^0.5<100){
					q++;
					slash(x, y, ex, ey, 2, ((x - ex)^2 + (y - ey)^2)^0.5, atan2(ey - y, ex - x), enemy);
					PlaySE(GetCurrentScriptDirectory~"starburst.wav");
					i = EnumEnemyEnd;
				}
			}
		}
	}
}

task slash(x, y, ex, ey, state, dis, ang, identifier){
	let laser = Obj_Create(OBJ_LASER);
	let dd = 0;
	let enemy = 0;
	Obj_SetPosition(laser, x, y);
	Obj_SetSpeed(laser, 0);
	Obj_SetAutoDelete(laser, false);
	Obj_SetAngle(laser, ang);
	ObjShot_SetGraphic(laser, 6);
	ObjShot_SetDamage(laser, 0.25);
	ObjLaser_SetSource(laser, false);
	ObjLaser_SetWidth(laser, 10);
	ObjLaser_SetLength(laser, 1);
	dis/=5;
	dd=dis;
	loop(5){
		ObjLaser_SetLength(laser, dd);
		dd+=dis;
		yield;
	}
	loop(5){
		x = x + dis*cos(ang);
		y = y + dis*sin(ang);
		Obj_SetPosition(laser, x, y);
		ObjLaser_SetLength(laser, dd);
		dd-=dis;
		yield;
	}
	x = ObjLaser_GetEndX(laser);
	y = ObjLaser_GetEndY(laser);
	loop(8){
		Glitter(x, y, rand(0, 360));
		}
	splode(x, y);
	if(state>0){
		let q = 0;
		ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
			if(q<1){
				enemy = EnumEnemyGetID(i);
				ex = GetEnemyInfo(enemy, ENEMY_X);
				ey = GetEnemyInfo(enemy, ENEMY_Y);
				if(enemy!=identifier){
					if(((x - ex)^2 + (y - ey)^2)^0.5<100){
						q++;
						slash(x, y, ex, ey, state - 1, ((x - ex)^2 + (y - ey)^2)^0.5, atan2(ey - y, ex - x), enemy);
						PlaySE(GetCurrentScriptDirectory~"starburst.wav");
						i = EnumEnemyEnd;
					}
				}
			}
		}
	}
	Obj_Delete(laser);
}
	
task splode(x, y){
	let obj = Obj_Create(OBJ_EFFECT);
	let shot = Obj_Create(OBJ_SHOT);
	ObjShot_SetGraphic(shot, 66);
	Obj_SetPosition(shot, x, y);
	if(totaloptions==1){
		ObjShot_SetDamage(shot, 3);
	}
	if(totaloptions==2){
		ObjShot_SetDamage(shot, 2);
	}
	if(totaloptions==3){
		ObjShot_SetDamage(shot, 1.5);
	}
	if(totaloptions==4){
		ObjShot_SetDamage(shot, 1.4);
	}
	ObjShot_SetPenetration(shot, 1);
	Obj_SetSpeed(shot, 0);
	Obj_SetAngle(shot, 0);
	ObjEffect_SetTexture(obj, boom);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 127, 0);
	ObjEffect_SetVertexUV(obj, 2, 127, 127);
	ObjEffect_SetVertexUV(obj, 3, 0, 127);
	let aa = rand(0, 360);
	let g = 1;
	loop(11){
		ascent(i in 0..4){
			ObjEffect_SetVertexXY(obj, i, x + (g*3)*cos((225 + 90*i) + aa), y + (g*3)*sin((225 + 90*i) + aa));
			ObjEffect_SetVertexColor(obj, i, 255-(g*20), 255, 255, 255);
		}
		aa+=rand(10, 350);
		g++;
		yield;
		if(!Obj_BeDeleted(shot)){
			Obj_Delete(shot);
		}
	}
	Obj_Delete(obj);
}

task Glitter(x, y, a){
	let obj = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj, part);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 63, 0);
	ObjEffect_SetVertexUV(obj, 2, 63, 63);
	ObjEffect_SetVertexUV(obj, 3, 0, 63);
	let r = rand(6, 20);
	let r2 = rand(4, 15);
	let angle = rand(0, 360);
	let subtr = r/15;
	loop(15){
		x+=r2*cos(a);
		y+=r2*sin(a);
		ObjEffect_SetVertexXY(obj, 0, x + r*cos(angle), y + r*sin(angle));
		ObjEffect_SetVertexXY(obj, 1, x + r*cos(angle + 90), y + r*sin(angle + 90));
		ObjEffect_SetVertexXY(obj, 2, x + r*cos(angle + 180), y + r*sin(angle + 180));
		ObjEffect_SetVertexXY(obj, 3, x + r*cos(angle + 270), y + r*sin(angle + 270));
		ObjEffect_SetVertexColor(obj, 0, 255, rand_int(230, 255), rand_int(200, 220), rand_int(0, 30));
		ObjEffect_SetVertexColor(obj, 1, 255, rand_int(230, 255), rand_int(200, 220), rand_int(0, 30));
		ObjEffect_SetVertexColor(obj, 2, 255, rand_int(230, 255), rand_int(200, 220), rand_int(0, 30));
		ObjEffect_SetVertexColor(obj, 3, 255, rand_int(230, 255), rand_int(200, 220), rand_int(0, 30));
		r-=subtr;
		yield;
		}
	Obj_Delete(obj);
}
	
  @Initialize{
	SetCommonData("PowerLevel", 1);
	LoadGraphic(zen);
	LoadGraphic(part);
	LoadGraphic(boom);
    LoadPlayerShotData(GetCurrentScriptDirectory~"zenshots.txt");
    SetPlayerLifeImage(zen, 0, 0, 26, 47);
    SetSpeed(5, 2);
	LoadSE(se);
	Hitbox;
  }
  @MainLoop{
	SetCommonData("PowerLevel", round(GetCommonData("PowerLevel")*100)/100);

	if(GetCommonData("PowerLevel")<1){
		SetCommonData("PowerLevel", GetCommonData("PowerLevel") + 0.5);
		}
		
		
		
		
	  if(GetCommonData("PowerLevel")>=0 && GetCommonData("PowerLevel")<1){
		totaloptions=0;
		}
	  if(GetCommonData("PowerLevel")>=1 && GetCommonData("PowerLevel")<2 && totaloptions==0){
		Option;
		}
	  if(GetCommonData("PowerLevel")>=1 && GetCommonData("PowerLevel")<2){
		totaloptions=1;
		}
	  if(GetCommonData("PowerLevel")>=2 && GetCommonData("PowerLevel")<3 && totaloptions==1){
		Option2;PlaySE(".\se_powerup.wav");
		}
	  if(GetCommonData("PowerLevel")>=2 && GetCommonData("PowerLevel")<3){
		totaloptions=2;
		}
	  if(GetCommonData("PowerLevel")>=3 && GetCommonData("PowerLevel")<4 && totaloptions==2){
		Option3;PlaySE(".\se_powerup.wav");
		}
	  if(GetCommonData("PowerLevel")>=3 && GetCommonData("PowerLevel")<4){
		totaloptions=3;
		}
	  if(GetCommonData("PowerLevel")>=4 && totaloptions==3){
		Option4;SetCommonData("PowerLevel",4);PlaySE(".\se_powerup.wav");
		}
	  if(GetCommonData("PowerLevel")==4){
		totaloptions=4;
		}

	if(!OnMissed){
		trackx = 120;
		tracky = GetClipMaxY;
		tracklives = GetPlayerLife;
		trackbombs = GetPlayerBomb;
		trackpower = GetCommonData("PowerLevel");
		threwitems=false;
		givebackpower = trackpower;
		arbitrarynumber=0;
	}
		
		
		
	  if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && count==-1){
		count = 0;
	  }
		if(count%4==0){
		shot(270, -7);
		shot(270, 7);
		if(!GetCommonDataDefault("OnDialogue", false)){
			PlaySE(se);
		}
		}
	  if(count >= 0){
		count++;
	  }
	  if(count >= 16 && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)){
		count=-1;
	  }
	  if(count >= 16){
		count=-1;
	  }
  if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH){
  Hitbox;
  }
	  yield;
	  SetIntersectionCircle(GetPlayerX, GetPlayerY, 1);
  }
  @Missed{
	arbitrarynumber++;
	if(!threwitems && arbitrarynumber>30){
		if(GetCommonData("PowerLevel")>=2){
			SetCommonData("PowerLevel",GetCommonData("PowerLevel") - 1);
		}else{
			SetCommonData("PowerLevel", 1);
		}
		SetCommonData("EnemyDestroyed", GetCommonDataDefault("EnemyDestroyed", []) ~ [GetPlayerX, GetPlayerY, 0, 50, 0, 50]);
		threwitems=true;
	}
  }
  @SpellCard{
	UseSpellCard("PhantasmicSpark", 0);
  }
  @DrawLoop{
	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD){
		if(al<155){
			al+=25;
			}
		spi+=spinn;
		if(spinn>3){
			spinn-=5;
			}
		if(spi>=360){
			spi-=360;
			}		
		SetTexture(zen);
		SetGraphicRect(192, 192, 256, 256);
		SetAlpha(al);
		SetGraphicAngle(0, 0, spi);
		DrawGraphic(GetPlayerX, GetPlayerY);
		SetTexture(zen);
		SetGraphicRect(192, 192, 256, 256);
		SetAlpha(al);
		SetGraphicAngle(0, 0, -spi);
		DrawGraphic(GetPlayerX, GetPlayerY);
	}else{
		al = 5;
		spinn = 103;
		}
  SetTexture(zen);
  SetGraphicAngle(0, 0, 0);
  
  if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_PUSH){
	drawc=0;
	}
	drawc++;
  if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD || GetKeyState(VK_RIGHT)==KEY_HOLD){
	if(drawc==33){
		drawc=17;
	}
  }
  if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD){
  if(drawc%32==1 || drawc%32==2 || drawc%32==3 || drawc%32==4){
    SetGraphicRect(0, 48, 25, 95);}
  if(drawc%32==5 || drawc%32==6 || drawc%32==7 || drawc%32==8){
    SetGraphicRect(26, 48, 51, 95);}
  if(drawc%32==9 || drawc%32==10 || drawc%32==11 || drawc%32==12){
    SetGraphicRect(52, 48, 77, 95);}
  if(drawc%32==13 || drawc%32==14 || drawc%32==15 || drawc%32==16){
    SetGraphicRect(78, 48, 103, 95);}
  if(drawc%32==17 || drawc%32==18 || drawc%32==19 || drawc%32==20){
    SetGraphicRect(104, 48, 129, 95);}
  if(drawc%32==21 || drawc%32==22 || drawc%32==23 || drawc%32==24){
    SetGraphicRect(130, 48, 155, 95);}
  if(drawc%32==25 || drawc%32==26 || drawc%32==27 || drawc%32==28){
    SetGraphicRect(156, 48, 181, 95);}
  if(drawc%32==29 || drawc%32==30 || drawc%32==31 || drawc%32==0){
    SetGraphicRect(182, 48, 207, 95);}
  }else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD){
  if(drawc%32==1 || drawc%32==2 || drawc%32==3 || drawc%32==4){
    SetGraphicRect(0, 96, 25, 143);}
  if(drawc%32==5 || drawc%32==6 || drawc%32==7 || drawc%32==8){
    SetGraphicRect(26, 96, 51, 143);}
  if(drawc%32==9 || drawc%32==10 || drawc%32==11 || drawc%32==12){
    SetGraphicRect(52, 96, 77, 143);}
  if(drawc%32==13 || drawc%32==14 || drawc%32==15 || drawc%32==16){
    SetGraphicRect(78, 96, 103, 143);}
  if(drawc%32==17 || drawc%32==18 || drawc%32==19 || drawc%32==20){
    SetGraphicRect(104, 96, 129, 143);}
  if(drawc%32==21 || drawc%32==22 || drawc%32==23 || drawc%32==24){
    SetGraphicRect(130, 96, 155, 143);}
  if(drawc%32==25 || drawc%32==26 || drawc%32==27 || drawc%32==28){
    SetGraphicRect(156, 96, 181, 143);}
  if(drawc%32==29 || drawc%32==30 || drawc%32==31 || drawc%32==0){
    SetGraphicRect(182, 96, 207, 143);}
  }else{  
  if(drawc%32==1 || drawc%32==2 || drawc%32==3 || drawc%32==4){
    SetGraphicRect(0, 0, 25, 47);}
  if(drawc%32==5 || drawc%32==6 || drawc%32==7 || drawc%32==8){
    SetGraphicRect(26, 0, 51, 47);}
  if(drawc%32==9 || drawc%32==10 || drawc%32==11 || drawc%32==12){
    SetGraphicRect(52, 0, 77, 47);}
  if(drawc%32==13 || drawc%32==14 || drawc%32==15 || drawc%32==16){
    SetGraphicRect(78, 0, 103, 47);}
  if(drawc%32==17 || drawc%32==18 || drawc%32==19 || drawc%32==20){
    SetGraphicRect(104, 0, 129, 47);}
  if(drawc%32==21 || drawc%32==22 || drawc%32==23 || drawc%32==24){
    SetGraphicRect(130, 0, 155, 47);}
  if(drawc%32==25 || drawc%32==26 || drawc%32==27 || drawc%32==28){
    SetGraphicRect(156, 0, 181, 47);}
  if(drawc%32==29 || drawc%32==30 || drawc%32==31 || drawc%32==0){
    SetGraphicRect(182, 0, 207, 47);}
  }
  SetAlpha(255);
  DrawGraphic(GetPlayerX, GetPlayerY);
	if(GetPlayerX<255 && GetPlayerY>390){
		if(alphavalue>90){
			alphavalue-=15;
		}
	}else if(alphavalue<255){
		alphavalue+=15;
	}
	DrawText("Power:" ~ ToString(GetCommonDataDefault("PowerLevel", 0)), 40, 400, 12, alphavalue);
	DrawText("IE:" ~ ToString(GetCommonDataDefault("IEcount", 0)), 40, 415, 12, alphavalue);
	DrawText("Point Value:" ~ ToString(GetCommonDataDefault("PointValue", 0)) ~ "x", 40, 430, 12, alphavalue);
	if(GetCommonDataDefault("IsGrazingFuriously", 0)==1){
		SetFontColor(rand_int(0, 255), rand_int(0, 255), rand_int(0, 255), rand_int(0, 255), rand_int(0, 255), rand_int(0, 255));
	}
	DrawText(ToString(GetCommonDataDefault("PointMultiplier", 1)), 200, 430, 12, alphavalue);
		SetFontColor(0, 0, 0, 0, 0, 255);
  }
  @Finalize{
	DeleteGraphic(zen);
	DeleteGraphic(part);
	DeleteGraphic(boom);
  }
}

script_spell PhantasmicSpark
{
	let star = GetCurrentScriptDirectory ~ "star.png";
	let bg = GetCurrentScriptDirectory ~ "psparkbg.png";

task run{
	SetPlayerInvincibility(220);
	loop(80){
		starr(rand(10, 438), 500);
		yield;yield;
		}
	loop(70){yield;}
	End;
	}

task starr(x, y){
	let obj = Obj_Create(OBJ_SPELL);
	Obj_SetPosition(obj, x, y);
	ObjEffect_SetTexture(obj, star);
	ObjEffect_SetRenderState(obj, ADD);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexUV(obj, 1, 1, 0);
	ObjEffect_SetVertexUV(obj, 2, 1, 1);
	ObjEffect_SetVertexUV(obj, 3, 0, 1);
	let obj2 = Obj_Create(OBJ_EFFECT);
	ObjEffect_SetTexture(obj2, star);
	ObjEffect_SetRenderState(obj2, ALPHA);
	ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_CreateVertex(obj2, 4);
	ObjEffect_SetVertexUV(obj2, 0, 0, 0);
	ObjEffect_SetVertexUV(obj2, 1, 35, 0);
	ObjEffect_SetVertexUV(obj2, 2, 35, 35);
	ObjEffect_SetVertexUV(obj2, 3, 0, 35);
	let angle = 0;
	let r = rand(30, 100);
	let v = (-r + 106)/2;
	let r1 = rand(-5, 5);
	while(y>-60){
		ObjSpell_SetIntersecrionCircle(obj, x, y, r, (-r + 106)/10, true);
		ObjEffect_SetVertexXY(obj2, 0, x + r*cos(angle), y + r*sin(angle));
		ObjEffect_SetVertexXY(obj2, 1, x + r*cos(angle + 90), y + r*sin(angle + 90));
		ObjEffect_SetVertexXY(obj2, 2, x + r*cos(angle + 180), y + r*sin(angle + 180));
		ObjEffect_SetVertexXY(obj2, 3, x + r*cos(angle  - 90), y + r*sin(angle - 90));
		Obj_SetPosition(obj, x, y);
		angle += r1;
		y-=v;
		v+=0.1;
		yield;
	}
	Obj_Delete(obj);
	Obj_Delete(obj2);
}

task back{
	let objj = Obj_Create(OBJ_EFFECT);
	let scroll = rand_int(0, 255);
	let counter = 0;
	let alph = 5;
	ObjEffect_SetTexture(objj, bg);
	ObjEffect_SetRenderState(objj, ALPHA);
	Obj_SetAlpha(objj, 210);
	ObjEffect_SetLayer(objj, 1);
	ObjEffect_CreateVertex(objj, 4);
	ObjEffect_SetPrimitiveType(objj, PRIMITIVE_TRIANGLEFAN);
	ObjEffect_SetVertexUV(objj, 0, 0, 0);
	ObjEffect_SetVertexUV(objj, 1, 255, 0);
	ObjEffect_SetVertexUV(objj, 2, 255, 255);
	ObjEffect_SetVertexUV(objj, 3, 0, 255);
	while(! Obj_BeDeleted(objj)){
		ObjEffect_SetVertexUV(objj, 0, 0, 0 + scroll);
		ObjEffect_SetVertexUV(objj, 1, 255, 0 + scroll);
		ObjEffect_SetVertexUV(objj, 2, 255, 255 + scroll);
		ObjEffect_SetVertexUV(objj, 3, 0, 255 + scroll);
		ObjEffect_SetVertexXY(objj, 0, 0, 0);
		ObjEffect_SetVertexXY(objj, 1, 448, 0);
		ObjEffect_SetVertexXY(objj, 2, 448, 480);
		ObjEffect_SetVertexXY(objj, 3, 0, 480);
		scroll+=-0.5;
		while(scroll>=255){
			scroll-=255;
			}
		if(counter<25){
			alph+=10;
			}
		if(counter>200){
		alph-=10;
			}
			ObjEffect_SetVertexColor(objj, 0, alph, 255, 255, 255);
			ObjEffect_SetVertexColor(objj, 1, alph, 255, 255, 255);
			ObjEffect_SetVertexColor(objj, 2, alph, 255, 255, 255);
			ObjEffect_SetVertexColor(objj, 3, alph, 255, 255, 255);
		if(counter==225){
			Obj_Delete(objj);
			}
		yield;
		counter++;
		}
	}
		
	@Initialize{
	PlaySE("seSuperNaturalBorder2.wav");
	PlaySE(GetCurrentScriptDirectory~"se_nep00.wav");
		LoadGraphic(star);
		LoadGraphic(bg);
		back;
		run;
		}
	@MainLoop{
		yield;
	CollectItems;
		}
	@Finalize{
		DeleteGraphic(star);
		DeleteGraphic(bg);
		}
}