Accueil du SiteAccueil du Site  AccueilAccueil  Dernières imagesDernières images  RechercherRechercher  ConnexionConnexion  S'enregistrerS'enregistrer  



Le Deal du moment :
Funko POP! Jumbo One Piece Kaido Dragon Form : ...
Voir le deal

Partagez
 

 Dynamic_sound

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Raven
Administrateur
Administrateur
Raven

Masculin
Messages postés : 1338
Date d'inscription : 20/04/2013
Jauge LPC :
Dynamic_sound 891527140041 / 10041 / 100Dynamic_sound 8915271400

Dynamic_sound Membre15
Dynamic_sound Dessin10
Dynamic_sound Graphi10
Dynamic_sound Collec10
Dynamic_sound Collec11
Dynamic_sound Collec12
Dynamic_sound Collec13
Dynamic_sound Red_ra11
Dynamic_sound Action10
Dynamic_sound Mappeu10
Dynamic_sound Projet10


Dynamic_sound Empty
MessageSujet: Dynamic_sound   Dynamic_sound EmptyDim 14 Juin 2015 - 17:38

Yo les gens !

J'vous partage un petit script pour faire des "sons" dynamiques". D'un part, ça permet de rajouter autre chose que BGM/BGS, d'autre part, le son dépendra de l'emplacement que vous lui aurez donné.
-> Plus vous serez prêt de la source, plus le son sera fort et inversement.

Pour modifier les sons, rendez-vous à la ligne 46 :
Code:
    @emissions[1] = Sound_Emission.new
    @emissions[1].setup (10,12,3,4,20,'011-Waterfall01',100)

C'est expliqué dans le script, mais pour les non anglophones voilà comment procéder.
@emission[X] : C'est l'ID de la map sur laquelle le son est joué.
(X,Y,largeur, hauteur, rayon d'effet,'nomdelaBGS',ton) : J'peux pas être plus clair

Vous pouvez faire ça pour plusieurs maps hein, pour ça recopiers les deux lignes de codes aux lignes 46 et 47 et modifiez les données en fonction de ce don vous avez besoin.

Note 1 : Un petit crédit à Modern Algebra serait cool aussi.

Avantages :
++ Pour les sons d'ambiance comme feu de camp, rivières, cascades, foule en colère, etc.

Inconvénient :
Ce script ne gère qu'un son dynamique par map.


Code:
#==============================================================================
#  Dynamic Sound Emissions
#  Version: 1.0
#  Author: Modern Algebra
#  Date: August 27, 2007
#------------------------------------------------------------------------------
#  Description:
#  This script allows you to set an object in the map which emits a sound. What
#  this script does is set the volume of that sound according to how close you
#  are to the object. If you are far away, the sound will be faint, if you are
#  close the sound will be loud. Sorry, in this version there can be only one
#  object per map.
#------------------------------------------------------------------------------
#  Instructions:
#  To set the objects which emit sound for each map, see below.
#------------------------------------------------------------------------------
# ** Data_Sound_Emission
#       This class holds all of the objects which emit any sound, for all maps
#==============================================================================

class Data_Sound_Emission
  #-------------------------------------------------------------------------
  # * Public Instance Variables
  #-------------------------------------------------------------------------
  attr_reader    :emissions
  #-------------------------------------------------------------------------
  # * Object Initialization
  #-------------------------------------------------------------------------
  def initialize
    @emissions = []
    #----------------------------------------------------------------------
    # * Editable Region
    #----------------------------------------------------------------------
    #  Place all sound emitting objects here. Write it like this:
    #
    #    @emissions[map_id] = Sound_Emission.new
    #    @emissions[map_id].setup (x,y,width,height,radius,bgs,pitch)
    #
    #  Where map_id is the ID of the map you want the object to appear on,
    #  x and y are the x and y positions of the upper-left corner of the object,
    #  width is the amount of squares in the x direction that the object covers,
    #  height is the amount of squares in the y direction that the object
    #  covers, radius is the number of squares away you want the sound to be
    #  hears, bgs is the bgs you want to play, and pitch is the pitch value
    #-----------------------------------------------------------------------
    @emissions[1] = Sound_Emission.new
    @emissions[1].setup (10,12,3,4,20,'011-Waterfall01',100)

    #-----------------------------------------------------------------------
    # * END Editable Region
    #-----------------------------------------------------------------------
  end
end
#==============================================================================
# ** Sound Emitting Object
#------------------------------------------------------------------------------
#  This class holds all the relevant data for the object which is emitting the
#  sound. It is accessed through $game_dynamic_sound_emission
#==============================================================================
class Sound_Emission
  #-------------------------------------------------------------------------
  # * Public Instance Variables
  #-------------------------------------------------------------------------
  attr_reader    :bgs
  attr_reader    :radius
  attr_reader    :pitch
  #-------------------------------------------------------------------------
  # * Object Initialization
  #-------------------------------------------------------------------------
  def setup (x, y, width, height, radius, bgs, pitch)
    @rect = Rect.new (x*128, y*128, (width-1)*128, (height-1)*128)
    @radius = radius*128
    @bgs = bgs
    @pitch = pitch
  end
  #-------------------------------------------------------------------------
  # * Volume
  #     Checks position to determine the appropriate volume.
  #-------------------------------------------------------------------------
  def volume (x, y)
    # Determine distance between position and the sound emitting object
    distance = [x - @rect.x, y - @rect.y]
    testers = [@rect.width, @rect.height]
    for i in 0...2 # For both the x distance and the y distance
      # Determine total distance in that direction from the object
      if distance[i] > 0  # IF you are to the right of the object
        # Take into account the width of the object
        if distance[i] <= testers[i] # If you are above or beside the object
          # Neglect the distance in that direction
          distance[i] = 0  
        else
          # Subtract the width to determine the closest row or column
          distance[i] -= testers[i]
        end
      else
        # Make the value positive
        distance[i] *= -1
      end
    end
    # Calculate the total distance
    total_distance = distance[0] + distance[1]
    ratio = (total_distance.to_f / @radius.to_f)*100 # Get the percentage
    ratio = [ratio,100].min
    ratio = 100 - ratio
    return ratio
  end
end

#==============================================================================
# ** Scene Title
#==============================================================================

class Scene_Title
  #-------------------------------------------------------------------------
  # * Alias Main to initialize the data class upon startup
  #-------------------------------------------------------------------------
  alias add_data_emissions main
  def main
    # Initialize $data_sound_objects
    $data_sound_objects = Data_Sound_Emission.new
    add_data_emissions
  end
end

#==============================================================================
# ** Game Player
#==============================================================================

class Game_Player
  #-------------------------------------------------------------------------
  # * Alias update to play the BGS
  #-------------------------------------------------------------------------
  alias update_volume update
  def update
    update_volume
    if $data_sound_objects.emissions[$game_map.map_id] != nil
      emitter = $data_sound_objects.emissions[$game_map.map_id]
      volume = emitter.volume (@real_x, @real_y)
      bgs = RPG::AudioFile.new (emitter.bgs,volume,emitter.pitch)
      if volume != 0
        $game_system.bgs_play (bgs)
      else
        Audio.bgs_stop
      end
    end
  end
end
Revenir en haut Aller en bas
http://redrustyraven.blogspot.fr https://www.facebook.com/RedRustyRaven
City Hunter
Administrateur
Administrateur
City Hunter

Masculin
Messages postés : 6523
Date d'inscription : 25/05/2011
Jauge LPC :
Dynamic_sound 891527140040 / 10040 / 100Dynamic_sound 8915271400

Dynamic_sound Staffe10
Dynamic_sound Mappeu10
Dynamic_sound Membre15
Dynamic_sound Testeu10
Dynamic_sound Promot10
Dynamic_sound Projet10
Dynamic_sound Projet16
Dynamic_sound Riche_10
Dynamic_sound Travai10
Dynamic_sound Collec10
Dynamic_sound Collec11
Dynamic_sound Collec12
Dynamic_sound Collec13
Dynamic_sound Pandac10
Dynamic_sound 10000011


Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound EmptyDim 14 Juin 2015 - 19:09

On peut aussi largement faire la même chose en évent en coupant ta map par zone et en faisant des conditions. C'est plutôt long et fastidieux, mais avec mes compétences je n'ai guère trouvé mieux ^^

Merci du partage. Des points.
Revenir en haut Aller en bas
Zexion
Administrateur
Administrateur
Zexion

Masculin
Messages postés : 6228
Date d'inscription : 04/01/2012
Jauge LPC :
Dynamic_sound 891527140097 / 10097 / 100Dynamic_sound 8915271400

Dynamic_sound Membre15
Dynamic_sound Event-10
Dynamic_sound Altrui10
Dynamic_sound Action10
Dynamic_sound Travai10
Dynamic_sound Collec10
Dynamic_sound Collec11
Dynamic_sound Collec12
Dynamic_sound Staffe11
Dynamic_sound Dessin10


Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound EmptyDim 14 Juin 2015 - 19:15

Intéressant. Merci Raven. Smile
Revenir en haut Aller en bas
Kasbak
Membre V.I.P.
Membre V.I.P.
Kasbak

Masculin
Messages postés : 1356
Date d'inscription : 05/01/2013
Jauge LPC :
Dynamic_sound 8915271400100 / 100100 / 100Dynamic_sound 8915271400

Dynamic_sound Dragon10
Dynamic_sound Meille12
Dynamic_sound Membre10
Dynamic_sound Projet12
Dynamic_sound Riche_10
Dynamic_sound Altrui10
Dynamic_sound Membre10
Dynamic_sound Membre15
Dynamic_sound Event-10
Dynamic_sound Partag10
Dynamic_sound Projet10
Dynamic_sound Mappeu10
Dynamic_sound Collec10


Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound EmptyDim 21 Juin 2015 - 0:32

Merci du partage ça peu etre utile.
Revenir en haut Aller en bas
http://kasbakprod.wifeo.com/ http://kasbak.deviantart.com/
Siegfried
Mage (niveau 2)
Mage (niveau 2)
Siegfried

Masculin
Messages postés : 286
Date d'inscription : 31/07/2011
Jauge LPC :
Dynamic_sound 891527140080 / 10080 / 100Dynamic_sound 8915271400

Dynamic_sound Altrui10
Dynamic_sound Script10


Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound EmptyJeu 23 Juil 2015 - 13:22

Script bien codé et fonctionnalité (je pense) inédite. Excellente idée. Smile

Applications possibles : ambiance, mini-jeux, mise en scène (musique inquiétante dans un couloir qui augmente plus on s'approche de l'événement déclencheur d'une catastrophe).

Par contre, il remplace toute autre ambiance sonore, non ? Je me demande s'il y aurait moyen de créer plusieurs "flux" de sons autres que BGM/BGS... Je n'y avais jamais pensé avant de voir ce script. Surprised
Revenir en haut Aller en bas
http://saleth.fr
Raven
Administrateur
Administrateur
Raven

Masculin
Messages postés : 1338
Date d'inscription : 20/04/2013
Jauge LPC :
Dynamic_sound 891527140041 / 10041 / 100Dynamic_sound 8915271400

Dynamic_sound Membre15
Dynamic_sound Dessin10
Dynamic_sound Graphi10
Dynamic_sound Collec10
Dynamic_sound Collec11
Dynamic_sound Collec12
Dynamic_sound Collec13
Dynamic_sound Red_ra11
Dynamic_sound Action10
Dynamic_sound Mappeu10
Dynamic_sound Projet10


Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound EmptyJeu 23 Juil 2015 - 14:24

Non non, il me semble pas qu'il remplace le son ambiant, mais il le "couvre" me semble t-il simplement parce qu'il est très fort. Faudrait que je vérifie.
Revenir en haut Aller en bas
http://redrustyraven.blogspot.fr https://www.facebook.com/RedRustyRaven
Contenu sponsorisé




Dynamic_sound Empty
MessageSujet: Re: Dynamic_sound   Dynamic_sound Empty

Revenir en haut Aller en bas
 
Dynamic_sound
Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Le Palais Créatif :: ~ PARTAGE ~ :: Scripts et plugins :: RPG Maker XP :: Autres-
Sauter vers: