Advertisement
diamondandplatinum3

Run Common Event When Equipping an Item ~ RGSS2

Oct 1st, 2012
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.41 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Run Common Event When Equipping an Item
  3. #             Version: 1.0
  4. #             Author: DiamondandPlatinum3
  5. #             Date: September 25, 2012
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script allows you to run a common event when you equip an item, be
  10. #    it a weapon or a piece of armour.
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. #------------------------------------------------------------------------------
  13. #  Instructions:
  14. #    
  15. #     ~  In your weapon and armour noteboxes, insert this line of code
  16. #
  17. #           ~E_COMMONEVENT_ID: ?
  18. #
  19. #        Replacing the ? with a number to represent which common event you
  20. #        want to run when that specific item is equipped.
  21. #
  22. #
  23. #     ~  You do not have to place this code on every weapon and armour you
  24. #        have, just the ones you wish to use a common event on.
  25. #
  26. #
  27. #     ~  There is a visual example that can be found
  28. #        Here: http://img4host.net/upload/242103145060ae72be40a.png
  29. #
  30. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  31. #
  32. #
  33. #                  THERE IS NO EDITABLE REGION TO THIS SCRIPT
  34. #
  35. #==============================================================================
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. class Game_Actor < Game_Battler
  49.   #--------------------------------------------------------------------------
  50.   # * Change Equipment (designate object)
  51.   #     equip_type : Equip region (0..4)
  52.   #     item       : Weapon or armor (nil is used to unequip)
  53.   #     test       : Test flag (for battle test or temporary equipment)
  54.   #--------------------------------------------------------------------------
  55.   alias dp3_equipcommonevent_9jsg4 change_equip
  56.   def change_equip(equip_type, item, test = false)
  57.  
  58.     # Call Original Method
  59.     dp3_equipcommonevent_9jsg4(equip_type, item, test)
  60.    
  61.    
  62.     # Proceed
  63.     item_id = item == nil ? 0 : item.id
  64.     note = nil
  65.    
  66.     if item_id > 0
  67.       if equip_type == 0
  68.         note = $data_weapons[item_id].note
  69.       elsif equip_type > 0
  70.         note = $data_armors[item_id].note
  71.       end
  72.      
  73.       note[/~E_COMMONEVENT_ID: ([-0-9]+)/]
  74.       $game_temp.common_event_id = $1.to_i if $1
  75.     end # If Statement
  76.    
  77.   end # Function
  78. end # Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement