06-14-2022, 06:53 AM (This post was last modified: 07-17-2025, 09:57 PM by kyonides.
Edit Reason: Version 1.1.0
)
KLazyWayOut XP
by Kyonides
Introduction
Are your players tired of fighting some random mobs? Fear not! There is a LAZY way out of such a messy situation!
A brand new message will show up on the map warning you about the upcoming battle. If the player wants to skip it, he or she can pay their way out of it!
Currently Available Payment Methods:
Gold - Default
Experience Points
The Old Script
Code:
# * KLazyWayOut XP
# Scripter : Kyonides Arkanthes
# 2022-06-14
# * A Non Plug & Play Script * #
# Are your players tired of fighting some random mobs?
# Fear not! There is a LAZY way out of such a messy situation!
# A brand new message will show up on the map warning you about the upcoming
# battle. If the player wants to skip it, he or she can pay their way out of it!
# :ox and :oy stands for the X & Y Offsets respectively.
class Spriteset_Map
def make_battle_alert
dimensions = KLazy::MESSAGE_SIZE
mx = dimensions[:x]
my = dimensions[:y]
cost = KLazy::SKIP_COST[$game_map.map_id]
pic = KLazy::PICTURE
message = KLazy::MESSAGE
font = KLazy::FONT
ay = $game_player.y - $game_map.display_y
@alert_sprite = Sprite.new(@viewport2)
@alert_sprite.y = ay < 8 ? 344 : 12
@alert_sprite.z += 1000
@alert_sprite.bitmap = b = Bitmap.new(dimensions[:width], 132)
bit = RPG::Cache.picture(pic[:name])
b.blt(pic[:ox], pic[:oy], bit, bit.rect)
bit.dispose
mw = b.width - mx - 8
b.font.name = font[:name]
b.font.size = font[:size]
b.font.bold = font[:bold]
message.size.times do |n|
text = sprintf(message[n], cost, $data_system.words.gold)
b.draw_text(mx, my, mw, 28, text)
my += 28
end
tr = KLazy::TRANSITION
Graphics.transition(tr[:frames], "Graphics/Transitions/" + tr[:name])
end
def dispose_battle_alert
@alert_sprite.bitmap.dispose
@alert_sprite.dispose
end
end
class Scene_Map
alias :kyon_lf_scn_bttl_up :update
alias :kyon_lf_scn_bttl_call_bttl :call_battle
def dispose_alert
@spriteset.dispose_battle_alert
@battle_alert = nil
end
def update_alert
$game_system.update
$game_screen.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
kyon_lf_scn_bttl_call_bttl
dispose_alert
elsif Input.trigger?(Input::C)
cost = KLazy::SKIP_COST[$game_map.map_id]
if $game_party.gold < cost
$game_system.se_play($data_system.buzzer_se)
kyon_lf_scn_bttl_call_bttl
dispose_alert
return
end
$game_system.se_play($data_system.shop_se)
$game_party.lose_gold(cost)
$game_temp.battle_troop_id = nil
dispose_alert
end
end
def update
if @battle_alert
update_alert
return
end
kyon_lf_scn_bttl_up
end
def call_battle
$game_switches[KLazy::SWITCH_ID] ? battle_alert : kyon_lf_scn_bttl_call_bttl
end
end
The New Script
Code:
# * KLazyWayOut XP
# Scripter : Kyonides
# v1.1.0 - 2025-07-17
# * A Non Plug & Play Script * #
# Are your players tired of fighting some random mobs?
# Fear not! There is a LAZY way out of such a messy situation!
# A brand new message will show up on the map warning you about the upcoming
# battle. If the player wants to skip it, he or she can pay their way out of it!
# Available Payment Methods: Gold & Experience.
# :ox and :oy stands for the X & Y Offsets respectively.
class Game_Actor
alias :kyon_lw_gm_act_setup :setup
def setup(actor_id)
kyon_lw_gm_act_setup(actor_id)
@skip_cost_type = :gold
end
attr_accessor :skip_cost_type
end
class Game_Party
def leader
@actors[0]
end
end
class LazyAlertSprite < Sprite
def initialize(sy, view=nil)
super(view)
self.y = sy
self.z += 1000
end
def make_bitmap(w, h)
self.bitmap = Bitmap.new(w, h)
@height = h
end
def draw_alert(message)
dimensions = KLazy::MESSAGE_SIZE
mx = dimensions[:x]
my = dimensions[:y]
mw = self.bitmap.width - mx - 8
pic = KLazy::PICTURE
lazy_font = KLazy::FONT
font = self.bitmap.font
font.name = lazy_font[:name]
font.size = lazy_font[:size]
font.bold = lazy_font[:bold]
self.bitmap.fill_rect(self.bitmap.rect, KLazy::BACKDROP_COLOR)
bit = RPG::Cache.picture(pic[:name])
self.bitmap.blt(pic[:ox], pic[:oy], bit, bit.rect)
bit.dispose
leader = $game_party.leader
pay_gold = leader.skip_cost_type == :gold
term_gold = $data_system.words.gold
if pay_gold
cost = KLazy::GOLD_SKIP_COST[$game_map.map_id]
label = term_gold
elsif leader.skip_cost_type == :exp
cost = KLazy::EXP_SKIP_COST[$game_map.map_id]
KLazy::EXP_LABEL
else
cost = 0
label = "None"
end
message.size.times do |n|
text = sprintf(message[n], cost, label)
self.bitmap.draw_text(mx, my + n * 28, mw, 28, text)
end
if pay_gold
label = $game_party.gold.to_s + term_gold
elsif leader.skip_cost_type == :exp
label = leader.exp + label
else
label = ""
end
self.bitmap.draw_text(8, @height - 28, mx - 16, 28, label, 2)
end
end
def dispose_battle_alert
@alert_sprite.bitmap.dispose
@alert_sprite.dispose
end
end
class Scene_Map
alias :kyon_lw_scn_bttl_up :update
alias :kyon_lw_scn_bttl_call_bttl :call_battle
def dispose_alert
@spriteset.dispose_battle_alert
@battle_alert = nil
end
def cancel_alert
$game_system.se_play($data_system.buzzer_se)
kyon_lf_scn_bttl_call_bttl
dispose_alert
end
def update_alert
$game_system.update
$game_screen.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
kyon_lf_scn_bttl_call_bttl
dispose_alert
return
elsif Input.trigger?(Input::C)
leader = $game_party.leader
if leader.skip_cost_type == :gold
cost = KLazy::GOLD_SKIP_COST[$game_map.map_id]
if $game_party.gold < cost
cancel_alert
return
end
$game_party.lose_gold(cost)
elsif leader.skip_cost_type == :exp
cost = KLazy::EXP_SKIP_COST[$game_map.map_id]
if leader.exp < cost
cancel_alert
return
end
leader.exp -= cost
end
$game_system.se_play($data_system.shop_se)
$game_temp.battle_troop_id = nil
dispose_alert
end
end
def update
if @battle_alert
update_alert
return
end
kyon_lw_scn_bttl_up
end