#TouhouDanmakufu[Player]
#ScriptVersion[3]
#ID["Sanae"]
#Title["Sanae Kochiya"]
#Text["Deified Human of the Wind"]
#Image["./Sanae_Select.png"]
#ReplayName["Sanae"]

//=======================================================//
//			INCLUDE						//
//=======================================================//
#include "./Load.txt"
#include "./Delete.txt"
//=======================================================//
//			GLOBAL VARIABLES				//
//=======================================================//
let objPlayer = GetPlayerObjectID();
let objSlowShot = ID_INVALID;
let SE_SHOT;
let SE_GRAZE;
let SE_SCORE;
let SE_DEATH;
let SE_BOMB;
let SE_SHOTBOMB;
let current = GetCurrentScriptDirectory();
let IsDead = false;
let IsOnBomb = false;
let Power = 0;
let graze_sound_wait = 0;
let checkpower = false;

let sclDx = 1; //PLAYER DEFORMATION X SCALE ON DEATH 
let sclDy = 1; //PLAYER DEFORMATION Y SCALE ON DEATH 
let alphaD = 255; //PLAYER ALPHA ON DEATH 
let objplayerghost = ObjPrim_Create(OBJ_SPRITE_2D);
let objOption = [ObjPrim_Create(OBJ_SPRITE_2D),ObjPrim_Create(OBJ_SPRITE_2D),ObjPrim_Create(OBJ_SPRITE_2D),ObjPrim_Create(OBJ_SPRITE_2D)];
let optX = [-24, 24];
let optXadd = [16, -16];
let optYadd = -40;
let opt_angle = 0;
//=======================================================//
//			FUNCTION					//
//=======================================================//
 function GetCenterX {
     	return GetStgFrameWidth/2;
 }
 function GetCenterY {
     	return GetStgFrameHeight/2;
 }
 function GetClipMinX {
     	return 0;
 }
 function GetClipMinY {
     	return 0;
 }
 function GetClipMaxX {
     	return GetStgFrameWidth;
 }
 function GetClipMaxY {
     	return GetStgFrameHeight;
 }
 function rand_int(min, max) {
     	return round(rand(min, max))
 }
 function GetDistance(x1,y1,x2,y2) {
     return(((x2-x1)^2+(y2-y1)^2)^(1/2));
 }
function LoadSE(path) {
     	let obj = ObjSound_Create;
	ObjSound_SetSoundDivision(obj, SOUND_SE);
    	ObjSound_Load(obj,path);
	return(obj);
}
function PlaySound(ID,vol) {
     	ObjSound_Play(ID);
     	ObjSound_SetVolumeRate(ID,vol);
	return(ID);
}
function Text(id,text,x,y,size,tr,tg,tb,br,bg,bb,r,g,b,BorWid,prior,alpha,scl) {
	let objTxt = id;
	ObjText_SetText(objTxt, text);
	ObjText_SetFontSize(objTxt, size);
	ObjText_SetFontBold(objTxt, false);
	ObjText_SetFontColorTop(objTxt, tr, tg, tb);
	ObjText_SetFontColorBottom(objTxt, br, bg, bb);
	ObjText_SetFontBorderType(objTxt, BORDER_FULL);
	ObjText_SetFontBorderColor(objTxt,r, g, b);
	ObjText_SetFontBorderWidth(objTxt, BorWid);
	Obj_SetRenderPriority(objTxt, prior);
	ObjRender_SetX(objTxt, x);
	ObjRender_SetY(objTxt, y);
	ObjRender_SetAlpha(objTxt, alpha);
	ObjRender_SetScaleX(objTxt, scl);
	ObjRender_SetScaleY(objTxt, scl);
}
//=======================================================//
//			TASK						//
//=======================================================//
task Graze_effect {
	let path = current ~ "Player_Sanae.png";
	let objGraze_eff = ObjPrim_Create(OBJ_SPRITE_2D);
	let eff_x = 0;
	let eff_y = 0;
	let R = 0.01;
	let Rmax = rand(24,38);
	let n = 0;
	let a = rand(0,360);

	ObjPrim_SetTexture(objGraze_eff , path);
	ObjRender_SetX(objGraze_eff, eff_x);
	ObjRender_SetY(objGraze_eff,eff_y);
	ObjRender_SetScaleX(objGraze_eff,0.45);
	ObjRender_SetScaleY(objGraze_eff,0.45);
	ObjRender_SetBlendType(objGraze_eff,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(objGraze_eff, 120);
	ObjSprite2D_SetSourceRect(objGraze_eff, 0, 95, 31, 127);
	ObjRender_SetAngleZ(objGraze_eff, a);

	while(!Obj_IsDeleted(objGraze_eff)) {
		yield;
		n+=3;
		R = Rmax*sin(n);
		if(R < 0) {R = 0;}
		eff_x = GetPlayerX+R*cos(a);
		eff_y = GetPlayerY+R*sin(a);
		ObjSprite2D_SetDestCenter(objGraze_eff);
		ObjRender_SetX(objGraze_eff, eff_x);
		ObjRender_SetY(objGraze_eff, eff_y);
		if(R <= 0) {
     			let obj = ObjSound_Create;
     			PlaySound(SE_SCORE,85);
			Obj_Delete(objGraze_eff);
			AddScore(10+truncate(GetGraze/10));
		}
	}
}
task Graze_effect2 {
	let path = current ~ "graze_eff.png";
	let objGraze_eff = ObjPrim_Create(OBJ_SPRITE_2D);
	let eff_x = 0;
	let eff_y = 0;
	let scl = 0.4+rand(-0.015,0.015);
	let R = 0;
	let a = rand(0,360);

	ObjPrim_SetTexture(objGraze_eff , path);
	ObjRender_SetX(objGraze_eff, eff_x);
	ObjRender_SetY(objGraze_eff,eff_y);
	ObjRender_SetScaleX(objGraze_eff,scl);
	ObjRender_SetScaleY(objGraze_eff,scl);
	ObjRender_SetBlendType(objGraze_eff,BLEND_ADD_RGB);
	ObjSprite2D_SetSourceRect(objGraze_eff, 0, 95, 31, 127);
	ObjRender_SetAngleZ(objGraze_eff, a);

	while(!Obj_IsDeleted(objGraze_eff)) {
		yield;
		ObjSprite2D_SetDestCenter(objGraze_eff);
		scl -= 0.011;
		if(scl <= 0) {
			Obj_Delete(objGraze_eff);
		}
		ObjRender_SetScaleX(objGraze_eff,scl);
		ObjRender_SetScaleY(objGraze_eff,scl);
		R += rand(0.5,0.8);
		eff_x = GetPlayerX+R*cos(a);
		eff_y = GetPlayerY+R*sin(a);
		ObjRender_SetX(objGraze_eff, eff_x);
		ObjRender_SetY(objGraze_eff,eff_y);
	}
}

//=======================================================//
//			EVENT						//
//=======================================================//
@Event {
	alternative(GetEventType())
	case(EV_REQUEST_SPELL) 	{
		let spell = GetPlayerSpell();
		if(spell >= 1) 		{
			SetScriptResult(true);
			SetPlayerSpell(spell-1);
			TSpell();
		} else {
			SetScriptResult(false);
		}
	}
	case(EV_HIT) {
		PlaySound(SE_DEATH,100);
		IsDead = true;
		TExplosion();
		if(GetCommonData("gfx","HIGH") != "LOW") {
			TExplosionB(GetPlayerX, GetPlayerY, 8, 0.01, 255, 25, 25, 255, 25, 25);
			TExplosionB(GetPlayerX, GetPlayerY, 4.5, 0.02, 255, 15, 55, 255, 15, 55);
		}
		TDeathEff;
	}
	case(EV_PLAYER_REBIRTH) {
		sclDx = 1; 
		sclDy = 1; 
		alphaD = 255; 
		SetPlayerSpell(3);
		SetPlayerInvincibilityFrame(190);
		IsDead = false;
	}
	case(EV_GET_ITEM) {
		let itemType = GetEventArgument(0);
		alternative(itemType)
		case(ITEM_SPELL) {
			WriteLog("ITEM_SPELL");
		}
		case(ITEM_SPELL_S) {
			WriteLog("ITEM_SPELL_S");
		}
		case(ITEM_POWER) {
			WriteLog("ITEM_POWER");
		}
		case(ITEM_POWER_S) {
			WriteLog("ITEM_POWER_S");
		}
	}
	case(EV_GRAZE) {
		Graze_effect;
		if(GetCommonData("gfx","HIGH") != "LOW") {Graze_effect2;}
		if(graze_sound_wait <= 0) {
			PlaySound(SE_GRAZE,100);
			graze_sound_wait = 2;
		}
	}
}
//=======================================================//
//			INITIALIZE					//
//=======================================================//
@Initialize {
	Load();
	SE_SHOT = LoadSE(current ~ "seShot.wav");
	SE_GRAZE = LoadSE(current ~ "seGraze.wav");
	SE_SCORE = LoadSE(current ~ "seScore.wav");
	SE_DEATH = LoadSE(current ~ "seDeath.wav");
	SE_BOMB = LoadSE(current ~ "seBomb.wav");
	SE_SHOTBOMB = LoadSE(current ~ "seShotBomb.wav");
	
	SetCommonData("Sanae",1);
	
	let path = current ~ "SanaeShotData.txt";
	LoadPlayerShotData(path);
	SetPlayerPower(400);
	ObjPlayer_AddIntersectionCircleA1(objPlayer, 0, 0, 1.5, 20); 
	SetPlayerSpeed(4.55,2.15);
	SetPlayerDownStateFrame(40);
	TDrawloop;
	TShot;
	TMagicCircle;
}

//=======================================================//
//			MAINLOOP					//
//=======================================================//
@MainLoop {
	if(checkpower == false) {
		checkpower = true;
		if(GetCommonData("Power_Enabled", false) == false) {SetPlayerPower(400);}
		if(GetCommonData("Power_Enabled", false) == true) {SetPlayerPower(100);}
	}
	graze_sound_wait--;
	if(graze_sound_wait < 0) {graze_sound_wait = 0;}
	yield;
	if(GetPlayerPower >= 0) {
		Power = 0;
	}
	if(GetPlayerPower >= 100) {
		Power = 100;
	}
	if(GetPlayerPower >= 200) {
		Power = 200;
	} 
	if(GetPlayerPower >= 300) {
		Power = 300;
	}
	if(GetPlayerPower >= 400) {
		Power = 400;
	}
}

//=======================================================//
//			FINALIZE						//
//=======================================================//
@Finalize {
	Obj_Delete(SE_SHOT);
	Obj_Delete(SE_SCORE);
	Obj_Delete(SE_BOMB);
	Obj_Delete(SE_GRAZE);
	Obj_Delete(SE_DEATH);
	Obj_Delete(SE_SHOTBOMB);
	Delete();
}

//=======================================================//
//			DRAWLOOP					//
//=======================================================//
task TDrawloop {
	let path = current ~ "Player_Sanae.png";
	let hbpath = current ~ "hitbox.png";
	let hbcpath = current ~ "hitboxcircle.png";
	let hbc_angle = 0;
	let hbalpha = 0;
	let anim = 0;
	let timer_anim = 0;
	let objHitbox = ObjPrim_Create(OBJ_SPRITE_2D);
	let objHitboxcircle = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objPlayer, path);
	ObjPrim_SetTexture(objplayerghost, path);
	ObjPrim_SetTexture(objHitbox, hbpath);
	ObjPrim_SetTexture(objHitboxcircle, hbcpath);

	ObjPrim_SetTexture(objOption[0], path);
	ObjPrim_SetTexture(objOption[1], path);
	ObjPrim_SetTexture(objOption[2], path);
	ObjPrim_SetTexture(objOption[3], path);
	loop {
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
//			PLAYER BLOCK		            //
//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::://
       		if(GetPlayerX < GetClipMinX+12) {ObjMove_SetX(objPlayer, GetClipMinX+12);}
      		if(GetPlayerX > GetClipMaxX-12) {ObjMove_SetX (objPlayer, GetClipMaxX-12);}
       		if(GetPlayerY < GetClipMinY+12) {ObjMove_SetY(objPlayer, GetClipMinY+12);}
       		if(GetPlayerY > GetClipMaxY-12) {ObjMove_SetY(objPlayer, GetClipMaxY-12);}
//-----------------------------------------------------------------//
//		HITBOXCIRCLE			//
//-----------------------------------------------------------------//
		hbc_angle += 3;
		ObjSprite2D_SetSourceRect(objHitboxcircle, 0, 0, 63, 63);
		ObjRender_SetAngleZ(objHitboxcircle, hbc_angle);
		ObjSprite2D_SetDestCenter(objHitboxcircle);
		ObjRender_SetAlpha(objHitboxcircle, hbalpha);
		ObjRender_SetX(objHitboxcircle, GetPlayerX);
		ObjRender_SetY(objHitboxcircle, GetPlayerY);
//-----------------------------------------------------------------//
//		OPTIONS				//
//-----------------------------------------------------------------//
		opt_angle += 7.77;
		ascent(i in 0 .. 2) {
			ObjSprite2D_SetSourceRect(objOption[i+2], 128, 96, 160, 128);
			ObjSprite2D_SetDestCenter(objOption[i+2]);
			ObjRender_SetX(objOption[i+2], GetPlayerX+optX[i]+optXadd[i]);
			ObjRender_SetY(objOption[i+2], GetPlayerY+12+optYadd);
			ObjRender_SetScaleY(objOption[i+2], 0.5*(0.85-0.15*sin(opt_angle)));
			ObjRender_SetScaleX(objOption[i+2], 0.5*(0.85-0.15*sin(opt_angle)));
			Obj_SetRenderPriority(objOption[i+2], 0.39);
			ObjRender_SetAlpha(objOption[i+2], alphaD);

			ObjSprite2D_SetSourceRect(objOption[i], 32, 96, 64, 128);
			ObjRender_SetAngleZ(objOption[i], -0.25*opt_angle);
			ObjSprite2D_SetDestCenter(objOption[i]);
			ObjRender_SetX(objOption[i], GetPlayerX+optX[i]+optXadd[i]);
			ObjRender_SetY(objOption[i], GetPlayerY+12+optYadd);
			ObjRender_SetScaleY(objOption[i], 0.5*(1.5-0.2*sin(180+opt_angle)));
			ObjRender_SetScaleX(objOption[i], 0.5*(1.5-0.2*sin(180+opt_angle)));
			ObjRender_SetBlendType(objOption[i], BLEND_ADD_ARGB);
			Obj_SetRenderPriority(objOption[i], 0.38);
			ObjRender_SetAlpha(objOption[i], 0.4*alphaD);

			if(IsPermitPlayerShot == false) {
				ObjRender_SetY(objOption[i], 999);
				ObjRender_SetY(objOption[i+2], 999);
			}
		}
//-----------------------------------------------------------------//
//		PLAYER				//
//-----------------------------------------------------------------//
		timer_anim++;
		anim = truncate(timer_anim/10); 
		if (timer_anim/2 == 10) {timer_anim = -1;}
		if(GetVirtualKeyState(VK_LEFT) == KEY_PUSH || GetVirtualKeyState(VK_LEFT) == KEY_HOLD) {
			ObjSprite2D_SetSourceRect(objPlayer, 1, 49, 32, 95);
			ObjSprite2D_SetSourceRect(objplayerghost, 1, 49, 32, 95);
		} else if(GetVirtualKeyState(VK_RIGHT) == KEY_PUSH || GetVirtualKeyState(VK_RIGHT) == KEY_HOLD) {
			ObjSprite2D_SetSourceRect(objPlayer, 32, 49, 64, 95);
			ObjSprite2D_SetSourceRect(objplayerghost, 32, 49, 64, 95);
		} else {
			ObjSprite2D_SetSourceRect(objPlayer, 1+32*anim, 1, 32+32*anim, 47);
			ObjSprite2D_SetSourceRect(objplayerghost, 1+32*anim, 1, 32+32*anim, 47);
		}
		ObjSprite2D_SetDestCenter(objPlayer);
		Obj_SetRenderPriority(objPlayer, 0.45);
		ObjSprite2D_SetDestCenter(objplayerghost);
		ObjRender_SetX(objplayerghost, GetPlayerX);
		ObjRender_SetY(objplayerghost, GetPlayerY);
		ObjRender_SetAlpha(objplayerghost, 0);
//-----------------------------------------------------------------//
//		HITBOX				//
//-----------------------------------------------------------------//
		ObjSprite2D_SetSourceRect(objHitbox, 0, 0, 31, 31);
		ObjRender_SetScaleX(objHitbox, 0.7);
		ObjRender_SetScaleY(objHitbox, 0.65);
		ObjSprite2D_SetDestCenter(objHitbox);
		Obj_SetRenderPriority(objPlayer, 0.45);
		ObjRender_SetAlpha(objHitbox, hbalpha);
		ObjRender_SetX(objHitbox, GetPlayerX);
		ObjRender_SetY(objHitbox, GetPlayerY);
		if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD) {
			hbalpha += 12;
			if(hbalpha > 255) {hbalpha = 255;}
			optXadd -= [16/15, -16/15];
			if(optXadd[0] <= 0) {optXadd[0] = 0;}
			if(optXadd[1] >= 0) {optXadd[1] = 0;}
			optYadd += 40/15;
			if(optYadd > 0) {optYadd = 0;}
		} else {
			hbalpha -= 12;
			if(hbalpha < 0) {hbalpha = 0;}
			optXadd += [16/15, -16/15];
			if(optXadd[0] >= 16) {optXadd[0] = 16;}
			if(optXadd[1] <= -16) {optXadd[1] = -16;}
			optYadd -= 40/15;
			if(optYadd < -40) {optYadd = -40;}
		}
		if(IsDead == true) {hbalpha = 0;}
		if(GetCommonData("start",true) == false) {hbalpha = 0;}
		yield;
	}

}

//=======================================================//
//			TASKSHOT					//
//=======================================================//
task shot01(x,y,s,a,d,penetration,graphic) {
	let anim_path = current ~ "Player_Sanae.png";
	let objShot = CreatePlayerShotA1(x,y,s,a,d,penetration,graphic);
	let task_end = false;
	let timer_anim = 0;
	let anim = 0;
	let objAnim = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objAnim, anim_path);
	while(task_end == false) {
		yield;
		if(Obj_IsDeleted(objShot) == true) {
			y -= 0.2*s;
			timer_anim++;
			anim = truncate(timer_anim/4); 
			if(GetCommonData("gfx","HIGH") == "LOW") {anim = 4;}
			if(anim >= 4 || y < 16) {
				Obj_Delete(objAnim);
				task_end = true;
			} else {
				ObjRender_SetAngleZ(objAnim, -90+a);
				ObjSprite2D_SetDestCenter(objAnim);
				ObjRender_SetAlpha(objAnim, 84-3*timer_anim);
				ObjRender_SetX(objAnim, x);
				ObjRender_SetY(objAnim, y);
				ObjSprite2D_SetSourceRect(objAnim, 64, 112-16*anim, 79, 127-16*anim);
			}
		} else {
			x = ObjMove_GetX(objShot);
			y = ObjMove_GetY(objShot);
		}
	}	
}
task shot03(x,y,s,a,d,penetration,graphic) {
	let anim_path = current ~ "Player_Sanae.png";
	let objShot = CreatePlayerShotA1(x,y,s,a,d,penetration,graphic);
	let task_end = false;
	let alpha = 194;
	let xadd = 0;
	let yadd = 0;
	let A = 0;
	let r = 255;
	let g = 255;
	let b = 255;
	let c = 0;
	let objAnim = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objAnim, anim_path);
	
	while(task_end == false) {
		yield;
		c += 10*rand(4,7);
		if(Obj_IsDeleted(objShot) == true) {
			alpha -= 15;
			xadd += 1.5*cos(a);
			yadd += 1.5*sin(a);
			if(alpha <= 10) {
				alpha = 0;
				Obj_Delete(objAnim);
				task_end = true;
			}
			ObjRender_SetAlpha(objAnim, alpha);
			ObjSprite2D_SetDestCenter(objAnim);
			ObjRender_SetX(objAnim, x+xadd);
			ObjRender_SetY(objAnim, y+yadd);
			ObjSprite2D_SetSourceRect(objAnim, 112, 64, 128, 80);
			ObjRender_SetColor(objShot, r,g,b);
			r = 170+85*(|cos(0.3*c)|);
			g = 170+85*(|sin(0.2*c)|);
			b = 170+85*(|cos(0.3*c)|);
		} else {
			A += 45;
			r = 150+105*(|cos(0.2*c)|);
			g = 150+105*(|cos(0.25*c)|);
			b = 150+105*(|cos(0.3*c)|);
			ObjRender_SetAngleZ(objShot, A);
			ObjRender_SetColor(objShot, r,g,b);
			x = ObjMove_GetX(objShot);
			y = ObjMove_GetY(objShot);
		}
	}	

}
task TShot {
	let shotCount = -1;
	let bNextShot = false;
	let objShot = ID_INVALID;

	loop {
		if(IsDead == false && IsOnBomb == false) {
			if((GetVirtualKeyState(VK_SHOT)==KEY_PUSH || GetVirtualKeyState(VK_SHOT)==KEY_HOLD || bNextShot==true) && shotCount==-1) {
				shotCount = 0;
				bNextShot = false;
			} 
			if(GetVirtualKeyState(VK_SHOT)==KEY_HOLD && shotCount>0) {
				bNextShot = true;
			} 
			if(GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD) {
				if(shotCount%5 == 0 && IsPermitPlayerShot == true) {
					PlaySound(SE_SHOT,100);
					shot01(GetPlayerX()-8, GetPlayerY()-16, 15, 270, 1.5, 2, 1);
					shot01(GetPlayerX()+8, GetPlayerY()-16, 15, 270, 1.5, 3, 1);
					if(Power == 100) {
						shot03(GetPlayerX()+6, GetPlayerY()+8, 15, 270, 0.7, 3, 3);
						shot03(GetPlayerX()-6, GetPlayerY()+8, 15, 270, 0.7, 3, 3);
					} else if(Power == 200) {
						shot03(GetPlayerX()+12, GetPlayerY()+12, 15, 272, 0.7, 3, 3);
						shot03(GetPlayerX()+4, GetPlayerY()+8, 15, 270, 0.82, 3, 3);
						shot03(GetPlayerX()-4, GetPlayerY()+8, 15, 270, 0.82, 3, 3);
						shot03(GetPlayerX()-12, GetPlayerY()+12, 15, 268, 0.7, 3, 3);
					} else if(Power == 300) {
						shot03(GetPlayerX()+20, GetPlayerY()+16, 15, 274, 0.7, 3, 3);
						shot03(GetPlayerX()+12, GetPlayerY()+12, 15, 272, 0.82, 3, 3);
						shot03(GetPlayerX()+4, GetPlayerY()+8, 15, 270, 0.95, 3, 3);
						shot03(GetPlayerX()-4, GetPlayerY()+8, 15, 270, 0.95, 3, 3);
						shot03(GetPlayerX()-12, GetPlayerY()+12, 15, 268, 0.82, 3, 3);
						shot03(GetPlayerX()-20, GetPlayerY()+16, 15, 266, 0.7, 3, 3);
					} else if(Power == 400) {
						shot03(GetPlayerX()+28, GetPlayerY()+20, 15, 276, 0.7, 3, 3);
						shot03(GetPlayerX()+20, GetPlayerY()+16, 15, 274, 0.82, 3, 3);
						shot03(GetPlayerX()+12, GetPlayerY()+12, 15, 272, 0.95, 3, 3);
						shot03(GetPlayerX()+4, GetPlayerY()+8, 15, 270, 1.1, 3, 3);
						shot03(GetPlayerX()-4, GetPlayerY()+8, 15, 270, 1.1, 3, 3);
						shot03(GetPlayerX()-12, GetPlayerY()+12, 15, 268, 0.95, 3, 3);
						shot03(GetPlayerX()-20, GetPlayerY()+16, 15, 266, 0.82, 3, 3);
						shot03(GetPlayerX()-28, GetPlayerY()+20, 15, 264, 0.7, 3, 3);
					}
				}
			} else {
				Obj_Delete(objSlowShot);
				if(shotCount%5 == 0 && IsPermitPlayerShot == true) {
					PlaySound(SE_SHOT,100);
					shot01(GetPlayerX()-8, GetPlayerY()-16, 15, 270, 1.5, 2, 1);
					shot01(GetPlayerX()+8, GetPlayerY()-16, 15, 270, 1.5, 2, 1);
					if(Power == 100) {
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 265, 0.5, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 270, 0.6, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 275, 0.5, 3, 3);
					} else if(Power == 200) {
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 260, 0.5, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 265, 0.6, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 270, 0.7, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 275, 0.6, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 280, 0.5, 2, 3);
					} else if(Power == 300) {
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 255, 0.5, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 260, 0.6, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 265, 0.7, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 270, 0.8, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 275, 0.7, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 280, 0.6, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 285, 0.5, 2, 3);
					} else if(Power == 400) {
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 245, 0.5, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 250, 0.5, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 255, 0.6, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 260, 0.7, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 265, 0.8, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 270, 0.9, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 275, 0.8, 3, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 280, 0.7, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 285, 0.6, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 290, 0.5, 2, 3);
						shot03(GetPlayerX(), GetPlayerY()-16, 15, 295, 0.5, 2, 3);
					}
				}		
			}

			if(shotCount >= 0) {
				shotCount++;
			}
			if(shotCount == 5) {
				shotCount=-1;
			}
		}
		yield;
	}
}


//=======================================================//
//			MAGIC CIRCLE					//
//=======================================================//
task TMagicCircle {
	let countVertex = 64;
	let listRadius = [];
	loop(countVertex) {
		listRadius = listRadius ~ [0];
	}

	let path = current ~ "Default_Player_MagicCircle.png";
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(obj, countVertex);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj, 0.60);
	ObjPrim_SetTexture(obj, path);
	ascent(iVert in 0..countVertex / 2) {
		let left = iVert * 128;
		let indexVert = iVert * 2;
		ObjPrim_SetVertexUVT(obj, indexVert + 0, left, 0);
		ObjPrim_SetVertexUVT(obj, indexVert + 1, left, 64);		
	}

	let cx = 0;
	let cy = 0;
	let maxRadius = 128;
	let alpha = 0;
	let frame = 0;
	let angleRender = 0;
	let frameInvOld = 0;

	while(true) {
		let frameInv = GetPlayerInvincibilityFrame();

		if(frameInv <= 0) {
			Obj_SetVisible(obj, false);
			frameInvOld = 0;
		}
		else {
			if(frameInvOld == 0) {
				ascent(iVert in 0..countVertex) {
					listRadius[iVert] = 0;
				}
				alpha = 0;
				frame = 0;
			}
			frameInvOld = frameInv;

			let px = GetPlayerX();
			let py = GetPlayerY();

			alpha += 1 / 120;
			alpha = min(alpha, 1);
			angleRender += 360 / countVertex / 2;
			Obj_SetVisible(obj, true);

			frameInv = min(100, frameInv);
			let rRate = frameInv / 100;

			ascent(iVert in 0..countVertex / 2) {
				let indexVert = iVert * 2;
				let angle = 360 / (countVertex / 2 - 1) * iVert;

				let vx1 = listRadius[indexVert] * cos(angle);
				let vy1 = listRadius[indexVert] * sin(angle);
				ObjPrim_SetVertexPosition(obj, indexVert + 0, vx1, vy1, 0);

				let vx2 = listRadius[indexVert+1] * cos(angle);
				let vy2 = listRadius[indexVert+1] * sin(angle);
				ObjPrim_SetVertexPosition(obj, indexVert + 1, vx2, vy2, 0);

				if(frame >= 0) {
					let dr = (maxRadius * rRate - listRadius[indexVert]) / 8;
					listRadius[indexVert] = listRadius[indexVert] + dr;
				}
				if(frame > 10) {
					let rRateIn = rRate - 0.12;
					if(rRateIn < 0){rRateIn=0;}
					let dr= (maxRadius * rRateIn - listRadius[indexVert + 1]) / 16;
					listRadius[indexVert + 1] = listRadius[indexVert + 1] + dr;
				}

			}

			ObjRender_SetColor(obj, 192 * alpha, 192 * alpha, 255 * alpha);
			ObjRender_SetPosition(obj, px, py, 0);
			ObjRender_SetAngleZ(obj, angleRender);

			frame++;
		}

		yield;
	}
}

//=======================================================//
//			TASK DEATH EXPLOSION				//
//=======================================================//
task TExplosion {
	let path = current ~ "Player_Sanae.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
	Obj_SetRenderPriority(obj, 0.60);
	ObjPrim_SetTexture(obj, path);
	ObjSprite2D_SetSourceRect(obj, 116, 0, 179, 63);
	ObjSprite2D_SetDestRect(obj, -32, -32, 32, 32);

	let alpha = 255;
	let scale = 0;
	loop(30) {
		scale += 0.2;
		alpha -= 8;
		ObjRender_SetColor(obj, alpha, alpha, alpha);
		ObjRender_SetPosition(obj, GetPlayerX, GetPlayerY, 0);
		ObjRender_SetScaleXYZ(obj, scale, scale, 1);
		yield;
	}
	Obj_Delete(obj);
}
//=======================================================//
//			TASK DEATH EXPLOSION B				//
//=======================================================//
task TExplosionB(x,y,dAlpha,dScale,r,g,b,rl,gl,bl) { 
	let path = current ~ "/expl.png";
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, path);
	Obj_SetRenderPriority(obj, 0.65);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	ObjSprite2D_SetSourceRect(obj, 1, 1, 257, 257);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj, x, y, 0);
	let scale = 0;
	let alpha = 155;
	let c = 0;
	let a = 0;
	task leaf_effect1(xl,yl,a,r,g,b,s,sc,) {
		let alpha = 155;
		let spinA = rand(0,360);
		let spinB = rand(0,360);
		let scl = sc*rand(0.6,1.6);
		let scadd = scl/220;
		let seff = s*rand(1.5,3);
		let R = 0;
		let path = current ~ "/leaf.png";
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);

		ObjPrim_SetTexture(obj, path);
		Obj_SetRenderPriority(obj, 0.65);
		ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
		ObjSprite2D_SetSourceRect(obj, 1, 1, 128, 128);
		ObjSprite2D_SetDestCenter(obj);
		ObjRender_SetPosition(obj, xl, yl, 0);
		ObjRender_SetAngleZ(obj,spinA);
		ObjRender_SetColor(obj, r, g, b);
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleX(obj,scl);
		ObjRender_SetScaleY(obj,scl);

		while(!Obj_IsDeleted(obj)) {
			yield;
			let gx = ObjRender_GetX(obj);
			let gy = ObjRender_GetY(obj);
			seff -= 0.08;
			if(seff <= 0) {seff=0}
			R += seff;
			xl += R*cos(a);
			yl += R*sin(a);
			ObjRender_SetX(obj, xl);
			ObjRender_SetY(obj, yl);
			ObjSprite2D_SetSourceRect(obj, 1, 1, 128, 128);
			ObjSprite2D_SetDestCenter(obj);
			scl-= scadd;
			if(scl < 0) {scl=0}
			ObjRender_SetScaleX(obj,scl);
			ObjRender_SetScaleY(obj,scl);
			
			if(alpha<=0){Obj_Delete(obj);}
			if(scl <= 0){Obj_Delete(obj);}

			if(alpha > 0) {alpha-=3;}
			spinA+= 1.0*rand(2,3);
			spinB+= 1.0*rand(-2,-3);
			ObjRender_SetAngleZ(obj,spinA);
			ObjRender_SetColor(obj, r, g, b);
			ObjRender_SetAlpha(obj, alpha);
		}
	}
	while(alpha > 0) {
		ObjRender_SetColor(obj, r, g, b);
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetScaleXYZ(obj, scale, scale, 1);

		scale += dScale;
		alpha -= dAlpha;

		c++;
		if(c <= 8) {
			leaf_effect1(x,y,rand(0,360),rl,gl,bl,0.2,0.2);
			leaf_effect1(x,y,rand(0,360),rl,gl,bl,0.25,0.1);
			leaf_effect1(x,y,rand(0,360),rl,gl,bl,0.2,0.15);
		}
		yield;
	}
	Obj_Delete(obj);
}
//=======================================================//
//			TASK DEATH EFFECT				//
//=======================================================//
task TDeathEff {
	loop(28) {
		sclDx -= 1/28;
		alphaD -= 255/28;
		sclDy += 0.05;
		ObjRender_SetScaleX(objplayerghost, sclDx);
		ObjRender_SetScaleY(objplayerghost, sclDy);
		ObjRender_SetAlpha(objplayerghost, alphaD);
		yield;
	}
}
//=======================================================//
//			TASK SPELLCARD					//
//=======================================================//
task TSpell {
	let objSpellname = ObjPrim_Create(OBJ_SPRITE_2D); //DEFINI ICI CAR EFFACE DANS LA TASK MERE
	let objSpellnametxt = ObjText_Create();
	let alpha_sn = 0;
	let a = 0;
	let soundID = 0;

	//let bSlowMove = GetVirtualKeyState(VK_SLOWMOVE)==KEY_PUSH || GetVirtualKeyState(VK_SLOWMOVE)==KEY_HOLD;
	let bSlowMove = false;
	let objManage = GetSpellManageObject();
	
	let enemyX = 0;
	let enemyY = 0;

	IsOnBomb = true;
	bgspell;
	spell_name();
	cutin();
	CollectItem();
	if(bSlowMove) {
		SetPlayerInvincibilityFrame(420);
	} else {
		SetPlayerInvincibilityFrame(420);
	}
	SetPlayerSpeed(0,0);
	loop(60) {
		alphaD = 255;  //alpha des option remis à 255 en cas de deathbomb
		yield;
	}

	loop(5) {
		effect_unf(a, GetPlayerX+96*cos(a), GetPlayerY+96*sin(a), 1, soundID, 112, 5);
		soundID++;
		a += 360/5;
	}
	a = 45;
	soundID = 0;
	loop(30) {yield;}
	loop(5) {
		effect_unf(a, GetPlayerX+2*96*cos(a), GetPlayerY+2*96*sin(a), 2, soundID, 2*112, 5.5);
		soundID++;
		a += 360/5;
	}
	a = 0;
	soundID = 0;
	loop(30) {yield;}
	loop(5) {
		effect_unf(a, GetPlayerX+3*96*cos(a), GetPlayerY+3*96*sin(a), 3, soundID, 3*112, 6);
		soundID++;
		a += 360/5;
	}
	a = 0;
	soundID = 0;
	SetPlayerSpeed(4.55,2.25);
	IsOnBomb = false;
	loop(200) {yield;}

	IsDead = false;
	Obj_Delete(objSpellname);
	Obj_Delete(objSpellnametxt);
	Obj_Delete(objManage);
	loop(60) {
		alpha_sn -= 5;
		if(alpha_sn < 0) {alpha_sn = 0;}
		ObjRender_SetAlpha(objSpellname, alpha_sn);
		yield;
	}
//-----------------------------------------------------------------//
//		COLLECT ITEMS			//
//-----------------------------------------------------------------//
	task CollectItem {
		while(!Obj_IsDeleted(objManage)){
			yield;
			CollectAllItems;
		}
	}
//-----------------------------------------------------------------//
//		BGSPELL				//
//-----------------------------------------------------------------//
	task bgspell {
		let imgbg = current ~ "bgsanae.png";
		let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
		let animbg = 0;
		let r = 255;
		let g = 255;
		let b = 255;
		let taskON = true;
		let alpha = 200;
		ObjPrim_SetTexture(objbg, imgbg);
		Obj_SetRenderPriority(objbg, 0.25);
		while(taskON == true) {
			yield;
			animbg+= 2;
			r = 50+205*(|cos(0.5*animbg)|);
			g = 50+205*(|sin(0.4*animbg)|);
			b = 50+205*(|cos(0.6*animbg)|);
			if(IsPlayerSpellActive == false) {
				alpha -= 5;
				if(alpha < 0) {Obj_Delete(objbg);}
			}
			ObjSprite2D_SetDestCenter(objbg);
			ObjSprite2D_SetSourceRect(objbg, 1+animbg, 1+animbg, GetClipMaxX+animbg, GetClipMaxY+animbg);
			ObjRender_SetX(objbg, GetCenterX);
			ObjRender_SetY(objbg, GetCenterY);
			ObjRender_SetColor(objbg, r,g,b);
			ObjRender_SetAlpha(objbg, alpha);
		}
	}
//-----------------------------------------------------------------//
//		SPELLNAME			//
//-----------------------------------------------------------------//
	task spell_name() {
		let scl_sn = 6;
		let imgSpell = current ~ "sanae_spell.png";
		
		let Spellname = "";
		ObjPrim_SetTexture(objSpellname, imgSpell);
		ObjRender_SetX(objSpellname, 126);
		ObjRender_SetY(objSpellname, GetClipMaxY-26);
		ObjRender_SetAlpha(objSpellname, alpha_sn);
		ObjRender_SetScaleX(objSpellname, scl_sn);
		ObjRender_SetScaleY(objSpellname, scl_sn);
		ObjSprite2D_SetSourceRect(objSpellname, 1, 1, 251, 35);
		Spellname = "Omikuji \"Omikuji Star\"";
		Text(objSpellnametxt, Spellname, 28, GetClipMaxY-36, 10, 240, 255, 245, 200, 255, 220, 1, 5, 1, 2, 0.55, 255, 1);
		while(!Obj_IsDeleted(objManage)){
			yield;
			alpha_sn += 2.5;
			if(alpha_sn > 255) {alpha_sn = 255;}
			scl_sn -= 0.1;
			if(scl_sn < 1) {scl_sn = 1;}
			ObjSprite2D_SetDestCenter(objSpellname); //MUST BE IN WHILE LOOP
			ObjRender_SetAlpha(objSpellname, alpha_sn);
			ObjRender_SetScaleX(objSpellname, scl_sn);
			ObjRender_SetScaleY(objSpellname, scl_sn);

			ObjRender_SetAlpha(objSpellnametxt, alpha_sn);
			ObjRender_SetScaleX(objSpellnametxt, scl_sn);
			ObjRender_SetScaleY(objSpellnametxt, scl_sn);
		}
	}

//-----------------------------------------------------------------//
//		CUTIN				//
//-----------------------------------------------------------------//
	task cutin() {
		let alpha_cuteff = 0;
		let alpha_cut = 0;
		let cuteffX = 0;
		let cuteffY = 0;
		let c_eff = 0;

		let imgCutin = current ~ "Sanae_cutin.png";
		let imgCutineff = current ~ "spellattack.png";

		let objCutin = ObjPrim_Create(OBJ_SPRITE_2D);
		let objCutineff_ver = ObjPrim_Create(OBJ_SPRITE_2D); 
		let objCutineff_hor = ObjPrim_Create(OBJ_SPRITE_2D);

		ObjPrim_SetTexture(objCutineff_ver, imgCutineff);
		ObjRender_SetX(objCutineff_ver, 136);
		ObjRender_SetY(objCutineff_ver, GetClipMaxY-126);
		ObjRender_SetAlpha(objCutineff_ver, alpha_cuteff);
		ObjRender_SetAngleZ(objCutineff_ver, -90);
		ObjSprite2D_SetSourceRect(objCutineff_ver, 1, 1, 3*755, 50);

		ObjPrim_SetTexture(objCutineff_hor, imgCutineff);
		ObjRender_SetX(objCutineff_hor, 126);
		ObjRender_SetY(objCutineff_hor, GetClipMaxY-126);
		ObjRender_SetAlpha(objCutineff_hor, alpha_cuteff);
		ObjRender_SetAngleZ(objCutineff_hor, 0);
		ObjSprite2D_SetSourceRect(objCutineff_hor, 1, 1, 3*755, 50);

		ObjPrim_SetTexture(objCutin, imgCutin);
		ObjRender_SetX(objCutin, 126);
		ObjRender_SetY(objCutin, GetClipMaxY-46);
		ObjSprite2D_SetSourceRect(objCutin, 1, 1, 2*403, 2*729);
		ObjRender_SetScaleXYZ(objCutin, 0.5, 0.5, 0.5);

		while(!Obj_IsDeleted(objManage)){
			yield;
			c_eff++;
			if(c_eff < 40) {
				alpha_cut += 8;
				if(alpha_cut > 255) {alpha_cut = 255;}
			}
			if(c_eff >= 70) {
				alpha_cut -= 6;
				if(alpha_cut < 0) {alpha_cut = 0;}
			}
			if(c_eff < 45) {
				alpha_cuteff += 6;
				if(alpha_cuteff > 120) {alpha_cuteff = 120;}
			}
			if(c_eff >= 80) {
				alpha_cuteff -= 5;
				if(alpha_cuteff < 0) {alpha_cuteff = 0;}
			}
			cuteffX += 0.75;
			cuteffY += 0.75;

			ObjSprite2D_SetDestCenter(objCutineff_hor); //MUST BE IN WHILE LOOP
			ObjRender_SetAlpha(objCutineff_hor, alpha_cuteff);
			ObjRender_SetX(objCutineff_hor, 126+cuteffX);
			ObjRender_SetY(objCutineff_hor, GetClipMaxY-126+0.25*cuteffY);
			ObjSprite2D_SetSourceRect(objCutineff_hor, 1, 1, 3*755, 50);

			ObjSprite2D_SetDestCenter(objCutineff_ver); //MUST BE IN WHILE LOOP
			ObjRender_SetAlpha(objCutineff_ver, alpha_cuteff);
			ObjRender_SetX(objCutineff_ver, 136+0.25*cuteffX);
			ObjRender_SetY(objCutineff_ver, GetClipMaxY-126+cuteffY);
			ObjSprite2D_SetSourceRect(objCutineff_ver, 1, 1, 3*755, 50);

			ObjSprite2D_SetDestCenter(objCutin); //MUST BE IN WHILE LOOP
			ObjRender_SetY(objCutin, GetClipMaxY-46-1.5*cuteffY);
			ObjRender_SetZ(objCutin, 79);
			ObjRender_SetAlpha(objCutin, alpha_cut);

		}
	}

//-----------------------------------------------------------------//
//		EFFECT 				//
//-----------------------------------------------------------------//
	task effect_unf(A,xmax,ymax,s, sound, r, dmg) {
		let angle = 0;
		let alpha = 255;
		let obj = ObjSpell_Create();
		let obj_img = ObjPrim_Create(OBJ_SPRITE_2D);
		let objExpl = ObjSpell_Create();
		let objExpl_img = ObjPrim_Create(OBJ_SPRITE_2D);
		let x = GetPlayerX;
		let y = GetPlayerY;
		let xs = GetPlayerX;
		let ys = GetPlayerY;
		let scl = 0;
		let c = 0;
		let imgEffect = current ~ "Player_Sanae.png";
		let imgEffect2 = current ~ "SanaeSpell_eff1.png";
		let Radd = 0;
		let  forced_end = false;
		
		ObjRender_SetBlendType(objExpl_img, BLEND_ADD_ARGB);

		ObjPrim_SetTexture(obj_img, imgEffect);
		ObjSprite2D_SetSourceRect(obj_img, 129,65,160,96);
		ObjRender_SetPosition(obj_img, x, y, 0);
		Obj_SetRenderPriority(obj_img, 0.60);
		Obj_SetRenderPriority(objExpl_img, 0.61);
		if(sound == 0) {PlaySound(SE_SHOTBOMB,100);}
		ObjSpell_Regist(obj);
		while(!Obj_IsDeleted(objManage)) {
			yield;
			if(GetDistance(xs, ys, x, y) >= 0.75*r) {
				s = 0.85*s;
			}
			if(GetDistance(xs, ys, x, y) < 0.80*r || s > 0.01) {
				x = ObjRender_GetX(obj_img);
				y = ObjRender_GetY(obj_img);
				Radd += s;
				angle += 5;
				ObjRender_SetAngleZ(obj_img, angle);
				ObjPrim_SetTexture(obj_img, imgEffect);
				ObjSprite2D_SetDestCenter(obj_img);
				ObjRender_SetX(obj_img, xs+Radd*cos(A));
				ObjRender_SetY(obj_img, ys+Radd*sin(A));
				//ObjSpell_SetIntersectionCircle(obj, xs+Radd*cos(A), ys+Radd*sin(A), 12);
				ObjSpell_SetDamage(obj, 1);
			}
			if(GetDistance(xs, ys, x, y) >= 0.80*r || s <= 0.01) {
				s = 0;
				c++;
				if(c == 30) {
					if(sound == 0) {
						PlaySound(SE_BOMB,100);
						TShake;
					}
					ObjSpell_Regist(objExpl);
					Obj_Delete(obj_img);
					//angle = rand(0,360);
				}
				if(c >= 30) {
					ObjSprite2D_SetDestCenter(objExpl_img);
					ObjPrim_SetTexture(objExpl_img, imgEffect2);
					ObjSprite2D_SetSourceRect(objExpl_img, 1,1,256,256);
					ObjRender_SetX(objExpl_img, x);
					ObjRender_SetY(objExpl_img, y);
					ObjRender_SetAngleZ(objExpl_img, angle);
					ObjRender_SetScaleX(objExpl_img, scl);
					ObjRender_SetScaleY(objExpl_img, scl);
					ObjRender_SetAlpha(objExpl_img, alpha);

					ObjSpell_SetIntersectionCircle(objExpl, x, y, 196*scl);
					ObjSpell_SetDamage(objExpl, scl*5);
					scl += 0.03;
				}
				if(c >= 60) {
					alpha -= 10;
				}
				if(alpha <= 0) {
					Obj_Delete(objExpl);
					Obj_Delete(objExpl_img);
					Obj_Delete(obj);
				}
			}
		}
	}
//-----------------------------------------------------------------//
//		EFFECT SHAKE			//
//-----------------------------------------------------------------//
	task TShake {
		loop(60) {
			Set2DCameraFocusX(GetStgFrameWidth / 2 + rand(-4, 4));
			Set2DCameraFocusY(GetStgFrameHeight / 2 + rand(-4, 4));
			yield;
		}
		Reset2DCamera();
	}
}
