Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #TouhouDanmakufu
- #Title[Magic "Phantasmal Vortex"]
- #Text[Owner - Hijiri Byakuren
- Difficulty - Phantasm
- Comments - It looks like a hard spell, but its actually pretty simple.]
- #Player[FREE]
- #ScriptVersion[2]
- script_enemy_main{
- #include_function ".\AnimationLib.dnh";
- let CSD=GetCurrentScriptDirectory;
- let imgBoss=CSD~"system\Byakuren.png";
- let imgCut=CSD~"system\ByakurenCut.png";
- let rotate=0;
- let angle=0;
- @Initialize {
- LoadUserShotData(CSD~"system\supershot.txt");
- LoadGraphic(imgBoss);
- LoadGraphic(imgCut);
- CutIn(YOUMU,"Magic "\""Phantasmal Vortex"\",imgCut,0,0,359,512);
- SetTimer(60);
- SetLife(1000);
- SetDamageRate(10,0);
- SetInvincibility(480);
- SetScore(2340000);
- SetEnemyMarker(true);
- MagicCircle(true);
- SetMovePosition03(GetCenterX,GetCenterY,10,5);
- animInit;
- mainTask;
- }
- @MainLoop {
- // SetPlayerInvincibility(1);
- SetCollisionA(GetX,GetY,32);
- SetCollisionB(GetX,GetY,16);
- rotate++;
- yield;
- }
- @DrawLoop {
- DrawAnimatedSprite("Byakuren",GetX,GetY);
- }
- @BackGround {
- }
- @Finalize {
- DeleteGraphic(imgBoss);
- DeleteGraphic(imgCut);
- }
- //Functions
- function wait(w){
- loop(w){yield;}
- }
- //Tasks and Subs
- sub animInit {
- //Idle Animation
- CreateAnimation("Byakuren","Idle",4);
- SetAnimationFrame("Byakuren","Idle",0,imgBoss,5,0,0,96,128);
- SetAnimationFrame("Byakuren","Idle",1,imgBoss,5,96,0,192,128);
- SetAnimationFrame("Byakuren","Idle",2,imgBoss,5,192,0,288,128);
- SetAnimationFrame("Byakuren","Idle",3,imgBoss,5,288,0,384,128);
- //Moving Left Animation
- CreateAnimation("Byakuren","MoveLeft",4);
- SetAnimationFrame("Byakuren","MoveLeft",0,imgBoss,5,0,256,96,384);
- SetAnimationFrame("Byakuren","MoveLeft",1,imgBoss,5,96,256,192,384);
- SetAnimationFrame("Byakuren","MoveLeft",2,imgBoss,5,192,256,288,384);
- SetAnimationFrame("Byakuren","MoveLeft",3,imgBoss,5,288,256,384,384);
- //Stopping Left Animation
- CreateAnimation("Byakuren","StopLeft",3);
- SetAnimationFrame("Byakuren","StopLeft",0,imgBoss,5,288,256,384,384);
- SetAnimationFrame("Byakuren","StopLeft",1,imgBoss,5,192,256,288,384);
- SetAnimationFrame("Byakuren","StopLeft",2,imgBoss,5,96,256,192,384);
- //Moving Right Animation
- CreateAnimation("Byakuren","MoveRight",4);
- SetAnimationFrame("Byakuren","MoveRight",0,imgBoss,5,0,128,96,256);
- SetAnimationFrame("Byakuren","MoveRight",1,imgBoss,5,96,128,192,256);
- SetAnimationFrame("Byakuren","MoveRight",2,imgBoss,5,192,128,288,256);
- SetAnimationFrame("Byakuren","MoveRight",3,imgBoss,5,288,128,384,256);
- //Stopping Right Animation
- CreateAnimation("Byakuren","StopRight",3);
- SetAnimationFrame("Byakuren","StopRight",0,imgBoss,5,288,128,384,256);
- SetAnimationFrame("Byakuren","StopRight",1,imgBoss,5,192,128,288,256);
- SetAnimationFrame("Byakuren","StopRight",2,imgBoss,5,96,128,192,256);
- //Begin Idling
- Animate("Byakuren","Idle",true);
- }
- task BossMoveAnim(direction){
- if(direction=="left"){
- Animate("Byakuren","MoveLeft",false);
- yield;
- while(GetSpeed>0.1){yield;}
- Animate("Byakuren","StopLeft",false);
- }
- if(direction=="right"){
- Animate("Byakuren","MoveRight",false);
- yield;
- while(GetSpeed>0.1){yield;}
- Animate("Byakuren","StopRight",false);
- }
- wait(15);
- Animate("Byakuren","Idle",true);
- }
- task mainTask {
- wait(120);
- Danmaku1;
- while(GetTimer>45 && GetLife>800){yield;}
- Danmaku2;
- while(GetTimer>35 && GetLife>600){yield;}
- Danmaku3;
- while(GetTimer>25 && GetLife>450){yield;}
- Danmaku4;
- }
- //The TeleportDanmaku task WORKS here
- task Danmaku1 {
- let direction=rand_int(0,72)*5;
- while(GetLife>0 && GetTimer>0){
- TeleportDanmaku(GetX,GetY,0.5,direction,97,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+90,97,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+180,97,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+270,97,10,5);
- direction+=20;
- wait(12);}
- }
- task Danmaku2 {
- let direction=rand_int(0,72)*5;
- while(GetLife>0 && GetTimer>0){
- loop(5){
- TeleportDanmaku(GetX,GetY,0.5,direction,99,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+90,99,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+180,99,10,5);
- TeleportDanmaku(GetX,GetY,0.5,direction+270,99,10,5);
- direction-=20;
- wait(12);}
- direction-=40;
- wait(60);}
- }
- task Danmaku3 {
- let direction1=rand_int(0,72)*5;
- let direction2=direction1+180;
- while(GetLife>0 && GetTimer>0){
- TeleportDanmaku(GetX,GetY,0.7,direction1,101,10,5);
- TeleportDanmaku(GetX,GetY,0.7,direction1+90,101,10,5);
- TeleportDanmaku(GetX,GetY,0.7,direction2,101,10,5);
- TeleportDanmaku(GetX,GetY,0.7,direction2+90,101,10,5);
- direction1+=20;
- direction2-=20;
- wait(12);}
- }
- task Danmaku4 {
- let random=0;
- while(GetLife>0 && GetTimer>0){
- random+=rand(-360,360);
- TeleportDanmaku(GetX,GetY,0.3,random,107,10,5);
- wait(6);}
- }
- //But if I put it here, for example, an error occurs
- task TeleportDanmaku(x,y,v,dir,graphic,delay,tcount){
- let obj=Obj_Create(OBJ_SHOT);
- Obj_SetPosition(obj,x,y);
- Obj_SetSpeed(obj,v);
- Obj_SetAngle(obj,dir);
- ObjShot_SetGraphic(obj,graphic);
- ObjShot_SetDelay(obj,delay);
- if(tcount==5){
- wait(40/v);
- angle=Obj_GetAngle(obj)+180;
- dir=atan2(90*sin(angle-rotate),90*cos(angle-rotate))+180;
- Obj_Delete(obj);
- TeleportDanmaku(GetCenterX+90*cos(angle-rotate),GetCenterY+90*sin(angle-rotate),v,dir,graphic,delay,tcount-1);}
- if(tcount==4){
- wait(50/v);
- angle=Obj_GetAngle(obj)+180;
- dir=atan2(90*sin(angle-rotate),90*cos(angle-rotate));
- Obj_Delete(obj);
- TeleportDanmaku(GetCenterX+90*cos(angle-rotate),GetCenterY+90*sin(angle-rotate),v,dir,graphic,delay,tcount-1);}
- if(tcount==3){
- wait(90/v);
- angle=Obj_GetAngle(obj)+180;
- dir=atan2(180*sin(angle+rotate),180*cos(angle+rotate))+180;
- Obj_Delete(obj);
- TeleportDanmaku(GetCenterX+180*cos(angle+rotate),GetCenterY+180*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
- if(tcount==2){
- wait(90/v);
- angle=Obj_GetAngle(obj)+180;
- dir=atan2(40*sin(angle+rotate),40*cos(angle+rotate));
- Obj_Delete(obj);
- TeleportDanmaku(GetCenterX+40*cos(angle+rotate),GetCenterY+40*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
- if(tcount==1){
- wait(50/v);
- angle=Obj_GetAngle(obj)+180;
- dir=atan2(180*sin(angle+rotate),180*cos(angle+rotate));
- Obj_Delete(obj);
- TeleportDanmaku(GetCenterX+180*cos(angle+rotate),GetCenterY+180*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment