Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V   1 2 >  
Reply to this topicStart new topic
> N543 Skit System, Like the Tales of series!
Night5h4d3
post Jun 29 2011, 02:20 PM
Post #1


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Skit System
version 5.0
By Night5h4d3




Introduction

A while back I was working on a project with a group as their scripter, and I was requested to make a script for displaying 'skits' as cutscenes. Later we changed engines and so I decided to upload this script for the general public. What it is-is basically a remake of the skit system from the 'Tales of' series (give or take a few features). It runs off of common events, so that creating and using skits is as simple as creating map-based cutscenes.

Features

> Display, move, and remove custom face graphics and expressions (See how to use)
> Runs from common events
> Custom music
> Easy to configure
> Supports 640x480 mode too!
> Face effects Hop, Pop, and Shake
> Animated 'new skit' button

Installation

To install, just place the script anywhere below other scripts and above main. Make sure you have the required resources!

Script

v5.0 Standalone

Demo

Skit System Demo 5.0

Compatability

Aliases
Game_Temp - initialize
Game_Interpreter - setup
Window_Message - reset_window
Scene_Title - create_game_objects
Scene_File - write_save_data and read_save_data

Changes
Game_Interpreter - update
Window_Message - initialize
Scene_Map - create_command_window and update_command_selection

Get RMXP v4.6.01 here!


Screenshots

spoiler




Required Resources

spoiler

see FAQ for info on animating this:






Positioning is relative, so it will be in the same area of the screen in both 544 and 640 resolutions.


How to use
spoiler

1) create the skit - in the script you'll find the Skits module, add a new array in the specified format
2) create a common event - make sure it corresponds to the common event you used in the skits module
3) Begin coding your skit!

Adding the face
CODE
$scene.new_face(face, expr, pos, mir?, num)

face - the filename of the face set to use
expr - the facial exp​ression (0 is the top left face, 1 is the one to it's right.. 4 is on the bottom left, etc). Default is 0
pos - the position of the face a number ranging from 0 to 18, or use an array to specify a direct placement, (refer to the cheat-sheet). Default is 0
mir? - set to true to mirror the face graphic. Default is false
num - the index of the face to use, normally the first face created is 0, the second is 1, etc, but you can specify the index.

Changing the face
CODE
$scene.change_face(pos, new expr, new file, mirror)
$scene.dispose_face(pos1)

pos - refers to the current position of the face being modified.
new expr - new facial exp​ression to use.
new file - new face graphic to use, set to nil to keep current face (see face). Default is nil
mirror - 'Mirror new face?' Default is false.

Repositioning the face
CODE
$scene.move_face(pos, new pos, pause)
$scene.dispose_face(pos1)

pos - refers to the current position of the face being modified.
new pos - refers to the destination position.
pause - 'Pause interpreter while moving face?' Default is false.

Hopping face effect
CODE
$scene.hop(pos, scale, count, dir, pause)
$scene.dispose_face(pos1)

pos - refers to the current position of the face being modified.
scale - how fast and high the face hops (scale of 1-10). Default is 5.
count - how many times to make the face jump (scale of 1-5). Default is 1
dir - direction of the jump ("up", "down", "left", "right"). Default is "up"
pause - 'Pause interpreter while moving face?' Default is false.

Popping face effect - Causes the face's size to grow then shrink
CODE
$scene.pop(pos, scale, pause)
$scene.dispose_face(pos1)

pos - refers to the current position of the face being modified.
scale - how fast and wide the face pops (scale of 1-5). Default is 3.
pause - 'Pause interpreter while moving face?' Default is false.

Shaking face effect
CODE
$scene.shake(pos, scale, axis, pause)
$scene.dispose_face(pos1)

pos - refers to the current position of the face being modified.
scale - how fast the face shakes (scale of 1-10). Default is 5.
axis - plane of shake "x" or "y" (horizontal or vertical). Default is "x".
pause - 'Pause interpreter while moving face?' Default is false.



FAQ

Q: How do I set it up for 640 mode?
A: If you're already running a game screen that's setup for 640x480, then all you need is the Skit BG that's the right size.

Q: How do I include A skit button?
A: all you need to do is name the file with the words 'skit' and 'button' in that order, (eg: Skit Button, Skitbutton, Skit_button) and put it in the Graphics/System folder

Q: How do I make it animate?
A: To animate a skit button all you need to do is append '#' (without the quotes) followed by the number of frames in the file (ex. '#4' for 4 frames)

Q: Where/how do I create the skits?
A: All skits are run from common events, to create a new skit you need to create a new common event.

Q: The new move/pop/hop/shake commands aren't working right, when I have 2 only the last one runs?
A: This is because by default the interpreter doesnt pause when performing these actions, if you want all of the actions to be taken, set the 'pause' flag and separate each action into a different 'call script' command.

Q: The real Tales of skit system had animated faces and they could swivel too.
A: Well, that's not really a question, but you can expect these sometime down the line!


Disclaimer

Please do not claim as your own, if you'd like to post this script on other sites, please notify me beforehand.


Other

Bugs? Ideas? Requests? Let me know, and I'll see about fixing/implementing them!


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Airon Neil
post Jul 18 2011, 07:34 PM
Post #2


Level 2
Group Icon

Group: Member
Posts: 16
Type: Writer
RM Skill: Skilled




I sure hope I'm not necroposting, but I have a problem with the script, whenever I activate a skit that doesn't change the BGM it comes up with an error message.



but other than that the script is great, it's exactly what I've been looking for.

This post has been edited by Airon Neil: Jul 18 2011, 07:37 PM


__________________________

Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 21 2011, 04:34 AM
Post #3


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Sorry for the late reply, I just made the correction and have re-uploaded the script (haven't gotten a chance to update the demo yet), it should work now.

Edit - Demo has been updated also.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
kurisu21
post Jul 21 2011, 12:56 PM
Post #4



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Undisclosed




I downloaded both the script and demo after you posted that you updated. Are the links updated as well
because I get this message:

Script 'N543 Skit System' line 742: NoMethodError occurred.
undefined method 'play' for nil:NilClass


it's the same as the above poster only line 742 instead of 741
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 21 2011, 01:49 PM
Post #5


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




whoa snap, I made a stupid revision. On line 741 you'll see ' = nil change that unless to an '== nil'
I'll revise that meanwhile. XP


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Airon Neil
post Jul 21 2011, 04:41 PM
Post #6


Level 2
Group Icon

Group: Member
Posts: 16
Type: Writer
RM Skill: Skilled




Alright, thank you...it works perfectly now.


__________________________

Go to the top of the page
 
+Quote Post
   
MEands
post Jul 21 2011, 06:52 PM
Post #7


We're out of nachos?!!
Group Icon

Group: Revolutionary
Posts: 534
Type: None
RM Skill: Skilled
Rev Points: 15




This looks great. Does it work with XP? I only see a VX example.


__________________________
I'm a Christian, just in case you were wondering.



Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Jul 21 2011, 07:05 PM
Post #8


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Fix has been uploaded (finally, lol)

Actually MEands, I am working on making a RMXP version of it at the moment, I'd say it's about 50% done. (After all, when I first made this script, it was intended for a 640x480 screen)


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
kurisu21
post Aug 1 2011, 11:09 AM
Post #9



Group Icon

Group: Member
Posts: 4
Type: None
RM Skill: Undisclosed




Cool the revision works well.
What could I do with the code so that after the skit finishes it goes straight back to game-play instead of the skit menu list?
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 1 2011, 06:49 AM
Post #10


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Sorry, due to the 'layout' of the Scene_Skit, this is not possible to change the code to achieve that. However, in the common event, you can add a call script to the end:
CODE
unless $game_skit.watched.include?(Skits::<NAME>)
  $game_skit.watched.push(Skits::<NAME>)
end
$scene = Scene_Map.new


Replacing <NAME> with the name of that skit (as it appears in the Skits constant in the script editor).
This forcefully states that the skit has been watched and exits to the map.

alternately, if you don't want it to exit to the map every time you watch it, you can put this:
CODE
if !$game_switches[NNN]
  unless $game_skit.watched.include?(Skits::<NAME>)
    $game_skit.watched.push(Skits::<NAME>)
  end
  $scene = Scene_Map.new
end

Replacing NNN with the number of the switch you want to use; turn that switch on, and it wont skip to the map next time you play it.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Pinky
post Sep 2 2011, 04:13 PM
Post #11


Level 13
Group Icon

Group: Revolutionary
Posts: 227
Type: Developer
RM Skill: Skilled




This script is great, but I cannot figure out where to include the talking text the demo doesn't tell me how. Do you just add them like a normal message I cannot find it in the demo and I am extreamly frustrated because I don't know.


EDIT:
AH!!! Figured it out I forgot to check the common events. Man I feel stupid.

This post has been edited by Pinky: Sep 2 2011, 04:16 PM
Go to the top of the page
 
+Quote Post
   
VVBlazeFuryVV
post Sep 2 2011, 07:43 PM
Post #12


Level 1
Group Icon

Group: Member
Posts: 9
Type: Mapper
RM Skill: Skilled




Er... I got a error message...
I tried putting this in my game and I got this weird error:

Script 'N543 Skit System' line 580: NoMethodError occured.
undefined method 'skits' for nil:NilClass


I think it's because of the Neo Message System 3 script that I have.
Can you help?


__________________________
Hello...

Name's Blast Fury.
I've been RPG making for the past 1 year now and I've gotten really, REALLY good at it. I'm working on my first RMVX project called Lunai Stories - Era of Old Miltia, which has been redone about... like a million times because I couldn't come up with a story. So hopefully I can get along with the people here in the RPG Maker forums...
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Sep 8 2011, 11:41 PM
Post #13


Level 50
Group Icon

Group: +Gold Member
Posts: 1,519
Type: Scripter
RM Skill: Undisclosed




It may be because I tweaked a couple of things, but it seemed to work fine for me: demo.
Talk to the guy in the bottom left, he's copied straight from N5's demo smile.gif



__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 9 2011, 04:52 AM
Post #14


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Nightrunner, you're something of a godsend XD. Also, as a teaser of sorts, expect an update, with some cool new features later this week!


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 14 2011, 10:06 AM
Post #15


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




Version 5.0 is here! Here is the changelog!

Bug Fixes:
Entering and exiting menu without watching new skit would sometimes crash/freeze game
Weather and screen effects would overlay skit button (Thanks EvilEagles)
Using an array for positioning a face rather than position number would sometimes prevent user from modifying that face.
When calling 'change_face' the bitmap would transfer the new image before clearing the previous one leading to overlapping face graphics.
When not using custom music for skits, the map music would still fade at the end of a skit. (Thanks EvilEagles)


New Features:
Skit System now supports animated skit buttons (suggested by Evil Eagles)
Skit button file automatically detected and animated (see how to use)
Skit System now allows option for showing name of most recent skit (suggested by Evil Eagles)
Ability to hide Skit button and most recent skit text (suggested by Evil Eagles)
Change_face command has been split into change_face and move_face
Pause_While is no longer used, instead, it is declared when face is moving, popping, hopping, etc
New actions for skit faces including shake (suggested by Evil Eagles), hop, and pop

Freed objects:

Scene_Map.update_basic
N5::Pause_While
N5::Skit_Button
Scene_Map.terminate and Scene_Map.update have been removed and changed to Scene_Base.terminate and Scene_Base.update. This improves compatability for other scripts that make edits to Scene_Map.


These updates will be for RMXP soon!


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
EvilEagles
post Sep 16 2011, 02:56 AM
Post #16


Level 3
Group Icon

Group: Member
Posts: 39
Type: Developer
RM Skill: Beginner




This is totally awesome happy.gif thank you very much for getting it done tongue.gif
Well hope you don't mind, I added full guide on how to use in the script's description. Just a little something for ease of use for those who wanna use the script.

CODE
#==============================================================================
# N5_Module - Skit
#------------------------------------------------------------------------------
# By Night5h4d3
# Version 5.0
# Date 11/11/2010
# Last Update 9/13/2011
#==============================================================================
# • Support/Troubleshooting/FAQ's/Bugs:
# If what you have in mind falls under those categories, PM me at:
# http://www.rpgrevolution.com/
# (Username: Night5h4d3)
#------------------------------------------------------------------------------
# • Key
#   <S> = New value in "string" format
#   <B> = New value in boolean format (true/false)
#   <H> = New value in hash format (I=>N)
#   <P> = Pointer to existing variable
#   <N> = Number format
#==============================================================================
module N5
#------------------------------------------------------------------------------
# • Skit Presets
#------------------------------------------------------------------------------
    # <S> This is the filename to use for the skit system
    #--------------------------------------------------------------------------
    Skit_BG       = "Skit_BG"
    #--------------------------------------------------------------------------
    # <P> This is the button needed in order to activate the skit system
    #--------------------------------------------------------------------------
    Skit_Activate = Input::X
    #--------------------------------------------------------------------------
    # <S> This is the default music to play during a 'skit', this can be changed
    # later by using a call script ($game_system.skit_bgm = "<new BGM name>")
    #--------------------------------------------------------------------------
    Skit_BGM      = "Spinach Rag Opera"
    #--------------------------------------------------------------------------
    # <S> Refers to the Icon used for new/un-watched skits, leave "" or nil
    # if you don't want an icon to be displayed next to new skits, they will be
    # italic if no icon is used.
    #--------------------------------------------------------------------------
    New_Skit_Icon = ""
    #--------------------------------------------------------------------------
    # <S> The term used in the menu for skits.
    #--------------------------------------------------------------------------
    Skits_Term    = "Skits"
    #--------------------------------------------------------------------------
    # <N> Switch number to toggle hiding new skit button. Set to false to never
    # hide,
    #--------------------------------------------------------------------------
    Hide_Btn      = 82
    #--------------------------------------------------------------------------
    # <N> Switch number to toggle hiding new skit text. Set to false to never
    # hide,
    #--------------------------------------------------------------------------
    Hide_Txt      = false
    #--------------------------------------------------------------------------
    # <N> Frame rate of the animated button. For animations with fewer frames
    # set this number higher. Keep in mind that if this number multiplied by
    # the number of frames in the animation exceeds 60(the game's framerate),
    # frames WILL skip.
    #--------------------------------------------------------------------------
    Anim_Rate     = 6
    #--------------------------------------------------------------------------
    # <H> The positioning used for the skit faces. > Do not change this unless
    # you know what you're doing! <
    #--------------------------------------------------------------------------
    SKIT_POS = { 0 => [(((Graphics.width-448)/2)+176),(((Graphics.height-(32*4))-120)/2)],
    1 => [(((Graphics.width-448)/2)+112), (((Graphics.height-(32*4))-120)/2)],
    2 => [(((Graphics.width-448)/2)+240), (((Graphics.height-(32*4))-120)/2)],
    3 => [(((Graphics.width-448)/2)+48), (((Graphics.height-(32*4))-120)/2)],
    4 => [(((Graphics.width-448)/2)+304), (((Graphics.height-(32*4))-120)/2)],
    5 => [(((Graphics.width-448)/2)+112), 32],
    6 => [(((Graphics.width-448)/2)+240), 32],
    7 => [(((Graphics.width-448)/2)+112), (((Graphics.height-(32*5))/2)+32)],  
    8 => [(((Graphics.width-448)/2)+240), (((Graphics.height-(32*5))/2)+32)],
    9 => [(((Graphics.width-448)/2)+48), 32],
    10 => [(((Graphics.width-448)/2)+304), 32],
    11 => [(((Graphics.width-448)/2)+48),(((Graphics.height-(32*5))/2)+32)],
    12 => [(((Graphics.width-448)/2)+304), (((Graphics.height-(32*5))/2)+32)],
    13 => [(((Graphics.width-448)/2)+176), 32],
    14 => [(((Graphics.width-448)/2)+176), (((Graphics.height-(32*5))/2)+32)],
    15 => [(((Graphics.width-448)/2)), (((Graphics.height-(32*5))/2)+32)],  
    16 => [(((Graphics.width-448)/2)+368), (((Graphics.height-(32*5))/2)+32)],
    17 => [(((Graphics.width-448)/2)), 32],
    18 => [(((Graphics.width-448)/2)+368), 32]
    19 => [(Graphics.width-96), 32],
    20 => [(Graphics.width+96), 32],
    21 => [(Graphics.width-96), 160],
    22 => [(Graphics.width+96), 160],
       # Your custom Face Position here. Format: Index => (x, y),
    }
    
end
  
#============================================================================= #
# HOW TO USE: ||
# ============================================================================ #
# STEP 1 | ADD THE SKIT |
# ------------------------
# In Skits module under this section, add a new array in the following format.
#    SKIT_ALIAS = [NAME, COMMON EVENT ID, MANDITORY, CUSTOM BGM]
#
# SKIT_ALIAS - Change this to the alias representing the corresponding skit
#              configured under SNIPPETS section.
# NAME - Name of the skit to be appeared on map and in Skit Menu.
# COMMON EVENT ID - Common Event ID
# MANDITORY? - True or false. True to make this skit to be played forcefully.
# CUSTOM BGM? - True or false. Current Map's BGM will be used if false.
#
# ------------------------------------------------------------------------------
# STEP 2 | CREATE THE SKIT  |
# --------------------------
# Start designing your skit. Remember to always ADD FACES first. Should look
# like this:
# > Script: $scene.new_face("Ralph", 3, 0, false, 0)
# > Script: $scene.new_face("Ulrika", 2, 17, true, 0)
# > Text: ...
#
# Check out the SNIPPETS under this section for more features in-skit.
# ---------------------------------------------------------------------------- #
# STEP 3 | CALL THE SKIT  |
# ------------------------
# Using an Event, Script Command to call and add the skit to Skit Menu.
#                      $scene.new_skit(Skits::SKIT_ALIAS)
# SKIT_ALIAS - The alias representing the corresponding skit already configured
#              under SNIPPETS section.
# ================================== DONE! =================================== #
#
#
#
# ============================================================================ #
# * SNIPPETS TO BE USED IN-SKIT
# ============================================================================ #
#                      * ======== ADD A FACE ======== *
#                  $scene.new_face(face, expr, pos, mir?, num)
#* NOTES                  
# face - the filename of the face set to use
# expr - facial expression (0-7, default is 0)
# pos - the position of the face (default is 0)
# mir? - set to true to mirror the face graphic. Default is false
# num - set default value of facial expression index
#
#
#                     * ======== CHANGE A FACE ======== *
#             $scene.change_face(pos, new expr, new file, mirror)
#* NOTES
# pos - refers to the current position of the face being modified.
# new expr - new facial exp​ression to use.
# new file - new face graphic to use, nil to keep.
# mirror - 'Mirror new face?' Default is false.
#
#
#                   * ======== REPOSITION A FACE ======== *
#                      $scene.move(pos, new pos, pause)
#* NOTES
# pos - refers to the current position of the face being modified.
# new pos - refers to the destination position.
# pause - 'Pause interpreter while moving face?' Default is false.
#
#
#                    * ======== HOPPING EFFECT ======== *
#                  $scene.hop(pos, scale, count, dir, pause)
#* NOTES
# pos - refers to the current position of the face being modified.
# scale - how fast and high the face hops (scale of 1-10). Default is 5.
# count - how many times to make the face jump (scale of 1-5). Default is 1
# dir - direction of the jump ("up", "down", "left", "right"). Default is "up"
# pause - 'Pause interpreter while moving face?' Default is false.
#
#
#                    * ======== POPPING EFFECT ======== *
#                        $scene.pop(pos, scale, pause)
#*NOTES
# pos - refers to the current position of the face being modified.
# scale - how fast and wide the face pops (scale of 1-5). Default is 3.
# pause - 'Pause interpreter while moving face?' Default is false.
#
#
#                    * ======== SHAKING EFFECT ======== *
#                    $scene.shake(pos, scale, axis, pause)
#* NOTES
# pos - refers to the current position of the face being modified.
# scale - how fast the face shakes (scale of 1-10). Default is 5.
# axis - plane of shake "x" or "y" (horizontal or vertical). Default is "x".
# pause - 'Pause interpreter while moving face?' Default is false.
#============================================================================= #

module Skits
  YOLINA_CAVE = ["I'm ... err ... not nfraid!", 101, false, false]
  THE_REASON = ["The reason why I decided to stay", 102, false, false]
  # Append skits here
  # NOTE: MUST BE ALL CAPS
  
  
end

#==============================================================================
# * END CONFIGURATION ZONE
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
# The instance of this class is referenced by $game_temp.
#==============================================================================
class Game_Temp
  attr_accessor :newskit                  # new skit available flag
  attr_accessor :skit_beep                # play SE flag
  attr_accessor :last_bgm                 # memory of the last bgm played
  attr_accessor :last_bgs                 # memory of the last bgs played
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias n543_init initialize
  def initialize
    n543_init
    @skit_beep = false
    @newskit   = false
    @last_bgm  = nil
    @last_bgs  = nil
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Get Skit BGM (N5)
  #--------------------------------------------------------------------------
  def skit_bgm
    if @skit_bgm == nil
      return N5::Skit_BGM
    else
      return @skit_bgm
    end
  end
  #--------------------------------------------------------------------------
  # * Set Skit BGM (N5)
  #     skit_bgm : new BGM
  #--------------------------------------------------------------------------
  def skit_bgm=(skit_bgm)
    @skit_bgm = skit_bgm
  end
end
#==============================================================================
# ** Game_Skit
#------------------------------------------------------------------------------
#  This class handles Skit variables. It includes the data of available and
# watched skits in addition to their names.
#==============================================================================
class Game_Skit
  attr_accessor   :skits
  attr_accessor   :watched
  attr_accessor   :names
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     skits : Current skits in list
  #   watched : Skits that have been watched (for displaying 'new' icon)
  #     names : Names to display for skit menu
  #--------------------------------------------------------------------------
  def initialize
    @skits   = []
    @watched = []
    @names   = []
    @skit_count_old = @skits.size
  end
  #--------------------------------------------------------------------------
  # * New Skits Available
  #--------------------------------------------------------------------------
  def new_skits?
    return true if @skits.size > @skit_count_old
  end
end

#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
#  An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
  #--------------------------------------------------------------------------
  # * Event Setup
  #     list     : list of event commands
  #     event_id : event ID
  #--------------------------------------------------------------------------
  alias n543_setup setup
  def setup(list, event_id = 0)
    n543_setup(list, event_id)
    @pause = false
  end
  #--------------------------------------------------------------------------
  # * Get Pause state
  #--------------------------------------------------------------------------
  def pause
    return @pause
  end
  #--------------------------------------------------------------------------
  # * Set Pause state
  #--------------------------------------------------------------------------
  def pause=(pause)
    @pause = pause
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    loop do
      if $game_map.map_id != @map_id        # Map is different?
        @event_id = 0                       # Make event ID 0
      end
      if @child_interpreter != nil          # If child interpreter exists
        @child_interpreter.update           # Update child interpreter
        if @child_interpreter.running?      # If running
          return                            # Return
        else                                # After execution has finished
          @child_interpreter = nil          # Erase child interpreter
        end
      end
      if @message_waiting                   # Waiting for message finish
        return
      end
      if @pause == true
        return
      end
      if @moving_character != nil           # Waiting for move to finish
        if @moving_character.move_route_forcing
          return
        end
        @moving_character = nil
      end
      if @wait_count > 0                    # Waiting
        @wait_count -= 1
        return
      end
      if $game_troop.forcing_battler != nil # Forcing battle action
        return
      end
      if $game_temp.next_scene != nil       # Opening screens
        return
      end
      if @list == nil                       # If content list is empty
        setup_starting_event if @main       # Set up starting event
        return if @list == nil              # Nothing was set up
      end
      return if execute_command == false    # Execute event command
      @index += 1                           # Advance index
    end
  end
end

#==============================================================================
# ** Window_Message
#------------------------------------------------------------------------------
#  This message window is used to display text.
#==============================================================================

class Window_Message < Window_Selectable
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, Graphics.height - 128, Graphics.width, 128)
    self.z          = 200
    self.active     = false
    self.index      = -1
    self.openness   = 0
    @opening        = false     # WIndow opening flag
    @closing        = false     # Window closing flag
    @text           = nil       # Remaining text to be displayed
    @contents_x     = 0         # X coordinate for drawing next character
    @contents_y     = 0         # Y coordinate for drawing next character
    @line_count     = 0         # Line count drawn up until now
    @wait_count     = 0         # Wait count
    @background     = 0         # Background type
    @position       = 2         # Display position
    @show_fast      = false     # Fast forward flag
    @line_show_fast = false     # Fast forward by line flag
    @pause_skip     = false     # Input standby omission flag
    create_gold_window
    create_number_input_window
    create_back_sprite
  end
  #--------------------------------------------------------------------------
  # * Set Window Background and Position
  #--------------------------------------------------------------------------
  alias n543_rw reset_window
  def reset_window
    n543_rw
    case @position
    when 0  # Top
      self.y         = 0
      @gold_window.y = 360
    when 1  # Middle
      self.y         = (Graphics.height / 2) - (128 / 2)
      @gold_window.y = 0
    when 2  # Bottom
      self.y         = (Graphics.height - 128)
      @gold_window.y = 0
    end
  end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
#  This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================

class Spriteset_Map
  attr_accessor    :viewport1
  attr_accessor    :viewport2
  attr_accessor    :viewport3
end
#==============================================================================
# ** Window_SkitCommand
#------------------------------------------------------------------------------
#  Similar to 'Menu_Command' but changed to adapt separate functionality for the
# skit system.
#==============================================================================
class Window_SkitCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader   :commands                 # command
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     width      : window width
  #     commands   : command string array
  #     align      : alignment (0 left, 1 center, 2 right)
  #     column_max : digit count (if 2 or more, horizontal selection)
  #     row_max    : row count (0: match command count)
  #     spacing    : blank space when items are arrange horizontally
  #--------------------------------------------------------------------------
  def initialize(commands, align = 1, column_max = 1, row_max = 13, spacing = 32)
    if row_max == 0
      row_max   = (commands.size + column_max - 1) / column_max
    end
    super(16,16,Graphics.width-32, Graphics.height-32, spacing)
    @align      = align
    @commands   = commands
    @item_max   = commands.size
    @column_max = column_max
    refresh
    self.index  = 0
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index   : item number
  #     enabled : enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_item(index, enabled = true)
    if N5::New_Skit_Icon != "" or nil
      rect        = item_rect(index)
      rect.x     += 4
      rect.width -= 8
      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
      unless @commands[index] == ""
        self.contents.blt(4, index * 24, Cache.system(N5::New_Skit_Icon), Rect.new(0, 0, 24, 24))
      end
      rect2        = item_rect(index)
      rect2.x     += 28
      rect2.width -= 8
      self.contents.clear_rect(rect2)
      self.contents.draw_text(rect2, @commands[index], @align)
    else
      rect = item_rect(index)
      rect.x     += 4
      rect.width -= 8
      self.contents.clear_rect(rect)
      if $game_skit.watched.include?($game_skit.skits[index])
        self.contents.font.italic = false
        self.contents.font.bold   = false
      else
        self.contents.font.italic = true
        self.contents.font.bold   = true
      end
      self.contents.draw_text(rect, @commands[index], @align)
    end
  end
  def change_array_size(new_size)
    @item_max = new_size
  end
  def change_command(old_index, new_data, now_enabled = true)
    if @commands[old_index] == nil
      @commands.push new_data
    else
      @commands[old_index] = new_data
    end
    draw_item(old_index, now_enabled)
    refresh
  end
  def delete_command(delete)
    @commands[delete] = ""
    refresh
  end
end

#==============================================================================
# ** Scene_Base
#------------------------------------------------------------------------------
#  This is a superclass of all scenes in the game.
#==============================================================================
class Scene_Base
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    if !$scene.is_a?(Scene_Map)
      if @button_sprite != nil
        @button_sprite.dispose
      end
      if @skit_text != nil
        @skit_text.dispose
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    if $scene.is_a?(Scene_Map)
      compare_watched
      unless $game_message.visible      # Unless displaying a message
        update_call_skit
        update_skit_text unless $game_temp.newskit == false or @skit_text == nil
        update_skit_button unless $game_temp.newskit == false or @button_sprite == nil
        @button_sprite.dispose if @button_sprite != nil and $game_switches[N5::Hide_Btn]
        @skit_text.dispose if @skit_text != nil and $game_switches[N5::Hide_Txt]
      end
    end
  end
  #--------------------------------------------------------------------------
  # * N5 Create Menu BG
  #--------------------------------------------------------------------------
  def create_menu_bg_lite(lite = false)
    @menuback_sprite = Sprite.new
    @menuback_sprite.bitmap = $game_temp.background_bitmap
    unless !lite
      @menuback_sprite.color.set(16, 16, 16, 128)
    end
    update_menu_background
  end
end

#==============================================================================
# ** Scene_Title
#------------------------------------------------------------------------------
#  This class performs the title screen processing.
#==============================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Game Objects
  #--------------------------------------------------------------------------
  alias n5_create_game_objects create_game_objects
  def create_game_objects
    n5_create_game_objects
    $game_skit          = Game_Skit.new
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs the map screen processing.
#==============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  # * N5 Update Call Skit
  #--------------------------------------------------------------------------
  def update_call_skit
    return unless $game_temp.newskit == true
    if Input.trigger?(N5::Skit_Activate)
      $game_temp.skit_beep = true                     # Set SE play flag
      $game_temp.next_scene = "skit"
    end
  end
  #--------------------------------------------------------------------------
  # * N5 Compare Watched Skits
  #--------------------------------------------------------------------------
  def compare_watched
    if $game_skit.skits.size > 0
      for i in 0..$game_skit.skits.size - 1
        if $game_skit.watched.include?($game_skit.skits[i])
          next
        else
          @skit = $game_skit.skits[i]
          $game_temp.newskit = true
          create_skit_text unless $game_switches[N5::Hide_Txt] or @skit_text != nil
          create_skit_button unless $game_switches[N5::Hide_Btn] or @skit_button != nil
          break
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Execute Screen Switch
  #--------------------------------------------------------------------------
  def update_scene_change
    return if $game_player.moving?    # Is player moving?
    case $game_temp.next_scene
    when "battle"
      call_battle
    when "shop"
      call_shop
    when "name"
      call_name
    when "menu"
      call_menu
    when "save"
      call_save
    when "debug"
      call_debug
    when "gameover"
      call_gameover
    when "title"
      call_title
    when "skit"
      call_skit
    else
      $game_temp.next_scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # * N5 Call Skit
  #--------------------------------------------------------------------------
  def call_skit
    if $game_temp.skit_beep
      Sound.play_decision
      $game_temp.skit_beep = false
    end
    @spriteset.update
    Graphics.update
    $game_player.straighten
    $game_temp.next_scene = nil
    $scene = Scene_Skit.new(@skit)
  end
  #--------------------------------------------------------------------------
  # * N5 New Skit
  #     skit : new skit to add (from Skits module)
  #--------------------------------------------------------------------------
  def new_skit(skit)
    @skit = skit                                # Inherit parameter
                                                # Add skit name unless it has already exists
    $game_skit.names.push(@skit[0]) unless $game_skit.skits.include?(@skit)
    # If added skit is manditory, player is on map, and skit doesn't exist
    if @skit[2] == true and $scene.is_a?(Scene_Map) and !$game_skit.skits.include?(@skit)
      @spriteset.update                         # Run a quick update like
      Graphics.update                           #  update from transfer player
      $game_player.straighten                   #  call.
      $game_skit.skits.push(@skit)              # Add skit to que
      $scene = Scene_Skit.new(@skit)            # Run manditory skit
    else       # conditions not met
                                                # Add skit if it hasn't been already
      $game_skit.skits.push(@skit) unless $game_skit.skits.include?(@skit)
    end        # end if
  end          # end def
  #--------------------------------------------------------------------------
  # * N5 Create Skit Text
  #--------------------------------------------------------------------------
  def create_skit_text
    @skit_text        = Sprite.new(@spriteset.viewport3)  # Create skit text sprite
    @skit_text.bitmap = Bitmap.new(120, 32)               # Create skit text bitmap
    
    # Align sprite
    @skit_text.x      = Graphics.width - @skit_text.width - 4
    @skit_text.y      = Graphics.height - @skit_text.height + 4
    @skit_text.z      = 900
    
    @skit_text.bitmap.draw_text(0, 0, 120, 32, get_unwatched, 2)
  end          # end def
  #--------------------------------------------------------------------------
  # * N5 Create Skit Button
  #--------------------------------------------------------------------------
  def create_skit_button
    return if @button_sprite != nil or $game_temp.newskit == false or $game_switches[N5::Hide_Btn]
    
    @file = Dir.entries("Graphics/System")      # Set file to files in folder
    for i in 0...@file.size                     # Number of files in /System
      if @file[i] =~ /(skit(.)(b?)utton)/i      # "Skit button" Regex
        @file = @file[i]                        # Set file to Regex match
        break  # break for
      end      # end if
    end        # end for
    
    # Regex get frame count from file name and convert to integer; or 1
    @anim_frames = (/\#(\d+)/.match(@file) ? Regexp.last_match(1).to_i  : 1)
    @button_sprite = Sprite.new(@spriteset.viewport3)   # Create button sprite
    @button_sprite.bitmap = Cache.system(@file)         # Load sprite bitmap
    
    if @anim_frames > 1      # Split bitmap by number of frames if frames > 1
      @button_sprite.src_rect.set(0, 0, @button_sprite.bitmap.width / @anim_frames, @button_sprite.bitmap.height)
    end        # end if
    
    # Align sprite
    @button_sprite.x = Graphics.width - @button_sprite.width
    @button_sprite.y = Graphics.height - @button_sprite.height - (@skit_text != nil ? 24 : 0)
    @button_sprite.z = 900
  end
  #--------------------------------------------------------------------------
  # * N5 Update Skit Text
  #--------------------------------------------------------------------------
  def update_skit_text
    @skit_text.bitmap.clear
    @skit_text.bitmap.draw_text(0, 0, 120, 32, get_unwatched, 2)
  end
  #--------------------------------------------------------------------------
  # * N5 Update Skit Button
  #--------------------------------------------------------------------------
  def update_skit_button
    @button_sprite.update                       # Update prior to animation check
    return unless @anim_frames > 1              # Return if no frames to cycle
    
    if N5::Anim_Rate == 0                       # Prevent 0 division
      @index = (Graphics.frame_count % ((@anim_frames - 1) * 2)) - (@anim_frames - 1)
    else       # Not dividing by 0
      @index = ((Graphics.frame_count / N5::Anim_Rate) % ((@anim_frames - 1) * 2)) - (@anim_frames - 1)
    end        # end if

    @button_sprite.src_rect.x = (@index.abs * @button_sprite.width) # new frame
    @button_sprite.update                       # Update picture
  end          # end def
  #--------------------------------------------------------------------------
  # * N5 Get Unwatched Skit Names
  #--------------------------------------------------------------------------
  def get_unwatched
    for i in 0...$game_skit.watched.size        # Number of watched skits
      @return[i] = $game_skit.watched[i][0]     # Set to watched names
    end        # end for
    
    if @return == nil        # Return from $game_skit if no watched skits
      return $game_skit.names[$game_skit.names.size - 1]
    end        # end if
    
    @return = $game_skit.names - @return        # Remove watched skits
    return @return[@return.size - 1]            # Return newest skit name
  end          # end def
end            # end class

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================
class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Create Command Window
  #--------------------------------------------------------------------------
  def create_command_window
    s1 = Vocab::item
    s2 = Vocab::skill
    s3 = Vocab::equip
    s4 = Vocab::status
    s5 = N5::Skits_Term  # N5
    s6 = Vocab::save
    s7 = Vocab::game_end
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6, s7]) # N5
    @command_window.index = @menu_index
    if $game_party.members.size == 0          # If number of party members is 0
      @command_window.draw_item(0, false)     # Disable item
      @command_window.draw_item(1, false)     # Disable skill
      @command_window.draw_item(2, false)     # Disable equipment
      @command_window.draw_item(3, false)     # Disable status
    end
    if $game_skit.skits.size <= 0             # If no playable skits
      @command_window.draw_item(4, false)     # Disable skit
    end
    if $game_system.save_disabled             # If save is forbidden
      @command_window.draw_item(5, false)     # Disable save
    end
  end
  #--------------------------------------------------------------------------
  # * Update Command Selection
  #--------------------------------------------------------------------------
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      if $game_party.members.size == 0 and @command_window.index < 4
        Sound.play_buzzer
        return
      elsif $game_skit.skits.size <= 0 and @command_window.index == 4 #N5
        Sound.play_buzzer
        return
      elsif $game_system.save_disabled and @command_window.index == 5
        Sound.play_buzzer
        return
      end
      Sound.play_decision
      case @command_window.index
      when 0      # Item
        $scene = Scene_Item.new
      when 1,2,3  # Skill, equipment, status
        start_actor_selection
      when 4      # N5
        $scene = Scene_Skit.new(nil, true)
      when 5      # Save
        $scene = Scene_File.new(true, false, false)
      when 6      # End Game
        $scene = Scene_End.new
      end
    end
  end
end

#==============================================================================
# ** Scene_Skit
#------------------------------------------------------------------------------
#  This class performs the basic Skit Processing.
#==============================================================================
class Scene_Skit < Scene_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(skit = nil, from_menu = false)
    @skit = skit unless skit == nil
    @from_menu = from_menu
    if !@from_menu
      @run_skit = true
    end
    @face_array = []
    @name_array = []
    @moving_face = []
    @number = -1
    @dest_x = []
    @dest_y = []
    @x = []
    @y = []
    @duration = []
    @count = []
    @zoom = []
  end
  #--------------------------------------------------------------------------
  # * Start processing
  #--------------------------------------------------------------------------
  def start
    super
    create_menu_bg_lite(@from_menu)
    @message_window = Window_Message.new
    case @run_skit
    when true
      create_skit_interface
      if @skit[3]
        $game_temp.last_bgm = RPG::BGM.last
        $game_temp.last_bgs = RPG::BGS.last
        RPG::BGM.stop
        RPG::BGS.stop
      end
      run_skit
    when false
      create_skit_window
    end
  end
  #--------------------------------------------------------------------------
  # * Termination Processing
  #--------------------------------------------------------------------------
  def terminate
    super
    dispose_menu_background
    @message_window.dispose
    if @run_skit
      @skit_interface.dispose  
    else
      if @skit_window != nil
        @skit_window.dispose
      end
    end
    if @face_array != []
      @face_array.clear
      @name_array.clear
      @moving_face.clear
      @dest_x.clear
      @dest_y.clear
      @duration.clear
    end
    unless $game_temp.last_bgm == nil
      RPG::BGM.fade(20)
      RPG::BGS.fade(20)
      $game_temp.last_bgm.play
      $game_temp.last_bgs.play
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    update_menu_background
    @message_window.update
    if @run_skit
      @skit_interface.update
    else
      unless @skit_window != nil
        create_skit_window
      else
        @skit_window.update
        update_skit_selection
      end
    end
    if @moving_face.nitems == 0 and $game_map.interpreter.pause != true
      $game_map.interpreter.update
    end
    if !$game_map.interpreter.running? and @run_skit
      $game_temp.newskit = false
      $scene = Scene_Skit.new(nil, true)
    end
    if @moving_face.nitems > 0
      update_move_face
    end
  end
  #--------------------------------------------------------------------------
  # * Create Skit Window
  #--------------------------------------------------------------------------
  def create_skit_window
    @skit_window = Window_SkitCommand.new($game_skit.names)
  end
  #--------------------------------------------------------------------------
  # * Create Skit Interface
  #--------------------------------------------------------------------------
  def create_skit_interface
    @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
    @skit_interface = Sprite.new(@viewport1)
    @skit_interface.bitmap = Cache.system(N5::Skit_BG)
    @skit_interface.bitmap.blur
    @skit_interface.x = 0
    @skit_interface.y = 0
    @skit_interface.z = 100
  end
  #--------------------------------------------------------------------------
  # * Run Skit
  #--------------------------------------------------------------------------
  def run_skit
    if @skit[3]
      Audio.bgm_play("Audio/BGM/" + $game_system.skit_bgm, 100, 100)
    end
    $game_map.interpreter.setup($data_common_events[@skit[1]].list, 0)
    $game_skit.watched.push(@skit)
  end
  #--------------------------------------------------------------------------
  # * Add New Face
  #--------------------------------------------------------------------------
  def new_face(face_name, expr = 0, pos = 0, mirror = false, num = @face_array.size)
    if space_empty?(pos)
      @face_array[num] = Sprite.new(@viewport1)
      @face_array[num].bitmap = Bitmap.new(96,120)
      bitmap = Cache.face(face_name)
      rect = Rect.new(0, 0, 0, 0)
      rect.x = expr % 4 * 96 + (0) / 2
      rect.y = expr / 4 * 120 + (0) / 2
      rect.width = 96
      rect.height = 120
      @face_array[num].bitmap.blt(0, 0, bitmap, rect)
      @face_array[num].x = pos.is_a?(Array) ? pos[0] : N5::SKIT_POS[pos][0]
      @face_array[num].y = pos.is_a?(Array) ? pos[1] : N5::SKIT_POS[pos][1]
      @face_array[num].z = 200
      @face_array[num].mirror = mirror
      @name_array[num] = face_name
      @dest_x[num] = nil
      @dest_y[num] = nil
      bitmap.dispose
    end
  end
  #--------------------------------------------------------------------------
  # * Get face number
  #--------------------------------------------------------------------------
  def get_face_num(o)
    for i in 0...@face_array.size
      if (@face_array[i].x == N5::SKIT_POS[o][0]) and (@face_array[i].y == N5::SKIT_POS[o][1])
        @num = i
        return @num
      elsif (o.is_a?(Array) and (@face_array[i].x == o[0] and @face_array[i].y == o[1]))
        @num = i
        return @num
      end
    end
    raise StandardError, "Position #{o} is un-occupied!"
  end
  #--------------------------------------------------------------------------
  # * Change Face
  #     o      : Face position
  #     expr   : New face expression
  #     file   : New face graphic
  #     mirror : Mirror face?
  #--------------------------------------------------------------------------
  def change_face(o, expr, file = nil, mirror = false)
    @id = get_face_num(o)
    if file != nil and @name_array[@id] != file
      bitmap = Cache.face(file)
      @name_array[@number] = file
    else
      bitmap = Cache.face(@name_array[@id])
    end
    rect = Rect.new(0, 0, 0, 0)
    rect.x = expr % 4 * 96 + (0) / 2
    rect.y = expr / 4 * 120 + (0) / 2
    rect.width = 96
    rect.height = 120
    @face_array[@id].bitmap.clear
    @face_array[@id].bitmap.blt(0, 0, bitmap, rect)
    bitmap.dispose
    @face_array[@id].mirror = mirror
  end
  #--------------------------------------------------------------------------
  # * Move Face
  #     o       : Face position
  #     new_o   : New face position
  #     pause   : Pause interpreter while moving?
  #--------------------------------------------------------------------------
  def move_face(o, new_o, pause = false)
    verify_new(new_o)
    @new_orig = new_o.is_a?(Array) ? new_o : N5::SKIT_POS[new_o]
    @number = @id
    if N5::SKIT_POS[o] != @new_orig and (new_o.is_a?(Array) ? true : space_empty?(new_o))
      @dest_x[@number] = @new_orig[0].to_f
      @dest_y[@number] = @new_orig[1].to_f
      @duration[@number] = N5::SKIT_POS.has_value?(@new_orig) ? 45 : 50
      @moving_face[@number] = true
      $game_map.interpreter.pause = pause
    end
  end
  #--------------------------------------------------------------------------
  # * Hop Face
  #     o     : Face position
  #     scale : Hop strength (1-10)
  #     count : Hop count    (1-5)
  #     dir   : Direction of hop: "up", "down", left", "right"
  #     pause : Pause interpreter while hopping?
  #--------------------------------------------------------------------------
  def hop(o, scale = 5, count = 1, dir = "up", pause = false)
    @id = get_face_num(o)
    if scale < 1                                  # If scale is out of range
      scale = 1                                   # Adjust
    elsif scale > 10    
      scale = 10                                  # Adjust
    end      # end if
    if count < 1                                  # If count is out of range
      count = 1                                   # Adjust
    elsif count > 5
      count = 5                                   # Adjust
    end      # end if
    
    @count[@id] = count * 2                       # Localize count
    @x[@id] = @face_array[@id].x                  # Store old x
    @y[@id] = @face_array[@id].y                  # Store old y
        
    case dir.downcase
    when "up"
      @dest_y[@id] = (@face_array[@id].y - scale * 4).to_f
      @dest_x[@id] = (@face_array[@id].x).to_f
    when "down"
      @dest_y[@id] = (@face_array[@id].y + scale * 4).to_f
      @dest_x[@id] = (@face_array[@id].x).to_f
    when "left"
      @dest_x[@id] = (@face_array[@id].x - scale * 4).to_f
      @dest_y[@id] = (@face_array[@id].y).to_f
    when "right"
      @dest_x[@id] = (@face_array[@id].x + scale * 4).to_f
      @dest_y[@id] = (@face_array[@id].y).to_f
    else
      raise StandardError, "Not a valid direction!\nGiven #{dir.downcase}, required up/down/left/right"
    end
    
    @duration[@id] = (scale * 2 - 24).abs
    @moving_face[@id] = "hopping"                 # Set face to hop
    $game_map.interpreter.pause = pause
  end
  #--------------------------------------------------------------------------
  # * Pop Face
  #     obj   : Face object
  #     scale : Pop strength (1-5)
  #     pause : Pause interpreter while popping?
  #--------------------------------------------------------------------------
  def pop(obj, scale = 3, pause = false)
    @id = get_face_num(obj)
    if scale < 1                                  # If scale is out of range
      scale = 1                                   # Adjust
    elsif scale > 5    
      scale = 5                                   # Adjust
    end      # end if
        
    @x[@id]       = @face_array[@id].x            # Store x
    @y[@id]       = @face_array[@id].y            # Store y
    
    @duration[@id]    = {1 => 9, 2 => 8, 3 => 7, 4 => 6, 5 => 5}[scale]
    @moving_face[@id] = "popping"                 # Set face to shake
    @zoom[@id]        = 0.4
    $game_map.interpreter.pause = pause
  end
  #--------------------------------------------------------------------------
  # * Shake Face
  #     o     : Face position
  #     scale : Shake strength (1-10)
  #     axis  : Axis of shake: ("vertical", "horizontal")
  #     pause : Pause interpreter while shaking?
  #--------------------------------------------------------------------------
  def shake(o, scale = 5, axis = "x", pause = false)
    @id = get_face_num(o)
    if scale < 1                                  # If scale is out of range
      scale = 1                                   # Adjust
    elsif scale > 10    
      scale = 10                                  # Adjust
    end      # end if
    
    @count[@id]   = -scale                        # Setup shake counter
    @x[@id]       = @face_array[@id].x            # Store old x
    @y[@id]       = @face_array[@id].y            # Store old y
    
    case axis.downcase
    when "x"
      @dest_x[@id] = [(@face_array[@id].x + scale + 22).to_f, (@face_array[@id].x + scale - 22).to_f]
      @dest_y[@id] = (@face_array[@id].y).to_f
    when "y"
      @dest_y[@id] = [(@face_array[@id].y + scale + 22).to_f, (@face_array[@id].x + scale - 22).to_f]
      @dest_x[@id] = (@face_array[@id].x).to_f
    else
      raise StandardError, "Not a valid axis!\nGiven #{axi.downcase}, required x/y"
    end
    
    @duration[@id] = (scale * 5 - 60).abs
    @moving_face[@id] = "shaking"                 # Set face to shake
    $game_map.interpreter.pause = pause
  end

  #--------------------------------------------------------------------------
  # * Dispose Face
  #--------------------------------------------------------------------------
  def dispose_face(o)
    for i in 0..@face_array.size - 1
      if @face_array[i] != nil and (@face_array[i].x == N5::SKIT_POS[o][0].to_f) and (@face_array[i].y == N5::SKIT_POS[o][1].to_f)
        @face_array[i].dispose
        @face_array.delete_at(i)
        @name_array.delete_at(i)
        @moving_face.delete_at(i)
        @dest_x.delete_at(i)
        @dest_y.delete_at(i)
        @duration.delete_at(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Face
  #--------------------------------------------------------------------------
  def update_move_face
    for i in 0..@face_array.size - 1
      unless @duration[i] == nil
        case @moving_face[i]
        when "hopping"
          if @d == 0 or @d == nil
            @d = @duration[i]
          elsif @d >= 1
            @face_array[i].x = (@face_array[i].x * (@d - 1) + @dest_x[i]) / @d
            @face_array[i].y = (@face_array[i].y * (@d - 1) + @dest_y[i]) / @d
            @d -= 1
          end
          if (@face_array[i].x == @dest_x[i]) and (@face_array[i].y == @dest_y[i])
            if @count[i] >= 2
              @dest_x[i] = @x[i]
              @dest_y[i] = @y[i]
              @x[i]      = @face_array[i].x
              @y[i]      = @face_array[i].y
              @count[i] -= 1
            else  # Done hopping
              @dest_x[i] = nil
              @dest_y[i] = nil
              @moving_face[i] = nil
              $game_map.interpreter.pause = false
              break
            end
          end
        when "shaking"
          if @d == 0 or @d == nil
            @d = @duration[i] / 4
          elsif @d >= 1
            @face_array[i].x = (@face_array[i].x * (@d - 1) + (@dest_x[i].is_a?(Array) ?
                                                               @dest_x[i][(@count[i]%2)] :
                                                               @dest_x[i])) / @d
            @face_array[i].y = (@face_array[i].y * (@d - 1) + (@dest_y[i].is_a?(Array) ?
                                                               @dest_y[i][(@count[i]%2)] :
                                                               @dest_y[i])) / @d
            @d -= 1
          end    
          if(@face_array[i].x == (@dest_x[i].is_a?(Array) ? @dest_x[i][(@count[i]%2)] : @dest_x[i])) and
            (@face_array[i].y == (@dest_y[i].is_a?(Array) ? @dest_y[i][(@count[i]%2)] : @dest_y[i]))
            if @count[i] <= 0
              @count[i] += 1
            elsif @count[i] <= 1 # Done shaking
              @count[i] += 1
              (@dest_x[i].is_a?(Array) ? @dest_x[i][(@count[i]%2)] = @x[i] : @dest_x[i] = @x[i])
              (@dest_y[i].is_a?(Array) ? @dest_y[i][(@count[i]%2)] = @y[i] : @dest_y[i] = @y[i])
            else # Done returning
              @dest_x[i] = nil
              @dest_y[i] = nil
              @moving_face[i] = nil
              $game_map.interpreter.pause = false
              break
            end
          end
        when "popping"
          if @d == 0 or @d == nil
            @d = @duration[i]
          elsif @d >= 1
            @face_array[i].zoom_x = (@face_array[i].zoom_x * (@d - 1) + (1.0 + @zoom[i])) / @d
            @face_array[i].zoom_y = (@face_array[i].zoom_y * (@d - 1) + (1.0 + @zoom[i])) / @d
            @d -= 1
            a =
            @face_array[i].x = (@x[i] - (@face_array[i].width.to_f * (@face_array[i].zoom_x - 1.0)) / 2).ceil
            @face_array[i].y = (@y[i] - (@face_array[i].height.to_f * (@face_array[i].zoom_y - 1.0)) / 2).ceil
          end  
          if ((@face_array[i].zoom_x and @face_array[i].zoom_y  == 1.0 + @zoom[i]) and (@zoom[i] == 0))
            @zoom[i] = nil
            @moving_face[i] = nil
            $game_map.interpreter.pause = false
            break
          elsif (@face_array[i].zoom_x and @face_array[i].zoom_y ==  1.0 + @zoom[i])
            @zoom[i] = 0 #-= 0.5
          end
        when true # Regular movement
          if @duration[i] >= 1
            d = @duration[i]
            @face_array[i].x = (@face_array[i].x * (d - 1) + @dest_x[i]) / d
            @face_array[i].y = (@face_array[i].y * (d - 1) + @dest_y[i]) / d
            @duration[i] -= 1
          end
          if (@face_array[i].x == @dest_x[i]) and (@face_array[i].y == @dest_y[i])
            @dest_x[i] = nil
            @dest_y[i] = nil
            @moving_face[i] = nil
            $game_map.interpreter.pause = false
            break
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Verify Position
  #--------------------------------------------------------------------------
  def verify_new(o)
    case o
    when Array
      return
    when 0..18
      return
    else
      raise IndexError,"Not a valid index!\nGiven #{o} required 0-18 or array."
    end
  end
  #--------------------------------------------------------------------------
  # * Space Empty?
  #--------------------------------------------------------------------------
  def space_empty?(pos)
    for i in 0..@face_array.size - 1
      if (@face_array[i].x == N5::SKIT_POS[pos][0].to_f) and (@face_array[i].y == N5::SKIT_POS[pos][1].to_f)
        if @moving_face[i]
          return true
        else
          print("IndexError\nPosition index #{pos} is currently occupied!")
        end
      else
        return true
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Update Skit Selection
  #--------------------------------------------------------------------------
  def update_skit_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Menu.new(4)
    elsif Input.trigger?(Input::C)
      $scene = Scene_Skit.new($game_skit.skits[@skit_window.index], false)
    end
  end
end

#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
#  This class performs the save and load screen processing.
#==============================================================================

class Scene_File < Scene_Base
  #--------------------------------------------------------------------------
  # * Write Save Data
  #     file : write file object (opened)
  #--------------------------------------------------------------------------
  alias n543_wsd write_save_data
  def write_save_data(file)
    n543_wsd(file)
    Marshal.dump($game_skit, file)
  end
  #--------------------------------------------------------------------------
  # * Read Save Data
  #     file : file object for reading (opened)
  #--------------------------------------------------------------------------
  alias n543_rsd read_save_data
  def read_save_data(file)
    n543_rsd(file)
    $game_skit = Marshal.load(file)
  end
end



This post has been edited by EvilEagles: Sep 16 2011, 04:37 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 16 2011, 09:57 AM
Post #17


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




You put documentation into my script?! Awesome, thanks Evil eagles! The only reason why I didn't put all that in mine was because it'd take up a whole bunch of extra lines; but now people can choose extra documentation or not! XD


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
EvilEagles
post Sep 19 2011, 04:12 AM
Post #18


Level 3
Group Icon

Group: Member
Posts: 39
Type: Developer
RM Skill: Beginner




Found another irritating bug >.<
this one is kinda hard to explain, please check out the demo sad.gif no viruses I swear sad.gif just talk to the 2 NPCs
http://www.mediafire.com/?62o2nh0td6ctcfr
Edit: Sorry I forgot to include the two NPCs' sprites, but actually they're just right next to character's starting position, left and right

This post has been edited by EvilEagles: Sep 19 2011, 04:17 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Night5h4d3
post Sep 19 2011, 06:23 AM
Post #19


The past tense
Group Icon

Group: +Gold Member
Posts: 1,199
Type: Scripter
RM Skill: Undisclosed




I sent you a PM regarding a resolution to your problem, can't find much wrong other than one of the events' code is still written up for v4.6.01.


__________________________
Got 30 minutes? Then you've enough time to play this awesome game:

- potentially promising project page
- thanks holder
My growing space of user-bars:

about me:







I made the following!





Go to the top of the page
 
+Quote Post
   
bazbroketail
post Sep 29 2011, 04:25 PM
Post #20


Level 3
Group Icon

Group: Member
Posts: 34
Type: None
RM Skill: Undisclosed




First off I wanted to say that I absolutely love this script. I loved the skit scenes in the Tales games, and this script makes any game now much more interesting and fun.

Secondly, I do have one question. I was wondering if there was a way, so that after you have watched a skit, for the screen to return to the game screen, instead of going to scene to either re-watch the skit or watch a different one. I am not having the skits in my menu, and I didn't want to have the skits re-watchable after watching them the first time. Is there a way to change that or turn that feature off and be able to make it available later on in the game? For instance, like in Tales of Vesperia, you watch a skit, but then you can't re-watch the skit until you get to that carnival island place.

Anyways, great job on this script though. Very well done.
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 18th May 2013 - 12:06 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker