Advertisement
dsiver144

DSI Coin Flip Anime

Jun 10th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Coin Flip Anime
  3. # -- Last Updated: 2017.06.10
  4. # -- Author: dsiver144
  5. # -- Level: Easy
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-CoinFlip"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.06.10 - Finish first version.
  14. #==============================================================================
  15. # + Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
  19. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. # Script Call: call_coinflip(id) -> See id below. Call this before battle start
  21. # It will reset to 0 after each battle.
  22. #==============================================================================
  23. module DSIVER144
  24. module COIN_FLIP
  25.  
  26. COIN_FLIP_STATE_VARIABLE = 15 # Variable 15 = 1 or 0 depend on flip result
  27. # 0 : Head -> Player goes first!
  28. # 1 : Tail -> Enemy Team goes first!
  29. # Just in case you want to check flip state in
  30. # battle for some reasons
  31. TINT_SCREEN_WHEN_FLIP = true
  32.  
  33. COIN_FLIP_ANIME = {}
  34. COIN_FLIP_ANIME[0] = [15,16] # Default
  35. COIN_FLIP_ANIME[1] = [15,16] # [Head Animation ID, Tail Animation ID]
  36. COIN_FLIP_ANIME[2] = [17,18]
  37.  
  38. end
  39. end
  40.  
  41. class Game_Interpreter
  42. include DSIVER144::COIN_FLIP
  43. #----------------------------------------------------------------------------
  44. # * new method: call_coinflip
  45. #----------------------------------------------------------------------------
  46. def call_coinflip(id)
  47. if COIN_FLIP_ANIME.has_key?(id)
  48. $game_system.current_coin_flip_id = id
  49. else
  50. $game_system.current_coin_flip_id = 0
  51. end
  52. end
  53. end
  54.  
  55. class Game_System
  56. attr_accessor :current_coin_flip_id
  57. alias_method(:game_system_init_coin_flip_anime, :initialize)
  58. #----------------------------------------------------------------------------
  59. # * new method: initialize
  60. #----------------------------------------------------------------------------
  61. def initialize
  62. @current_coin_flip_id = 0
  63. game_system_init_coin_flip_anime
  64. end
  65. end # Game_System
  66.  
  67. class Scene_Battle
  68. include DSIVER144::COIN_FLIP
  69.  
  70. def tint_screen(*args)
  71. tone = Tone.new(*args)
  72. duration = 30
  73. $game_troop.screen.start_tone_change(tone, duration)
  74. 60.times do
  75. $game_troop.screen.update_tone
  76. @spriteset.update
  77. Graphics.update
  78. end
  79. end
  80. #--------------------------------------------------------------------------
  81. # * Battle Start
  82. #--------------------------------------------------------------------------
  83. def battle_start
  84. BattleManager.battle_start
  85. flip_result = rand(2)
  86. $game_variables[COIN_FLIP_STATE_VARIABLE] = flip_result
  87. flip_anime_id = COIN_FLIP_ANIME[$game_system.current_coin_flip_id][flip_result]
  88. $game_system.current_coin_flip_id = 0 # Reset coin flip id
  89. if flip_result == 1
  90. tint_screen(-40,-40,-40,0) if TINT_SCREEN_WHEN_FLIP
  91. sprite_anime = Sprite_Base.new
  92. sprite_anime.x = Graphics.width*0.5
  93. sprite_anime.y = Graphics.height*0.5
  94. sprite_anime.start_animation($data_animations[flip_anime_id])
  95. while sprite_anime.animation?
  96. sprite_anime.update_animation
  97. Graphics.update
  98. end
  99. sprite_anime.dispose
  100. abs_wait_short
  101. $game_message.add("Enemy team goes first!")
  102. wait_for_message
  103. tint_screen(0,0,0,0) if TINT_SCREEN_WHEN_FLIP
  104. BattleManager.input_start
  105. turn_start
  106. else
  107. tint_screen(-40,-40,-40,0) if TINT_SCREEN_WHEN_FLIP
  108. sprite_anime = Sprite_Base.new
  109. sprite_anime.x = Graphics.width*0.5
  110. sprite_anime.y = Graphics.height*0.5
  111. sprite_anime.start_animation($data_animations[flip_anime_id])
  112. while sprite_anime.animation?
  113. sprite_anime.update_animation
  114. Graphics.update
  115. end
  116. sprite_anime.dispose
  117. abs_wait_short
  118. $game_message.add("Player goes first!")
  119. process_event
  120. wait_for_message
  121. tint_screen(0,0,0,0) if TINT_SCREEN_WHEN_FLIP
  122. start_party_command_selection
  123. end
  124. end
  125. end # Scene_Battle
  126. #===============================================================================
  127. # * END OF FILE
  128. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement