The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on September 03, 2009, 08:17:27 PM

Title: Learn Skill Sound Effect
Post by: modern algebra on September 03, 2009, 08:17:27 PM
Learn Skill Sound Effect
Version: 1.0
Author: modern algebra
Date: September 3, 2009

Version History



Description


This script will play an SE when levelling if the actor has learned any new skills.

Features


Instructions

Place this script above Main and below Materials. If you wish to change the SE that plays, scroll down to line 30 and read the instructions located there.

Script


Code: [Select]
#==============================================================================
#    Learn Skill Sound Effect
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: September 3, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    
#    This script will play an SE when levelling if the actor has learned any
#   new skills.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials.
#
#    If you wish to change the SE that plays, scroll down to line 30 and read
#   the instructions located there.
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - LSSE_LEARN_SKILL_SE
#    aliased method - display_level_up
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Class Constants
  #``````````````````````````````````````````````````````````````````````````
  #  LSSE_LEARN_SKILL_SE - an array holding the name, volume, and pitch of
  # the SE to be played when learning a new skill through level up. The
  # format is:
  #
  #      ["se_name", se_volume, se_pitch]
  #          se_name : the name of the file to be played. This must be there.
  #          se_volume : the volume of the SE to be played. If left blank, it
  #            defaults to 100
  #          se_pitch : the pitch of the SE to be played. If left blank, it
  #            defaults to 100
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LSSE_LEARN_SKILL_SE = ["Up", 80]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Show Level Up Message
  #     new_skills : Array of newly learned skills
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgb_zero_se_skilllearn_lvlup_8kb3 display_level_up
  def display_level_up(new_skills, *args)
    # Play SE unless no new skills passed
    RPG::SE.new (*LSSE_LEARN_SKILL_SE).play unless new_skills.empty?
    # Run Original Method
    malgb_zero_se_skilllearn_lvlup_8kb3 (new_skills, *args)
  end
end

Credit



Thanks


Support


Please post here with suggestions or bug reports.

Known Compatibility Issues

No known compatibility issues

Author's Notes


Kind of minor and useless, but easy and a request, so I figured I'd share. No credit is necessary.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Learn Skill Sound Effect
Post by: SuperMega on September 03, 2009, 09:10:16 PM
Very cool, and yet simple script!  I've seen a bunch of requests for something like this lately!

EDIT: Hehe, I posted 15 miliseconds before Zero2008.
Title: Re: Learn Skill Sound Effect
Post by: Zero2008 on September 03, 2009, 09:10:31 PM
Thanks man! I've been wanting this script for a long time.
But is it possible to put a little bit of wait time before playing the SE?
Title: Re: Learn Skill Sound Effect
Post by: modern algebra on September 04, 2009, 01:10:38 PM
It can be done pretty easily if you are willing to use Zeriab's Scheduler (http://rmrk.net/index.php/topic,31002.0.html).

Make sure that you include the part that binds it to Graphics.update. Once you do that, then replacing the script with the following code will allow you to set the delay for as long as you like:

Spoiler for:
Code: [Select]
#==============================================================================
#    Learn Skill Sound Effect
#    Version: 1.0
#    Author: modern algebra
#    Date: September 3, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#   
#    This script will play an SE when levelling if the actor has learned any
#   new skills.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials.
#
#    If you wish to change the SE that plays, scroll down to line 30 and read
#   the instructions located there.
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - LSSE_LEARN_SKILL_SE
#    aliased method - display_level_up
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Class Constants
  #``````````````````````````````````````````````````````````````````````````
  #  LSSE_LEARN_SKILL_SE - an array holding the name, volume, and pitch of
  # the SE to be played when learning a new skill through level up. The
  # format is:
  #
  #      ["se_name", se_volume, se_pitch]
  #          se_name : the name of the file to be played. This must be there.
  #          se_volume : the volume of the SE to be played. If left blank, it
  #            defaults to 100
  #          se_pitch : the pitch of the SE to be played. If left blank, it
  #            defaults to 100
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  LSSE_LEARN_SKILL_SE = ["Up", 80]
  LSSE_SE_DELAY = 30 # Time, in frames, to wait before playing SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Show Level Up Message
  #     new_skills : Array of newly learned skills
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malgb_zero_se_skilllearn_lvlup_8kb3 display_level_up
  def display_level_up(new_skills, *args)
    # Play SE unless no new skills passed
    proc = Proc.new {RPG::SE.new (*LSSE_LEARN_SKILL_SE).play}
    Scheduler.schedule (LSSE_SE_DELAY, proc) unless new_skills.empty?
    # Run Original Method
    malgb_zero_se_skilllearn_lvlup_8kb3 (new_skills, *args)
  end
end