Advertisement
TheSixth

Simple Shop Sell Common Events

Apr 15th, 2018
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.99 KB | None | 0 0
  1. =begin
  2. Shop Sell Common Events
  3. Made by: Sixth
  4.  
  5. Just a very short snippet for allowing sold items to trigger common events.
  6.  
  7. Use this note-tag:
  8.  
  9.   <ce trigger: comon_event_id>
  10.  
  11. Replace the common_event_id with the ID of the... common event you want to
  12. trigger when the item is sold.
  13. You can use this note-tag on items, weapons and armors.
  14.  
  15. Note that the common event will run only after the event that triggered the shop
  16. actually ends.
  17.  
  18. =end
  19.  
  20. class RPG::BaseItem
  21.  
  22.   attr_accessor :ce_trigger
  23.  
  24.   def ce_trigger
  25.     init_ce_trigger if @ce_trigger.nil?
  26.     return @ce_trigger
  27.   end
  28.  
  29.   def init_ce_trigger
  30.     @ce_trigger = @note =~ /<ce trigger:(?:\s*)(\d+)>/i ? $1.to_i : 0
  31.   end
  32.  
  33. end
  34.  
  35. class Scene_Shop < Scene_MenuBase
  36.  
  37.   alias add_ce_trigger6614 do_sell
  38.   def do_sell(num)
  39.     add_ce_trigger6614(num)
  40.     if @item.ce_trigger > 0
  41.       $game_temp.reserve_common_event(@item.ce_trigger)
  42.       SceneManager.goto(Scene_Map)
  43.     end
  44.   end
  45.  
  46. end
  47. # End of script! o.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement