Changing gerkrt/gerrtunk's battle log window script

Started by Wingard, June 08, 2013, 03:14:35 pm

Previous topic - Next topic

Wingard

June 08, 2013, 03:14:35 pm Last Edit: June 14, 2013, 11:05:33 am by Wingard
Hi! I found this http://forum.chaos-project.com/index.php?topic=8361.0 script and i liked the idea. In a way. I mean - the present feature is moderately useful imo (it writes about things that are happening at the moment. Like we couldnt see them...), but it can be easily changed to display things that our characters are GOING TO do in the next turn. May be helpful if we have many party members or when we were wondering for a long time what should they do. :)  At the moment i have the script that displays the actions our party member will peform in the next turn and the log window dissapears at the start of the fourth phase of the battle (the battle-itself phase). That log is buggy since it needs only pressing esc and ordering the order again to make the log display the info that one actor is going to do two things (while only the most recent action ordered will be done) but im happy with that anyway  :D. (Since changing that would probably need alot of difficult work)
But there are few things i dont know how to do.  :???:
Here is the screenshot from the original script, unchanged by me: http://img541.imageshack.us/img541/4962/logxw.png


1. The most recent log lines are added to the top and the older are pushed down. Is there a way to reverse that order? So the newer entries will be added to the bottom instead of top of the list?
2. Would it be possible to clear the log with a command? Id add such command somewhere in the Scene_battle at the end of the turn or at the beginning...
3. This one will be tricky i guess, but i'll ask anyway - would it be hard to make the log display the name of the target of our's actor action? I managed to use (@enemy_arrow.index+1.to_s) to display it as a number, but its not that helpful as it would be with a name of the monster before the number (both name and number will be most useful since there can be a battle with more than one enemy of the same kind). This way this would look like "Aluxes is going to attack the Ghost [2]" - where the ghost is the second in a row enemy added to the troop (of the id 1, since the count is from 0)(@enemy_arrow.index).
4. The last one is related to the third one. Is there a way to display enemy's number in a row near its battler in the battle? like on the bottom left of the battler. This would make identyfying enemies much easier than counting them from the left to the right just to know which one of them is the "Ghost [7]". Killing the enemy would make the number dissapear as well, along with its battler.


I know that this script ideas are not fantastic since the script itself is not fantastic but i like the concept of the battle log window and gerkrt/gerrtunk's script was the closest thing to the log window that i could find. The original script would be more useful with displaying the values of damage that the battlers did to each other (or healed) and stuff like this but that would mean making completely new script and i dont think someone would be up to such work since it werent done yet for such a long time.  :( This is why im happy with what i have now, i just wanted to be more happy about it by adding more useful features to this script.  :)

So, could someone help me with any of these 4 issues? Pretty please! :hi:

KK20

1. If you know the height of the window, it shouldn't be hard to implement. Basically look at the draw method:
self.contents.draw_text(0, i * 32, Wep::BattleWindow_Width-32, 32, @small_list[i], 1)

And change the y-value into something like 200-(i*32) (of course, change the 200, I'm just throwing that out there).

2.
def clear
  self.contents.clear
end


3. I'll get back to you on that one.

4. Should be an easy blt or draw_text to Sprite_Battler#update. Granted, you would need to know the number. Thus, refer to above.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

1. Works a bit different from what i was expecting, but works! Thank you!  :D

2. Uhm, i didnt know where to put it so i copypasted it into the Window_BattleLog and at the end of Scene_Battle 1. But i dont know the command to activate it. :/ I tried $scene.log_clear under the   def start_phase2   in the Scene_Battle 2 but it says that the method is undefined. :(

KK20

Put the method inside class Window_BattleLog. Because you most likely want to call it in Scene_Battle, you will add the line
@log_window.clear

somewhere in the class Scene_Battle.

Just for future reference, anything that goes def followed by a name or words is the name of the method, and thus what you should be typing in to use the method.

Why @log_window? That's what gerrtunk decided to call it in Scene_Battle:

  def main
  ...
    @log_window = Window_BattleLog.new(@troop_id)


Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

QuoteJust for future reference, anything that goes def followed by a name or words is the name of the method, and thus what you should be typing in to use the method.


Aah, so if method would be called "clearabc" instead of "clear" then the method would be "@log_window.clearabc"! Now i understand it. Thank you. :)

About the method itself - it works! Almost... I mean it does, but only if my turn counter is not active. Well, let me just show this to you:
  def start_phase2
    # Shift to phase 2
    @phase = 2
    # Set actor to non-selecting
    @actor_index = -1
    @active_battler = nil
    # Enable party command window
    @party_command_window.active = true
    @party_command_window.visible = true
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # Clear main phase flag
    $game_temp.battle_main_phase = false
    @log_window.visible = false
    @log_window.clear
    $scene.log_add_linesy("------------------------------ " + Wep::VocTura + $game_temp.battle_turn.to_s + " ------------------------------")
      # Clear all party member actions
    $game_party.clear_actions
    # If impossible to input command
    unless $game_party.inputable?
      # Start main phase
      start_phase4
     end
  end


I modified add_line a bit (so i can display things with less than 3 arguments) (1 in this case), and now the log window shows me which turn it is. But if it does, the clear method doesnt work! :( But it does again if i make the "$scene.log_add_linesy("----- " + Wep::VocTura + $game_temp.battle_turn.to_s + " --")" be a comment by adding # at the beggining of the line. Is there no way these two things can work together? The clearing of log and then adding the new line right after clearing?

Even if its not possible, thank you for your help. :)

KK20

I'd need to know what edits you made to the scripts (both the Battle Log and whatever $scene.log_add_linesy is). Implementing that feature should be more than possible.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

Window_BattleLog itself looks like this:

#==============================================================================
# ** Window_BattleLog
#------------------------------------------------------------------------------

#==============================================================================
# Battle log window
# By gerkrt/gerrtunk
# Version: 1
# License: MIT, credits
# Date: 24/01/2011
# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
# script check here: http://usuarios.multimania.es/kisap/english_list.html
#==============================================================================

=begin

------INTRODUCTION------

This window shows a new window and in battle that displays a list of the last
actions executed.
You can configure witdh, lines heigh, x and y and all the vocabulary used.

-----INSTRUCTIONS-------

The vocabulary is pretty self explanatory. Thet are the variables called Voc and
they dot whay you see. Note that a . is added always at the end of a phrase.

Lines height is the max lines of the log window.

Battle window X and Y control these positions. You can changue they at your will
for aesthetichs or improve interface.
 
Finall You can modifiy the Battle witdht window if you think that it takes too
space or you need more.

=end

module Wep
 
  Lines_height = 10

  BattleWindow_Width = 350
  Wep::BattleWindow_X = 0
  Wep::BattleWindow_Y = 0

  VocStart = 'Walka rozpoczęta!'
  VocMiss = ' chybia'
  VocAtk = ' atakuje'
  VocDies = ' umiera'
  VocWin = 'Zwycięstwo!'
  VocLose = 'Porażka!'
  VocEscape = 'Drużyna ucieka!'
  VocEscapeFails = 'Nie udało się uciec'
  VocMag = ' rzuca '
  VocItem = ' używa '
  VocDef = ' broni się'
  VocNothing = ' nic nie robi'
  VocItem = ' użyje przedmiotu '
  VocItemZS = ' użyje na sojuszniku przedmiotu '
  VocItemZW = ' użyje na wrogu przedmiotu '
  VocSkill = ' rzuci zaklęcie '
  VocSkillZS = ' rzuci na sojusznika zaklęcie '
  VocSkillZW = ' rzuci na wroga zaklęcie '
  VocRez = ' coś chciał ale się rozmyślił'
  VocCeluje = ' zaatakuje '
  VocNakogo = ' na '
  VocNic = ' '
  VocObrona = ' będzie się bronić'
  VocNowaTura = '------------------------------ Nowa tura ------------------------------'
  VocTura = 'TURA  '
 
end


class Window_BattleLog < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     exp       : EXP
  #     gold      : amount of gold
  #     treasures : treasures
  #--------------------------------------------------------------------------
  def initialize(troop_id)
    @small_list = []
    @troop_id = troop_id
    Wep::Lines_height.times {@small_list.push('')}
    # until this, no contents
  super(Wep::BattleWindow_X, Wep::BattleWindow_Y, Wep::BattleWindow_Width, $game_party.actors.size * 20 + 40)
    self.z = 99
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.clear
    self.back_opacity = 160
    refresh
  end
 
  def end_log
    if Wep::Battle_Ends[@troop_id] != nil
      @list.push Wep::Battle_Ends[@troop_id]
    else
      @list.push Wep::Default_End
    end

    @list.push Wep:Battle_Ends[troop_id]
  end
 
  def refresh
    self.contents = Bitmap.new(width - 32, height - 32)
    for i in 0...@small_list.size
      self.contents.font.size = 15
      self.contents.draw_text(0, (($game_party.actors.size * 20 - 20) - (i * 20)), Wep::BattleWindow_Width-32, 32, @small_list[i], 1)
      self.contents.font.size = 22
    end

  end
 
  def add_line(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
  end
 
  def add_linem(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
  end
 
  def add_linema(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
  end
 
  def add_linesy(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
  end
   
  def add_special_line(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
    refresh
  end
 
  def clear
      self.contents.clear
  end
 
end


The rest is scattered throughout the scripts it was modyfing (Game_Battler and Scene_Battle) in theirs respective places.


I added this at the end of Scene battle 1:

  # Chequea turno, linea, posa . final,etc
  def log_add_line(line, origin, extra, jeszcze)
    complete = origin.name + line + extra + jeszcze
    @log_window.add_line(complete)
    @log_window.refresh
  end
 
  # Chequea turno, linea, posa . final,etc
  def log_add_linem(line, origin, extra)
    complete = origin.name + line + extra
    @log_window.add_linem(complete)
    @log_window.refresh
  end
 
  # Chequea turno, linea, posa . final,etc
  def log_add_linema(line, origin)
    complete = origin.name + line
    @log_window.add_linema(complete)
    @log_window.refresh
  end

  # Chequea turno, linea, posa . final,etc
  def log_add_linesy(line)
    @log_window.add_linema(line)
    @log_window.refresh
  end



Its right after this thing:
    # Branch according to phase
    case @phase
    when 1  # pre-battle phase
      update_phase1
    when 2  # party command phase
      update_phase2
    when 3  # actor command phase
      update_phase3
    when 4  # main phase
      update_phase4
    when 5  # after battle phase
      update_phase5
    end
  end


As you can see i copied "def log_add_line" and added some letters so i can use this command with less amount of arguments than 3 to display lines in battle log. Sometimes they require less information, for example line about defending requires only the name of the actor and the quote " is going to defend himself" which means 2 arguments, or the information about what turn it is, it requires only 1 argument).

And of course there are many commands in the Scene_Battle 3 like...
"      $scene.log_add_line(Wep::VocSkill, @active_battler, @skill.name, " on the enemy #" + (@enemy_arrow.index+1).to_s)"

([Actor's name] + " will cast the skill "  + [skill name] + " on the enemy #" + [enemy's id in battle(number in a row)].
or
      $scene.log_add_line(Wep::VocItem, @active_battler, @item.name, " on the ally #" + (@actor_arrow.index+1).to_s)

([Actor's name] + " will use the item "  + [item name] + " on the ally #" + [ally's id in party(number in a row)].

...to make the lines appear in the battle log when the action is ordered to be done in the main phase of the battle turn.


And thats it, let me know if you need more informations.

KK20

Replace the battle log script with this new one.
Spoiler: ShowHide


#==============================================================================
# Battle log window
# By gerkrt/gerrtunk
# Version: 1
# License: MIT, credits
# Date: 24/01/2011
# IMPORTANT NOTE: to acces the more actualitzed or corrected version of this
# script check here: http://usuarios.multimania.es/kisap/english_list.html
#==============================================================================

=begin

------INTRODUCTION------

This window shows a new window and in battle that displays a list of the last
actions executed.
You can configure witdh, lines heigh, x and y and all the vocabulary used.

-----INSTRUCTIONS-------

The vocabulary is pretty self explanatory. Thet are the variables called Voc and
they dot whay you see. Note that a . is added always at the end of a phrase.

Lines height is the max lines of the log window.

Battle window X and Y control these positions. You can changue they at your will
for aesthetichs or improve interface.

Finall You can modifiy the Battle witdht window if you think that it takes too
space or you need more.

=end

module Wep

  Lines_height = 6

  BattleWindow_Width = 220
  Wep::BattleWindow_X = 0
  Wep::BattleWindow_Y = 96

  VocStart = 'Battle starts!'
  VocMiss = ' missed'
  VocAtk = ' attacked'
  VocDies = ' fall'
  VocWin = 'You win!'
  VocLose = 'You lose!'
  VocEscape = 'You escaped!'
  VocEscapeFails = 'You failed to escape'
  VocMag = ' cast '
  VocItem = ' use '
  VocDef = ' defended'
  VocNothing = ' does nothing'

end





class Game_Battler
    #--------------------------------------------------------------------------
  # * Change HP
  #     hp : new HP
  # moded to add log line in battle if dead
  #--------------------------------------------------------------------------
  def hp=(hp)
    @hp = [[hp, maxhp].min, 0].max
    # Add log line if in battle and dead
    if self.dead? and $game_temp.in_battle
      $scene.log_add_line(Wep::VocDies, self)
    end
    # add or exclude incapacitation
    for i in 1...$data_states.size
      if $data_states[i].zero_hp
        if self.dead?
          add_state(i)
        else
          remove_state(i)
        end
      end
    end
  end

end

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Battle Ends
  #     result : results (0:win 1:escape 2:lose)
  #--------------------------------------------------------------------------
  def battle_end(result)
   
    case result
      when 0; @log_window.add_special_line(Wep::VocWin)
      when 1; @log_window.add_special_line(Wep::VocLose)
    end

    # Clear in battle flag
    $game_temp.in_battle = false
    # Clear entire party actions flag
    $game_party.clear_actions
    # Remove battle states
    for actor in $game_party.actors
      actor.remove_states_battle
    end
    # Clear enemies
    $game_troop.enemies.clear
    # Call battle callback
    if $game_temp.battle_proc != nil
      $game_temp.battle_proc.call(result)
      $game_temp.battle_proc = nil
    end
    # Switch to map screen
    $scene = Scene_Map.new
  end
  #--------------------------------------------------------------------------
  # * Make Skill Action Results
  #--------------------------------------------------------------------------
  def make_skill_action_result
    # Get skill
    @skill = $data_skills[@active_battler.current_action.skill_id]
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If unable to use due to SP running out
      unless @active_battler.skill_can_use?(@skill.id)
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Use up SP
    @active_battler.sp -= @skill.sp_cost
    # Refresh status window
    @status_window.refresh
    # Show skill name on help window
    @help_window.set_text(@skill.name, 1)
    # Set animation ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # Set command event ID
    @common_event_id = @skill.common_event_id
    # Set target battlers
    set_target_battlers(@skill.scope)
    # Add log line
    $scene.log_add_line(Wep::VocMag, @active_battler, @skill.name)
    # Apply skill effect
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
  #--------------------------------------------------------------------------
  # * Make Item Action Results
  #--------------------------------------------------------------------------
  def make_item_action_result
    # Get item
    @item = $data_items[@active_battler.current_action.item_id]
    # If unable to use due to items running out
    unless $game_party.item_can_use?(@item.id)
      # Shift to step 1
      @phase4_step = 1
      return
    end
    # If consumable
    if @item.consumable
      # Decrease used item by 1
      $game_party.lose_item(@item.id, 1)
    end
    # Display item name on help window
    @help_window.set_text(@item.name, 1)
    # Set animation ID
    @animation1_id = @item.animation1_id
    @animation2_id = @item.animation2_id
    # Set common event ID
    @common_event_id = @item.common_event_id
    # Decide on target
    index = @active_battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # Set targeted battlers
    set_target_battlers(@item.scope)
    # Add log line
    $scene.log_add_line(Wep::VocItem, @active_battler, @item.name)
    # Apply item effect
    for target in @target_battlers
      target.item_effect(@item)
    end
  end
  #--------------------------------------------------------------------------
  # * Make Basic Action Results
  #--------------------------------------------------------------------------
  def make_basic_action_result
    # If attack
    if @active_battler.current_action.basic == 0
      # Add log line
      $scene.log_add_line(Wep::VocAtk, @active_battler)
      # Set anaimation ID
      @animation1_id = @active_battler.animation1_id
      @animation2_id = @active_battler.animation2_id
      # If action battler is enemy
      if @active_battler.is_a?(Game_Enemy)
        if @active_battler.restriction == 3
          target = $game_troop.random_target_enemy
        elsif @active_battler.restriction == 2
          target = $game_party.random_target_actor
        else
          index = @active_battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        end
      end
      # If action battler is actor
      if @active_battler.is_a?(Game_Actor)
        if @active_battler.restriction == 3
          target = $game_party.random_target_actor
        elsif @active_battler.restriction == 2
          target = $game_troop.random_target_enemy
        else
          index = @active_battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        end
      end
      # Set array of targeted battlers
      @target_battlers = [target]
      # Apply normal attack results
      for target in @target_battlers
        target.attack_effect(@active_battler)
      end
      return
    end
    # If guard
    if @active_battler.current_action.basic == 1
      # Display "Guard" in help window
      # Add log line
      $scene.log_add_line(Wep::VocDef, @active_battler)
      @help_window.set_text($data_system.words.guard, 1)
      return
    end
    # If escape
    if @active_battler.is_a?(Game_Enemy) and
       @active_battler.current_action.basic == 2
      # Add log line
      # @log_window.add_special_line(Wep::VocEscaping)

      # Display "Escape" in help window
      @help_window.set_text("Escape", 1)
      # Escape
      @active_battler.escape
      return
    end
    # If doing nothing
    if @active_battler.current_action.basic == 3
      # Add log line
      $scene.log_add_line(Wep::VocNothing, @active_battler)
      # Clear battler being forced into action
      $game_temp.forcing_battler = nil
      # Shift to step 1
      @phase4_step = 1
      return
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update (party command phase: escape)
  #--------------------------------------------------------------------------
  def update_phase2_escape
    # Calculate enemy agility average
    enemies_agi = 0
    enemies_number = 0
    for enemy in $game_troop.enemies
      if enemy.exist?
        enemies_agi += enemy.agi
        enemies_number += 1
      end
    end
    if enemies_number > 0
      enemies_agi /= enemies_number
    end
    # Calculate actor agility average
    actors_agi = 0
    actors_number = 0
    for actor in $game_party.actors
      if actor.exist?
        actors_agi += actor.agi
        actors_number += 1
      end
    end
    if actors_number > 0
      actors_agi /= actors_number
    end
    # Determine if escape is successful
    success = rand(100) < 50 * actors_agi / enemies_agi
    # If escape is successful
    if success
      # Add log line
      @log_window.add_special_line(Wep::VocEscape)
      # 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
      # Add log line
      @log_window.add_special_line(Wep::VocEscapeFails)
      # Clear all party member actions
      $game_party.clear_actions
      # Start main phase
      start_phase4
    end
  end
end

#==============================================================================
# ** Scene_Battle (part 1)
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Main Processing
  # moded to use
  #--------------------------------------------------------------------------
  def main
    # Initialize each kind of temporary battle data
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # Initialize battle event interpreter
    $game_system.battle_interpreter.setup(nil, 0)
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make actor command window
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 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
   
    @log_window = Window_BattleLog.new(@troop_id)
    @log_window.add_special_line(Wep::VocStart)
   
    # Make sprite set
    @spriteset = Spriteset_Battle.new
    # Initialize wait count
    @wait_count = 0
    # Execute transition
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
      $data_system.battle_transition)
    end
    # Start pre-battle phase
    start_phase1
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    # Dispose of windows
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose

    @log_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # Dispose of sprite set
    @spriteset.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
    # If switching from battle test to any screen other than game over screen
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end

  #--------------------------------------------------------------------------
  # * Frame Update
  # moded to use
  #--------------------------------------------------------------------------
  def update
    # If battle event is running
    if $game_system.battle_interpreter.running?
      # Update interpreter
      $game_system.battle_interpreter.update
      # If a battler which is forcing actions doesn't exist
      if $game_temp.forcing_battler == nil
        # If battle event has finished running
        unless $game_system.battle_interpreter.running?
          # Rerun battle event set up if battle continues
          unless judge
            setup_battle_event
          end
        end
        # If not after battle phase
        if @phase != 5
          # Refresh status window
          @status_window.refresh
        end
      end
    end
    # Update system (timer) and screen
    $game_system.update
    $game_screen.update
    # If timer has reached 0
    if $game_system.timer_working and $game_system.timer == 0
      # Abort battle
      $game_temp.battle_abort = true
    end
    # Update windows
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @log_window.update
    @status_window.update
    @message_window.update
    # Update sprite set
    @spriteset.update
    # If transition is processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
        $game_temp.transition_name)
      end
    end
    # If message window is showing
    if $game_temp.message_window_showing
      return
    end
    # If effect is showing
    if @spriteset.effect?
      return
    end
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Switch to title screen
      $scene = Scene_Title.new
      return
    end
    # If battle is aborted
    if $game_temp.battle_abort
      # Return to BGM used before battle started
      $game_system.bgm_play($game_temp.map_bgm)
      # Battle ends
      battle_end(1)
      return
    end
    # If waiting
    if @wait_count > 0
      # Decrease wait count
      @wait_count -= 1
      return
    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
    end
    # Branch according to phase
    case @phase
    when 1  # pre-battle phase
      update_phase1
    when 2  # party command phase
      update_phase2
    when 3  # actor command phase
      update_phase3
    when 4  # main phase
      update_phase4
    when 5  # after battle phase
      update_phase5
    end
  end


  # Chequea turno, linea, posa . final,etc
  def log_add_line(line, origin=nil, extra='', jeszcze='')
    unless origin.nil?
      complete = origin.name + line + extra + jeszcze
    else
      complete = line
    end
    @log_window.add_line(complete)
    @log_window.refresh
  end

end

#==============================================================================
# ** Window_BattleLog
#------------------------------------------------------------------------------
#  This window displays amount of gold and EXP acquired at the end of a battle.
#==============================================================================

class Window_BattleLog < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     exp       : EXP
  #     gold      : amount of gold
  #     treasures : treasures
  #--------------------------------------------------------------------------
  def initialize(troop_id)
    @small_list = []
    @troop_id = troop_id
    #Wep::Lines_height.times {@list.push('')}
    Wep::Lines_height.times {@small_list.push('')}
    # until this, no contents
    super(Wep::BattleWindow_X, Wep::BattleWindow_Y, Wep::BattleWindow_Width, Wep::Lines_height * 32 + 32)
    self.z = 99
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end

  def end_log
    if Wep::Battle_Ends[@troop_id] != nil
      @list.push Wep::Battle_Ends[@troop_id]
    else
      @list.push Wep::Default_End
    end

    @list.push Wep:Battle_Ends[troop_id]
  end

  def refresh
    self.contents = Bitmap.new(width - 32, height - 32)
    for i in 0...@small_list.size
      self.contents.draw_text(0, 160-(i * 32), Wep::BattleWindow_Width-32, 32, @small_list[i], 1)
    end

  end

  def add_line(line)
    # Add to the start and move
    @small_list.unshift(line)
    # Remove last element
    @small_list.pop
  end

  def add_special_line(line)
    add_line(line)
    refresh
  end
 
  def clear
    self.contents.clear
    Wep::Lines_height.times {@small_list.push('')}
  end

end

I removed the need to have four separate call methods. You can just use the default log_add_line and, depending on how many parameters you put in, it will make the adjustment. There is no need to call $scene.log_add_line unless you are calling log_add_line outside of the Scene_Battle class.

I also found out how to do #3.

class Game_Enemy < Game_Battler
  attr_writer :id_number
  def name
    return $data_enemies[@enemy_id].name if @id_number.nil?
    return $data_enemies[@enemy_id].name + " [#{@id_number}]"
  end
end

class Game_Troop
  alias name_enemies_with_numbers setup
  def setup(troop_id)
    name_enemies_with_numbers(troop_id)
    enemy_types = {}
    @enemies.each{|e|
      enemy_types[e.id] = [] if enemy_types[e.id].nil?
      enemy_types[e.id].push(e)
    }
    enemy_types.each_value{|list|
      next if list.size == 1
      list.each_index{|index|
        list[index].id_number = index+1
      }
    }
  end
end

Obviously, place that below the default scripts.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

June 13, 2013, 07:14:25 am #8 Last Edit: June 13, 2013, 07:19:58 am by Wingard
QuoteI removed the need to have four separate call methods. You can just use the default log_add_line and, depending on how many parameters you put in, it will make the adjustment.


Its a much better thing than i had before! Thank you :D

QuoteThere is no need to call $scene.log_add_line unless you are calling log_add_line outside of the Scene_Battle class.


Useful tip, thank you again. :)

QuoteI also found out how to do #3. Obviously, place that below the default scripts.


Ok, i pasted this above Main.


But now im not sure how to make the script show the line properly. When i tried this:
    # If C button was pressed
   if Input.trigger?(Input::C)
     
     # Add log line ====================================================
   case @actor_command_window.index
     when 0 #atak wręcz   (attack)
      log_add_line(Wep::VocCeluje, @active_battler, "enemy " + $data_enemies[@enemy_arrow.index].name.to_s)
     

...game crashes and says that name is an undefined method for NilClass. :( The code i showed is from Scene_Battle 3, near the line 270. (def update_phase3_enemy_select)

(btw. There was no "case" in the original script, i created it to make the log display different quotes after selecting the enemy for different actions (attack, skill, item).)


@edit
And when i tried this:
       log_add_line(Wep::VocCeluje, @active_battler, "enemy " + @enemy_arrow.index.name.to_s)

... "name" is undefined method again, but this time for "0:Fixnum".

KK20

@enemy_arrow is an instance of class Arrow_Enemy. If you take a look at it, there's already a method there for retrieving the enemy the arrow is currently pointing over:

class Arrow_Enemy < Arrow_Base
  #--------------------------------------------------------------------------
  # * Get Enemy Indicated by Cursor
  #--------------------------------------------------------------------------
  def enemy
    return $game_troop.enemies[@index]
  end

Thus, all you have to do is this:

log_add_line(Wep::VocCeluje, @active_battler, "enemy " + @enemy_arrow.enemy.name)

to_s is redundant because the object already is a string. You really only need to use that for instances of numbers.

damage = actor.atk - enemy.def                          #-> Returns an integer
message = "Actor did " + damage.to_s + " to enemy!"
message = "Actor did " + damage + " to enemy!"          #-> Error: 'damage' is not a string

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

June 14, 2013, 10:51:01 am #10 Last Edit: June 14, 2013, 11:12:24 am by Wingard
Yeey, now it works! :D Maybe now issue #4 wouldnt even be an issue, i didnt know that the number in [] will be reseting for the enemies of different kind! :)

But, uhm, i think issue 5 comes to my mind. Could using this method work for actors? For example when the active actor is ordered to use a skill or item on the other actor (or on self, not other). I think it would require some other command since number in a [] wouldnt be needed, just the name, but i have no idea how to code it. :/



btw. Though i dont really know what "Level++" means under the nick, i clicked it for you, i suppose its something like "that user helped/did something good". I hope im right, i did some leveling up for others too.

Im really grateful for your help, KK20. :)

KK20

What do you mean exactly? If all you want to do is copy the same method you did for enemies but instead for actors, then that's a simple replacement:

@actor_arrow.actor.name


And leveling up a person is kind of like karma or rep. The level of a member is displayed on the left, underneath the name and above the online status. So yes, it is a good indicator of how helpful/awesome/sexy/respected a person is.

Always willing to help ;)

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

June 14, 2013, 05:26:12 pm #12 Last Edit: June 14, 2013, 05:59:13 pm by Wingard
QuoteIf all you want to do is copy the same method you did for enemies but instead for actors, then that's a simple replacement: @actor_arrow.actor.name

And thats indeed it! I feel so silly now  :facepalm:   :^_^':

But how about this: i tried to make log display different quote if actor uses skill of self, not the other target. I tried
     when 1 # skill
      if @active_battler == @actor_arrow.actor.name
     log_add_line(Wep::VocSkill, @active_battler, @skill.name, " on self")
      else
     log_add_line(Wep::VocSkill, @active_battler, @skill.name, " on ally " + @actor_arrow.actor.name)
   end

But it doesnt work, it always displays the one with  " on ally ". Can you please tell where did i make a mistake?

KK20

Your mistake is this:

@active_battler == @actor_arrow.actor.name

You are trying to compare a Game_Actor object with a String. Every time it runs through this, the condition will always be false and skip to the 'else' statement. I believe you want to use @active_battler.name

Note that only works for skills/items when you choose the same actor. Skills that by default only work on the user will not run through this code. For that you will have to edit the update_phase3_skill_select and update_phase3_item_select methods.

Curious, did you already address the issue of canceling the previous actor's action and having the log still display what he/she was originally going to do?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Wingard

June 15, 2013, 06:04:04 am #14 Last Edit: June 15, 2013, 07:57:38 am by Wingard
QuoteYou are trying to compare a Game_Actor object with a String. Every time it runs through this, the condition will always be false and skip to the 'else' statement. I believe you want to use @active_battler.name

Thats right! Thanks! :D

QuoteSkills that by default only work on the user will not run through this code

I know, i already did some "if"s for the @item.scope and @skill.scope things, now log shows different quotes for skill/item targetted on self, dead ally, all enemies, etc. :)

QuoteCurious, did you already address the issue of canceling the previous actor's action and having the log still display what he/she was originally going to do?

No... :( Cancelling the order and making a new one makes log display two lines saying that one actor is going to do two things while only the most recent one is right. And i have no idea how to change that. :(


@edit
Ugh, i just tried a battle with 8 ghosts. I guess issue #4 is still an issue, counting them from left to right to see if i ordered to kill the proper target wasnt confortable. :/ I think the little number could come in handy during the making orders phase.

And i got an idea! Would it be hard to implement thing that would display in log the icon of skilll/item that actor is going to use? For example at the end of the line, or before the skill's/item's name?

KK20

QuoteCancelling the order and making a new one makes log display two lines saying that one actor is going to do two things while only the most recent one is right. And i have no idea how to change that.

You would have to add another method to Window_BattleLog that erases loaded messages. Something like

  def remove_last
    @small_list[@small_list.size-1] = ''
    refresh
  end

And then locate the method in Scene_Battle that processes the "When B is triggered, go back to previous actor and remake action selection" and call that above method.

QuoteUgh, i just tried a battle with 8 ghosts. I guess issue #4 is still an issue, counting them from left to right to see if i ordered to kill the proper target wasnt confortable. :/ I think the little number could come in handy during the making orders phase.

I don't understand...?

QuoteWould it be hard to implement thing that would display in log the icon of skilll/item that actor is going to use? For example at the end of the line, or before the skill's/item's name?

Should be easy enough. Basically can look at any Window class that draws icons like _Item or _Skill to understand how it's done.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!