#============================================================================== # LonaCraft - 95_Debug.rb # Debug hotkeys for testing. On only when Config/LonaCraft.json has # "debug": true (LonaCraft.debug?, 05_Config.rb; default false, the developer # build ships true). Only active on the map, for Lona, while no message or # event is running. Numpad 2/4/6/8 are left alone because the game binds them # (D2/D4/D6/D8 in 3000_InputMenu.rb). # # Numpad 0 +10 of every LonaCraft material and the Hatchet # (ITEM_NAMES + WEAPON_NAMES, 0_Core.rb) # Numpad 1 +10 of every LonaCraft furniture and decoration item # (Furniture::ITEM_NAMES, incl. the four stations) # Numpad 3 +10 raw inputs: Wooden Club, Crystal Ore, Apple, Herb Sta # Numpad 5 own every home, rent the rentable ones for 52 weeks # (Homes::LOCATIONS, 100_Homes.rb) # Numpad 9 / Num + crafting skill level +1 # Numpad 7 / Num - crafting skill level -1 # Numpad * reload the recipes: Recipes/*.json and Config/Recipes.json # (Recipes.build; recipes are not saved, so this is safe) # Home god mode on / off (D2, owner 2026-10-07; GOD_KEY). Not # saved, off at every start. While on (god? / free?): # * building, crafting, furniture and repairs are free: # every material charge and "not enough" check of the # mod asks Debug.free? (110_Bases.rb pay, can_build_count, # single placement, repair_piece; 90_Furniture.rb # placement; 55_Recipes.rb affordable?, missing, craft; # 80_CraftScene.rb missing, process_craft). The skill # requirement still applies. Coins (rent, mercenaries, # the maid) are not building costs and are still paid. # * Lona takes no damage: Game_Actor#take_damage # (Battle_System, BattleSystem.rb:495; RolePlayS # replaces it) is skipped for Lona unless the skill is a # support skill. Hit states (stun, grab) still apply. # * health, stamina and satiety ("health", "sta", "sat", # GOD_STATS) are held at their maximums every map frame # (top_up, Scene_Map#update below) and after every nap # (Game_Actor#process_nap_change, wrapping 160_Rest.rb's # hook and the game's nap math); crafting in the crafting # screen takes no stamina. LonaRPG has no separate rest # stat: tiredness is "sta" (the Fatigue state comes at # sta <= 0, 100_Game_Player_handle_on_move.rb:349-353). # Off again: nothing is refunded or charged afterwards, # the top-up stops. #============================================================================== module LonaCraft module Debug RAW_INPUTS = ["ItemMhWoodenClub", "ItemMineral", "ItemApple", "ItemHerbSta"] AMOUNT = 10 # Home: free (the numpad is taken: 0 1 3 5 7 9 + - * here, / 110_Bases.rb, # . 120_Raids.rb, 2 4 6 8 the game; Numpad Enter is the same key code # as Enter, the game's Confirm). The game reads :HOME only in its # console (520_Console.rb:761). With Num Lock off Numpad 7 also sends Home. GOD_KEY = :HOME GOD_STATS = ["health", "sta", "sat"] # held at max while god mode is on MAX_STAT = 2 # LonaActorStat / ActorStat MAX_STAT (280_Actor&NPC_Stat_root.rb:15) @god = false # God mode is on (debug builds only; never saved) def self.god? @god == true && enabled? end # The one question every material charge and "not enough" check of the # mod asks: true = build, craft, place and repair without paying. def self.free? god? end def self.toggle_god @god = !@god key = @god ? "god_on" : "god_off" msg = LonaCraft::TextFallback.get("Menu", "Debug/#{key}", @god ? "God mode ON" : "God mode OFF") p "LonaCraft debug god mode #{@god ? "ON" : "OFF"} (free building and crafting, no damage, health / stamina / satiety held)" say(msg) top_up end # Lona's health, stamina and satiety to their maximums. prev_health / # prev_sta are set first so the setters' change hooks (EXP, dirt, # arousal, mood and baby health from a change, LonaActorStat#set_stat, # 94_Game_Actor_Stats.rb:96) see no change. def self.top_up(actor = nil) return unless god? actor ||= $game_player ? $game_player.actor : nil return if actor.nil? || !actor.respond_to?(:battle_stat) return if actor.is_a?(Game_NPC_ActorPortraitChannel) st = actor.battle_stat GOD_STATS.each{|name| max = st.get_stat(name, MAX_STAT) next unless max.is_a?(Numeric) next if st.get_stat(name) >= max actor.prev_health = max if name == "health" && actor.respond_to?(:prev_health=) actor.prev_sta = max if name == "sta" && actor.respond_to?(:prev_sta=) actor.send("#{name}=", max) } rescue => e p "LonaCraft debug god top-up error #{e.class} #{e.message}" end # The switch (was the constant LonaCraft::DEBUG): Config/LonaCraft.json "debug". def self.enabled? LonaCraft.debug? end # The switch plus the moment: on the map, Lona in control. def self.active? return false unless enabled? return false if $game_map.nil? || $game_party.nil? || $game_player.nil? return false if $game_message && $game_message.busy? return false if $game_map.interpreter && $game_map.interpreter.running? return false if $game_player.actor.nil? || $game_player.actor.is_a?(Game_NPC_ActorPortraitChannel) true end def self.key?(*syms) syms.each do |s| begin return true if Input.trigger?(s) rescue # unknown key symbol in this input layer: ignore it end end false end def self.give_all(names, label) given = 0 names.each do |name| item = $data_ItemName[name] next if item.nil? $game_party.gain_item(item, AMOUNT) given += 1 end say("LonaCraft debug +#{AMOUNT} x #{given} #{label}") end def self.change_level(delta) d = LonaCraft::Skill.data lv = d["level"].to_i + delta lv = 0 if lv < 0 lv = LonaCraft::Skill::MAX_LEVEL if lv > LonaCraft::Skill::MAX_LEVEL d["level"] = lv d["exp"] = 0 say("LonaCraft debug crafting level #{lv}") end def self.reload_recipes list = LonaCraft::Recipes.build say("LonaCraft debug recipes reloaded (#{list.length}), see the console") end def self.say(text) begin $game_map.popup(0, text, 0, 0) rescue p text end begin SndLib.sys_Gain rescue end end def self.update return unless active? if key?(:NUMPAD0) give_all(LonaCraft::ITEM_NAMES + LonaCraft::WEAPON_NAMES, "materials and tools") elsif key?(:NUMPAD1) names = defined?(LonaCraft::Furniture::ITEM_NAMES) ? LonaCraft::Furniture::ITEM_NAMES : [] give_all(names, "furniture") elsif key?(:NUMPAD3) give_all(RAW_INPUTS, "raw inputs") elsif key?(:NUMPAD5) if defined?(LonaCraft::Homes) n = LonaCraft::Homes.debug_own_all say("LonaCraft debug all homes owned or rented 52 weeks (#{n})") end elsif key?(:NUMPAD9, :ADD) change_level(1) elsif key?(:NUMPAD7, :SUBTRACT) change_level(-1) elsif key?(:MULTIPLY) reload_recipes elsif key?(GOD_KEY) toggle_god end end end end class Scene_Map < Scene_Base alias lonacraft_debug_update update unless method_defined?(:lonacraft_debug_update) def update # god mode: topped up before the frame too, so a hit or a drain in this # frame starts from full (top_up returns at once when god mode is off) LonaCraft::Debug.top_up lonacraft_debug_update begin LonaCraft::Debug.update if LonaCraft::Debug.enabled? LonaCraft::Debug.top_up rescue => e p "LonaCraft debug error: #{e.message}" end end end #============================================================================== # God mode (D2): Lona takes no damage, and naps leave health, stamina and # satiety at their maximums. Lona only; NPCs (Game_NonPlayerCharacter) keep # their own take_damage. #============================================================================== class Game_Actor # Battle_System#take_damage(user, skill, force_hit=false, back_stabed=false) # (BattleSystem.rb:495, included at 25_Game_Actor.rb:16; RolePlayS # 160_BattleSystem.rb replaces it, the alias takes whichever is there) if method_defined?(:take_damage) && !method_defined?(:take_damage_lonacraft_god) alias_method :take_damage_lonacraft_god, :take_damage def take_damage(user, skill, *args) if LonaCraft::Debug.god? && $game_player && equal?($game_player.actor) && !(skill.respond_to?(:is_support) && skill.is_support) @accumulated_damage = 0 return nil end take_damage_lonacraft_god(user, skill, *args) end end # process_nap_change (97_Game_Actor_Stats&State&Nap.rb:63) as wrapped by # 160_Rest.rb (its tiers run inside): after all the nap math, back to max if method_defined?(:process_nap_change) && !method_defined?(:process_nap_change_lonacraft_god) alias_method :process_nap_change_lonacraft_god, :process_nap_change def process_nap_change(*args) result = process_nap_change_lonacraft_god(*args) begin LonaCraft::Debug.top_up(self) if LonaCraft::Debug.god? && $game_player && equal?($game_player.actor) rescue => e p "LonaCraft debug god nap error #{e.class} #{e.message}" end result end end end