Advertisement
Guest User

Script Derpington

a guest
Jun 5th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. #TouhouDanmakufu[Single]
  2. #ScriptVersion[3]
  3. #Title["SampleA55"]
  4. #Text["SampleA55"]
  5.  
  6. //load the default shotsheet
  7. #include"script/default_system/FondueShotDefine.txt"
  8.  
  9. //----------------------------------------------------
  10. //Declaring Global Variables
  11. //The variables declared here can be used throughout the entire script.
  12. //However, the variables declared here are static. (They can be changed, but not by themselves as they are not in the main loop)
  13. //(As execution order cannot be guaranteed, random numbers cannot be used(?))
  14. //----------------------------------------------------
  15. let objEnemy;
  16. let objPlayer;
  17. let frame=0;
  18. let frame2=0;
  19. let addangle=0;
  20. let spinangle=0;
  21. let radius=150;
  22. //----------------------------------------------------
  23. //Enemy movement
  24. //----------------------------------------------------
  25. @Event
  26. {
  27. alternative(GetEventType())
  28. case(EV_REQUEST_LIFE)
  29. {
  30. //script requests for the enemy's life
  31. SetScriptResult(500);//setting enemy life to 500
  32. }
  33. }
  34.  
  35. @Initialize
  36. {
  37. //Sets variable "objPlayer" to the Player ID
  38. objPlayer = GetPlayerObjectID();
  39.  
  40. //creates and registers enemy object
  41. objEnemy = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  42. ObjEnemy_Regist(objEnemy);
  43.  
  44. //Setting the enemy's image
  45. let imgExRumia = GetCurrentScriptDirectory ~ "ExRumia.png"; //file path to enemy image
  46. ObjPrim_SetTexture(objEnemy, imgExRumia); //Setting the above image file as a texture to the enemy object(objEnemy)
  47. ObjSprite2D_SetSourceRect(objEnemy, 64, 1, 127, 64); //Setting the rectangle coordinates in the enemy image to use(Left, Top, Right, Bottom).
  48. ObjSprite2D_SetDestCenter(objEnemy); //Positioning the center of the rectangle(w/texture) at (0, 0) on the stage(top left corner).
  49.  
  50. //Moving to the coordinate (cx, 120) in 60 frames
  51. let sx = GetStgFrameHeight() / 2;
  52. let cx = GetStgFrameWidth() / 2;//defines the variable cx as the horizontal middle of the stage. (Stage width / 2)
  53. ObjMove_SetDestAtFrame(objEnemy, cx, sx, 60);
  54.  
  55. mainTask;
  56. }
  57.  
  58. @MainLoop
  59. {
  60. let ex = ObjMove_GetX(objEnemy);
  61. let ey = ObjMove_GetY(objEnemy);
  62.  
  63. yield;
  64.  
  65. //Setting the enemy hit box
  66. ObjEnemy_SetIntersectionCircleToShot(objEnemy, ex, ey, 32);//hitbox against player bullets. 32 is the radius.
  67. ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ex, ey, 24);//hitbox against the player. 24 is the radius.
  68.  
  69. //adding +1 to frame. "frame++" is equivalent to "frame = frame + 1;" or "frame += 1;"
  70. frame++;
  71. frame2++;
  72.  
  73. if(radius>=150){
  74. radius--;
  75. }
  76.  
  77. if(radius<=-150){
  78. radius++;
  79. }
  80.  
  81. if(frame>=90){
  82. spinangle++;
  83. addangle+=0.5;
  84. }
  85.  
  86. //if enemy life is 0
  87. if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) <= 0)
  88. {
  89. //The enemy is killed immediately when life is 0
  90. //As this is a beginner sample script,
  91. //the script is ended immediately without waiting for an explosion effect.
  92. Obj_Delete(objEnemy);
  93. CloseScript(GetOwnScriptID());
  94. return;
  95. }
  96. }
  97.  
  98. task mainTask{
  99. yield;
  100. fire;
  101. firefollowshot;
  102. }
  103.  
  104. task firefollowshot{
  105. wait(90);
  106. let shot1;
  107. shot1 = CreateShotA1(ex,ey-150,0,0,BALL_T_RED,60);
  108. while(!Obj_IsDeleted(shot1)){
  109. ObjMove_SetAngle(shot1,ObjAngleToObj(shot1,objPlayer));
  110. ObjMove_SetDestAtFrame(shot1,px,py,120);
  111. yield;
  112. }
  113. }
  114.  
  115.  
  116. task fire{
  117. wait(90);
  118. loop{
  119. let angle=0;
  120. while(angle<359){
  121. shot(ex+50*cos(angle+(addangle*spinangle/25)),ey+50*sin(angle+(addangle*spinangle/25)),1,(addangle*spinangle/25)+angle,OVAL_T_CYAN,5);
  122. angle+=(360/2);
  123. }
  124. wait(1);
  125. }
  126. }
  127.  
  128. task shot(x,y,speed,angle,graphic,delay){
  129. let obj = ObjShot_Create(OBJ_SHOT);
  130. ObjMove_SetPosition(obj,x,y);
  131. ObjMove_SetSpeed(obj,speed);
  132. ObjMove_SetAngle(obj,angle);
  133. ObjMove_SetAngularVelocity(obj,0);
  134. ObjShot_SetGraphic(obj,graphic);
  135. ObjShot_SetDelay(obj,delay);
  136. ObjShot_Regist(obj);
  137. while(Obj_IsDeleted(obj)){
  138. yield;
  139. }
  140. }
  141.  
  142. function followshot(x,y,speed,angle,graphic,delay){
  143. let obj = ObjShot_Create(OBJ_SHOT);
  144. ObjMove_SetPosition(obj,x,y);
  145. ObjMove_SetSpeed(obj,speed);
  146. ObjMove_SetAngle(obj,angle);
  147. ObjShot_SetGraphic(obj,graphic);
  148. ObjShot_SetDelay(obj,delay);
  149. ObjShot_Regist(obj);
  150. return obj;
  151. }
  152.  
  153.  
  154. function wait(n){loop(n){yield;}}
  155.  
  156. function ex{
  157. return ObjMove_GetX(objEnemy);
  158. }
  159.  
  160. function ey{
  161. return ObjMove_GetY(objEnemy);
  162. }
  163.  
  164. function px{
  165. return ObjMove_GetX(objPlayer);
  166. }
  167.  
  168. function py{
  169. return ObjMove_GetY(objPlayer);
  170. }
  171.  
  172. function ObjAngleToObj(obj2,obj1){
  173. let obj1x=ObjMove_GetX(obj1);
  174. let obj1y=ObjMove_GetY(obj1);
  175. let obj2x=ObjMove_GetX(obj2);
  176. let obj2y=ObjMove_GetY(obj2);
  177. let angleresult=atan2(obj1y-obj2y,obj1x-obj2x);
  178. return angleresult;
  179. }
  180.  
  181. function NormalizeAngle(angle){
  182. angle %= 360;
  183. if(angle<0){ angle += 360; }
  184. return angle;
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement