Compare commits
12
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e832c8446 | ||
|
|
3189092af2 | ||
|
|
b920fe9bf5 | ||
|
|
6adc6dbc73 | ||
|
|
63593f9e44 | ||
|
|
2782e0a8bb | ||
|
|
3267bf2930 | ||
|
|
3ce9e59d24 | ||
|
|
7e60dbd70a | ||
|
|
597edd72a9 | ||
|
|
89060d79ce | ||
|
|
6afdce9da0 |
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,465 @@
|
||||
#==============================================================================
|
||||
# Mob hit bars
|
||||
# Shows stamina and health above an NPC after either value is reduced.
|
||||
#==============================================================================
|
||||
|
||||
module MobHitBars
|
||||
WIDTH = 42
|
||||
INNER_WIDTH = WIDTH - 2
|
||||
BITMAP_WIDTH = 160
|
||||
BAR_X = (BITMAP_WIDTH - WIDTH) / 2
|
||||
HEIGHT = 48
|
||||
VISIBLE_FRAMES = 150
|
||||
FADE_FRAMES = 30
|
||||
Y_OFFSET = 7
|
||||
|
||||
BACK_COLOR = Color.new(0, 0, 0, 220)
|
||||
BORDER_COLOR = Color.new(210, 210, 210, 220)
|
||||
STAMINA_COLOR = Color.new(255, 220, 20, 255)
|
||||
HEALTH_COLOR = Color.new(225, 35, 35, 255)
|
||||
LABEL_FONT = "AuX DotBitC Xtra Bold"
|
||||
LABEL_FONT_SIZE = 18
|
||||
LEVEL_FONT_SIZE = 16
|
||||
MAX_NPC_LEVEL = 100
|
||||
POWER_REFERENCE = 196.8
|
||||
HEALTH_POWER_CAP = 2500.0
|
||||
STAMINA_POWER_CAP = 3000.0
|
||||
|
||||
NORMAL_LEVEL_COLOR = Color.new(255, 255, 255, 255)
|
||||
STRONG_LEVEL_COLOR = Color.new(255, 220, 20, 255)
|
||||
VERY_STRONG_LEVEL_COLOR = Color.new(255, 140, 0, 255)
|
||||
DEADLY_LEVEL_COLOR = Color.new(255, 55, 55, 255)
|
||||
|
||||
NAME_KEY_ALIASES = {
|
||||
"AbomCreatureBat" => "DataNpcName:name/nameCreatureBat",
|
||||
"AbomCreatureGroundSpore" => "DataNpcName:name/nameCreatureGroundSpore",
|
||||
"AbomCreatureMeatWorm" => "DataNpcName:name/nameCreatureMeatWorm",
|
||||
"AbomCreatureSpore" => "DataNpcName:name/nameCreatureSpore",
|
||||
"AbomCreatureSummonSpore" => "DataNpcName:name/nameCreatureSummonSpore",
|
||||
"AbomCreatureTentacle" => "DataNpcName:name/nameCreatureTentacle",
|
||||
"AbomCreatureTentacleSummoned" => "DataNpcName:name/nameCreatureTentacleSummoned",
|
||||
"Baby_AbominationBaby" => "DataNpcName:name/Baby_nameinationBaby",
|
||||
"PlayerAbominationBaby" => "DataNpcName:name/PlayernameinationBaby",
|
||||
"GoblinBow" => "DataNpcName:goblin/GoblinBow",
|
||||
"WildGiantMiceFristQuestVer" => "DataNpcName:name/WildGiantMice",
|
||||
"WildGiantMicePassive" => "DataNpcName:name/WildGiantMice",
|
||||
"WildBoarF" => "DataNpcName:name/WildBoar",
|
||||
"WildApeF_Sneak" => "DataNpcName:name/WildApeF",
|
||||
"CompHorseCarry" => "DataNpcName:name/HorseCarry"
|
||||
}
|
||||
|
||||
NAME_OVERRIDES = {
|
||||
"UniqueAdam" => "Адам",
|
||||
"UniqueBossMamaT1" => "Большая Мама",
|
||||
"UniqueBossMamaT2" => "Большая Мама",
|
||||
"UniqueTavernWaifu" => "Большая Мама",
|
||||
"UniqueCaptainEdward" => "Эдвард",
|
||||
"UniqueCecily" => "Сесилия",
|
||||
"UniqueCocona" => "Кокона",
|
||||
"UniqueDavidBorn" => "Дэвид Борн",
|
||||
"UniqueDedOne" => "Правосудие",
|
||||
"UniqueDedOneGuns" => "Правосудие",
|
||||
"UniqueElise" => "Элис",
|
||||
"UniqueFerrum" => "Феррум",
|
||||
"UniqueGangBoss" => "Уэйн",
|
||||
"UniqueGrayRat" => "Грейрат",
|
||||
"UniqueHappyMerchant" => "Торговец",
|
||||
"UniqueLisa" => "Лиза",
|
||||
"UniqueMaani" => "Маани",
|
||||
"UniqueMaaniCombat" => "Маани",
|
||||
"UniqueMilo" => "Мило",
|
||||
"UniqueSeaWitch" => "Морская ведьма",
|
||||
"UniqueTeller" => "Аиша",
|
||||
"UniqueKillerRabbit" => "Очень большой кролик",
|
||||
"UniqueFishkindFistMasterT1" => "Мастер кулака",
|
||||
"UniqueFishkindFistMasterT2" => "Мастер кулака",
|
||||
"UniqueOgreWarBoss" => "Вождь огров",
|
||||
"OgreWarBoss" => "Вождь огров",
|
||||
"OrcButcher" => "Мясник",
|
||||
"OrcSlaveMaster" => "Надсмотрщик",
|
||||
"CompKitten" => "Котёнок",
|
||||
"CompDoggy" => "Собака",
|
||||
"CompElfArcher" => "Эльфийская лучница",
|
||||
"CompFireMage" => "Огненный маг",
|
||||
"CompFishGuard" => "Рыбостраж",
|
||||
"CompFishShaman" => "Рыбошаман",
|
||||
"CompMusketeer" => "Мушкетёр",
|
||||
"CompNinjaKiller" => "Ниндзя",
|
||||
"CompOrkindSlayer" => "Истребитель оркоидов",
|
||||
"CompWarSister" => "Сестра войны",
|
||||
"LonaCraftMaid" => "Горничная",
|
||||
"LonaCraftMercCaptain" => "Капитан наёмников",
|
||||
"LonaCraftMercenary" => "Наёмник",
|
||||
"Player_Baby_OgreChild" => "Ребёнок",
|
||||
"CompHumanExplorer" => "Исследователь",
|
||||
"MobEliseGagCrazy" => "Безумец",
|
||||
"NeutralBSHumanwhoreF" => "Проститутка",
|
||||
"NeutralHumanGraveKeeper" => "Могильщик",
|
||||
"NeutralHumanKidRack" => "Ребёнок",
|
||||
"SaintHumanRake" => "Распутник",
|
||||
"SaintHumanWhip" => "Бичеватель",
|
||||
"WildAnimalRattus" => "Крыса",
|
||||
"WildDireWolf" => "Лютоволк",
|
||||
"WildRabbit" => "Кролик",
|
||||
"WildCrow" => "Ворон",
|
||||
"SwineF" => "Свинья",
|
||||
"SwineM" => "Свинья",
|
||||
"Overmap_Unit" => "Отряд"
|
||||
}
|
||||
|
||||
NAME_PATTERNS = [
|
||||
[/DungeonVictim/i, "Пленник"],
|
||||
[/HiveHeart/i, "Сердце улья"],
|
||||
[/BatHive/i, "Улей летучих мышей"],
|
||||
[/CreatureBat/i, "Летучая мышь-мутант"],
|
||||
[/Cocoon/i, "Кокон"],
|
||||
[/GroundSpore/i, "Наземная спора"],
|
||||
[/Spore/i, "Спора"],
|
||||
[/Tentacle/i, "Щупальце"],
|
||||
[/Spider/i, "Арахнид"],
|
||||
[/Scorpion/i, "Ползун"],
|
||||
[/Worm/i, "Червь"],
|
||||
[/Zombie/i, "Мутант"],
|
||||
[/Hive.*Manager|ManagerTrap/i, "Изверг"],
|
||||
[/CorrosionTrap/i, "Коррозийная ловушка"],
|
||||
[/(TriggerTrap|SpiderTrap|HideTrap|\bTrap\b)/i, "Ловушка"],
|
||||
[/CorrosionBomb/i, "Коррозийная бомба"],
|
||||
[/Bomb/i, "Бомба"],
|
||||
[/(Missile|Projectile)/i, "Снаряд"],
|
||||
[/(SkillDummy|SandBag|Sandbag)/i, "Манекен"],
|
||||
[/ProtectShield/i, "Защитный щит"],
|
||||
[/ProtectTower/i, "Защитная башня"],
|
||||
[/SexModeController/i, "Технический объект"],
|
||||
[/UniqueGrayRat/i, "Грейрат"],
|
||||
[/^(WildAnimalRattus|WildGiantMice)/i, "Крыса"],
|
||||
[/Rabbit/i, "Кролик"],
|
||||
[/DireWolf/i, "Лютоволк"],
|
||||
[/Wolf/i, "Волк"],
|
||||
[/Dog/i, "Собака"],
|
||||
[/(Boar|Swine)/i, "Дикий кабан"],
|
||||
[/Horse/i, "Лошадь"],
|
||||
[/^WildApe/i, "Дикая обезьяна"],
|
||||
[/Baby/i, "Младенец"],
|
||||
[/Child/i, "Ребёнок"],
|
||||
[/DedOne/i, "Правосудие"],
|
||||
[/FistMaster/i, "Мастер кулака"],
|
||||
[/WarBoss/i, "Вождь"],
|
||||
[/Deepone.*Guard/i, "Рыбостраж"],
|
||||
[/Executioner/i, "Палач"],
|
||||
[/Torturer/i, "Мучитель"],
|
||||
[/Butcher/i, "Мясник"],
|
||||
[/MasterMage/i, "Архимаг"],
|
||||
[/(FireMage|LightMage|Mage|Witch)/i, "Маг"],
|
||||
[/Shaman/i, "Шаман"],
|
||||
[/Priest/i, "Священник"],
|
||||
[/Musketeer/i, "Мушкетёр"],
|
||||
[/(Bow|Archer)/i, "Лучник"],
|
||||
[/Spear/i, "Копейщик"],
|
||||
[/Catcher/i, "Ловчий"],
|
||||
[/(Scout|Watcher)/i, "Разведчик"],
|
||||
[/Berserk/i, "Берсерк"],
|
||||
[/(Warrior|Fighter|Charger)/i, "Воин"],
|
||||
[/Guard/i, "Стражник"],
|
||||
[/Raider/i, "Налётчик"],
|
||||
[/(Bandit|Rogue|Gang)/i, "Бандит"],
|
||||
[/Raper/i, "Насильник"],
|
||||
[/(Miner|PickAxe)/i, "Шахтёр"],
|
||||
[/Prisoner/i, "Заключённый"],
|
||||
[/Slave/i, "Раб"],
|
||||
[/Hobo/i, "Бродяга"],
|
||||
[/GraveKeeper/i, "Могильщик"],
|
||||
[/Explorer/i, "Исследователь"],
|
||||
[/Teen/i, "Подросток"],
|
||||
[/Kid/i, "Ребёнок"],
|
||||
[/Mother/i, "Мать"],
|
||||
[/Whore/i, "Проститутка"],
|
||||
[/Rake/i, "Распутник"],
|
||||
[/Whip/i, "Бичеватель"],
|
||||
[/Victim/i, "Пленник"],
|
||||
[/Maid/i, "Горничная"],
|
||||
[/Merc/i, "Наёмник"],
|
||||
[/Slayer/i, "Истребитель"],
|
||||
[/(Follower|Companion)/i, "Спутник"],
|
||||
[/SexBeast/i, "Зверь"],
|
||||
[/Hazubendo/i, "Завсегдатай"],
|
||||
[/Rack/i, "Пыточная стойка"],
|
||||
[/^Deepone/i, "Глубинный"],
|
||||
[/Undead/i, "Нежить"]
|
||||
]
|
||||
|
||||
NON_LEVEL_RACES = [
|
||||
"Missile", "Bomb", "Mine", "SkillDummy", "AreaDot", "Overmap", "Johnson"
|
||||
]
|
||||
|
||||
NON_LEVEL_AI = [
|
||||
"GameTrap",
|
||||
"Game_DestroyableObject",
|
||||
"Game_DestroyableSkillDummy",
|
||||
"Game_SandboxObject",
|
||||
"Game_PorjectileCharacter",
|
||||
"Game_FireballPorjectile",
|
||||
"Game_OvermapChar"
|
||||
]
|
||||
|
||||
def self.level_bearing_actor?(actor)
|
||||
data = actor.respond_to?(:npc) ? actor.npc : nil
|
||||
return true unless data
|
||||
return false if data.respond_to?(:is_object) && data.is_object == true
|
||||
race = data.respond_to?(:race) ? data.race.to_s : ""
|
||||
return false if NON_LEVEL_RACES.include?(race)
|
||||
ai = data.respond_to?(:ai) ? data.ai.to_s : ""
|
||||
return false if NON_LEVEL_AI.include?(ai)
|
||||
true
|
||||
rescue
|
||||
true
|
||||
end
|
||||
|
||||
def self.npc_actor(character)
|
||||
return nil unless character.is_a?(Game_Event)
|
||||
return nil unless character.respond_to?(:npc?) && character.npc?
|
||||
actor = character.actor
|
||||
return nil unless actor && actor.respond_to?(:battle_stat)
|
||||
return nil unless level_bearing_actor?(actor)
|
||||
actor
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
|
||||
def self.stat(actor, name, type = nil)
|
||||
if type.nil?
|
||||
actor.battle_stat.get_stat(name).to_f
|
||||
else
|
||||
actor.battle_stat.get_stat(name, type).to_f
|
||||
end
|
||||
rescue
|
||||
0.0
|
||||
end
|
||||
|
||||
def self.ratio(value, maximum)
|
||||
return 0.0 if maximum <= 0.0
|
||||
[[value / maximum, 0.0].max, 1.0].min
|
||||
end
|
||||
|
||||
def self.display_name(actor)
|
||||
raw = actor.respond_to?(:npc_name) ? actor.npc_name.to_s : "NPC"
|
||||
key = NAME_KEY_ALIASES[raw] || "DataNpcName:name/#{raw}"
|
||||
translated = $game_text[key, true].to_s rescue ""
|
||||
valid_translation = !translated.empty? && translated !~ /^name\//i && translated !~ /^asd$/i
|
||||
return translated if valid_translation
|
||||
|
||||
override = NAME_OVERRIDES[raw]
|
||||
return override if override
|
||||
|
||||
role = NAME_PATTERNS.find { |pair| raw =~ pair[0] }
|
||||
return role[1] if role
|
||||
|
||||
race = actor.respond_to?(:race) ? actor.race.to_s : ""
|
||||
race_name = $game_text["DataNpcName:race/#{race}", true].to_s rescue ""
|
||||
race_name.empty? ? "NPC" : race_name
|
||||
rescue
|
||||
"NPC"
|
||||
end
|
||||
|
||||
def self.fit_name(bitmap, npc_name)
|
||||
name = npc_name.to_s
|
||||
shortened = false
|
||||
while name.length > 3 && bitmap.text_size("#{name}#{shortened ? "." : ""}").width > BITMAP_WIDTH - 8
|
||||
name = name[0...-1]
|
||||
shortened = true
|
||||
end
|
||||
"#{name}#{shortened ? "." : ""}"
|
||||
rescue
|
||||
"NPC"
|
||||
end
|
||||
|
||||
def self.base_stat(actor, data, name, maximum = nil)
|
||||
raw = data.send(name) if data && data.respond_to?(name)
|
||||
raw = stat(actor, name) if raw.nil?
|
||||
value = [raw.to_f, 0.0].max
|
||||
maximum ? [value, maximum].min : value
|
||||
rescue
|
||||
0.0
|
||||
end
|
||||
|
||||
def self.level(actor)
|
||||
data = actor.respond_to?(:npc) ? actor.npc : nil
|
||||
combat = base_stat(actor, data, "combat", 100.0)
|
||||
attack = base_stat(actor, data, "atk", 100.0)
|
||||
defense = base_stat(actor, data, "def", 100.0)
|
||||
constitution = base_stat(actor, data, "constitution", 100.0)
|
||||
survival = base_stat(actor, data, "survival", 100.0)
|
||||
wisdom = base_stat(actor, data, "wisdom", 100.0)
|
||||
health = base_stat(actor, data, "health", HEALTH_POWER_CAP)
|
||||
stamina = base_stat(actor, data, "sta", STAMINA_POWER_CAP)
|
||||
|
||||
score = combat * 0.35
|
||||
score += attack * 0.90
|
||||
score += defense * 0.55
|
||||
score += constitution * 0.15
|
||||
score += survival * 0.10
|
||||
score += wisdom * 0.10
|
||||
score += Math.sqrt(health) * 0.80
|
||||
score += Math.sqrt(stamina) * 0.35
|
||||
|
||||
value = (score * MAX_NPC_LEVEL / POWER_REFERENCE).round
|
||||
[[value, 1].max, MAX_NPC_LEVEL].min
|
||||
rescue
|
||||
1
|
||||
end
|
||||
|
||||
def self.player_level
|
||||
actor = $game_player && $game_player.respond_to?(:actor) ? $game_player.actor : nil
|
||||
value = actor && actor.respond_to?(:level) ? actor.level.to_i : 1
|
||||
[value, 1].max
|
||||
rescue
|
||||
1
|
||||
end
|
||||
|
||||
def self.level_color(npc_level, current_player_level = nil)
|
||||
current_player_level = player_level if current_player_level.nil?
|
||||
npc_value = [npc_level.to_i, 1].max
|
||||
player_value = [current_player_level.to_i, 1].max
|
||||
return NORMAL_LEVEL_COLOR if npc_value <= player_value
|
||||
return DEADLY_LEVEL_COLOR if npc_value >= player_value * 3
|
||||
return VERY_STRONG_LEVEL_COLOR if npc_value >= player_value * 2
|
||||
return STRONG_LEVEL_COLOR if npc_value > player_value
|
||||
NORMAL_LEVEL_COLOR
|
||||
rescue
|
||||
NORMAL_LEVEL_COLOR
|
||||
end
|
||||
end
|
||||
|
||||
class Sprite_Character < Sprite_Base
|
||||
unless method_defined?(:mob_hit_bars_initialize_without)
|
||||
alias mob_hit_bars_initialize_without initialize
|
||||
end
|
||||
|
||||
def initialize(viewport, character = nil)
|
||||
mob_hit_bars_initialize_without(viewport, character)
|
||||
@mob_hit_bars_sprite = Sprite.new(viewport)
|
||||
@mob_hit_bars_sprite.bitmap = Bitmap.new(MobHitBars::BITMAP_WIDTH, MobHitBars::HEIGHT)
|
||||
@mob_hit_bars_sprite.ox = MobHitBars::BITMAP_WIDTH / 2
|
||||
@mob_hit_bars_sprite.oy = MobHitBars::HEIGHT
|
||||
@mob_hit_bars_sprite.visible = false
|
||||
@mob_hit_bars_timer = 0
|
||||
@mob_hit_bars_actor_id = nil
|
||||
@mob_hit_bars_last_hp = nil
|
||||
@mob_hit_bars_last_sta = nil
|
||||
@mob_hit_bars_signature = nil
|
||||
end
|
||||
|
||||
unless method_defined?(:mob_hit_bars_update_without)
|
||||
alias mob_hit_bars_update_without update
|
||||
end
|
||||
|
||||
def update
|
||||
result = mob_hit_bars_update_without
|
||||
update_mob_hit_bars
|
||||
result
|
||||
end
|
||||
|
||||
def update_mob_hit_bars
|
||||
sprite = @mob_hit_bars_sprite
|
||||
return unless sprite
|
||||
actor = MobHitBars.npc_actor(@character)
|
||||
unless actor
|
||||
sprite.visible = false
|
||||
reset_mob_hit_bars_tracking
|
||||
return
|
||||
end
|
||||
|
||||
actor_id = actor.object_id
|
||||
hp = MobHitBars.stat(actor, "health")
|
||||
sta = MobHitBars.stat(actor, "sta")
|
||||
hp_max = MobHitBars.stat(actor, "health", ActorStat::MAX_STAT)
|
||||
sta_max = MobHitBars.stat(actor, "sta", ActorStat::MAX_STAT)
|
||||
|
||||
if @mob_hit_bars_actor_id != actor_id
|
||||
@mob_hit_bars_actor_id = actor_id
|
||||
@mob_hit_bars_last_hp = hp
|
||||
@mob_hit_bars_last_sta = sta
|
||||
@mob_hit_bars_timer = 0
|
||||
elsif (@mob_hit_bars_last_hp && hp < @mob_hit_bars_last_hp) ||
|
||||
(@mob_hit_bars_last_sta && sta < @mob_hit_bars_last_sta)
|
||||
@mob_hit_bars_timer = MobHitBars::VISIBLE_FRAMES
|
||||
end
|
||||
|
||||
@mob_hit_bars_last_hp = hp
|
||||
@mob_hit_bars_last_sta = sta
|
||||
|
||||
if @mob_hit_bars_timer <= 0
|
||||
sprite.visible = false
|
||||
return
|
||||
end
|
||||
|
||||
npc_name = MobHitBars.display_name(actor)
|
||||
npc_level = MobHitBars.level(actor)
|
||||
player_level = MobHitBars.player_level
|
||||
signature = [hp, hp_max, sta, sta_max, npc_name, npc_level, player_level]
|
||||
redraw_mob_hit_bars(sprite.bitmap, hp, hp_max, sta, sta_max, npc_name, npc_level, player_level) if signature != @mob_hit_bars_signature
|
||||
@mob_hit_bars_signature = signature
|
||||
|
||||
sprite.x = self.x
|
||||
sprite.y = self.y - (self.oy * self.zoom_y).to_i - MobHitBars::Y_OFFSET
|
||||
sprite.z = self.z + 100
|
||||
sprite.opacity = if @mob_hit_bars_timer < MobHitBars::FADE_FRAMES
|
||||
@mob_hit_bars_timer * 255 / MobHitBars::FADE_FRAMES
|
||||
else
|
||||
255
|
||||
end
|
||||
sprite.visible = self.visible && !$hudForceHide
|
||||
@mob_hit_bars_timer -= 1
|
||||
rescue
|
||||
@mob_hit_bars_sprite.visible = false if @mob_hit_bars_sprite
|
||||
end
|
||||
|
||||
def redraw_mob_hit_bars(bitmap, hp, hp_max, sta, sta_max, npc_name, npc_level, player_level)
|
||||
bitmap.clear
|
||||
bitmap.font.name = MobHitBars::LABEL_FONT
|
||||
bitmap.font.size = MobHitBars::LABEL_FONT_SIZE
|
||||
bitmap.font.bold = false
|
||||
bitmap.font.outline = false
|
||||
bitmap.font.shadow = true
|
||||
bitmap.font.color = MobHitBars.level_color(npc_level, player_level)
|
||||
bitmap.font.size = MobHitBars::LEVEL_FONT_SIZE
|
||||
bitmap.draw_text(0, 0, MobHitBars::BITMAP_WIDTH, 18, "Ур. #{npc_level}", 1)
|
||||
bitmap.font.size = MobHitBars::LABEL_FONT_SIZE
|
||||
label = MobHitBars.fit_name(bitmap, npc_name)
|
||||
bitmap.draw_text(0, 17, MobHitBars::BITMAP_WIDTH, 21, label, 1)
|
||||
|
||||
x = MobHitBars::BAR_X
|
||||
bitmap.fill_rect(x, 39, MobHitBars::WIDTH, 4, MobHitBars::BORDER_COLOR)
|
||||
bitmap.fill_rect(x + 1, 40, MobHitBars::INNER_WIDTH, 2, MobHitBars::BACK_COLOR)
|
||||
sta_width = (MobHitBars::INNER_WIDTH * MobHitBars.ratio(sta, sta_max)).round
|
||||
bitmap.fill_rect(x + 1, 40, sta_width, 2, MobHitBars::STAMINA_COLOR) if sta_width > 0
|
||||
|
||||
bitmap.fill_rect(x, 44, MobHitBars::WIDTH, 4, MobHitBars::BORDER_COLOR)
|
||||
bitmap.fill_rect(x + 1, 45, MobHitBars::INNER_WIDTH, 2, MobHitBars::BACK_COLOR)
|
||||
hp_width = (MobHitBars::INNER_WIDTH * MobHitBars.ratio(hp, hp_max)).round
|
||||
bitmap.fill_rect(x + 1, 45, hp_width, 2, MobHitBars::HEALTH_COLOR) if hp_width > 0
|
||||
end
|
||||
|
||||
def reset_mob_hit_bars_tracking
|
||||
@mob_hit_bars_actor_id = nil
|
||||
@mob_hit_bars_last_hp = nil
|
||||
@mob_hit_bars_last_sta = nil
|
||||
@mob_hit_bars_signature = nil
|
||||
@mob_hit_bars_timer = 0
|
||||
end
|
||||
|
||||
unless method_defined?(:mob_hit_bars_dispose_without)
|
||||
alias mob_hit_bars_dispose_without dispose
|
||||
end
|
||||
|
||||
def dispose
|
||||
if @mob_hit_bars_sprite
|
||||
bitmap = @mob_hit_bars_sprite.bitmap
|
||||
bitmap.dispose if bitmap && !bitmap.disposed?
|
||||
@mob_hit_bars_sprite.dispose unless @mob_hit_bars_sprite.disposed?
|
||||
@mob_hit_bars_sprite = nil
|
||||
end
|
||||
mob_hit_bars_dispose_without
|
||||
end
|
||||
end
|
||||
|
||||
puts "[MOB-HIT-BARS] stamina and health bars enabled" rescue nil
|
||||
@@ -0,0 +1,453 @@
|
||||
# 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)
|
||||
class Game_Player
|
||||
alias ibru_movable_without movable?
|
||||
def movable?(*args, &block)
|
||||
return false if MPIslandVoyage.transit? && $game_map && $game_map.map_id == 156
|
||||
ibru_movable_without(*args, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(WebSocket)
|
||||
module WebSocket
|
||||
class << self
|
||||
alias ibru_parse_without parse
|
||||
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
|
||||
ibru_parse_without(message)
|
||||
end
|
||||
|
||||
alias ibru_noclip_without admin_noclip_enabled?
|
||||
def admin_noclip_enabled?
|
||||
MPIslandVoyage.noclip? || ibru_noclip_without
|
||||
end
|
||||
|
||||
alias ibru_hidden_without admin_see_hidden_enabled?
|
||||
def admin_see_hidden_enabled?
|
||||
(MPIslandVoyage.active? && !!@admin_see_hidden_enabled) || ibru_hidden_without
|
||||
end
|
||||
|
||||
alias ibru_ghost_without admin_can_ghost?
|
||||
def admin_can_ghost?
|
||||
MPIslandVoyage.active? || ibru_ghost_without
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if defined?(MPGodMode)
|
||||
module MPGodMode
|
||||
class << self
|
||||
alias ibru_active_without active?
|
||||
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
|
||||
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
|
||||
def tick
|
||||
ibru_tick_without
|
||||
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
|
||||
|
||||
if defined?(Scene_Map)
|
||||
class Scene_Map
|
||||
alias ibru_update_without update
|
||||
def update(*args, &block)
|
||||
result = ibru_update_without(*args, &block)
|
||||
MPIslandVoyage.tick
|
||||
result
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
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