Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Fixed most my issues...Battle System won't work anymore :/

I don't have the graphic files to test it.
But the divided by 0 thing, if it's like trying to divide a variable like width or height when it's possible they could be 0 just change it to multiplication
divided by 2 | Multiply by 0.5
divided by 3 | Multiply by 0.33
divided by 4 | Multiply by 0.25

(something.width * 0.5)
remember to write decimals with 0 in front because ".5" is a syntax error.

edit:
Oh and that fact that it's trying to draw something on screen that has 0 width or height could be a clue.
 
Reeeeeeeee

I keep finding stuff wrong with the battle system
Both Defend and Escape didn't work, crashing the game. I think I fixed it.

Then I discovered if you cancel out from target-select you don't go back to the command window, you're just stuck. So I'm looking into that now.
 
coyotecraft":3jxc9b1j said:
Reeeeeeeee

I keep finding stuff wrong with the battle system
Both Defend and Escape didn't work, crashing the game. I think I fixed it.

Then I discovered if you cancel out from target-select you don't go back to the command window, you're just stuck. So I'm looking into that now.
Alright so I've got everything here to start going through it, but you seem to have made some significant progress. Would you be able to alias your changes coyote or should I leave it to you?

EDIT: When I said put my script above main, I meant literally as the script above it. That's why the Status screen wasn't working.
 
Wow really thanks guys for the help, it's well appreciated :D

Also ZenVirZan since he's doing the battlescript perhaps you could try the Time HUD with the Daily Life script...
And perhaps have a way to show ''Region Of Map'' instead of ''Map Name'' in location...If you want ^^.
 
I made it show regions instead of the map name. It'll default to map name if region is not specified.
Please put this ZenVirZan script directly above main. You can remove the old one.
Code:
class Window_Base

  def draw_actor_hp(actor, x, y, width = 144, text = true)

    # Draw hp bar

    bitmap = RPG::Cache.acms_menusprite("HP")

    rect = Rect.new(x + BAR_PADDING, y, (width - 2 * BAR_PADDING) * actor.hp / actor.maxhp, bitmap.height)

    self.contents.stretch_blt(rect, bitmap, Rect.new(0, 0,

      bitmap.width * actor.hp / actor.maxhp, bitmap.height), opacity)

    bitmap = RPG::Cache.acms_menusprite("Gauge")

    rect = []

    w = bitmap.width / 3

    for i in 0...3

      rect << Rect.new(i * w, 0, w, bitmap.height)

    end

    self.contents.blt(x, y, bitmap, rect[0], opacity)

    i = w

    while i < width - 2 * w

      self.contents.blt(x + i, y, bitmap, rect[1], opacity)

      i += w

    end

    rect[1].width = (width - 1) % w + 1

    self.contents.blt(x + i, y, bitmap, rect[1], opacity)

    i += (width - 1) % w + 1

    self.contents.blt(x + i, y, bitmap, rect[2], opacity)

    # Draw hp name

    rect = self.contents.text_size($data_system.words.hp)

    self.contents.draw_text(x, y + (bitmap.height - rect.height) / 2, 32, 32, $data_system.words.hp, opacity)

   

    self.contents.font.color = Color.new(255,255,255)

    sz = self.contents.font.size

    self.contents.font.size = 18

    self.contents.font.bold = true

    self.contents.draw_text_outline(x-16, y-8, width, 32, sprintf("%4d/%4d", actor.hp, actor.maxhp),2)

    self.contents.font.size = sz

    self.contents.font.bold = false

  end

 

  def draw_actor_sp(actor, x, y, width = 144, text = true)

    # Draw sp bar

    bitmap = RPG::Cache.acms_menusprite("SP")

    rect = Rect.new(x + BAR_PADDING, y, (width - 2 * BAR_PADDING) * actor.sp / actor.maxsp, bitmap.height)

    self.contents.stretch_blt(rect, bitmap, Rect.new(0, 0,

      bitmap.width * actor.sp / actor.maxsp, bitmap.height), opacity)

    bitmap = RPG::Cache.acms_menusprite("Gauge")

    rect = []

    w = bitmap.width / 3

    for i in 0...3

      rect << Rect.new(i * w, 0, w, bitmap.height)

    end

    self.contents.blt(x, y, bitmap, rect[0], opacity)

    i = w

    while i < width - 2 * w

      self.contents.blt(x + i, y, bitmap, rect[1], opacity)

      i += w

    end

    rect[1].width = (width - 1) % w + 1

    self.contents.blt(x + i, y, bitmap, rect[1], opacity)

    i += (width - 1) % w + 1

    self.contents.blt(x + i, y, bitmap, rect[2], opacity)

    # Draw sp name

    rect = self.contents.text_size($data_system.words.sp)

    self.contents.draw_text(x, y + (bitmap.height - rect.height) / 2, 32, 32, $data_system.words.sp, opacity)

   

    self.contents.font.color = Color.new(255,255,255)

    sz = self.contents.font.size

    self.contents.font.size = 18

    self.contents.font.bold = true

    self.contents.draw_text_outline(x-16, y-8, width, 32, sprintf("%4d/%4d", actor.sp, actor.maxsp),2)

    self.contents.font.bold = false

    self.contents.font.size = sz

  end

end

 

class Bitmap

  def draw_text_outline(x,y,w,h,s,align=0)

    c = font.color.dup

    font.color = Color.new(0,0,0)

    draw_text(x,  y+1 ,w  ,h,s,align)

    draw_text(x+2,y+1 ,w,h,s,align)

   

    draw_text(x+1,y   ,w,h  ,s,align)

    draw_text(x+1,y+2 ,w,h,s,align)

   

    font.color = c

    mp_draw_text(x+1,  y+1 ,w,h,s,align)

  end

end

 

 

class Window_Status < Window_Base

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    draw_actor_graphic(@actor, 16, 48)

    draw_actor_name(@actor, 40, 0)

    #draw_actor_class(@actor, 160, 0)

    draw_actor_level(@actor, 160, 0)

    draw_actor_state(@actor, 224, 0)

    draw_actor_hp(@actor, 64, 44, 192, true)

    draw_actor_sp(@actor, 64, 64, 192, true)

   

    self.contents.font.color = system_color

    self.contents.draw_text(0, 88, 40, 32, "EXP")

    self.contents.draw_text(128, 88, 40, 32, "NEXT")

    self.contents.font.color = normal_color

    self.contents.draw_text(24, 88, 80, 32, @actor.exp_s, 2)

    self.contents.draw_text(152, 88, 80, 32, @actor.next_rest_exp_s, 2)

    draw_actor_parameter(@actor, 0, 120, 0)

    draw_actor_parameter(@actor, 0, 144, 1)

    draw_actor_parameter(@actor, 0, 168, 2)

    draw_actor_parameter(@actor, 0, 192, 3)

    draw_actor_parameter(@actor, 0, 216, 4)

    draw_actor_parameter(@actor, 0, 240, 5)

    draw_actor_parameter(@actor, 0, 264, 6)

    draw_item_name($data_weapons[@actor.weapon_id], 120, 120, 136)

    draw_item_name($data_armors[@actor.armor1_id], 120, 152, 136)

    draw_item_name($data_armors[@actor.armor2_id], 120, 184, 136)

    draw_item_name($data_armors[@actor.armor3_id], 120, 216, 136)

    draw_item_name($data_armors[@actor.armor4_id], 120, 248, 136)

  end

end

 

class Game_Map

  attr_reader :cur_reg

end

 

class Window_Base

  def draw_info(type, align)

    icon = nil

    text = nil

    number = nil

    case type

    # Gold

    when GOLD

      icon = ICON_GOLD

      number = $game_party.gold

      text = $data_system.words.gold

      size = 32 + SPACING_BIG * (number.to_s.size + 1) + self.contents.text_size(text).width

      fnt = FNT_GOLD

    # Location

    when LOCATION

      icon = ICON_LOCATION

      text = zen_get_location_name

      size = 32 + self.contents.text_size(text).width

    # Time

    when TIME

      icon = ICON_TIME

      t = Graphics.frame_count / Graphics.frame_rate

      number = sprintf("%02d:%02d:%02d", t / 3600, (t / 60) % 60, t % 60)

      size = 32 + SPACING_BIG * number.to_s.size

      fnt = FNT_TIME

    end

    case align

    # Left

    when 0

      x = 12

    # Middle

    when 1

      x = (self.contents.width - size) / 2

    # Right

    when 2

      x = self.contents.width - size - 12

    end

    # Draw icon

    if icon

      self.contents.blt(x, (self.contents.height - 24) / 2, icon, icon.rect)

      x += 32

    end

    # Draw number

    if number

      self.contents.draw_number(x, (self.contents.height - fnt.height) / 2, number, fnt, SPACING_BIG)

      x += SPACING_BIG * (number.to_s.size + 1)

    end

    # Draw text

    if text

      rect = self.contents.text_size(text)

      self.contents.draw_text(x, (self.contents.height - rect.height) / 2, 200, 32, text, 0)

      x += rect.width

    end

  end

  

  def zen_get_location_name

    $game_map.check_current_region

    regions = [$data_mapinfos[$game_map.map_id].name]

    if $game_map.cur_reg.length > 0

      regions = []

      for i in $game_map.cur_reg

        regions.push REGIONS.regions($game_map.map_id)[i][0]

      end

    end

    return regions.join(", ")

  end

    

   

end
 
No, I don't think I fixed the root of the problem.

Like, 'defend' and 'escape' weren't ending the turn. The command window comes up for same character again and selecting anything the second time crashed the game; unless you pressed 'Right' then it would go to the next character and perform the command you selected the first time.
So I just rigged it in a way that made sure an action was made and the turn ended.

I got the command window to come back after canceling from the enemy select.
But when I cancel an attack and choose defend, I'm getting the same error message again 'undefined method "current_action" for nil.'
And if I try to select 'escape' after canceling an attack, it doesn't do anything. Like it's not coded to do anything.
I'm thinking by canceling an attack the game script returned to an older method, because there are measures in place to not do anything in instances of nil.
But yet the script editor shows it stopped on the aliased method. So I'm not sure what's going on.
 
Remove the Old ZenVirZan Script?
Regions work fine! Thanks.

Now for the Time HUD and the Battle system...

Coyote would it be easier for you to make a new one aslong as i have the same features.?
All i need is Active Time Bar (Based on the Speed Stat (Agility in RMXP's stats)
I need it to calculate turns (so that i can script events that happen at the turn i want it to.
It needs to handle ''Double Attack'' (Which I've made a skill+ common event for a character) : Common event raises speed to max, perform attack, twice (forced action) then reset speed to normal... Idk if theres a better method for a skill to do that.

If you can fix this one then everything is fine too,
 
Cassandrainbows":loht4li6 said:
new zenvirzan script crashes Stats, Skills and Party Menu (any ways of locking character 1 in Party Menu so it can't be switched??? and/or Lock/unlock Character slots 1 2 3 4 in game menu for quest characters and so on?

http://www.filedropper.com/scripts_1

This contains all my most recent edits (I'll quit touching them unless it's scripts from you guys)
The Stats, Skills and Party menu all work fine for me using that set of scripts.
 
I think I got the battle system debugged.
You can replace the Scene_Battle above the LVreq script with this

Code:
#Coyotecraft Edits: 

#       The check_command alias was combined with the original

#       and the methods like is_a_attacking? seemed unnecessary 

#       so I removed them.

#

#       Now, when pressing Left or Right to change active characters

#       the @active_battler.wait is set to 0 encase an action was canceled.

#

#       Fixed a bug where canceling enemy select didn't bring back the menu. 

#       

#

#--------------------------------------------------------------------------

# Begin SDK Enabled Check

#--------------------------------------------------------------------------

if SDK.state('CTB Battle System') == true

  

class Scene_Battle

  #--------------------------------------------------------------------------

  # * Main Windows

  #--------------------------------------------------------------------------

  def main_windows

    # Make other windows

    @party_command_window = Window_PartyCommand.new

    @help_window = Window_Help.new

    @help_window.back_opacity = 160

    @help_window.visible = false

    @status_window = Window_BattleStatus.new

    @message_window = Window_Message.new

  end

  #--------------------------------------------------------------------------

  # * Troop Setup

  #--------------------------------------------------------------------------

  alias tatb_main_troop main_troop

  def main_troop

    tatb_main_troop

    reset_at

    initialize_at

    setup_bars

    # Set Turns to 1

    $game_temp.battle_turn = 1

  end

  #--------------------------------------------------------------------------

  # * Set Commands

  #--------------------------------------------------------------------------

  alias tatb_commands_init commands_init

  def commands_init

    tatb_commands_init

    @commands << 'Escape'

    @commands.flatten!

  end

  #--------------------------------------------------------------------------

  # * Reset At

  #--------------------------------------------------------------------------

  def reset_at

    ($game_party.actors + $game_troop.enemies).each do |battler|

      battler.at = 0

      battler.at_rate = 0

      battler.at_multiplier = 1.0

      battler.action_able = false

      battler.wait = 0

      battler.battle_turns = 0

      battler.current_action.clear

    end

  end

  #--------------------------------------------------------------------------

  # * Initialize At

  #--------------------------------------------------------------------------

  def initialize_at

    # Initialize Speed Array

    speed_array = []

    # Get All Battlers

    battlers = $game_party.actors + $game_troop.enemies

    # Run Through each battler

    battlers.each do |battler|

      # If Speed Setting

      if Ctb_Setup::Base_Speed == 0

        # Make Action Speed

        battler.make_action_speed

        # Push Speed Onto Speed Array

        speed_array << battler.current_action.speed

      # Else then Agi Setting

      else

        # Push Agililty

        speed_array << battler.agi

      end

    end

    # Get Maximum Speed

    max = speed_array.max

    # Get Speed Constant

    speed = Ctb_Setup::At_Max / Ctb_Setup::Speed.to_f

    # Edit Values in Array to (speed) / (max speed) * speed

    speed_array.collect! {|object| object / max.to_f * speed}

    # Set At Rate for Each Battler

    battlers.each_with_index {|battler, i| battler.at_rate = speed_array[i]}

  end

  #--------------------------------------------------------------------------

  # * Setup Bars

  #--------------------------------------------------------------------------

  def setup_bars

    # Get Flag

    flag = $game_system.battle_start_flag

    # Return if 0: None

    return if flag == 0

    # Get Battlers

    battlers = flag < 0 ? $game_troop.enemies : $game_party.actors

    # Get All Battlers if flag > 100

    if flag > 100

      battlers = $game_troop.enemies + $game_party.actors

      # Return to 0-9

      flag -= 100

    end

    # Absolute Value (Make Positive Integer)

    flag = flag.abs

    # Run Through each battler

    battlers.each do |battler|

      case flag

      when 1 # Little 0-25 percent fill

        # Get Percentage rounded to two deicmal places

        amount = rand(2501) / 100.0

      when 2 # Some 25-50 percent fill

        # Get Percentage rounded to two deicmal places

        amount = rand(2501) / 100.0 + 25

      when 3 # Most 50-75 percent fill

        # Get Percentage rounded to two deicmal places

        amount = rand(2501) / 100.0 + 50

      when 4 # Random 0-99 percent fill

        # Get Percentage rounded to two deicmal places

        amount = rand(9901) / 100.0

      when 5 # Speed ??? percent fill (depends on agi/speed)

        # Initialize temporary block variable speed

        speed = 0

        # Run Through Each Battler

        ($game_party.actors + $game_troop.enemies).each do |sub_battler|

          # If Speed Setting

          if Ctb_Setup::Base_Speed == 0

            # Push Speed Onto Speed Array

            speed += sub_battler.current_action.speed

          # Else then Agi Setting

          else

            # Push Agililty

            speed += sub_battler.agi

          end

        end

        # If Speed Setting

        if Ctb_Setup::Base_Speed == 0

          # Push Speed Onto Speed Array

          amount = battler.current_action.speed.to_f / speed * 100

        # Else then Agi Setting

        else

          # Push Agililty

          amount = battler.agi.to_f / speed * 100

        end

      when 6 # Exactly 25%

        # 25%

        amount = 25.0

      when 7 # Exactly 50%

        # 50%

        amount = 50.0

      when 8 # Exactly 75%

        # 75%

        amount = 75.0

      when 9 # Exactly 99%

        # 99%

        amount = 99.0

      end

      # Convert to amount

      gain_at = amount / 100 * Ctb_Setup::At_Max

      # Add To At

      battler.at += gain_at

    end

  end  

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    bars_fill

    update_event

    update_system

    update_objects

    update_transition

    # If message window is showing

    return if $game_temp.message_window_showing

    # If effect is showing

    return if @spriteset.effect?

    update_scene_exit

    update_abort

    return if update_waiting

    update_phase

  end

  #--------------------------------------------------------------------------

  # * Waiting Update

  #--------------------------------------------------------------------------

  def update_waiting

    # If waiting

    if @wait_count > 0

      # Decrease wait count

      @wait_count -= 1

      return true

    end

    # If battler forcing an action doesn't exist,

    # and battle event is running

    if $game_temp.forcing_battler == nil and

       $game_system.battle_interpreter.running?

      return true

    end

  end

  #--------------------------------------------------------------------------

  # * Bars Fill

  #--------------------------------------------------------------------------

  def bars_fill

    # Skip if action performed or victory

    return if @phase == 5 or @phase == 4

    # Get All Battlers

    battlers = $game_party.actors + $game_troop.enemies

    # Run Through Each Battler

    battlers.each do |battler|

      # Skip if not movable

      next if not battler.movable?

      # If not Battler Action Made

      if not battler.inputable? and not battler.action_made?

        # Fill At Bar (see <game_battler>.at_fill)

        battler.at_fill

      # If Action Made

      elsif battler.action_made? and battler.wait > 0

        # Decrease Battler Wait

        battler.wait -= 1

      end

      # If At Filled but not action able

      if battler.at_filled? and not battler.action_able

        # Set Action Able Flag

        battler.action_able = true

        # Play Filled At Se if Actor

        if battler.is_a?(Game_Actor)

          $game_system.se_play(Ctb_Setup::Full_At_Se)

        end

      # If At Bar not filled

      elsif not battler.at_filled?

        # Set Action Able Flag

        battler.action_able = false

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Start Party Command Phase

  #--------------------------------------------------------------------------

  alias tatb_start_phase2 start_phase2

  def start_phase2

    tatb_start_phase2

    # Disable party command window

    @party_command_window.active = false

    @party_command_window.visible = false

    # Start Phase 3

    start_phase3

  end

  #--------------------------------------------------------------------------

  # * Start Party Command Phase

  #--------------------------------------------------------------------------

  alias tatb_start_phase5 start_phase5

  def start_phase5

    # The Usual

    tatb_start_phase5

    # Turn off All Visible Objects Except Status, Message, and Spriteset

    self.instance_variables.each do |variable|

      # Get Object

      object = eval(variable)

      # Skip if Status Message or Spriteset or no response to active and visible

      flag = object.is_a?(Window_BattleStatus)

      flag2 = object.is_a?(Window_Message)

      flag3 = object.is_a?(Spriteset_Battle) || object.is_a?(Spriteset_Map)

      next if flag || flag2 || flag3

      # Make inactive and invisble

      object.active = false if object.respond_to?(:active)

      object.visible = false if object.respond_to?(:visible)

    end

    # Set Blink Status to False

    $game_party.actors.each {|actor| actor.blink = false}

  end

  #--------------------------------------------------------------------------

  # * Start Actor Command Phase

  #--------------------------------------------------------------------------

  def start_phase3

    # Shift to phase 3

    @phase = 3

    # Set actor as unselectable or selectable

    @actor_index = -1

    @active_battler = nil 

    # Active Battler Blink On

    @active_battler.blink = true if @active_battler != nil

  end

  #--------------------------------------------------------------------------

  # * Go to Command Input for Next Actor

  #--------------------------------------------------------------------------

  def phase3_next_actor

    # Actor blink effect OFF

    $game_party.actors.each {|actor| actor.blink = false}

    # Actor has made action if wait is set and If Battler Exists?

    if @active_battler != nil and @active_battler.wait > 0

      @active_battler.current_action.action_made = true

    end

    # Call Block The Number of Times There are Actors

    $game_party.actors.size.times do

      # Advance actor index

      @actor_index = (@actor_index + 1) % $game_party.actors.size

      # Get Active Battler

      @active_battler = $game_party.actors[@actor_index]

      # Set Blink To True

      @active_battler.blink = @active_battler.inputable?

      # Break if can accept input

      if @active_battler.inputable?

        # Set index to 0

        @actor_command_window.index = 0

        # Break

        break

      end

      # Actor blink effect OFF

      @active_battler.blink = false if @active_battler != nil

      # Set Active Battler to Nil

      @active_battler = nil

    end

    # Set To Unselectable if no active battler

    @actor_index = -1 if @active_battler == nil

    # Set up actor command window

    phase3_setup_command_window

  end

  #--------------------------------------------------------------------------

  # * Go to Command Input of Previous Actor

  #--------------------------------------------------------------------------

  def phase3_prior_actor

    # Actor blink effect OFF

    $game_party.actors.each {|actor| actor.blink = false}

    # Call Block The Number of Times There are Actors

    $game_party.actors.size.times do

      # Get Previous Index

      @actor_index = (@actor_index - 1) % $game_party.actors.size

      # Get Active Battler

      @active_battler = $game_party.actors[@actor_index]

      # Set Blink to True

      @active_battler.blink = @active_battler.inputable?

      # Break if can accept input

      if @active_battler.inputable?

        # Set index to 0

        @actor_command_window.index = 0

        # Break

        break

      end

      # Actor blink effect OFF

      @active_battler.blink = false if @active_battler != nil

      # Set Active Battler to Nil

      @active_battler = nil

    end

    # Set To Unselectable if no active battler

    @actor_index = -1 if @active_battler == nil

    # Set up actor command window

    phase3_setup_command_window

  end

  #--------------------------------------------------------------------------

  # * Actor Command Window Setup

  #--------------------------------------------------------------------------

  def phase3_setup_command_window

    # Disable party command window

    @party_command_window.active = false

    @party_command_window.visible = false

    # Enable actor command window

    @actor_command_window.active = true

    @actor_command_window.visible = true

    # Set actor command window position

    @actor_command_window.x = @actor_index * 160

    # If Active Battler is nil

    if @active_battler == nil or not @active_battler.inputable?

      # Disable actor command window

      @actor_command_window.active = false

      @actor_command_window.visible = false

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (actor command phase)

  #--------------------------------------------------------------------------

  alias tatb_update_phase3 update_phase3

  def update_phase3

    tatb_update_phase3 if @active_battler != nil

    # Update Enemy Actions

    update_phase3_enemy_actions

    # Skip if any windows active

    return if not priority

    # If There is an available battler

    if available_battler?

      # Start Phase4 

      start_phase4

      return

    end

    # Attempt to Get Next Actor

    phase3_next_actor if @active_battler == nil or !@active_battler.inputable?

  end

  #--------------------------------------------------------------------------

  # * Frame Update (actor command phase : basic command)

  #--------------------------------------------------------------------------

  alias tatb_update_phase3_basic_command update_phase3_basic_command

  def update_phase3_basic_command

    # The Usual

    tatb_update_phase3_basic_command

    if Input.trigger?(Input::RIGHT)

      # PLay Cursor Se

      $game_system.se_play($data_system.cursor_se)

      # Clear wait incase target was cancled  

      @active_battler.wait = 0

      # Attempt to Get Next Actor (Cycle Forward)

      phase3_next_actor

      return

    elsif Input.trigger?(Input::LEFT)

      # PLay Cursor Se

      $game_system.se_play($data_system.cursor_se)

      # Clear wait incase target was cancled  

      @active_battler.wait = 0

      # Attempt to Get Previous Actor (Cycle Backward)

      phase3_prior_actor

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Command : Escape

  #--------------------------------------------------------------------------

  def update_phase3_command_escape

    # Play decision SE

    $game_system.se_play($data_system.decision_se)

    # Set action

    @active_battler.current_action.kind = 0

    @active_battler.current_action.basic = 2

    # Go to command input for next actor

    phase3_next_actor

  end

  #--------------------------------------------------------------------------

  # * Check Commands

  #--------------------------------------------------------------------------

  alias tatb_check_commands check_commands

  def check_commands

    # Return if no active battler

    return if @active_battler == nil

    # Loads Current Command

    command = @commands[@actor_command_window.index]

    # Branches Possible Commands

    if command == $data_system.words.attack

      # Get Wait Count For Weapon

      weapon_wait = Action_Timer::Timer_Attack_Weapon[@active_battler.weapon_id]

      # Get Wait Count For Actor

      actor_wait = Action_Timer::Timer_Attack_Actor[@active_battler.id]

      # Set Waiting Variable

      @active_battler.wait = weapon_wait.nil? ? actor_wait : weapon_wait

      update_phase3_command_attack

    elsif command == $data_system.words.skill

      # Get Skill Id

      skill_id = @active_battler.current_action.skill_id

      # Set Waiting Variable

      @active_battler.wait = Action_Timer::Timer_Skill[skill_id]

      update_phase3_command_skill

    elsif command == $data_system.words.guard

      # Set Wait Variable to Defend waitng

      @active_battler.wait = Action_Timer::Timer_Defend

      update_phase3_command_guard

    elsif command == $data_system.words.item

      # Get Item Id

      item_id = @active_battler.current_action.item_id

      # Set Wait Variable

      @active_battler.wait = Action_Timer::Timer_Item[item_id]

      update_phase3_command_item

    elsif command == 'Escape'

      # Set Wait Variable

      @active_battler.wait = Action_Timer::Timer_Escape

      update_phase3_command_escape

    # If Waiting

    elsif @active_battler.current_action.is_a_wait?

      # Set Wait Variable

      @active_battler.wait = Action_Timer::Timer_Wait

    # If ????

    else

      # Set Wait Variable

      @active_battler.wait = Action_Timer::Timer_Default

    end

  end

  #--------------------------------------------------------------------------

  # * End Enemy Selection

  #--------------------------------------------------------------------------

  alias tatb_end_enemy_select end_enemy_select

  def end_enemy_select

    tatb_end_enemy_select

    # If command is [fight]

    if @actor_command_window.index == 0

      # Enable actor command window

      @actor_command_window.active = true

      @actor_command_window.visible = true

      # Hide help window

      @help_window.visible = false

    end

  end

  #--------------------------------------------------------------------------

  # * Update Phase 3 Enemy Actions

  #--------------------------------------------------------------------------

  def update_phase3_enemy_actions

    # Run Through All Enemies

    $game_troop.enemies.each do |enemy|

      # Next if not inputable

      next if not enemy.inputable?

      # Make Enemy Action

      enemy.make_action

      # Set Action Made Flag

      enemy.current_action.action_made = true

      # If Attacking

      if enemy.current_action.is_a_attack?

        # Set Waiting Variable

        enemy.wait = Action_Timer::Timer_Attack_Enemy[enemy.id]

      # If Using A Skill

      elsif enemy.current_action.is_a_skill?

        # Set Waiting Variable

        enemy.wait = Action_Timer::Timer_Skill[enemy.current_action.skill_id]

      # If Defending

      elsif enemy.current_action.is_a_defend?

        # Set Wait Variable to Defend waitng

        enemy.wait = Action_Timer::Timer_Defend

      # If Using an Item

      elsif enemy.current_action.is_a_item?

        # Set Wait Variable

        enemy.wait = Action_Timer::Timer_Item[enemy.current_action.item_id]

      # If Attempting to Escape

      elsif enemy.current_action.is_a_escape?

        # Set Wait Variable

        enemy.wait = Action_Timer::Timer_Escape

      # If Waiting

      elsif enemy.current_action.is_a_wait?

        # Set Wait Variable

        enemy.wait = Action_Timer::Timer_Wait

      # If ????

      else

        # Set Wait Variable

        enemy.wait = Action_Timer::Timer_Default

      end

    end

  end

  #--------------------------------------------------------------------------

  # * Avialable Battler?

  #--------------------------------------------------------------------------

  def available_battler?

    # Get All Battlers

    battlers = $game_party.actors + $game_troop.enemies

    # Delete If No Action Made or Still Waiting

    battlers.delete_if {|battler| !(battler.wait <= 0 && battler.action_made?)}

    # If At least one battler exists then return true

    return !battlers.empty?

  end

  #--------------------------------------------------------------------------

  # * Start Main Phase

  #--------------------------------------------------------------------------

  def start_phase4

    # Shift to phase 4

    @phase = 4

    # Initialize turns

    turns = 0

    # Get all Battlers

    battlers = $game_troop.enemies + $game_party.actors

    # Delete if non existant

    battlers.delete_if {|battler| not battler.exist?}

    # Get Total Number of Turns

    battlers.each {|battler| turns += battler.battle_turns}

    # Divide by total number of battlers

    turns /= battlers.size

    # Set Turn Count To Maximum (Prevent Turn events from repeating)

    $game_temp.battle_turn = [$game_temp.battle_turn, turns].max

    # Search all battle event pages

    for index in 0...$data_troops[@troop_id].pages.size

      # Get event page

      page = $data_troops[@troop_id].pages[index]

      # If this page span is [turn]

      if page.span == 1

        # Clear action completed flags

        $game_temp.battle_event_flags[index] = false

      end

    end

    # Set Actor as unselectable

    @actor_index = -1

    @active_battler = nil

    # Set main phase flag

    $game_temp.battle_main_phase = true

    # Make action orders

    make_action_orders

    # Shift to step 1

    @phase4_step = 1

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase step 1 : action preparation)

  #--------------------------------------------------------------------------

  def update_phase4_step1

    # Hide help window

    @help_window.visible = false

    # Determine win/loss

    if judge

      # If won, or if lost : end method

      return

    end

    # If an action forcing battler doesn't exist

    if $game_temp.forcing_battler == nil

      # Set up battle event

      setup_battle_event

      # If battle event is running

      return if $game_system.battle_interpreter.running?

    end

    # If an action forcing battler exists

    if $game_temp.forcing_battler != nil

      # Add to head, or move

      @action_battlers.delete($game_temp.forcing_battler)

      @action_battlers.unshift($game_temp.forcing_battler)

    end

    # If no actionless battlers exist (all have performed an action)

    if @action_battlers.size == 0

      # Start Phase 3

      start_phase3

      return

    end

    # Initialize animation ID and common event ID

    @animation1_id = 0

    @animation2_id = 0

    @common_event_id = 0

    # Shift from head of actionless battlers

    @active_battler = @action_battlers.shift

    # Increase Turns

    @active_battler.battle_turns += 1

    # If already removed from battle

    return if @active_battler.index == nil

    # Slip damage

    if @active_battler.hp > 0 and @active_battler.slip_damage?

      @active_battler.slip_damage_effect

      @active_battler.damage_pop = true

    end

    # Natural removal of states

    @active_battler.remove_states_auto

    # Refresh status window

    @status_window.refresh

    # Shift to step 2

    @phase4_step = 2

  end

  #--------------------------------------------------------------------------

  # * Make Action Orders

  #--------------------------------------------------------------------------

  alias tatb_make_action_orders make_action_orders

  def make_action_orders

    # The Usual

    tatb_make_action_orders

    # Delete If No Action Made or Still Waiting

    @action_battlers.delete_if {|battler| !(battler.wait <= 0 && battler.action_made?)}

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase)

  #--------------------------------------------------------------------------

  alias tatb_update_phase4 update_phase4

  def update_phase4

    # Make Action Orders

    make_action_orders

    # Make a Copy of Last Phase

    last_phase = @phase4_step

    # Run Actions as usual

    tatb_update_phase4

    # If current phase is less than last phase and current_phase is 1

    if last_phase != nil and @phase4_step < last_phase and @phase4_step == 1

      # Clear Action

      @active_battler.current_action.clear

      # Reinitialize At Amounts (Agility change and Speed Changes)

      initialize_at

    end

  end

  #--------------------------------------------------------------------------

  # * Frame Update (main phase step 2 : start action)

  #--------------------------------------------------------------------------

  alias tatb_update_phase4_step2 update_phase4_step2

  def update_phase4_step2

    # The Usual

    tatb_update_phase4_step2

    # If Attacking

    if @active_battler.current_action.is_a_attack?

      # If An Actor

      if @active_battler.is_a?(Game_Actor)

        # Get Attack Cost For Weapon

        weapon_at = Action_Cost::Action_Attack_Weapon[@active_battler.weapon_id]

        # Get Attack Cost For Actor

        actor_at = Action_Cost::Action_Attack_Actor[@active_battler.id]

        # Get Lost At Percentage

        lost_at = weapon_at.nil? ? actor_at : weapon_at

        # Convert to amount

        lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

        # Decrease At

        @active_battler.at -= lost_at

      # If An Enemy

      elsif @active_battler.is_a?(Game_Enemy)

        # Get lost At Percentage

        lost_at = Action_Cost::Action_Attack_Enemy[@active_battler.id]

        # Convert to amount

        lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

        # Decrease At

        @active_battler.at -= lost_at

      end

      return

    end

    # If Defending

    if @active_battler.current_action.is_a_defend?

      # Get lost At Percentage

      lost_at = Action_Cost::Action_Defend

      # Convert to amount

      lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

      # Decrease At

      @active_battler.at -= lost_at

      return

    end

    # If Attempt to Escape

    if @active_battler.current_action.is_a_escape?

      # Get lost At Percentage

      lost_at = Action_Cost::Action_Escape

      # Convert to amount

      lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

      # Decrease At

      @active_battler.at -= lost_at

      return

    end

    # If Skill

    if @active_battler.current_action.is_a_skill?

      # Get Skill Id

      skill_id = @active_battler.current_action.skill_id

      # Get lost At Percentage

      lost_at = Action_Cost::Action_Skill[skill_id]

      # Convert to amount

      lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

      # Decrease At

      @active_battler.at -= lost_at

      return

    end

    # If Item

    if @active_battler.current_action.is_a_item?

      # Get Item Id

      item_id = @active_battler.current_action.item_id

      # Get lost At Percentage

      lost_at = Action_Cost::Action_Item[item_id]

      # Convert to amount

      lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

      # Decrease At

      @active_battler.at -= lost_at

      return

    end

    # If Waiting

    if @active_battler.current_action.is_a_wait?

      # Get lost At Percentage

      lost_at = Action_Cost::Action_Wait

      # Convert to amount

      lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

      # Decrease At

      @active_battler.at -= lost_at

      return

    end

    # Get lost At Percentage

    lost_at = Action_Cost::Action_Default

    # Convert to amount

    lost_at = lost_at / 100.0 * Ctb_Setup::At_Max

    # Decrease At

    @active_battler.at -= lost_at

  end

  #--------------------------------------------------------------------------

  # * Make Basic Action Results

  #--------------------------------------------------------------------------

  alias tatb_make_basic_action_result make_basic_action_result

  def make_basic_action_result

    # The Usual

    tatb_make_basic_action_result

    # If escape

    if @active_battler.is_a?(Game_Actor) and

       @active_battler.current_action.basic == 2

      make_basic_action_result_escape

      return

    end

  end

  #--------------------------------------------------------------------------

  # * Make Basic Action Results - Escape

  #--------------------------------------------------------------------------

  def make_basic_action_result_escape

    # Calculate enemy agility average

    enemies_agi = 0

    enemies_number = 0

    $game_troop.enemies.each do |enemy|

      next if not enemy.exist?

      enemies_agi += enemy.agi

      enemies_number += 1

    end

    enemies_agi /= enemies_number.to_f if enemies_number > 0

    # Calculate actor agility average

    actors_agi = 0

    actors_number = 0

    $game_party.actors.each do |actor|

      next if not actor.exist?

      actors_agi += actor.agi

      actors_number += 1

    end

    actors_agi /= actors_number.to_f if actors_number > 0

    chance = 50 * actors_agi / enemies_agi if @active_battler.is_a?(Game_Actor)

    chance = 50 * enemies_agi / actors_agi if @active_battler.is_a?(Game_Enemy)

    # Determine if escape is successful

    success = rand(100) < 50 * chance

    # If Actor

    if @active_battler.is_a?(Game_Actor)

      # If escape is successful and possible to escape

      if success and $game_temp.battle_can_escape

        # Play escape SE

        $game_system.se_play($data_system.escape_se)

        # Return to BGM before battle started

        $game_system.bgm_play($game_temp.map_bgm)

        # Battle ends

        battle_end(1)

        # If escape is failure

      else

        # Display Cannot Escape

        @help_window.set_text('Cannot Escape', 1)

      end

    # If Enemy

    else

      # If Escape is successful

      if success

        # Display "Escape" in help window

        @help_window.set_text("Escape", 1)

        # Escape

        @active_battler.escape

      else

        # Escape Failed

        @phase4_step = 1

      end

    end

  end

end

#--------------------------------------------------------------------------

# End SDK Enabled Check

#--------------------------------------------------------------------------

end

The HP and SP bars don't appear in battle. And Status effect icons are too far below everything to be seen.
Idk if that was what ZenVirZan was working on.
 
coyotecraft":3tfzc34i said:
I think I got the battle system debugged.
You can replace the Scene_Battle above the LVreq script with this
The HP and SP bars don't appear in battle. And Status effect icons are too far below everything to be seen.
Idk if that was what ZenVirZan was working on.
Not sure what you mean, the HP and SP bars are fine with my copy. I'm not sure what Status effects you're talking about, probably because they aren't on the screen idk
6b036ba1fe.jpg

8385115794.jpg
 
coyotecraft":2khbxz36 said:
My bad. I put the scripts into a Moonpearl Demo Project that have the hp really low, I couldn't see it.
I must not have my picture folder set up right because the graphic font isn't showing up
I'd suggest grabbing the project from here. It may be a bit outdated but it does have all the resources.
 
# Draw sp bar
bitmap = RPG::Cache.acms_menusprite("SP")
rect = Rect.new(x + BAR_PADDING, y, (width - 2 * BAR_PADDING) * actor.sp / actor.maxsp, bitmap.height)
self.contents.stretch_blt(rect, bitmap, Rect.new(0, 0,
bitmap.width * actor.sp / actor.maxsp, bitmap.height), opacity)
bitmap = RPG::Cache.acms_menusprite("Gauge")
rect = []

Is always the div by 0 error :/
idgi if it works on your end, whats stopping mind from working?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top