KTrespass XP
#1
KTrespass XP

by Kyonides

Introduction

Let the player do crazy stuff like slipping into a pond or climbing a mountain (no batteries nor UI included) by just owning a very specific item.

Everything is handled by the very short KTrespass module. Just add an item ID to the Hash and set its corresponding Array of Terrain Tags, and that's it! :D

NOTE: Game_Player#passable? method has been overwritten on purpose to keep the script as simple as possible.

The Script

Code:
# * KTrespass XP * #
#   Scripter : Kyonides
#   v1.0.1 - 2026-06-26

# Let the player slip into a pond or climb a mountain (no UI included)
# if the party owns a specific item.
# Just configure the TERRAIN_ITEMS Constant below accordingly.

module KTrespass
  TERRAIN_ITEMS = {} # Better leave this line alone!
# Terrain Tags: Never include 0 in the array!
# [ItemID] = [Tag1, etc.]
  TERRAIN_ITEMS[26] = [1,2]
end

class Game_Party
  alias :kyon_trespass_gm_pty_init :initialize
  alias :kyon_trespass_gm_pty_gain_item :gain_item
  def initialize
    kyon_trespass_gm_pty_init
    @terrain_items = {}
  end

  def gain_item(item_id, n)
    kyon_trespass_gm_pty_gain_item(item_id, n)
    tags = KTrespass::TERRAIN_ITEMS[item_id]
    refresh_item_terrain_tags(item_id, tags) if tags
  end

  def refresh_item_terrain_tags(item_id, tags)
    n = @items[item_id] || 0
    if n > 0
      @terrain_items[item_id] ||= tags
    else
      @terrain_items.delete(item_id)
    end
  end

  def terrain_items
    @terrain_items ||= {}
  end

  def item_has_terrain_tag?(target)
    @terrain_items.values.flatten.include?(target)
  end
end

class Game_Player
  def passable?(x, y, d)
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    return false if !$game_map.valid?(new_x, new_y)
    return true if $DEBUG and Input.press?(Input::CTRL)
    return true if @through
    pass_now = $game_map.passable?(x, y, d, self)
    pass_next = $game_map.passable?(new_x, new_y, 10 - d)
    if $game_party.terrain_items.empty?
      return false if !pass_now or !pass_next
    else
      if !pass_now
        tag = $game_map.terrain_tag(x, y)
        return false if tag == 0 or !$game_party.item_has_terrain_tag?(tag)
      end
      if !pass_next
        tag = $game_map.terrain_tag(new_x, new_y)
        return false if !$game_party.item_has_terrain_tag?(tag)
      end
    end
    for event in $game_map.events.values
      if event.x == new_x and event.y == new_y
        unless event.through
          return false if self != $game_player
          return false if !event.character_name.empty?
        end
      end
    end
    if @x == new_x and @y == new_y
      return true if @through or
      return false if !@character_name.empty?
    end
    true
  end
end

Terms & Conditions

Under MIT License.
That's it! Tongue sticking out
"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.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

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! Laughing + Tongue sticking out

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
Reply




Users browsing this thread: 3 Guest(s)