codingOL

[wip] first dnf script

Sep 30th, 2013
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #東方弾幕風[Single]
  2. #ScriptVersion[3]
  3. #Title["テスト「ダークネス」"]
  4. #Text["azakacrossのはじめのスペカー"]
  5.  
  6. // include files
  7. #include"script/default_system/Default_ShotConst.txt"
  8. #include"script/default_system/Default_Effect.txt"
  9.  
  10. // globs
  11. let objEnemy;
  12. let inMotion = false;
  13. let stgX = GetStgFrameWidth() / 2; // Obtains the X coordinate of the center of the stage
  14.  
  15. @Initialize
  16. {
  17.     objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS); // generates boss obj
  18.     ObjEnemy_Regist(objEnemy); // Sets objEnemy to active
  19.     ObjEnemy_SetDamageRate(objEnemy, 50, 75); // 50% dmg from bullets, 75% dmg from bomb
  20.    
  21.     // Load important tasks here
  22.     // Tasks are "microthreads" which perform independently of one another
  23.     // Using the yield; command in a task suspends it, when placed in loop(n) { }
  24.     // It will suspend for n frames.
  25.    
  26.     TWork;
  27.     TEnemDraw;
  28.     TFinish;
  29.    
  30. }
  31.  
  32. @MainLoop
  33. {
  34.     let enemyX = ObjMove_GetX(objEnemy);
  35.     let enemyY = ObjMove_GetY(objEnemy);
  36.    
  37.     // Enemy collision to bullets
  38.     ObjEnemy_SetIntersectionCircleToShot(objEnemy, enemyX, enemyY, 32);
  39.    
  40.     // Enemy collision to player chara
  41.     ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, enemyX, enemyY, 24);
  42.    
  43.     yield; // Allows all tasks to perform their job before repeating @MainLoop
  44. }
  45.  
  46. @Event
  47. {
  48.     alternative(GetEventType())
  49.     case(EV_REQUEST_LIFE)
  50.     {
  51.         SetScriptResult(250) // Set eHP to 500
  52.     }
  53.     case(EV_REQUEST_TIMER)
  54.     {
  55.         SetScriptResult(120) // Set timer to 120s
  56.     }
  57.     case(EV_REQUEST_SPELL_SCORE)
  58.     {
  59.         SetScriptResult(50000) // Set score get to 50k
  60.     }
  61. }
  62.  
  63. /*******
  64. * Tasks
  65. ********/
  66.  
  67. // Power task, performing the bulk
  68.  
  69. task TWork
  70. {
  71.     /*******
  72.     * Parameters:
  73.     * real: object id ,
  74.     * real: X-coordinate (in this example, X coord of the center) ,
  75.     * real: Y-coordinate (in this example, 60 pixels below (stgX,0)) ,
  76.     * real: the frame the object should be placed in (stgX, 60)
  77.     ********/
  78.     ObjMove_SetDestAtFrame(objEnemy, stgX, 60, 60);
  79.    
  80.     loop(60) { yield; } // Suspend this task for 60 frames or 1 second
  81.    
  82.     // Performs spell card activation
  83.     let objScene = GetEnemyBossSceneObjectID();
  84.     ObjEnemyBossScene_StartSpell(objScene);
  85.    
  86.     // Perform this while the enemy isn't dead yet
  87.     while(!Obj_IsDeleted(objEnemy))
  88.     {
  89.         loop(90) { yield; }
  90.         TShotBallA(135);
  91.         TShotBallA(90);
  92.         TShotBallA(45);
  93.     }
  94. }
  95.  
  96. // Drawing task
  97.  
  98. task TEnemDraw
  99. {
  100.     let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia.png";
  101.     ObjPrim_SetTexture(objEnemy, imgExRumia); // Set exrumia.png as texture to objEnemy
  102.    
  103.     while(!Obj_IsDeleted(objEnemy)) // perform this while the enemy isn't dead yet
  104.     {
  105.             let angle = ObjMove_GetAngle(objEnemy);
  106.             let speed = ObjMove_GetSpeed(objEnemy);
  107.            
  108.             if(speed == 0) // Only perform this entire block if Rumia's speed was 0
  109.             {
  110.                 if(inMotion) // Perform this block if Rumia was in motion
  111.                 {
  112.                     /**************************
  113.                     * Parameters - Takes only ONE texture image:
  114.                     * real: object's id ,
  115.                     * real: lower-left point ,
  116.                     * real: upper-left point ,
  117.                     * real: upper-right point ,
  118.                     * real: lower-right point
  119.                     **************************/
  120.                     ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64);
  121.                 }
  122.                 else // Otherwise, make her appear stationary.
  123.                 {
  124.                     ObjSprite2D_SetSourceRect(objEnemy, 1, 1, 64, 64);
  125.                 }
  126.             }
  127.             // positive value = move right, so make Rumia's body go right
  128.             else if (cos(angle) > 0) { ObjSprite2D_SetSourceRect(objEnemy, 192, 1, 255, 64); }
  129.             // negative value = move left, so make Rumia's body go left
  130.             else if (cos(angle) < 0) { ObjSprite2D_SetSourceRect(objEnemy, 128, 1, 191, 64); }
  131.            
  132.             ObjSprite2D_SetDestCenter(objEnemy);
  133.            
  134.             yield; // This loop performed once per frame
  135.     }
  136. }
  137.  
  138. /******************
  139. * Bullet routines
  140. * go here
  141. ******************/
  142.  
  143. // Shoots a big ball forward which spawns smaller stars
  144. // Parameters:
  145. // angle1 - real : the angle from Rumia which the bullet is shot
  146.  
  147. task TShotBallA(angle1)
  148. {
  149.     let posX = ObjMove_GetX(objEnemy);
  150.     let posY = ObjMove_GetY(objEnemy);
  151.    
  152.     // Create bullet object
  153.     /**********************
  154.     * Parameters
  155.     * real: X coordinate of the origin
  156.     * real: Y coordinate of the origin
  157.     * real: acceleration of the object
  158.     * real: angle from the origin of the object
  159.     * real: top speed
  160.     * real: object id of the shot to generate
  161.     * real: delay time
  162.     **********************/
  163.     let bObj = CreateShotA2(posX, posY, 3, angle1, 0.05, 0, DS_BALL_L_PURPLE, 0);
  164.    
  165.     ascent(i in 0 .. 250)
  166.     {
  167.         if(Obj_IsDeleted(bObj)) { break; }
  168.         let bSpd = rand(0.3,2);
  169.         let bx = ObjMove_GetX(bObj);
  170.         let by = ObjMove_GetY(bObj);
  171.         // spawn a small star bullet as the bigger bullet travels
  172.         CreateShotA1(bx, by, bSpd, rand(0,360), DS_STAR_S_PURPLE, 45);
  173.         yield;
  174.     }
  175. }
  176.  
  177. // Post-fight processing
  178.  
  179. task TFinish
  180. {
  181.     // Suspend this task indefinitely as long as enemy is still alive
  182.     while(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0)
  183.     {
  184.         yield;
  185.     }
  186.    
  187.     let enemyX = ObjMove_GetX(objEnemy);
  188.     let enemyY = ObjMove_GetY(objEnemy);
  189.    
  190.     /******
  191.     * TExplosionA is found in "script/default_system/..."
  192.     * Parameters:
  193.     * real: X coordinate of the explosion ,
  194.     * real: Y coordinate of the explosion ,
  195.     * real: "dAlpha" - reduce the brightness of the explosion by this amount
  196.     * real: "dScale" - adjust the size of the explosion by this multiplier
  197.     ******/
  198.     TExplosionA(enemyX, enemyY, 45, 0.7);
  199.    
  200.     DeleteShotAll(TYPE_ALL, TYPE_ITEM); // Get rid of everything
  201.     Obj_Delete(objEnemy); // Delete the enemy to kill the loops
  202.    
  203.     loop(30) { yield; } // suspend this task for half a second
  204.    
  205.     // Don't forget to close the script when it ends!
  206.     CloseScript(GetOwnScriptID());
  207. }
Advertisement
Add Comment
Please, Sign In to add comment