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.

[Battle System] Blinking battlers

How do I make the enemy battlers blink when the cursor is over them? This is what I did so far in the class Scene_Battle (part 3), but it doesn't work:

Code:
#--------------------------------------------------------------------------
  # * Start Enemy Selection
  #--------------------------------------------------------------------------
  def start_enemy_select
    # Make enemy arrow
    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1)
    # Associate help window
    @enemy_arrow.help_window = @help_window
    # Disable actor command window
    @actor_command_window.active = false
    @actor_command_window.visible = false


 if  @enemy_arrow.help_window = @help_window
   for i in 0... $game_troop.enemies.size

    if @enemy_arrow.index == 0 
      @active_battler = $game_troop.enemies[0]
      @active_battler.blink = true
    else
      @active_battler.blink = false
    end
  end  
  end
end

Basically what I want to happen is for the selected enemy to blink/flash white continuously if the selection cursor is over them. Any help?
 

khmp

Sponsor

This is what I came up. This doesn't override any methods in Scene_Battle so it shouldn't destroy any other script that might affect Scene_Battle. I haven't tested it thoroughly so let me know if you get any odd bugs or crashes. To install this script just restore the code that you edited back to it's default basically just toss that for loop. Then create an empty code section in the script editor above Main and paste this code in that section.

Code:
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle
  alias_method :xava_blinkingenemies_end_enemy_select, :end_enemy_select
  alias_method :xava_blinkingenemies_update_phase3_enemy_select, :update_phase3_enemy_select
  #--------------------------------------------------------------------------
  # * Frame Update (actor command phase : enemy selection)
  #--------------------------------------------------------------------------
  def update_phase3_enemy_select
    # Disable blink for all enemies.
    $game_troop.enemies.each { |enemy| enemy.blink = false; }
    
    xava_blinkingenemies_update_phase3_enemy_select
    
    # Turn on the blink effect for the active enemy.
    $game_troop.enemies[@enemy_arrow.index].blink = true
  end
  #--------------------------------------------------------------------------
  # * End Enemy Selection
  #--------------------------------------------------------------------------
  def end_enemy_select
    # Save the index before the arrow is destroyed.
    last_enemy_selected = @enemy_arrow.index
    
    xava_blinkingenemies_end_enemy_select
    
    # Turn off the blink effect for the enemy that was selected.
    $game_troop.enemies[last_enemy_selected].blink = false
  end
end

Good luck with it Xathia Vastar! :thumb:
 
Ack.. I spoke too soon >.> I got an error when I selected the enemy. It said:
"Script 'Blinking_Enemy' line 20: NoMethodError occurred.
undefined method 'index' for nil class"

it was pointing to this line:
Code:
    # Turn on the blink effect for the active enemy.
    $game_troop.enemies[@enemy_arrow.index].blink = true
 

khmp

Sponsor

My apology. Inside the update_phase3_enemy_select method change this line:
Code:
$game_troop.enemies[@enemy_arrow.index].blink = true
to:
Code:
$game_troop.enemies[@enemy_arrow.index].blink = true unless @enemy_arrow.nil?

Good luck with it Xathia Vastar! :thumb:
 

RPGS

Member

I dont understand !!! This SIDE VIEW BATTLE SYSTEM CODE (Found on RGSS Section) Do not work .... it stands "Shall replace game_Actor#Screen_Y // X ..

And whats that ? Shall theese 3 BLOCKS of codes be SEPARETED or TOGETHER on 1 PAGE    ????        HELP ME !!!!!   

Code:
  def screen_x
    if self.index != nil
      return self.index * 40 + 360
    else
      return 0
    end
  end

  def screen_y
    return self.index * 20 + 220
  end

  def update
    super
    if $game_temp.battle_main_phase
      self.contents_opacity = 255
    end
  end

khmp: code tags around code please. You can delete this line when you see it.
 

khmp

Sponsor

You should have created a new thread, RPGS. Instead of hijacking this one. For future reference. :wink:

I'm not sure what you mean when you say should the code be on one page or what. They should definitely stick together in any case. Never ever replace the original code with code you find here. So go back and restore the default scripts to their original code. You can do that by copying from an unedited project. Once you are done with that open your Script Editor(F11) and right click the word "Main" inside the panel to the left and selecting "Insert". Now copy the text from this Sideview Battle System script file and paste it into this section. And now you have installed the script properly. Let me know if you have any problem after doing this.

If I have misunderstood your problem just let me know but don't simply restate the problem. Clarify, what script you are using, and what you have tried to do so far. If it is Minkoff's I expect that you have at least looked at the PDF Readme that is supplied with it.

Good luck with it RPGS! :thumb:
 

RPGS

Member

dont understand : When testing the game  after inputing this code it appears an error : ;Error "Line 25" ;  And why ?  Its just "End" x3 there and I havent
changed anything ....

def screen_x
    if self.index != nil
      return self.index * 40 + 360
    else
      return 0
    end
  end




def screen_y
    return self.index * 20 + 220
end




def update
    super
    if $game_temp.battle_main_phase
      self.contents_opacity = 255
    end
  end
end                                                               



Ps . Here are the Information of the code that stands where you can find this code.... I cannot  understand this ;

 
>This script is a simple script to implement side-view battles. Modification is required if you want the characters to walk up to the monsters and attack, for instance. The first block of code below should replace Game_Actor#Screen_X. The second block should replace Game_Actor#Screen_Y. The last block should replace Window_BattleStatus#Update. If you want to change the arrangement of the party members on the battle screen, play around with the return values of Game_Actor#Screen_X and Game_Actor#Screen_Y until you find something you like. Please note that the coordinates provided in this script are intended to be used with battler images the size of map sprites. If you keep the full-size battler sprites, this script will make your battles look really stupid. <

What does "Shall replace Game_Actor#Screen_X  // Screen_Y"  means ? Must I edit the scrpt a bit ?  Help me Please !!!!
 

khmp

Sponsor

Please put code inside code tags. So please go back and edit the above post. To do that, while editing your code, first select the text you want in code tags and then press the button that looks like a pound sign(#). Please try to follow the rules of posting code while you're here.  :thumb:

That aside the reason it would error on an end would be the fact that some other code block is not being ended and this causes end's to mismatch. Here is an example of where you would get an error about end:
Code:
  def toaster
    return 'toast'
  end
end
That last "end" is one too many ends for that code and you'll get an error on Line 4 about it. Now in the above post you made. Is that the whole script? Or just part of it? And lastly do I have it right when I say that you replaced the old methods with these?
 

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