Files
LonaRPG-Online-Games/ModScripts/_Mods/CheatFramework/modules/Teleport.rb
T
2026-10-29 21:59:06 +04:00

218 lines
7.5 KiB
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#===============================================================================
# Teleport Module for Cheat Framework (с change_map_leave_tag_map)
#===============================================================================
FrameworkModule = {
name: "Teleportation",
key: :teleport,
menu: :TELEPORT,
order: 25,
depends_on: []
}
MenuFramework::MENU.register_command(
type: :scene,
key: :teleport_menu,
label: "modules/teleport:commands/title",
name: "CheatMenuTeleport",
dict: :TELEPORT,
order: 25
)
#-------------------------------------------------------------------------------
# категории и локации (без изменений)
#-------------------------------------------------------------------------------
module CFTeleport
OVERMAP_ID = 2
CATEGORIES = {
settlements: {
key: :settlements,
label: "modules/teleport:category/settlements",
locations: [
{ key: :noertown, x: 35, y: 99 },
{ key: :doom_stronghold, x: 49, y: 37 },
{ key: :aris_village, x: 71, y: 94 },
{ key: :pirates_bane, x: 93, y: 85 },
{ key: :south_gate_camp, x: 122, y: 54 },
{ key: :coastal_fortress, x: 90, y: 24 },
{ key: :nine_inch_tribe, x: 65, y: 48 },
{ key: :fishtopia_market, x: 117, y: 129 },
{ key: :bridge_fort, x: 101, y: 38 }
]
},
noertown_locations: {
key: :noertown_locations,
label: "modules/teleport:category/noertown_locations",
locations: [
{ key: :tavern, x: 33, y: 100 },
{ key: :coliseum, x: 35, y: 99 },
{ key: :east_trade, x: 33, y: 98 },
{ key: :sewer, x: 32, y: 96 },
{ key: :back_alleys, x: 31, y: 98 },
{ key: :bubba_smith, x: 29, y: 99 },
{ key: :toy_house, x: 27, y: 98 },
{ key: :warehouse_13, x: 25, y: 101 },
{ key: :prison, x: 26, y: 95 },
{ key: :cemetery, x: 23, y: 95 },
{ key: :parade_ground, x: 39, y: 99 },
{ key: :elis_clinic, x: 37, y: 98 },
{ key: :bank, x: 37, y: 100 },
{ key: :market, x: 35, y: 101 },
{ key: :port, x: 35, y: 103 },
{ key: :gold_ingot, x: 36, y: 95 },
{ key: :east_gate, x: 41, y: 99 }
]
},
outposts: {
key: :outposts,
label: "modules/teleport:category/outposts",
locations: [
{ key: :east_noertown_outpost, x: 60, y: 95 },
{ key: :east_doom_outpost, x: 72, y: 34 },
{ key: :north_pirates_outpost, x: 91, y: 69 }
]
},
camps: {
key: :camps,
label: "modules/teleport:category/camps",
locations: [
{ key: :refugee_monastery, x: 35, y: 79 },
{ key: :refugee_doom, x: 60, y: 41 },
{ key: :mercenary_camp, x: 97, y: 29 },
{ key: :swamp_camp, x: 108, y: 90 },
{ key: :fishfolk_camp, x: 72, y: 84 }
]
},
monster_lairs: {
key: :monster_lairs,
label: "modules/teleport:category/monster_lairs",
locations: [
{ key: :orkind_cave1, x: 28, y: 93 },
{ key: :orkind_cave2, x: 33, y: 82 },
{ key: :orkind_cave3, x: 51, y: 82 },
{ key: :orkind_cave4, x: 99, y: 70 },
{ key: :orkind_forest, x: 99, y: 76 },
{ key: :orkind_hut, x: 53, y: 60 },
{ key: :lost_caravan, x: 50, y: 89 },
{ key: :fishfolk_cave1, x: 74, y: 82 },
{ key: :fishfolk_cave1b2, x: 76, y: 85 },
{ key: :fishfolk_cave2, x: 117, y: 80 },
{ key: :fishfolk_cave3, x: 124, y: 129 },
{ key: :abomination_lair1, x: 79, y: 40 },
{ key: :abomination_lair2, x: 95, y: 56 },
{ key: :abomination_lair3, x: 123, y: 42 },
{ key: :bat_cave, x: 102, y: 42 }
]
},
points_of_interest: {
key: :points_of_interest,
label: "modules/teleport:category/points_of_interest",
locations: [
{ key: :saints_monastery, x: 33, y: 78 },
{ key: :mountain_monastery, x: 55, y: 67 },
{ key: :cloud_village, x: 49, y: 72 },
{ key: :bandit_shelter, x: 26, y: 69 },
{ key: :noertown_mine, x: 53, y: 94 },
{ key: :berserk_tomb, x: 69, y: 74 },
{ key: :abandoned_copper_mine, x: 48, y: 67 },
{ key: :woodson_manor, x: 51, y: 50 },
{ key: :doom_armory, x: 54, y: 40 },
{ key: :south_granary, x: 91, y: 30 },
{ key: :perranwey_village, x: 101, y: 28 },
{ key: :fallen_fortress, x: 101, y: 38 },
{ key: :looted_caravan, x: 122, y: 74 },
{ key: :abandoned_copper_town, x: 109, y: 69 },
{ key: :mass_grave, x: 98, y: 85 },
{ key: :good_island, x: 70, y: 137 },
{ key: :waterway, x: 127, y: 124 },
{ key: :remains_shore, x: 113, y: 127 },
{ key: :thorn_temple, x: 117, y: 126 },
{ key: :krusty_krab_pot, x: 120, y: 127 }
]
}
}
@pending = nil
@transfer_started = false
def self.request(x, y)
return false unless FrameworkUtils.ingame? && FrameworkUtils.cheats_allowed?
@pending = [x.to_i, y.to_i]
@transfer_started = false
# Exit the entire CheatFramework scene stack. One SceneManager.return only
# closes the location list and does not run Scene_Map#update yet.
SceneManager.goto(Scene_Map)
true
end
def self.update
return unless @pending
# Do not finish a queued teleport if OWNER privileges disappeared.
unless FrameworkUtils.cheats_allowed?
@pending = nil
@transfer_started = false
return
end
x, y = @pending
if $game_map.map_id.to_i == OVERMAP_ID
@pending = nil
@transfer_started = false
$game_player.moveto(x, y)
elsif !@transfer_started
@transfer_started = true
# A direct transfer avoids triggering story events at the exit or
# running change_map_leave_tag_map (which clears all carried gold).
$game_player.reserve_transfer(OVERMAP_ID, x, y, $game_player.direction)
end
rescue => e
@pending = nil
@transfer_started = false
p("[CheatFramework Teleport] " + e.to_s)
end
end
# Teleport appears *inside* the CheatFramework main menu, not in LonaRPG's / overlay.
CFTeleport::CATEGORIES.each do |cat_sym, cat_data|
MenuFramework::SUBMENU.register_command(
group: :TELEPORT,
type: :scene,
key: cat_data[:key],
label: cat_data[:label],
name: "CheatMenuTeleport_#{cat_data[:key].to_s.capitalize}",
dict: cat_data[:key].to_s.upcase.to_sym,
order: 0
)
cat_data[:locations].each do |loc|
MenuFramework::SUBMENU.register_command(
group: cat_data[:key].to_s.upcase.to_sym,
type: :action,
key: loc[:key],
label: "modules/teleport:location/#{loc[:key]}",
help1: "modules/teleport:help/#{loc[:key]}",
help4: "menu:command_help/execute",
action: -> {
if CFTeleport.request(loc[:x], loc[:y])
SndLib.sys_ok if defined?(SndLib)
else
SndLib.sys_buzzer if defined?(SndLib)
end
}
)
end
end
# Process queued transfer once the cheat menu has closed.
class Scene_Map
unless method_defined?(:cf_teleport_base_update)
alias_method :cf_teleport_base_update, :update
def update
cf_teleport_base_update
CFTeleport.update
end
end
end