Advertisement
Alrysc

Danmakufu Help

Jul 4th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.18 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["Project"]
  4. #Text["Let's try this out"]
  5.  
  6. let bossObj;
  7. let bossX = 0;
  8. let bossY = 0;
  9. let count = 0;
  10. let count2 = 0;
  11. let animFrame = 0;
  12. let animFrame2 = 0;
  13.  
  14. let imgBoss = GetCurrentScriptDirectory ~ "texture/cirno.png";
  15. let background = GetCurrentScriptDirectory ~ "texture/background.png";
  16. let overlay = GetCurrentScriptDirectory ~ "texture/blizzard.png";
  17.  
  18. let spellcardSFX = GetCurrentScriptDirectory ~ "sfx/spellcard.wav";
  19. let bossdeathSFX = GetCurrentScriptDirectory ~ "sfx/death.wav";
  20.  
  21. #include "script/default_system/Default_Shotconst.txt"
  22. #include "script/default_system/Default_Effect.txt"
  23.  
  24. @Initialize {
  25.  
  26. // automatically deletes objects when this script ends
  27. SetAutoDeleteObject(true);
  28.  
  29. bossObj = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  30. ObjEnemy_Regist(bossObj);
  31.  
  32. // warp boss when loaded
  33. ObjMove_SetPosition(bossObj,192,-100);
  34.  
  35. // move boss to certain place at certain speed
  36. ObjMove_SetDestAtSpeed(bossObj,192,120,8);
  37.  
  38. // Loads the sounds
  39. LoadSound(spellcardSFX);
  40. LoadSound(bossdeathSFX);
  41.  
  42. // Plays sound effect as attack starts up
  43. PlaySE(spellcardSFX);
  44.  
  45. mainTask;
  46. }
  47.  
  48. @Event {
  49. // Life and time
  50. alternative(GetEventType())
  51. case(EV_REQUEST_LIFE) {
  52. SetScriptResult(1500);
  53. }
  54. case(EV_REQUEST_TIMER) {
  55. SetScriptResult(60);
  56. }
  57. }
  58.  
  59. @MainLoop {
  60. bossX = ObjMove_GetX(bossObj);
  61. bossY = ObjMove_GetY(bossObj);
  62.  
  63. // Collision for shots and player 24 is boss hitbox 32 is boss collision box
  64. ObjEnemy_SetIntersectionCircleToShot(bossObj,bossX,bossY,24);
  65. ObjEnemy_SetIntersectionCircleToPlayer(bossObj,bossX,bossY,32);
  66. yield;
  67. }
  68.  
  69. @Finalize {
  70.  
  71. }
  72.  
  73. function wait(w) {
  74. loop(w) {
  75. yield;
  76. }
  77. }
  78.  
  79. function angleToPlayer {
  80. let dir = GetAngleToPlayer(bossObj);
  81. return dir;
  82. }
  83.  
  84. task mainTask {
  85. renderBoss;
  86. renderBG;
  87. movement;
  88. TEnd;
  89. }
  90.  
  91. task renderBG {
  92.  
  93. let scrollTex = 0;
  94.  
  95. // background, priority is roman 1, so I
  96. let obj = ObjPrim_Create(OBJ_SPRITE_2D);
  97. Obj_SetRenderPriorityI(obj,20);
  98. ObjPrim_SetTexture(obj,background);
  99. ObjSprite2D_SetSourceRect(obj,0,0,384,210);
  100. ObjSprite2D_SetDestRect(obj,0,0,GetStgFrameWidth,GetStgFrameHeight);
  101.  
  102. // spell card overlay texture
  103. let overlayObj = ObjPrim_Create(OBJ_SPRITE_2D);
  104. Obj_SetRenderPriorityI(overlayObj,21);
  105. ObjPrim_SetTexture(overlayObj,overlay);
  106. ObjRender_SetBlendType(overlayObj,BLEND_ADD_ARGB); // blend type ADDITIVE with alpha ability and RGB color
  107. ObjRender_SetAlpha(overlayObj,200); // set Alpha value to make it transparent, 0-250, most visible at 250
  108. ObjSprite2D_SetSourceRect(overlayObj,0,0,256,256);
  109. ObjSprite2D_SetDestRect(overlayObj,0,0,GetStgFrameWidth,GetStgFrameHeight);
  110.  
  111. // as long as boss is alive, scroll overlay from top left to bottom right
  112. while(!Obj_IsDeleted(bossObj)) {
  113. ObjSprite2D_SetSourceRect(overlayObj,0-scrollTex,0-scrollTex,256-scrollTex,256-scrollTex);
  114. scrollTex += 2;
  115. yield;
  116. }
  117. Obj_Delete(overlayObj);
  118. }
  119.  
  120. task renderBoss {
  121. let dir;
  122. let speed;
  123.  
  124. ObjPrim_SetTexture(bossObj,imgBoss);
  125. ObjSprite2D_SetSourceRect(bossObj,0,0,64,64);
  126. ObjSprite2D_SetDestCenter(bossObj);
  127. ObjRender_SetScaleXYZ(bossObj,1.0,1.0,0);
  128.  
  129. while(!Obj_IsDeleted(bossObj)) {
  130.  
  131. dir = ObjMove_GetAngle(bossObj);
  132. speed = ObjMove_GetSpeed(bossObj);
  133.  
  134. // animation handling
  135. if(speed == 0) {
  136. // the 64 in the second line says when the last picture ends, 128 is where the next starts
  137. // first value is left side of picture, third is right side, second is top side, fourth is bottom side
  138. ObjRender_SetAngleXYZ(bossObj,0,0,0);
  139. if(animFrame < 15) { ObjSprite2D_SetSourceRect(bossObj,0,0,64,64); }
  140. if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(bossObj,64,0,128,64); }
  141. if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(bossObj,128,0,192,64); }
  142. if(animFrame >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,0,256,64); }
  143. animFrame2 = 0;
  144. // boss idle
  145. }
  146. else if(cos(dir) < 0) {
  147. ObjRender_SetAngleXYZ(bossObj,0,180,0); // 180 flips sprite around
  148. if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,64,64,128); }
  149. if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,64,128,128); }
  150. if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,64,192,128); }
  151. if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,64,256,128); }
  152. // boss moving right
  153. }
  154. else if(cos(dir) > 0) {
  155. ObjRender_SetAngleXYZ(bossObj,0,180,0); // 180 flips sprite around
  156. if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(bossObj,0,128,64,192); }
  157. if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(bossObj,64,128,128,192); }
  158. if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(bossObj,128,128,192,192); }
  159. if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(bossObj,192,128,256,192); }
  160. // boss moving to right, 180 mirrors image
  161. }
  162. animFrame++; // count animFrame (++ makes value go up each frame, -- goes down each frame) you can also do things like +=2 to make it go up by 2 every frame
  163. animFrame2++; // count animFrame2
  164. if(animFrame > 60) { animFrame = 0; } // makes frame count reset after reaching 60
  165. yield;
  166. }
  167.  
  168. }
  169.  
  170.  
  171. task movement {
  172. wait(60);
  173. while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
  174. fire;
  175. wait(25);
  176. if(count >= 60) { shoot; }
  177.  
  178. count++;
  179. yield;
  180. }
  181. }
  182.  
  183. task fire {
  184. loop(20) {
  185. CreateShotA1(bossX,bossY,2,count2+90,14,0);
  186. wait(3);
  187.  
  188. count2++;
  189. if(count >=360) { count = 0; }
  190. }
  191. }
  192.  
  193. task shoot {
  194. loop(20) {
  195. CreateShotA1(bossX,bossY,1,count2-180,10,0);
  196. CreateShotA1(bossX,bossY,3,count2,20,0);
  197. wait(20); // try 20 or 3
  198.  
  199. count2+=10;
  200. if(count >=360) { count = 0; }
  201. }
  202. }
  203.  
  204. task TEnd {
  205. // as long as boss HP is above 0, this part is ignored
  206. while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0) {
  207. wait(20);
  208. }
  209. // plays sound before boss explodes, in this case
  210. PlaySE(bossdeathSFX);
  211. // the last two numbers are the opacity of explosion and speed of explosion, respectively
  212. TExplosionA(bossX,bossY,10,0.5);
  213. Obj_Delete(bossObj);
  214. DeleteShotAll(TYPE_ALL, TYPE_ITEM); // turns remaining bullets on screen into points
  215. wait(120);
  216. CloseScript(GetOwnScriptID);
  217. }
  218.  
  219. Pictures: http://imgur.com/a/TnLqg
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement