Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5123d1bc7e | ||
|
|
89f0da185b | ||
|
|
5804acfcec | ||
|
|
3e832c8446 | ||
|
|
3189092af2 |
No files matched your search
@@ -1,4 +1,11 @@
|
||||
|
||||
if defined?(MPIslandVoyage) && MPIslandVoyage.transit?
|
||||
$game_player.opacity = 255
|
||||
chcg_background_color(0,0,0,0,0)
|
||||
map_background_color(0,0,0,0,0)
|
||||
return
|
||||
end
|
||||
|
||||
$game_switches.data_common_event[:default] = false #turn off all GMI and HOM update
|
||||
$game_switches.data_common_event[:AutoCommon] = false
|
||||
map_background_color(0,0,0,255,0)
|
||||
|
||||
@@ -5,6 +5,11 @@ if $game_map.threat
|
||||
return
|
||||
end
|
||||
|
||||
# Online passage uses the ship map without the single-player ending.
|
||||
if defined?(MPIslandVoyage) && MPIslandVoyage.online?
|
||||
return MPIslandVoyage.edward_menu(self)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ def overmap_gen_WildDangerous
|
||||
end
|
||||
|
||||
def overmap_event_EnterMap(customData=nil)
|
||||
if defined?(MPIslandVoyage) && MPIslandVoyage.exit_tile?
|
||||
return MPIslandVoyage.exit_menu(self)
|
||||
end
|
||||
#overmap_roll_capturedXY
|
||||
#TODO 環境危險係數 RAND一個基本變數 當環境危險係數高於基本變數時 且玩家處於 REGION MAP 則NAP後出現敵人
|
||||
#TODO 基本變數為玩家的3*SURVIVAL+RAND(100)基本變數
|
||||
@@ -61,15 +64,17 @@ def overmap_event_EnterMap(customData=nil)
|
||||
$story_stats["WildDangerous"] += 100+rand(100)+$story_stats["WorldDifficulty"] if tgtOnRegionMapSpawnRace
|
||||
|
||||
loop_is_over = 0
|
||||
camp_tile = defined?(LonaCraft::Bases) && LonaCraft::Bases.respond_to?(:record_at_player) &&
|
||||
!LonaCraft::Bases.record_at_player.nil?
|
||||
until loop_is_over ==1
|
||||
tmpPicked = ""
|
||||
tmpQuestList = []
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Cancel"] ,"Region_option_Cancel"]
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Relax"] ,"Region_option_Relax"] if $game_player.actor.report_relax_able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Observe"] ,"Region_option_Observe"] if $game_player.actor.sta > 0 && tmp_Observe_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_RemoveTracks"] ,"Region_option_RemoveTracks"] if $game_player.actor.sta > 0 && tmp_RemoveTracks_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Relax"] ,"Region_option_Relax"] if !camp_tile && $game_player.actor.report_relax_able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Observe"] ,"Region_option_Observe"] if !camp_tile && $game_player.actor.sta > 0 && tmp_Observe_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_RemoveTracks"] ,"Region_option_RemoveTracks"] if !camp_tile && $game_player.actor.sta > 0 && tmp_RemoveTracks_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Enter"] ,"Region_option_Enter"] if tmp_Enter_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Kyaaah"] ,"Region_option_Kyaaah"] if tmp_Kyaaah_Able
|
||||
tmpQuestList << [$game_text["OvermapEvents:World/Region_option_Kyaaah"] ,"Region_option_Kyaaah"] if !camp_tile && tmp_Kyaaah_Able
|
||||
cmd_sheet = tmpQuestList
|
||||
cmd_text =""
|
||||
for i in 0...cmd_sheet.length
|
||||
|
||||
@@ -0,0 +1,447 @@
|
||||
# encoding: UTF-8
|
||||
# The IBRU_VIZ island is an online, server-authorized temporary mode.
|
||||
module MPIslandVoyage
|
||||
SHEET = '-char-M-REGULAR04'
|
||||
INDEX = 2
|
||||
@active = false
|
||||
@noclip = false
|
||||
@targets = {}
|
||||
|
||||
def self.online?
|
||||
defined?(WebSocket) && WebSocket.connected?
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def self.active?
|
||||
online? && !!@active
|
||||
end
|
||||
|
||||
def self.transit?
|
||||
!!@transit_runtime || ($story_stats && $story_stats['IBRU_Transit'].to_i == 1)
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def self.mark_transit
|
||||
@transit_runtime = true
|
||||
$story_stats['IBRU_Transit'] = 1 if $story_stats
|
||||
end
|
||||
|
||||
def self.exit_tile?
|
||||
online? && $game_map && $game_map.map_id == 2 && $game_player &&
|
||||
$game_player.x == 101 && $game_player.y == 106
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def self.edward_menu(interpreter)
|
||||
interpreter.call_msg('\\CBid[-1,2]\\SETpl[Mfat_DockCaptain]\\c[4]Эдвард:\\C[0] Куда направимся? \\optB[Отмена,Остров IBRU_VIZ]')
|
||||
choice = $game_temp.choice
|
||||
$game_temp.choice = -1
|
||||
board('out') if choice == 1
|
||||
end
|
||||
|
||||
def self.exit_menu(interpreter)
|
||||
interpreter.call_msg('\\CBid[-1,2]\\SETpl[Mfat_DockCaptain]\\c[4]Эдвард:\\C[0] Отплываем? \\optB[Отмена,Уплыть]')
|
||||
choice = $game_temp.choice
|
||||
$game_temp.choice = -1
|
||||
board('back') if choice == 1
|
||||
end
|
||||
|
||||
def self.board(direction)
|
||||
return unless online?
|
||||
@ship_ready_at = nil
|
||||
if $story_stats
|
||||
if direction == 'out'
|
||||
$story_stats['IBRU_ReturnOverX'] = $story_stats['LastOverMapX']
|
||||
$story_stats['IBRU_ReturnOverY'] = $story_stats['LastOverMapY']
|
||||
end
|
||||
end
|
||||
mark_transit
|
||||
WebSocket.send_line("ibru_board:#{direction}")
|
||||
end
|
||||
|
||||
def self.arrived(direction)
|
||||
@arrival = [direction, direction == 'out' ? 2 : 14]
|
||||
end
|
||||
|
||||
def self.tick
|
||||
unless online?
|
||||
set_active(false) if @active
|
||||
return
|
||||
end
|
||||
if WebSocket.respond_to?(:bootstrap_sync_unlocked?) && WebSocket.bootstrap_sync_unlocked? &&
|
||||
(!@hello_at || Time.now.to_f - @hello_at > 5)
|
||||
@hello_at = Time.now.to_f
|
||||
WebSocket.send_line('ibru_hello')
|
||||
end
|
||||
if transit? && $game_map && $game_map.map_id == 156 &&
|
||||
(!@ship_ready_at || Time.now.to_f - @ship_ready_at > 10)
|
||||
@ship_ready_at = Time.now.to_f
|
||||
WebSocket.send_line('ibru_ship_ready')
|
||||
end
|
||||
if @arrival && $game_map && $game_map.map_id == @arrival[1] && $game_message && !$game_message.busy?
|
||||
if $story_stats
|
||||
if @arrival[0] == 'out'
|
||||
$story_stats['LastOverMapX'] = 101
|
||||
$story_stats['LastOverMapY'] = 106
|
||||
$story_stats['OverMapID'] = 2
|
||||
else
|
||||
x = $story_stats['IBRU_ReturnOverX'].to_i
|
||||
y = $story_stats['IBRU_ReturnOverY'].to_i
|
||||
$story_stats['LastOverMapX'] = x if x > 0
|
||||
$story_stats['LastOverMapY'] = y if y > 0
|
||||
$story_stats.delete('IBRU_ReturnOverX') if $story_stats.respond_to?(:delete)
|
||||
$story_stats.delete('IBRU_ReturnOverY') if $story_stats.respond_to?(:delete)
|
||||
end
|
||||
$story_stats['IBRU_Transit'] = 0
|
||||
end
|
||||
@transit_runtime = false
|
||||
@ship_ready_at = nil
|
||||
$game_message.background = 0
|
||||
$game_message.position = 2
|
||||
$game_message.add('\\CBid[-1,2]\\SETpl[Mfat_DockCaptain]\\c[4]Эдвард:\\C[0] Приплыли.')
|
||||
@arrival = nil
|
||||
end
|
||||
if active? && (!@skin_applied || ($game_player &&
|
||||
($game_player.instance_variable_get(:@chs_type).to_s != SHEET ||
|
||||
$game_player.charset_index.to_i != INDEX)))
|
||||
apply_skin
|
||||
end
|
||||
rescue => e
|
||||
puts("[IBRU] tick: #{e.class}: #{e.message}") rescue nil
|
||||
end
|
||||
|
||||
def self.set_active(value)
|
||||
value = !!value
|
||||
return if @active == value
|
||||
@active = value
|
||||
unless value
|
||||
@noclip = false
|
||||
@targets = {}
|
||||
MPGodMode.reset if defined?(MPGodMode)
|
||||
restore_skin
|
||||
if defined?(WebSocket)
|
||||
WebSocket.instance_variable_set(:@admin_ghost_enabled, false)
|
||||
WebSocket.instance_variable_set(:@admin_see_hidden_enabled, false)
|
||||
WebSocket.instance_variable_set(:@ninja_local_last_active, nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.noclip?
|
||||
active? && !!@noclip
|
||||
end
|
||||
|
||||
def self.set_noclip(value)
|
||||
@noclip = !!value
|
||||
end
|
||||
|
||||
def self.targets
|
||||
@targets || {}
|
||||
end
|
||||
|
||||
def self.set_targets(value)
|
||||
@targets = value
|
||||
end
|
||||
|
||||
def self.apply_skin
|
||||
return unless active? && $game_player && defined?(WebSocket)
|
||||
return unless WebSocket.respond_to?(:mp_male_apply_specific_skin)
|
||||
@previous_male ||= [WebSocket.mp_male_skin_active?,
|
||||
($story_stats[WebSocket::MP_MALE_CHS_KEY].to_s rescue ''),
|
||||
($story_stats[WebSocket::MP_MALE_CHS_IDX_KEY].to_i rescue 0)]
|
||||
WebSocket.mp_male_set_flag(1)
|
||||
@skin_applied = WebSocket.mp_male_apply_specific_skin(SHEET, INDEX)
|
||||
rescue => e
|
||||
puts("[IBRU] skin: #{e.class}: #{e.message}") rescue nil
|
||||
end
|
||||
|
||||
def self.restore_skin
|
||||
return unless @skin_applied && defined?(WebSocket)
|
||||
previous = @previous_male
|
||||
if previous && previous[0] && previous[1] != ''
|
||||
WebSocket.mp_male_apply_specific_skin(previous[1], previous[2])
|
||||
else
|
||||
WebSocket.mp_male_set_flag(0)
|
||||
WebSocket.mp_male_restore_lona_skin
|
||||
end
|
||||
ensure
|
||||
@skin_applied = false
|
||||
@previous_male = nil
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(Game_Player)
|
||||
module MPIslandVoyageMovementPatch
|
||||
def movable?(*args, &block)
|
||||
return false if MPIslandVoyage.transit? && $game_map && $game_map.map_id == 156
|
||||
super
|
||||
end
|
||||
end
|
||||
Game_Player.prepend(MPIslandVoyageMovementPatch) unless Game_Player.ancestors.include?(MPIslandVoyageMovementPatch)
|
||||
end
|
||||
|
||||
if defined?(WebSocket)
|
||||
# PresenceVersionGate and several other mods already prepend WebSocket.
|
||||
# Aliasing their parse/disconnect methods here makes their super call return
|
||||
# to this wrapper forever. A final prepend keeps the lookup chain linear.
|
||||
module MPIslandVoyageWebSocketPatch
|
||||
def parse(message)
|
||||
# The server uses a distinct room ID for island interiors. Only the
|
||||
# transport layer sees it; the game loads the original map data.
|
||||
if message =~ /\Abootstrap_map:(10\d{3})\z/
|
||||
MPIslandVoyage.mark_transit if $1.to_i == 10_156
|
||||
message = "bootstrap_map:#{$1.to_i - 10_000}"
|
||||
elsif message =~ /\Abootstrap_state:(10\d{3}):(.*)\z/m
|
||||
message = "bootstrap_state:#{$1.to_i - 10_000}:#{$2}"
|
||||
elsif message =~ /\Apvp_force_spawn:(10\d{3}):(.*)\z/m
|
||||
message = "pvp_force_spawn:#{$1.to_i - 10_000}:#{$2}"
|
||||
end
|
||||
case message
|
||||
when /\Aibru_state:([01])\z/
|
||||
MPIslandVoyage.set_active($1 == '1')
|
||||
return
|
||||
when /\Aibru_noclip_state:([01])\z/
|
||||
MPIslandVoyage.set_noclip($1 == '1')
|
||||
return
|
||||
when /\Aibru_arrived:(out|back)\z/
|
||||
MPIslandVoyage.arrived($1)
|
||||
return
|
||||
when /\Aibru_board_reject\z/
|
||||
$story_stats['IBRU_Transit'] = 0 if $story_stats
|
||||
MPIslandVoyage.instance_variable_set(:@transit_runtime, false)
|
||||
MPIslandVoyage.instance_variable_set(:@ship_ready_at, nil)
|
||||
chat_local_system('Эдвард: переправа сейчас недоступна.') if respond_to?(:chat_local_system)
|
||||
return
|
||||
when /\Aibru_targets:(.*)\z/
|
||||
list = {}
|
||||
$1.split('|').each do |entry|
|
||||
id, name = entry.split(':', 2)
|
||||
list[id.to_i] = unesc(name) if id.to_i > 0 && name
|
||||
end
|
||||
MPIslandVoyage.set_targets(list)
|
||||
return
|
||||
end
|
||||
super(message)
|
||||
end
|
||||
|
||||
def disconnect(*args, &block)
|
||||
MPIslandVoyage.set_active(false)
|
||||
super
|
||||
end
|
||||
|
||||
def admin_noclip_enabled?
|
||||
MPIslandVoyage.noclip? || super
|
||||
end
|
||||
|
||||
def admin_see_hidden_enabled?
|
||||
(MPIslandVoyage.active? && !!@admin_see_hidden_enabled) || super
|
||||
end
|
||||
|
||||
def admin_can_ghost?
|
||||
MPIslandVoyage.active? || super
|
||||
end
|
||||
end
|
||||
sc = WebSocket.singleton_class
|
||||
sc.prepend(MPIslandVoyageWebSocketPatch) unless sc.ancestors.include?(MPIslandVoyageWebSocketPatch)
|
||||
end
|
||||
|
||||
if defined?(MPGodMode)
|
||||
module MPGodMode
|
||||
class << self
|
||||
alias ibru_active_without active? unless method_defined?(:ibru_active_without)
|
||||
def active?
|
||||
return !!@enabled && MPIslandVoyage.active? && Time.now.to_f < @expires.to_f if MPIslandVoyage.active?
|
||||
ibru_active_without
|
||||
end
|
||||
alias ibru_toggle_without request_toggle unless method_defined?(:ibru_toggle_without)
|
||||
def request_toggle
|
||||
return ibru_toggle_without unless MPIslandVoyage.active?
|
||||
return if pending? || !WebSocket.connected?
|
||||
@pending_at = Time.now.to_f
|
||||
WebSocket.send_line("god_toggle:#{active? ? 0 : 1}")
|
||||
refresh_menu
|
||||
end
|
||||
alias ibru_tick_without tick unless method_defined?(:ibru_tick_without)
|
||||
def tick
|
||||
ibru_tick_without
|
||||
MPIslandVoyage.tick
|
||||
if MPIslandVoyage.active? && WebSocket.bootstrap_sync_unlocked? && (!@ibru_hello_at || Time.now.to_f - @ibru_hello_at > 10)
|
||||
@ibru_hello_at = Time.now.to_f
|
||||
WebSocket.send_line('god_hello:1')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Keep the island tools in the existing VIP overlay, without granting OWNER.
|
||||
if defined?(Scene_Map) && Scene_Map.method_defined?(:mp_admin_open_root)
|
||||
class Scene_Map
|
||||
alias ibru_hotkey_without mp_admin_update_hotkey unless method_defined?(:ibru_hotkey_without)
|
||||
def mp_admin_update_hotkey
|
||||
return ibru_hotkey_without unless MPIslandVoyage.active? && WebSocket.admin_role_rank <= 0
|
||||
return if MPAdminMenu.blocked_by_other_ui? || !MPAdminMenu.open_triggered?
|
||||
mp_admin_menu_active? ? mp_admin_dispose_menu : mp_admin_open_root
|
||||
end
|
||||
|
||||
alias ibru_validate_role_without mp_admin_validate_menu_role unless method_defined?(:ibru_validate_role_without)
|
||||
def mp_admin_validate_menu_role
|
||||
return if MPIslandVoyage.active? && WebSocket.connected?
|
||||
ibru_validate_role_without
|
||||
end
|
||||
|
||||
alias ibru_admin_root_without mp_admin_open_root unless method_defined?(:ibru_admin_root_without)
|
||||
def mp_admin_open_root
|
||||
return ibru_admin_root_without unless MPIslandVoyage.active?
|
||||
rows = []
|
||||
rows << [MPAdminMenu::ROOT_STYLE_TEXT, :style_root, true, nil] if WebSocket.admin_can_style?
|
||||
rows << [MPAdminMenu::ROOT_EMOJI_TEXT, :emoji_root, true, nil] if WebSocket.admin_can_style?
|
||||
rows << ["Noclip: #{MPIslandVoyage.noclip? ? 'ВКЛ' : 'ВЫКЛ'}", :ibru_noclip, true, nil]
|
||||
rows << [MPAdminMenu.see_hidden_label, :ibru_hidden, true, nil]
|
||||
rows << [MPAdminMenu.ghost_label, :ibru_ghost, true, nil]
|
||||
rows << ['Телепортироваться к игроку на острове', :ibru_teleport, true, nil]
|
||||
rows << [MPGodMode.label, :ibru_god, !MPGodMode.pending?, nil] if defined?(MPGodMode)
|
||||
mp_admin_show_commands(rows, :root, 360)
|
||||
@mp_admin_window.set_handler(:style_root, method(:mp_admin_open_style_menu))
|
||||
@mp_admin_window.set_handler(:emoji_root, method(:mp_admin_open_emoji_side_menu))
|
||||
@mp_admin_window.set_handler(:ibru_noclip, method(:ibru_toggle_noclip))
|
||||
@mp_admin_window.set_handler(:ibru_hidden, method(:ibru_toggle_hidden))
|
||||
@mp_admin_window.set_handler(:ibru_ghost, method(:ibru_toggle_ghost))
|
||||
@mp_admin_window.set_handler(:ibru_teleport, method(:ibru_open_targets))
|
||||
@mp_admin_window.set_handler(:ibru_god, method(:ibru_toggle_god)) if defined?(MPGodMode)
|
||||
@mp_admin_window.set_handler(:cancel, method(:mp_admin_dispose_menu))
|
||||
end
|
||||
|
||||
alias ibru_admin_back_without mp_admin_back unless method_defined?(:ibru_admin_back_without)
|
||||
def mp_admin_back
|
||||
return mp_admin_open_root if @mp_admin_state == :ibru_targets
|
||||
ibru_admin_back_without
|
||||
end
|
||||
|
||||
def ibru_toggle_noclip
|
||||
WebSocket.send_line('ibru_noclip_toggle') if MPIslandVoyage.active?
|
||||
mp_admin_open_root
|
||||
end
|
||||
|
||||
def ibru_toggle_hidden
|
||||
if MPIslandVoyage.active?
|
||||
current = WebSocket.instance_variable_get(:@admin_see_hidden_enabled)
|
||||
WebSocket.instance_variable_set(:@admin_see_hidden_enabled, !current)
|
||||
end
|
||||
mp_admin_open_root
|
||||
end
|
||||
|
||||
def ibru_toggle_ghost
|
||||
WebSocket.admin_toggle_ghost if MPIslandVoyage.active?
|
||||
mp_admin_open_root
|
||||
end
|
||||
|
||||
def ibru_toggle_god
|
||||
MPGodMode.request_toggle if MPIslandVoyage.active?
|
||||
mp_admin_open_root
|
||||
end
|
||||
|
||||
def ibru_open_targets
|
||||
return mp_admin_open_root unless MPIslandVoyage.active?
|
||||
WebSocket.send_line('ibru_targets_req')
|
||||
rows = MPIslandVoyage.targets.map { |id, nick| [nick, :ibru_target, true, id] }
|
||||
rows = [['На острове нет других игроков', :noop, false, nil]] if rows.empty?
|
||||
mp_admin_show_commands(rows, :ibru_targets, 360)
|
||||
@mp_admin_window.set_handler(:ibru_target, method(:ibru_teleport_target))
|
||||
@mp_admin_window.set_handler(:cancel, method(:mp_admin_open_root))
|
||||
end
|
||||
|
||||
def ibru_teleport_target
|
||||
if MPIslandVoyage.active? && @mp_admin_window
|
||||
WebSocket.send_line("ibru_tp_to:#{@mp_admin_window.current_ext.to_i}")
|
||||
end
|
||||
mp_admin_dispose_menu
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(MPAdminMenu)
|
||||
module MPAdminMenu
|
||||
class << self
|
||||
alias ibru_grid_title_without grid_title unless method_defined?(:ibru_grid_title_without)
|
||||
def grid_title(state)
|
||||
return 'Остров IBRU_VIZ' if state == :root && MPIslandVoyage.active?
|
||||
ibru_grid_title_without(state)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Gray the item entry and block both keyboard and mouse access to its page.
|
||||
if defined?(Menu_Command)
|
||||
class Menu_Command
|
||||
alias ibru_menu_initialize_without initialize unless method_defined?(:ibru_menu_initialize_without)
|
||||
def initialize(command_names)
|
||||
@ibru_item_index = command_names.index($game_text['menu:core/items']) rescue nil
|
||||
ibru_menu_initialize_without(command_names)
|
||||
end
|
||||
alias ibru_menu_refresh_without refresh unless method_defined?(:ibru_menu_refresh_without)
|
||||
def refresh
|
||||
ibru_menu_refresh_without
|
||||
if MPIslandVoyage.active? && @ibru_item_index && @menu_sprites[@ibru_item_index]
|
||||
@menu_sprites[@ibru_item_index].opacity = 65
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(Scene_Menu)
|
||||
class Scene_Menu
|
||||
alias ibru_menu_start_without start unless method_defined?(:ibru_menu_start_without)
|
||||
def start(*args, &block)
|
||||
result = ibru_menu_start_without(*args, &block)
|
||||
if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items)
|
||||
ibru_menu_switch_without(0)
|
||||
end
|
||||
result
|
||||
end
|
||||
alias ibru_menu_switch_without process_switchMenuIndex unless method_defined?(:ibru_menu_switch_without)
|
||||
def process_switchMenuIndex(index)
|
||||
if MPIslandVoyage.active? && @contents && @contents.contents[index].is_a?(Menu_Items)
|
||||
direction = index.to_i >= @menu_index.to_i ? 1 : -1
|
||||
skip = index.to_i + direction
|
||||
return if skip < 0 || skip >= @contents.contents.size
|
||||
index = skip
|
||||
end
|
||||
ibru_menu_switch_without(index)
|
||||
end
|
||||
alias ibru_menu_ok_without process_ok unless method_defined?(:ibru_menu_ok_without)
|
||||
def process_ok
|
||||
return SndLib.sys_buzzer if MPIslandVoyage.active? && @contents && @contents.contents[@menu_index].is_a?(Menu_Items)
|
||||
ibru_menu_ok_without
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Local NPC combat is client simulated; suppress its damage before the server
|
||||
# relay as well, so an island owner cannot hurt either NPCs or players.
|
||||
if defined?(Battle_System)
|
||||
module IbruIslandNoDamage
|
||||
def take_damage(user, *args, &block)
|
||||
return [] if MPIslandVoyage.active? && $game_player && user.equal?($game_player.actor)
|
||||
super
|
||||
end
|
||||
def apply_skill_state_effect(skill, user, *args, &block)
|
||||
return if MPIslandVoyage.active? && $game_player && user.equal?($game_player.actor)
|
||||
super
|
||||
end
|
||||
end
|
||||
Battle_System.prepend(IbruIslandNoDamage)
|
||||
end
|
||||
if defined?(Game_SandboxObject)
|
||||
class Game_SandboxObject
|
||||
alias ibru_sandbox_damage_without take_damage unless method_defined?(:ibru_sandbox_damage_without)
|
||||
def take_damage(user, *args, &block)
|
||||
return [] if MPIslandVoyage.active? && $game_player && user.equal?($game_player.actor)
|
||||
ibru_sandbox_damage_without(user, *args, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1997,19 +1997,23 @@ module LonaCraft
|
||||
nil
|
||||
end
|
||||
|
||||
# (x, y) is open ground: passable from all 4 sides, no water or bush.
|
||||
# Grass carries the bush flag but is still usable ground. Wilderness camp
|
||||
# tiles need one walkable approach; sewer geometry keeps its stricter rule.
|
||||
# A tile showing one of our faces is judged by the map file's own tiles.
|
||||
def self.ground_ok?(map, pieces, x, y)
|
||||
return false if map.water_floor?(x, y)
|
||||
return false if named_map?(map) && map.bush?(x, y)
|
||||
if face_at(pieces, map, x, y).nil?
|
||||
return false if map.water_floor?(x, y) || map.bush?(x, y)
|
||||
return [2, 4, 6, 8].all?{|d| map.passable?(x, y, d) }
|
||||
directions = [2, 4, 6, 8]
|
||||
return named_map?(map) ? directions.all?{|d| map.passable?(x, y, d) } :
|
||||
directions.any?{|d| map.passable?(x, y, d) }
|
||||
end
|
||||
orig = original_data(map)
|
||||
return false if orig.nil?
|
||||
flags = map.tileset.flags
|
||||
tiles = [orig[x, y, 2], orig[x, y, 1], orig[x, y, 0]]
|
||||
return false if tiles.any?{|t| flags[t] & 0x40 != 0 }
|
||||
[1, 2, 4, 8].all?{|bit|
|
||||
return false if tiles.any?{|t| flags[t] & 0x100 != 0 }
|
||||
check = lambda{|bit|
|
||||
res = false
|
||||
tiles.each{|t|
|
||||
f = flags[t]
|
||||
@@ -2019,6 +2023,8 @@ module LonaCraft
|
||||
}
|
||||
res
|
||||
}
|
||||
bits = [1, 2, 4, 8]
|
||||
named_map?(map) ? bits.all?{|bit| check.call(bit) } : bits.any?{|bit| check.call(bit) }
|
||||
end
|
||||
|
||||
# Where a door may stand (A4 walls): in the FACE row under a wall that runs
|
||||
@@ -3709,12 +3715,30 @@ class Game_Interpreter
|
||||
def call_msg(*args)
|
||||
msg = args[0]
|
||||
rec = nil
|
||||
if msg.is_a?(String) && msg =~ /\AOvermapEvents:World\/Region\d+\z/ && $game_map && $game_map.isOverMap
|
||||
rec = LonaCraft::Bases.record_at_player
|
||||
if rec
|
||||
original = $game_text[msg].to_s
|
||||
label = LonaCraft::Bases.name_of(rec).gsub(LonaCraft::Bases::NAME_DROP, '')
|
||||
title = original.sub(/\A(\\cg\[[^\]]+\])?[^\r\n]*/) do |line|
|
||||
graphic = line[/\A\\cg\[[^\]]+\]/].to_s
|
||||
graphic + label
|
||||
end
|
||||
new_args = args.dup
|
||||
new_args[0] = LonaCraft::RuntimeText.key('Bases', 'rt_camp_region', title)
|
||||
return call_msg_lonacraft_bases(*new_args)
|
||||
end
|
||||
end
|
||||
if msg.is_a?(String) && msg.include?("\\optB[") && $game_map && $game_map.isOverMap
|
||||
start = $game_text["OvermapEvents:World/Region_option_start"].to_s
|
||||
rec = LonaCraft::Bases.record_at_player if !start.empty? && msg.start_with?(start)
|
||||
end
|
||||
return call_msg_lonacraft_bases(*args) if rec.nil?
|
||||
got = LonaCraft::Homes.extend_menu(msg, LonaCraft::Bases.menu_labels(rec), nil) if defined?(LonaCraft::Homes)
|
||||
return call_msg_lonacraft_bases(*args) unless LonaCraft::Bases.manageable?(rec)
|
||||
labels = LonaCraft::Bases.menu_labels(rec)
|
||||
access_option = rec['lc_shared'] && LonaCraft::OnlineSync.ready?
|
||||
labels << 'Доступ к лагерю' if access_option
|
||||
got = LonaCraft::Homes.extend_menu(msg, labels, nil) if defined?(LonaCraft::Homes)
|
||||
return call_msg_lonacraft_bases(*args) if got.nil?
|
||||
new_args = args.dup
|
||||
new_args[0] = got[0]
|
||||
@@ -3725,6 +3749,9 @@ class Game_Interpreter
|
||||
elsif $game_temp.choice == got[1] + 1
|
||||
$game_temp.choice = -1
|
||||
LonaCraft::Bases.cycle_danger(rec) # R10
|
||||
elsif access_option && $game_temp.choice == got[1] + 2
|
||||
$game_temp.choice = -1
|
||||
lonacraft_base_access_menu(rec) if respond_to?(:lonacraft_base_access_menu)
|
||||
end
|
||||
result
|
||||
rescue => e
|
||||
|
||||
@@ -643,6 +643,12 @@ module LonaCraft
|
||||
owner = owner_name(info['owner'])
|
||||
label = LonaCraft::Bases.clean_name(info['name'])
|
||||
label = camp_name(owner) if label.empty? && !owner.empty?
|
||||
access = Array(info['access']).select do |entry|
|
||||
entry.is_a?(Hash) && entry['profile'].is_a?(Integer) && entry['profile'] > 0 &&
|
||||
entry['name'].is_a?(String) && !owner_name(entry['name']).empty?
|
||||
end.first(12).map do |entry|
|
||||
{'profile'=>entry['profile'], 'name'=>owner_name(entry['name'])}
|
||||
end
|
||||
danger = info['danger'].is_a?(Integer) && info['danger'] >= -1 && info['danger'] <= 1 ? info['danger'] : 0
|
||||
bases = LonaCraft::Bases
|
||||
root = bases.root
|
||||
@@ -663,6 +669,7 @@ module LonaCraft
|
||||
# replace its structures; fill in its shared display metadata.
|
||||
if existing['key'].to_s == key && existing['map_no'].to_i == no
|
||||
existing['owner'] = owner unless owner.empty?
|
||||
existing['lc_access'] = access
|
||||
pending_meta = @pending_camp_meta[camp_ack_key(om, id)]
|
||||
unless pending_meta
|
||||
existing['name'] = label unless label.empty?
|
||||
@@ -683,7 +690,7 @@ module LonaCraft
|
||||
return false if registered.to_i != no
|
||||
rec = {'id'=>id, 'om'=>om, 'region'=>region, 'field'=>field,
|
||||
'key'=>key, 'map_no'=>no, 'pieces'=>{}, 'made'=>bases.date_now,
|
||||
'owner'=>owner, 'name'=>label, 'danger'=>danger, 'lc_shared'=>true}
|
||||
'owner'=>owner, 'name'=>label, 'danger'=>danger, 'lc_access'=>access, 'lc_shared'=>true}
|
||||
bases.list << rec
|
||||
root['next_id'] = [root['next_id'].to_i, id + 1].max
|
||||
refresh_marker(rec) if world
|
||||
|
||||
@@ -0,0 +1,442 @@
|
||||
# encoding: UTF-8
|
||||
# Shared LonaCraft camp permissions. The server stores authenticated profile
|
||||
# IDs in the canonical camp record; clients display the matching names.
|
||||
module LonaCraft
|
||||
module CampAccess
|
||||
MAX_MEMBERS = 12
|
||||
|
||||
def self.normal_name(value)
|
||||
LonaCraft::OnlineSync.owner_name(value).downcase
|
||||
end
|
||||
|
||||
def self.members(rec)
|
||||
return [] unless rec.is_a?(Hash)
|
||||
Array(rec['lc_access']).select { |entry| entry.is_a?(Hash) }.
|
||||
map { |entry| LonaCraft::OnlineSync.owner_name(entry['name']) }.
|
||||
reject { |name| name.empty? }.
|
||||
uniq { |name| name.downcase }.first(MAX_MEMBERS)
|
||||
end
|
||||
|
||||
def self.entries(rec)
|
||||
return [] unless rec.is_a?(Hash)
|
||||
Array(rec['lc_access']).select do |entry|
|
||||
entry.is_a?(Hash) && entry['profile'].to_i > 0 && !entry['name'].to_s.empty?
|
||||
end.first(MAX_MEMBERS)
|
||||
end
|
||||
|
||||
def self.owner?(rec)
|
||||
LonaCraft::OnlineSync.owns_camp?(rec)
|
||||
end
|
||||
|
||||
def self.allowed?(rec)
|
||||
return true unless rec.is_a?(Hash) && rec['lc_shared']
|
||||
return true if owner?(rec)
|
||||
return false unless LonaCraft::OnlineSync.ready?
|
||||
local = normal_name((::WebSocket.local_nickname rescue nil))
|
||||
!local.empty? && members(rec).any? { |name| normal_name(name) == local }
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def self.online_players
|
||||
return [] unless defined?(::WebSocket) && ::WebSocket.respond_to?(:nickname_for)
|
||||
players = ::WebSocket.instance_variable_get(:@players)
|
||||
return [] unless players.respond_to?(:each)
|
||||
names = []
|
||||
players.each do |pid, _player|
|
||||
name = LonaCraft::OnlineSync.owner_name(::WebSocket.nickname_for(pid))
|
||||
names << [pid.to_i, name] unless name.empty? || pid.to_i <= 0
|
||||
end
|
||||
names.uniq { |pair| pair[0] }.sort_by { |pair| pair[1].downcase }
|
||||
rescue
|
||||
[]
|
||||
end
|
||||
|
||||
def self.sender_allowed?(rec, sender)
|
||||
return true unless rec.is_a?(Hash) && rec['lc_shared']
|
||||
return true if sender.to_i == 0 # server-originated canonical state
|
||||
return false if sender.to_i <= 0
|
||||
nick = normal_name((::WebSocket.nickname_for(sender.to_i) rescue nil))
|
||||
return false if nick.empty?
|
||||
nick == normal_name(rec['owner']) || members(rec).any? { |name| normal_name(name) == nick }
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def self.refuse
|
||||
SndLib.sys_buzzer if defined?(SndLib)
|
||||
$game_map.popup(0, LonaCraft::Bases.text_key('Access/denied'), 0, 0) if $game_map
|
||||
false
|
||||
end
|
||||
|
||||
def self.creation_block_reason(map)
|
||||
return nil unless map && !map.isOverMap && LonaCraft::OnlineSync.ready?
|
||||
entry = LonaCraft::Bases.entry
|
||||
return nil unless entry.is_a?(Hash) && entry['om'].is_a?(Array) && entry['om'].size == 3
|
||||
coords = entry['om'].map(&:to_i)
|
||||
owner = normal_name((::WebSocket.local_nickname rescue nil))
|
||||
LonaCraft::Bases.list.each do |base|
|
||||
next unless base.is_a?(Hash) && base['lc_shared'] && base['om'].is_a?(Array)
|
||||
return LonaCraft::Bases.text_key('Access/one_camp') if normal_name(base['owner']) == owner && !owner.empty?
|
||||
other = base['om'].map(&:to_i)
|
||||
if other[0] == coords[0] && (other[1] - coords[1]).abs <= 2 && (other[2] - coords[2]).abs <= 2
|
||||
return LonaCraft::Bases.text_key('Access/near_camp')
|
||||
end
|
||||
end
|
||||
reason = LonaCraft::OnlineSync.camp_creation_reason(coords)
|
||||
return nil if reason == 'ok'
|
||||
LonaCraft::Bases.text_key('Access/' + (reason == 'already_owned' ? 'one_camp' :
|
||||
reason == 'too_close' ? 'near_camp' : 'checking'))
|
||||
rescue StandardError
|
||||
LonaCraft::Bases.text_key('Access/checking')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module LonaCraft
|
||||
module Bases
|
||||
class << self
|
||||
alias_method :lc_access_previous_can_build_here, :can_build_here?
|
||||
def can_build_here?(map = $game_map)
|
||||
rec = record_for_map(map) if map
|
||||
return text_key('Access/denied') if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
reason = lc_access_previous_can_build_here(map)
|
||||
return reason unless reason.nil?
|
||||
LonaCraft::CampAccess.creation_block_reason(map)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_place_block_reason, :place_block_reason
|
||||
def place_block_reason(map, code)
|
||||
rec = record_for_map(map) if map
|
||||
return text_key('Access/denied') if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
reason = LonaCraft::CampAccess.creation_block_reason(map) unless rec
|
||||
return reason if reason
|
||||
lc_access_previous_place_block_reason(map, code)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_place_piece, :place_piece
|
||||
def place_piece(map, code, x, y)
|
||||
rec = record_for_map(map) if map
|
||||
return nil if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
lc_access_previous_place_piece(map, code, x, y)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_take_down, :take_down
|
||||
def take_down(map, x, y, part)
|
||||
rec = record_for_map(map) if map
|
||||
return nil if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
lc_access_previous_take_down(map, x, y, part)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_repair_piece, :repair_piece
|
||||
def repair_piece(map, x, y, interp)
|
||||
rec = record_for_map(map) if map
|
||||
return LonaCraft::CampAccess.refuse if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
lc_access_previous_repair_piece(map, x, y, interp)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_action_on_piece, :action_on_piece
|
||||
def action_on_piece(player)
|
||||
map = $game_map
|
||||
rec = record_for_map(map) if map && !map.isOverMap
|
||||
if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
x, y = front_tile(player)
|
||||
pieces = pieces_of(rec)
|
||||
x, y = owner_tile(pieces, map, x, y)
|
||||
value = pieces[piece_key(x, y)]
|
||||
if wall?(value) || (floor?(value) && !door?(value))
|
||||
LonaCraft::CampAccess.refuse
|
||||
return true
|
||||
end
|
||||
end
|
||||
lc_access_previous_action_on_piece(player)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_furniture_map_ok, :furniture_map_ok?
|
||||
def furniture_map_ok?(map)
|
||||
rec = record_for_map(map) if map
|
||||
return false if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
lc_access_previous_furniture_map_ok(map)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module LonaCraft
|
||||
module Furniture
|
||||
class << self
|
||||
alias_method :lc_access_previous_map_allowed, :map_allowed?
|
||||
def map_allowed?(map = $game_map)
|
||||
rec = LonaCraft::Bases.record_for_map(map) if map
|
||||
return false if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
lc_access_previous_map_allowed(map)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_block_reason, :block_reason
|
||||
def block_reason(map = $game_map)
|
||||
rec = LonaCraft::Bases.record_for_map(map) if map
|
||||
return LonaCraft::Bases.text_key('Access/denied') if rec && !LonaCraft::CampAccess.allowed?(rec)
|
||||
reason = LonaCraft::CampAccess.creation_block_reason(map) unless rec
|
||||
return reason if reason
|
||||
lc_access_previous_block_reason(map)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_place, :place
|
||||
def place(map, item_name, x, y)
|
||||
rec = LonaCraft::Bases.record_for_map(map) if map
|
||||
return nil if rec && !LonaCraft::CampAccess.allowed?(rec) && !LonaCraft::OnlineSync.applying_remote_access?
|
||||
lc_access_previous_place(map, item_name, x, y)
|
||||
end
|
||||
|
||||
alias_method :lc_access_previous_remove, :remove
|
||||
def remove(map, uid)
|
||||
rec = LonaCraft::Bases.record_for_map(map) if map
|
||||
return nil if rec && !LonaCraft::CampAccess.allowed?(rec) && !LonaCraft::OnlineSync.applying_remote_access?
|
||||
lc_access_previous_remove(map, uid)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module LonaCraft
|
||||
module OnlineSync
|
||||
def self.camp_creation_reason(coords)
|
||||
return nil unless ready? && coords.is_a?(Array) && coords.size == 3
|
||||
token = map_token
|
||||
time = now
|
||||
state = @lc_camp_check
|
||||
if !state || state['token'] != token || state['om'] != coords ||
|
||||
(state['reason'].nil? && time - state['sent'].to_f > 3.0)
|
||||
@lc_camp_check = {'token'=>token, 'om'=>coords, 'sent'=>time, 'reason'=>nil}
|
||||
send_now({'v'=>1, 'm'=>token, 'o'=>'camp_check', 'd'=>{'om'=>coords}})
|
||||
end
|
||||
@lc_camp_check['reason']
|
||||
end
|
||||
|
||||
def self.receive_camp_check(packet, sender)
|
||||
return false unless sender.to_i == 0 && @lc_camp_check
|
||||
info = packet['d']
|
||||
return false unless info.is_a?(Hash) && packet['m'] == @lc_camp_check['token']
|
||||
return false unless info['om'] == @lc_camp_check['om']
|
||||
return false unless %w[ok already_owned too_close].include?(info['reason'])
|
||||
@lc_camp_check['reason'] = info['reason']
|
||||
true
|
||||
end
|
||||
|
||||
def self.receive_camp_reject(packet, sender)
|
||||
return false unless sender.to_i == 0
|
||||
info = packet['d']
|
||||
return false unless info.is_a?(Hash) && info['om'].is_a?(Array)
|
||||
return false unless %w[already_owned too_close].include?(info['reason'])
|
||||
key = camp_ack_key(info['om'], info['id'])
|
||||
return false unless @pending_new_camps[key]
|
||||
rec = LonaCraft::Bases.record_for_tile(*info['om'])
|
||||
return false unless rec && rec['id'].to_i == info['id'].to_i && owns_camp?(rec)
|
||||
unless defined?(LonaCraft::Debug) && LonaCraft::Debug.free?
|
||||
rec['pieces'].each_value do |value|
|
||||
names = []
|
||||
names << (LonaCraft::Bases.stone?(value) ? LonaCraft::Bases::STONE_ITEM : LonaCraft::Bases::WALL_ITEM) if LonaCraft::Bases.wall?(value)
|
||||
names << LonaCraft::Bases::FLOOR_ITEM if LonaCraft::Bases.floor?(value)
|
||||
names << LonaCraft::Bases::DOOR_ITEM if LonaCraft::Bases.door?(value)
|
||||
names.each do |name|
|
||||
item = $data_ItemName[name]
|
||||
$game_party.gain_item(item, 1) if item
|
||||
end
|
||||
end if rec['pieces'].is_a?(Hash)
|
||||
end
|
||||
@pending_new_camps.delete(key)
|
||||
@pending_camp_meta.delete(key)
|
||||
@saved_camps.delete(key)
|
||||
@outbox.clear
|
||||
@observed = {}
|
||||
LonaCraft::Bases.destroy_records!([rec])
|
||||
reason = info['reason'] == 'already_owned' ? 'one_camp' : 'near_camp'
|
||||
SndLib.sys_buzzer if defined?(SndLib)
|
||||
$game_map.popup(0, LonaCraft::Bases.text_key('Access/' + reason), 0, 0) if $game_map
|
||||
true
|
||||
end
|
||||
|
||||
def self.applying_remote_access?
|
||||
@lc_access_remote_depth.to_i > 0
|
||||
end
|
||||
|
||||
def self.request_camp_access(rec, operation, target)
|
||||
return false unless ready? && LonaCraft::CampAccess.owner?(rec)
|
||||
return false unless %w[access_add access_remove].include?(operation)
|
||||
return false unless rec.is_a?(Hash) && rec['om'].is_a?(Array)
|
||||
data = {'id'=>rec['id'].to_i, 'om'=>rec['om'].map(&:to_i)}
|
||||
data[operation == 'access_add' ? 'target_session' : 'target_profile'] = target.to_i
|
||||
send_now({'v'=>1, 'm'=>map_token, 'o'=>operation, 'd'=>data})
|
||||
end
|
||||
|
||||
def self.request_online_players(rec)
|
||||
return false unless ready? && LonaCraft::CampAccess.owner?(rec)
|
||||
return false unless rec.is_a?(Hash) && rec['om'].is_a?(Array)
|
||||
@lc_online_request = [map_token, rec['id'].to_i]
|
||||
@lc_online_total = nil
|
||||
@lc_online_parts = {}
|
||||
send_now({'v'=>1, 'm'=>map_token, 'o'=>'access_online',
|
||||
'd'=>{'id'=>rec['id'].to_i, 'om'=>rec['om'].map(&:to_i)}})
|
||||
end
|
||||
|
||||
def self.receive_online_players(packet, sender)
|
||||
return false unless sender.to_i == 0 && @lc_online_request
|
||||
return false unless packet['m'] == @lc_online_request[0]
|
||||
info = packet['d']
|
||||
return false unless info.is_a?(Hash) && info['id'] == @lc_online_request[1]
|
||||
part, total = info['part'], info['total']
|
||||
return false unless part.is_a?(Integer) && total.is_a?(Integer) && total > 0 && total <= 100
|
||||
return false unless part >= 0 && part < total && info['players'].is_a?(Array) && info['players'].size <= 12
|
||||
return false if @lc_online_total && @lc_online_total != total
|
||||
@lc_online_total = total
|
||||
@lc_online_parts[part] = info['players'].map do |player|
|
||||
next unless player.is_a?(Hash) && player['session'].is_a?(Integer) && player['session'] > 0
|
||||
name = LonaCraft::OnlineSync.owner_name(player['name'])
|
||||
[player['session'], name] unless name.empty?
|
||||
end.compact
|
||||
true
|
||||
end
|
||||
|
||||
def self.online_players_ready?
|
||||
@lc_online_request && @lc_online_request[0] == map_token &&
|
||||
@lc_online_total && @lc_online_parts && @lc_online_parts.size == @lc_online_total
|
||||
end
|
||||
|
||||
def self.server_online_players
|
||||
return [] unless online_players_ready?
|
||||
(0...@lc_online_total).flat_map { |part| @lc_online_parts[part] || [] }.
|
||||
uniq { |pair| pair[0] }.sort_by { |pair| pair[1].downcase }
|
||||
end
|
||||
|
||||
class << self
|
||||
alias_method :lc_access_previous_receive, :receive
|
||||
def receive(sender, phase, payload)
|
||||
return lc_access_previous_receive(sender, phase, payload) unless phase == 'msg' && ready?
|
||||
packet = decode(payload)
|
||||
return lc_access_previous_receive(sender, phase, payload) unless packet.is_a?(Hash)
|
||||
return receive_camp_check(packet, sender) if packet['o'] == 'camp_check'
|
||||
return receive_camp_reject(packet, sender) if packet['o'] == 'base_reject'
|
||||
if packet['o'] == 'access_online'
|
||||
return receive_online_players(packet, sender)
|
||||
end
|
||||
if %w[base base_new].include?(packet['o'])
|
||||
return false unless sender.to_i == 0
|
||||
end
|
||||
if %w[put del].include?(packet['o']) && packet['m'] == map_token
|
||||
rec = LonaCraft::Bases.record_for_map($game_map)
|
||||
return false if rec && !LonaCraft::CampAccess.sender_allowed?(rec, sender)
|
||||
@lc_access_remote_depth = @lc_access_remote_depth.to_i + 1
|
||||
begin
|
||||
return lc_access_previous_receive(sender, phase, payload)
|
||||
ensure
|
||||
@lc_access_remote_depth -= 1
|
||||
end
|
||||
end
|
||||
lc_access_previous_receive(sender, phase, payload)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Game_Interpreter
|
||||
if method_defined?(:lonacraft_furniture_pickup)
|
||||
alias_method :lc_access_previous_furniture_pickup, :lonacraft_furniture_pickup
|
||||
def lonacraft_furniture_pickup(rec, kind)
|
||||
camp = LonaCraft::Bases.record_for_map($game_map) if $game_map
|
||||
return LonaCraft::CampAccess.refuse if camp && !LonaCraft::CampAccess.allowed?(camp)
|
||||
lc_access_previous_furniture_pickup(rec, kind)
|
||||
end
|
||||
end
|
||||
|
||||
def lonacraft_base_access_choice(prompt, labels)
|
||||
text = "#{prompt}\\optB[#{labels.join(',')},]"
|
||||
key = LonaCraft::RuntimeText.key('Bases', 'rt_access_choice', text)
|
||||
call_msg(key)
|
||||
choice = $game_temp.choice
|
||||
$game_temp.choice = -1
|
||||
choice
|
||||
end
|
||||
|
||||
def lonacraft_base_access_menu(rec)
|
||||
return unless LonaCraft::CampAccess.owner?(rec)
|
||||
loop do
|
||||
choice = lonacraft_base_access_choice('Доступ к лагерю', ['Добавить игрока', 'Удалить игрока', 'Назад'])
|
||||
case choice
|
||||
when 0
|
||||
if LonaCraft::CampAccess.entries(rec).size >= LonaCraft::CampAccess::MAX_MEMBERS
|
||||
call_msg(LonaCraft::RuntimeText.key('Bases', 'rt_access_full', 'Список доступа заполнен.'))
|
||||
next
|
||||
end
|
||||
unless LonaCraft::OnlineSync.request_online_players(rec)
|
||||
call_msg(LonaCraft::RuntimeText.key('Bases', 'rt_access_unavailable', 'Не удалось запросить список игроков.'))
|
||||
next
|
||||
end
|
||||
180.times do
|
||||
break if LonaCraft::OnlineSync.online_players_ready?
|
||||
wait(1)
|
||||
end
|
||||
unless LonaCraft::OnlineSync.online_players_ready?
|
||||
call_msg(LonaCraft::RuntimeText.key('Bases', 'rt_access_unavailable', 'Сервер не ответил. Доступ пока нельзя изменить.'))
|
||||
next
|
||||
end
|
||||
online = LonaCraft::OnlineSync.server_online_players
|
||||
current = LonaCraft::CampAccess.members(rec)
|
||||
owner = LonaCraft::CampAccess.normal_name(rec['owner'])
|
||||
available = online.reject do |pair|
|
||||
normalized = LonaCraft::CampAccess.normal_name(pair[1])
|
||||
normalized == owner || current.any? { |member| LonaCraft::CampAccess.normal_name(member) == normalized }
|
||||
end
|
||||
if available.empty?
|
||||
key = LonaCraft::RuntimeText.key('Bases', 'rt_access_empty', 'Нет игроков онлайн для добавления.')
|
||||
call_msg(key)
|
||||
next
|
||||
end
|
||||
lonacraft_base_access_pick_online(rec, available)
|
||||
when 1
|
||||
entries = LonaCraft::CampAccess.entries(rec)
|
||||
if entries.empty?
|
||||
key = LonaCraft::RuntimeText.key('Bases', 'rt_access_empty', 'Список доступа пуст.')
|
||||
call_msg(key)
|
||||
next
|
||||
end
|
||||
pick = lonacraft_base_access_choice('Удалить игрока', entries.map { |entry| entry['name'] } + ['Назад'])
|
||||
if pick && pick >= 0 && pick < entries.size
|
||||
LonaCraft::OnlineSync.request_camp_access(rec, 'access_remove', entries[pick]['profile'])
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def lonacraft_base_access_pick_online(rec, available)
|
||||
page = 0
|
||||
pages = (available.size + 9) / 10
|
||||
loop do
|
||||
current = available[page * 10, 10] || []
|
||||
labels = current.map { |pair| pair[1] }
|
||||
labels << 'Далее' if page + 1 < pages
|
||||
labels << 'Назад к списку' if page > 0
|
||||
labels << 'Закрыть'
|
||||
pick = lonacraft_base_access_choice("Добавить игрока (#{page + 1}/#{pages})", labels)
|
||||
break unless pick && pick >= 0
|
||||
if pick < current.size
|
||||
LonaCraft::OnlineSync.request_camp_access(rec, 'access_add', current[pick][0])
|
||||
break
|
||||
end
|
||||
offset = current.size
|
||||
if page + 1 < pages
|
||||
if pick == offset
|
||||
page += 1
|
||||
next
|
||||
end
|
||||
offset += 1
|
||||
end
|
||||
if page > 0 && pick == offset
|
||||
page -= 1
|
||||
next
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -472,8 +472,8 @@ module LonaCraft
|
||||
# nil when +kind+ can stand on (x, y), else the popup key saying why.
|
||||
# Floor pieces, every footprint tile: inside the map, inside an owned
|
||||
# area (tile_allowed?) and not an owned wall tile, not Lona's tile, no
|
||||
# event (rugs without :occupy do not count), not water or bush,
|
||||
# passable from all four sides. Wall pieces (1x1): inside the map, an
|
||||
# event (rugs without :occupy do not count), not water. Wilderness camp
|
||||
# grass is allowed if the tile has a walkable approach. Wall pieces (1x1): inside the map, an
|
||||
# owned back-wall tile (wall_tile_allowed?), no event; no passability
|
||||
# check, the wall is meant to be impassable.
|
||||
# +ignore+: the ghost, which stands on the anchor tile.
|
||||
@@ -492,8 +492,15 @@ module LonaCraft
|
||||
return text_key("Place/not_home") if wall_tile_allowed?(map, tx, ty)
|
||||
return blocked if $game_player.x == tx && $game_player.y == ty
|
||||
return blocked if map.events_xy(tx, ty).any?{|ev| !placement_ignores?(ev, ignore) }
|
||||
return "QuickMsg:Lona/WrongPlace#{rand(2)}" if map.water_floor?(tx, ty) || map.bush?(tx, ty)
|
||||
return blocked unless [2, 4, 6, 8].all?{|d| map.passable?(tx, ty, d) }
|
||||
camp_field = base_map?(map) && !LonaCraft::Bases.named_map?(map)
|
||||
return "QuickMsg:Lona/WrongPlace#{rand(2)}" if map.water_floor?(tx, ty) || (map.bush?(tx, ty) && !camp_field)
|
||||
directions = [2, 4, 6, 8]
|
||||
walkable = if camp_field
|
||||
directions.any?{|d| map.passable?(tx, ty, d) }
|
||||
else
|
||||
directions.all?{|d| map.passable?(tx, ty, d) }
|
||||
end
|
||||
return blocked unless walkable
|
||||
}
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -55,6 +55,18 @@ Arrows move it. OK builds it. Cancel stops.
|
||||
Place/not_here
|
||||
\narr Lona can only build out in the wild, on a map she walked into from the world map.
|
||||
|
||||
Access/denied
|
||||
Only the camp owner and invited players can build or dismantle here.
|
||||
|
||||
Access/checking
|
||||
The server is checking this camp location. Try again in a few seconds.
|
||||
|
||||
Access/one_camp
|
||||
You already own a camp. Each player may own only one camp.
|
||||
|
||||
Access/near_camp
|
||||
Too close to another camp. Keep a clear 5 by 5 OverMap area.
|
||||
|
||||
Place/no_tiles
|
||||
\narr This ground does not take that.
|
||||
|
||||
|
||||
@@ -54,6 +54,18 @@ Place/hint
|
||||
Place/not_here
|
||||
\narr Лона может строить только в глуши, на карте, куда она зашла с карты мира.
|
||||
|
||||
Access/denied
|
||||
Строить и разбирать здесь может только владелец лагеря и добавленные им игроки.
|
||||
|
||||
Access/checking
|
||||
Сервер проверяет, можно ли основать здесь лагерь. Повторите действие через несколько секунд.
|
||||
|
||||
Access/one_camp
|
||||
У вас уже есть лагерь. Одному игроку разрешён только один лагерь.
|
||||
|
||||
Access/near_camp
|
||||
Слишком близко к другому лагерю: нужна свободная область 5 на 5 клеток OverMap.
|
||||
|
||||
Place/no_tiles
|
||||
\narr Эта земля для такого не годится.
|
||||
|
||||
|
||||
@@ -54,6 +54,18 @@ Place/hint
|
||||
Place/not_here
|
||||
\narr Лона может строить только в глуши, на карте, куда она зашла с карты мира.
|
||||
|
||||
Access/denied
|
||||
Строить и разбирать здесь может только владелец лагеря и добавленные им игроки.
|
||||
|
||||
Access/checking
|
||||
Сервер проверяет, можно ли основать здесь лагерь. Повторите действие через несколько секунд.
|
||||
|
||||
Access/one_camp
|
||||
У вас уже есть лагерь. Одному игроку разрешён только один лагерь.
|
||||
|
||||
Access/near_camp
|
||||
Слишком близко к другому лагерю: нужна свободная область 5 на 5 клеток OverMap.
|
||||
|
||||
Place/no_tiles
|
||||
\narr Эта земля для такого не годится.
|
||||
|
||||
|
||||
@@ -53,6 +53,8 @@ load_script($mod_manager.get_resource("LonaCraft", "Scripts/160_Rest.rb"))
|
||||
load_script($mod_manager.get_resource("LonaCraft", "Scripts/170_Maid.rb"))
|
||||
# Cooperative online world-object synchronization through multiplayer deistvia.
|
||||
load_script($mod_manager.get_resource("LonaCraft", "Scripts/180_OnlineSync.rb"))
|
||||
# Shared-camp owner and invited-player building permissions.
|
||||
load_script($mod_manager.get_resource("LonaCraft", "Scripts/181_CampAccess.rb"))
|
||||
# Crafting mastery stored per online profile in server MySQL (after cloud bootstrap).
|
||||
load_script($mod_manager.get_resource("LonaCraft", "Scripts/190_SkillMySQL.rb"))
|
||||
# Personal camp-chest contents in character cloud (extends bank_blob lc_chests).
|
||||
|
||||
Reference in new issue
Block a user