Advertisement
dsiver144

DSI Class Image As Battler

Jul 4th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.53 KB | None | 0 0
  1. #==============================================================================
  2. # DSI Class Image As Battler (Can't find a fancy name, lol)
  3. # -- Last Updated: 2017.06.09
  4. # -- Author: dsiver144
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #==============================================================================
  8. $imported = {} if $imported.nil?
  9. $imported["DSI-ClassImageAsBattler"] = true
  10. #==============================================================================
  11. # + Updates
  12. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  13. # 2017.06.08 - Finish first version.
  14. #==============================================================================
  15. # + Instructions
  16. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  17. # To install this script, open up your script editor and copy/paste this script
  18. # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
  19. #==============================================================================
  20. module DSIVER144
  21. module CARD_AS_BATTLER
  22. NON_CLASS_BATTLER_IMAGE = "bt_mgirl_pudding_a" # In Graphics/Battlers Folder
  23. BATTLER_POSITION = [445,265] # [ X , Y ]
  24. ZOOM_SCALE = 1.0 # 1.0 = Full size
  25. end # CARD_AS_BATTLER
  26. end # DSIVER144
  27.  
  28. class Spriteset_Battle
  29. #--------------------------------------------------------------------------
  30. # * Create Actor Sprite
  31. # By default, the actor image is not displayed, but for convenience
  32. # a dummy sprite is created for treating enemies and allies the same.
  33. #--------------------------------------------------------------------------
  34. def create_actors
  35. @actor_sprites = Array.new(4) { Sprite_CardBattler.new(@viewport1) }
  36. end
  37. end # Spriteset_Battle
  38.  
  39. class Game_Actor
  40. include DSIVER144::CARD_AS_BATTLER
  41. #--------------------------------------------------------------------------
  42. # * new method: screen_x
  43. #--------------------------------------------------------------------------
  44. def screen_x
  45. return BATTLER_POSITION[0]
  46. end
  47. #--------------------------------------------------------------------------
  48. # * new method: screen_y
  49. #--------------------------------------------------------------------------
  50. def screen_y
  51. return BATTLER_POSITION[1]
  52. end
  53. #--------------------------------------------------------------------------
  54. # * new method: screen_z
  55. #--------------------------------------------------------------------------
  56. def screen_z
  57. return 100
  58. end
  59. end
  60.  
  61. class Sprite_CardBattler < Sprite_Base
  62. include DSIVER144::CARD_AS_BATTLER
  63. #--------------------------------------------------------------------------
  64. # * Public Instance Variables
  65. #--------------------------------------------------------------------------
  66. attr_accessor :battler
  67. #--------------------------------------------------------------------------
  68. # * new method: initialize
  69. #--------------------------------------------------------------------------
  70. def initialize(viewport, battler = nil)
  71. super(viewport)
  72. @battler = battler
  73. @battler_visible = false
  74. @effect_type = nil
  75. @effect_duration = 0
  76. self.zoom_x = self.zoom_y = ZOOM_SCALE
  77. end
  78. #--------------------------------------------------------------------------
  79. # * new method: update
  80. #--------------------------------------------------------------------------
  81. def update
  82. super
  83. if @battler
  84. update_bitmap
  85. update_origin
  86. update_position
  87. setup_new_effect
  88. setup_new_animation
  89. update_effect
  90. else
  91. self.bitmap = nil
  92. @effect_type = nil
  93. end
  94. end
  95. #--------------------------------------------------------------------------
  96. # * new method: update_bitmap
  97. #--------------------------------------------------------------------------
  98. def update_bitmap
  99. id = $game_system.current_class ? $game_system.current_class : 0
  100. if id == 0
  101. new_bitmap = Cache.battler(NON_CLASS_BATTLER_IMAGE,0)
  102. else
  103. new_bitmap = Cache.picture(DSIVER144::CLASS_CHOOSING::CLASSES[id][:picture])
  104. end
  105. if bitmap != new_bitmap
  106. self.bitmap = new_bitmap
  107. init_visibility
  108. end
  109. end
  110. #--------------------------------------------------------------------------
  111. # * new method: dispose
  112. #--------------------------------------------------------------------------
  113. def dispose
  114. bitmap.dispose if bitmap
  115. super
  116. end
  117. #--------------------------------------------------------------------------
  118. # * new method: init_visibility
  119. #--------------------------------------------------------------------------
  120. def init_visibility
  121. @battler_visible = @battler.alive?
  122. self.opacity = 0 unless @battler_visible
  123. end
  124. #--------------------------------------------------------------------------
  125. # * new method: update_origin
  126. #--------------------------------------------------------------------------
  127. def update_origin
  128. if bitmap
  129. self.ox = bitmap.width / 2
  130. self.oy = bitmap.height
  131. end
  132. end
  133. #--------------------------------------------------------------------------
  134. # * new method: update_position
  135. #--------------------------------------------------------------------------
  136. def update_position
  137. self.x = BATTLER_POSITION[0]
  138. self.y = BATTLER_POSITION[1]
  139. self.z = 100
  140. end
  141. #--------------------------------------------------------------------------
  142. # * new method: setup_new_effect
  143. #--------------------------------------------------------------------------
  144. def setup_new_effect
  145. if !@battler_visible && @battler.alive?
  146. start_effect(:appear)
  147. elsif @battler_visible && @battler.hidden?
  148. start_effect(:disappear)
  149. end
  150. if @battler_visible && @battler.sprite_effect_type
  151. start_effect(@battler.sprite_effect_type)
  152. @battler.sprite_effect_type = nil
  153. end
  154. end
  155. #--------------------------------------------------------------------------
  156. # * new method: start_effect
  157. #--------------------------------------------------------------------------
  158. def start_effect(effect_type)
  159. @effect_type = effect_type
  160. case @effect_type
  161. when :appear
  162. @effect_duration = 16
  163. @battler_visible = true
  164. when :disappear
  165. @effect_duration = 32
  166. @battler_visible = false
  167. when :whiten
  168. @effect_duration = 16
  169. @battler_visible = true
  170. when :blink
  171. @effect_duration = 20
  172. @battler_visible = true
  173. when :collapse
  174. @effect_duration = 48
  175. @battler_visible = false
  176. when :boss_collapse
  177. @effect_duration = bitmap.height
  178. @battler_visible = false
  179. when :instant_collapse
  180. @effect_duration = 16
  181. @battler_visible = false
  182. end
  183. revert_to_normal
  184. end
  185. #--------------------------------------------------------------------------
  186. # * new method: revert_to_normal
  187. #--------------------------------------------------------------------------
  188. def revert_to_normal
  189. self.blend_type = 0
  190. self.color.set(0, 0, 0, 0)
  191. self.opacity = 255
  192. self.ox = bitmap.width / 2 if bitmap
  193. self.src_rect.y = 0
  194. end
  195. #--------------------------------------------------------------------------
  196. # * new method: setup_new_animation
  197. #--------------------------------------------------------------------------
  198. def setup_new_animation
  199. if @battler.animation_id > 0
  200. animation = $data_animations[@battler.animation_id]
  201. mirror = @battler.animation_mirror
  202. start_animation(animation, mirror)
  203. @battler.animation_id = 0
  204. end
  205. end
  206. #--------------------------------------------------------------------------
  207. # * new method: effect?
  208. #--------------------------------------------------------------------------
  209. def effect?
  210. @effect_type != nil
  211. end
  212. #--------------------------------------------------------------------------
  213. # * new method: update_effect
  214. #--------------------------------------------------------------------------
  215. def update_effect
  216. if @effect_duration > 0
  217. @effect_duration -= 1
  218. case @effect_type
  219. when :whiten
  220. update_whiten
  221. when :blink
  222. update_blink
  223. when :appear
  224. update_appear
  225. when :disappear
  226. update_disappear
  227. when :collapse
  228. update_collapse
  229. when :boss_collapse
  230. update_boss_collapse
  231. when :instant_collapse
  232. update_instant_collapse
  233. end
  234. @effect_type = nil if @effect_duration == 0
  235. end
  236. end
  237. #--------------------------------------------------------------------------
  238. # * new method: update_whiten
  239. #--------------------------------------------------------------------------
  240. def update_whiten
  241. self.color.set(255, 255, 255, 0)
  242. self.color.alpha = 128 - (16 - @effect_duration) * 10
  243. end
  244. #--------------------------------------------------------------------------
  245. # * new method: update_blink
  246. #--------------------------------------------------------------------------
  247. def update_blink
  248. self.opacity = (@effect_duration % 10 < 5) ? 255 : 0
  249. end
  250. #--------------------------------------------------------------------------
  251. # * new method: update_appear
  252. #--------------------------------------------------------------------------
  253. def update_appear
  254. self.opacity = (16 - @effect_duration) * 16
  255. end
  256. #--------------------------------------------------------------------------
  257. # * new method: update_disappear
  258. #--------------------------------------------------------------------------
  259. def update_disappear
  260. self.opacity = 256 - (32 - @effect_duration) * 10
  261. end
  262. #--------------------------------------------------------------------------
  263. # * new method: update_collapse
  264. #--------------------------------------------------------------------------
  265. def update_collapse
  266. self.blend_type = 1
  267. self.color.set(255, 128, 128, 128)
  268. self.opacity = 256 - (48 - @effect_duration) * 6
  269. execute_exp_pop
  270. end
  271. #--------------------------------------------------------------------------
  272. # * new method: update_boss_collapse
  273. #--------------------------------------------------------------------------
  274. def update_boss_collapse
  275. alpha = @effect_duration * 120 / bitmap.height
  276. self.ox = bitmap.width / 2 + @effect_duration % 2 * 4 - 2
  277. self.blend_type = 1
  278. self.color.set(255, 255, 255, 255 - alpha)
  279. self.opacity = alpha
  280. self.src_rect.y -= 1
  281. Sound.play_boss_collapse2 if @effect_duration % 20 == 19
  282. execute_exp_pop
  283. end
  284. #--------------------------------------------------------------------------
  285. # * new method: update_instant_collapse
  286. #--------------------------------------------------------------------------
  287. def update_instant_collapse
  288. self.opacity = 0
  289. execute_exp_pop
  290. end
  291. #--------------------------------------------------------------------------
  292. # ● Execute Exp Pop
  293. #--------------------------------------------------------------------------
  294. def execute_exp_pop
  295. return if !MOG_DAMAGEPOPUP::EXP_GOLD_POPUP_BATTLE or @dam_exp != nil
  296. return if @battler == nil or @battler.is_a?(Game_Actor)
  297. @dam_exp = true
  298. if $imported[:mog_active_bonus_gauge] != nil
  299. real_exp = $game_troop.bonus_exp? ? @battler.exp * 2 : @battler.exp
  300. real_gold = $game_troop.bonus_gold? ? @battler.gold * 2 : @battler.gold
  301. else
  302. real_exp = @battler.exp ; real_gold = @battler.gold
  303. end
  304. @battler.damage.push([real_exp,"Exp"]) if @battler.exp > 0
  305. @battler.damage.push([real_gold,"Gold"]) if @battler.gold > 0
  306. end
  307. end # Sprite_CardBattler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement