Random Battle Transitions

Started by ThallionDarkshine, June 20, 2012, 11:27:31 am

Previous topic - Next topic

ThallionDarkshine

Random Battle Transitions



  Alright, I'm not quite sure if this is the right place for this, because it's just a script snippet. If you are like me, then you'd like some randomness in your games. It gets really annoying when the engine always uses the same transition for Scene_Battle.

First, go into the Script Editor. Next go to Scene_Battle1. Now look in the main method for where it says:


if $data_system.battle_transition == ""
  Graphics.transition(20)
else
  Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition)
end


Replace those lines with:


trans = []
Dir['Graphics/Transitions/*.{png,jpg,bmp}'].each{ |file|
  trans.push(File.basename(file, '.*'))
}
if FileTest.directory?('C:\Program Files/Common Files/Enterbrain/RGSS/Standard/Graphics/Windowskins')
  Dir['C:\Program Files/Common Files/Enterbrain/RGSS/Standard/Graphics/Transitions/*.{png,jpg,bmp}'].each{ |file|
    trans.push(File.basename(file, '.*'))
  }
end
trans_index = rand(trans.size)
Graphics.transition(40, "Graphics/Transitions/" + trans[trans_index])


And there you have it, random battle transitions.
Note. It works even if you don't use the RTP.

Blizzard

"C:\" Should be either "C:\\" or "C:/". xD
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

You shouldn't hard code non-relative paths. That won't work on a 64 bit PC or if some installed the RTP somewhere else. The RGSS DLL has a function to get the RTP path, just use Win32API to use it.

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

ThallionDarkshine

What is the method, then?
And blizz, I don't know how it worked if C:\ doesn't work. It worked fine on my computer.

Landith

C:\Users\Cody\Projects

I think he means because you changed the slashes after the 'C:\' because every slash after that is '/'

Blizzard

Maybe Ruby was smart enough to realize that \P is not a character (unlike \r or \n or \t) and simply looked at the \ as if it was \\.
Since \ is used to designate an escape character, in order to get the actual character in a string, you have to use \\. I'm not entirely sure, but it could also be because of the '' strings instead of "" strings as '' strings are considered simple strings.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

ForeverZer0

Here is an example in old script I made long ago. It gives paths to any/all RTP's (since up to 3 RTPs can be used).

http://forum.chaos-project.com/index.php/topic,5908.0.html
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.