Guest User

Dnh Script

a guest
Jan 7th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. #TouhouDanmakufu
  2. #Title[Magic "Phantasmal Vortex"]
  3. #Text[Owner - Hijiri Byakuren
  4. Difficulty - Phantasm
  5. Comments - It looks like a hard spell, but its actually pretty simple.]
  6. #Player[FREE]
  7. #ScriptVersion[2]
  8.  
  9. script_enemy_main{
  10.  
  11. #include_function ".\AnimationLib.dnh";
  12. let CSD=GetCurrentScriptDirectory;
  13. let imgBoss=CSD~"system\Byakuren.png";
  14. let imgCut=CSD~"system\ByakurenCut.png";
  15. let rotate=0;
  16. let angle=0;
  17.  
  18. @Initialize {
  19. LoadUserShotData(CSD~"system\supershot.txt");
  20. LoadGraphic(imgBoss);
  21. LoadGraphic(imgCut);
  22. CutIn(YOUMU,"Magic "\""Phantasmal Vortex"\",imgCut,0,0,359,512);
  23. SetTimer(60);
  24. SetLife(1000);
  25. SetDamageRate(10,0);
  26. SetInvincibility(480);
  27. SetScore(2340000);
  28. SetEnemyMarker(true);
  29. MagicCircle(true);
  30. SetMovePosition03(GetCenterX,GetCenterY,10,5);
  31. animInit;
  32. mainTask;
  33. }
  34.  
  35. @MainLoop {
  36. // SetPlayerInvincibility(1);
  37. SetCollisionA(GetX,GetY,32);
  38. SetCollisionB(GetX,GetY,16);
  39. rotate++;
  40. yield;
  41. }
  42.  
  43. @DrawLoop {
  44. DrawAnimatedSprite("Byakuren",GetX,GetY);
  45. }
  46.  
  47. @BackGround {
  48. }
  49.  
  50. @Finalize {
  51. DeleteGraphic(imgBoss);
  52. DeleteGraphic(imgCut);
  53. }
  54.  
  55. //Functions
  56.  
  57. function wait(w){
  58. loop(w){yield;}
  59. }
  60.  
  61. //Tasks and Subs
  62.  
  63. sub animInit {
  64. //Idle Animation
  65. CreateAnimation("Byakuren","Idle",4);
  66. SetAnimationFrame("Byakuren","Idle",0,imgBoss,5,0,0,96,128);
  67. SetAnimationFrame("Byakuren","Idle",1,imgBoss,5,96,0,192,128);
  68. SetAnimationFrame("Byakuren","Idle",2,imgBoss,5,192,0,288,128);
  69. SetAnimationFrame("Byakuren","Idle",3,imgBoss,5,288,0,384,128);
  70. //Moving Left Animation
  71. CreateAnimation("Byakuren","MoveLeft",4);
  72. SetAnimationFrame("Byakuren","MoveLeft",0,imgBoss,5,0,256,96,384);
  73. SetAnimationFrame("Byakuren","MoveLeft",1,imgBoss,5,96,256,192,384);
  74. SetAnimationFrame("Byakuren","MoveLeft",2,imgBoss,5,192,256,288,384);
  75. SetAnimationFrame("Byakuren","MoveLeft",3,imgBoss,5,288,256,384,384);
  76. //Stopping Left Animation
  77. CreateAnimation("Byakuren","StopLeft",3);
  78. SetAnimationFrame("Byakuren","StopLeft",0,imgBoss,5,288,256,384,384);
  79. SetAnimationFrame("Byakuren","StopLeft",1,imgBoss,5,192,256,288,384);
  80. SetAnimationFrame("Byakuren","StopLeft",2,imgBoss,5,96,256,192,384);
  81. //Moving Right Animation
  82. CreateAnimation("Byakuren","MoveRight",4);
  83. SetAnimationFrame("Byakuren","MoveRight",0,imgBoss,5,0,128,96,256);
  84. SetAnimationFrame("Byakuren","MoveRight",1,imgBoss,5,96,128,192,256);
  85. SetAnimationFrame("Byakuren","MoveRight",2,imgBoss,5,192,128,288,256);
  86. SetAnimationFrame("Byakuren","MoveRight",3,imgBoss,5,288,128,384,256);
  87. //Stopping Right Animation
  88. CreateAnimation("Byakuren","StopRight",3);
  89. SetAnimationFrame("Byakuren","StopRight",0,imgBoss,5,288,128,384,256);
  90. SetAnimationFrame("Byakuren","StopRight",1,imgBoss,5,192,128,288,256);
  91. SetAnimationFrame("Byakuren","StopRight",2,imgBoss,5,96,128,192,256);
  92. //Begin Idling
  93. Animate("Byakuren","Idle",true);
  94. }
  95.  
  96. task BossMoveAnim(direction){
  97. if(direction=="left"){
  98. Animate("Byakuren","MoveLeft",false);
  99. yield;
  100. while(GetSpeed>0.1){yield;}
  101. Animate("Byakuren","StopLeft",false);
  102. }
  103. if(direction=="right"){
  104. Animate("Byakuren","MoveRight",false);
  105. yield;
  106. while(GetSpeed>0.1){yield;}
  107. Animate("Byakuren","StopRight",false);
  108. }
  109. wait(15);
  110. Animate("Byakuren","Idle",true);
  111. }
  112.  
  113. task mainTask {
  114. wait(120);
  115. Danmaku1;
  116. while(GetTimer>45 && GetLife>800){yield;}
  117. Danmaku2;
  118. while(GetTimer>35 && GetLife>600){yield;}
  119. Danmaku3;
  120. while(GetTimer>25 && GetLife>450){yield;}
  121. Danmaku4;
  122. }
  123.  
  124. //The TeleportDanmaku task WORKS here
  125.  
  126. task Danmaku1 {
  127. let direction=rand_int(0,72)*5;
  128. while(GetLife>0 && GetTimer>0){
  129. TeleportDanmaku(GetX,GetY,0.5,direction,97,10,5);
  130. TeleportDanmaku(GetX,GetY,0.5,direction+90,97,10,5);
  131. TeleportDanmaku(GetX,GetY,0.5,direction+180,97,10,5);
  132. TeleportDanmaku(GetX,GetY,0.5,direction+270,97,10,5);
  133. direction+=20;
  134. wait(12);}
  135. }
  136.  
  137. task Danmaku2 {
  138. let direction=rand_int(0,72)*5;
  139. while(GetLife>0 && GetTimer>0){
  140. loop(5){
  141. TeleportDanmaku(GetX,GetY,0.5,direction,99,10,5);
  142. TeleportDanmaku(GetX,GetY,0.5,direction+90,99,10,5);
  143. TeleportDanmaku(GetX,GetY,0.5,direction+180,99,10,5);
  144. TeleportDanmaku(GetX,GetY,0.5,direction+270,99,10,5);
  145. direction-=20;
  146. wait(12);}
  147. direction-=40;
  148. wait(60);}
  149. }
  150.  
  151. task Danmaku3 {
  152. let direction1=rand_int(0,72)*5;
  153. let direction2=direction1+180;
  154. while(GetLife>0 && GetTimer>0){
  155. TeleportDanmaku(GetX,GetY,0.7,direction1,101,10,5);
  156. TeleportDanmaku(GetX,GetY,0.7,direction1+90,101,10,5);
  157. TeleportDanmaku(GetX,GetY,0.7,direction2,101,10,5);
  158. TeleportDanmaku(GetX,GetY,0.7,direction2+90,101,10,5);
  159. direction1+=20;
  160. direction2-=20;
  161. wait(12);}
  162. }
  163.  
  164. task Danmaku4 {
  165. let random=0;
  166. while(GetLife>0 && GetTimer>0){
  167. random+=rand(-360,360);
  168. TeleportDanmaku(GetX,GetY,0.3,random,107,10,5);
  169. wait(6);}
  170. }
  171.  
  172. //But if I put it here, for example, an error occurs
  173.  
  174. task TeleportDanmaku(x,y,v,dir,graphic,delay,tcount){
  175. let obj=Obj_Create(OBJ_SHOT);
  176. Obj_SetPosition(obj,x,y);
  177. Obj_SetSpeed(obj,v);
  178. Obj_SetAngle(obj,dir);
  179. ObjShot_SetGraphic(obj,graphic);
  180. ObjShot_SetDelay(obj,delay);
  181. if(tcount==5){
  182. wait(40/v);
  183. angle=Obj_GetAngle(obj)+180;
  184. dir=atan2(90*sin(angle-rotate),90*cos(angle-rotate))+180;
  185. Obj_Delete(obj);
  186. TeleportDanmaku(GetCenterX+90*cos(angle-rotate),GetCenterY+90*sin(angle-rotate),v,dir,graphic,delay,tcount-1);}
  187. if(tcount==4){
  188. wait(50/v);
  189. angle=Obj_GetAngle(obj)+180;
  190. dir=atan2(90*sin(angle-rotate),90*cos(angle-rotate));
  191. Obj_Delete(obj);
  192. TeleportDanmaku(GetCenterX+90*cos(angle-rotate),GetCenterY+90*sin(angle-rotate),v,dir,graphic,delay,tcount-1);}
  193. if(tcount==3){
  194. wait(90/v);
  195. angle=Obj_GetAngle(obj)+180;
  196. dir=atan2(180*sin(angle+rotate),180*cos(angle+rotate))+180;
  197. Obj_Delete(obj);
  198. TeleportDanmaku(GetCenterX+180*cos(angle+rotate),GetCenterY+180*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
  199. if(tcount==2){
  200. wait(90/v);
  201. angle=Obj_GetAngle(obj)+180;
  202. dir=atan2(40*sin(angle+rotate),40*cos(angle+rotate));
  203. Obj_Delete(obj);
  204. TeleportDanmaku(GetCenterX+40*cos(angle+rotate),GetCenterY+40*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
  205. if(tcount==1){
  206. wait(50/v);
  207. angle=Obj_GetAngle(obj)+180;
  208. dir=atan2(180*sin(angle+rotate),180*cos(angle+rotate));
  209. Obj_Delete(obj);
  210. TeleportDanmaku(GetCenterX+180*cos(angle+rotate),GetCenterY+180*sin(angle+rotate),v,dir,graphic,delay,tcount-1);}
  211. }
  212. }
Advertisement
Add Comment
Please, Sign In to add comment