Guest User

Tsukuhime - ShapeShift

a guest
Aug 7th, 2016
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2. #===============================================================================
  3. ** Effect: Shape shift
  4. Author: Hime
  5. Date: Sep 8, 2015
  6. --------------------------------------------------------------------------------
  7. ** Change log
  8. Sep 8, 2015
  9. - fixed bug where game crashes when enemy shapeshift state is removed
  10. Jun 3, 2015
  11. - fixed item dupe bug
  12. - fixed equip revert crash issue
  13. Jun 1, 2015
  14. - pull actor data from game actor, not database actor
  15. Sep 12, 2013
  16. - equips are changed to the new battler's equips
  17. - changing equips and skills are now optional
  18. Mar 10, 2013
  19. - old equips are re-equipped after transformation process
  20. Mar 9, 2013
  21. - updates character name and index, class, and initializes skills
  22. Oct 25, 2012
  23. - added support for actor transform
  24. Oct 10, 2012
  25. - initial release
  26. --------------------------------------------------------------------------------
  27. ** Terms of Use
  28. * Free to use in non-commercial projects
  29. * Contact me for commercial use
  30. * No real support. The script is provided as-is
  31. * Will do bug fixes, but no compatibility patches
  32. * Features may be requested but no guarantees, especially if it is non-trivial
  33. * Preserve this header
  34. --------------------------------------------------------------------------------
  35. ** Description
  36.  
  37. Adds a "Shape shift" effect to your state.
  38. When this state is active, the battler will be transformed to a different
  39. battler specified by the state.
  40.  
  41. --------------------------------------------------------------------------------
  42. ** Required
  43.  
  44. Effects Manager
  45. (http://himeworks.com/2012/10/05/effects-manager/)
  46. --------------------------------------------------------------------------------
  47. ** Usage
  48.  
  49. Tag your state with
  50. <eff: shape_shift battler_ID change_equips change_skills>
  51.  
  52. Where
  53. `battler_id` - either the ID of the actor or an enemy, depending on the
  54. battler type
  55. `change_equips` - true or false, if you want to transform equips
  56. `change_skills` - true or false, if you want to transform skills
  57.  
  58. If you don't want to change equips or skills, then your old equips or skills
  59. will only be preserved if the transformed battler can equip or use those
  60. equips or skills.
  61.  
  62. --------------------------------------------------------------------------------
  63. ** Example
  64.  
  65. If you want to change to actor 5, change the equips to the new actor's
  66. equips, but use the original actor's skills, tag a state with
  67.  
  68. <eff: shape_shift 5 true false>
  69.  
  70. Actor 5 will need to have the appropriate "equip" and "skill type" features.
  71.  
  72. #===============================================================================
  73. =end
  74. $imported = {} if $imported.nil?
  75. $imported["Effect_Shapeshift"] = true
  76. #===============================================================================
  77. # ** Rest of the script
  78. #===============================================================================
  79. module Effects
  80. module Shape_Shift
  81. Effect_Manager.register_effect(:shape_shift)
  82. end
  83. end
  84.  
  85. module RPG
  86. class State < BaseItem
  87. def add_effect_shape_shift(code, data_id, args)
  88. # type cast your args here
  89. args[1] = args[1] ? args[1].downcase == "true" : false
  90. args[2] = args[2] ? args[2].downcase == "true" : false
  91. # now add the effect to the object
  92. add_effect(code, data_id, args)
  93. end
  94. end
  95. end
  96.  
  97. class Game_Battler < Game_BattlerBase
  98.  
  99. def state_effect_shape_shift_add(state, effect)
  100. new_form_id = effect.value1[0].to_i
  101. effect_transform(new_form_id, effect)
  102. end
  103.  
  104. def state_effect_shape_shift_remove(state, effect)
  105. revert_transform(effect)
  106. end
  107.  
  108. def effect_transform(new_id, effect)
  109. end
  110.  
  111. def revert_transform(effect)
  112. end
  113. end
  114.  
  115. class Game_Enemy < Game_Battler
  116.  
  117. def state_effect_shape_shift_add(state, effect)
  118. @old_form_id = enemy.id
  119. @old_hp = self.hp
  120. @old_mp = self.mp
  121. @old_name = @name
  122. super
  123. end
  124.  
  125. def effect_transform(new_id, effect)
  126. transform(new_id)
  127. super
  128. end
  129.  
  130. def revert_transform(effect)
  131. transform(@old_form_id)
  132. @name = @old_name
  133. self.hp = @old_hp
  134. self.mp = @old_mp
  135. super
  136. end
  137. end
  138.  
  139. class Game_Actor < Game_Battler
  140.  
  141. def effect_transform(actor_id, effect)
  142. new_actor = Marshal.load(Marshal.dump($game_actors[actor_id]))
  143. @actor_id = actor_id
  144. @name = new_actor.name
  145. change_class(new_actor.class_id, true)
  146. init_skills if effect.value1[1]
  147. if effect.value1[2]
  148. curr_equips = equips
  149. new_equips = new_actor.equips
  150. new_equips.each_with_index {|equip, slot_id|
  151. change_equip(slot_id, equip) if equip != curr_equips[slot_id]
  152. }
  153. end
  154. @face_name = new_actor.face_name
  155. @face_index = new_actor.face_index
  156. @character_index = new_actor.character_index
  157. @character_name = new_actor.character_name
  158. refresh
  159. super
  160. end
  161.  
  162. def revert_transform(effect)
  163. @actor_id = @old_form_id
  164. @name = @old_name
  165. change_class(@old_class_id, true)
  166. init_skills if effect.value1[1]
  167. if effect.value1[2]
  168. curr_equips = equips
  169. @old_equips.each_with_index {|equip, slot_id|
  170. change_equip(slot_id, equip) if equip != curr_equips[slot_id]
  171. }
  172. end
  173. @face_name = @old_face_name
  174. @face_index = @old_face_index
  175. @character_index = @old_character_index
  176. @character_name = @old_character_name
  177. self.hp = @old_hp
  178. self.mp = @old_mp
  179. super
  180. end
  181.  
  182. #-----------------------------------------------------------------------------
  183. # Save the equips since we might remove them
  184. #-----------------------------------------------------------------------------
  185. def state_effect_shape_shift_add(state, effect)
  186. @old_form_id = @actor_id
  187. @old_equips = equips
  188. @old_hp = self.hp
  189. @old_mp = self.mp
  190. @old_name = @name
  191. @old_class_id = @class_id
  192. @old_face_name = face_name
  193. @old_face_index = face_index
  194. @old_character_index = character_index
  195. @old_character_name = character_name
  196. super
  197. end
  198. end
RAW Paste Data