Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # DSI HP Shield
- # -- Last Updated: 2017.03.19
- # -- Author: dsiver144
- # -- Level: Normal
- # -- Requires: n/a
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["DSI-HPShield"] = true
- #==============================================================================
- # + Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2017.03.19 - 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.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # + Skills notetag: <shp: x> : Increase x shield point when use a skill.
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # + Note:
- # Max Shield point = Max HP
- #==============================================================================
- module DSIVER144
- module HP_SHIELD
- SHIELD_STATE_ID = 49 # STATE ID IN DATABASE
- Revive_Penalty_SHIELD = false # Penalty will subtract shield point when revive
- SHIELD_NOTE = /<shp:\s*(\d+)>/i # Don't touch this please xD!
- end # HP_SHIELD
- end # HP_SHIELD
- module Icons
- SHIELD_Icon = 486 # Icon for SHIELD
- end # Icons
- #==============================================================================
- # ** DataManager
- #==============================================================================
- module DataManager
- class << self
- alias hp_shield_load_database load_database
- alias hp_shield_init init
- end
- #----------------------------------------------------------------------------
- # * alias method: init
- #----------------------------------------------------------------------------
- def self.init
- hp_shield_init
- load_notetags_hp_shield
- end
- #----------------------------------------------------------------------------
- # * alias method: load_database
- #----------------------------------------------------------------------------
- def self.load_database
- hp_shield_load_database
- if $BTEST
- load_notetags_hp_shield
- end
- end
- #----------------------------------------------------------------------------
- # * new method: load_notetags_hp_shield
- #----------------------------------------------------------------------------
- def self.load_notetags_hp_shield
- groups = [$data_skills]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_notetags_hp_shield
- end
- end
- end
- end # DataManager
- #==============================================================================
- # ** RPG::Skill
- #==============================================================================
- class RPG::Skill
- attr_accessor :shp
- #----------------------------------------------------------------------------
- # * new method: load_notetags_hp_shield
- #----------------------------------------------------------------------------
- def load_notetags_hp_shield
- @shp = 0
- self.note.split(/[\r\n]+/).each do |line|
- if line =~ DSIVER144::HP_SHIELD::SHIELD_NOTE
- @shp = $1.to_i
- end
- end
- end
- end
- #==============================================================================
- # ** Game_BattlerBase
- #==============================================================================
- class Game_BattlerBase
- include DSIVER144::HP_SHIELD
- attr_accessor :shp
- attr_accessor :mshp
- alias dsi_shp_initialize initialize
- #----------------------------------------------------------------------------
- # * alias method: initialize
- #----------------------------------------------------------------------------
- def initialize
- dsi_shp_initialize
- @shp = @mshp = 0
- end
- #----------------------------------------------------------------------------
- # * new method: mshp
- #----------------------------------------------------------------------------
- def mshp
- @mshp
- end
- #----------------------------------------------------------------------------
- # * new method: shp_rate
- #----------------------------------------------------------------------------
- def shp_rate
- mshp > 0 ? @shp.to_f / mshp : 0
- end
- end
- #==============================================================================
- # ** Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #----------------------------------------------------------------------------
- # * overwrite method: revive_penalty
- #----------------------------------------------------------------------------
- def revive_penalty
- percent = PC27::CG::REVIVE_PENALTY[0] * 0.01
- case PC27::CG::REVIVE_PENALTY[1]
- when :hp
- point = (@hp * percent).round
- if Revive_Penalty_SHIELD
- ori_point = point
- point -= self.shp
- if point < 0
- point = 0
- end
- self.shp -= ori_point
- if self.shp < 0
- self.shp = 0
- remove_state(SHIELD_STATE_ID)
- end
- end
- @hp -= point
- when :mhp
- point = (@mhp * percent).round
- if Revive_Penalty_SHIELD
- ori_point = point
- point -= self.shp
- if point < 0
- point = 0
- end
- self.shp -= ori_point
- if self.shp < 0
- self.shp = 0
- remove_state(SHIELD_STATE_ID)
- end
- end
- @hp -= point
- when :mp
- @mp -= (@mp * percent).round
- when :mmp
- @mp -= (@mmp * percent).round
- end
- RPG::SE.new(*PC27::CG::PENALTY_SOUND).play
- end
- end # Game_Actor
- #==============================================================================
- # ** Game_Battler
- #==============================================================================
- class Game_Battler < Game_BattlerBase
- include DSIVER144::HP_SHIELD
- alias_method(:dsi_game_battler_item_apply_shp, :item_apply)
- #----------------------------------------------------------------------------
- # * alias method: item_apply
- #----------------------------------------------------------------------------
- def item_apply(user, item)
- dsi_game_battler_item_apply_shp(user, item)
- return unless $game_party.in_battle
- if item.is_a?(RPG::Skill) && item.shp > 0 && user == self
- @result.success = true
- add_state(SHIELD_STATE_ID)
- self.shp += item.shp
- self.shp = [self.mhp,self.shp].min
- self.mshp = self.shp
- end
- end
- #--------------------------------------------------------------------------
- # * alias method: remove_state
- #--------------------------------------------------------------------------
- alias_method(:dsi_shp_remove_state, :remove_state)
- def remove_state(state_id)
- if state?(state_id) && state_id == SHIELD_STATE_ID
- self.shp = 0
- self.mshp = 0
- end
- dsi_shp_remove_state(state_id)
- end
- #----------------------------------------------------------------------------
- # * alias method: update_state_turns
- #----------------------------------------------------------------------------
- alias_method(:dsi_update_state_turns_shp, :update_state_turns)
- def update_state_turns
- dsi_update_state_turns_shp
- update_shield_state_remove
- end
- #----------------------------------------------------------------------------
- # * new method: update_shield_state_remove
- #----------------------------------------------------------------------------
- def update_shield_state_remove
- states.each do |state|
- if state.id == SHIELD_STATE_ID && @state_turns[state.id] == 0
- self.shp = 0
- self.mshp = 0
- end
- end
- end
- #----------------------------------------------------------------------------
- # * alias method: execute_damage
- #----------------------------------------------------------------------------
- alias_method(:dsi_game_battler_execute_dmg_shp, :execute_damage)
- def execute_damage(user)
- if self.shp > 0 && @result.hp_damage > 0
- on_damage(@result.hp_damage) if @result.hp_damage > 0
- p "Shield: #{self.shp} | Dmg: #{@result.hp_damage} | HP: #{self.hp}"
- self.hp -= @result.hp_damage - self.shp if @result.hp_damage > self.shp
- self.shp -= @result.hp_damage
- self.mp -= @result.mp_damage
- user.hp += @result.hp_drain
- user.mp += @result.mp_drain
- if self.shp == 0
- remove_state(SHIELD_STATE_ID)
- end
- else
- dsi_game_battler_execute_dmg_shp(user)
- end
- end
- end # Game_Battler
- #==============================================================================
- # ** BattleManager
- #==============================================================================
- module BattleManager
- include DSIVER144::HP_SHIELD
- class << self
- alias_method(:dsi_shp_battle_end,:battle_end)
- end
- def self.battle_end(result)
- dsi_shp_battle_end(result)
- for actor in $game_party.all_members
- next if actor.nil?
- actor.remove_state(SHIELD_STATE_ID)
- actor.shp = 0
- actor.mshp = 0
- end
- end
- end # BattleManager
- #==============================================================================
- # ** Window_Status
- #==============================================================================
- class Window_Status < Window_Selectable
- #----------------------------------------------------------------------------
- # * alias method: draw_basic_info
- #----------------------------------------------------------------------------
- alias_method(:dsi_draw_basic_info_shp, :draw_basic_info)
- def draw_basic_info(x, y)
- draw_actor_level(@actor, x, y + line_height * 0)
- draw_actor_icons(@actor, x, y + line_height * 1)
- draw_actor_hp(@actor, x, y + line_height * 2)
- draw_actor_mp(@actor, x, y + line_height * 3)
- draw_actor_shield(@actor, x, y + line_height * 4)
- end
- end # Window_Status
- #==============================================================================
- # ** Window_Base
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Get HP Text Color
- #--------------------------------------------------------------------------
- def shield_color(actor)
- return knockout_color if actor.shp == 0
- return tp_gauge_color1 if actor.shp < actor.mshp / 2
- return normal_color
- end
- #----------------------------------------------------------------------------
- # * new method: draw_actor_shield
- #----------------------------------------------------------------------------
- def draw_actor_shield(actor, x, y, width = 124)
- return if actor.shp == 0
- color1 = Color.new(255,178,102)
- color2 = Color.new(255,153,51)
- draw_gauge(x, y, width, actor.shp_rate, color1, color2)
- change_color(system_color)
- draw_text(x, y, 30, line_height, "")
- draw_icon(Icons::SHIELD_Icon, x, y, enabled = true)
- draw_current_and_max_values(x, y, width, actor.shp, actor.mshp,
- shield_color(actor), normal_color)
- change_color(normal_color)
- end
- end # Window_Base
- #==============================================================================
- # ** Window_BattleStatus
- #==============================================================================
- class Window_BattleStatus < Window_Selectable
- alias_method(:dsiver_draw_gauge_with_tp,:draw_gauge_area_with_tp)
- #----------------------------------------------------------------------------
- # * alias method: draw_gauge_area_with_tp
- #----------------------------------------------------------------------------
- def draw_gauge_area_with_tp(rect, actor)
- dsiver_draw_gauge_with_tp(rect, actor)
- draw_actor_shield(actor, rect.x, rect.y + line_height, 72)
- end
- end # Window_BattleStatus
- #===============================================================================
- # * END OF FILE
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement