Advertisement
neonblack

Common Event Pop-ups

Apr 23rd, 2013
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.98 KB | None | 0 0
  1. ##----------------------------------------------------------------------------##
  2. ## Common Event Pop-ups
  3. ## Created by Neon Black
  4. ##
  5. ## For both commercial and non-commercial use as long as credit is given to
  6. ## Neon Black and any additional authors.  Licensed under Creative Commons
  7. ## CC BY 3.0 - http://creativecommons.org/licenses/by/3.0/.
  8. ##----------------------------------------------------------------------------##
  9.                                                                               ##
  10. ##----------------------------------------------------------------------------##
  11. ##    Revision Info:
  12. ## v1.0 - 3.13.2013
  13. ##  Wrote and debugged main script
  14. ##----------------------------------------------------------------------------##
  15.                                                                               ##
  16. $imported ||= {}                                                              ##
  17. $imported["CP_EVENT_POP"] = 1.0                                               ##
  18.                                                                               ##
  19. ##----------------------------------------------------------------------------##
  20. ##    Instructions:
  21. ## Place this script in the script editor below "Materials" and above "Main".
  22. ## This script allows a common event to be called whenever an item or gold is
  23. ## obtained or lost from an event.  The value/amount and name of the item are
  24. ## stored in variables so they can be referenced by a message.  The script can
  25. ## also be enabled/disabled with a switch.
  26. ##----------------------------------------------------------------------------##
  27.                                                                               ##
  28. module CP  # Do not touch                                                     ##
  29. module CEP #  these lines.                                                    ##
  30.                                                                               ##
  31. ##----------------------------------------------------------------------------##
  32. ##    Config:
  33. ## The config options are below.  You can set these depending on the flavour of
  34. ## your game.  Each option is explained in a bit more detail above it.
  35. ##
  36. ##------
  37. # These are the variables used to store the icon/name of an item as well as the
  38. # amount of the item/gold gained or lost.  These values cannot be nil.
  39. Item = 1
  40. Value = 2
  41.  
  42. # These are the common events to play when an item/gold is gained or lost.  You
  43. # can set these to nil if you do not want one to be played.  You can also have
  44. # multiple with the same value, for example, having the same event for items,
  45. # weapons, and armour.
  46. GoldCE = 1
  47. ItemCE = 2
  48. WeaponCE = 2
  49. ArmorCE = 2
  50.  
  51. # This is the switch to enable/disable the script.  While the switch is on, the
  52. # events will play.  While it is off the events will not play.
  53. Switch = 1
  54. ##----------------------------------------------------------------------------##
  55.                                                                               ##
  56.                                                                               ##
  57. ##----------------------------------------------------------------------------##
  58. ## The following lines are the actual core code of the script.  While you are
  59. ## certainly invited to look, modifying it may result in undesirable results.
  60. ## Modify at your own risk!
  61. ###----------------------------------------------------------------------------
  62.  
  63.  
  64. end
  65. end
  66.  
  67. class Game_Interpreter
  68.   alias :cp_42313_125 :command_125
  69.   alias :cp_42313_126 :command_126
  70.   alias :cp_42313_127 :command_127
  71.   alias :cp_42313_128 :command_128
  72.  
  73.   def command_125
  74.     cp_42313_125
  75.     value = operate_value(@params[0], @params[1], @params[2])
  76.     $game_variables[CP::CEP::Value] = value
  77.     common_event_pop(CP::CEP::GoldCE)
  78.   end
  79.  
  80.   def command_126
  81.     cp_42313_126
  82.     value = operate_value(@params[1], @params[2], @params[3])
  83.     item = $data_items[@params[0]]
  84.     $game_variables[CP::CEP::Item] = "\eI[#{item.icon_index}]#{item.name}"
  85.     $game_variables[CP::CEP::Value] = value
  86.     common_event_pop(CP::CEP::ItemCE)
  87.   end
  88.  
  89.   def command_127
  90.     cp_42313_127
  91.     value = operate_value(@params[1], @params[2], @params[3])
  92.     item = $data_weapons[@params[0]]
  93.     $game_variables[CP::CEP::Item] = "\eI[#{item.icon_index}]#{item.name}"
  94.     $game_variables[CP::CEP::Value] = value
  95.     common_event_pop(CP::CEP::WeaponCE)
  96.   end
  97.  
  98.   def command_128
  99.     cp_42313_128
  100.     value = operate_value(@params[1], @params[2], @params[3])
  101.     item = $data_armors[@params[0]]
  102.     $game_variables[CP::CEP::Item] = "\eI[#{item.icon_index}]#{item.name}"
  103.     $game_variables[CP::CEP::Value] = value
  104.     common_event_pop(CP::CEP::ArmorCE)
  105.   end
  106.  
  107.   def common_event_pop(ce)
  108.     return unless ce && $game_switches[CP::CEP::Switch]
  109.     @params[0] = ce
  110.     command_117
  111.   end
  112. end
  113.  
  114.  
  115. ###----------------------------------------------------------------------------
  116. #  End of script.
  117. ###----------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement