Clash between instant use and Turn X in battle.

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
I am using Yanfly's Instant Cast script. Only one character has Instant, and that is only for a range of items. To achieve that, an additional script was required.
Code:
#=============================================================
# Moogle_X given on rpgmakerweb.com forum 29 July 2015
# Enables Yanfly's Instant Cast script to apply to using an item
# as the instant action.
# Restricts to one instant action per turn.
# Restricts to one actor ID at line #60
# Put below Yanfly's Instant Cast script.
#===========================================================
 
class Game_Actor < Game_Battler

  attr_accessor :already_instant
 
  alias moogle_setup_instant setup
  def setup(actor_id)
    moogle_setup_instant(actor_id)
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at Start of Battle
  #--------------------------------------------------------------------------
  def on_battle_start
    super
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at End of Battle
  #--------------------------------------------------------------------------
  def on_battle_end
    super
    @already_instant = false
  end
 
  #--------------------------------------------------------------------------
  # * Processing at End of Turn
  #--------------------------------------------------------------------------
  def on_turn_end
    super
    @already_instant = false
  end
 
end # Game_Actor

#==============================================================================
# ¡ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
 
  #--------------------------------------------------------------------------
  # new method: instant_action?
  #--------------------------------------------------------------------------
  def instant_action?
    return false if BattleManager.actor.nil?
    return false if BattleManager.actor.input.nil?
    action = BattleManager.actor.input.item
    if action.is_a?(RPG::Item)
      return false if BattleManager.actor.id != 3 # <= CHANGE THIS TO ACTOR ID.
    end
    return false if action.nil?
    return false if BattleManager.actor.already_instant == true
    return action.instant
  end

 
  #--------------------------------------------------------------------------
  # new method: perform_instant_action
  #--------------------------------------------------------------------------
  def perform_instant_action
    hide_instant_action_windows
    @subject = BattleManager.actor
    @subject.check_instant_action
    if @subject.current_action.valid?
      execute_action
      @subject.already_instant = true
    end
    
    process_event
    loop do
      @subject.remove_current_action
      break if $game_troop.all_dead?
      break unless @subject.current_action
      @subject.current_action.prepare
      execute_action if @subject.current_action.valid?
    end
    process_action_end
    @subject.make_actions
    @subject.restore_instant_action
    @subject = nil
    show_instant_action_windows
  end

end

I am also using Troop Events (typically for boss fights) where, for example, a variable is keeping track of the boss's HP and when it reaches a certain point or lower, there is a Force Action. This can also happen if the troop event introduces an additional enemy after the battle scene has started.

Independently, both of these elements work smoothly and give no cause for concern. It is when they are used in conjunction that a problem occurs.

For example, the character throws a healing potion on someone. This happens immediately and then the Troop Event, of whatever type, occurs. At that point the player has a problem because this happens:
HUD vanishes.PNG
The individual actor faces and their HP/MP/TP bars vanish.
They can be brought back again by pressing ESC and the HUD appears as normal and you can then select the battle actions in the usual way. You can, if you're confident enough, select the actions successfully without the visual prompts, so it is not that battle commands have stopped working, it is just the HUD.

Can anyone suggest what is happening and a way to resolve it?
Thanks.
 

Another Fen

Veteran
Veteran
Joined
Jan 23, 2013
Messages
564
Reaction score
275
First Language
German
Primarily Uses
Can't look it up right now but as far as I know those windows are hidden when a text message occurs and are shown again when either the next action or the next party command selection (fight/escape) starts. You may have to add instructions to also show them when returning from an instant action:

Code:
class Scene_Battle
 
  alias_method(:show_instant_action_windows_ILC_showStatusWindow,
  :show_instant_action_windows)
  def show_instant_action_windows
    @status_window.show
    @party_command_window.show
    @actor_command_window.show
    show_instant_action_windows_ILC_showStatusWindow 
  end
end
I can't look up the exact code, so the actual window names might be off (=> undefined method 'show' for nil:NilClass). If that is the case, you could search for occurrances of "$game_message." in the Scene_Battle script until you find the method that hides those windows when showing a message (should be called like update_message_openess or something... =) ) and see which windows are hidden.

Edit: Small edit to the script.
 
Last edited:
  • Like
Reactions: Kes

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Another Fen Sorry for the length of time it's taken to reply, but somehow I missed the notification that you had posted in this thread.

I've tested this out, and it seems to have done the trick. You have no idea of the depth of my gratitude for this - I was faced with the prospect of either removing a key feature of one of my characters or reworking the AI for my bosses. Neither prospect thrilled. But now I get to keep them both.

Thank you very much indeed.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,047
Members
137,569
Latest member
Shtelsky
Top