vindaca510

Custom Tags v1.0

Aug 4th, 2014
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 17.17 KB | None | 0 0
  1.  
  2. ################################################################################
  3. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  4. #↓                                                                            ↓#
  5. #↓                         Custom Tags: Version 0.1                           ↓#
  6. #↓                                                                            ↓#
  7. #↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕#
  8. #↑                                                                            ↑#
  9. #↑                            Written By: Joe Pro                             ↑#
  10. #↑                        Last Edited:  July 31, 2014                         ↑#
  11. #↑                                                                            ↑#
  12. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  13. ################################################################################
  14.  
  15. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  16. #◙ ** Disclaimer                                                              ◙#
  17. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  18. #◙                                                                            ◙#
  19. #◙ This script is not for commercial, if you wish to use this script in a     ◙#
  20. #◙ game please PM me. All credit is to be given to me as the author of this   ◙#
  21. #◙ script.                                                                    ◙#
  22. #◙                                                                            ◙#
  23. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  24. #◙ ** How To Use                                                              ◙#
  25. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  26. #◙                                                                            ◙#
  27. #◙ * Use the example below in an any notebox to create a tag.                 ◙#
  28. #◙                                                                            ◙#
  29. #◙    tag: "Tag_Description", "Tag_Info"                                      ◙#
  30. #◙                                                                            ◙#
  31. #◙                                                                            ◙#
  32. #◙ * You can check the value of $game_party.battle_members[0] tags            ◙#
  33. #◙   by using the following method.                                           ◙#
  34. #◙                                                                            ◙#
  35. #◙   tag?("Tag_Description")                                                  ◙#
  36. #◙                                                                            ◙#
  37. #◙ * You can check the value of $game_actors[x], $game_party.members[x]       ◙#
  38. #◙   or $game_party.battle_members[x] tags by using the following method.     ◙#
  39. #◙                                                                            ◙#
  40. #◙   actor_tag?(actor, "Tag_Description")                                     ◙#
  41. #◙                                                                            ◙#
  42. #◙ * You can check the value of $data_actors[x], $data_weapons[x],            ◙#
  43. #◙   $data_armors[x], $data_items[x], $data_enemies[x] tags by using the      ◙#
  44. #◙   following method.                                                        ◙#
  45. #◙      data_types are as follows;                                            ◙#
  46. #◙         0 = Actors                                                         ◙#
  47. #◙         1 = Weapons                                                        ◙#
  48. #◙         2 = Armors                                                         ◙#
  49. #◙         3 = Items                                                          ◙#
  50. #◙         4 = Enemies                                                        ◙#
  51. #◙                                                                            ◙#
  52. #◙   data_tag?(data_type, ID, "Tag_Description")                              ◙#
  53. #◙                                                                            ◙#
  54. #◙ * You can change the value of $game_party.battle_members[0] tags by        ◙#
  55. #◙   using the following method, you can also assign the new value to         ◙#
  56. #◙   $game_variables.                                                         ◙#
  57. #◙                                                                            ◙#
  58. #◙   change_tag(handler, new_value)                                           ◙#
  59. #◙                                                                            ◙#
  60. #◙ * You can change the value of $game_actors[x], $game_party.members[x]      ◙#
  61. #◙   or $game_party.battle_members[x] tags by using the following method,     ◙#
  62. #◙   you can also assign the new value to $game_variables.                    ◙#
  63. #◙                                                                            ◙#
  64. #◙   change_actor_tag(actor, handler, new_value)                              ◙#
  65. #◙                                                                            ◙#
  66. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  67. #◙ ** Updates / Version Notes                                                 ◙#
  68. #◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙#
  69. #◙                                                                            ◙#
  70. #◙   v0.1                                                                     ◙#
  71. #◙ ~◄◙◙◙◙►~                                                                   ◙#
  72. #◙ * This script allows create as many and whatever tags for characters       ◙#
  73. #◙   weapons, armors, items and enemies as you want to. Gender, Race,         ◙#
  74. #◙   Height, Weight, ID.. These are just a few examples. Actors tags are      ◙#
  75. #◙   saved and can be changed through out the game.                           ◙#
  76. #◙                                                                            ◙#
  77. #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
  78.  
  79.  
  80.  
  81. ################################################################################
  82. #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
  83. #↓                                                                            ↓#
  84. #↕                          Custom Tags: Version 0.1                          ↕#
  85. #↑                                                                            ↑#
  86. #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
  87. ################################################################################
  88.  
  89.  
  90.  
  91. #==============================================================================
  92. # ** RPG::Actor < RPG::BaseItem
  93. #------------------------------------------------------------------------------
  94. #  The Data Class for actors.
  95. #==============================================================================
  96.  
  97. class RPG::Actor < RPG::BaseItem
  98.  
  99.   #--------------------------------------------------------------------------
  100.   # * Get All Weapon's Tags
  101.   #--------------------------------------------------------------------------
  102.   def tags
  103.     return self.note.scan(/tag:\s*(\w*)\S*\s*(\S*)/im)
  104.   end
  105.  
  106. end
  107.  
  108.  
  109. #==============================================================================
  110. # ** RPG::Weapon < RPG::EquipItem
  111. #------------------------------------------------------------------------------
  112. #  The Data Class for weapons.
  113. #==============================================================================
  114.  
  115. class RPG::Weapon < RPG::EquipItem
  116.  
  117.   #--------------------------------------------------------------------------
  118.   # * Get All Weapon's Tags
  119.   #--------------------------------------------------------------------------
  120.   def tags
  121.     return self.note.scan(/tag:\s*(\w*)\S*\s*(\S*)/im)
  122.   end
  123.  
  124.   #--------------------------------------------------------------------------
  125.   # * Return Weapon's Tag Value by Index
  126.   #--------------------------------------------------------------------------
  127.   def tag?(handler)
  128.     tags.each { |tag|
  129.       return tag[1] if tag[0] == handler
  130.     }
  131.   end
  132.  
  133. end
  134.  
  135.  
  136. #==============================================================================
  137. # ** RPG::Armor < RPG::EquipItem
  138. #------------------------------------------------------------------------------
  139. #  The Data Class for Armors.
  140. #==============================================================================
  141.  
  142. class RPG::Armor < RPG::EquipItem
  143.  
  144.   #--------------------------------------------------------------------------
  145.   # * Get All Armor's Tags
  146.   #--------------------------------------------------------------------------
  147.   def tags
  148.     return self.note.scan(/tag:\s*(\w*)\S*\s*(\S*)/im)
  149.   end
  150.  
  151.   #--------------------------------------------------------------------------
  152.   # * Return Weapon's Tag Value by Index
  153.   #--------------------------------------------------------------------------
  154.   def tag?(handler)
  155.     tags.each { |tag|
  156.       return tag[1] if tag[0] == handler
  157.     }
  158.   end
  159.  
  160. end
  161.  
  162.  
  163. #==============================================================================
  164. # ** RPG::Item < RPG::UsableItem
  165. #------------------------------------------------------------------------------
  166. #  The Data Class for Items.
  167. #==============================================================================
  168.  
  169. class RPG::Item < RPG::UsableItem
  170.  
  171.   #--------------------------------------------------------------------------
  172.   # * Get All Item's Tags
  173.   #--------------------------------------------------------------------------
  174.   def tags
  175.     return self.note.scan(/tag:\s*(\w*)\S*\s*(\S*)/im)
  176.   end
  177.  
  178.   #--------------------------------------------------------------------------
  179.   # * Return Weapon's Tag Value by Index
  180.   #--------------------------------------------------------------------------
  181.   def tag?(handler)
  182.     tags.each { |tag|
  183.       return tag[1] if tag[0] == handler
  184.     }
  185.   end
  186.  
  187. end
  188.  
  189.  
  190. #==============================================================================
  191. # ** RPG::Enemy < RPG::BaseItem
  192. #------------------------------------------------------------------------------
  193. #  The Data Class for Enemies.
  194. #==============================================================================
  195.  
  196. class RPG::Enemy < RPG::BaseItem
  197.  
  198.   #--------------------------------------------------------------------------
  199.   # * Get All Enemy Tags
  200.   #--------------------------------------------------------------------------
  201.   def tags
  202.     return self.note.scan(/tag:\s*(\w*)\S*\s*(\S*)/im)
  203.   end
  204.  
  205.   #--------------------------------------------------------------------------
  206.   # * Return Weapon's Tag Value by Index
  207.   #--------------------------------------------------------------------------
  208.   def tag?(handler)
  209.     tags.each { |tag|
  210.       return tag[1] if tag[0] == handler
  211.     }
  212.   end
  213.  
  214. end
  215.  
  216.  
  217. #==============================================================================
  218. # ** Game_Actor
  219. #------------------------------------------------------------------------------
  220. #  This class handles actors. It is used within the Game_Actors class
  221. # ($game_actors) and is also referenced from the Game_Party class ($game_party).
  222. #==============================================================================
  223.  
  224. class Game_Actor < Game_Battler
  225.  
  226.   #--------------------------------------------------------------------------
  227.   # * Public Instance Variables
  228.   #--------------------------------------------------------------------------
  229.   attr_accessor :tags                                              # timers
  230.  
  231.   #--------------------------------------------------------------------------
  232.   # * Aliasing Method: Object Initialization
  233.   #--------------------------------------------------------------------------
  234.   alias :gai1321654654 :initialize
  235.    
  236.   #--------------------------------------------------------------------------
  237.   # * Object Initialization
  238.   #--------------------------------------------------------------------------
  239.   def initialize(*args)
  240.     gai1321654654(*args)
  241.     set_tags
  242.   end
  243.  
  244.   #--------------------------------------------------------------------------
  245.   # * Set Weapon's Tags
  246.   #--------------------------------------------------------------------------
  247.   def set_tags
  248.     @tags = {}
  249.     actor.tags.size.times { |i|
  250.       @tags[actor.tags[i][0]] = actor.tags[i][1]
  251.     }
  252.     @tags
  253.   end
  254.  
  255.   #--------------------------------------------------------------------------
  256.   # * Return Actor Variable's Value by Index
  257.   #--------------------------------------------------------------------------
  258.   def tag?(handler)
  259.     return @tags[handler]
  260.   end
  261.  
  262.   #--------------------------------------------------------------------------
  263.   # * Change Tag Value
  264.   #--------------------------------------------------------------------------
  265.   def change_tag(handler, new_value)
  266.     @tags[handler] = new_value
  267.   end
  268.  
  269. end
  270.  
  271.  
  272. #==============================================================================
  273. # ** Game_Interpreter
  274. #------------------------------------------------------------------------------
  275. #  An interpreter for executing event commands. This class is used within the
  276. # Game_Map, Game_Troop, and Game_Event classes.
  277. #==============================================================================
  278.  
  279. class Game_Interpreter
  280.  
  281.   #--------------------------------------------------------------------------
  282.   # * Returns Data's Tag Value by Index and ID
  283.   #    0 = Acotrs
  284.   #    1 = Weapons
  285.   #    2 = Armors
  286.   #    3 = Items
  287.   #    4 = Enemies
  288.   #--------------------------------------------------------------------------
  289.   def data_tag?(type, id, handler)
  290.     case type
  291.     when 0
  292.       return $data_actors[id].tag?(handler)
  293.     when 1
  294.       return $data_weapons[id].tag?(handler)
  295.     when 2
  296.       return $data_armors[id].tag?(handler)
  297.     when 3
  298.       return $data_items[id].tag?(handler)
  299.     when 4
  300.       return $data_enemies[id].tag?(handler)
  301.     end
  302.   end
  303.  
  304.   #--------------------------------------------------------------------------
  305.   # * Returns Leader's Saved Tag Value by Index
  306.   #--------------------------------------------------------------------------
  307.   def tag?(handler)
  308.     return $game_party.battle_members[0].tags[handler]
  309.   end
  310.  
  311.   #--------------------------------------------------------------------------
  312.   # * Returns Actors's Saved Tag Value by Index
  313.   #--------------------------------------------------------------------------
  314.   def actor_tag?(actor, handler)
  315.     return actor.tags[handler]
  316.   end
  317.  
  318.   #--------------------------------------------------------------------------
  319.   # * Changes Leader's Saved Tag Value by Index
  320.   #--------------------------------------------------------------------------
  321.   def change_tag(handler, new_value)
  322.     $game_party.battle_members[0].tags[handler] = new_value
  323.   end
  324.  
  325.   #--------------------------------------------------------------------------
  326.   # * Changes Actor's Saved Tag Value by Index
  327.   #--------------------------------------------------------------------------
  328.   def change_tag(actor, handler, new_value)
  329.     actor.tags[handler] = new_value
  330.   end
  331.  
  332. end
Advertisement
Add Comment
Please, Sign In to add comment