# XAS - Bonnus Gauge V1.0
#===============================================================================
# By Moghunter
#
http://www.atelier-rgss.com#===============================================================================
# Sistema permite ganhar bonificações ou penalidades quando
# os medidores chegarem ao nível maximo
#
#===============================================================================
module MOG
# Definição da quantidade de Pontos ganhos no medidor de Bonnus.
# BG_PT = {A=>B}
#
# A = ID da SKILL
# B = Porcentagem de pontos ganhos de 0 a 100.
BG_PT = {
3 => 5
}
# Definição padrão da quantidade de pontos ganhos.
DEFAULT_BG_PT = 5
# Velocidade de redução do medidor de Bonnus.
BG_DOWN_GAUGE1 = 1
# Tipos de bonificações ao atingir o nível maximo.
#
# 0 - Ganhar HP
# 1 - Ganhar SP
# 2 - Adicionar Condição
# 3 - Ganhar dinheiro
# 4 - Aleatório
BG_BONNUS_TYPE = 4
# Porcentagem de HP Ganho.
BG_BONNUS_GAIN_HP = 100
# Porcentagem de SP Ganho
BG_BONNUS_GAIN_SP = 100
# Condições adquiridas.
BG_BONNUS_STATE = [2,3,8,16,27]#(Aleatório caso haver mais de 1.)
# Dinheiro ganho. Dinheiro será multiplicado pelo level do herói.
BG_BONNUS_GAIN_GOLD = 150
# Som ao atigir o nivel maximo do medidor de bonus.
BG_SE = RPG::AudioFile.new("055-Right01", 100, 100)
# Tipos de penalidades ao atingir o nível maximo de fadiga.
#
# 0 - Ganhar HP
# 1 - Ganhar SP
# 2 - Adicionar Condição
# 3 - Ganhar dinheiro
# 4 - Aleatório
BG_BAD_BONNUS_TYPE = 4
# Porcentagem de HP Ganho.
BG_BAD_BONNUS_LOSE_HP = 25
# Porcentagem de SP Ganho
BG_BAD_BONNUS_LOSE_SP = 100
# Condições adquiridas.(Aleatório caso haver mais de 1.)
BG_BAD_BONNUS_STATE = [4,5,12,20]
# Dinheiro ganho. Dinheiro será multiplicado pelo level do herói.
BG_BAD_BONNUS_LOSE_GOLD = 150
# Som ao atingir o nivel maximo de fadiga.
BG_BAD_SE = RPG::AudioFile.new("058-Wrong02", 100, 100)
#Posição do medidor na horizontal.
BG_X = 25
#Posição do medidor na vertical.
BG_Y = 124
#Switch que desativa o sistema de bonnus gauge.
XAS_BG_DISABLE_SWITCH_ID = 4 ############################[ set number to match the control switch ID number ] ~g
end
$mog_rgss_xas_bonnusgauge = true
#-------------------------------------------------------------------------------
# Game_Temp
#-------------------------------------------------------------------------------
class Game_Temp
attr_accessor :bg_seta1_x
attr_accessor :bg_seta1_y
attr_accessor :bg_seta1_opa
attr_accessor :bg_seta1_zoom_x
attr_accessor :bg_seta1_zoom_y
attr_accessor :bg_seta2_x
attr_accessor :bg_seta2_y
attr_accessor :bg_seta2_opa
attr_accessor :bg_seta2_zoom_x
attr_accessor :bg_seta2_zoom_y
attr_accessor :bg_meter_x
attr_accessor :bg_meter_y
attr_accessor :bg_meter_opa
attr_accessor :bg_meter_zoom_x
attr_accessor :bg_meter_zoom_y
attr_accessor :bg_number_x
attr_accessor :bg_number_y
attr_accessor :bg_number_opa
attr_accessor :bg_number_zoom_x
attr_accessor :bg_number_zoom_y
attr_accessor :bg_gauge1
attr_accessor :bg_gauge2
attr_accessor :bg_gauge1_overheat
attr_accessor :bg_gauge2_overheat
attr_accessor :bg_gauge_height
attr_accessor :bg_gauge_speed
attr_accessor :bg_gauge_speed2
alias mog_xas_bonnusgauge_initialize initialize
def initialize
mog_xas_bonnusgauge_initialize
@bg_seta1_x = 0
@bg_seta1_y = 0
@bg_seta1_opa = 255
@bg_seta1_zoom_x = 1.00
@bg_seta1_zoom_y = 1.00
@bg_seta2_x = 0
@bg_seta2_y = 0
@bg_seta2_opa = 255
@bg_seta2_zoom_x = 1.00
@bg_seta2_zoom_y = 1.00
@bg_meter_x = 0
@bg_meter_y = 0
@bg_meter_opa = 255
@bg_meter_zoom_x = 1.00
@bg_meter_zoom_y = 1.00
@bg_number_x = 0
@bg_number_y = 0
@bg_number_opa = 255
@bg_number_zoom_x = 1.00
@bg_number_zoom_y = 1.00
@bg_gauge1 = 0
@bg_gauge2 = 0
@bg_gauge1 = false
@bg_gauge2 = false
@bg_gauge_height = 0
@bg_gauge_speed = 0
@bg_gauge_speed2 = 0
end
def bg_gauge_height
image1 = RPG::Cache.picture("XAS_Bonnus_Meter")
image2 = RPG::Cache.picture("XAS_Bonnus_Cursor1")
bg_height = image1.height - image2.height
return bg_height
end
end
#-------------------------------------------------------------------------------
# Game_Battler
#-------------------------------------------------------------------------------
class Game_Battler
include MOG
alias mog_xas_bg_attack_effect attack_effect
def attack_effect(attacker)
mog_xas_bg_attack_effect(attacker)
if $game_switches[MOG::XAS_BG_DISABLE_SWITCH_ID] == true
return false
end
if attacker.is_a?(Game_Enemy) and self.is_a?(Game_Actor) and
self.damage.is_a?(Numeric) and self.damage > 0
@actor = $game_party.actors[0]
return false if @actor == nil
if $game_temp.bg_gauge2_overheat == false
dmg = self.damage * 150 / self.maxhp
dmg = 5 if dmg <= 5
gain = dmg * $game_temp.bg_gauge_height / 100
$game_temp.bg_seta2_y += gain
$game_temp.bg_seta2_zoom_y += gain
$game_temp.bg_seta2_zoom_x = 1.02
$game_temp.bg_seta2_zoom_y = 1.02
$game_temp.bg_seta2_y = $game_temp.bg_gauge_height if $game_temp.bg_seta2_y > $game_temp.bg_gauge_height
$game_temp.bg_gauge2_overheat = true if $game_temp.bg_seta2_y >= $game_temp.bg_gauge_height
if $game_temp.bg_gauge2_overheat == true
$game_screen.start_flash(Color.new(255, 155, 55, 255),120)
$game_screen.start_shake(5,10,60)
$game_system.se_play(BG_BAD_SE)
bonnus_type = BG_BAD_BONNUS_TYPE
if bonnus_type > 3
bonnus_type = rand(3)
end
if bonnus_type == 0
valor = BG_BAD_BONNUS_LOSE_HP * @actor.maxhp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_system.words.hp.to_s + " " + valor.to_s + " damaged!!!"
end
@actor.hp -= valor
$game_player.battler.damage = valor
$game_player.battler.damage_pop = true
elsif bonnus_type == 1
valor = BG_BAD_BONNUS_LOSE_SP * @actor.maxsp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_system.words.sp.to_s + " " + valor.to_s + " damaged!!!"
end
@actor.sp -= valor
$game_player.battler.damage = $data_system.words.sp + " " + valor.to_s
$game_player.battler.damage_pop = true
elsif bonnus_type == 2
state = BG_BAD_BONNUS_STATE
if state != nil
valor = state[rand(state.size)]
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_states[valor].name.to_s + " added!!!"
end
@actor.add_state(valor)
end
elsif bonnus_type == 3
valor = BG_BAD_BONNUS_LOSE_GOLD * @actor.level
$game_party.lose_gold(valor)
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - Lose " + valor.to_s + " " + $data_system.words.gold.to_s + "!!!"
end
end
if $mog_rgss_ifw != nil
$game_temp.ifw_active = true
end
end
end
end
end
alias mog_xas_bg_skill_effect skill_effect
def skill_effect(user, skill)
mog_xas_bg_skill_effect(user, skill)
if $game_switches[MOG::XAS_BG_DISABLE_SWITCH_ID] == true
return false
end
if user.is_a?(Game_Enemy) and self.is_a?(Game_Actor) and
self.damage.is_a?(Numeric) and self.damage > 0
@actor = $game_party.actors[0]
return false if @actor == nil
if $game_temp.bg_gauge2_overheat == false
dmg = self.damage * 130 / self.maxhp
dmg = 5 if dmg <= 5
gain = dmg * $game_temp.bg_gauge_height / 100
$game_temp.bg_seta2_y += gain
$game_temp.bg_seta2_zoom_y += gain
$game_temp.bg_seta2_zoom_x = 1.02
$game_temp.bg_seta2_zoom_y = 1.02
$game_temp.bg_seta2_y = $game_temp.bg_gauge_height if $game_temp.bg_seta2_y > $game_temp.bg_gauge_height
$game_temp.bg_gauge2_overheat = true if $game_temp.bg_seta2_y >= $game_temp.bg_gauge_height
if $game_temp.bg_gauge2_overheat == true
$game_screen.start_flash(Color.new(255, 155, 55, 255),120)
$game_screen.start_shake(5,10,60)
$game_system.se_play(BG_BAD_SE)
bonnus_type = BG_BAD_BONNUS_TYPE
if bonnus_type > 3
bonnus_type = rand(3)
end
if bonnus_type == 0
valor = BG_BAD_BONNUS_LOSE_HP * @actor.maxhp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_system.words.hp.to_s + " " + valor.to_s + " damaged!!!"
end
if valor >= @actor.hp
valor = @actor.hp - 1
end
@actor.hp -= valor
$game_player.battler.damage = valor
$game_player.battler.damage_pop = true
elsif bonnus_type == 1
valor = BG_BAD_BONNUS_LOSE_SP * @actor.maxsp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_system.words.sp.to_s + " " + valor.to_s + " damaged!!!"
end
@actor.sp -= valor
$game_player.battler.damage = $data_system.words.sp + " " + valor.to_s
$game_player.battler.damage_pop = true
elsif bonnus_type == 2
state = BG_BAD_BONNUS_STATE
if state != nil
valor = state[rand(state.size)]
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - " + $data_states[valor].name.to_s + " added!!!"
end
@actor.add_state(valor)
end
elsif bonnus_type == 3
valor = BG_BAD_BONNUS_LOSE_GOLD * @actor.level
$game_party.lose_gold(valor)
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Fatigue - Lose " + valor.to_s + " " + $data_system.words.gold.to_s + "!!!"
end
end
if $mog_rgss_ifw != nil
$game_temp.ifw_active = true
end
end
end
end
if skill.element_set.include?($data_system.elements.index("HIT")) and
user.is_a?(Game_Actor) and self.is_a?(Game_Enemy)
if self.damage.is_a?(Numeric) and self.damage > 0
unless XAS_BA_ENEMY::ITEM_ENEMY.include?(self.id)
gain_pt = BG_PT[skill.id]
@actor = $game_party.actors[0]
return false if @actor == nil
if $game_temp.bg_gauge1_overheat == false
if gain_pt != nil
gain = gain_pt * $game_temp.bg_gauge_height / 100
else
gain = DEFAULT_BG_PT * $game_temp.bg_gauge_height / 100
end
$game_temp.bg_seta1_zoom_x = 1.02
$game_temp.bg_seta1_zoom_y = 1.02
$game_temp.bg_seta1_y += gain
$game_temp.bg_seta1_y = $game_temp.bg_gauge_height if $game_temp.bg_seta1_y > $game_temp.bg_gauge_height
$game_temp.bg_gauge1_overheat = true if $game_temp.bg_seta1_y >= $game_temp.bg_gauge_height
if $game_temp.bg_gauge1_overheat == true
$game_screen.start_flash(Color.new(55, 155, 255, 255),120)
$game_system.se_play(BG_SE)
bonnus_type = BG_BONNUS_TYPE
if bonnus_type > 3
bonnus_type = rand(3)
end
if bonnus_type == 0
valor = BG_BONNUS_GAIN_HP * @actor.maxhp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Bonnus - " + $data_system.words.hp.to_s + " " + valor.to_s + " recovered!!!"
end
@actor.hp += valor
$game_player.battler.damage = -valor
$game_player.battler.damage_pop = true
elsif bonnus_type == 1
valor = BG_BONNUS_GAIN_SP * @actor.maxsp / 100
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Bonnus - " + $data_system.words.sp.to_s + " " + valor.to_s + " recovered!!!"
end
@actor.sp += valor
$game_player.battler.damage = $data_system.words.sp + " - " + valor.to_s
$game_player.battler.damage_pop = true
elsif bonnus_type == 2
state = BG_BONNUS_STATE
if state != nil
valor = state[rand(state.size)]
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Bonnus - " + $data_states[valor].name.to_s + " added!!!"
end
@actor.add_state(valor)
end
elsif bonnus_type == 3
valor = BG_BONNUS_GAIN_GOLD * @actor.level
$game_party.gain_gold(valor)
if $mog_rgss_ifw != nil
$game_temp.ifw_text = "Bonnus - Extra " + valor.to_s + " " + $data_system.words.gold.to_s + "!!!"
end
end
if $mog_rgss_ifw != nil
$game_temp.ifw_active = true
end
end
end
end
end
end
end
end
#-------------------------------------------------------------------------------
# Bonnus_Gauge
#-------------------------------------------------------------------------------
class Bonnus_Gauge < Sprite
include MOG
def initialize(viewport)
super(viewport)
@actor = $game_party.actors[0]
@bg_meter = Sprite.new
@bg_meter.bitmap = RPG::Cache.picture("XAS_Bonnus_Meter")
@bg_meter.z = 9000
@bg_meter.ox = -BG_X + $game_temp.bg_meter_x
@bg_meter.oy = -BG_Y + $game_temp.bg_meter_y
@bg_meter.zoom_x = $game_temp.bg_meter_zoom_x
@bg_meter.zoom_y = $game_temp.bg_meter_zoom_y
@bg_meter.opacity = $game_temp.bg_meter_opa
@bg_seta1 = Sprite.new
@bg_seta1.bitmap = RPG::Cache.picture("XAS_Bonnus_Cursor1")
@bonnus_height = @bg_meter.bitmap.height - @bg_seta1.bitmap.height
@bg_seta1.z = 9002
@bg_seta1.ox = -BG_X + 20 + $game_temp.bg_seta1_x
@bg_seta1.oy = -BG_Y - $game_temp.bg_gauge_height + $game_temp.bg_seta1_y
@bg_seta1.zoom_x = $game_temp.bg_seta1_zoom_x
@bg_seta1.zoom_y = $game_temp.bg_seta1_zoom_y
@bg_seta1.opacity = $game_temp.bg_seta1_opa
@bg_seta2 = Sprite.new
@bg_seta2.bitmap = RPG::Cache.picture("XAS_Bonnus_Cursor2")
@bg_seta2.z = 9002
@bg_seta2.ox = -BG_X - 13 + $game_temp.bg_seta2_x
@bg_seta2.oy = -BG_Y - $game_temp.bg_gauge_height + $game_temp.bg_seta2_y
@bg_seta2.zoom_x = $game_temp.bg_seta2_zoom_x
@bg_seta2.zoom_y = $game_temp.bg_seta2_zoom_y
@bg_seta2.opacity = $game_temp.bg_seta2_opa
@bg_number = Sprite.new
@bg_number.bitmap = RPG::Cache.picture("XAS_Bonnus_Number")
@bg_number.z = 9003
@bg_number.ox = -BG_X + 10 + $game_temp.bg_number_x
@bg_number.oy = -BG_Y + $game_temp.bg_number_y
@bg_number.zoom_x = $game_temp.bg_number_zoom_x
@bg_number.zoom_y = $game_temp.bg_number_zoom_y
@bg_number.opacity = $game_temp.bg_number_opa
if @actor == nil or
$game_switches[MOG::XAS_BG_DISABLE_SWITCH_ID] == true
@bg_meter.visible = false
@bg_seta1.visible = false
@bg_seta2.visible = false
@bg_number.visible = false
else
@bg_meter.visible = true
@bg_seta1.visible = true
@bg_seta2.visible = true
@bg_number.visible = true
end
end
def dispose
if @bg_meter != nil
@bg_meter.bitmap.dispose
@bg_meter.dispose
@bg_meter = nil
end
if @bg_seta1 != nil
@bg_seta1.bitmap.dispose
@bg_seta1.dispose
@bg_seta1 = nil
end
if @bg_seta2 != nil
@bg_seta2.bitmap.dispose
@bg_seta2.dispose
@bg_seta2 = nil
end
if @bg_number != nil
@bg_number.bitmap.dispose
@bg_number.dispose
@bg_number = nil
end
end
def update
if @actor == nil or
$game_switches[MOG::XAS_BG_DISABLE_SWITCH_ID] == true
@bg_meter.visible = false
@bg_seta1.visible = false
@bg_seta2.visible = false
@bg_number.visible = false
else
@bg_meter.visible = true
@bg_seta1.visible = true
@bg_seta2.visible = true
@bg_number.visible = true
end
@bg_meter.ox = -BG_X + $game_temp.bg_meter_x
@bg_meter.oy = -BG_Y + $game_temp.bg_meter_y
@bg_meter.zoom_x = $game_temp.bg_meter_zoom_x
@bg_meter.zoom_y = $game_temp.bg_meter_zoom_y
@bg_meter.opacity = $game_temp.bg_meter_opa
@bg_seta1.ox = -BG_X + 20 + $game_temp.bg_seta1_x
@bg_seta1.oy = -BG_Y - $game_temp.bg_gauge_height + $game_temp.bg_seta1_y
@bg_seta1.zoom_x = $game_temp.bg_seta1_zoom_x
@bg_seta1.zoom_y = $game_temp.bg_seta1_zoom_y
@bg_seta1.opacity = $game_temp.bg_seta1_opa
@bg_seta2.ox = -BG_X - 13 + $game_temp.bg_seta2_x
@bg_seta2.oy = -BG_Y - $game_temp.bg_gauge_height + $game_temp.bg_seta2_y
@bg_seta2.zoom_x = $game_temp.bg_seta2_zoom_x
@bg_seta2.zoom_y = $game_temp.bg_seta2_zoom_y
@bg_seta2.opacity = $game_temp.bg_seta2_opa
@bg_number.ox = -BG_X + 10 + $game_temp.bg_number_x
@bg_number.oy = -BG_Y + $game_temp.bg_number_y
@bg_number.zoom_x = $game_temp.bg_number_zoom_x
@bg_number.zoom_y = $game_temp.bg_number_zoom_y
@bg_number.opacity = $game_temp.bg_number_opa
if $game_temp.bg_gauge1_overheat == true
@bg_meter.color.set(rand(150), 0, 0, 155)
else
if $game_temp.bg_seta1_y != 0 or
$game_temp.bg_seta2_y != 0
@bg_meter.color.set(0, rand(100), rand(150), 25 + rand(50))
else
@bg_meter.color.set(0,0, 0, 0)
end
end
if $game_temp.bg_seta1_zoom_x > 1.00
$game_temp.bg_seta1_zoom_x -= 0.002
$game_temp.bg_seta1_zoom_y -= 0.002
elsif $game_temp.bg_seta1_zoom_x < 1.00
$game_temp.bg_seta1_zoom_x = 1.00
$game_temp.bg_seta1_zoom_y = 1.00
end
$game_temp.bg_gauge_speed += 1
if $game_temp.bg_gauge1_overheat == false
$game_temp.bg_gauge_speed = 0 if $game_temp.bg_gauge_speed > 5
else
$game_temp.bg_gauge_speed = 0 if $game_temp.bg_gauge_speed > 15
end
if $game_temp.bg_gauge_speed == 0
down_gauge1 = BG_DOWN_GAUGE1 * $game_temp.bg_gauge_height / 100
$game_temp.bg_seta1_y -= down_gauge1
$game_temp.bg_seta1_y = 0 if $game_temp.bg_seta1_y < 0
$game_temp.bg_gauge1_overheat = false if $game_temp.bg_seta1_y <= 0
end
if $game_temp.bg_gauge2_overheat == true
@bg_seta2.color.set(rand(150), 0, 0, 155)
else
@bg_seta2.color.set(0,0, 0, 0)
end
if $game_temp.bg_seta2_zoom_x > 1.00
$game_temp.bg_seta2_zoom_x -= 0.002
$game_temp.bg_seta2_zoom_y -= 0.002
elsif $game_temp.bg_seta2_zoom_x < 1.00
$game_temp.bg_seta2_zoom_x = 1.00
$game_temp.bg_seta2_zoom_y = 1.00
end
$game_temp.bg_gauge_speed2 += 1
if $game_temp.bg_gauge2_overheat == false
$game_temp.bg_gauge_speed2 = 0 if $game_temp.bg_gauge_speed2 > 25
else
$game_temp.bg_gauge_speed2 = 0 if $game_temp.bg_gauge_speed2 > 10
end
if $game_temp.bg_gauge_speed2 == 0
down_gauge2 = BG_DOWN_GAUGE1 * $game_temp.bg_gauge_height / 100
$game_temp.bg_seta2_y -= down_gauge2
$game_temp.bg_seta2_y = 0 if $game_temp.bg_seta2_y < 0
$game_temp.bg_gauge2_overheat = false if $game_temp.bg_seta2_y <= 0
end
end
end
#-------------------------------------------------------------------------------
# Scene_Map
#-------------------------------------------------------------------------------
class Scene_Map
alias xas_bonnus_gauge_main main
def main
@viewport = Viewport.new(0, 0, 640, 480)
@viewport.z = 99999
@bonnus_gauge = Bonnus_Gauge.new(@viewport)
xas_bonnus_gauge_main
@bonnus_gauge.dispose
@bonnus_gauge = nil
end
alias xas_bonnus_gauge_update update
def update
xas_bonnus_gauge_update
@bonnus_gauge.update if @bonnus_gauge != nil
end