TheoAllen

YEA - Dynamic VA english

May 6th, 2014
1,328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.59 KB | None | 0 0
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Dynamic Victory Aftermath (Addon)
  4. # -- Level: Normal, Hard
  5. # -- Requires: YEA - Victory Aftermath
  6. #
  7. #------------------------------------------------------------------------------
  8. #
  9. # Edited by : TheoAllen
  10. # Version : 1.0
  11. # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
  12. # (English Documentation)
  13. #
  14. #==============================================================================
  15. $imported = {} if $imported.nil?
  16. if $imported["YEA-VictoryAftermath"]
  17. $imported[:Theo_DynamicYEA_VA] = true
  18. #==============================================================================
  19. =begin
  20.  
  21.   Introduction :
  22.   It is an addon to Yanfly Victory Aftermath. So you could change the actor's
  23.   quote dynamically. Such as changing faceset or some quotes that only appears
  24.   on a certain condition.
  25.  
  26.   How to use :
  27.   Put this script below Yanfly Victory Aftermath
  28.   These are notetag you could use
  29.  
  30.   <win: Constant>
  31.   <level: Constant>
  32.   <drops: Constant>
  33.  
  34.   Constant is a constanta name you define below this editable area. The
  35.   explanation is written down below
  36.  
  37. =end
  38. #=============================================================================
  39. # Editable region
  40. #=============================================================================
  41. module TLZ # <-- Do not touch at all cost!
  42.  
  43.   # --------------------------------------------------------------------------
  44.   # Time wait in frame before victory aftermath is displayed. I'm doing this
  45.   # is for displaying victory pose sequence for my battle system
  46.   # --------------------------------------------------------------------------
  47.   Wait = 160
  48.  
  49.   # ==========================================================================
  50.   # Here the explanations of making new quotes
  51.   # Format :
  52.   # --------------------------------------------------------------------------
  53.   # Quote = [
  54.   # ["face_name", face_index, "text","condition"],
  55.   # ]
  56.   #
  57.   # Explanation :
  58.   # Quote >> Constanta name you call it in notetag. The first letter have to
  59.   #          be capitalized. For example, you add the Ralph_Win, then the
  60.   #          notetag parameter would be <win: Ralph_Win>
  61.   # face_name >> Faceset name that will be used. Just leave it empty if you
  62.   #              want to use the currently used actor faceset
  63.   # face_index >> Faceset index. From the top-left corner till bottom right
  64.   #               corner is around 0 - 7
  65.   # text >> Texts which will be displayed in victory aftermath. Add \n if
  66.   #         you want to separate the line
  67.   # condition >> Script eval condition. If you want to display the quote
  68.   #              despite in any conditions, just write "true"
  69.   # ==========================================================================
  70.  
  71.   # --------------------------------------------------------------------------
  72.   # Please note that these sample quotes are based from my game. So make your
  73.   # own then
  74.   # --------------------------------------------------------------------------
  75.  
  76.   Stella_Quotes = [
  77.   ["Actor28_ex",3,"Haha... Sorry...","true"],
  78.   ["Actor28_ex",3,"Did you see that? Did you see that I shot" +
  79.     "\nthree bullets in single shot?","true"],
  80.   ["Actor28_ex",3,"Ha. Bull's eye!","true"],
  81.   ["",4,"Fuuhh.... That was so close...","hp_rate <= 0.5"],
  82.   ["",7,"Darn. That one almost messed my hair...","true"],
  83.   ["",1,"Did you hear me? I told you, \nheads down!","true"],
  84.   ["",7,"So, do you dare to challenge a \nmarksman like me again?", "true"],
  85.   ]
  86.  
  87.   # --------------------------------------------------------------------------
  88.  
  89.   Stella_Level = [
  90.   ["Actor28_ex",3,"I got better aim, better shot...","true"],
  91.   ]
  92.  
  93.   # --------------------------------------------------------------------------
  94.  
  95.   Stella_Drops = [
  96.   ["",1,"That's MINE!!","true"],
  97.   ["Actor28_ex",3,"Hey! That's golds!","true"],
  98.   ["Actor28_ex",3,"Wah... Health Potion!",
  99.     "$game_temp.drops.include?($data_items[1])"],
  100.   ["Actor28_ex",2,"Wow! We got a bunch of these!",
  101.     "$game_temp.drops.size > 2"],
  102.   ]
  103.  
  104.   # --------------------------------------------------------------------------
  105.  
  106.   Lunar_Quotes = [
  107.   ["",0,"You're ten years too early to \nchallenge me.","hp_rate > 0.5"],
  108.   ["",7,"Was that magic... awesome?","true"],
  109.   ["",5,"Whoever created this place, he \nmust be nuts...",
  110.     "hp_rate <= 0.45"],
  111.   ["",3,"Good thing that I'm here...","true"],
  112.   ]
  113.  
  114.   Lunar_Level = [
  115.   ["",7,"Experience is the best mentor.","true"],
  116.   ]
  117.  
  118.   Lunar_Drops = [
  119.   ["",3,"Get them already, then...","true"],
  120.   ["",7,"Health Potion,\\. not bad",
  121.     "$game_temp.drops.include?($data_items[1])"],
  122.   ]
  123.  
  124.   # --------------------------------------------------------------------------
  125.  
  126.   Soleil_Quotes = [
  127.   ["Actor63_ex",0,"Haha. Not bad!","true"],
  128.   ["Actor63_ex",4,"Woi, Stella.\. Mind if you don't \naim it to my back again?","true"],
  129.   ["Actor63_ex",6,"Hah, is that all?","$game_troop.turn_count <= 2"],
  130.   ["Actor63_ex",3,"I've got used with dungeons like \nthis one.",
  131.     "true"],
  132.   ["",1,"C'mon, Lunar! Did you even heal me?","hp_rate <= 0.5"],
  133.   ["",1,"C'mon! Who's next?!","hp_rate > 0.5"],
  134.   ["",0,"Not bad....","true"],
  135.   ["",7,"Good game, well played....","true"],
  136.   ]
  137.  
  138.   Soleil_Level = [
  139.   ["",7,"The deeper this place, the more \ninteresting it is.","true"],
  140.   ]
  141.  
  142.   Soleil_Drops = [
  143.   ["",3,"Shut up! Let me take these.","true"],
  144.   ["",7,"Well, not bad...","true"],
  145.   ["",6,"Well\\..\\..\\.. nothing. Nothing.",
  146.     "$game_temp.drops.empty?"],
  147.   ["Actor63_ex",2,"You reap what you killed. Bleh!",
  148.     "$game_temp.drops.size >= 2"],
  149.   ]
  150.  
  151.   # --------------------------------------------------------------------------
  152.   # Regular expression to read notetags. Do not touch if you don't have any
  153.   # idea about it.
  154.   # --------------------------------------------------------------------------
  155.   WinQuoteREGX    = /<win\s*:\s*(.+)>/i
  156.   LevelQuoteREGX  = /<level\s*:\s*(.+)>/i
  157.   DropsQuoteREGX  = /<drops\s*:\s*(.+)>/i
  158.   # --------------------------------------------------------------------------
  159.  
  160. end
  161. # ============================================================================
  162. # End of editable region. Editing below this point is your own risk.
  163. # ============================================================================
  164. class RPG::Actor
  165.   attr_accessor :tlz_win
  166.   attr_accessor :tlz_level
  167.   attr_accessor :tlz_drops
  168.  
  169.   def load_actor_quotes
  170.     note.split(/[\r\n]+/).each do |line|
  171.       case line
  172.       when TLZ::WinQuoteREGX
  173.         @tlz_win = $1.to_s
  174.       when TLZ::LevelQuoteREGX
  175.         @tlz_level = $1.to_s
  176.       when TLZ::DropsQuoteREGX
  177.         @tlz_drops = $1.to_s
  178.       end
  179.     end
  180.   end
  181.  
  182. end
  183.  
  184. class << DataManager
  185.  
  186.   alias yea_va_tlz_load_db load_database
  187.   def load_database
  188.     yea_va_tlz_load_db
  189.     load_tlz_va_quotes
  190.   end
  191.  
  192.   def load_tlz_va_quotes
  193.     $data_actors.compact.each do |actor|
  194.       actor.load_actor_quotes
  195.     end
  196.   end
  197.  
  198. end
  199.  
  200. class Game_Temp
  201.   attr_accessor :drops
  202.  
  203.   alias yea_va_tlz_init initialize
  204.   def initialize
  205.     yea_va_tlz_init
  206.     @drops = []
  207.   end
  208.  
  209. end
  210.  
  211. class Game_Actor < Game_Battler
  212.  
  213.   def tlz_win_quotes
  214.     ary = eval("TLZ::#{actor.tlz_win}").select do |quote|
  215.       eval(quote[3])
  216.     end
  217.     return ary[rand(ary.size)]
  218.   end
  219.  
  220.   def tlz_level_quotes
  221.     ary = eval("TLZ::#{actor.tlz_level}").select do |quote|
  222.       eval(quote[3])
  223.     end
  224.     return ary[rand(ary.size)]
  225.   end
  226.  
  227.   def tlz_drops_quotes
  228.     ary = eval("TLZ::#{actor.tlz_drops}").select do |quote|
  229.       eval(quote[3])
  230.     end
  231.     return ary[rand(ary.size)]
  232.   end
  233.  
  234.   def win_type_defined?(type)
  235.     case type
  236.     when :win
  237.       return !actor.tlz_win.nil?
  238.     when :level
  239.       return !actor.tlz_level.nil?
  240.     when :drops
  241.       return !actor.tlz_drops.nil?
  242.     end
  243.   end
  244.  
  245.   def tlz_victory_quotes(type)
  246.     case type
  247.     when :win
  248.       return tlz_win_quotes
  249.     when :level
  250.       return tlz_level_quotes
  251.     when :drops
  252.       return tlz_drops_quotes
  253.     end
  254.   end
  255.  
  256. end
  257.  
  258. class << BattleManager
  259.  
  260.   alias yea_va_tlz_set_victory_text set_victory_text
  261.   def set_victory_text(actor, type)
  262.     return yea_va_tlz_set_victory_text(actor, type) unless
  263.       actor.win_type_defined?(type)
  264.     return tlz_va_text(actor, type)
  265.   end
  266.  
  267.   def tlz_va_text(actor, type)
  268.     array = actor.tlz_victory_quotes(type)
  269.     text = "" + sprintf(YEA::VICTORY_AFTERMATH::HEADER_TEXT, actor.name)
  270.     text += array[2]
  271.     text += YEA::VICTORY_AFTERMATH::FOOTER_TEXT
  272.     $game_message.face_name = (array[0].empty? ? actor.face_name : array[0])
  273.     $game_message.face_index = array[1]
  274.     $game_message.add(text)
  275.     wait_for_message
  276.   end
  277.  
  278.   alias tlz_display_exp display_exp
  279.   def display_exp
  280.     SceneManager.scene.va_wait(TLZ::Wait)
  281.     tlz_display_exp
  282.   end
  283.  
  284.   #--------------------------------------------------------------------------
  285.   # overwrite method: self.gain_drop_items
  286.   #--------------------------------------------------------------------------
  287.   def gain_drop_items
  288.     drops = []
  289.     $game_troop.make_drop_items.each do |item|
  290.       $game_party.gain_item(item, 1)
  291.       drops.push(item)
  292.     end
  293.     $game_temp.drops = drops
  294.     SceneManager.scene.show_victory_spoils($game_troop.gold_total, drops)
  295.     set_victory_text(@victory_actor, :drops)
  296.     wait_for_message
  297.   end
  298.  
  299. end
  300.  
  301. class Scene_Battle
  302.  
  303.   def va_wait(dur)
  304.     dur.times do
  305.       if Input.trigger?(:C)
  306.         Input.update
  307.         break
  308.       end
  309.       update_basic
  310.     end
  311.   end
  312.  
  313. end
  314.  
  315. end
Advertisement
Add Comment
Please, Sign In to add comment