09-11-2024, 10:14 PM
KMapData
version 0.4.0
by Kyonides Arkanthes
Introduction
Did you ever want to keep track of how many chests the player has found? Or did you need to record how many traps the player has triggered so far? Or you wanted to save which switches the player turned on and off and in which order he did it?
Now you can do it!
! The direct script call to change the required number of monster encounter steps has been included already.
! By the way, you can also modify the default behavior of the monster encounter steps micro system.
Just follow the instructions already included in my script.
Notes
There is no screenshot available for there's no menu included here.
KMapData Main Script
Code:
# * KMapData
# Scripter : Kyonides Arkanthes
# 2020-07-06 - v0.4.0
# This scriptlet allows you to keep track of the chest you've found on the map
# and all the traps you've triggered so far.
# I guess the latter could be helpful to design a system where you can keep
# track of many chests and traps without using any game variables. You can clear
# a map's data at any time if deemed necessary.
# It's also possible to keep track of switches a player needs to turn on or off.
# You still need to setup the initial values of a few CONSTANTS listed in the
# KMap module! Some of them allow you to modify the default behavoir of the
# number of steps required to encounter a monster.
# * Script Calls *
# To easily get your current Map ID - Script Command Box Only!
# @map_id
# To toggle any map's Fixed Number of Steps
# $game_system.fixed_steps = true or false
# To divide the Number of Steps
# $game_system.steps_reducer = 1 -> No Division - Default Behavior
# $game_system.steps_reducer = 2 or greater -> Steps / Steps Reduction
# $game_system.steps_reducer = 0 -> Game Crash! ZeroDivisionError!!
# To increase the Total Number of Chests Found on the current Map
# $game_party.chests_found[MapID] += 1
# To increase the Total Number of Traps Triggered on the current Map
# $game_party.traps_triggered[MapID] += 1
# To clear any map's data - Options: Defined in CLEAR_DATA_OPTIONS constant
# $game_party.clear_data(Option) - For the current map
# $game_party.clear_data(Option, MapID) - For any other map
# To check if the player has found enough chests and has not triggered too many
# traps on a specific map
# KMap.pass_chest_trap_test? - For Current Map
# KMap.pass_chest_trap_test?(MapID) - For Any Other Map
# To check if the player triggered the right switches in the right order
# KMap.pass_switch_order? - For Current Map
# KMap.pass_switch_order?(MapID) - For Any Other Map
# To set a map's Switch Order
# -> Predefined Order
# KMap.map_switch_order[MapID] = [1, 3, 5, etc.]
# -> Player's Input
# Assign a value to the Game Variable set in SWITCH_ORDER_VAR constant for
# each separate switch by clicking on Control Variables.
# It does not matter if the player turns it ON or OFF at any time.
# To clear Switch Order related stuff
# KMap.clear_switch_order
# * Examples of Script Condition Event Command
# There the @map_id would be the same as the current map.
# Script [ $game_party.chests_found[@map_id] >= 20 ]
# Script [ $game_party.traps_triggered[@map_id] < 6 ]
# Script [ KMap.pass_switch_order? ]
module KMap
CHESTS_SWITCH = 1
TRAPS_SWITCH = 2
SWITCH_ORDER_VAR = 1
MAP_SWITCH_ORDER = "Best Switch Order"
ALT_SWITCH_ORDER = "Alternate Switch Order"
SWITCH_ORDER = "Player's Switch Order"
FIXED_STEPS = true # Fix Number of Monster Encounter Steps?
DIVIDE_STEPS_BY = 1 # 1 : No Reduction, 2+ : Divide Steps by that value
# Options Order as :symbols : [ Chest, Trap, All ]
CLEAR_DATA_OPTIONS = [:chest, :trap, :all]
MIN_CHESTS_FOUND = {}
MIN_CHESTS_FOUND.default = 0 # For those maps you won't include here
MAX_TRAPS_FOUND = {}
MAX_TRAPS_FOUND.default = 0
# Example of Chests for Map #1: MIN_CHESTS_FOUND[1] = 20
# Example of Traps for Map #1: MIN_TRAPS_FOUND[1] = 5
class << self
def pass_chest_trap_test?(mid=$game_map.map_id)
return false if $game_party.chests_found[mid] < MIN_CHESTS_FOUND[mid]
$game_party.traps_triggered[mid] <= MIN_TRAPS_FOUND[mid]
end
def pass_switch_order?(mid=$game_map.map_id)
@map_switch_order == @switch_order
end
def select_order(n)
(n == 0 ? @map_switch_order : n == 1 ? @alt_switch_order : @switch_order)
end
def select_label(n)
(n == 0 ? MAP_SWITCH_ORDER : n == 1 ? ALT_SWITCH_ORDER : SWITCH_ORDER)
end
def clear_switch_order
@map_switch_order = []
@alt_switch_order = []
@switch_order = []
end
def retrieve_version
lines = File.readlines('Game.ini')
lines.each do |line|
value = line =~ /rgss\d/i
next if value == nil
return line.scan(/\d/)[0].to_i
end
end
attr_accessor :map_switch_order, :alt_switch_order
attr_reader :switch_order
end
MAKER_VERSION = retrieve_version
clear_switch_order
Manager = MAKER_VERSION == 1 ? Interpreter : Game_Interpreter
end
module SwitchOrder
def make_windows(y1, y2, y3)
@order_windows = [SwitchOrderWindow.new(y1, 0)]
@order_windows << SwitchOrderWindow.new(y2, 1)
@order_windows << SwitchOrderWindow.new(y3, 2)
end
def update_scene
Graphics.update
Input.update
update
end
def terminate
Graphics.freeze
@order_windows.each{|win| win.dispose }
end
end
class Game_System
alias :kyon_mdx_gm_sys_init :initialize
def initialize
kyon_mdx_gm_sys_init
@fixed_steps = KMap::FIXED_STEPS
@steps_reducer = KMap::DIVIDE_STEPS_BY
end
attr_accessor :fixed_steps, :steps_reducer
end
class Game_Party
alias :kyon_md_gm_party_init :initialize
def initialize
kyon_md_gm_party_init
@chests_found = {}
@chests_found.default = 0
@traps_triggered = {}
@traps_triggered.default = 0
end
def clear_data(data_sym, map_id=$game_map.map_id)
chest, traps, all = KMap::CLEAR_DATA_OPTIONS
@chests_found[map_id] = 0 if [all, chest].include?(data_sym)
@traps_triggered[map_id] = 0 if [all, traps].include?(data_sym)
end
attr_reader :chests_found, :traps_triggered
end
class Game_Player
def make_encounter_count
return if $game_map.map_id == 0
m = $game_system.steps_reducer
if $game_system.fixed_steps
@encounter_count = $game_map.encounter_step / m if @encounter_count == 0
else
n = $game_map.encounter_step / m
@encounter_count = rand(n) + rand(n) + 1
end
end
end
class KMap::Manager
alias :kyon_md_int_switches :command_121
alias :kyon_md_int_variables :command_122
def command_121
kyon_int_switches
cs = KMap::CHESTS_SWITCH
ts = KMap::TRAPS_SWITCH
if $game_switches[cs]
$game_switches[cs] = false
$game_party.chests_found[@map_id] += 1
end
if $game_switches[ts]
$game_switches[ts] = false
$game_party.traps_triggered[@map_id] += 1
end
return true
end
def command_122
sov = KMap::SWITCH_ORDER_VAR
if sov == @parameters[4] and $game_variables[sov] > 0
KMap.switch_order << $game_variables[sov]
$game_variables[sov] = 0
return true
end
kyon_md_int_variables
end
end
class SwitchOrderWindow < Window_Selectable
def initialize(wy, pos)
@switches = KMap.select_order(pos)
@label = KMap.select_label(pos)
@lh = KMap::MAKER_VERSION == 3 ? 24 : 32
@lj, h = KMap::MAKER_VERSION == 1 ? [28, 96] : [24, 88]
super(0, wy, Graphics.width, h)
create_contents
refresh
end
def refresh
bitmap = self.contents
bitmap.draw_text(0, 0, width - @lh, @lj, @label, 1)
lw = 0
@switches.size.times do |n|
label = @switches[n].to_s
lx = contents.text_size(label).width
bitmap.draw_text(lw, @lh, lx, @lj, label)
lw += lx + 8
end
end
end
Debug Scene Script
For VX or ACE
Code:
# * KMapData - Switch Order Debug Menu VX & ACE
# Scripter : Kyonides Arkanthes
class SwitchOrderScene < Scene_Base
def main
@keep_open = true
@order_windows = [SwitchOrderWindow.new(0, 0)]
@order_windows << SwitchOrderWindow.new(88, 1)
@order_windows << SwitchOrderWindow.new(176, 2)
perform_transition
while @keep_open
Graphics.update
Input.update
update
end
Graphics.freeze
@order_windows.each{|win| win.dispose }
end
def update
return unless Input.trigger?(Input::B)
Sound.play_cancel
@keep_open = nil
if KMap::MAKER_VERSION == 2
$scene = Scene_Map.new
else
SceneManager.goto(Scene_Map)
end
end
end
class Scene_Map
alias :kyon_md_scn_map_up_call_menu :update_call_menu
def update_call_menu
if Input.trigger?(Input::CTRL)
if KMap::MAKER_VERSION == 2
Sound.play_decision
$scene = SwitchOrderScene.new
else
Sound.play_ok
SceneManager.goto(SwitchOrderScene)
end
return
end
kyon_md_scn_map_up_call_menu
end
end
Terms & Conditions
I don't know, I guess I might accept suggestions on this topic.
Free for non commercial games.
Give me a free copy of your completed game if you include at least 2 of my scripts!
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Maranatha!
The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.
My Original Stories (available in English and Spanish)
List of Compiled Binary Executables I have published...
HiddenChest & Roole
Give me a free copy of your completed game if you include at least 3 of my scripts!
Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE