Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Overhead Icon by OneEyedEagle (http://oneeyedeagle.lofter.com/)
- # License - MIT License: http://opensource.org/licenses/mit-license.php
- #==============================================================================
- # - 2020.10.23.0 New variable added
- #==============================================================================
- # - Adds the ability to show icon above the character's head on the map.
- #--------------------------------------------------------------------------
- # - In RGSS3, you can use value on @balloon_id variable for Game_CharacterBase class.
- # Which is use to show dynamic balloon above the character's head on map.
- # - Adds @pop_icon variable to the Game_Character class.
- # Assign a value to variable that shows icon above the character for certain time.
- # And a new @pop_icon_type variable has been added to specify types of motion.
- # - Example:
- # $game_player.pop_icon = 1
- # → Display is icon index 1, above player's head for MAX_SHOW_FRAME.
- # If set to 0, the icon is removed.
- #==============================================================================
- module POP_ICON
- #--------------------------------------------------------------------------
- # ● 【Constant】 Icon isn't shown when this switch for serial ID is on.
- #--------------------------------------------------------------------------
- S_ID_NO_POP = 1
- #--------------------------------------------------------------------------
- # ● 【Constant】 Maximum number of frames to be shown after one activation.
- # If set to nil, it will not disappear.
- #--------------------------------------------------------------------------
- MAX_SHOW_FRAME = 30
- #--------------------------------------------------------------------------
- # ● 【Constant】 Maximum number of loop frames
- #--------------------------------------------------------------------------
- MAX_LOOP_FRAME = 60
- #--------------------------------------------------------------------------
- # ● Loop of frame number.
- # frame set value of 0 ~ MAX_LOOP_FRAME-1
- #--------------------------------------------------------------------------
- def self.draw_pop_icon(sprite_chara, sprite_icon, icon_id, frame, move_type)
- # Set icon position
- sprite_icon.x = sprite_chara.x
- sprite_icon.y = sprite_chara.y - sprite_chara.height
- sprite_icon.z = sprite_chara.z + 200
- # On first frame, creates a new bitmap to draw an icon.
- if frame == 0
- sprite_icon.visible = true
- sprite_icon.bitmap ||= Bitmap.new(24, 24)
- sprite_icon.bitmap.clear
- sprite_icon.ox = 12
- sprite_icon.oy = 24
- draw_icon(sprite_icon.bitmap, icon_id, 0, 0)
- sprite_icon.opacity = 255
- end
- if move_type == 0
- elsif move_type == 1
- sprite_icon.y = sprite_chara.y - sprite_chara.height / 2
- end
- case frame
- when 1..29
- sprite_icon.opacity -= 6
- sprite_icon.y += (frame/4)
- when 30..59
- sprite_icon.opacity += 6
- sprite_icon.y += ((29-(frame-29))/4)
- end
- end
- #--------------------------------------------------------------------------
- # ● Draw icon
- # enabled : If false, transparent effect.
- #--------------------------------------------------------------------------
- def self.draw_icon(bitmap, icon_index, x, y, enabled = true)
- bitmap_ = Cache.system("Iconset")
- rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
- bitmap.blt(x, y, bitmap_, rect, enabled ? 255 : 120)
- end
- end
- #=============================================================================
- # ○ Game_Character
- #=============================================================================
- class Game_Character
- attr_accessor :pop_icon, :pop_icon_type
- #--------------------------------------------------------------------------
- # ● Initialize pop icon
- #--------------------------------------------------------------------------
- alias eagle_popicon_init initialize
- def initialize
- @pop_icon = 0
- @pop_icon_type = 0
- eagle_popicon_init
- end
- end
- #=============================================================================
- # ○ Sprite_Character
- #=============================================================================
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------
- # ● Pop icon remove
- #--------------------------------------------------------------------------
- alias eagle_popicon_dispose dispose
- def dispose
- eagle_popicon_dispose
- if @popicon_sprite
- @popicon_sprite.bitmap.dispose if @popicon_sprite.bitmap
- @popicon_sprite.dispose
- end
- end
- #--------------------------------------------------------------------------
- # ● Pop icon alias
- #--------------------------------------------------------------------------
- alias eagle_popicon_update update
- def update
- eagle_popicon_update
- update_popicon
- end
- #--------------------------------------------------------------------------
- # ● Update pop icon
- #--------------------------------------------------------------------------
- def update_popicon
- if $game_switches[POP_ICON::S_ID_NO_POP]
- end_popicon if @pop_icon != 0
- return
- end
- reset_popicon if @popicon_sprite.nil?
- flag_continue_show = false
- if @character.pop_icon > 0
- if @character.pop_icon == @pop_icon # If matches the display
- @character.pop_icon = -1
- flag_continue_show = true
- else
- reset_popicon
- end
- else
- return end_popicon if @character.pop_icon == 0
- end
- if @pop_icon > 0
- if !flag_continue_show && POP_ICON::MAX_SHOW_FRAME &&
- @popicon_count > POP_ICON::MAX_SHOW_FRAME
- return end_popicon
- end
- c = @popicon_count % POP_ICON::MAX_LOOP_FRAME
- POP_ICON.draw_pop_icon(self, @popicon_sprite, @pop_icon, c,
- @character.pop_icon_type)
- @popicon_sprite.update
- @popicon_count += 1
- end
- end
- #--------------------------------------------------------------------------
- # ● Reset pop icon
- #--------------------------------------------------------------------------
- def reset_popicon
- @pop_icon = @character.pop_icon
- @character.pop_icon = -1 # When shown, set it to -1.
- @popicon_sprite ||= Sprite.new(viewport)
- @popicon_count = 0
- end
- #--------------------------------------------------------------------------
- # ● End pop icon
- #--------------------------------------------------------------------------
- def end_popicon
- @popicon_sprite.visible = false if @popicon_sprite
- @pop_icon = 0
- @character.pop_icon = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement