Advertisement
bb94

Floofy's Spell Header

Feb 14th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. #include "../item/itemConsts.dnh"
  2. #include "../language.dnh"
  3. #include "../system/healthbar.dnh"
  4. let objBoss;
  5.  
  6. let list = [];
  7. @Initialize {
  8. objBoss = ObjEnemy_Create(OBJ_ENEMY_BOSS);
  9. ObjEnemy_Regist(objBoss);
  10. ObjMove_SetDestAtFrame(objBoss, GetStgFrameWidth / 2, 90, 30);
  11. ObjEnemy_SetDamageRate(objBoss, 0, 0);
  12. setBoss(objBoss);
  13. if (id != 0 && !IsReplay) {saveHistoryPre(id);}
  14. TRender;
  15. TCutIn;
  16. TEnd;
  17. }
  18.  
  19. @MainLoop {
  20. let ex = ObjMove_GetX(objBoss);
  21. let ey = ObjMove_GetY(objBoss);
  22. ObjEnemy_SetIntersectionCircleToShot(objBoss,
  23. ex, ey, 24);
  24. ObjEnemy_SetIntersectionCircleToPlayer(objBoss,
  25. ex, ey, 24);
  26. yield;
  27. }
  28.  
  29. task TCutIn {
  30. while (GetPlayerInvincibilityFrame > 0) {yield;}
  31. ObjEnemy_SetDamageRate(objBoss, 100, 100);
  32. if (id != 0) {
  33. ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
  34. let scName = getSpellNames(id)[getDifficulty];
  35. let spellText = textOf(scName);
  36. ObjText_SetFontSize(spellText, 16 * fontScale);
  37. ObjText_SetMaxWidth(spellText, 400);
  38. ObjText_SetHorizontalAlignment(spellText, ALIGNMENT_RIGHT);
  39. ObjText_SetFontBorderWidth(spellText, 1);
  40. ObjText_SetFontBorderType(spellText, BORDER_FULL);
  41. ObjText_SetFontBorderColor(spellText, 0, 0, 0);
  42. ObjRender_SetX(spellText, -40);
  43. //Obj_SetRenderPriority(spellText, 0.2);
  44. let width = GetStgFrameWidth;
  45. let height = GetStgFrameHeight;
  46. let enemyPortrait = ObjPrim_Create(OBJ_SPRITE_2D);
  47. ObjPrim_SetTexture(enemyPortrait, GetCurrentScriptDirectory ~ "../resource/boss/st" ~ rtos("00", level)
  48. ~ ".png");
  49. // 224 wide, 368 tall
  50. ObjSprite2D_SetSourceRect(enemyPortrait, 0, 144, 223, 511);
  51. descent (i in 0..90) {
  52. ObjSprite2D_SetDestRect(enemyPortrait, width - 223 + i, height - 367, width + i, height);
  53. ObjRender_SetY(spellText, 30 + i);
  54. yield;
  55. }
  56. let bonusText = ObjText_Create;
  57. ObjText_SetFontSize(bonusText, 8);
  58. ObjText_SetMaxWidth(bonusText, 400);
  59. ObjText_SetHorizontalAlignment(bonusText, ALIGNMENT_RIGHT);
  60. ObjText_SetFontBorderWidth(bonusText, 1);
  61. ObjText_SetFontBorderType(bonusText, BORDER_FULL);
  62. ObjText_SetFontBorderColor(bonusText, 0, 0, 0);
  63. ObjRender_SetX(bonusText, -40);
  64. ObjRender_SetY(bonusText, 45);
  65. list = list ~ [spellText, bonusText];
  66. TBonusUpdate(bonusText);
  67. Obj_Delete(enemyPortrait);
  68. } else {
  69. wait(30); // Wait so boss doesn't accidentally shoot at (0, 0)
  70. }
  71. TWork;
  72. }
  73.  
  74. task TBonusUpdate(txt) {
  75. let bs = GetEnemyBossSceneObjectID;
  76. let hist = getHistory(id);
  77. while (ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
  78. let score = roundScore(ObjEnemyBossScene_GetInfo(bs, INFO_SPELL_SCORE));
  79. let success = ObjEnemyBossScene_GetInfo(bs, INFO_PLAYER_SHOOTDOWN_COUNT) == 0 &&
  80. ObjEnemyBossScene_GetInfo(bs, INFO_PLAYER_SPELL_COUNT) == 0;
  81. ObjText_SetText(txt, "Bonus " ~ ["Failed", IntToStringBase(score, base)][success] ~
  82. " | History " ~ IntToStringBase(hist[0], base) ~ "/" ~ IntToStringBase(hist[1], base));
  83. yield;
  84. }
  85. }
  86.  
  87. task TEnd {
  88. while (ObjEnemy_GetInfo(objBoss, INFO_LIFE) > 0) {
  89. yield;
  90. }
  91. yield;
  92. let ex = ObjMove_GetX(objBoss);
  93. let ey = ObjMove_GetY(objBoss);
  94. let width = GetStgFrameWidth;
  95. TExplosionA(ex, ey, 10, 0.6);
  96. DeleteShotAll(TYPE_ALL, TYPE_ITEM);
  97. //When making plural scripts,
  98. //Deleting the enemy allows the plural script to proceed on to the next script.
  99. //Do not forget to delete the enemy.
  100. Obj_Delete(objBoss);
  101. delBoss;
  102. ascent(i in 0 .. 32 * (level + getDifficulty)) {
  103. createItemU1(POINT_ITEM, ex + rand(-20, 20), ey + rand(-20, 20), 0);
  104. }
  105.  
  106. let len = length(list);
  107. ascent (i in 0 .. len) {
  108. Obj_Delete(list[i]);
  109. }
  110. let bs = GetEnemyBossSceneObjectID;
  111. let success = ObjEnemyBossScene_GetInfo(bs, INFO_PLAYER_SHOOTDOWN_COUNT) == 0 &&
  112. ObjEnemyBossScene_GetInfo(bs, INFO_PLAYER_SPELL_COUNT) == 0 &&
  113. (ObjEnemyBossScene_GetInfo(bs, INFO_TIMERF) != 0 ||
  114. ObjEnemyBossScene_GetInfo(bs, INFO_IS_DURABLE_SPELL));
  115. if (success) {
  116. if (id != 0) {NotifyEventAll(EV_GAIN_SPELL, id);}
  117. createItemU1(2, rand(0, width), 0, 0);
  118. createItemU1(3, rand(0, width), 0, 0);
  119. }
  120. if (id != 0 && !IsReplay) {saveHistoryPost(id, success);}
  121. wait(240);
  122. // Please close the script at the end
  123. CloseScript(GetOwnScriptID());
  124. }
  125.  
  126. function spellBonus {
  127. let totalHealth = ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_CURRENT_LIFE_MAX);
  128. return getPIV * 48 * (level + getDifficulty + totalHealth / 1000);
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement