Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Coin Flip Anime
- # -- Last Updated: 2017.06.10
- # -- Author: dsiver144
- # -- Level: Easy
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-CoinFlip"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.06.10 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Script Call: call_coinflip(id) -> See id below. Call this before battle start
- # It will reset to 0 after each battle.
- #==============================================================================
- module DSIVER144
- module COIN_FLIP
- COIN_FLIP_STATE_VARIABLE = 15 # Variable 15 = 1 or 0 depend on flip result
- # 0 : Head -> Player goes first!
- # 1 : Tail -> Enemy Team goes first!
- # Just in case you want to check flip state in
- # battle for some reasons
- TINT_SCREEN_WHEN_FLIP = true
- COIN_FLIP_ANIME = {}
- COIN_FLIP_ANIME[0] = [15,16] # Default
- COIN_FLIP_ANIME[1] = [15,16] # [Head Animation ID, Tail Animation ID]
- COIN_FLIP_ANIME[2] = [17,18]
- end
- end
- class Game_Interpreter
- include DSIVER144::COIN_FLIP
- #----------------------------------------------------------------------------
- # * new method: call_coinflip
- #----------------------------------------------------------------------------
- def call_coinflip(id)
- if COIN_FLIP_ANIME.has_key?(id)
- $game_system.current_coin_flip_id = id
- else
- $game_system.current_coin_flip_id = 0
- end
- end
- end
- class Game_System
- attr_accessor :current_coin_flip_id
- alias_method(:game_system_init_coin_flip_anime, :initialize)
- #----------------------------------------------------------------------------
- # * new method: initialize
- #----------------------------------------------------------------------------
- def initialize
- @current_coin_flip_id = 0
- game_system_init_coin_flip_anime
- end
- end # Game_System
- class Scene_Battle
- include DSIVER144::COIN_FLIP
- def tint_screen(*args)
- tone = Tone.new(*args)
- duration = 30
- $game_troop.screen.start_tone_change(tone, duration)
- 60.times do
- $game_troop.screen.update_tone
- @spriteset.update
- Graphics.update
- end
- end
- #--------------------------------------------------------------------------
- # * Battle Start
- #--------------------------------------------------------------------------
- def battle_start
- BattleManager.battle_start
- flip_result = rand(2)
- $game_variables[COIN_FLIP_STATE_VARIABLE] = flip_result
- flip_anime_id = COIN_FLIP_ANIME[$game_system.current_coin_flip_id][flip_result]
- $game_system.current_coin_flip_id = 0 # Reset coin flip id
- if flip_result == 1
- tint_screen(-40,-40,-40,0) if TINT_SCREEN_WHEN_FLIP
- sprite_anime = Sprite_Base.new
- sprite_anime.x = Graphics.width*0.5
- sprite_anime.y = Graphics.height*0.5
- sprite_anime.start_animation($data_animations[flip_anime_id])
- while sprite_anime.animation?
- sprite_anime.update_animation
- Graphics.update
- end
- sprite_anime.dispose
- abs_wait_short
- $game_message.add("Enemy team goes first!")
- wait_for_message
- tint_screen(0,0,0,0) if TINT_SCREEN_WHEN_FLIP
- BattleManager.input_start
- turn_start
- else
- tint_screen(-40,-40,-40,0) if TINT_SCREEN_WHEN_FLIP
- sprite_anime = Sprite_Base.new
- sprite_anime.x = Graphics.width*0.5
- sprite_anime.y = Graphics.height*0.5
- sprite_anime.start_animation($data_animations[flip_anime_id])
- while sprite_anime.animation?
- sprite_anime.update_animation
- Graphics.update
- end
- sprite_anime.dispose
- abs_wait_short
- $game_message.add("Player goes first!")
- process_event
- wait_for_message
- tint_screen(0,0,0,0) if TINT_SCREEN_WHEN_FLIP
- start_party_command_selection
- end
- end
- end # Scene_Battle
- #===============================================================================
- # * END OF FILE
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement