Advertisement
nio_kasgami

beta23442125234

Dec 30th, 2015
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 10.06 KB | None | 0 0
  1. #==============================================================================
  2. # ■ Antagonist Engine Ace - "Battle Speech Popup"
  3. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  4. # Dev Script who permit to have interactive basic AI for your scene.
  5. # Created by Nio Kasgami.
  6. # Requested by Nivlacart.
  7. # Data : 2016/01/10
  8. # Version : 1.0.0 {Beta}
  9. # Require : NA
  10. #==============================================================================
  11.  
  12. #==============================================================================
  13. # History
  14. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. # 2016/01/10 - Begin and finished Script {Beta}
  16. #==============================================================================
  17.  
  18. #==============================================================================
  19. # Introduction
  20. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  21. # System who permit to Show Popup when a certain skill is used.
  22. #==============================================================================
  23. module Antagonist_Engine
  24.     module BattleSpeech
  25.         Speech ={
  26.         # you input text here the last ONE need to not have a "," or this gonna
  27.         #bug for access in script you need to do Speech[:text]
  28.             :fire => "Hiya!",
  29.             :water => "COLD!"
  30.         }
  31.  
  32.         BattleFont ={
  33.             # speech font name
  34.             :fontName => "Arial",
  35.             # speech font size
  36.             :fontSize => 20
  37.  
  38.         }
  39.         BattleBubble ={
  40.             # sprite bubble bitmap name
  41.             :bitmap => "speechbubble",
  42.             # sprite x-axis position
  43.             :x => 100,
  44.             # sprite y-axis position
  45.             :y => 50,
  46.             # sprite z-axis position
  47.             :z => 100,
  48.             # sprite opacity
  49.             :opacity => 255
  50.         }
  51.     end
  52. end
  53.  
  54. #==============================================================================
  55. # ■ Sprite_Speech
  56. #------------------------------------------------------------------------------
  57. # The Sprite class who handle the Battle bubble speech appearance when used
  58. # with skill.
  59. #==============================================================================
  60.  
  61. class Sprite_Speech < Sprite
  62.    include Antagonist_Engine::BattleSpeech
  63.  
  64. #==============================================================================
  65. # ■ Sprite_Speech {Public Instance Variables}
  66. #------------------------------------------------------------------------------
  67. # this the section where I handdle all the variables who can be change in games
  68. # or in script in simple this permit to handle variable who change a lots
  69. #==============================================================================
  70.  
  71.   #----------------------------------------------------------------------------
  72.   # ♦ Public Instance Variables {System}
  73.   #----------------------------------------------------------------------------
  74.     attr_accessor :speech   # permit the system to access speech (pure convenience code)
  75.     attr_accessor :skill_id # permit to access skill_id (pure convenience code)
  76.  
  77. #===============================================================================
  78. # => END : Game_AI {Public Instance Variables}
  79. #===============================================================================
  80.  
  81. #----------------------------------------------------------------------------
  82. # ○ new method: initialize
  83. #----------------------------------------------------------------------------
  84.     def initialize(viewport)
  85.         super(viewport)
  86.         self.bitmap = Cache.system(BattleBubble[:bitmap])
  87.         self.x = BattleBubble[:x]
  88.         self.y = BattleBubble[:y]
  89.         self.z = BattleBubble[:z]
  90.         self.opacity = BattleBubble[:opacity]
  91.         self.visible = false
  92.         @speech = ""
  93.         @skill_id = 0
  94.         update_visibility
  95.         create_text
  96.     end
  97.  
  98. #----------------------------------------------------------------------------
  99. # ○ new method: speech=
  100. #----------------------------------------------------------------------------
  101.     def speech=(skill_id)
  102.         @skill_id = skill_id
  103.     end
  104.  
  105. #----------------------------------------------------------------------------
  106. # ○ new method: clear_speech
  107. #----------------------------------------------------------------------------
  108.     def clear_speech
  109.       @text.bitmap.clear
  110.       @text.bitmap.draw_text(6,4,190,32,"",2)
  111.         @speech = ""
  112.         @skill_id = 0
  113.        
  114.     end
  115.  
  116. #----------------------------------------------------------------------------
  117. # ○ new method: update
  118. #----------------------------------------------------------------------------
  119.     def update
  120.         super
  121.         update_visibility
  122.         update_speech
  123.     end
  124.  
  125. #----------------------------------------------------------------------------
  126. # ○ new method: update_visibility
  127. #----------------------------------------------------------------------------
  128.     def update_visibility
  129.         if @skill_id != 0 && @speech != ""
  130.             self.visible = true
  131.         else
  132.             self.visible = false
  133.         end
  134.     end
  135.  
  136. #----------------------------------------------------------------------------
  137. # ○ new method: update_speech
  138. #----------------------------------------------------------------------------
  139. # it's where you setup your skill.
  140. # follow the example I made you do a when with the id you want to use for the skill
  141. # then input return and NOW input Speech[:thename] for get the filename
  142. #----------------------------------------------------------------------------
  143.     def update_speech
  144.         case @skill_id
  145.         when 30 # the id of the skill
  146.           return @speech = Speech[:fire] #the text
  147.           when 20 #another id
  148.             return @speech = Speech[:water] # the text again
  149.         end
  150.     end
  151.  
  152. #----------------------------------------------------------------------------
  153. # ○ new method: draw_speech
  154. #----------------------------------------------------------------------------
  155.    
  156.    def create_text
  157.      @text = Sprite.new
  158.      @text.bitmap = Bitmap.new(200,40)
  159.      @text.z = 300
  160.       @text.bitmap.font.name = BattleFont[:fontName]
  161.       @text.bitmap.font.size = BattleFont[:fontSize]
  162.       @text.bitmap.font.bold = false
  163.       @text.bitmap.font.italic = true
  164.      @text.x = self.x
  165.      @text.y = self.y
  166.   #   refresh
  167.    end
  168.    
  169.    def draw_speech
  170.       if @speech != ""
  171.        
  172.        # refresh
  173.       end
  174.     end
  175.    
  176.      
  177.  
  178.       def refresh
  179.         try = @speech
  180.        @text.bitmap.clear
  181.     #   @text.bitmap.font.color = Color.new(255,255,255,0)
  182.         @text.bitmap.draw_text(6,4,190,32,try,0)
  183.       end
  184.      
  185. end
  186. #===============================================================================
  187. # => END : Sprite_Speech
  188. #===============================================================================
  189.  
  190. #==============================================================================
  191. # ■ Scene_Battle
  192. #------------------------------------------------------------------------------
  193. #  This class performs battle screen processing.
  194. #==============================================================================
  195.  
  196. class Scene_Battle < Scene_Base
  197.  
  198.     alias neo_start start
  199.     def start
  200.         neo_start
  201.         create_speech_popup
  202.     end
  203.  
  204. #----------------------------------------------------------------------------
  205. # ○ new method: execute_inverti_slide {in vertical slide effect}
  206. #----------------------------------------------------------------------------
  207.     def create_speech_popup
  208.         @battlespeech = Sprite_Speech.new(@viewport1)
  209.     end
  210.  
  211.     alias neo_update_basic update_basic
  212.     def update_basic
  213.         neo_update_basic
  214.         update_speech
  215.     end
  216. #----------------------------------------------------------------------------
  217. # ○ new method: execute_inverti_slide {in vertical slide effect}
  218. #----------------------------------------------------------------------------
  219.     def update_speech
  220.         @battlespeech.update
  221.     end
  222.  
  223.   #--------------------------------------------------------------------------
  224.   # * Processing at End of Action
  225.   #--------------------------------------------------------------------------
  226.   def process_action_end
  227.     @subject.on_action_end
  228.      status_redraw_target(@subject)
  229.     refresh_popup
  230.     @log_window.display_auto_affected_status(@subject)
  231.     @log_window.wait_and_clear
  232.     @log_window.display_current_state(@subject)
  233.     @log_window.wait_and_clear
  234.     BattleManager.judge_win_loss
  235.   end
  236.  
  237.   #--------------------------------------------------------------------------
  238.   # * Execute Battle Actions
  239.   #--------------------------------------------------------------------------
  240.   def execute_action
  241.     @subject.sprite_effect_type = :whiten if YEA::BATTLE::FLASH_WHITE_EFFECT
  242.     draw_popup
  243.     use_item
  244.     @log_window.wait_and_clear
  245.   end
  246.  
  247. #----------------------------------------------------------------------------
  248. # ○ new method: execute_inverti_slide {in vertical slide effect}
  249. #----------------------------------------------------------------------------
  250.   def draw_popup
  251.     item = @subject.current_action.item
  252.     if item.is_a?(RPG::Skill)
  253.       show_popup(item.id)
  254.       @battlespeech.update_speech
  255.       @battlespeech.refresh
  256.     end
  257.   end
  258.  
  259. #----------------------------------------------------------------------------
  260. # ○ new method: execute_inverti_slide {in vertical slide effect}
  261. #----------------------------------------------------------------------------
  262.   def show_popup(item)
  263.     @battlespeech.speech=(item)
  264.   end
  265. #----------------------------------------------------------------------------
  266. # ○ new method: execute_inverti_slide {in vertical slide effect}
  267. #----------------------------------------------------------------------------
  268.   def refresh_popup
  269.     @battlespeech.clear_speech
  270.   end
  271. end
  272. #===============================================================================
  273. # => END : Scene_Battle
  274. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement