Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
michallaszlo

Script for Equip in battles

Recommended Posts

I'm not sure if anybody already did this but I've made a script for accessing equip screen in battles and thought I'd share it here in case anybody would be interested. It basically just tweaks of Scene_Battle and Spriteset_Battle classes. I'm including complete scripts in attached files so in case you're not interested in scripting, just open these files and copy their content to their respective pages in script editor. Just be careful, as it'll rewrite any other scripts you may have had there. I strongly recommend backuping them first in case anything goes wrong but I've tested them on vanilla scripts and it works fine.

 

In case you'd be wondering what changes I made I'll try to explain step by step so you can make further tweaks wherever you need.

 

So first let's look on Scene_Battle 1:

 

First I made another line on command window with the text "Equip" and added an corresponding attribute on @actor_command_window. I've also appropriately raised its position to @actor_command_window.y = 128, so it would fit battle screen with the new command. Then I've created variables for disposing of equip windows, as a condition I've left just if @right_window != nil. There are 7 equip windows in total but all are being created and disposed at the same time so I left just 1 window as condition. That's pretty much it for init phase.

 

Scene_Battle 2 deals with pre and post battle phases so there's not need to change anything there. Most changes were in Scene_Battle 3:

 

Most of the things here is basically just Scene_Equip class split into multiple parts so it would adhere to Scene_Battle 3 structure. First thing that needed to be updated is update_phase3 method, so I've created another condition here for updating equip window:

 

# If equip windows are enabled
elsif @right_window != nil
  update_phase3_equip
 
 
update_phase3_equip method is then created later on. Another thing is created appropriate actions called by pressing Equip on command window:
 
when 4  # equip
  # Play decision SE
  $game_system.se_play($data_system.decision_se)
  # Set action
  @active_battler.current_action.kind = 3
  # Start equip screen
  start_equip
 
I've created a new action kind for this, which is then used for acquiring the action in phase 4. start_equip method is for creating equip windows, is on the very bottom of the script page, together with other starts.
 
Then I created update_phase3_equip method below def update_phase3_item_select. I've split it to 3 parts, same as it's done in Scene_Equip. These can't be called at the same time because index is going back and forth between right equip window and item equip window. update_phase3_equip and update_right are same as in Scene_Equip with exception of 4 things:
 
1. I had to change name of @item_window which is substituting for @item_window1..5 to @item_window_e, because these item windows wouldn't otherwise update properly for some reason. My guess is it was somehow colliding with @item_window used for Item action in command window, but I may be mistaken.
 
1. In update_phase3_equip I had to change @item_window (or in my case @item_window_e) for updating all 5 item windows separately, otherwise it would throw out an error. Again, not sure what was the issue here but it's working like this so I guess it doesn't matter.
 
3. I changed cancel button action on update_right method so it will call out end_equip method instead of going to menu, which will the properly close equip windows and activate status and command windows.
 
4. I've completely excluded changing actors in equip menu by pressing R or L due to turn based nature of battle actions.
 
Now the main change in update_item method is result of confirm button input. Original Scene_Battle script first changes the equipment by calling @actor.equip(@right_window.index, item == nil ? 0 : item.id), then returns index to the right window. However I wanted to have it work not as an immediate action but rather as a command, same way as other battle command. So I got rid of @actor.equip and instead called it from 4th phase. I just needed to somehow store @actor.equip attributes, because they couldn't be called out the same way after equip windows would be disposed of. So I called them out the same way but stored them in variables @weapon_type and @item_eq. These would however get overwritten by actors in case more the one actor would use equip during the fight, so I had to number them and create separate variables for each actor. Maybe there was some more elegant way how to do this but this worked so it's good enough for me.
 
Another option here would be to leave it as it is in Scene_Equip so it would change equipment immediately and return to the right window. It depends on what you prefer for your gameplay. I wanted to retain the turn based structure of all battle actions.
 
Anyway after I did this the last thing here was getting rid of returning to @right_window and instead calling out end_equip, which closes equip windows and phase3_next_actor, which gives turn to the next actor.
 
Now the last thing remaining in 3rd phase is adding start_equip and end_equip methods which will open/close equip windows. There is also additional refresh method which serves for calling out separate item windows for changing items and updating left window with new stats. It has to be separated this way for a multi-step nature of equip windows. Refresh method is then repeatedly called out from def update_phase3_equip.
 
def start_equip and def end_equip are copied from different parts of Scene_Equip, with natural addition of disabling/activating of command windows.
 
Another problem was battle status window, because it would stay visible after opening of equip windows. This was easily resolved by deactivating @status_window and calling out hide_actors/show_actors methods, which I've created for Spriteset_Battle class. I'll get to them at the end. Other thing were changing @actor = $game_party.actors[@actor_index] to @actor = @active_battler, as it didn't get actor id from the first one properly and getting rid of @actor_index and @equip_index called out on Scene_Equip init, which are useless here. The last was setting all equip window to nil after disposing some other functions during the battle would't work properly without it.
 
Now only refresh method remains in phase 3. Here I just interchanged all @item_window with @item_window_e as I've explained previously. Otherwise no other change here.
 
Ok let's move on to phase 4 finally (or Scene_Battle 4):
 
First thing I needed to do here was adding a new action kind which I've created for equip in phase 3. This is done at the end of the update_phase4_step2 method by adding:
 
when 3  # equip
  make_equip_action_result
 
Then we just have to create a method we calling by this at the end of the script page and that's it. Here I'm calling that @active_battler.equip I postponed from phase 3 with attributes @weapon_type1..4 and @item_eq1..4 I've created previously. I had to separate them again by @active_battler.id. And of course $game_system.se_play($data_system.equip_se) for sound effect and @help_window.set_text('Reequipping', 1) for message text at the end. You can of course change sound and text to whatever you want.
 
That's pretty much it, now the last thing that remains is creating those hide_actors and show_actors methods in Spriteset_Battle. Basically what these are doing is that they are enabling/disabling visibility of @viewport2 in battle, which is reserved for actor sprites. I didn't know how to disable it from battle so i just created separate methods for them in Spriteset_Battle.
 
One thing I forgot to mention is the opacity of the windows during the fight. I left it as it is in original script but in case you'd be bothered by some windows being transparent and some note, you can tweak this by changing opacity of each window by simply adding self.back_opacity = * to the init method of each window. You can make either all transparent which I wouldn't recommend because battleback sprites are not over the whole screen so in case of getting rid of status window during equip there would be big black space at the bottom of the screen. Or you can cancel transparency of item and skill windows by erasing their 'during the fight' opacity statements in their script pages. If you would want to change opacity of help window, you can do that by changing value of @help_window.back_opacity in main method in Scene_Battle 1.
 
And that's it. I hope you'll enjoy using and further building on this. Also I may have missed something in description so feel free to correct me in comments. I also made scripts other battle mechanics like wait command or cover command (substitution for guard command - it takes guarding as invulnerability status that's being kept for as long as you won't use attack or any attack items, can be used by party as well as enemies). Making a game with contemporary settings I also made a simple ammo mechanic, where every attack from a gun weapon substracts some ammo from it, so you need to keep eye on your ammo reserves or reload during fights (works well with cover mechanic). Other things I did is for instance making changed stats of left equip window green or red depending on whether the new equip stats are better or worse or giving animation/sound and damage to no weapon, in case you want to subdue somebody with your bare hands. This could be done also by creating a 'fist' weapon, it just felt strange to have your own fists as an item in inventory. I'm gonna further improve on this one by making some event fight results differ depending on whether you kill your opponent with weapon or just knock him out with punching, although this is not done yet.
 
So in case anyone would be interested it these other things let me know in comments or pm me and I can share them too. Have a good one!

 

Scene_Battle 1.txt

Scene_Battle 3.txt

Scene_Battle 4.txt

Spriteset_Battle.txt

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...