Advertisement
DrDhoom

Guest Party

Aug 31st, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.08 KB | None | 0 0
  1. module Dhoom
  2.   module PartyGuest
  3.     #To set guest bonus for the party, use notetag in actor note.
  4.     #The syntax: <g_(attribute) (0 for exact value and 1 percentage),value>
  5.     #The attribute is: hp, mp, atk, def, matk, mdef, agi, and luk
  6.     #for example:
  7.     # <g_def 0,100>   this will give 100 defensive bonus to the whole party
  8.     # <g_hp 1,10>     this wil give 10% hp bonus to the whole party
  9.     #
  10.     #Commands:
  11.     # - guest_included?(actor id)
  12.     # - add_guest(actor id)
  13.     # - remove_guest(actor id)
  14.     # - remove_all_guest
  15.    
  16.     Max_Guest = 2 #MAX GUEST PARTY
  17.   end
  18. end
  19.  
  20. class RPG::Actor < RPG::BaseItem
  21.  
  22.   attr_reader :guest_attribute
  23.  
  24.   def initialize_guest_attribute
  25.     @guest_attribute = []
  26.     if @note =~ /<g_hp (.*)>/i
  27.       ar = []
  28.       for x in $1.split(",")
  29.         ar.push(x.to_i)
  30.       end
  31.       @guest_attribute.push([0,ar[0],ar[1]])
  32.     end
  33.     if @note =~ /<g_mp (.*)>/i
  34.       ar = []
  35.       for x in $1.split(",")
  36.         ar.push(x.to_i)
  37.       end
  38.       @guest_attribute.push([1,ar[0],ar[1]])
  39.     end
  40.     if @note =~ /<g_atk (.*)>/i
  41.       ar = []
  42.       for x in $1.split(",")
  43.         ar.push(x.to_i)
  44.       end
  45.       @guest_attribute.push([2,ar[0],ar[1]])
  46.     end
  47.     if @note =~ /<g_def (.*)>/i
  48.       ar = []
  49.       for x in $1.split(",")
  50.         ar.push(x.to_i)
  51.       end
  52.       @guest_attribute.push([3,ar[0],ar[1]])
  53.     end
  54.     if @note =~ /<g_matk (.*)>/i
  55.       ar = []
  56.       for x in $1.split(",")
  57.         ar.push(x.to_i)
  58.       end
  59.       @guest_attribute.push([4,ar[0],ar[1]])
  60.     end
  61.     if @note =~ /<g_mdef (.*)>/i
  62.       ar = []
  63.       for x in $1.split(",")
  64.         ar.push(x.to_i)
  65.       end
  66.       @guest_attribute.push([5,ar[0],ar[1]])
  67.     end
  68.     if @note =~ /<g_agi (.*)>/i
  69.       ar = []
  70.       for x in $1.split(",")
  71.         ar.push(x.to_i)
  72.       end
  73.       @guest_attribute.push([6,ar[0],ar[1]])
  74.     end
  75.     if @note =~ /<g_luk (.*)>/i
  76.       ar = []
  77.       for x in $1.split(",")
  78.         ar.push(x.to_i)
  79.       end
  80.       @guest_attribute.push([7,ar[0],ar[1]])
  81.     end
  82.   end
  83. end
  84.  
  85. class Game_Actor < Game_Battler
  86.   def param_base(param_id)
  87.     if $game_party.guests.empty?
  88.       self.class.params[param_id, @level]
  89.     else
  90.       value = self.class.params[param_id, @level]
  91.       for id in $game_party.guests
  92.         for at in $data_actors[id].guest_attribute
  93.           if at[0] == param_id
  94.             if at[1] == 0
  95.               value += at[2]
  96.             else
  97.               value += value*at[2]/100              
  98.             end
  99.           end
  100.         end
  101.       end
  102.       return value
  103.     end
  104.   end
  105. end
  106.  
  107. class Game_Party < Game_Unit
  108.  
  109.   attr_accessor :guests
  110.  
  111.   alias dhoom_guest_game_party_init initialize
  112.   def initialize
  113.     dhoom_guest_game_party_init
  114.     @guests = []
  115.   end
  116.  
  117.   def add_guest(actor_id)
  118.     return if @guests.include?(actor_id) or @guests.size == Dhoom::PartyGuest::Max_Guest
  119.     @guests.push(actor_id)
  120.     remove_actor(actor_id)
  121.     $game_player.refresh
  122.     $game_map.need_refresh = true
  123.   end
  124.  
  125.   def remove_guest(actor_id)
  126.     return if !@guests.include?(actor_id) or @guests.empty?
  127.     @guests.delete(actor_id)
  128.     $game_player.refresh
  129.     $game_map.need_refresh = true
  130.   end
  131.  
  132.   def remove_all_guest
  133.     @guests.clear
  134.     $game_player.refresh
  135.     $game_map.need_refresh = true
  136.   end
  137.  
  138.   alias dhoom_guest_game_party_add_actor add_actor
  139.   def add_actor(actor_id)
  140.     @guests.delete(actor_id) if @guests.include?(actor_id)
  141.     dhoom_guest_game_party_add_actor(actor_id)    
  142.   end
  143. end
  144.  
  145. class Game_Interpreter
  146.   def add_guest(actor_id)
  147.     $game_party.add_guest(actor_id)
  148.   end
  149.  
  150.   def remove_guest(actor_id)
  151.     $game_party.remove_guest(actor_id)
  152.   end
  153.  
  154.   def remove_all_guest
  155.     $game_party.remove_all_guest
  156.   end
  157.  
  158.   def guest_included?(actor_id)
  159.     $game_party.guests.include?(actor_id)
  160.   end
  161. end
  162.  
  163. class Scene_Title < Scene_Base
  164.   alias dhoom_guest_scene_title_start start
  165.   def start
  166.     dhoom_guest_scene_title_start
  167.     for actor in $data_actors
  168.       actor.initialize_guest_attribute if !actor.nil?
  169.     end
  170.   end
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement