#TouhouDanmakufu[Single]
#ScriptVersion[3]
#Title["Spellcard 7"]
#Text[""]
#System[".\system\Default_System.txt"]

#include"./lib/AllStarShot_Const.dnh"
#include"./lib/Functions.txt"
#include"./BGTask.txt"
#include"./Animation_lib.txt"
let Enemy = ID_INVALID;
let e1 = ID_INVALID;
let e2 = ID_INVALID;
let e3 = ID_INVALID;
let e4 = ID_INVALID;
let EnemyX = 0;
let EnemyY = 0;
let yuyuX = 0;
let yuyuY = 0;
let yuyuko = 0;
//those Min and Max x y are taken from Shadow's Raimoo, Edited for full screen by Me(i am too honest :))
//if(ObjEnemy_GetInfo(Enemy, INFO_LIFE) == 0){break;}  my god "function"
let MinX = 0;
let MaxX = 640;
let MinY = 0;
let MaxY = GetStgFrameHeight*1.8;
let eimg = CSD~"Letra.png";
@Event{
	alternative(GetEventType)
	case(EV_REQUEST_LIFE){SetScriptResult(1900);}
	case(EV_REQUEST_TIMER){SetScriptResult(120);}
case(EV_REQUEST_SPELL_SCORE){SetScriptResult(90000);}
}

@Initialize{
	Enemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
	ObjEnemy_Regist(Enemy);
//SetShotAutoDeleteClip(50,50,50,50);
SetAutoDeleteObject(true);
ObjEnemy_SetDamageRate(Enemy,0,0);
DrawTimer03(1);
InitializeAction(Enemy,GetCurrentScriptDirectory ~"img/dot_mogel.png");
DrawBoss_Task(Enemy);
name("Mogel",0,30);
ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
	
	BossActions;
}

task DrawPig{
ObjPrim_SetTexture(Enemy,GetCurrentScriptDirectory~"img/pig_sheet.png");
ObjSprite2D_SetSourceRect(Enemy,405,0,540,145);
ObjSprite2D_SetDestCenter(Enemy);
}

@MainLoop{
	yield;
}

task BossActions{
ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2, 140, 20,6);
//SetAction(Enemy,ACT_MOVE_R,100);
//wait(120);
	ShootBullets;
//Texto;
	while(ObjEnemy_GetInfo(Enemy, INFO_LIFE) > 0){
		EnemyX = ObjMove_GetX(Enemy);
		EnemyY = ObjMove_GetY(Enemy);
		ObjEnemy_SetIntersectionCircleToShot(Enemy, ObjMove_GetX(e1), ObjMove_GetY(e1), 20);
		//ObjEnemy_SetIntersectionCircleToPlayer(e1, ObjMove_GetX(e1), ObjMove_GetY(e1), 20);
		ObjEnemy_SetIntersectionCircleToPlayer(Enemy, EnemyX, EnemyY, 20);
		//ObjEnemy_SetIntersectionCircleToShot(e2, ObjMove_GetX(e4), ObjMove_GetY(e4), 20);

		yield;
	}

StartSlow(TARGET_ALL,30);
SE(CSD~"sfx/boom00.wav");
ObjMove_SetDestAtWeight(Enemy, GetStgFrameWidth/2+rand(50,-50), rand(100,140), 20,2);
wait(60);
StopSlow(TARGET_ALL);
SE(CSD~"sfx/boom01.wav");
DeleteShotAll(TYPE_ALL, TYPE_ITEM);
Diffusion01(EnemyX,EnemyY,60,255,255,255);
Diffusion01(ObjMove_GetX(e1),ObjMove_GetY(e1),30,255,255,255);
Diffusion01(ObjMove_GetX(e2),ObjMove_GetY(e2),30,255,255,255);
Diffusion01(ObjMove_GetX(e3),ObjMove_GetY(e3),30,255,255,255);
Diffusion01(ObjMove_GetX(e4),ObjMove_GetY(e4),30,255,255,255);
	Obj_Delete(Enemy);
	Obj_Delete(e1);
	Obj_Delete(e2);
	Obj_Delete(e3);
	Obj_Delete(e4);
	loop(120){yield;}
	CloseScript(GetOwnScriptID);
}
function wait(t){loop(t){yield;}}

task ShootBullets{
//Preparation
MagicCircleEx2(Enemy,false); //Magic Circle, false doesnt contain opening, but loads the last script's pos and angle
LifeCircleBar_A(Enemy,1.0,0.0,false);//Active Lifebar part(enemy,usable part,unusable part(empity),opening)
LifeCircleBar_B(Enemy,0.0,0.0,false);//Inactive LB part
//LifeCircleBar_Marker(Enemy,0.5);//Marker
Aura1(Enemy,8,128,128,128);	//Aura(enemy,spawn rate,r,g,b)			
wait(60);
//Spellcard
SE(CSD~"sfx/spell.wav");
Cutin01(3,0,0,CSD ~ "img/mogel.png",0,0,700,1200);
Cutin03(2,0,0,"Golem -Emet-");
SpellBGoverlay;
SpellBG3;
wait(90);
ObjEnemy_SetDamageRate(Enemy,30,0);
//Shots
let angul = 0;
let angul2 = 180;
let time = 180;
let radius = 30;
wait(80);
//shoot2;
e1 = CreateEnemyA1(EnemyX,EnemyY,0); //E
e2 = CreateEnemyA1(EnemyX,EnemyY,0); //m
e3 = CreateEnemyA1(EnemyX,EnemyY,0); //e
e4 = CreateEnemyA1(EnemyX,EnemyY,0); //t
let es = [e1,e2,e3,e4];

ascent(i in 0..4){
 ObjPrim_SetTexture(es[i],CSD~"Emet.png");
 }
 
 ObjSprite2D_SetSourceRect(e1,0,0,30,40);
 ObjSprite2D_SetDestCenter(e1);
 ObjSprite2D_SetSourceRect(e2,35,0,70,40);
 ObjSprite2D_SetDestCenter(e2);
 ObjSprite2D_SetSourceRect(e3,72,0,100,40);
 ObjSprite2D_SetDestCenter(e3);
 ObjSprite2D_SetSourceRect(e4,100,0,130,40);
 ObjSprite2D_SetDestCenter(e4);
 
 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY-60,20,5);
 ObjMove_SetDestAtWeight(e2,EnemyX+180,EnemyY-90,20,5);
 ObjMove_SetDestAtWeight(e3,EnemyX-180,EnemyY-90,20,5);
 ObjMove_SetDestAtWeight(e4,EnemyX,EnemyY+30,20,5);
 SetHitbox;
 MagicCircleEx(e1,true);
 
 let spdadd = 2.5;
 let angadd = 0;
 wait(60);

loop{
if(ObjEnemy_GetInfo(Enemy, INFO_LIFE) == 0){break;}
// First part, Masterspark on [m,e], > shaped bullets on [t]  Raiko nons
 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY-60,20,5);
 ObjMove_SetDestAtWeight(e2,EnemyX+180,EnemyY-90,20,5);
 ObjMove_SetDestAtWeight(e3,EnemyX-180,EnemyY-90,20,5);
 ObjMove_SetDestAtWeight(e4,EnemyX,EnemyY+30,20,5);
  nTestCharge(ObjMove_GetX(e2),ObjMove_GetY(e2),90,255,255,255);
  nTestCharge(ObjMove_GetX(e3),ObjMove_GetY(e3),90,255,255,255);
  SE(CSD~"sfx/charge00.wav");
  wait(80);
  MasterSpark([ObjMove_GetX(e2),ObjMove_GetY(e2)],90,0,30,300);
  MasterSpark([ObjMove_GetX(e3),ObjMove_GetY(e3)],90,0,30,300);
  SE(CSD~"sfx/spark.wav");
  //Eshot1(e1);
   loop(7){
    spdadd = 2.5;
	angadd =0;
	SE(CSD~"sfx/tan04.wav");
	ascent(i in 0..8){
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)+angadd,PELLET_GRAY,10,false);
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)-angadd,PELLET_GRAY,10,false);
     angadd+= 7;
     spdadd-= 0.3;
     }
	 //wait(30);
	spdadd = 2.5;
	angadd =0;
	 ascent(i in 0..8){
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)+45+angadd,PELLET_GRAY,10,false);
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)+45-angadd,PELLET_GRAY,10,false);
     angadd+= 7;
     spdadd-= 0.3;
     }
	spdadd = 2.5;
	angadd =0;
	 ascent(i in 0..8){
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)-45+angadd,PELLET_GRAY,10,false);
     CreateShotFA1(ObjMove_GetX(e4),ObjMove_GetY(e4),2+spdadd,getAtanAngle(e4,Player)-45-angadd,PELLET_GRAY,10,false);
     angadd+= 7;
     spdadd-= 0.3;
     }
	 wait(60);
    }
	wait(120);
	SE(CSD~"sfx/warp.wav");
	ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY+60,20,5);
	wait(60);
	angul = 0;
	loop(30){
	SE(CSD~"sfx/tan00.wav");
	 ascent(i in 0..4){
	 spdadd = 1;
	 angadd = 0;
	  ascent(o in 0..4){
	    CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),2.5+spdadd,angul+i*90+angadd,PELLET_GRAY,10,false);
        CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),2.5+spdadd,angul+i*90-angadd,PELLET_GRAY,10,false);
		angadd+=1;
		spdadd-=0.25;
	   }
	  }
	  angul+= 20;
	  wait(5);
	 }
	 angul = 0;
	loop(30){
	SE(CSD~"sfx/tan00.wav");
	 ascent(i in 0..4){
	 spdadd = 1;
	 angadd = 0;
	  ascent(o in 0..4){
	    let a=CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),2.5+spdadd,angul+i*90+angadd,PELLET_GRAY,10,false);
        let b=CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),2.5+spdadd,angul+i*90-angadd,PELLET_GRAY,10,false);
		ObjRender_SetColorHSV(a,0,0,0);
		ObjRender_SetColorHSV(b,0,0,0);
		angadd+=1;
		spdadd-=0.25;
	   }
	  }
	  angul-= 20;
	  wait(5);
	 }
	 wait(60);
	 SE(CSD~"sfx/warp.wav");
	 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY-60,20,5);
	 wait(60);
	 //Pattern 2, Straight lasers [t], fast Shots [m,e]
    spdadd = 0;
	angul=0;
	 loop(60){
	 SE(CSD~"sfx/tan03.wav");
	 ascent(i in 0..8){
	  CreateShotFA1(ObjMove_GetX(e3),ObjMove_GetY(e3),1+spdadd,angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  let a=CreateShotFA1(ObjMove_GetX(e2),ObjMove_GetY(e2),1+spdadd,-angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  ObjRender_SetColorHSV(a,0,0,0);
	  }
	   angul+= 5;
	   spdadd+= 0.04;
	   wait(2);
	  }
	  //wait(60);
	  loop(4){
	  SE(CSD~"sfx/Laser.wav");
	 ascent(i in 0..8){
	  CreateStraightLaserA1(ObjMove_GetX(e4),ObjMove_GetY(e4),getAtanAngle(e4,Player)+i*360/8,600,90,90,ST_LASER_GRAY,80); 
	  }
	  wait(10);
	 }
	 wait(120);
	 SE(CSD~"sfx/warp.wav");
	 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY+60,20,5);
	 wait(60);
	 angul = 0;
	 spdadd = 0;
	 loop(20){
	 SE(CSD~"sfx/tan03.wav");
	 ascent(i in 0..8){
	  //CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  let a=CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,-angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  ObjRender_SetColorHSV(a,0,0,0);
	  }
	   angul+= 5;
	   spdadd+= 0.05;
	   wait(2);
	  }
	  angul+= 45;
	  spdadd = 0;
	  loop(20){
	 SE(CSD~"sfx/tan03.wav");
	 ascent(i in 0..8){
	  CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  //let a=CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,-angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  //ObjRender_SetColorHSV(a,0,0,0);
	  }
	   angul+= 5;
	   spdadd+= 0.05;
	   wait(2);
	  }
	  wait(90);
	  angul = 0;
	  spdadd=0;
	 loop(25){
	 SE(CSD~"sfx/tan03.wav");
	 ascent(i in 0..8){
	  CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  let a=CreateShotFA1(ObjMove_GetX(e1),ObjMove_GetY(e1),1+spdadd,-angul+i*360/8,ARROWHEAD_GRAY,10,true);
	  ObjRender_SetColorHSV(a,0,0,0);
	  }
	   angul+= 5;
	   spdadd+= 0.1;
	   wait(2);
	  }
	 //Pattern 3
	 wait(60);
	 SE(CSD~"sfx/warp.wav");
	 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY-60,20,5);
	 wait(60);
	 
	 angul = 90;
	 ascent(i in 0..5){
	 SE(CSD~"sfx/Laser.wav");
	  let a2=CreateCurveLaserA1(ObjMove_GetX(e4),ObjMove_GetY(e4),6,angul+i*360/5,100,20,C_LASER_GRAY,0);
	  let a = CreateCurveLaserA1(ObjMove_GetX(e4),ObjMove_GetY(e4),6,angul+i*360/5,100,20,C_LASER_GRAY,0);
	  //ObjRender_SetColorHSV(a,0,0,0);
	  ObjCrLaser_SetTipDecrement(a,0);
	  ObjCrLaser_SetTipDecrement(a2,0);
	  ObjMove_AddPatternA2(a2,0,NO_CHANGE,NO_CHANGE,0,6,0);
	  ObjMove_AddPatternA2(a,0,NO_CHANGE,NO_CHANGE,0,-6,0);
	  ObjMove_AddPatternA2(a2,90,5,NO_CHANGE,0,0.7,0);
	  ObjMove_AddPatternA2(a,90,5,NO_CHANGE,0,-0.7,0);
	  Trail(a2,10);
	  Trail(a,10);
	  }
	 CreateStraightLaserA1(ObjMove_GetX(e2),ObjMove_GetY(e2),90,700,30,120,ST_LASER_GRAY,60);
	 PagodaBullet(ObjMove_GetX(e2),ObjMove_GetY(e2),90);
	 CreateStraightLaserA1(ObjMove_GetX(e3),ObjMove_GetY(e3),90,700,30,120,ST_LASER_GRAY,60);
	 PagodaBullet(ObjMove_GetX(e3),ObjMove_GetY(e3),90);
	 wait(480);
	 SE(CSD~"sfx/warp.wav");
	 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY+60,4,20);
	 wait(60);
	 ascent(i in 0..5){
	 WindGodPart(ObjMove_GetX(e1),ObjMove_GetY(e1),3,0+i*360/5,AMULET_GRAY);
	 }
	 
wait(300);
	 wait(60);
	 SE(CSD~"sfx/warp.wav");
	 ObjMove_SetDestAtWeight(e1,EnemyX,EnemyY-60,20,5);
	 wait(60);
  }
}
function angleToPlayer{
let angle=atan2(GetPlayerY-EnemyY,GetPlayerX-EnemyX);
return angle;
}

task SetHitbox{
loop{
ObjEnemy_SetIntersectionCircleToShot(e2, ObjMove_GetX(e2), ObjMove_GetY(e2), 40);
ObjEnemy_SetIntersectionCircleToShot(e3, ObjMove_GetX(e3), ObjMove_GetY(e3), 40);
ObjEnemy_SetIntersectionCircleToShot(e4, ObjMove_GetX(e4), ObjMove_GetY(e4), 40);
ObjEnemy_SetIntersectionCircleToPlayer(e2, ObjMove_GetX(e2), ObjMove_GetY(e2), 20);
ObjEnemy_SetIntersectionCircleToPlayer(e3, ObjMove_GetX(e3), ObjMove_GetY(e3), 20);
ObjEnemy_SetIntersectionCircleToPlayer(e4, ObjMove_GetX(e4), ObjMove_GetY(e4), 20);
yield;
 }
}


//master spark
task MasterSpark(pos,angle,plus,delay,kill){
	let id		= [ObjPrim_Create(OBJ_SPRITE_2D),ObjPrim_Create(OBJ_SPRITE_2D)];
	let die		= 0;
	let alpha1	= 0;
	let alphaA	= 0;
	let sca1	= 0;
	let scaA	= 0;
	let sca2	= 0;
	let scaB	= 0;
	let ang1	= 0;
	let angA	= 0;
	let cc		= 0;
	let i		= 0;
	
	loop(length(id)){
		ObjRender_SetPosition(id[i],pos[0],pos[1],0);
		ObjPrim_SetTexture(id[i],GetCurrentScriptDirectory~"./img/laser01a.png");
		Obj_SetRenderPriorityI(id[i],22);
		ObjRender_SetBlendType(id[i],BLEND_ADD_RGB);
		ObjRender_SetScaleXYZ(id[i],0.06+sca1,sca2,0);
		ObjRender_SetAngleXYZ(id[i],0,0,angle-90);
		ObjSprite2D_SetSourceRect(id[i],0,1,256,256);
		ObjSprite2D_SetDestRect(id[i],-128,0,128,256);
		i++;
	}
	i=0;
	
	ObjRender_SetColor(id[0],255-alpha1,255-alpha1,255-alpha1);
	ObjRender_SetColor(id[1],128-alpha1/2,128-alpha1/2,128-alpha1/2);
	
	while(!Obj_IsDeleted(Enemy)){
		die++;
		if(die>kill){break;}
		
		if(ang1<plus && cc>30){angA+=0.04;ang1=plus*sin(angA);}
if(ang1>plus && cc>30){angA-=0.04;ang1=plus*sin(-angA);}
		
		ObjRender_SetAngleXYZ(id[0],0,0,angle+ang1-90);
		ObjRender_SetAngleXYZ(id[1],0,0,angle+ang1-90);
		
		if(sca2>=1){cc++;}
		if(sca1<1 && cc>30){scaA+=2;}
		sca1=1*sin(scaA);
		if(sca2<1){scaB+=5;}
		sca2=1*sin(scaB);
		ObjRender_SetPosition(id[0],pos[0]+rand(-2,2),pos[1]+rand(-2,2),0);
		ObjRender_SetPosition(id[1],pos[0]+rand(-4,4),pos[1]+rand(-4,4),0);
		ObjRender_SetScaleXYZ(id[0],0.06+sca1*1.6,sca2*2.0,0);
		ObjRender_SetScaleXYZ(id[1],0.06+sca1*2,sca2*2.0,0);
		
		if(cc>30){
			let sht = [CreateShotA2(pos[0],pos[1],rand(10,15),angle+ang1+rand(-15,15),0,0,LARGE_GRAY+500,0),
						CreateShotA2(pos[0],pos[1],rand(10,15),angle+ang1+rand(-16,16),0,0,LARGE_GRAY+500,0)];
			ObjRender_SetScaleXYZ(sht[0],1.4,2,0);
			ObjRender_SetScaleXYZ(sht[1],1.6,2,0);
		}
		
		yield;
	}
	while(alpha1<255){
		alphaA+=5;
		alpha1=255*sin(alphaA);
		ObjRender_SetColor(id[0],255-alpha1,255-alpha1,255-alpha1);
		ObjRender_SetColor(id[1],128-alpha1/2,128-alpha1/2,128-alpha1/2);
		
		yield;
	}
	Obj_Delete(id[0]);
	Obj_Delete(id[1]);
}

task Eshot1(obj){
loop(60*7){
SE(CSD~"sfx/tan05.wav");
 CreateShotFA2(ObjMove_GetX(obj),ObjMove_GetY(obj),0,rand(0,360),0.5,3,SMALL_GRAY,30,false);
 yield;
 }
}
task Trail(obj,frame){
wait(frame);

while(!Obj_IsDeleted(obj)){
let angol= getAtanAngle(obj,Enemy);
SE(CSD~"sfx/tan00.wav");
 let oa= CreateShotFA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,angol,PELLET_GRAY,10,true);
 ObjMove_AddPatternA2(oa,30,0,NO_CHANGE,0.01,0,3);
 let ob= CreateShotFA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,angol+180,PELLET_GRAY,10,true);
 ObjMove_AddPatternA2(ob,30,0,NO_CHANGE,0.01,0,3);
 //let oc= CreateShotFA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,angol+270,PELLET_GRAY,10,true);
 //ObjMove_AddPatternA2(oc,30,0,NO_CHANGE,0.01,0,3);
 //let od= CreateShotFA1(ObjMove_GetX(obj),ObjMove_GetY(obj),0,angol+90,PELLET_GRAY,10,true);
 //ObjMove_AddPatternA2(od,30,0,NO_CHANGE,0.01,0,3);
 ObjRender_SetColorHSV(oa,0,0,0);
 ObjRender_SetColorHSV(ob,0,0,0);
 //ObjRender_SetColorHSV(oc,0,0,0);
 //ObjRender_SetColorHSV(od,0,0,0);
 wait(12);
 }
}

task WindGodPart(x,y,anv,mainangle,graphic){
let a = CreateShotFA1(x,y,3,mainangle,DOT_RED,1,true);
ObjMove_SetAngularVelocity(a,anv);
ObjShot_SetDeleteFrame(a,120);
ObjShot_SetSpellResist(a,true);
while(!Obj_IsDeleted(a)){
 SE(CSD~"sfx/kira00.wav");
 let b=CreateShotFA1(ObjMove_GetX(a),ObjMove_GetY(a),0,ObjMove_GetAngle(a),graphic,10,true);
 ObjMove_AddPatternA2(b,120,0,NO_CHANGE,0.01,0,4);
 ObjShot_SetSpellResist(b,true);
 wait(2);
 }
}

task PagodaBullet(x,y,angle){
let obj = CreateShotFA1(x,y,3,angle,0,1,true);
let radius = 0;
let angol = angle+90;
let angol2 = angle-90;
let radd = 0;
let rad = radius;
while(!Obj_IsDeleted(obj)){
SE(CSD~"sfx/kira00.wav");
let a=CreateShotFA1(ObjMove_GetX(obj)+rad*cos(angle+90),ObjMove_GetY(obj)+rad*sin(angle+90),0,angol,AMULET_GRAY,10,true);
let a2=CreateShotFA1(ObjMove_GetX(obj)+rad*cos(angle-90),ObjMove_GetY(obj)+rad*sin(angle-90),0,angol2,AMULET_GRAY,10,true);
ObjMove_AddPatternA2(a,180,0,NO_CHANGE,0.008,0,4);
ObjMove_AddPatternA2(a2,180,0,NO_CHANGE,0.008,0,4);

rad = radius+sin(radd)*40;
radd+=10;
angol+= 10;
angol2+= 10;
wait(3);
}

}