estriole

EST - EFFECT SCENE GOLDEN TOUCH

Mar 29th, 2013
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.95 KB | None | 0 0
  1. =begin
  2. #==============================================================================
  3.  ** Effect: Golden Touch
  4.  Author: Tsukihime
  5.  Date: Oct 30, 2012
  6.  HEAVILY MODDED by Estriole (almost rewrite it in fact >.<)
  7.  you must credit me Tsukihime and Estriole if you're using it
  8.  
  9.  requirement :
  10.   -Tsukihime Effect Manager
  11.   (http://xtsukihime.wordpress.com/2012/10/05/effects-manager)
  12.  -Yanfly Gab Window
  13.  -Estriole Effect Scene Core
  14.  
  15. ------------------------------------------------------------------------------
  16.  ** Change log
  17.  v1.1 Nov 05, 2012
  18.    - Split the script and make the Effect Scene Core so now any scene
  19.      can work fine in victor animated battle (of course must be set the last
  20.      skill executed). with the core scene equip, scene party could be possible
  21.      to use with victor animated battle
  22.    - Estriole effect scene core also repair problem with turn restart to 1
  23.  v1.0 Nov 04, 2012
  24.    - modded so it can work as normal scene call
  25.    - heavily modded so work in battle using victor animated battle
  26.      (but don't forget to set the speed fix to make the skill act last)
  27.    - compatibility with moghunter popup damage script
  28.    - compatibility with yami combo count script
  29.    - compatibility with yanfly enemy hp bar script
  30.    - compatibility with mog wallpaper ex script
  31.    
  32.  v0.1 Nov 03, 2012
  33.    - modded by estriole
  34.  
  35.  Oct 30, 2012
  36.    - initial release
  37. ------------------------------------------------------------------------------  
  38.  ** Terms of Use
  39.  * Free to use in commercial/non-commercial projects
  40.  * No real support. The script is provided as-is
  41.  * Will do bug fixes, but no compatibility patches
  42.  * Features may be requested but no guarantees, especially if it is non-trivial
  43.  * Preserve this header
  44. ------------------------------------------------------------------------------
  45.  ** Required
  46.  -Tsukihime Effect Manager
  47.   (http://xtsukihime.wordpress.com/2012/10/05/effects-manager)
  48.  -Yanfly Gab Window
  49.  -Estriole Effect Scene Core
  50. ------------------------------------------------------------------------------
  51.  ** Description
  52.  
  53.  This script adds a "golden touch" effect to your skill.
  54.  When this effect is activated, you can select an item from your inventory
  55.  and turn it into gold.
  56.  
  57.  The amount of gold received is based on the price of the item times the
  58.  multiplier of the effect.
  59.  
  60.  Tag your item/skills with
  61.     <eff: golden_touch x>
  62.    
  63.  Where x is some float representing the gold multiplier
  64.  
  65.  estriole mod -  could become scene
  66.  can be used as scene also (for sell only shop event?)
  67.  - golden touch also could be called as scene by using script call
  68.  SceneManager.call(Scene_GoldenTouch)
  69.  by default it will use 1.0 multiplier if you want to change that
  70.  use script call:
  71.  $game_temp.golden_touch_multiplier = x
  72.  where x is float or integer
  73.  if the scene called by skill using effect notetag above. the multiplier will
  74.  follow the skill setting instead and ignore other.
  75.  
  76.  estriole mod - use in victor animated battle
  77.  set the notetags. then set the skill speed fix to make the skill act last
  78.  because after returning from scene any action after the actor calling the
  79.  scene will not executed.
  80.  and if you're using other script that i'm not making compatibility with...
  81.  the compatibility i made is only for hiding the naughty images that still
  82.  shown when changing scene (because i don't dispose them - because i can't)
  83.  
  84.  so if you're planning make compatibility yourself... (since i maybe
  85.  won't make it if i'm not using that script)
  86.  
  87.  remember that you must not dispose any object that shown in the battle if you can.
  88.  you must just change the visible to false or opacity to 0 (depending the type).
  89.  
  90. #==============================================================================
  91. =end
  92. module Effects
  93.   module Golden_Touch
  94.     Effect_Manager.register_effect(:golden_touch, 1.6)
  95.   end
  96. end
  97.  
  98. module ESTRIOLE
  99.   TEXT_GOLDEN_TOUCH_GAINED_MONEY = "You reconstruct %s and turn it to %d %s!"
  100.   #by order %s %d %s -> item name, money number, gold vocab
  101.   TEXT_GOLDEN_TOUCH_CANNOT_CONVERT = "<cannot reconstruct>"
  102.   TEXT_GOLDEN_TOUCH_VALUE_SHOW = "%s\nValue: %d gold"
  103. end
  104.  
  105. class RPG::UsableItem
  106.  
  107.   # Check whether the operator is valid
  108.   def add_effect_golden_touch(code, data_id, args)
  109.     args[0] = args[0] ? args[0].to_f : 1
  110.     add_effect(code, data_id, args)
  111.   end
  112. end
  113.  
  114. class Game_Temp
  115.   attr_accessor :golden_touch_multiplier
  116. end
  117.  
  118. class Game_Battler < Game_BattlerBase  
  119.   def item_effect_golden_touch_global(user,target,effect)
  120.     SceneManager.scene.call_scene(Scene_GoldenTouch, :effect_golden_touch, effect)
  121.   end
  122. end
  123.  
  124. # Just a custom window for my effect
  125. class Window_ItemList_GoldenTouch < Window_ItemList
  126.  
  127.   # everything should be available for almost everything
  128.   def enable?(item)
  129.     return false if item.is_a?(RPG::Item) && item.key_item?
  130.     return false if item.is_a?(RPG::Item) && item.price == 0 #will not convert item with 0 price
  131.     return true
  132.   end
  133.  
  134.   # Let's just show the price of the item
  135.   def update_help
  136.     return unless item
  137.     name = item.name
  138.     if item.price == 0 || item.key_item?
  139.     @help_window.set_text(ESTRIOLE::TEXT_GOLDEN_TOUCH_CANNOT_CONVERT)
  140.     else
  141.     text = sprintf(ESTRIOLE::TEXT_GOLDEN_TOUCH_VALUE_SHOW,name,item.price)    
  142.     @help_window.set_text(text)
  143.     end
  144.   end
  145. end
  146.  
  147. # A new scene for selecting an item for the effect
  148.  
  149. class Scene_GoldenTouch < Scene_Item  
  150.  
  151. #~   def effect_scene_mark
  152. #~   return true
  153. #~   end
  154.  
  155. #~   def return_scene
  156. #~     effect_return_scene
  157. #~   end
  158.  
  159.   def create_item_window
  160.     wy = @category_window.y + @category_window.height
  161.     wh = Graphics.height - wy
  162.     @gab_window = Window_Gab.new
  163.     @gab_window.z = 200 #to put the order on top other window
  164.     @gab_window.y += 300 #move the gab window to bottom
  165.     @item_window = Window_ItemList_GoldenTouch.new(0, wy, Graphics.width, wh)
  166.     @item_window.viewport = @viewport
  167.     @item_window.help_window = @help_window
  168.     @item_window.set_handler(:ok,     method(:on_item_ok))
  169.     @item_window.set_handler(:cancel, method(:on_item_cancel))
  170.     @category_window.item_window = @item_window
  171.   end
  172.    
  173.   def on_item_ok
  174.     if @effect_callback
  175.     send(@effect_callback)
  176.     elsif $game_temp.golden_touch_multiplier
  177.     effect_golden_touch($game_temp.golden_touch_multiplier)
  178.     else
  179.     effect_golden_touch(1.0)
  180.     end
  181.     @item_window.refresh
  182.     @item_window.activate
  183.     #back to window after converting one item for more converting
  184.   end
  185.  
  186.   def effect_golden_touch(rate = 1)
  187.     return if item.nil? #escape code when you convert the last of the item and click again
  188.     gained = item.price * rate
  189.     gained = item.price * @effect.value1[0] if @effect_callback
  190.     name   = item.name
  191.     $game_party.gain_gold(gained.to_i)
  192.     $game_party.lose_item(item, 1)
  193.     text = sprintf(ESTRIOLE::TEXT_GOLDEN_TOUCH_GAINED_MONEY,name,gained.to_i,Vocab.currency_unit)
  194.     @gab_window.clear
  195.     @gab_window.setup(text,nil,nil)
  196.  
  197.   end
  198. end
Advertisement
Add Comment
Please, Sign In to add comment