Advertisement
BananaCupcake

Another danmakufu error

Jun 5th, 2017
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["Test 2"]
  4. #Text["Boss collision, movement and firing"]
  5.  
  6. let bossObj;
  7. let bossX = 0;
  8. let bossY = 0;
  9. let imgBoss = GetCurrentScriptDirectory ~ "shikieiki.png.png";
  10.  
  11. #include "script/default_system/Default_ShotConst.txt"
  12.  
  13. @Initialize {
  14.  
  15. // define a boss in bossObj and register it
  16. bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  17. ObjEnemy_Regist(bossObj);
  18.  
  19. // Warp the boss to this location when loaded
  20. ObjMove_SetPosition(bossObj,192,-100);
  21.  
  22. // move boss to desired x y location at desired speed
  23. ObjMove_SetDestAtSpeed(bossObj,192,120,5);
  24.  
  25. mainTask; // run mainTask
  26. }
  27.  
  28. @Event {
  29. // setting the boss timer and life
  30. alternative(GetEventType())
  31. case(EV_REQUEST_LIFE) {
  32. SetScriptResult(2000);
  33. }
  34. case(EV_REQUEST_TIMER) {
  35. SetScriptResult(45);
  36. }
  37. case(EV_REQUEST_SPELL_SCORE){
  38. SetScriptResult(1000000)
  39. }
  40.  
  41. @MainLoop {
  42. bossX = ObjMove_GetX(bossObj);
  43. bossY = ObjMove_GetY(bossObj);
  44.  
  45. // collision for the shots and player
  46. ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
  47. ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
  48.  
  49. yield;
  50. }
  51.  
  52. @Finalize {
  53. while(ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0){yield;}
  54. if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT)
  55. +ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
  56. AddScore(ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE));
  57. }
  58.  
  59. // your best friend, forever.
  60. function wait(w) { loop(w) { yield; } }
  61.  
  62. task mainTask {
  63. fire;
  64. renderBoss;
  65. movement;
  66. }
  67.  
  68. task renderBoss {
  69. let dir;
  70. let speed;
  71.  
  72. // texture the boss, set centre as true centre.
  73. ObjPrim_SetTexture(bossObj,imgBoss);
  74. ObjSprite2D_SetSourceRect(bossObj,0,0,148,125);
  75. ObjSprite2D_SetDestCenter(bossObj);
  76. ObjRender_SetScaleXYZ(bossObj,0.7,0.7,0);
  77.  
  78. while(!Obj_IsDeleted(bossObj)) {
  79.  
  80. // update boss speed and direction locally
  81. dir = ObjMove_GetAngle(bossObj);
  82. speed = ObjMove_GetSpeed(bossObj);
  83.  
  84. // if the boss is idle, show this image/rect
  85. if(speed == 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,0,0); }
  86.  
  87. // boss holding location
  88. else if(cos(dir) < 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,0,0); }
  89.  
  90. // boss moving to the left
  91. else if(cos(dir) > 0) { ObjSprite2D_SetSourceRect(bossObj,0,0,148,125); ObjRender_SetAngleXYZ(bossObj,0,180,0); }
  92.  
  93. // boss moving to the right
  94.  
  95. yield;
  96. }
  97.  
  98. }
  99.  
  100. task movement {
  101. wait(60);
  102. fire;
  103. wait(30);
  104. loop {
  105. ObjMove_SetDestAtSpeed(bossObj,100,120,5); // move to the left
  106. wait(45);
  107. fire;
  108. wait(30);
  109. ObjMove_SetDestAtSpeed(bossObj,280,120,5); // move to the right
  110. wait(45);
  111. fire;
  112. wait(30);
  113. }
  114. }
  115.  
  116. function angleToPlayer {
  117. let dir = atan2(GetPlayerY-bossY,GetPlayerX-bossX);
  118. return dir;
  119. }
  120.  
  121. task fire {
  122. while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){
  123. let angleT = GetAngleToPlayer(bossObj);
  124. loop(20){
  125. ascent(i in 0..1){
  126. CreateShotA1(ObjMove_GetX(bossObj), ObjMove_GetY(bossObj), 3 - i/3, angleT, DS_BALL_L_SKY + i, 20);
  127. }
  128. angleT += 360/ 15;
  129. }
  130. wait(60);
  131. }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement