Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ==============================================================================
- # ▼▼▼▼▼▼ TroyZ - Crisis HP Warning ▼▼▼▼▼▼
- # ==============================================================================
- # Script by : Agung Prasetyo(TroyZ)
- # Contact me by : - Email agung.endisnear.xyz@gmail.com
- # - Forum RPGMakerID, username TroyZ
- # - Handphone 085756289121
- # Engine : VXAce
- # Level : Easy
- # Version : 1.0
- # ------------------------------------------------------------------------------
- # Change Logs :
- # 28 November 2013 : Version 1.0 released
- # ------------------------------------------------------------------------------
- # How this work :
- # This script allows you to create warnings on the map when the actors'
- # HP are below specified percentage of their max HP.
- # ------------------------------------------------------------------------------
- # How to use :
- # Place it between material and main. Use this notetags inside actors :
- #
- # <hp warn rate: x>
- #
- # Actors that have this notetag will show the warn on the map when their HP is
- # below x percent of their MaxHP. For example, an actor has this notetag :
- #
- # <hp warn rate: 50>
- #
- # This actor will show the warn on the map when this actor's HP is below 50% of
- # it's MaxHP. You can alter the warn with the following script calls :
- #
- # hp_warn_flash_color(color), when the color is the new color object.
- # hp_warn_duration_flash_color(duration), when the duration is the new duration
- # (in frames).
- # hp_warn_duration(duration), when the duration is the new duration (in frames).
- # ------------------------------------------------------------------------------
- # Compatibility issues :
- # None yet. If you found some, let me know, and bug fixes will come out soon.
- # ------------------------------------------------------------------------------
- # Who to credit :
- # - Allah swt. : For the chance of living that he has given to me.
- # - Nabi Muhammad saw. : As a leader and messenger and prophet of Muslim.
- # I'm proud to be your follower. :)
- # - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. :P
- # ------------------------------------------------------------------------------
- # License :
- # - Free Game : Just credit those names above.
- # - Commercial Game : Same as free game's license.
- # ------------------------------------------------------------------------------
- $imported = {} if $imported.nil?
- $imported[:TroyZ_CrisisHPWarning] = true
- # ------------------------------------------------------------------------------
- # Configuration of script starts here
- # ------------------------------------------------------------------------------
- module AGUNG
- module CRI_HP_WARN
- SWITCH_FLASH_WARN = 20 # when this switch is ON, the flash effect of hp warn
- # is active
- FLASH_WARN_COLOR = Color.new(255,0,0,128) # the color when flash effect of
- # hp warn is used
- DURATION_FLASH_WARN_COLOR = 20 # duration of flash effect
- DURATION_WARN = 60 # how long the warn shows (in frames)
- WARN_SE = "Audio/SE/Absorb1" # the SE of warn
- CRI_HP_WARN_DEFAULT = 25 # the default rate with actors that don't have
- # notetag of hp warn
- end
- module NOTETAGS_CRI_HP_WARN
- CRI_HP_WARN = /<(?:HP WARN RATE|hp warn rate):[ ]*(\d+)>/i
- end
- end
- # ------------------------------------------------------------------------------
- # End of Configuration
- # ------------------------------------------------------------------------------
- # ------------------------------------------------------------------------------
- # You shall not pass
- # ------------------------------------------------------------------------------
- module DataManager
- class << self
- alias agung_load_cri_hp_warn_dbase_x load_database
- end
- def self.load_database
- agung_load_cri_hp_warn_dbase_x
- agung_load_notetags_cri_hp_warn_x
- end
- def self.agung_load_notetags_cri_hp_warn_x
- [$data_actors].each do |actors|
- actors.each do |obj|
- next unless obj
- obj.agung_load_notetags_cri_hp_warn_x
- end
- end
- end
- end
- class RPG::Actor < RPG::BaseItem
- include AGUNG::CRI_HP_WARN
- include AGUNG::NOTETAGS_CRI_HP_WARN
- attr_accessor :hp_warn_rate
- def agung_load_notetags_cri_hp_warn_x
- @hp_warn_rate = CRI_HP_WARN_DEFAULT.to_f / 100
- self.note.split(/[\r\n]+/).each { |baris|
- case baris
- when CRI_HP_WARN
- @hp_warn_rate = $1.to_f / 100
- end
- }
- end
- end
- class Game_System
- attr_accessor :flash_warn_color
- attr_accessor :duration_flash_warn_color
- attr_accessor :duration_warn
- alias agung_hp_warn_init_x initialize
- def initialize
- agung_hp_warn_init_x
- @flash_warn_color = AGUNG::CRI_HP_WARN::FLASH_WARN_COLOR
- @duration_flash_warn_color = AGUNG::CRI_HP_WARN::DURATION_FLASH_WARN_COLOR
- @duration_warn = AGUNG::CRI_HP_WARN::DURATION_WARN
- end
- end
- class Game_Interpreter
- def hp_warn_flash_color(color)
- $game_system.flash_warn_color = color
- end
- def hp_warn_duration_flash_color(duration)
- $game_system.duration_flash_warn_color = duration
- end
- def hp_warn_duration(duration)
- $game_system.duration_warn = duration
- end
- end
- class Game_Actor < Game_Battler
- def hp_warn_rate
- $data_actors[id].hp_warn_rate
- end
- end
- class Game_Screen
- def hp_warn_flash
- start_flash($game_system.flash_warn_color, $game_system.duration_flash_warn_color)
- end
- end
- class Scene_Map < Scene_Base
- include AGUNG::CRI_HP_WARN
- alias agung_update_map_x update
- def update
- agung_update_map_x
- x_play_crisis_sound_x if Graphics.frame_count % $game_system.duration_warn == 0
- end
- def x_play_crisis_sound_x
- $game_party.members.each do |actor|
- if actor.hp <= actor.mhp * actor.hp_warn_rate
- $game_map.screen.hp_warn_flash if $game_switches[SWITCH_FLASH_WARN]
- Audio.se_play(WARN_SE)
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement