Chaos Project

RPG Maker => RPG Maker Scripts => Topic started by: ThallionDarkshine on June 20, 2012, 11:27:31 am

Title: Random Battle Transitions
Post by: ThallionDarkshine on June 20, 2012, 11:27:31 am
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.
Title: Re: Random Battle Transitions
Post by: Blizzard on June 20, 2012, 11:38:25 am
"C:\" Should be either "C:\\" or "C:/". xD
Title: Re: Random Battle Transitions
Post by: ForeverZer0 on June 20, 2012, 12:35:02 pm
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.

Title: Re: Random Battle Transitions
Post by: ThallionDarkshine on June 21, 2012, 08:23:43 am
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.
Title: Re: Random Battle Transitions
Post by: Landith on June 21, 2012, 10:38:41 am
C:\Users\Cody\Projects

I think he means because you changed the slashes after the 'C:\' because every slash after that is '/'
Title: Re: Random Battle Transitions
Post by: Blizzard on June 21, 2012, 10:43:11 am
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.
Title: Re: Random Battle Transitions
Post by: ForeverZer0 on June 21, 2012, 10:44:21 am
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