#include "./ImageEnnemy.txt"
#include "./Sounds.txt"

// Ennemy simple sans attaque (Sauf Lunatic)
task CreateStageEnemy0(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee3(EnnemyObj);
	fire0(EnnemyObj);
	mouvement0(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 3*2 tirs vers le joueur
task CreateStageEnemy1(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire1(EnnemyObj);
	mouvement1(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy2(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec cercle de tirs vers le joueur
task CreateStageEnemy2(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee3(EnnemyObj);
	fire2(EnnemyObj);
	mouvement2(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 7*2 tirs vers le joueur
task CreateStageEnemy3(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire3(EnnemyObj);
	mouvement2(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy2(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec cercle de tirs tombant++
task CreateStageEnemy4(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee1(EnnemyObj);
	fire4(EnnemyObj);
	mouvement3(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy3(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy simple 1 tir vers le joueur
task CreateStageEnemy5(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee3(EnnemyObj);
	fire5(EnnemyObj);
	mouvement0(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy 5*3*20 tirs++
task CreateStageEnemy6(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee1(EnnemyObj);
	fire6(EnnemyObj);
	mouvement4(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy3(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 5*10 tirs vers le joueur
task CreateStageEnemy7(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire7(EnnemyObj);
	mouvement2(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy2(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 7*2 tirs kunai entre le joueur
task CreateStageEnemy8(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee3(EnnemyObj);
	fire8(EnnemyObj);
	mouvement5(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy 4*3 tirs++
task CreateStageEnemy9(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee1(EnnemyObj);
	fire9(EnnemyObj);
	mouvement5(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy3(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 1 gros tir et des petits derriere *3 vers le joueur
task CreateStageEnemy10(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire10(EnnemyObj);
	mouvement3(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy2(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy 5 tir descendant
task CreateStageEnemy11(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire11(EnnemyObj);
	mouvement0(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 5 tir descendant*3 vers le sol
task CreateStageEnemy12(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee2(EnnemyObj);
	fire12(EnnemyObj);
	mouvement3(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy2(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec 5 tir descendant*3 vers le sol++
task CreateStageEnemy13(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee1(EnnemyObj);
	fire13(EnnemyObj);
	mouvement3(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy3(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

// Ennemy avec cercle tirs pellets aleatoire
task CreateStageEnemy14(vie,appX,appY,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
    let EnnemyObj = ObjEnemy_Create(OBJ_ENEMY);
	ObjEnemy_Regist(EnnemyObj);
	ObjEnemy_SetLife(EnnemyObj, vie);
	ObjMove_SetPosition(EnnemyObj, getCenterX+appX, getCenterY+appY);
	renderFee3(EnnemyObj);
	fire14(EnnemyObj);
	mouvement0(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin);
	TFinalizeEnnemy1(EnnemyObj);
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
            ObjEnemy_SetIntersectionCircleToShot(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 32); 
            ObjEnemy_SetIntersectionCircleToPlayer(EnnemyObj, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 8);
			yield;
		}
}

//120
task mouvement0(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(120);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

//180
task mouvement1(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(180);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

//240
task mouvement2(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(240);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

//345
task mouvement3(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(345);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

//465
task mouvement4(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(465);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

//645
task mouvement5(EnnemyObj,debutX,debutY,finX,finY,tempsdebut,tempsfin) {
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+debutX, getCenterY+debutY, tempsdebut);
	wait(645);
	ObjMove_SetDestAtFrame(EnnemyObj, getCenterX+finX, getCenterY+finY, tempsfin);
	wait(tempsfin);
	ObjEnemy_SetLife(EnnemyObj, -20000);
}

task fire0(EnnemyObj) {
	wait(30);
	loop(25) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 5, dir, 47, 15);
	wait(6);
	}
	}
}

task fire1(EnnemyObj) {
	wait(120);
	loop(2) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3, dir, 27, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3, dir+15, 27, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3, dir-15, 27, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3, dir+30, 27, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3, dir-30, 27, 15);
	wait(30);
	}
	}
}

task fire2(EnnemyObj) {
	wait(120);
	loop(3) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	loop(32) {
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2, dir, 3, 15);
	dir += 360/32;
	}
	}
	wait(30);
	}
}

task fire3(EnnemyObj) {
	wait(120);
	loop(6) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir+15, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir-15, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir+30, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir-30, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir+45, 28, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, dir-45, 28, 15);
	wait(30);
	}
	}
}

task fire4(EnnemyObj) {
	wait(120);
	loop(5) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let angleT = rand(0,360);
	loop(64) {
	let obj1 = CreateShotA1(ObjMove_GetX(EnnemyObj)+40*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT, 16, 15);
	ObjMove_AddPatternA1(obj1, 110, NO_CHANGE, 90);
	angleT += 360/64;
	}
	}
	wait(45);
	}
}

task fire5(EnnemyObj) {
	wait(60);
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	let obj1 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, dir, 35, 15);
	let obj2 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, dir+20, 35, 15);
	let obj3 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, dir-20, 35, 15);
	}
}

task fire6(EnnemyObj) {
	wait(120);
	let angleT = 0;
	loop(20) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	loop(5) {
	CreateShotA1(ObjMove_GetX(EnnemyObj)+20*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT, 831, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj)+20*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT+3, 831, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj)+20*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT+6, 831, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj)+20*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT+9, 831, 15);
	CreateShotA1(ObjMove_GetX(EnnemyObj)+20*cos(angleT),ObjMove_GetY(EnnemyObj)+20*sin(angleT), 1.5, angleT+12, 831, 15);
	angleT += 360/5;
	}
	angleT += 360/20;
	}
	wait(15);
	}
}

task fire7(EnnemyObj) {
	wait(120);
	loop(10) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let angleT = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	loop(12) {
	let obj1 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 1.5, angleT+rand(-10,10), 51, 15);
	angleT += 360/12;
	}
	}
	wait(9);
	}
}

task fire8(EnnemyObj) {
	wait(120);
	loop(10) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let angleT = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	let vitesse = 1.5;
	loop(10) {
	let obj1 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 1.5, angleT+10, 67, 15);
	let obj2 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 1.5, angleT-10, 67, 15);
	ObjMove_AddPatternA1(obj1, 45, vitesse, NO_CHANGE);
	ObjMove_AddPatternA1(obj2, 45, vitesse, NO_CHANGE);
	vitesse += 0.25
	}
	}
	wait(45);
	}
}

task fire9(EnnemyObj) {
	wait(120);
	loop(10) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let angleT = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	loop(4) {
	let obj1 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.75, angleT, 275, 15);
	let obj2 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, angleT+15, 275, 15);
	let obj3 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.5, angleT-15, 275, 15);
	let obj4 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.25, angleT+30, 275, 15);
	let obj5 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2.25, angleT-30, 275, 15);
	let obj6 = CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 2, angleT+45, 275, 15);
	angleT += 90;
	}
	}
	wait(45);
	}
}

task fire10(EnnemyObj) {
	wait(120);
	loop(3) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let angleT = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT, 824, 5);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+50, 824, 5);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT-50, 824, 5);
	loop(3) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20), 287, 11);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20), 23, 17);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20), 23, 23);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20), 23, 29);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)+50, 287, 11);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)+50, 23, 17);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)+50, 23, 23);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)+50, 23, 29);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)-50, 287, 11);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)-50, 23, 17);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)-50, 23, 23);
	CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 3.5, angleT+rand(-20,20)-50, 23, 29);
	wait(29);
	}
	}
	}
	}
}

task fire11(EnnemyObj) {
	wait(140);
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let obj1 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270,-0.5,2, 87, 5);
	let obj2 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+30,-0.5,2, 87, 5);
	let obj3 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-30,-0.5,2, 87, 5);
	let obj4 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+60,-0.5,2, 87, 5);
	let obj5 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-60,-0.5,2, 87, 5);
	let obj6 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+90,-0.5,2, 87, 5);
	let obj7 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-90,-0.5,2, 87, 5);
	ObjMove_AddPatternA1(obj1, 60, NO_CHANGE, 90+rand(-15,15));
	descente2(obj2);
	descente1(obj3);
	descente2(obj4);
	descente1(obj5);
	descente2(obj6);
	descente1(obj7);
	}
}

task fire12(EnnemyObj) {
	wait(140);
	loop(15) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let obj1 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+5,-0.5,2, 24, 5);
	let obj2 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-5,-0.5,2, 24, 5);
	let obj3 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-15,-0.5,2, 24, 5);
	let obj4 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+15,-0.5,2, 24, 5);
	let obj5 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-25,-0.5,2, 24, 5);
	let obj6 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+25,-0.5,2, 24, 5);
	let obj7 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-35,-0.5,2, 24, 5);
	let obj8 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+35,-0.5,2, 24, 5);
	descente2(obj1);
	descente1(obj2);
	descente1(obj3);
	descente2(obj4);
	descente1(obj5);
	descente2(obj6);
	descente1(obj7);
	descente2(obj8);
	wait(15);
	}
	}
}

task fire13(EnnemyObj) {
	wait(140);
	loop(15) {
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	let obj1 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+5,-0.5,2, 32, 5);
	let obj2 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-5,-0.5,2, 32, 5);
	let obj3 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-15,-0.5,2, 32, 5);
	let obj4 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+15,-0.5,2, 32, 5);
	let obj5 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-25,-0.5,2, 32, 5);
	let obj6 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+25,-0.5,2, 32, 5);
	let obj7 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270-25,-0.5,2, 32, 5);
	let obj8 = CreateShotA2(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 4, 270+25,-0.5,2, 32, 5);
	descente2(obj1);
	descente1(obj2);
	descente1(obj3);
	descente2(obj4);
	descente1(obj5);
	descente2(obj6);
	descente1(obj7);
	descente2(obj8);
	wait(15);
	}
	}
}

task fire14(EnnemyObj) {
	wait(rand(20,40));
	loop(3) {
	let angleT = rand(0,360);
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {
	loop(25) {
	let obj1 = CreateShotA2(ObjMove_GetX(EnnemyObj)+rand(10,30)*cos(angleT),ObjMove_GetY(EnnemyObj)+rand(10,30)*sin(angleT), 4, angleT,-0.5,1, 59, 5);
	angleT +=360/25 ;
	}
	wait(rand(20,40));
	}
	}
}

task descente1(aaa) {
	wait(60);
	let angleT = ObjMove_GetAngle(aaa);
	while(angleT > 90+rand(-15,15)) {
	angleT -= 2;
	ObjMove_SetAngle(aaa, angleT);
	wait(1);
	}
}

task descente2(aaa) {
	wait(60);
	let angleT = ObjMove_GetAngle(aaa);
	while(angleT < 450+rand(-15,15)) {
	angleT += 2;
	ObjMove_SetAngle(aaa, angleT);
	wait(1);
	}
}

task TFinalizeEnnemy1(EnnemyObj) {
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {yield;}
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) != -20000) {
	CreateItemA1(ITEM_POWER_S, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 100);
	play(17, 20);
	}
    Obj_Delete(EnnemyObj);
}

task TFinalizeEnnemy2(EnnemyObj) {
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {yield;}
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) != -20000) {
	CreateItemA1(ITEM_POINT_S, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 100);
	play(17, 20);
	}
    Obj_Delete(EnnemyObj);
}

task TFinalizeEnnemy3(EnnemyObj) {
	while(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) > 0) {yield;}
	if(ObjEnemy_GetInfo(EnnemyObj, INFO_LIFE) != -20000) {
	//cercle explosion cristaux
	let dir = angleToPlayer(ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj));
		loop(16) {
		CreateShotA1(ObjMove_GetX(EnnemyObj),ObjMove_GetY(EnnemyObj), 1.5, dir, 596, 0);
		dir += 360/16;
		}
	CreateItemA1(ITEM_POWER_S, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj)+20, 100);
	CreateItemA1(ITEM_POWER_S, ObjMove_GetX(EnnemyObj)+20, ObjMove_GetY(EnnemyObj)-10, 100);
	CreateItemA1(ITEM_POWER_S, ObjMove_GetX(EnnemyObj)-20, ObjMove_GetY(EnnemyObj)-10, 100);
	CreateItemA1(ITEM_POWER, ObjMove_GetX(EnnemyObj), ObjMove_GetY(EnnemyObj), 100);
	play(17, 30);
	}
    Obj_Delete(EnnemyObj);
}