Bigace360

Module RPG::BaseItem [RMXP]

May 2nd, 2012
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.22 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  2. # ■ Module RPG::BaseItem [RMXP]
  3. # ■ Author: Bigace360
  4. # ■ Date: May 2, 2012
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  6. # This script was designed to act as a parent class for Skills, Item, Weapon,
  7. # and Armor classes. This superclass is based off RMVX version of RPG::BaseItem
  8. # class. This is a script for developers, not non-scripters.  
  9. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  10. # ■ Module RPG::BaseItem (Superclass of Skill, Item, Weapon, and Armor.)
  11. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  12. module RPG
  13.     class BaseItem
  14.         attr_accessor :id, :name, :icon_name, :description     
  15.         def initialize
  16.             @id = 0
  17.             @name = ""
  18.             @icon_name = ""
  19.             @description = ""
  20.         end
  21.     end
  22.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  23.     # ■ Module RPG::UsableItem (Superclass of Skill and Item.)
  24.     # ■ Methods
  25.     # ●  for_opponent?
  26.     # Determines whether or not the area of effect is enemies. Returns true if  
  27.     # the value of scope is 1 or 2.
  28.     # ●  for_friend?
  29.     # Determines whether or not the area of effect is allies. Returns true if
  30.     # the value of scope is 3, 4, 5, 6, or 7.
  31.     # ●  for_dead_friend?
  32.     # Determines whether or not the area of effect is downed allies. Returns
  33.     # true if the value of scope is 5 or 6.
  34.     # ●  for_user?
  35.     # Determines whether or not the area of effect is the user. Returns true if
  36.     # the value of scope is 7.
  37.     # ●  for_one?
  38.     # Determines whether or not the area of effect is one character. Returns
  39.     # true if the value of scope is 1, 3, 5, or 7.
  40.     # ●  for_all?
  41.     # Determines whether or not the area of effect is everyone. Returns true if
  42.     # the value of scope is 2, 4, or 6.
  43.     # ●  battle_ok?
  44.     # Determines if it may be used on the battle screen. Returns true if the
  45.     # value of occasion is 0 or 1.
  46.     # ●  menu_ok?
  47.     # Determines if it may be used on the menu screen. Returns true if the value
  48.     # of occasion is 0 or 2.
  49.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  50.     class UsableItem < BaseItem
  51.         attr_accessor :scope, :occasion, :animation1_id, :animation2_id, :menu_se
  52.         attr_accessor :common_event_id, :hit, :pdef_f, :mdef_f, :variance
  53.         attr_accessor :element_set, :plus_state_set, :minus_state_set
  54.         def initialize
  55.             super
  56.             @scope = 0
  57.             @occasion = 0
  58.             @animation1_id = 0
  59.             @animation2_id = 0
  60.             @menu_se = RPG::AudioFile.new("", 80)
  61.             @common_event_id = 0
  62.             @hit = 100
  63.             @pdef_f = 0
  64.             @mdef_f = 0
  65.             @variance = 0
  66.             @element_set = []
  67.             @plus_state_set = []
  68.             @minus_state_set = []
  69.         end
  70.         # Scope
  71.         # 0: none
  72.         # 1: one enemy
  73.         # 2: all enemies
  74.         # 3: one ally
  75.         # 4: all allies
  76.         # 5: 1 ally--HP 0
  77.         # 6: all allies--HP 0
  78.         # 7: the user
  79.         def for_opponent?;    return [1,2].include?(@scope);       end 
  80.         def for_friend?;      return [3,4,5,6,7].include?(@scope); end
  81.         def for_dead_friend?; return [5,6].include?(@scope);       end
  82.         def for_user?;        return [7].include?(@scope);         end
  83.         def for_one?;         return [1,3,5,7].include?(@scope);   end
  84.         def for_all?;         return [2,4,6].include?(@scope);     end
  85.         # occasion
  86.         # 0: always
  87.         # 1: only in battle
  88.         # 2: only from the menu
  89.         # 3: never
  90.         def battle_ok?;       return [0,1].include?(@occasion);    end
  91.         def menu_ok?;         return [0,2].include?(@occasion);    end
  92.         #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  93.     end
  94.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  95.     # ■ RPG::Item (Data class for items.)
  96.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  97.     class Item < UsableItem  
  98.         attr_accessor :price, :consumable, :recover_hp_rate, :recover_hp
  99.         attr_accessor :recover_sp_rate, :recover_sp, :parameter_type, :parameter_points        
  100.         def initialize
  101.             super
  102.             @price = 0
  103.             @consumable = true
  104.             @recover_hp_rate = 0
  105.             @recover_hp = 0
  106.             @recover_sp_rate = 0
  107.             @recover_sp = 0
  108.             @parameter_type = 0
  109.             @parameter_points = 0          
  110.         end
  111.     end
  112.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  113.     # ■ RPG::Skill (Data class for skills.)
  114.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  115.     class Skill < UsableItem
  116.         attr_accessor :sp_cost, :power, :atk_f, :eva_f, :str_f, :dex_f, :agi_f, :int_f     
  117.         def initialize
  118.             super
  119.             @sp_cost = 0
  120.             @power = 0
  121.             @atk_f = 0
  122.             @eva_f = 0
  123.             @str_f = 0
  124.             @dex_f = 0
  125.             @agi_f = 0
  126.             @int_f = 100
  127.         end
  128.     end
  129.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  130.     # ■ Module RPG::EquippableItem (Superclass of Weapon and Armor.)
  131.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  132.     class EquippableItem < BaseItem
  133.         attr_accessor :price, :pdef, :mdef, :str_plus, :dex_plus, :agi_plus, :int_plus
  134.         def initialize
  135.             super      
  136.             @price = 0
  137.             @pdef = 0
  138.             @mdef = 0          
  139.             @str_plus = 0
  140.             @dex_plus = 0
  141.             @agi_plus = 0
  142.             @int_plus = 0              
  143.         end
  144.     end
  145.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  146.     # ■ RPG::Weapon (Data class for weapons.)
  147.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  148.     class Weapon < EquippableItem
  149.         attr_accessor :animation1_id, :animation2_id, :price, :atk, :element_set
  150.         attr_accessor :plus_state_set, :minus_state_set
  151.         def initialize
  152.             super
  153.             @animation1_id = 0
  154.       @animation2_id = 0
  155.       @atk = 0
  156.             @element_set = []
  157.       @plus_state_set = []
  158.       @minus_state_set = []
  159.         end
  160.     end
  161.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  162.     # ■ RPG::Armor (Data class for armor.)
  163.     #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  164.     class Armor < BaseItem
  165.         attr_accessor :kind, :auto_state_id, :eva, :guard_element_set, :guard_state_set
  166.         def initialize
  167.             super
  168.             # kind
  169.             # 0: shield
  170.             # 1: helmet
  171.             # 2: body armor
  172.             # 3: accessory
  173.             @kind = 0
  174.       @auto_state_id = 0
  175.       @eva = 0
  176.             @guard_element_set = []
  177.       @guard_state_set = []
  178.         end
  179.     end
  180. end
Advertisement
Add Comment
Please, Sign In to add comment