#東方弾幕風 #Title[テストスクリプト] #Text[テストスクリプト] #ScriptVersion[2] script_enemy_main { let imgBoss = "script\img\ExRumia.png"; let frame = 0; let angleBase = 90; let Crisis1 = 1000; let Crisis2 = 900; let WaitTime = 320; @Initialize { SetX(GetCenterX); SetY(GetClipMinY + 120); SetLife(8000); SetTimer(210); SetDurableSpellCard; SetScore(50000000); LoadGraphic(imgBoss); SetTexture(imgBoss); SetGraphicRect(0, 0, 63, 63); //SetInitialBombCount(3); Concentration02(300); //wait(1200); TimeStop(60,0,0,1); //CreateShot12(GetX, GetY, 3+3*rand(-1,1), 3+3*rand(-1,1),1.2*rand(-1,1),1.2*rand(-1,1),100,100,random7color_01, 0); TSetBombResist; TNway; TNway2; TNway3; TNway4; TGomad; //TCircle; TCircle2; } @MainLoop { SetCollisionA(GetX, GetY, 24); SetCollisionB(GetX, GetY, 24); yield; } @DrawLoop { DrawGraphic(GetX, GetY); } @Finalize { DeleteGraphic(imgBoss); } task TSetBombResist { while(GetLife > Crisis1) { if (OnBomb == true){ SetDamageRate(3,10); wait(200); } else if(OnBomb == false) { SetDamageRate(100,100); } yield; } loop(WaitTime){ yield; } while(GetLife > Crisis2){ if (OnBomb == true){ loop(200){ SetDamageRate(0,0); yield; } SetDamageRate(100,100); } else if(OnBomb == false) { //SetDamageRate(100,100); } yield; } } task TNway { let angleBase1= 90; let shot_interval = 10; let colorchange_interval = 900; let shot_operationtimes = colorchange_interval/shot_interval; let waitframe = 0; yield; loop { while(GetLife > Crisis1) { loop(shot_operationtimes) { loop(shot_interval){ if (GetLife <= Crisis1){ waitframe++; } if (waitframe >= WaitTime){ break; } yield; } nway(angleBase1, 3, 10, ORANGE02, 1); angleBase1 -= 32; } loop(shot_operationtimes) { loop(shot_interval){ if (GetLife <= Crisis1){ waitframe++; } if (waitframe >= WaitTime){ break; } yield; } nway(angleBase1, 3, 10, RED02, 1); angleBase1 -= 32; } loop(shot_operationtimes) { loop(shot_interval){ if (GetLife <= Crisis1){ waitframe++; } if (waitframe >= WaitTime){ break; } yield; } nway(angleBase1, 3, 10, BLUE02, 1); angleBase1 -= 32; } } while(GetLife > Crisis2) { loop(shot_operationtimes) { wait(shot_interval); nway(angleBase1, 3, 10, ORANGE02, 1); angleBase1 -= 32; } loop(shot_operationtimes) { wait(shot_interval); nway(angleBase1, 3, 10, RED02, 1); angleBase1 -= 32; } loop(shot_operationtimes) { wait(shot_interval); nway(angleBase1, 3, 10, BLUE02, 1); angleBase1 -= 32; } } loop{yield;} } } task TNway2 { let angleBase2= 90; yield; while(GetLife > Crisis1) { wait(30); nway(angleBase2+rand_int(-10,10), 2, 2, AQUA23, 10); angleBase2 += 8; } loop(WaitTime/30){ wait(30); nway(angleBase2+rand_int(-10,10), 2, 2, AQUA23, 10);yield; angleBase2 += 8; } while(GetLife > Crisis2){ wait(30); nway(angleBase2+rand_int(-10,10), 2, 2, AQUA23, 10); angleBase2 += 8; } loop{yield;} } task TNway3 { let angleBase2= 90; let speed = 10; let angle = GetAngleToPlayer; let color = RED03; let span = 30; let slowturn = 2; yield; while(GetLife > Crisis1) { wait(4); if (GetPlayerMoveState == MOVE_SLOW) { slowturn += 1; if (slowturn >= 3) { angle += 5; slowturn = 0; } } else { slowturn = 2; } loop(5) { CreateShot01(GetX, GetY, speed, angle+rand_int(-span/2,span/2), color, 0); } } loop(WaitTime/5){ wait(4); if (GetPlayerMoveState == MOVE_SLOW) { slowturn += 1; if (slowturn >= 3) { angle += 5; slowturn = 0; } } else { slowturn = 2; } loop(5) { CreateShot01(GetX, GetY, speed, angle+rand_int(-span/2,span/2), color, 0); } yield; } while(GetLife > Crisis2) { wait(4); if (GetPlayerMoveState == MOVE_SLOW) { slowturn += 1; if (slowturn >= 3) { angle += 5; slowturn = 0; } } else { slowturn = 2; } loop(5) { CreateShot01(GetX, GetY, speed, angle+rand_int(-span/2,span/2), color, 0); } } loop{yield;} } task TNway4 { let angleBase2= 90; let speed = 10; let angle = GetAngleToPlayer; let color = BLUE03; let span = 30; yield; while(GetLife > Crisis1) { loop(5) { wait(4); loop(5) { CreateShot01(GetX, GetY, speed, angleBase2+rand_int(-span/2,span/2), color, 0); } angleBase2 -= 4; } wait(80); } loop(WaitTime/81){ loop(5) { wait(4); loop(5) { CreateShot01(GetX, GetY, speed, angleBase2+rand_int(-span/2,span/2), color, 0); } angleBase2 -= 4; } wait(80); yield; } while(GetLife > Crisis2) { loop(5) { wait(4); loop(5) { CreateShot01(GetX, GetY, speed, angleBase2+rand_int(-span/2,span/2), color, 0); } angleBase2 -= 4; } wait(80); } loop{yield;} } task TCircle { let angleBase = 90; loop(30) { yield; } loop { wait(60); circle(GetAngleToPlayer, 100, 1, WHITE01);//1行で自機狙い円弾 円を大きくしたら、radius * densityが360の整数分の1になるようにすること(radius*densityが90とか60とか45とか) } } task TCircle2 {//circle2を60フレームごとに、それぞれの弾の回転はタスクTCircleRotateで let omega = 1; let radiusBase = 100; let density = 0.7; let densityformiddlecircle = 0.8; let densityforsmallcircle = 1; let currentradius = 0;//現在の半径、0は初期値で意味なし。小さい場合、関数circle2に代入する値を変えて、密度変更。関数は、入力が一定なら常に同じ動作 let color; let formercolor=0; let colorchangetimes = 0; let colorarray = [];//[0,1,2,3,4,5,6]; //let colorexistarray = [false,false,false,false,false,false,false]; let c=0; ascent(i in 0..7) {//配列colorarrayを[0 1 2 … 5 6]で初期化 colorarray = colorarray ~ [i];//配列の結合 i++; } while(GetLife > Crisis1) { wait(60); if (length(colorarray)==0){ ascent(i in 0..6) {//配列colorarrayを[0 1 2 … 5 6]で初期化 colorarray = colorarray ~ [i];//配列の結合 i++; } } c = rand_int(0,(length(colorarray)-1)); //color=random7color_01_translate(colorarray[c]); //color=RED01; currentradius = radiusBase*sin(rand(0,179.99999999)); circle2(90, currentradius, chosendensity(currentradius,density,densityformiddlecircle,densityforsmallcircle), random7color_01_translate(colorarray[c]),omega);//1行で自機狙い回転する円弾 円を大きくしたら、radius * densityが360の整数分の1になるようにすること(radius*densityが90とか60とか45とか) colorarray = erase(colorarray,c); } loop(WaitTime/60){ wait(60); if (length(colorarray)==0){ ascent(i in 0..6) {//配列colorarrayを[0 1 2 … 5 6]で初期化 colorarray = colorarray ~ [i];//配列の結合 i++; } } c = rand_int(0,(length(colorarray)-1)); //color=random7color_01_translate(colorarray[c]); //color=RED01; currentradius = radiusBase*sin(rand(0,179.99999999)); circle2(90, currentradius, chosendensity(currentradius,density,densityformiddlecircle,densityforsmallcircle), random7color_01_translate(colorarray[c]),omega);//1行で自機狙い回転する円弾 円を大きくしたら、radius * densityが360の整数分の1になるようにすること(radius*densityが90とか60とか45とか) colorarray = erase(colorarray,c); yield; } while(GetLife > Crisis2) { wait(60); if (length(colorarray)==0){ ascent(i in 0..6) {//配列colorarrayを[0 1 2 … 5 6]で初期化 colorarray = colorarray ~ [i];//配列の結合 i++; } } c = rand_int(0,(length(colorarray)-1)); //color=random7color_01_translate(colorarray[c]); //color=RED01; currentradius = radiusBase*sin(rand(0,179.99999999)); circle2(90, currentradius, chosendensity(currentradius,density,densityformiddlecircle,densityforsmallcircle), random7color_01_translate(colorarray[c]),omega);//1行で自機狙い回転する円弾 円を大きくしたら、radius * densityが360の整数分の1になるようにすること(radius*densityが90とか60とか45とか) colorarray = erase(colorarray,c); } loop{yield;} function chosendensity(currentradius,density,densityformiddlecircle,densityforsmallcircle){//chosendensity?? イミフ if (currentradius>40){ return density; } else if(currentradius>12){ return densityformiddlecircle; } else if(currentradius>=0){ return densityforsmallcircle; } else { CreateShot12(GetX, GetY, 3+3*rand(-1,1), 3+3*rand(-1,1),1.2*rand(-1,1),1.2*rand(-1,1),100,100,color, 0); return 0; } } }//Task TCircle2 end function nway(let dir, let way, let span, let color,let speed) { let angle = dir - (way - 1) / 2 * span; loop(way) { CreateShot01(GetX, GetY, speed, angle, color, 0); angle += span; } } function circle(let dir, let radius, let density, let color) {//一応circle(GetAngleToPlayer, 10, 1, WHITE01);で動作確認済みなので、わからなくなった時のために取っておいてるだけ。 let way = radius * density; let angle = 360 / way; let getx = GetX; let gety = GetY; let x = radius * cos(dir) + getx; let y = radius * sin(dir) + gety; let currentdir = dir; loop(way) { currentdir += angle; x = getx + radius * cos(currentdir); y = gety + radius * sin(currentdir); CreateShot01(x, y, 1, dir, color, 0); angle += 0; } } task TCircleRotate(x,y,speed,dir,color,radius,omega){ //let T=2*3.1415926535897932384626433832795/360;//定数だが、あらかじめ計算して処理を早くする let T=2*3.141592/360;//定数だが、あらかじめ計算して処理を早くする let type = color; let obj = Obj_Create(OBJ_SHOT); let v=T*radius*omega;//回転する円の速さのベクトルの大きさ、進行方向とは let maxX = GetClipMaxX+200;//弾を削除しないXの最大の座標 let minX = GetClipMinX-200;//弾を削除しないXの最小の座標 let maxY = GetClipMaxY+200;//弾を削除しないYの最大の座標 let minY = GetClipMinY-200;//弾を削除しないYの最小の座標 Obj_SetX(obj, x); Obj_SetY(obj, y); Obj_SetAngle(obj, 90); //Obj_SetSpeed(obj, speed); Obj_SetSpeed(obj, 0); ObjShot_SetGraphic(obj, type); Obj_SetAutoDelete(obj, false); loop{ if(Obj_BeDeleted(obj)) { break; } //x, y, speed, dir, color, 0);//v=radius*2pai*omega/360,pi=3.1415926535897932384626433832795 dir = dir + omega; loop { if(dir > 359) {dir -= 360;} //loopしなくてもいいが、オメガにとんでもない大きな値を設定しても同じように動くように else {break;} } Obj_SetAngle(obj, dir); //Obj_SetX(obj, v*sin(dir)); //Obj_SetY(obj, v*cos(dir)+speed); //Obj_SetAngle(obj, 90); Obj_SetSpeed(obj, v); Obj_SetX(obj,Obj_GetX(obj)+speed*cos(GetAngleToPlayer)); Obj_SetY(obj,Obj_GetY(obj)+speed*sin(GetAngleToPlayer)); if ((maxX < Obj_GetX(obj))||(minX > Obj_GetX(obj))||(maxY < Obj_GetY(obj))||(minY > Obj_GetY(obj))){ Obj_Delete(obj); } yield; } } function circle2(let dir, let radius, let density, let color, let omega) {// let way = radius * density; let angle = 360 / way; let getx = GetX; let gety = GetY; let x = radius * cos(dir) + getx; let y = radius * sin(dir) + gety; let currentdir = dir; let speed = 1;//わかりやすいようにspeedも変数でspeedと名前を付けて渡す loop(way) { currentdir += angle; x = getx + radius * cos(currentdir); y = gety + radius * sin(currentdir); TCircleRotate(x,y,speed,dir,color,radius,omega);//弾の進行方向を制御するため、 angle += 0; } } // w フレームだけ待つ function wait(w) { loop(w) { yield; } } //色をランダムで選ぶ、ただしWHITEなし function random7color_01{ let color = rand_int(0,6); alternative(color) case(0) { return RED01;//aが0の時に実行される } case(1) { return GREEN01; } case(2) { return BLUE01; } case(3) { return YELLOW01; } case(4) { return PURPLE01; } case(5) { return AQUA01; } case(6) { return ORANGE01; } others { //それ以外の時実行される } } //色を言われた通り返す、ただしWHITEなし、エラーも出ない function random7color_01_translate(color){ alternative(color) case(0) { return RED01;//aが0の時に実行される } case(1) { return GREEN01; } case(2) { return BLUE01; } case(3) { return YELLOW01; } case(4) { return PURPLE01; } case(5) { return AQUA01; } case(6) { return ORANGE01; } others { //それ以外の時実行される } } //色を言われた通り返す、ただしWHITEなし、エラーも出ない function random8color_02_translate(color){ alternative(color) case(0) { return RED02;//aが0の時に実行される } case(1) { return GREEN02; } case(2) { return BLUE02; } case(3) { return YELLOW02; } case(4) { return PURPLE02; } case(5) { return AQUA02; } case(6) { return ORANGE02; } others { return WHITE02;//それ以外の時実行される } } //色を言われた通り返す、ただしWHITEなし、エラーも出ない function random8color_03_translate(color){ alternative(color) case(0) { return RED03;//aが0の時に実行される } case(1) { return GREEN03; } case(2) { return BLUE03; } case(3) { return YELLOW03; } case(4) { return PURPLE03; } case(5) { return AQUA03; } case(6) { return ORANGE03; } others { return WHITE03;//それ以外の時実行される } } task TGomad{ let itemscatter = 50;//scatterで「散り散りになる、撒き散らす」らしい。 while(GetLife > Crisis1){ yield; } Explosion01(GetX,GetY,1,5,720); SetInvincibility(10); //SetInitialBombCount(5); //SetRebirthFrame(GetRebirthFrame*3); loop(30){ SetDamageRate(20,0); yield; } CreateItem(ITEM_1UP,GetX+rand(itemscatter,-itemscatter),GetY+rand(itemscatter,-itemscatter)); CreateItem(ITEM_BOMB,GetX+rand(itemscatter,-itemscatter),GetY+rand(itemscatter,-itemscatter)); CreateItem(ITEM_BOMB,GetX+rand(itemscatter,-itemscatter),GetY+rand(itemscatter,-itemscatter)); loop(240){ SetDamageRate(50,0); yield; } Slow(3); SetInvincibility(1500); loop(50){ AddLife(25); yield; } SetDamageRate(100,0); wait(60); while(GetLife > Crisis2){ wait(3); loop(5) { nway(GetAngleToPlayer+rand(-22.5,22.5), 8, 45, RED31, rand(1,3)); } yield; } Explosion01(GetX,GetY,1,5,720); loop { loop(5) { wait(3); loop(4) { nway(GetAngleToPlayer+rand(-22.5,22.5), 8, 45, RED31, rand(1,3)); nway(GetAngleToPlayer+rand(-22.5,22.5), 8, 45, BLUE31, rand(1,3)); } } SetDamageRate(50,0); yield; } } }