KSteps2Doom VX
KSteps2Doom VXby 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.
Spoiler: The Script 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 =
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
$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!
本贴来自国际rpgmaker官方论坛作者:kyonides处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/ksteps2doom-vx.166985/
页:
[1]