estriole

WIP - Effect - Simple Pet

Jan 14th, 2013
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.37 KB | None | 0 0
  1. =begin
  2. #==============================================================================
  3.  ** Effect: Simple Pet
  4.  Author: Estriole
  5.  Date: 14 Jan 2013
  6. ------------------------------------------------------------------------------
  7.  ** Change log
  8.  2013-01-14
  9.    - initial release
  10. ------------------------------------------------------------------------------  
  11.  ** Terms of Use
  12.  * Free to use in commercial/non-commercial projects
  13.  * No real support. The script is provided as-is
  14.  * Will do bug fixes, but no compatibility patches
  15.  * Features may be requested but no guarantees, especially if it is non-trivial
  16.  * Preserve this header
  17. ------------------------------------------------------------------------------
  18.  Requires
  19.  - Tsukihime Effect Manager 2.6
  20.  - Yanfly Equip Engine
  21.  
  22.  Create your armor : equipment type accessory
  23.  Tag your armors with
  24.     <equip type: Pet>
  25.     <eff: simple_pet x>
  26.  Where x is the id of actor that acting as pet.
  27.  
  28.  Give it name: example:
  29.  "Natalie Lv - " it will shown as: "Natalie Lv - x" (x -> natalie level)
  30.  
  31.  then tag your actor (not the pet one) with notetags to allow him to equip Pet.
  32.  don't add Pet as default equip type. since pet will be able to equip another pet
  33.  and that will become trouble.
  34.  
  35.  Compatibility
  36.  not compatible with yanfly command equip. it turn out error.
  37.  
  38. #==============================================================================
  39. =end
  40. $imported = {} if $imported.nil?
  41. $imported["Effect_Simple_Pet"] = true
  42. #==============================================================================
  43. # ** Rest of the script
  44. #==============================================================================
  45. module Effect
  46.   module Simple_Pet
  47.     Effect_Manager.register_effect(:simple_pet)
  48.     EQUIP_TYPE = 10
  49.     #CHANGE ABOVE TO NEW ID IF THAT ID ALREADY USED    
  50.     YEA::EQUIP::TYPES[EQUIP_TYPE]=[ "Pet",       true,     false]    
  51.   end
  52. end
  53.  
  54. class Game_Battler < Game_BattlerBase
  55.   def armor_effect_simple_pet_equip(user, effect)
  56.   end
  57.   def armor_effect_simple_pet_unequip(user, effect)
  58.   end
  59. end
  60.  
  61. class Game_Actor < Game_Battler
  62.   def armor_effect_simple_pet_equip(user, effect)
  63.     pet_id = effect.value1[0].to_i
  64.     $game_party.add_actor(pet_id)
  65.     @result.effect_results.push("%s takes out %s!" %[user.name, $game_actors[pet_id].name])
  66.     @result.success = true
  67.   end
  68.   def armor_effect_simple_pet_unequip(user, effect)
  69.     pet_id = effect.value1[0].to_i
  70.     $game_party.remove_actor(pet_id)
  71.     @result.effect_results.push("%s returns!" %[$game_actors[pet_id].name])
  72.     @result.success = true
  73.   end    
  74. end
  75.  
  76. class RPG::EquipItem < RPG::BaseItem
  77.   def linked_actor
  78.     if @linked_actor.nil?
  79.       if @note =~ /<eff: simple_pet (.*)>/i
  80.         @linked_actor = $1.to_i
  81.       else
  82.         @linked_actor = nil
  83.       end
  84.     end
  85.     @linked_actor
  86.   end
  87. end
  88.  
  89. class Window_Base < Window
  90.   alias draw_pet_lv_draw_item_name draw_item_name
  91.   def draw_item_name(item, x, y, enabled = true, width = 172)
  92.     return unless item
  93.     if item.is_a?(RPG::EquipItem) && item.linked_actor
  94.     draw_icon(item.icon_index, x, y, enabled)
  95.     change_color(normal_color, enabled)
  96.     text = item.name
  97.     text += $game_actors[item.linked_actor].level.to_s
  98.     draw_text(x + 24, y, width, line_height, text)    
  99.     else  
  100.     draw_pet_lv_draw_item_name(item, x, y, enabled = true, width = 172)
  101.     end
  102.   end
  103. end
Advertisement
Add Comment
Please, Sign In to add comment