iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Closed TopicStart new topic
> [SOLVED] Play a sound when guarding.
Jaide
post Nov 23 2011, 05:12 PM
Post #1


ಠ_ಠ
Group Icon


Type: Writer
Alignment: Chaotic Good




Hello, I hope this is the right section for this sort of question. I wasn't entirely positive, but I'm using a script to achieve most of what I want, so I thought this was probably the best place.

Anyway, in my game, every attack the player has costs MP, and you must guard to refill your MP to continue attacking. I'm using the following script by wltr3565 to achieve the recovery of MP when guarding:

Spoiler:
CODE
=begin
================================================================================
MP increasing by guarding template by wltr3565, v1.2
================================================================================
This script works for increasing mp of the guarding corresponding battler. It
won't disturb any guarding-related scripts because it's aliased already. So
don't worry about any incompability. Now can heal hp if wanted!
================================================================================
Effect: Makes the guarder's mp (and/or hp) to increase at the calculated amount.
        This effects foes as well.
================================================================================
Instructions of using: Put this script above main and below any battle system
                       related scripts. You can adjust how the mp increase
                       at the script below. Instructions incoming.
                       Don't forget to credit me :)
                      
Calculation reference for using other status:
@active_battler.hp = guarder's hp
@active_battler.maxhp = guarder's max hp
@active_battler.mp = guarder's mp
@active_battler.maxmp = guarder's max mp
@active_battler.atk = guarder's attack
@active_battler.def = guarder's defense
@active_battler.spi = guarder's spirit
@active_battler.agi = guarder's agility
@active_battler.level = guarder's level. I suggest to not use this.

Sample for calculation:

@active_battler.mp += (@active_battler.spi + @active_battler.maxhp)
When Ralph is guarding, his mp will heal by the total of his spirit and maxhp.
So: Spirit = 1; maxhp = 50; then his mp will increase by 51 while guarding.
================================================================================
History: -This script is publicized. (v1.0)
         -Added HP healing (by calculation) (v1.1)
         -The healing is now executed while guarding, not at start of guarding. (v1.2)
          thanking Mithran for this!
================================================================================        
=end
module WLTR
module HEALING_ADJUSTMENTS

MP_HEAL = true #if you want the mp to be healed...

MP_HEAL_LEAST = 10 #amount of points mp healed if the calculation made is not reaching 1

HP_HEAL = false #if you want the hp to be healed...

HP_HEAL_LEAST = 1 #amount of points hp healed if the calculation made is not reaching 1

end
end

#================================================================================
#Adjusting the calculation is below
#================================================================================

class Scene_Battle < Scene_Base
  alias mp_increase_template execute_action_guard
  def execute_action_guard
if WLTR::HEALING_ADJUSTMENTS::MP_HEAL
    if (@active_battler.spi / 10) < 1 #calculation for making sure mp to increase at least 1 is added here.
    @active_battler.mp += WLTR::HEALING_ADJUSTMENTS::MP_HEAL_LEAST
    else
    @active_battler.mp += (@active_battler.maxmp * 100 / 100) #calculation for mp increase is added here.
    end
end
if WLTR::HEALING_ADJUSTMENTS::HP_HEAL
  if (@active_battler.def / 5) < 1 #calculation for making sure hp to increase at least 1 is added here.
    @active_battler.hp += WLTR::HEALING_ADJUSTMENTS::HP_HEAL_LEAST
  else
    @active_battler.hp += (@active_battler.def / 5) #calculation for hp increase is added here.
  end
end
  mp_increase_template
end
end

#===============================================================================
#SETTING END
#===============================================================================


The thing is, I would like it to be apparent to the player what is happening by guarding, aside from just explaining the mechanic ahead of time. I'd like to play a sound effect when the guard command is issued. I know nothing about scripting, so I don't really have the foggiest idea how to go about this.

Any help is appreciated, and thanks for reading. :3

This post has been edited by Jaide: Nov 26 2011, 01:01 AM
Go to the top of the page
 
+Quote Post
   
IMP1
post Nov 25 2011, 06:20 PM
Post #2


Retributionist.
Group Icon


Type: Writer




The script to play a SE/ME is this:
CODE
Audio.se_play(filename, volume, pitch) # plays a SE
Audio.me_play(filename, volume, pitch) # plays a ME
Where voulme and pitch can be omitted.
I'd put it before the line containing "if WLTR::HEALING_ADJUSTMENTS::MP_HEAL"
Oh, and I think the filename needs to be in the format "Audio/SE/filename" or "Audio/ME/filename". I don't think you need the filetype.


--------------------
Go to the top of the page
 
+Quote Post
   
Jaide
post Nov 25 2011, 09:07 PM
Post #3


ಠ_ಠ
Group Icon


Type: Writer
Alignment: Chaotic Good




Perfect! That's exactly what I needed. Thank you, IMP1! smile.gif You're right about the format, and the file type isn't needed.

This post has been edited by Jaide: Nov 25 2011, 09:07 PM
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 1st September 2014 - 12:48 PM

RPGMakerVX.net is an Privacy Policy, Legal.