Guest User

Untitled

a guest
Apr 8th, 2019
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "./../default_system/SE_ShotConst.dnh"
  2. task CreateStageEnemyA1(x, y, life, speed, angle, startVelocty, velocity, endVelocity, shotType, deleteTime){
  3. let objImage = GetModuleDirectory() ~ "script/img/enemy/enemFairy.png";
  4. let counter = 0;
  5. let xMin = -32;
  6. let xMax = GetStgFrameWidth + 32;
  7. let yMin = -32;
  8. let yMax = GetStgFrameHeight + 0;
  9.  
  10. let objEnemy;
  11. let enemyX;
  12. let enemyY;
  13. TInitialize();
  14.  
  15. task TInitialize(){
  16. objEnemy = ObjEnemy_Create(OBJ_ENEMY);
  17. ObjEnemy_Regist(objEnemy);
  18. ObjEnemy_SetLife(objEnemy, life);
  19. SetDamageRateAtFrame(objEnemy, 30, 100, 100);
  20. ObjMove_SetPosition(objEnemy, x, y);
  21. ObjMove_SetAngle(objEnemy, angle);
  22. ObjMove_SetSpeed(objEnemy, speed);
  23. ObjMove_AddPatternA2(objEnemy, startVelocty, NO_CHANGE, NO_CHANGE, 0, velocity,0);
  24. ObjMove_AddPatternA2(objEnemy, endVelocity, NO_CHANGE, NO_CHANGE, 0, 0, 0);
  25.  
  26. TMainLoop();
  27. TDraw();
  28. TMainTask();
  29. }
  30.  
  31. task TMainLoop(){
  32. while(deleteTime >= counter && ObjEnemy_GetInfo(objEnemy, INFO_LIFE) > 0 && (ObjMove_GetX(objEnemy) > xMin && ObjMove_GetX(objEnemy) < xMax && ObjMove_GetY(objEnemy) > yMin && ObjMove_GetY(objEnemy) < yMax)){
  33. ObjEnemy_SetIntersectionCircleToShot(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy), 12);
  34. ObjEnemy_SetIntersectionCircleToPlayer(objEnemy, ObjMove_GetX(objEnemy), ObjMove_GetY(objEnemy) - 2, 8);
  35.  
  36. enemyX = ObjMove_GetX(objEnemy);
  37. enemyY = ObjMove_GetY(objEnemy);
  38. counter++;
  39. yield;
  40. }
  41. TFinalize();
  42. }
  43.  
  44. task TMainTask(){
  45. if(shotType == "1"){
  46. while(!Obj_IsDeleted(objEnemy)){
  47. CreateCircleRing(enemyX, enemyY, 2, 45, 20, 15, 12);
  48. loop(30){yield;}
  49. yield;
  50. }
  51.  
  52. task CreateCircleRing(x, y, speed, angle, graphic, delay, amt){
  53. let angleT = angle;
  54. loop(amt){
  55. CreateShotA1(x, y, speed, angleT, graphic, delay);
  56. angleT += 360/amt;
  57. }
  58. }
  59. }
  60.  
  61. }
  62.  
  63. task TDraw(){
  64. ObjPrim_SetTexture(objEnemy, objImage);
  65. Obj_SetRenderPriorityI(objEnemy, 25);
  66. ObjRender_SetBlendType(objEnemy, BLEND_ALPHA);
  67. ObjRender_SetAngleXYZ(objEnemy, 0, 0, 0);
  68. ObjRender_SetScaleXYZ(objEnemy, 0.55, 0.55, 0);
  69. ObjRender_SetAlpha(objEnemy, 255);
  70. ObjSprite2D_SetSourceRect(objEnemy, 0, 0, 96, 64); //96, 96
  71. ObjSprite2D_SetDestCenter(objEnemy);
  72.  
  73. let left = 96; let top = 64; let right = 96; let bottom = 64;
  74. let animFrame = 0; let animFrame2 = 0;
  75. while(!Obj_IsDeleted(objEnemy)){
  76. //ObjRender_SetPosition(objEnemy, GetPlayerX, GetPlayerY, 0);
  77.  
  78. if(speed == 0 || ((angle == 90 || angle == 270) && velocity == 0)){
  79. if(animFrame < 15) { ObjSprite2D_SetSourceRect(objEnemy,left*0, top*0, right*1, bottom*1); }
  80. if(animFrame >= 15 && animFrame < 30) { ObjSprite2D_SetSourceRect(objEnemy,left*1, top*0, right*2, bottom*1); }
  81. if(animFrame >= 30 && animFrame < 45) { ObjSprite2D_SetSourceRect(objEnemy,left*2, top*0, right*3, bottom*1); }
  82. if(animFrame >= 45) { ObjSprite2D_SetSourceRect(objEnemy,left*3, top*0, right*4, bottom*1); }
  83. ObjRender_SetAngleXYZ(objEnemy, 0, 0, 0);
  84. }
  85.  
  86. else if(cos(angle) < 0 && speed > 0){ //left
  87. ObjRender_SetAngleY(objEnemy, 180);
  88. if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(objEnemy,left*0, top*1, right*1, bottom*2); }
  89. if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(objEnemy,left*1, top*1, right*2, bottom*2); }
  90. if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(objEnemy,left*2, top*1, right*3, bottom*2); }
  91. if(animFrame2 >= 45 && animFrame2 < 60) { ObjSprite2D_SetSourceRect(objEnemy,left*3, top*1, right*4, bottom*2); }
  92.  
  93. if(animFrame2 >= 60 && animFrame2 < 75) { ObjSprite2D_SetSourceRect(objEnemy,left*0, top*2, right*1, bottom*3); }
  94. if(animFrame2 >= 75 && animFrame2 < 90) { ObjSprite2D_SetSourceRect(objEnemy,left*1, top*2, right*2, bottom*3); }
  95. if(animFrame2 >= 90 && animFrame2 < 105) { ObjSprite2D_SetSourceRect(objEnemy,left*2, top*2, right*3, bottom*3); }
  96. if(animFrame2 >= 105) { ObjSprite2D_SetSourceRect(objEnemy,left*3, top*2, right*4, bottom*3); }
  97. ObjRender_SetAngleXYZ(objEnemy, 0, 0, 0);
  98. }
  99.  
  100. else if(cos(angle) > 0 && speed > 0){ //right
  101. if(animFrame2 < 15) { ObjSprite2D_SetSourceRect(objEnemy,left*0, top*1, right*1, bottom*2); }
  102. if(animFrame2 >= 15 && animFrame2 < 30) { ObjSprite2D_SetSourceRect(objEnemy,left*1, top*1, right*2, bottom*2); }
  103. if(animFrame2 >= 30 && animFrame2 < 45) { ObjSprite2D_SetSourceRect(objEnemy,left*2, top*1, right*3, bottom*2); }
  104. if(animFrame2 >= 45) { ObjSprite2D_SetSourceRect(objEnemy,left*3, top*1, right*4, bottom*2); }
  105.  
  106. if(animFrame2 >= 60 && animFrame2 < 75) { ObjSprite2D_SetSourceRect(objEnemy,left*0, top*2, right*1, bottom*3); }
  107. if(animFrame2 >= 75 && animFrame2 < 90) { ObjSprite2D_SetSourceRect(objEnemy,left*1, top*2, right*2, bottom*3); }
  108. if(animFrame2 >= 90 && animFrame2 < 105) { ObjSprite2D_SetSourceRect(objEnemy,left*2, top*2, right*3, bottom*3); }
  109. if(animFrame2 >= 105) { ObjSprite2D_SetSourceRect(objEnemy,left*3, top*2, right*4, bottom*3); }
  110. ObjRender_SetAngleXYZ(objEnemy, 0, 0, 0);
  111. }
  112. if(animFrame > 60) { animFrame = 0; }
  113. if(animFrame2 > 120) { animFrame2 = 60; }
  114. animFrame += 3.5;
  115. animFrame2 += 3;
  116. yield;
  117. }
  118. }
  119.  
  120. task TFinalize(){
  121. //if(ObjEnemy_GetInfo(objEnemy, INFO_LIFE) == 0){
  122. //deathCircle(enemyX, enemyY, 0, 153, 255);
  123. //deathCircle2(enemyX, enemyY, 0, 153, 255);
  124. //deathCircle2(enemyX, enemyY, 0, 153, 255);
  125. //}
  126. Obj_Delete(objEnemy);
  127. }
  128.  
  129. task SetDamageRateAtFrame(obj, frame, shot, spell){
  130. ObjEnemy_SetDamageRate(obj, 0, 0);
  131. loop(frame){yield;}
  132. ObjEnemy_SetDamageRate(obj, 100, 100);
  133. }
  134. }
RAW Paste Data