RPG Maker Forums

I found this script from browsing across the forum (https://forums.rpgmakerweb.com/index.php?threads/show-enemy-hp-gauge-de-buffs.43717/).

I came across this jumbled-up code and don't know how to fix it and make it work. Can anyone help me?

#==============================================================================# Display State icons# By Lecode# Requested from BCj#----------------------# Free to use in commercial games as long as you credit me#==============================================================================module Lecode_StatesIcons #- :top or :bottom Position = :bottom Offset_X = 0 Offset_Y = 0 #- Space between icons Space = 2 #- false = show only when the battler is selected Always_Visible = true #- Icons z Z = 5 Opacity = 205 #- Show turn count ? Turn_Count= true TC_Size = 16 TC_Color = Color.new(255,255,255) #- Change text color when current turn count = TC_Warning_Turn TC_Warning_Turn = 1 TC_Warning_Color = Color.new(245,100,100) TC_Warning_Blink = true TC_Blink_Color = Color.new(255,255,255) TC_Blink_Duration = 30 #- Wait x frames before looping TC_Blink_Wait = 5 end#==============================================================================# END OF CONFIGURATION#==============================================================================class LeState_Icons def initialize(battler,sprite) @battler = battler @sprite = sprite @last_record = [] @icons = [] @turns = [] @blinking_ics = [] @blink_frame = 0 end def update return if @battler.nil? update_icons refresh_icons update_positions update_visibility update_blinks end def update_icons @icons.each { |i| i.update } @turns.each { |i| i.update } end def refresh_icons dispose_icons if @battler.dead? return if @battler.dead? return if current_record == @last_record @last_record = @battler.states dispose_icons @battler.states.each { |state| #- Icon icon = Sprite.new icon.bitmap = Bitmap.new(24,24) icon_index = state.icon_index bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) icon.bitmap.blt(0, 0, bitmap, rect) icon.z = Lecode_StatesIcons::Z icon.opacity = Lecode_StatesIcons::opacity @icons.push(icon) #- Turn count turn_count = state_turns(state) tc_sprite = Sprite.new dum_bitmap = Bitmap.new(1,1) dum_bitmap.font.size = Lecode_StatesIcons::TC_Size rect = dum_bitmap.text_size(turn_count) tc_sprite.bitmap = Bitmap.new(rect.width+4,rect.height+4) tc_sprite.bitmap.font.size = Lecode_StatesIcons::TC_Size if turn_count == Lecode_StatesIcons::TC_Warning_Turn tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Warning_Color else tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Color end if state.auto_removal_timing == 2 tc_sprite.bitmap.draw_text(0,0,rect.width+2,rect.height+2,turn_count.to_s) end tc_sprite.z = icon.z+1 @turns.push(tc_sprite) if Lecode_StatesIcons::TC_Warning_Blink && state.auto_removal_timing == 2 start_blink(icon) if turn_count == Lecode_StatesIcons::TC_Warning_Turn end #- @last_record.push(turn_count) } @blink_frame = Lecode_StatesIcons::TC_Blink_Duration end def current_record arr = @battler.states @battler.states.each { |s| arr.push(state_turns(s)) } return arr end def start_blink(sprite) @blinking_ics.push(sprite) end def update_positions #- Icons total_width = @icons.size*(24+space) x = @battler.screen_x - total_width/2 if position == :top y = @battler.screen_y - @sprite.height - 24 else y = @battler.screen_y - 24 end x += Lecode_StatesIcons::offset_X y += Lecode_StatesIcons::offset_Y @icons.each_with_index { |ic,i| ic.x = x+i*(24+space) ic.y = y } #- Turn counts @turns.each_with_index { |ic,i| ic.x = x+i*(24+space) ic.y = y } end def update_visibility @icons.each { |i| i.visible = visible? } @turns.each { |i| i.visible = visible? } end def visible? return true if Lecode_StatesIcons::Always_Visible return false unless SceneManager.scene_is?(Scene_Battle) return false unless SceneManager.scene.enemy_window.visible return true if SceneManager.scene.enemy_window.enemy == @battler return true if SceneManager.scene.enemy_window.select_all? return false end def update_blinks color = Lecode_StatesIcons::TC_Blink_Color duration = Lecode_StatesIcons::TC_Blink_Duration wait = Lecode_StatesIcons::TC_Blink_Wait @blink_frame = [@blink_frame+1,duration+wait].min if @blink_frame == duration+wait @blink_frame = 0 @blinking_ics.each { |ic| ic.flash(color,duration) } end end def space Lecode_StatesIcons::Space end def position Lecode_StatesIcons::position end def state_turns(state) if $imported["YEA-Buff&StateManager"] return @battler.state_turns(state) end return @battler.state_turns[state.id] end def dispose_icons @icons.each { |i| i.bitmap.dispose i.dispose } @icons.clear @turns.each { |i| i.bitmap.dispose i.dispose } @turns.clear @blinking_ics.clear end endclass Sprite_Battler < Sprite_Base alias lecode_siinitialize initialize def initialize(viewport, battler = nil) lecode_siinitialize(viewport, battler) @state_icons = LeState_Icons.new(@battler,self) end alias lecode_sidispose dispose def dispose lecode_sidispose @state_icons.dispose_icons end alias lecode_siupdate update def update lecode_siupdate @state_icons.update end endclass Scene_Battle attr_reader :enemy_windowendunless $imported["YEA-Buff&StateManager"]class Game_Battler attr_reader :state_turnsendend

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,018
Messages
1,018,358
Members
137,803
Latest member
andrewcole
Top