Jump to content
NumbeRED39

Call a common event before battle processing.

Recommended Posts

So I have this neat minimap I made with events and it's all neat and useful...but it stays on during fights. 

Now, with boss fights it's easy. I disable it during the event process of the boss itself...but now it kinda bugs me that regular fights always have that minimap stuck there. 

 

Now, I know basically zilch of ruby, but is there a way for me to run a simple common event that can take care of my minimap? 

Share this post


Link to post
Share on other sites
11 hours ago, NumbeRED39 said:

a simple common event that can take care of my minimap?

You will have to show us how you did the events for the minimap.

unless you are doing something completely different than minimap scripts I would suggest to use a script and then it doesn't run in battle.

Otherwise you could show how you turned it off for events and then we could make a snippet to automatically turn it on and off during battles.

Share this post


Link to post
Share on other sites
1 hour ago, roninator2 said:

You will have to show us how you did the events for the minimap.

unless you are doing something completely different than minimap scripts I would suggest to use a script and then it doesn't run in battle.

Otherwise you could show how you turned it off for events and then we could make a snippet to automatically turn it on and off during battles.

Spoiler

minimap_page1.png.e2115f475bde6cb771d0375d8a2df8c9.png

minimap_page2.png.f7c55a89dbd7adbfb603c649f949bb9b.png

minimap_page3.png.c423fd94c6c1320aa8d992597266e848.png

 

This one is the Minimap event playing on the map.

The second page is where I turn off the minimap with a switch.

 

For Boss fights I had to do this before the actual fight: 

 

turnminimapoff.png.ef954bd8dbb341701d720eb922ef76ac.png

 

Idk why I turned off the cursor twice but okay, lol.

Anyhow this did the trick for those situations.

 

I was gonna use a script for the minimap, but the one I would've really liked to use somehow didn't work and the others weren't quite what I wanted

or looked weird.

Share this post


Link to post
Share on other sites

Okay, let me see if I can whip up something real quick and kinda dirty:
 

Spoiler

=begin
Place above Materials but below Bug Fixes
=end
module BattleManager


  #--------------------------------------------------------------------------
  # * Processing at Encounter Time
  #--------------------------------------------------------------------------
  def self.on_encounter
    @preemptive = (rand < rate_preemptive)
    @surprise = (rand < rate_surprise && !@preemptive)
    $game_temp.reserve_common_event(ID)
  end
end

 

Just replace ID with the number of the common event you're using; this should actually work for boss battles as well.

Share this post


Link to post
Share on other sites

Thanks, but unfortunately, it's seems the common event takes action after the battle, not before it starts.

Meaning the minimap stay on during the fight and only gets turned off after it.

Maybe the battle processing just starts too fast? That's my best guess.

 

Edit: Nvm I played around with the script you gave me and decided to have it do what the common event does instead. So now it works! 

Edited by NumbeRED39

Share this post


Link to post
Share on other sites

Well, I'm glad it worked with a little bit of wrench and oil. (I know I butchered that line but I forget how it goes lolz)

Okay, so...if you wanted to use the common event, I think I know where to inject the common event push code. Rather than on Encounter, since that seems to be run after the battle is started (I derped on that one), it should be run before Scene_Battle is called. (Scene_Interpreter)

 

Spoiler

class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Battle Processing
  #--------------------------------------------------------------------------
  def command_301
    return if $game_party.in_battle
    $game_temp.reserve_common_event(ID)
    if @params[0] == 0                      # Direct designation
      troop_id = @params[1]
    elsif @params[0] == 1                   # Designation with variables
      troop_id = $game_variables[@params[1]]
    else                                    # Map-designated troop
      troop_id = $game_player.make_encounter_troop_id
    end
    if $data_troops[troop_id]
      BattleManager.setup(troop_id, @params[2], @params[3])
      BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n }
      $game_player.make_encounter_count
      SceneManager.call(Scene_Battle)
    end
    Fiber.yield
  end
  #--------------

 

As before, replace ID with the number of the common event to use. This should work with any and all battles.

Share this post


Link to post
Share on other sites

Another option?

module R2_Hud_Switch_Off
  Switch_1 = 2
  Switch_2 = 3
end
module BattleManager
  class << self
    alias :r2_setup_battle :setup
    alias :r2_victory_switch :process_victory
    alias :r2_escape_switch :process_escape
    alias :r2_abort_switch :process_abort
    alias :r2_defeat_switch :process_defeat
  end
  def self.event_hud_on
    $game_switches[R2_Hud_Switch_Off::Switch_1] = true
    $game_switches[R2_Hud_Switch_Off::Switch_2] = true
  end
  def self.setup(troop_id, can_escape = true, can_lose = false)
    $game_switches[R2_Hud_Switch_Off::Switch_1] = false
    $game_switches[R2_Hud_Switch_Off::Switch_2] = false
    r2_setup_battle(troop_id, can_escape = true, can_lose = false)
  end
  def self.process_victory
    r2_victory_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    r2_escape_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Abort Processing
  #--------------------------------------------------------------------------
  def self.process_abort
    r2_abort_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Defeat Processing
  #--------------------------------------------------------------------------
  def self.process_defeat
    r2_defeat_switch
    event_hud_on
  end
end

 

Edited by roninator2

Share this post


Link to post
Share on other sites
11 hours ago, roninator2 said:

Another option?


module R2_Hud_Switch_Off
  Switch_1 = 2
  Switch_2 = 3
end
module BattleManager
  class << self
    alias :r2_setup_battle :setup
    alias :r2_victory_switch :process_victory
    alias :r2_escape_switch :process_escape
    alias :r2_abort_switch :process_abort
    alias :r2_defeat_switch :process_defeat
  end
  def event_hud_on
    $game_switches[R2_Hud_Switch_Off::Switch_1] = true
    $game_switches[R2_Hud_Switch_Off::Switch_2] = true
  end
  def self.setup(troop_id, can_escape = true, can_lose = false)
    $game_switches[R2_Hud_Switch_Off::Switch_1] = false
    $game_switches[R2_Hud_Switch_Off::Switch_2] = false
    r2_setup_battle(troop_id, can_escape = true, can_lose = false)
  end
  def self.process_victory
    r2_victory_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Escape Processing
  #--------------------------------------------------------------------------
  def self.process_escape
    r2_escape_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Abort Processing
  #--------------------------------------------------------------------------
  def self.process_abort
    r2_abort_switch
    event_hud_on
  end
  #--------------------------------------------------------------------------
  # * Defeat Processing
  #--------------------------------------------------------------------------
  def self.process_defeat
    r2_defeat_switch
    event_hud_on
  end
end

 

I get this error from this one:

error.png.c0b04e6b6bf6890bbbe54cac1dbbf7b2.png

And the other script still didn't do it for me.

I tried even making the event and autorun one, but still nothing.

 

I just think a common event is just not good for something like this at this point.

No matter how you slice it, battle processing seems to take priority over the event 🤔

 

Either way, thanks for both of you though, I wouldn't have figured a way of doing it alone!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted