Battle Processing on a new Class

I thought of making a new thread for this query instead...

I always wanted to make a battle of my own... so I tried making a class named NewBattle and placed this script afterwards:

BattleManager.setup(2, true, true) BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n } $game_player.make_encounter_count SceneManager.call(Scene_Battle)but it gives me an error about replay BGM. how can i resolve the issue since the bgm since its on battlemanager?
Whenever you encounter an error, screenshot it and post it here... it also comes with a description on which script and line caused the error so you should also post the full script too (if you made it) or a link...
Okay here's how it is...

here's my error:

i66g.jpg


and this is my code...

class NewBattle def main start_battle end def start_battle BattleManager.setup(1, true, true) BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n } $game_player.make_encounter_count SceneManager.call(Scene_Battle) end end what i wanted to do was to call a battle through a script...

I made an event with this script call SceneManager,call(NewBattle)
you don't need the main... why are you even trying to do it in a class anyways? doing it that way, with that class will probably cause lots of problems...

you could just put it on a module like

Code:
module Heart  def self.start_battle      BattleManager.setup(1, true, true)      BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n }      BattleManager.save_bgm_and_bgs #This is the method used for saving the map's BGM and BGS      $game_player.make_encounter_count      SceneManager.call(Scene_Battle)  endend
then call it via Heart.start_battle
that solved my problem, thanks!
though, why not just simply call the Battle Processing Event Command? or you'd like to do call it inside another script?
There are lots of reasons. I wanted to do conditional battles that only happens when some events actually happen, a time, a region...etc.

And its a way to learn how they work and how scripts are working 🙂

You can say I am tired eventing and I just want to learn how to script everything.
I would highly recommend subclassing your custom scene from either Scene_Battle or Scene_Base and overwrite the methods that you need to change as needed instead of copy pasting everything.
I don't think he's modifying anything really, he just wants to call Scene_Battle from other places...
I wanted to call a battle process on a new class, as to the reason of...

say I wanted to engage battle into a boss rush...

rather than eventing it, I want to do it via scripting to set up advanced conditions...

so does making it class NewBattle < Scene_Battle more appropriate rather than making a module or a new class without a subclass?
nah, since you're not modifying anything on the battle scene itself, you won't really need to do that
Oh great, the module seems to work, but here's another problem though:

eqq8.jpg


the problem is seems not to be having the proper items closed whenever the battle ends, since its not done in the conventional battle processing way. Of which, if I ever add data troops in it, gives me an undefined data troops error as well.
there's no data troops, since it is $data_troop... what's the exact line?
I used your script:

module Heart def self.start_battle BattleManager.setup(1, true, true) BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n } BattleManager.save_bgm_and_bgs #This is the method used for saving the map's BGM and BGS $game_player.make_encounter_count SceneManager.call(Scene_Battle) endendand line 4 error is this:

Code:
      BattleManager.event_proc = Proc.new {|n| @branch[@indent] = n }
well, you don't have @branch defined anywhere in there so that's bound to error...


remove that line, it seems to be used as a callback to the event, I don't think you need it...
Great! It worked 🙂

That saved a lot.

Any mods can lock this thread now. The issue is solved 🙂

Original thread: https://forums.rpgmakerweb.com/threads/battle-processing-on-a-new-class.23191/