Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI Class Image As Battler (Can't find a fancy name, lol)
- # -- Last Updated: 2017.06.09
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-ClassImageAsBattler"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.06.08 - Finish first version.
- #==============================================================================
- # + Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ?? Materials/?f?? but above ?? Main. Remember to save.
- #==============================================================================
- module DSIVER144
- module CARD_AS_BATTLER
- NON_CLASS_BATTLER_IMAGE = "bt_mgirl_pudding_a" # In Graphics/Battlers Folder
- BATTLER_POSITION = [445,265] # [ X , Y ]
- ZOOM_SCALE = 1.0 # 1.0 = Full size
- end # CARD_AS_BATTLER
- end # DSIVER144
- class Spriteset_Battle
- #--------------------------------------------------------------------------
- # * Create Actor Sprite
- # By default, the actor image is not displayed, but for convenience
- # a dummy sprite is created for treating enemies and allies the same.
- #--------------------------------------------------------------------------
- def create_actors
- @actor_sprites = Array.new(4) { Sprite_CardBattler.new(@viewport1) }
- end
- end # Spriteset_Battle
- class Game_Actor
- include DSIVER144::CARD_AS_BATTLER
- #--------------------------------------------------------------------------
- # * new method: screen_x
- #--------------------------------------------------------------------------
- def screen_x
- return BATTLER_POSITION[0]
- end
- #--------------------------------------------------------------------------
- # * new method: screen_y
- #--------------------------------------------------------------------------
- def screen_y
- return BATTLER_POSITION[1]
- end
- #--------------------------------------------------------------------------
- # * new method: screen_z
- #--------------------------------------------------------------------------
- def screen_z
- return 100
- end
- end
- class Sprite_CardBattler < Sprite_Base
- include DSIVER144::CARD_AS_BATTLER
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :battler
- #--------------------------------------------------------------------------
- # * new method: initialize
- #--------------------------------------------------------------------------
- def initialize(viewport, battler = nil)
- super(viewport)
- @battler = battler
- @battler_visible = false
- @effect_type = nil
- @effect_duration = 0
- self.zoom_x = self.zoom_y = ZOOM_SCALE
- end
- #--------------------------------------------------------------------------
- # * new method: update
- #--------------------------------------------------------------------------
- def update
- super
- if @battler
- update_bitmap
- update_origin
- update_position
- setup_new_effect
- setup_new_animation
- update_effect
- else
- self.bitmap = nil
- @effect_type = nil
- end
- end
- #--------------------------------------------------------------------------
- # * new method: update_bitmap
- #--------------------------------------------------------------------------
- def update_bitmap
- id = $game_system.current_class ? $game_system.current_class : 0
- if id == 0
- new_bitmap = Cache.battler(NON_CLASS_BATTLER_IMAGE,0)
- else
- new_bitmap = Cache.picture(DSIVER144::CLASS_CHOOSING::CLASSES[id][:picture])
- end
- if bitmap != new_bitmap
- self.bitmap = new_bitmap
- init_visibility
- end
- end
- #--------------------------------------------------------------------------
- # * new method: dispose
- #--------------------------------------------------------------------------
- def dispose
- bitmap.dispose if bitmap
- super
- end
- #--------------------------------------------------------------------------
- # * new method: init_visibility
- #--------------------------------------------------------------------------
- def init_visibility
- @battler_visible = @battler.alive?
- self.opacity = 0 unless @battler_visible
- end
- #--------------------------------------------------------------------------
- # * new method: update_origin
- #--------------------------------------------------------------------------
- def update_origin
- if bitmap
- self.ox = bitmap.width / 2
- self.oy = bitmap.height
- end
- end
- #--------------------------------------------------------------------------
- # * new method: update_position
- #--------------------------------------------------------------------------
- def update_position
- self.x = BATTLER_POSITION[0]
- self.y = BATTLER_POSITION[1]
- self.z = 100
- end
- #--------------------------------------------------------------------------
- # * new method: setup_new_effect
- #--------------------------------------------------------------------------
- def setup_new_effect
- if !@battler_visible && @battler.alive?
- start_effect(:appear)
- elsif @battler_visible && @battler.hidden?
- start_effect(:disappear)
- end
- if @battler_visible && @battler.sprite_effect_type
- start_effect(@battler.sprite_effect_type)
- @battler.sprite_effect_type = nil
- end
- end
- #--------------------------------------------------------------------------
- # * new method: start_effect
- #--------------------------------------------------------------------------
- def start_effect(effect_type)
- @effect_type = effect_type
- case @effect_type
- when :appear
- @effect_duration = 16
- @battler_visible = true
- when :disappear
- @effect_duration = 32
- @battler_visible = false
- when :whiten
- @effect_duration = 16
- @battler_visible = true
- when :blink
- @effect_duration = 20
- @battler_visible = true
- when :collapse
- @effect_duration = 48
- @battler_visible = false
- when :boss_collapse
- @effect_duration = bitmap.height
- @battler_visible = false
- when :instant_collapse
- @effect_duration = 16
- @battler_visible = false
- end
- revert_to_normal
- end
- #--------------------------------------------------------------------------
- # * new method: revert_to_normal
- #--------------------------------------------------------------------------
- def revert_to_normal
- self.blend_type = 0
- self.color.set(0, 0, 0, 0)
- self.opacity = 255
- self.ox = bitmap.width / 2 if bitmap
- self.src_rect.y = 0
- end
- #--------------------------------------------------------------------------
- # * new method: setup_new_animation
- #--------------------------------------------------------------------------
- def setup_new_animation
- if @battler.animation_id > 0
- animation = $data_animations[@battler.animation_id]
- mirror = @battler.animation_mirror
- start_animation(animation, mirror)
- @battler.animation_id = 0
- end
- end
- #--------------------------------------------------------------------------
- # * new method: effect?
- #--------------------------------------------------------------------------
- def effect?
- @effect_type != nil
- end
- #--------------------------------------------------------------------------
- # * new method: update_effect
- #--------------------------------------------------------------------------
- def update_effect
- if @effect_duration > 0
- @effect_duration -= 1
- case @effect_type
- when :whiten
- update_whiten
- when :blink
- update_blink
- when :appear
- update_appear
- when :disappear
- update_disappear
- when :collapse
- update_collapse
- when :boss_collapse
- update_boss_collapse
- when :instant_collapse
- update_instant_collapse
- end
- @effect_type = nil if @effect_duration == 0
- end
- end
- #--------------------------------------------------------------------------
- # * new method: update_whiten
- #--------------------------------------------------------------------------
- def update_whiten
- self.color.set(255, 255, 255, 0)
- self.color.alpha = 128 - (16 - @effect_duration) * 10
- end
- #--------------------------------------------------------------------------
- # * new method: update_blink
- #--------------------------------------------------------------------------
- def update_blink
- self.opacity = (@effect_duration % 10 < 5) ? 255 : 0
- end
- #--------------------------------------------------------------------------
- # * new method: update_appear
- #--------------------------------------------------------------------------
- def update_appear
- self.opacity = (16 - @effect_duration) * 16
- end
- #--------------------------------------------------------------------------
- # * new method: update_disappear
- #--------------------------------------------------------------------------
- def update_disappear
- self.opacity = 256 - (32 - @effect_duration) * 10
- end
- #--------------------------------------------------------------------------
- # * new method: update_collapse
- #--------------------------------------------------------------------------
- def update_collapse
- self.blend_type = 1
- self.color.set(255, 128, 128, 128)
- self.opacity = 256 - (48 - @effect_duration) * 6
- execute_exp_pop
- end
- #--------------------------------------------------------------------------
- # * new method: update_boss_collapse
- #--------------------------------------------------------------------------
- def update_boss_collapse
- alpha = @effect_duration * 120 / bitmap.height
- self.ox = bitmap.width / 2 + @effect_duration % 2 * 4 - 2
- self.blend_type = 1
- self.color.set(255, 255, 255, 255 - alpha)
- self.opacity = alpha
- self.src_rect.y -= 1
- Sound.play_boss_collapse2 if @effect_duration % 20 == 19
- execute_exp_pop
- end
- #--------------------------------------------------------------------------
- # * new method: update_instant_collapse
- #--------------------------------------------------------------------------
- def update_instant_collapse
- self.opacity = 0
- execute_exp_pop
- end
- #--------------------------------------------------------------------------
- # ● Execute Exp Pop
- #--------------------------------------------------------------------------
- def execute_exp_pop
- return if !MOG_DAMAGEPOPUP::EXP_GOLD_POPUP_BATTLE or @dam_exp != nil
- return if @battler == nil or @battler.is_a?(Game_Actor)
- @dam_exp = true
- if $imported[:mog_active_bonus_gauge] != nil
- real_exp = $game_troop.bonus_exp? ? @battler.exp * 2 : @battler.exp
- real_gold = $game_troop.bonus_gold? ? @battler.gold * 2 : @battler.gold
- else
- real_exp = @battler.exp ; real_gold = @battler.gold
- end
- @battler.damage.push([real_exp,"Exp"]) if @battler.exp > 0
- @battler.damage.push([real_gold,"Gold"]) if @battler.gold > 0
- end
- end # Sprite_CardBattler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement