SHARE
TWEET

Untitled

a guest Dec 13th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Initialize {
  2.     renderStage;
  3.     scrollStage;
  4.    
  5.  
  6.    SetAutoDeleteObject(true); //automatically deletes object when THIS script ends
  7.  
  8.         bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  9.         ObjEnemy_Regist(bossObj);
  10.  
  11.         ObjMove_SetPosition(bossObj,182,200); //warps the boss
  12.  
  13.         ObjMove_SetDestAtSpeed(bossObj,180,120,10); //movement function
  14.  
  15.  
  16.    
  17.               LoadSound (spellcardSFX);
  18.         LoadSound(bossdeathSFX);
  19.      PlaySE(spellcardSFX);
  20.      LoadSound(shootSFX);
  21.  
  22.      mainTask;
  23.  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. @MainLoop {
  30.      bossX = ObjMove_GetX(bossObj);
  31.      bossY = ObjMove_GetY(bossObj);
  32.      
  33. //enemy collision
  34.     ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
  35.     ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
  36.    
  37.        if(count == 0){
  38.             CreateOrb2(1, 64);
  39.             CreateOrb2(-1, 64);
  40.         }
  41.         count++;
  42.  
  43.     yield;
  44. }
  45.  
  46.  
  47.  
  48. task CreateOrb2(dir, dist) {
  49.         wait(100);
  50.         let objcount = 0; //counter to control firing of bullets and movement
  51.         //obtain object ID
  52.     let graphic = GetCurrentScriptDirectory() ~ "sprite/familiar.png"; //Define path
  53.     let obj = ObjPrim_Create(OBJ_SPRITE_2D);
  54.     ObjPrim_SetTexture(obj, graphic);
  55.     ObjSprite2D_SetSourceRect(obj, 0, 0, 60, 53); //use whatever dimensions necessary
  56.     ObjSprite2D_SetDestCenter(obj);
  57.     //----
  58.    
  59.     //ObjRender_SetBlendType(obj, BLEND_ALPHA);
  60.         while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) { //linked to the parent enemy's life
  61.             ObjRender_SetPosition(obj, ObjMove_GetX(bossObj) + dir * dist,
  62.                                        ObjMove_GetY(bossObj), 1);
  63.             if (objcount % 20 == 0) { //control firing rate
  64.                 let curx = ObjRender_GetX(obj);
  65.                 let cury = ObjRender_GetY(obj);
  66.         ascent(i in 0..36) {
  67.                     CreateShotA1(curx, cury, 2 + 2*sin(i * 8), 90 + 60*sin(i * 3) + objcount * 4 * dir, DS_RICE_S_RED, 0);
  68.                     CreateShotA1(curx, cury, 2 + 2*sin(i * 8), 90 - 60*sin(i * 3) + objcount * 4 * dir, DS_RICE_S_RED, 0);
  69.         }
  70.        
  71.             }
  72.             objcount++;
  73.             yield;
  74.         }
  75.         Obj_Delete(obj);
  76.     }
  77.  
  78. task mainTask {
  79.     renderBoss;
  80.     renderBG;
  81.     movement;
  82.         TEnd;
  83. }
  84.  
  85. task movement {
  86.    
  87.     loop {
  88.         wait(60);
  89.        
  90.    
  91.     }
  92. }
  93.  
  94. @Event {
  95. //boss health and timer
  96.        alternative(GetEventType())
  97.        case(EV_REQUEST_LIFE) {
  98.           SetScriptResult(1800);
  99.        }
  100.        case(EV_REQUEST_TIMER) {
  101.           SetScriptResult(70);
  102.      }
  103.  
  104. }
  105.  
  106. @Finalize {
  107.  
  108. }
  109.  
  110.  
  111.  
  112.  
  113. function wait(w) { loop(w) { yield; } }
  114.  
  115.  
  116. task renderBoss {
  117.     let dir;
  118.         let speed;
  119.  
  120.         //texture the boss and set the center
  121.         ObjPrim_SetTexture(bossObj,imgBoss);
  122.         ObjSprite2D_SetSourceRect(bossObj,0,0,77,100);
  123.         ObjSprite2D_SetDestCenter(bossObj);
  124.         ObjRender_SetScaleXYZ(bossObj,0.6,0.6,0);
  125.    
  126.     while(!Obj_IsDeleted(bossObj)) {
  127.         //when the boss is NOT deleted
  128.  
  129.        
  130.         dir = ObjMove_GetAngle(bossObj);
  131.         speed = ObjMove_GetSpeed(bossObj);
  132.        
  133.  //animation handling
  134.         if(speed == 0){
  135.             ObjRender_SetAngleXYZ(bossObj,0,0,0);
  136.             if(animFrame < 10) { ObjSprite2D_SetSourceRect(bossObj,12,0,65,68); }
  137.             if(animFrame >= 20 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,68,0,115,68); }
  138.             if(animFrame >= 30 && animFrame < 40) { ObjSprite2D_SetSourceRect(bossObj,115,0,160,68); }
  139.             if(animFrame >= 50) { ObjSprite2D_SetSourceRect(bossObj,160,0,212,68); }
  140.  
  141.            
  142.             animFrame2 = 0;
  143.         }
  144.         else if(cos(dir) < 0){
  145.             ObjRender_SetAngleXYZ(bossObj,0,0,0);   // flip vertical
  146.             if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,210,0,263,68); }
  147.             if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,259,0,313,68); }
  148.             if(animFrame2 >= 30 && animFrame2 < 40){ ObjSprite2D_SetSourceRect(bossObj,210,0,263,68); }
  149.             if(animFrame2 >= 40) { ObjSprite2D_SetSourceRect(bossObj,259,0,313,68); }
  150.            
  151.         }
  152.         else if(cos(dir) > 0){
  153.             ObjRender_SetAngleXYZ(bossObj,0,180,0); // flip vertical
  154.             if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,210,0,263,68); }
  155.             if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,259,0,313,68); }
  156.             if(animFrame2 >= 30 && animFrame2 < 40){ ObjSprite2D_SetSourceRect(bossObj,210,0,263,68); }
  157.             if(animFrame2 >= 40) { ObjSprite2D_SetSourceRect(bossObj,259,0,313,68); }
  158.         }
  159.         animFrame++;        // count animFrame. (++ is +1)
  160.         animFrame2+=2;      // count animFrame2.
  161.         if(animFrame > 60) { animFrame = 0; }   // reset animFrame when it is higher than 60.
  162.         yield;
  163.     }
  164. }
  165.  
  166.  
  167. function angleToPlayer {
  168.     let dir = atan2(GetPlayerY-bossY,GetPlayerX-bossX);
  169.     return dir;
  170. }
  171. task fire {
  172.  
  173.    let angleT = angleToPlayer;
  174.    
  175.     loop(13){
  176.    
  177.        
  178.         }
  179.     }
  180.  
  181.  
  182. task SnakePattern(obj, angleT){
  183.     let wvel = 1;
  184.     ascent(i in 0..12){
  185.         ObjMove_AddPatternA2(obj, i * 30, ObjMove_GetSpeed(obj), angleT, 0.01, wvel, 3);
  186.         wvel *= -1;
  187.     }
  188. }
  189.  
  190. task TDrawLoop {
  191.     let imgBoss = GetCurrentScriptDirectory() ~ "sprite/testsheet.png";
  192.     ObjPrim_SetTexture(bossObj, imgBoss);
  193.     ObjSprite2D_SetSourceRect(bossObj, 64, 1, 127, 64);
  194.     ObjSprite2D_SetDestCenter(bossObj);
  195. }
  196. task TDrawLoopFamiliar(obj){
  197.   let objFami = ObjPrim_Create(OBJ_SPRITE_2D);
  198.   // things for getting it set up (SetTexture, SetRenderPriority, etc)
  199.   let familiar = GetCurrentScriptDirectory() ~ "sprite/familiar.png";
  200.    ObjPrim_SetTexture(objFami, familiar);
  201.  
  202.     ObjSprite2D_SetSourceRect(bossObj, 64, 1, 127, 64);
  203.     ObjSprite2D_SetDestCenter(bossObj);
  204.   let animFrame = 0;
  205.   let interval = 5;
  206.   let x = 64;
  207.   let y = 64;
  208.  
  209.   while(!Obj_IsDeleted(obj)){
  210.     // Set the position of the sprite to the position of the object you want to have a texture.
  211.     ObjRender_SetPosition(objFami, ObjMove_GetX(obj), ObjMove_GetY(obj), 0);
  212.  
  213.     if(animFrame < 15){
  214.       ObjSprite2D_SetSourceRect(objFami, 0, 0, 60, 53);
  215.     }
  216.     if(animFrame >= 20 && animFrame < 25){
  217.       ObjSprite2D_SetSourceRect(objFami, 60, 0, 120, 53);
  218.     }
  219.     if(animFrame >= 25  && animFrame < 30){
  220.       ObjSprite2D_SetSourceRect(objFami, 120, 0, 180, 53);
  221.     }
  222.     if(animFrame >= 30){
  223.       ObjSprite2D_SetSourceRect(objFami, 180, 0, 240, 53);
  224.     }
  225.     if(animFrame > 35){
  226.       // Loop back to the start after 4 frames of animation
  227.       animFrame = 0;
  228.     }
  229.     animFrame ++;
  230.     yield;
  231.   }
  232.  
  233. }
  234.  
  235.  
  236. task TEnd
  237. {
  238.     while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
  239.         yield;
  240.     }
  241.        
  242.     Obj_Delete(bossObj);
  243.     DeleteShotAll(TYPE_ALL, TYPE_ITEM);
  244.     wait(20);  
  245.     CloseScript(GetOwnScriptID());
  246.  
  247. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top