All pastes #20196 Raw Edit

Untitled

public text v1 · immutable
#20196 ·published 2005-08-16 21:05 UTC
rendered paste body
class Scene_Battle
  alias atbv1_update update
  def update
    unless @atb
      @atb = Game_ATB.new
    end
    @atb.update
    atbv1_update
  end
end

class Game_Battler
  attr_accessor :time
  alias atbv1_initialize initialize
  def initialize
    @time = 10000.0
    atbv1_initialize
  end
end

class Game_ATB
  def update
    agi = 0
    count = 0
    for battler in  $game_troop.enemies + $game_party.actors
      agi += battler.agi
      count += 1
    end
    for battler in $game_troop.enemies + $game_party.actors
      battler.time -= (battler.agi.to_f / (agi / count) * 100).to_i
      if battler.time <= 0
        battler.time = 10000.0
      end
    end
  end
end

class Window_BattleStatus < Window_Base
  alias atbv1_update update
  def update
    atbv1_update
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      draw_atb_meter(i * 160 + 4, 93, 120, actor)
    end
  end
  def draw_atb_meter(x, y, width, actor)
    w = width - width * (actor.time / 10000)
    self.contents.fill_rect(x, y, width, 6, Color.new(0, 0, 0, 255))
    self.contents.fill_rect(x + 1, y + 1, w - 1, 1, Color.new(255, 255, 128, 255))
    self.contents.fill_rect(x + 1, y + 2, w - 1, 1, Color.new(255, 255, 0  , 255))
    self.contents.fill_rect(x + 1, y + 3, w - 1, 1, Color.new(192, 192, 0  , 255))
    self.contents.fill_rect(x + 1, y + 4, w - 1, 1, Color.new(128, 128, 0  , 255))
  end
end