Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: theneonheart on July 30, 2013, 05:53:14 am

Title: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: theneonheart on July 30, 2013, 05:53:14 am
Hi, I'm using an RM Flash script to show movies in rpg maker xp, and I want to show a movie before my title screen. I was wondering if I can use the Advanced Title Screen script to do this and if so, how would I manage it? I would like it to play the movie first thing, and then once it ends go to title screen, and then if you stay on title screen long enough to go back to playing the movie. I see in the script there is something about 'calling a scene', like it says here in the configuration:


def _SCENE_LINK(command_index)
    # Configure here any scenes you would like to link to the Title screen. You
    # must first configure the name of the command in COMMANDS. After that, just
    # fill in the name of the scene for the proper index. Any command index left
    # undefined will be assumed to be a 'Shutdown' option.
   
    # ex.   when 2 then Scene_MyOptions
   
    # Will make the third command (index starts at 0) start the defined scene.
    # Do not configue anything for index 0 or 1. It will not work. They are
    # reserved for 'New Game' and 'Continue'.

Does that mean it will go to a map where I can set up the movie event? If so, can you clarify how I would do that? Can anyone help me with this? Or will I need a different script?
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: WhiteRose on July 30, 2013, 09:58:19 am
This might be a little bit more complicated than another solution, but one option would be to create an evented title screen and have one of the events there call the movie scene.

Here is a thread with some great instructions on how you can do this:

http://forum.chaos-project.com/index.php/topic,13033.0.html (http://forum.chaos-project.com/index.php/topic,13033.0.html)

:)
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: theneonheart on August 03, 2013, 07:00:14 pm
I tried using the script you recommended, and the event plays the flash movie with sound but no image. I think if that can be fixed I can figure out how to set up the rest of the script based on the demo I got off that page. But I don't know why the movie isn't showing correctly. Any ideas? Do I have to load some database or something in the title scene? I can upload the RM Flash script if that helps. Also, part of the RM Flash script asks you to make an addition to the main script to use it... like this:

#                                                   Graphics.freeze                         #
#  1. Go to Main Script and add ---->  $flash = Play.new                       #
#                                                   $scene = Scene_Title.new 

I don't know if that is relevant to loading the title screen, just trying to help get it figured out... Thanks.

Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: WhiteRose on August 04, 2013, 02:16:14 pm
Quote from: theneonheart on August 03, 2013, 07:00:14 pm
I tried using the script you recommended, and the event plays the flash movie with sound but no image. I think if that can be fixed I can figure out how to set up the rest of the script based on the demo I got off that page. But I don't know why the movie isn't showing correctly. Any ideas? Do I have to load some database or something in the title scene? I can upload the RM Flash script if that helps. Also, part of the RM Flash script asks you to make an addition to the main script to use it... like this:

#                                                   Graphics.freeze                         #
#  1. Go to Main Script and add ---->  $flash = Play.new                       #
#                                                   $scene = Scene_Title.new 

I don't know if that is relevant to loading the title screen, just trying to help get it figured out... Thanks.




Hmm. Try posting a link to the script that you are using (either to the page where we can find it, or just upload it in "code" tags,) and we'll take a look at it and help you figure it out. :)
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: theneonheart on August 05, 2013, 08:30:10 am
I'm not sure where I got the code, it was a while ago. I know you have to put it at the very top of all scripts, and I mean all of them, not just the ones you're adding. And there are a couple of files you need to have in the game folder. I think these are the right ones, I uploaded them to my website: http://www.theneonheart.com/files/RMFlashFiles.rar (http://www.theneonheart.com/files/RMFlashFiles.rar)

#==============================================================================#
#                                                                 Version 0.3  #
#                         RPG Maker XP Flash Player                            #
#                                                                              #
#  Author: 灼眼的夏娜                     Updated by: Dark_Wolf_Warrior/Dahrkael #
#                                                                              #
#  How to Use:                                                                 #
#                                      Graphics.freeze                         #
#  1. Go to Main Script and add ---->  $flash = Play.new                       #
#                                      $scene = Scene_Title.new                #
#                                                                              #
#  2. Copy the .dll and the .ocx to the game folder                            #
#                                                                              #
#  3. Make a folder called "Flash" in the folder "Graphics" -> Graphics/Flash/ #
#                                                                              #
#  4. To play a flash file use:                                                #
#    $flash.play("file.swf", button)                                           #
#                                                                              #
#    button can be 0 or 1, if 1 you can skip the flash using "Enter"           #
#                                                                              #
#                                                                              #
#                                                                              #
#  Interactive flashes requires RGSS knownledge to make they work              #
#                                                                              #
#  Original Keyb module by HoundNinja                                          #
#                                                                              #
#==============================================================================#



class String
 
  CP_ACP = 0
  CP_UTF8 = 65001
 
  def u2s
    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
   
    len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
    buf = "\0" * (len*2)
    m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
   
    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
    ret = "\0" * len
    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
   
    return ret
  end
 
  def s2u
    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
 
    len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
    buf = "\0" * (len*2)
    m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
 
    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
    ret = "\0" * len
    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
     
    return ret
  end

  def s2u!
    self[0, length] = s2u
  end 
 
  def u2s!
    self[0, length] = u2s
  end
 
end

class Bitmap
 
  RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')

  def address
    buffer, ad = "xxxx", object_id * 2 + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  end
 
end

class RMFlash

API_NEW       = Win32API.new("RMFlash", "_new", "piil", "l")
API_UPDATE     = Win32API.new("RMFlash", "_update", "l", "v")
API_FREE       = Win32API.new("RMFlash", "_free", "l", "v")
API_PLAYING     = Win32API.new("RMFlash", "_is_playing", "l", "i")
API_PAUSE       = Win32API.new("RMFlash", "_pause", "l", "v")
API_RESUME     = Win32API.new("RMFlash", "_resume", "l", "v")
API_BACK       = Win32API.new("RMFlash", "_back", "l", "v")
API_REWIND     = Win32API.new("RMFlash", "_rewind", "l", "v")
API_FORWARD     = Win32API.new("RMFlash", "_forward", "l", "v")
API_CURFRAME   = Win32API.new("RMFlash", "_cur_frame", "l", "i")
API_TOTALFRAME = Win32API.new("RMFlash", "_total_frames", "l", "i")
API_GOTOFRAME   = Win32API.new("RMFlash", "_goto_frame", "li", "v")
API_GETLOOP   = Win32API.new("RMFlash", "_get_loop", "l", "i")
API_SETLOOP   = Win32API.new("RMFlash", "_set_loop", "li", "v")
API_CLEARALL   = Win32API.new("RMFlash", "_clear_all", "v", "v")
  API_VALID       = Win32API.new("RMFlash", "_valid", "l", "i")
  API_SENDMSG     = Win32API.new("RMFlash", "_send_message", "liii", "l")

  CUR_PATH        = Dir.pwd
 
def self.get_version

end

def self.clear_all
API_CLEARALL.call
end
 
  def self.load(name, width, height, v = nil)
    new("#{CUR_PATH}/Graphics/Flash/#{name}".u2s, width, height, v)
  end
 
  attr_reader   :valid

def initialize(flash_name, flash_width, flash_height, viewport = nil)
@sprite = Sprite.new(viewport)
@sprite.bitmap = Bitmap.new(flash_width, flash_height)
@value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
@loop = API_GETLOOP.call(@value) > 0
    @valid = API_VALID.call(@value) > 0
end

def viewport
@sprite.viewport
end

def update
API_UPDATE.call(@value)
end

def dispose
API_FREE.call(@sprite.bitmap.address)
end

def playing?
API_PLAYING.call(@value) > 0
end

def pause
API_PAUSE.call(@value)
end

def resume
API_RESUME.call(@value)
end

def back
API_BACK.call(@value)
end

def rewind
API_REWIND.call(@value)
end

def forward
API_FORWARD.call(@value)
end

def current_frame
API_CURFRAME.call(@value)
end

def total_frames
API_TOTALFRAME.call(@value)
end

def goto_frame(goal_frame)
API_GOTOFRAME.call(@value, goal_frame)
end

def x
@sprite.x
end

def x=(v)
@sprite.x = v
end

def y
@sprite.y
end

def y=(v)
@sprite.y = v
end

def z
@sprite.z
end

def z=(v)
@sprite.z = v
end

def width
@sprite.bitmap.width
end

def height
@sprite.bitmap.height
end

def loop?
@loop
end

def loop=(v)
if @loop != v
@loop = v
API_SETLOOP.call(@value, v)
end
end
 
  def msg_to_flash(msg, wParam, lParam)
    return API_SENDMSG.call(@value, msg, wParam, lParam)
  end
 
  #  例
  WM_MOUSEMOVE  = 0x0200
 
  def make_long(a, b)
    return (a & 0xffff ) | (b & 0xffff) << 16
  end
 
  def on_mouse_move(x, y)
    return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  end

end

module Kernel

  alias origin_exit exit unless method_defined? :exit
 
  def exit(*args)
    RMFlash.clear_all
    origin_exit(*args)
  end
 
end

module Keyb
  $keys = {}
  $keys["Enter"] = 0x0D
  GetKeyState = Win32API.new("user32","GetAsyncKeyState",['i'],'i')
  module_function
  def trigger(rkey)
    GetKeyState.call(rkey) & 0x01 == 1
  end
end

class Play
 
  def play(filename, button)
    fondo = Sprite.new
    fondo.bitmap = Bitmap.new(640, 480)
    fondo.bitmap.fill_rect(0, 0, 640, 480, Color.new(0,0,0,255))
    fls = RMFlash.load(filename, 640, 480)
    fls.loop = 1
    fls.z = 9999
    @button = button
    @fr = Graphics.frame_rate
    Graphics.frame_rate = 40

    while true
      Graphics.update
      #Input.update
      fls.update
      break if @button == 1 and Keyb.trigger($keys["Enter"])
      break if !fls.playing?
      end
    fls.dispose
    Graphics.frame_rate = @fr
    fondo.dispose
  end

end
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: Zexion on August 05, 2013, 09:47:40 am
I came to this thread so many times and I didn't realize that your actual question was so easy, lol. I thought I had to do some asian math, so I kept ignoring.
1. Anywho, it's going to take a bit of eventing and a script. First you need a title skip script. If you can't find it, I've provided the one I use below.
2. Next you are going to need a start up map. I usually make it the first map, but it doesn't matter which map it is, just make sure it has no tiles and no background.
3. Go to the database and erase your starting party (I think it's the last tab.)
4. On your blank start up map, make the player starting position be in the center.
5. Create a new event with no character graphic anywhere on the map. Set it to be a parallel process event.
6. Now, you might have to get creative here. Firstly, inside the event, make a script call (last button, last page) and put:
$flash.play("file.swf", button)

Of course you're going to have to edit that with whatever.
Since I don't know how that script works exactly, you will have to figure out what to do next. If the script pauses the map to play the video and then resumes it after it's done, then you should be fine by simply following the event flow:
script: $flash.play("file.swf", button)
call title screen

Otherwise, like I said, you might have to play around with the events to get it to work.
Spoiler: ShowHide
 #==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================

class Scene_Title
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# If battle test
if $BTEST
battle_test
return
end
# Load database
$data_actors = load_data("Data/Actors.rxdata")
$data_classes = load_data("Data/Classes.rxdata")
$data_skills = load_data("Data/Skills.rxdata")
$data_items = load_data("Data/Items.rxdata")
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
$data_enemies = load_data("Data/Enemies.rxdata")
$data_troops = load_data("Data/Troops.rxdata")
$data_states = load_data("Data/States.rxdata")
$data_animations = load_data("Data/Animations.rxdata")
$data_tilesets = load_data("Data/Tilesets.rxdata")
$data_common_events = load_data("Data/CommonEvents.rxdata")
$data_system = load_data("Data/System.rxdata")
# Make system object
$game_system = Game_System.new
# Make title graphic
# Make command window
# Continue enabled determinant
# Check if at least one save file exists
# If enabled, make @continue_enabled true; if disabled, make it false
command_new_game
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
# * Command: New Game
#--------------------------------------------------------------------------
def command_new_game
# Play decision SE
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Continue
#--------------------------------------------------------------------------
def command_continue
# If continue is disabled
unless @continue_enabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to load screen
$scene = Scene_Load.new
end
#--------------------------------------------------------------------------
# * Command: Shutdown
#--------------------------------------------------------------------------
def command_shutdown
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Fade out BGM, BGS, and ME
Audio.bgm_fade(800)
Audio.bgs_fade(800)
Audio.me_fade(800)
# Shutdown
$scene = nil
end
#--------------------------------------------------------------------------
# * Battle Test
#--------------------------------------------------------------------------
def battle_test
# Load database (for battle test)
$data_actors = load_data("Data/BT_Actors.rxdata")
$data_classes = load_data("Data/BT_Classes.rxdata")
$data_skills = load_data("Data/BT_Skills.rxdata")
$data_items = load_data("Data/BT_Items.rxdata")
$data_weapons = load_data("Data/BT_Weapons.rxdata")
$data_armors = load_data("Data/BT_Armors.rxdata")
$data_enemies = load_data("Data/BT_Enemies.rxdata")
$data_troops = load_data("Data/BT_Troops.rxdata")
$data_states = load_data("Data/BT_States.rxdata")
$data_animations = load_data("Data/BT_Animations.rxdata")
$data_tilesets = load_data("Data/BT_Tilesets.rxdata")
$data_common_events = load_data("Data/BT_CommonEvents.rxdata")
$data_system = load_data("Data/BT_System.rxdata")
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up party for battle test
$game_party.setup_battle_test_members
# Set troop ID, can escape flag, and battleback
$game_temp.battle_troop_id = $data_system.test_troop_id
$game_temp.battle_can_escape = true
$game_map.battleback_name = $data_system.battleback_name
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Switch to battle screen
$scene = Scene_Battle.new
end
end
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: theneonheart on August 05, 2013, 10:21:08 am
That makes perfect sense, and that seems like it will work fine. Thanks. But can you attach the title skip script you mentioned?
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: Zexion on August 05, 2013, 10:28:15 am
Oh yeah, I totally forgot to get that from my other thread hold on lol.
Done XD
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: theneonheart on August 06, 2013, 03:58:56 pm
OK, I think it is almost there but there are still a few questions that I need answered before I think it will work.

Basically, I just plugged in the title skip script as you laid it down, at the beginning of all my other custom scripts, and it skips the title and goes to the start map, but then I think it is just skipping it again when it gets to the 'return to title screen' script call, because the start map repeats itself. So, I need to know how to DISable the title skip when it does that, so that it will not run, and will actually go to the title screen when I want it to. I think that will wrap it up.
Title: Re: [XP] Advanced Title Screen-Can I show movie with RMFlash before title?
Post by: Zexion on August 06, 2013, 08:10:45 pm
Like I mentioned, you might need to look around for another (better) title skip script. The reason it skips is because it overrides scene_title completely, so you can never actually go to the normal scene_title. I think it would be easy to change but I don't have time atm D: