Advertisement
BananaCupcake

.

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