Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Antagonist Engine Ace - "Battle Speech Popup"
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # Dev Script who permit to have interactive basic AI for your scene.
- # Created by Nio Kasgami.
- # Requested by Nivlacart.
- # Data : 2016/01/10
- # Version : 1.0.0 {Beta}
- # Require : NA
- #==============================================================================
- #==============================================================================
- # History
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2016/01/10 - Begin and finished Script {Beta}
- #==============================================================================
- #==============================================================================
- # Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # System who permit to Show Popup when a certain skill is used.
- #==============================================================================
- module Antagonist_Engine
- module BattleSpeech
- Speech ={
- # you input text here the last ONE need to not have a "," or this gonna
- #bug for access in script you need to do Speech[:text]
- :fire => "Hiya!",
- :water => "COLD!"
- }
- BattleFont ={
- # speech font name
- :fontName => "Arial",
- # speech font size
- :fontSize => 20
- }
- BattleBubble ={
- # sprite bubble bitmap name
- :bitmap => "speechbubble",
- # sprite x-axis position
- :x => 100,
- # sprite y-axis position
- :y => 50,
- # sprite z-axis position
- :z => 100,
- # sprite opacity
- :opacity => 255
- }
- end
- end
- #==============================================================================
- # ■ Sprite_Speech
- #------------------------------------------------------------------------------
- # The Sprite class who handle the Battle bubble speech appearance when used
- # with skill.
- #==============================================================================
- class Sprite_Speech < Sprite
- include Antagonist_Engine::BattleSpeech
- #==============================================================================
- # ■ Sprite_Speech {Public Instance Variables}
- #------------------------------------------------------------------------------
- # this the section where I handdle all the variables who can be change in games
- # or in script in simple this permit to handle variable who change a lots
- #==============================================================================
- #----------------------------------------------------------------------------
- # ♦ Public Instance Variables {System}
- #----------------------------------------------------------------------------
- attr_accessor :speech # permit the system to access speech (pure convenience code)
- attr_accessor :skill_id # permit to access skill_id (pure convenience code)
- #===============================================================================
- # => END : Game_AI {Public Instance Variables}
- #===============================================================================
- #----------------------------------------------------------------------------
- # ○ new method: initialize
- #----------------------------------------------------------------------------
- def initialize(viewport)
- super(viewport)
- self.bitmap = Cache.system(BattleBubble[:bitmap])
- self.x = BattleBubble[:x]
- self.y = BattleBubble[:y]
- self.z = BattleBubble[:z]
- self.opacity = BattleBubble[:opacity]
- self.visible = false
- @speech = ""
- @skill_id = 0
- update_visibility
- create_text
- end
- #----------------------------------------------------------------------------
- # ○ new method: speech=
- #----------------------------------------------------------------------------
- def speech=(skill_id)
- @skill_id = skill_id
- end
- #----------------------------------------------------------------------------
- # ○ new method: clear_speech
- #----------------------------------------------------------------------------
- def clear_speech
- @text.bitmap.clear
- @text.bitmap.draw_text(6,4,190,32,"",2)
- @speech = ""
- @skill_id = 0
- end
- #----------------------------------------------------------------------------
- # ○ new method: update
- #----------------------------------------------------------------------------
- def update
- super
- update_visibility
- update_speech
- end
- #----------------------------------------------------------------------------
- # ○ new method: update_visibility
- #----------------------------------------------------------------------------
- def update_visibility
- if @skill_id != 0 && @speech != ""
- self.visible = true
- else
- self.visible = false
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: update_speech
- #----------------------------------------------------------------------------
- # it's where you setup your skill.
- # follow the example I made you do a when with the id you want to use for the skill
- # then input return and NOW input Speech[:thename] for get the filename
- #----------------------------------------------------------------------------
- def update_speech
- case @skill_id
- when 30 # the id of the skill
- return @speech = Speech[:fire] #the text
- when 20 #another id
- return @speech = Speech[:water] # the text again
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: draw_speech
- #----------------------------------------------------------------------------
- def create_text
- @text = Sprite.new
- @text.bitmap = Bitmap.new(200,40)
- @text.z = 300
- @text.bitmap.font.name = BattleFont[:fontName]
- @text.bitmap.font.size = BattleFont[:fontSize]
- @text.bitmap.font.bold = false
- @text.bitmap.font.italic = true
- @text.x = self.x
- @text.y = self.y
- # refresh
- end
- def draw_speech
- if @speech != ""
- # refresh
- end
- end
- def refresh
- try = @speech
- @text.bitmap.clear
- # @text.bitmap.font.color = Color.new(255,255,255,0)
- @text.bitmap.draw_text(6,4,190,32,try,0)
- end
- end
- #===============================================================================
- # => END : Sprite_Speech
- #===============================================================================
- #==============================================================================
- # ■ Scene_Battle
- #------------------------------------------------------------------------------
- # This class performs battle screen processing.
- #==============================================================================
- class Scene_Battle < Scene_Base
- alias neo_start start
- def start
- neo_start
- create_speech_popup
- end
- #----------------------------------------------------------------------------
- # ○ new method: execute_inverti_slide {in vertical slide effect}
- #----------------------------------------------------------------------------
- def create_speech_popup
- @battlespeech = Sprite_Speech.new(@viewport1)
- end
- alias neo_update_basic update_basic
- def update_basic
- neo_update_basic
- update_speech
- end
- #----------------------------------------------------------------------------
- # ○ new method: execute_inverti_slide {in vertical slide effect}
- #----------------------------------------------------------------------------
- def update_speech
- @battlespeech.update
- end
- #--------------------------------------------------------------------------
- # * Processing at End of Action
- #--------------------------------------------------------------------------
- def process_action_end
- @subject.on_action_end
- status_redraw_target(@subject)
- refresh_popup
- @log_window.display_auto_affected_status(@subject)
- @log_window.wait_and_clear
- @log_window.display_current_state(@subject)
- @log_window.wait_and_clear
- BattleManager.judge_win_loss
- end
- #--------------------------------------------------------------------------
- # * Execute Battle Actions
- #--------------------------------------------------------------------------
- def execute_action
- @subject.sprite_effect_type = :whiten if YEA::BATTLE::FLASH_WHITE_EFFECT
- draw_popup
- use_item
- @log_window.wait_and_clear
- end
- #----------------------------------------------------------------------------
- # ○ new method: execute_inverti_slide {in vertical slide effect}
- #----------------------------------------------------------------------------
- def draw_popup
- item = @subject.current_action.item
- if item.is_a?(RPG::Skill)
- show_popup(item.id)
- @battlespeech.update_speech
- @battlespeech.refresh
- end
- end
- #----------------------------------------------------------------------------
- # ○ new method: execute_inverti_slide {in vertical slide effect}
- #----------------------------------------------------------------------------
- def show_popup(item)
- @battlespeech.speech=(item)
- end
- #----------------------------------------------------------------------------
- # ○ new method: execute_inverti_slide {in vertical slide effect}
- #----------------------------------------------------------------------------
- def refresh_popup
- @battlespeech.clear_speech
- end
- end
- #===============================================================================
- # => END : Scene_Battle
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement