Bem-vindos ao fórum VXAOS!!


#==============================================================================
# ** Window_Shop
#------------------------------------------------------------------------------
# Esta classe lida com a janela da loja.
#------------------------------------------------------------------------------
# Autor: Valentine Mod: Merim
#==============================================================================
class Window_Shop < Window_ItemSelectable
attr_reader :price
def initialize
super(280, 165, 212, 212)
self.visible = false
self.closable = true
self.title = Vocab::Shop
end
def show(shop_goods, purchase_only)
@shop_goods = shop_goods
@purchase_only = purchase_only
super()
end
def hide_window
# Não envia o send_close_window se pressionar Esc quando a loja não estiver aberta
return unless visible
$network.send_close_window
end
def enable?(item)
item && @price[item] <= $game_party.gold && !$game_party.item_max?(item)
end
def make_item_list
@data = []
@price = {}
@shop_goods.each do |goods|
item = $game_party.item_object(goods
+ 1, goods[1])
if item
@data << item
@price[item] = goods[2] == 0 ? item.price : goods[3]
end
end
end
def update
super
$windows[:amount].show(Enums::Amount::BUY_ITEM, item, index) if Mouse.dbl_clk?(:L) && index >= 0
end
def update_drag
return unless Mouse.press?(:L)
return if $cursor.object
return if $dragging_window
return unless index >= 0
$cursor.change_item(item, Enums::Mouse::SHOP)
end
def update_drop
return if Mouse.press?(:L)
return unless $cursor.object
return unless $cursor.type == Enums::Mouse::ITEM
return unless in_area?
sell_item
end
def sell_item
if @purchase_only
$error_msg = Vocab::NotSellItem
Sound.play_buzzer
return
end
$windows[:amount].show(Enums::Amount::SELL_ITEM, $windows[:item].item)
end
end#==============================================================================
# ** Window_Amount
#------------------------------------------------------------------------------
# Esta classe lida com a janela de quantidade.
#------------------------------------------------------------------------------
# Autor: Valentine Mod: Merim
#==============================================================================
class Window_Amount < Window_Base
def initialize
super(400, 230, 150, 140) # Ajusta a altura da janela para 140
self.visible = false
self.closable = true
self.title = Vocab::Amount
@amount_box = Number_Box.new(self, 10, 40, 130, 5) { enable_ok_button } # Ajusta a posição da barra de quantidade
@ok_button = Button.new(self, 60, 110, Vocab::Ok) { ok } # Reposiciona o botão OK para mais abaixo
@total_value = 0
end
def deposit_gold
amount = @amount_box.value
puts "Tentando depositar #{amount} ouro."
return if $game_party.gold < amount
puts "Ouro suficiente no inventário."
$network.send_bank_gold(amount)
end
def show(type, item = nil, index = 0)
@type = type
@item = item
@index = index
@amount_box.clear
@amount_box.active = true
@ok_button.enable = false
@quantity = 1
update_total_value
if index == 0 && item_number_one?
@amount_box.value = 1
ok
return
end
super()
refresh
end
def update_total_value
@total_value = @item.price * @amount_box.value if @item
end
def refresh
super
contents.clear
if @item
draw_text(0, 0, contents.width, line_height, @item.name) # Coloca o nome do recurso no topo
draw_text(0, 50, contents.width, line_height, "#{@item.name} x #{@amount_box.value}") # Ajusta a posição da quantidade logo abaixo da barra de quantidade
else
draw_text(0, 0, contents.width, line_height, "Gold") # Exibe "Gold" no topo se @item for nil
draw_text(0, 50, contents.width, line_height, "Gold x #{@amount_box.value}") # Exibe "Gold" e a quantidade logo abaixo da barra de quantidade
end
draw_text(0, 80, contents.width, line_height, "Total: #{@total_value} G") # Ajusta a posição do total para logo abaixo da quantidade
end
def item_number_one?
return ($game_trade.my_item_number(@item) == 1) if @type == Enums::Amount::REMOVE_TRADE_ITEM
return ($game_bank.item_number(@item) == 1) if @type == Enums::Amount::WITHDRAW_ITEM
return ($game_party.item_number(@item) == 1)
end
def ok
case @type
when Enums::Amount::BUY_ITEM
buy_item
when Enums::Amount::SELL_ITEM
sell_item
when Enums::Amount::DROP_ITEM
drop_item
when Enums::Amount::ADD_TRADE_ITEM
add_trade_item
when Enums::Amount::ADD_TRADE_GOLD
add_trade_gold
when Enums::Amount::REMOVE_TRADE_ITEM
remove_trade_item
when Enums::Amount::REMOVE_TRADE_GOLD
remove_trade_gold
when Enums::Amount::DEPOSIT_ITEM
deposit_item
when Enums::Amount::DEPOSIT_GOLD
deposit_gold
when Enums::Amount::WITHDRAW_ITEM
withdraw_item
when Enums::Amount::WITHDRAW_GOLD
withdraw_gold
end
hide
end
def buy_item
amount = [@amount_box.value, Configs::MAX_ITEMS - $game_party.item_number(@item)].min
return if $game_party.full_items?(@item)
if $game_party.gold < @item.price * amount
$error_msg = Vocab::NotEnoughMoney
return
end
$network.send_buy_item(@index, amount)
end
def sell_item
amount = @amount_box.value
return if $game_party.item_number(@item) < amount
$network.send_sell_item(@item.id, $game_party.kind_item(@item), amount)
end
def drop_item
amount = @amount_box.value
return if $game_party.item_number(@item) < amount
if $game_map.drops.size >= Configs::MAX_MAP_DROPS
$error_msg = Vocab::FullDrops
return
elsif @item.soulbound?
$error_msg = Vocab::SoulboundItem
return
end
$network.send_add_drop(@item.id, $game_party.kind_item(@item), amount)
end
def add_trade_item
amount = @amount_box.value
return if $game_party.item_number(@item) < $game_trade.my_item_number(@item) + amount
return if $game_trade.full_items?(@item)
if @item.soulbound?
$error_msg = Vocab::SoulboundItem
return
end
$network.send_trade_item(@item.id, $game_party.kind_item(@item), amount)
end
def add_trade_gold
amount = @amount_box.value
return if $game_party.gold < $game_trade.my_gold + amount
$network.send_trade_gold(amount)
end
def remove_trade_item
amount = @amount_box.value
return if $game_trade.my_item_number(@item) < amount
return if $game_party.full_items?(@item)
$network.send_trade_item(@item.id, $game_party.kind_item(@item), -amount)
end
def remove_trade_gold
amount = @amount_box.value
return if $game_trade.my_gold < amount
$network.send_trade_gold(-amount)
end
def deposit_item
amount = [@amount_box.value, Configs::MAX_ITEMS - $game_bank.item_number(@item)].min
return if $game_party.item_number(@item) < amount
return if $game_bank.full_items?(@item)
if @item.soulbound?
$error_msg = Vocab::SoulboundItem
return
end
$network.send_bank_item(@item.id, $game_party.kind_item(@item), amount)
end
def deposit_gold
amount = @amount_box.value
return if $game_party.gold < amount
$network.send_bank_gold(amount)
end
def withdraw_item
amount = [@amount_box.value, Configs::MAX_ITEMS - $game_party.item_number(@item)].min
return if $game_bank.item_number(@item) < amount
return if $game_party.full_items?(@item)
$network.send_bank_item(@item.id, $game_party.kind_item(@item), -amount)
end
def withdraw_gold
amount = @amount_box.value
return if $game_bank.gold < amount
$network.send_bank_gold(-amount)
end
def enable_ok_button
@ok_button.enable = (@amount_box.value != 0)
update_total_value
refresh
end
def update
super
ok if Input.trigger?(:C) && @amount_box.value != 0
end
enddef self.create_player(client, actor_id, name, character_index, class_id, sex, params, points)
actor = Actor.new
actor.name = name
actor.character_name = $data_classes[class_id].graphics[sex][character_index]
actor.character_index = $data_classes[class_id].graphics[sex][character_index][1]
actor.face_name = $data_classes[class_id].graphics[sex + 2] ? $data_classes[class_id].graphics[sex + 2][character_index] : ''
actor.face_index = $data_classes[class_id].graphics[sex + 2] ? $data_classes[class_id].graphics[sex + 2][character_index][1] : 0
actor.class_id = class_id
actor.sex = sex
actor.level = $data_actors[class_id].initial_level
actor.exp = $data_classes[class_id].exp_for_level(actor.level)
maxhp = params[Enums::Param::MAXHP] * 10 + $data_classes[class_id].params[Enums::Param::MAXHP, actor.level]
maxmp = params[Enums::Param::MAXMP] * 10 + $data_classes[class_id].params[Enums::Param::MAXMP, actor.level]
actor.hp = maxhp
actor.mp = maxmp
actor.param_base = [maxhp, maxmp]
(Enums::Param::ATK..Enums::Param::LUK).each do |param_id|
actor.param_base << $data_classes[class_id].params[param_id, actor.level] + params[param_id]
end
actor.equips = $data_actors[class_id].equips + * (Configs::MAX_EQUIPS - 5)
actor.points = points
actor.guild_name = ''
actor.revive_map_id = actor.map_id = $data_system.start_map_id
actor.revive_x = actor.x = $data_system.start_x
actor.revive_y = actor.y = $data_system.start_y
actor.direction = Enums::Dir::DOWN
actor.gold = 0
actor.items = {}
actor.weapons = {}
actor.armors = {}
actor.skills = []
$data_classes[class_id].learnings.each do |learning|
actor.skills << learning.skill_id if learning.level <= actor.level
end
actor.quests = {}
actor.hotbar = Array.new(Configs::MAX_HOTBAR) { Hotbar.new(0, 0) }
actor.switches = Array.new(Configs::MAX_PLAYER_SWITCHES, false)
actor.variables = Array.new(Configs::MAX_PLAYER_VARIABLES, 0)
actor.self_switches = {}
s_client = sql_client
s_client.transaction do
s_client[:actors].insert(
slot_id: actor_id, account_id: client.account_id_db, name: actor.name,
character_name: actor.character_name, character_index: actor.character_index,
face_name: actor.face_name, face_index: actor.face_index, class_id: actor.class_id,
sex: actor.sex, level: actor.level, exp: actor.exp, hp: actor.hp, mp: actor.mp,
mhp: actor.param_base, mmp: actor.param_base[1], atk: actor.param_base[2], def: actor.param_base[3],
int: actor.param_base[4], res: actor.param_base[5], agi: actor.param_base[6], luk: actor.param_base[7],
points: actor.points, revive_map_id: actor.revive_map_id, revive_x: actor.revive_x,
revive_y: actor.revive_y, map_id: actor.map_id, x: actor.x, y: actor.y,
direction: actor.direction, creation_date: Time.now.to_i, last_login: Time.now.to_i
)
actor.id_db = s_client[:actors].select(:id).where(name: actor.name).single_value
actor.equips.each_with_index do |equip_id, slot_id|
s_client[:actor_equips].insert(actor_id: actor.id_db, slot_id: slot_id, equip_id: equip_id)
end
actor.skills.each do |skill|
s_client[:actor_skills].insert(actor_id: actor.id_db, skill_id: skill)
end
Configs::MAX_HOTBAR.times do |slot_id|
s_client[:actor_hotbars].insert(actor_id: actor.id_db, slot_id: slot_id)
end
Configs::MAX_PLAYER_SWITCHES.times do |switch_id|
s_client[:actor_switches].insert(actor_id: actor.id_db, switch_id: switch_id + 1)
end
Configs::MAX_PLAYER_VARIABLES.times do |variable_id|
s_client[:actor_variables].insert(actor_id: actor.id_db, variable_id: variable_id + 1)
end
end
s_client.disconnect
client.actors[actor_id] = actor
end
# ** Sprite_Minimap
#------------------------------------------------------------------------------
# Esta classe lida com a exibição do mapa em miniatura.
#------------------------------------------------------------------------------
# Autor: Valentine Mod: Merim
#==============================================================================
class Sprite_Minimap < Sprite2
Event_Data = Struct.new(:name, :width)
def initialize
super
self.bitmap = Bitmap.new(172, 148) # Aumenta a altura para 148 para incluir a hora
self.x = adjust_x
self.y = 9
self.z = 50
self.bitmap.font.size = 15
@bitmap = Cache.system('Minimap')
@dragable = true
@event_sprites = {}
@event_data = {}
@last_tip_name = ''
create_player_point
create_tool_tip
refresh
update
end
def line_height
18
end
def adjust_x
Graphics.width - 188
end
def in_area?(x = 0, y = 0, w = self.bitmap.width, h = self.bitmap.height)
super(x + 24, y, w - 24, h)
end
def change_opacity(x = 0, y = 0)
super()
@player_sprite.opacity = self.opacity
@event_sprites.each_value { |sprite| sprite.opacity = self.opacity }
end
def create_player_point
@player_sprite = Sprite.new
@player_sprite.bitmap = Bitmap.new(16, 16)
@player_sprite.bitmap.blt(0, 0, @bitmap, Rect.new(142, 0, 16, 16))
@player_sprite.z = self.z + 1
end
def create_tool_tip
@tool_tip = Sprite.new
@tool_tip.bitmap = Bitmap.new(self.bitmap.width, line_height)
@tool_tip.z = @player_sprite.z + 1
end
def create_event(event_id, event_name, rect_y)
event_sprite = Sprite.new
event_sprite.bitmap = Bitmap.new(16, 16)
event_sprite.bitmap.blt(0, 0, @bitmap, Rect.new(142, rect_y, 16, 16))
event_sprite.x = self.x + object_x($game_map.events[event_id])
event_sprite.y = self.y + object_y($game_map.events[event_id])
event_sprite.z = self.z
@event_sprites[event_id] = event_sprite
@event_data[event_id] = Event_Data.new(event_name, text_width(event_name) + 8)
end
def dispose
super
@player_sprite.bitmap.dispose
@player_sprite.dispose
@tool_tip.bitmap.dispose
@tool_tip.dispose
dispose_events
end
def dispose_events
@event_sprites.each_value do |event|
event.bitmap.dispose
event.dispose
end
@event_sprites.clear
@event_data.clear
end
def object_x(object)
[[object.x * 134 / $game_map.width + 25, 33].max, 161].min
end
def object_y(object)
[[object.y * 106 / $game_map.height - 5, 3].max, 104].min
end
def refresh
@tool_tip.visible = false
draw_background
draw_icon
draw_map_name
draw_time # Desenha a hora abaixo do minimapa
dispose_events
if FileTest.exist?("Graphics/Minimaps/#{$game_map.map_id}.png")
draw_map
draw_events
else
@player_sprite.visible = false
end
end
def draw_background
self.bitmap.clear
self.bitmap.blt(30, 0, @bitmap, self.bitmap.rect)
end
def draw_icon
bitmap = Cache.system('Iconset')
icon_index = $game_map.pvp? ? Configs::MAP_PVP_ICON : Configs::MAP_NONPVP_ICON
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.bitmap.blt(0, 0, bitmap, rect)
end
def draw_map_name
self.bitmap.draw_text(30, 113, 142, 18, $game_map.display_name, 1)
end
def draw_time
current_time = Time.now.strftime("%H:%M")
self.bitmap.draw_text(30, 130, 142, 18, current_time, 1)
end
def draw_map
bitmap = Cache.minimap($game_map.map_id.to_s)
self.bitmap.blt(33, 3, bitmap, bitmap.rect)
end
def refresh_tool_tip(event_name, width)
@last_tip_name = event_name
@tool_tip.bitmap.clear
rect = Rect.new(0, 0, width, @tool_tip.bitmap.height)
@tool_tip.bitmap.fill_rect(rect, Color.new(0, 0, 0, 160))
@tool_tip.bitmap.draw_text(rect, event_name, 1)
end
def draw_events
@player_sprite.visible = true
$game_map.events.each do |event_id, event|
next unless event.list
# Missão
if event.quest_not_started?
create_event(event_id, Vocab::Quest, 32)
next
# Boss
elsif event.boss?
create_event(event_id, Vocab::Boss, 96)
next
end
event.list.each do |item|
# Loja
if item.code == 302
create_event(event_id, Vocab::Shop, 16)
break
elsif item.code == 355
# Banco
if item.parameters[0].include?('open_bank')
create_event(event_id, Vocab::Bank, 48)
break
# Teletransporte
elsif item.parameters[0].include?('open_teleport')
create_event(event_id, Vocab::Teleport, 64)
break
# Ponto de referência
elsif item.parameters[0].include?('check_point')
create_event(event_id, Vocab::CheckPoint, 80)
break
end
end
end
end
end
def update
super
change_opacity(24)
@player_sprite.x = self.x + object_x($game_player)
@player_sprite.y = self.y + object_y($game_player)
@event_sprites.each do |event_id, event_sprite|
event_sprite.x = self.x + object_x($game_map.events[event_id])
event_sprite.y = self.y + object_y($game_map.events[event_id])
update_tool_tip(event_id)
end
end
def update_tool_tip(event_id)
return if @tool_tip.visible && @last_tip_name != @event_data[event_id].name
@tool_tip.visible = in_area?(object_x($game_map.events[event_id]) - 24, object_y($game_map.events[event_id]), 40, 16)
if @tool_tip.visible
@tool_tip.x = Mouse.x + 18 + @event_data[event_id].width > Graphics.width ? Graphics.width - @event_data[event_id].width : Mouse.x + 18
@tool_tip.y = Mouse.y + 18 + @tool_tip.bitmap.height > Graphics.height ? Graphics.height - @tool_tip.bitmap.height : Mouse.y + 18
refresh_tool_tip(@event_data[event_id].name, @event_data[event_id].width) unless @last_tip_name == @event_data[event_id].name
end
end
end
Defina o fuso horário do servidor
SERVER_TIMEZONE_OFFSET = -1 # Ajuste conforme o fuso horário do servidor
#==============================================================================
# ** Sprite_Minimap
#------------------------------------------------------------------------------
# Esta classe lida com a exibição do mapa em miniatura.
#------------------------------------------------------------------------------
# Autor: Valentine Mod: Merim
#==============================================================================
class Sprite_Minimap < Sprite2
Event_Data = Struct.new(:name, :width)
def initialize
super
self.bitmap = Bitmap.new(172, 148) # Aumenta a altura para 148 para incluir a hora
self.x = adjust_x
self.y = 9
self.z = 50
self.bitmap.font.size = 15
@bitmap = Cache.system('Minimap')
@dragable = true
@event_sprites = {}
@event_data = {}
@last_tip_name = ''
create_player_point
create_tool_tip
refresh
update
end
def line_height
18
end
def adjust_x
Graphics.width - 188
end
def in_area?(x = 0, y = 0, w = self.bitmap.width, h = self.bitmap.height)
super(x + 24, y, w - 24, h)
end
def change_opacity(x = 0, y = 0)
super()
@player_sprite.opacity = self.opacity
@event_sprites.each_value { |sprite| sprite.opacity = self.opacity }
end
def create_player_point
@player_sprite = Sprite.new
@player_sprite.bitmap = Bitmap.new(16, 16)
@player_sprite.bitmap.blt(0, 0, @bitmap, Rect.new(142, 0, 16, 16))
@player_sprite.z = self.z + 1
end
def create_tool_tip
@tool_tip = Sprite.new
@tool_tip.bitmap = Bitmap.new(self.bitmap.width, line_height)
@tool_tip.z = @player_sprite.z + 1
end
def create_event(event_id, event_name, rect_y)
event_sprite = Sprite.new
event_sprite.bitmap = Bitmap.new(16, 16)
event_sprite.bitmap.blt(0, 0, @bitmap, Rect.new(142, rect_y, 16, 16))
event_sprite.x = self.x + object_x($game_map.events[event_id])
event_sprite.y = self.y + object_y($game_map.events[event_id])
event_sprite.z = self.z
@event_sprites[event_id] = event_sprite
@event_data[event_id] = Event_Data.new(event_name, text_width(event_name) + 8)
end
def dispose
super
@player_sprite.bitmap.dispose
@player_sprite.dispose
@tool_tip.bitmap.dispose
@tool_tip.dispose
dispose_events
end
def dispose_events
@event_sprites.each_value do |event|
event.bitmap.dispose
event.dispose
end
@event_sprites.clear
@event_data.clear
end
def object_x(object)
[[object.x * 134 / $game_map.width + 25, 33].max, 161].min
end
def object_y(object)
[[object.y * 106 / $game_map.height - 5, 3].max, 104].min
end
def refresh
@tool_tip.visible = false
draw_background
draw_icon
draw_map_name
draw_time # Desenha a hora abaixo do minimapa
dispose_events
if FileTest.exist?("Graphics/Minimaps/#{$game_map.map_id}.png")
draw_map
draw_events
else
@player_sprite.visible = false
end
end
def draw_background
self.bitmap.clear
self.bitmap.blt(30, 0, @bitmap, self.bitmap.rect)
end
def draw_icon
bitmap = Cache.system('Iconset')
icon_index = $game_map.pvp? ? Configs::MAP_PVP_ICON : Configs::MAP_NONPVP_ICON
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
self.bitmap.blt(0, 0, bitmap, rect)
end
def draw_map_name
self.bitmap.draw_text(30, 113, 142, 18, $game_map.display_name, 1)
end
def draw_time
current_time = server_time.strftime("%H:%M")
self.bitmap.draw_text(30, 130, 142, 18, current_time, 1)
end
def draw_map
bitmap = Cache.minimap($game_map.map_id.to_s)
self.bitmap.blt(33, 3, bitmap, bitmap.rect)
end
def refresh_tool_tip(event_name, width)
@last_tip_name = event_name
@tool_tip.bitmap.clear
rect = Rect.new(0, 0, width, @tool_tip.bitmap.height)
@tool_tip.bitmap.fill_rect(rect, Color.new(0, 0, 0, 160))
@tool_tip.bitmap.draw_text(rect, event_name, 1)
end
def draw_events
@player_sprite.visible = true
$game_map.events.each do |event_id, event|
next unless event.list
# Missão
if event.quest_not_started?
create_event(event_id, Vocab::Quest, 32)
next
# Boss
elsif event.boss?
create_event(event_id, Vocab::Boss, 96)
next
end
event.list.each do |item|
# Loja
if item.code == 302
create_event(event_id, Vocab::Shop, 16)
break
elsif item.code == 355
# Banco
if item.parameters[0].include?('open_bank')
create_event(event_id, Vocab::Bank, 48)
break
# Teletransporte
elsif item.parameters[0].include?('open_teleport')
create_event(event_id, Vocab::Teleport, 64)
break
# Ponto de referência
elsif item.parameters[0].include?('check_point')
create_event(event_id, Vocab::CheckPoint, 80)
break
end
end
end
end
end
def update
super
change_opacity(24)
@player_sprite.x = self.x + object_x($game_player)
@player_sprite.y = self.y + object_y($game_player)
@event_sprites.each do |event_id, event_sprite|
event_sprite.x = self.x + object_x($game_map.events[event_id])
event_sprite.y = self.y + object_y($game_map.events[event_id])
update_tool_tip(event_id)
end
end
def update_tool_tip(event_id)
return if @tool_tip.visible && @last_tip_name != @event_data[event_id].name
@tool_tip.visible = in_area?(object_x($game_map.events[event_id]) - 24, object_y($game_map.events[event_id]), 40, 16)
if @tool_tip.visible
@tool_tip.x = Mouse.x + 18 + @event_data[event_id].width > Graphics.width ? Graphics.width - @event_data[event_id].width : Mouse.x + 18
@tool_tip.y = Mouse.y + 18 + @tool_tip.bitmap.height > Graphics.height ? Graphics.height - @tool_tip.bitmap.height : Mouse.y + 18
refresh_tool_tip(@event_data[event_id].name, @event_data[event_id].width) unless @last_tip_name == @event_data[event_id].name
end
end
# Método para obter a hora do servidor
def server_time
Time.now.getutc + SERVER_TIMEZONE_OFFSET * 3600 # Adapta conforme o fuso horário do servidor
end
endidade = 25 # A variável `idade` armazena o valor 25
nome = "Alice" # A variável `nome` armazena o texto "Alice"
nome = "João"
idade = 30
altura = 1.75
idade = 25
idade = 26 # Agora idade é 26
a = 10
b = 5
soma = a + b # soma será 15
nome = "Alice"
sobrenome = "Silva"
nome_completo = nome + " " + sobrenome # nome_completo será "Alice Silva"