KSteps2Doom XP
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 terrain tags belonging to a specific troop group.
You have set no such troop groups on that map via script call?
Well, that means you will just fight the same old random troops of yore.
Spoiler: The Script
Ruby: # * KSteps2Doom XP * # # 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. # Terrain Tags can be used to set separate Troop groups in game via script call. # * Script Calls * # # - Define a Terrain Tag for 1+ Enemy Troops # $game_map.troop_terrains[TroopID] = [Index0, etc.] # troop_terrains(TroopID, Index0, etc.) module KSteps2Doom BACKDROP = "" BATTLE_ICON = "046-Skill03" ICON_OFFSET_X = 32 COUNTER_X = 4 COUNTER_Y = 4 VIEWPORT_WH = [640, 480] # The rest of the Constants will be ignored if the BACKDROP exists. COUNTER_WH = [104, 26] # [Red, Green, Blue, Alpha] # Alpha is Optional! BACKDROP_COLOR = [0, 0, 0, 128] end class Game_Map alias :kyon_steps2doom_gm_map_setup :setup def setup(map_id) kyon_steps2doom_gm_map_setup(map_id) @troop_terrains = {} end def bottom_terrain_tag(x, y) return 0 if @map_id == 0 tile_id = data[x, y, 0] return 0 unless tile_id @terrain_tags[tile_id] > 0 ? @terrain_tags[tile_id] : 0 end attr_reader :troop_terrains end class Game_Player alias :kyon_steps2doom_gm_plyr_up :update attr_reader :encounter_steps def make_encounter_count @encounter_steps = $game_map.encounter_step @encounter_count = @encounter_steps end def encounter_steps @encounter_steps - @encounter_count end def terrain_tag $game_map.bottom_terrain_tag(@x, @y) end def encounter_changed? terrain_tag == 0 and @last_count != @encounter_count end def update @last_count = @encounter_count last_moving = moving? kyon_steps2doom_gm_plyr_up update_encounter(last_moving) end def update_encounter(moved) @encounter_count += 1 if !moving? and moved and encounter_changed? end end class Interpreter def troop_terrains(troop_id, *indexes) $game_map.troop_terrains[troop_id] = indexes end end class EncounterSprite < Sprite include KSteps2Doom def initialize(vp=nil) super(vp) self.x = COUNTER_X self.y = COUNTER_Y @color = Color.new(*BACKDROP_COLOR) make_bitmap make_rect end def make_bitmap if BACKDROP.nil? or BACKDROP.empty? self.bitmap = Bitmap.new(*COUNTER_WH) bitmap.fill_rect(bitmap.rect, @color) else self.bitmap = RPG::Cache.picture(BACKDROP) end icon = RPG::Cache.icon(BATTLE_ICON) bitmap.blt(8, 0, icon, icon.rect) end def make_rect iox = ICON_OFFSET_X @text_rect = Rect.new(iox, 0, bitmap.width - iox - 4, bitmap.height) @one_time = true end def refresh self.visible = $game_player.terrain_tag > 0 steps = $game_player.encounter_steps return if @last_steps == steps @last_steps = steps self.bitmap.clear make_bitmap counter = sprintf("%02d/%02d", @last_steps, $game_map.encounter_step) bitmap.draw_text(@text_rect, counter) end def dispose_all bitmap.dispose dispose end end class Spriteset_Map alias :kyon_steps2doom_sprtst_map_init :initialize alias :kyon_steps2doom_sprtst_map_up :update alias :kyon_steps2doom_sprtst_map_disp :dispose def initialize make_encounter_counter kyon_steps2doom_sprtst_map_init end def make_encounter_counter @encounter_vp = Viewport.new(0, 0, *KSteps2Doom::VIEWPORT_WH) @encounter_vp.z = 10000 @encounter_sprite = EncounterSprite.new(@encounter_vp) end def update kyon_steps2doom_sprtst_map_up update_encounter_bitmap end def update_encounter_bitmap @encounter_sprite.refresh end def dispose kyon_steps2doom_sprtst_map_disp @encounter_sprite.dispose_all @encounter_vp.dispose end end class Scene_Map alias :kyon_steps2doom_gm_map_cl_btl :call_battle def call_battle process_troop_terrains kyon_steps2doom_gm_map_cl_btl end def process_troop_terrains terrains = $game_map.troop_terrains return if terrains.empty? Graphics.update tag = $game_player.terrain_tag list = terrains[tag] n = rand(list.size) n = list[n] troop_id = $game_map.encounter_list[n] return unless $data_troops[troop_id] $game_temp.battle_troop_id = troop_id $game_player.straighten end end 复制代码
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-xp.166991/