Advertisement
Guest User

Exploding_Problem

a guest
Apr 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.23 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["Script #3"]
  4. #Text["Exploding Ring Random"]
  5. #BGM["./BLD.mp3"]
  6.  
  7. #include "script/AllStarShot/AllStarShot_Const_Andi.txt"
  8.  
  9. let objBoss;
  10. let objScene = GetEnemyBossSceneObjectID();
  11.  
  12. @Event{
  13.     alternative(GetEventType())
  14.     case(EV_REQUEST_LIFE){
  15.         SetScriptResult(3500);
  16.     }
  17.     case(EV_REQUEST_TIMER){
  18.         SetScriptResult(60);
  19.     }
  20.     case(EV_REQUEST_SPELL_SCORE){
  21.         SetScriptResult(1000000);
  22.     }
  23. }
  24.  
  25. @Initialize{
  26.     objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS); 
  27.     ObjEnemy_Regist(objBoss);      
  28.     ObjMove_SetDestAtFrame(objBoss, GetCenterX, 120, 60);      
  29.     ObjEnemyBossScene_StartSpell(objScene);
  30.     TDrawLoop;  // Defined OUTSIDE
  31.     TFinalize;
  32.     MainTask;
  33. }
  34.  
  35. @MainLoop{
  36.     ObjEnemy_SetIntersectionCircleToShot(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 32);
  37.     ObjEnemy_SetIntersectionCircleToPlayer(objBoss, ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 24);
  38.     yield;
  39. }
  40.  
  41. task MainTask{
  42.     wait(60);
  43.     movement;
  44.     fireA;
  45. }
  46.  
  47. task fireA{
  48.     while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
  49.         let angle = rand(0, 360);
  50.         let obj = CreateShotA1(ObjMove_GetX(objBoss), ObjMove_GetY(objBoss), 2.5, angle, 99, 5);   
  51.         Explode(obj);  
  52.         yield;
  53.     }
  54. }
  55.  
  56. task Explode(obj){
  57.     wait(45);
  58.     ObjMove_SetSpeed(obj, rand_int(0, 30));
  59.     let speed = ObjMove_GetSpeed(obj);
  60.     if(speed > 1){
  61.         ObjMove_SetSpeed(obj, 2.5); // Set speed back to normal if obj's speed > 1
  62.     }
  63.     else{   // Execute if obj's speed < 1. Probability: 3.33%.
  64.         let angle = rand(0, 360);
  65.         ObjMove_SetSpeed(obj, 0);
  66.         ObjMove_AddPatternA3(obj, 0, NO_CHANGE, NO_CHANGE, 0, 0, 2.5, 103); // Change graphic if the object's going to explode
  67.         wait(100);
  68.         loop(8){
  69.             let obj2 = CreateShotA1(ObjMove_GetX(obj), ObjMove_GetY(obj), 2, angle, 3, 15); // Create ring of bullet (Exploding effect)
  70.             angle += 360/8;
  71.             ObjMove_AddPatternA1(obj2, 60, 2.7, rand(80, 100)); // Redirect the bullet
  72.         }
  73.         Obj_Delete(obj);    // Delete the original object
  74.     }
  75. }
  76.  
  77. task movement{
  78.     while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){
  79.         ObjMove_SetDestAtFrame(objBoss, rand(GetCenterX + 90, GetCenterX - 90), rand(GetCenterY - 60, GetCenterY - 120), 60);
  80.         wait(60);
  81.     }  
  82. }
  83.  
  84. task TDrawLoop{
  85.     let imgBoss = GetCurrentScriptDirectory() ~ "texture/cirno.png";    // Declare variable imgBoss
  86.     ObjPrim_SetTexture(objBoss, imgBoss);       // Set Enemy's image as imgBoss  
  87.     ObjSprite2D_SetSourceRect(objBoss, 64, 1, 127, 64);    // Set Enemy's sprite
  88.     ObjSprite2D_SetDestCenter(objBoss);    // Center the sprite with the Enemy
  89. }
  90.  
  91. task TFinalize{
  92.     while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
  93.     if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
  94.         + ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
  95.         AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
  96.     }
  97.     Obj_Delete(objBoss);
  98.     DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
  99.     SetAutoDeleteObject(true);
  100.     CloseScript(GetOwnScriptID());
  101.     return;
  102. }
  103.  
  104. function GetCenterX(){
  105.     return GetStgFrameWidth() / 2;
  106. }
  107.  
  108. function GetCenterY(){
  109.     return GetStgFrameHeight() / 2;
  110. }
  111.  
  112. function wait(n){
  113.     loop(n){yield;}
  114. }
  115.  
  116. function rand_int(min, max){
  117.     return truncate(rand(min, max + 1));
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement