public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers
Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: KSteps2Doom VX
  • Original author: kyonides
  • Original date: March 19, 2024
  • Source thread: https://forums.rpgmakerweb.com/threads/ksteps2doom-vx.166985/
  • Source forum path: Game Development Engines > Ruby Game System (RGSS) Scripts > RGSS2 Scripts (RMVX)

Summary

KSteps2Doom VX by Kyonides​ Introduction This script turns the map's encounter steps as a fixed number.

Archived First Post

KSteps2Doom VX

by Kyonides

Introduction

This script turns the map's encounter steps as a fixed number.
It features a simple HUD to let you know when you are about to trigger a random encounter on the current map.
The HUD will disappear if you leave any of the monster areas.
You have set no areas on that map?
Well, that means you won't be fighting any given monster.

ksteps2doom_vx01.jpg

Ruby:
# * KSteps2Doom VX * #
#   Scripter : Kyonides Arkanthes
#   2024-03-19

# This script turns the map's encounter steps as a fixed number.
# It features a simple HUD to let you know when you are about to trigger a
# random encounter on the current map.

module KSteps2Doom
  COUNTER_ICON_INDEX = 112
  COUNTER_X  = 4
  COUNTER_Y  = 4
  COUNTER_WH = [104, 26]
end

class Game_Map
  alias :kyon_steps2doom_gm_map_setup :setup
  def setup(map_id)
    kyon_steps2doom_gm_map_setup(map_id)
    areas = $data_areas.values.compact
    @map_areas = areas.select {|area| area.map_id == @map_id }
  end
  attr_reader :map_areas
end

class Game_Player
  attr_reader :encounter_count
  def make_encounter_count
    @encounter_count = 0
  end

  def update_encounter
    return if $TEST and Input.press?(Input::CTRL)
    return if in_vehicle? or !area_found?
    @encounter_count += 1
  end

  def map_area?(area)
    rect = area.rect
    return false if rect.x > @x or rect.y > @y 
    return false if @x >= rect.x + rect.width
    return false if @y >= rect.y + rect.height
    return true
  end

  def area_found?
    $game_map.map_areas.find {|area| map_area?(area) } != nil
  end
end

class EncounterSprite < Sprite
  include KSteps2Doom
  def initialize(vp=nil)
    super(vp)
    self.x = COUNTER_X
    self.y = COUNTER_Y
    self.bitmap = Bitmap.new(*COUNTER_WH)
    make_rects
  end

  def make_rects
    grad_width = bitmap.width / 2
    @black = Color.new(0, 0, 0)
    @alpha = Color.new(0, 0, 0, 0)
    @left_rect = Rect.new(0, 0, grad_width, bitmap.height)
    @right_rect = Rect.new(grad_width, 0, grad_width, bitmap.height)
    @text_rect = Rect.new(32, 0, bitmap.width - 36, 24)
    pos = COUNTER_ICON_INDEX
    icon = Cache.system("IconSet")
    icon_rect = Rect.new(pos % 16 * 24, pos / 16 * 24, 24, 24)
    @icon = Bitmap.new(24, 24)
    @icon.blt(0, 0, icon, icon_rect)
  end

  def refresh
    self.visible = $game_player.area_found?
    return if $game_player.encounter_count == @last_steps
    @last_steps = $game_player.encounter_count
    self.bitmap.clear
    es = $game_map.encounter_step
    counter = sprintf("%02d/%02d", @last_steps, es)
    bitmap.gradient_fill_rect(@left_rect, @alpha, @black)
    bitmap.gradient_fill_rect(@right_rect, @black, @alpha)
    bitmap.blt(8, 0, @icon, @icon.rect)
    bitmap.draw_text(@text_rect, counter)
  end

  def dispose_all
    @icon.dispose
    bitmap.dispose
    dispose
  end
end

class Spriteset_Map
  alias :kyon_steps2doom_sprtst_map_crt_pix :create_pictures
  alias :kyon_steps2doom_sprtst_map_up :update
  alias :kyon_steps2doom_sprtst_map_disp :dispose
  def create_pictures
    kyon_steps2doom_sprtst_map_crt_pix
    make_encounter_counter
  end

  def make_encounter_counter
    @encounter_sprite = EncounterSprite.new(@viewport3)
  end

  def update_encounter_bitmap
    @encounter_sprite.refresh
  end

  def update
    kyon_steps2doom_sprtst_map_up
    update_encounter_bitmap
  end

  def dispose
    kyon_steps2doom_sprtst_map_disp
    @encounter_sprite.dispose_all
  end
end

class Scene_Map
  def update_encounter
    return if $game_map.interpreter.running?
    return if $game_system.encounter_disabled
    return if $game_map.encounter_step != $game_player.encounter_count
    troop_id = $game_player.make_encounter_troop_id
    return unless $data_troops[troop_id]
    $game_player.make_encounter_count
    $game_troop.setup(troop_id)
    $game_troop.can_escape = true
    $game_temp.battle_proc = nil
    $game_temp.next_scene = "battle"
    preemptive_or_surprise
  end
end

Download Demo

Terms & Conditions

Free for use in ANY game.
Due credit is mandatory.
Mention this forum in your game credits.
That's it!

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download

License / Terms Note

Due credit is mandatory. Mention this forum in your game credits. That's it!

Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rgss2#script-archive

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar