Advertisement
Rafael_Sol_Maker

Rafael_Sol_Maker's Balloon Upgrade MV v1.0

Apr 26th, 2018
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // BalloonUpgrade.js
  3. //=============================================================================
  4. /*:
  5.  * @plugindesc Um pequeno upgrade para o balão de expressão. v1.0 para testes.
  6.  * Feito com exclusividade como tutorial da Revista Make the RPG edição 16.
  7.  * @author Rafael_Sol_Maker (www.condadobraveheart.com/forum)
  8.  * @help Os comandos de plugin disponíveis são os seguintes:
  9.  *
  10.  * Balloon set_position x y
  11.  * Muda a posição vertical e horizontal (x e y) do Balão de Expressão.
  12.  *
  13.  * Balloon set_blend_mode N
  14.  * Muda a mistura para N. Valores de 0 à 3 (Normal, Add, Multiply e Screen).
  15.  *
  16.  * Balloon set_sfx ARQUIVO
  17.  * Muda o nome do arquivo de som executado para ARQUIVO.
  18.  *
  19.  * Balloon set_frame_speed N
  20.  * Muda o tempo de espera para a troca de quadros para N.
  21.  *
  22.  * Balloon set_final_wait N
  23.  * Muda o tempo de espera do último quadro para N.
  24.  *
  25.  * @param offsetX
  26.  * @desc Deslocamento horizontal do Balão de Expressão. Valor em tiles.
  27.  * @default 0.25
  28.  *
  29.  * @param offsetY
  30.  * @desc Deslocamento vertical do Balão de Expressão. Valor em tiles.
  31.  * @default 0.5
  32.  *
  33.  * @param frameDuration
  34.  * @desc Tempo de espera para a troca de um quadro para outro da animação.
  35.  * @default 16
  36.  *
  37.  * @param finalFrameWait
  38.  * @desc Tempo de espera adicional que a animação "segura" o quadro final.
  39.  * @default 30
  40.  *
  41.  * @param blendMode
  42.  * @desc Define o modo de mistura da imagem. Valores de 0 à 3:
  43.  * BLEND_NORMAL = 0; BLEND_ADD = 1; BLEND_MULTIPLY= 2; BLEND_SCREEN = 3;
  44.  * @default 0
  45.  *
  46.  * @param sfxFilename
  47.  * @desc Nome do arquivo de som executado ao se chamar um balão;
  48.  * @default
  49. */
  50.  
  51. (function() {
  52.   // As variáveis
  53.   var parameters = PluginManager.parameters('BalloonUpgrade');
  54.     var __anchor_x = Number(parameters['offsetX'] || 0.5);
  55.     var __anchor_y = Number(parameters['offsetY'] || 1);
  56.     var __blend_mode = Number(parameters['blendMode'] || 0);
  57.     var __sfx_filename = parameters['sfxFilename'] || 'Jump1';
  58.     var __frame_speed = Number(parameters['frameDuration'] || 8);
  59.     var __final_wait_time = Number(parameters['finalFrameWait'] || 12);
  60.  
  61.   // Comandos de plugin para facilitar a vida
  62.   var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  63.   Game_Interpreter.prototype.pluginCommand = function(command, args) {
  64.       _Game_Interpreter_pluginCommand.call(this, command, args);
  65.     if (command === 'Balloon') {
  66.       switch (args[0]) {
  67.       case 'set_position':
  68.         __anchor_x = Number(args[1] || 0.5);
  69.         __anchor_y = Number(args[2] || 1.0);
  70.         break;
  71.       case 'set_blend_mode':
  72.         __blend_mode = Number(args[1] || 0);
  73.         break;
  74.       case 'set_sfx':
  75.         console.log(__sfx_filename)
  76.         __sfx_filename = (args[1] || 'Jump1');
  77.         break;
  78.       case 'set_frame_speed':
  79.         __frame_speed = Number(args[1] || 8);
  80.         break;
  81.       case 'set_final_wait':
  82.         __final_wait_time = Number(args[1] || 12);
  83.         break;
  84.       case 'reset_defaults':
  85.         __anchor_x = Number(parameters['offsetX'] || 0.5);
  86.         __anchor_y = Number(parameters['offsetY'] || 1);
  87.         __blend_mode = Number(parameters['blendMode'] || 0);
  88.         __sfx_filename = parameters['sfxFilename'] || 'Jump1';
  89.         __frame_speed = Number(parameters['frameDuration'] || 8);
  90.         __final_wait_time = Number(parameters['finalFrameWait'] || 12);
  91.         break;
  92.       }
  93.     }
  94.   };
  95.  
  96.     // Mudando nossas propriedades na medida da necessidade
  97.     var _Sprite_Balloon_setup = Sprite_Balloon.prototype.setup;
  98.     Sprite_Balloon.prototype.setup = function(balloonId) {
  99.     _Sprite_Balloon_setup.call(this, balloonId);
  100.     this.anchor.x = __anchor_x;
  101.     this.anchor.y = __anchor_y;
  102.     this.blendMode = __blend_mode;
  103.     if (__sfx_filename == '') return;
  104.         AudioManager.playSe({name: __sfx_filename, pan: 0, pitch: 100, volume: 100});
  105.     };
  106.  
  107.     // Velocidade da animação
  108.     Sprite_Balloon.prototype.speed = function() {
  109.         return __frame_speed;
  110.  
  111.     };
  112.  
  113.     // Espera adicional do quadro final
  114.     Sprite_Balloon.prototype.waitTime = function() {
  115.         return __final_wait_time;
  116.     };
  117.  
  118. })(); // Não deletar!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement