Advertisement
Rafael_Sol_Maker

RSM's Balloon Upgrade MV PLUS v1.0 [BR]

May 24th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // RSM_BalloonUpgradePlus.js
  3. // Rafael_Sol_Maker's Balloon Upgrade MV PLUS edition v1.0
  4. // Este trabalho é licenciado sob a Creative Commons Attribution 4.0 International License.
  5. //=============================================================================
  6.  
  7. // A galera diz que esta é uma prática bacana...
  8. var Imported = Imported || {};
  9. Imported.RSM_BalloonUpgrade = true;
  10.  
  11. var RSMTweaks = RSMTweaks || {};
  12. RSMTweaks.BalloonUpgrade = RSMTweaks.BalloonUpgrade || {};
  13. RSMTweaks.BalloonUpgrade.version = 1.0;
  14.  
  15. /*:
  16.  * @plugindesc RSM's Balloon Upgrade MV PLUS v1.0.
  17.  * Um upgrade para o balão de expressão. Requer RPG Maker 1.5 ou superior.
  18.  * @author Rafael_Sol_Maker (www.condadobraveheart.com/forum)
  19.  * @help Este plugin permite a customização a fundo dos balões de expressão.
  20.  *
  21.  * ---------------------------------------------------------------
  22.  * IMPORTANTE: ESSE PLUGIN SUBSTITUIRÁ OS BALÕES PADRÃO, E EXIGIRÁ A
  23.  * RECONFIGURAÇÃO DOS MESMOS PARA SER UTILIZADO!
  24.  * ---------------------------------------------------------------
  25.  *
  26.  * O índice na qual ele será apresentado nesta lista corresponde ao
  27.  * que é exibido na lista de seleção via comandos de eventos.
  28.  *
  29.  * Não será possível utilizar um balão para além do que foi configurado
  30.  * anteriormente. Ex.: Se você configurou apenas 3 balões, tentar usar o
  31.  * 4o da lista resultará em ERRO.
  32.  *
  33.  * Em caso de dúvidas, bugs, críticas ou sugestões, não deixe de me procurar.
  34.  * Atenciosamente,
  35.  *                                                          ~RAFAEL_SOL_MAKER
  36.  *
  37.  * @param balloon_list
  38.  * @text Configuração dos Balões
  39.  * @desc Configure aqui cada propriedade de cada balão individualmente.
  40.  * @type struct<Balloon>[]
  41.  */
  42.  
  43. /*~struct~Balloon:
  44.  * @param animation
  45.  * @text Animação
  46.  * @desc Categoria que lida dos pormenores da animação
  47.  * @default ===================================
  48.  *
  49.  * @param filename
  50.  * @parent animation
  51.  * @text Nome do Arquivo
  52.  * @desc Nome do arquivo do qual será extraída a animação.
  53.  * @type file
  54.  * @dir img/system
  55.  * @default Balloon
  56.  *
  57.  * @param animation_id
  58.  * @parent animation
  59.  * @text ID da Animação
  60.  * @desc Determinação do índice da animação que será extraída do arquivo.
  61.  * @type number
  62.  * @min 1
  63.  * @default 1
  64.  *
  65.  * @param total_frames
  66.  * @parent animation
  67.  * @text Total de Quadros
  68.  * @desc Total de quadros para completar a animação.
  69.  * @type number
  70.  * @min 1
  71.  * @default 8
  72.  *
  73.  * @param speed
  74.  * @parent animation
  75.  * @text Velocidade
  76.  * @desc Tempo de exposição de cada quadro da animação, em quadros (1/60 segundo).
  77.  * @type number
  78.  * @min 1
  79.  * @default 8
  80.  *
  81.  * @param wait_time
  82.  * @parent animation
  83.  * @text Espera Final
  84.  * @desc Tempo de espera do último quadro da animação, em quadros (1/60 segundo).
  85.  * @type number
  86.  * @min 1
  87.  * @default 12
  88.  *
  89.  * @param frame
  90.  * @text Quadro da Animação
  91.  * @desc Categoria do quadro de animação.
  92.  * @default ===================================
  93.  *
  94.  * @param offset
  95.  * @parent frame
  96.  * @text Posição (Deslocamento)
  97.  * @desc Deslocamento (offset) do balão de expressão em relação ao centro do personagem alvo. Valor em tiles.
  98.  * @type struct<Point>
  99.  * @default {"X":"0.250","Y":"0.500"}
  100.  *
  101.  * @param scale
  102.  * @parent frame
  103.  * @text Fator de Escala
  104.  * @desc Fator de escala em múltiplos, para largura e altura. Use entre 0 e 1 para encolher e maior que 1 para ampliar.
  105.  * @type struct<Point>
  106.  * @default {"X":"1.000","Y":"1.000"}
  107.  *
  108.  * @param rotation
  109.  * @parent frame
  110.  * @text Rotação
  111.  * @desc Rotação do balão, em radianos. Use valores de 0 a 2*PI.
  112.  * @type number
  113.  * @decimals 4
  114.  * @default 0.0000
  115.  *
  116.  * @param frame_size
  117.  * @parent frame
  118.  * @text Tamanho do Quadro
  119.  * @desc Tamanho do quadro da animação do balão.
  120.  * @type struct<Size>
  121.  * @default {"W":"48","H":"48"}
  122.  *
  123.  * @param z_order
  124.  * @parent frame
  125.  * @text Prioridade
  126.  * @desc Prioridade de exibição. Quanto maior o valor, mais acima dos outros objetos aparecerá.
  127.  * @type number
  128.  * @default 7
  129.  *
  130.  * @param sfx
  131.  * @text Efeito Sonoro
  132.  * @desc Categoria onde colocamos a configuração de reprodução do efeito sonoro.
  133.  * @default ===================================
  134.  *
  135.  * @param sfx_filename
  136.  * @parent sfx
  137.  * @text Nome de Arquivo
  138.  * @desc O nome do arquivo de som a ser executado.
  139.  * @type file
  140.  * @dir audio/se
  141.  * @default Cancel2
  142.  *
  143.  * @param sfx_volume
  144.  * @parent sfx
  145.  * @text Volume
  146.  * @desc Volume que será executado o som (0 a 100).
  147.  * @type number
  148.  * @min 0
  149.  * @max 100
  150.  * @default 90
  151.  *
  152.  * @param sfx_pitch
  153.  * @parent sfx
  154.  * @text Tonalidade
  155.  * @desc Altura (grave ou aguda) na qual será executado o som. O padrão é 100 (altura normal).
  156.  * @type number
  157.  * @min 50
  158.  * @max 150
  159.  * @default 100
  160.  *
  161.  * @param sfx_pan
  162.  * @parent sfx
  163.  * @text Balanço
  164.  * @desc Balaço estéreo (esquerda-direita) do som. Use valores de -100 a 100.
  165.  * @type number
  166.  * @min -100
  167.  * @max 100
  168.  * @default 0
  169.  *
  170.  * @param sfx_wait
  171.  * @parent sfx
  172.  * @text Espera para Iniciar
  173.  * @desc Espera, em quadros (1/60 segundo), antes de executar o som.
  174.  * Não executará se a animação já tiver acabado.
  175.  * @type number
  176.  * @default 0
  177.  *
  178.  * @param blend
  179.  * @text Opacidade e Mistura
  180.  * @desc Categoria que lida com transparências e afins.
  181.  * @default ===================================
  182.  *
  183.  * @param opacity
  184.  * @parent blend
  185.  * @text Opacidade
  186.  * @desc Grau de transparência da imagem. Use valores de 0 a 255.
  187.  * @type number
  188.  * @min 0
  189.  * @max 255
  190.  * @default 255
  191.  *
  192.  * @param blend_mode
  193.  * @parent blend
  194.  * @text Modo de Mistura
  195.  * @desc Modo de mistura (sobreposição) que a imagem será colocada sob as demais.
  196.  * @type select
  197.  * @option Graphics.BLEND_NORMAL
  198.  * @option Graphics.BLEND_ADD
  199.  * @option Graphics.BLEND_MULTIPLY
  200.  * @option Graphics.BLEND_SCREEN
  201.  * @default Graphics.BLEND_NORMAL
  202.  *
  203.  * @param blend_color
  204.  * @parent blend
  205.  * @text Cor de Mistura
  206.  * @desc Cor RGB sob a qual será realizada a mistura do Modo de Mistura.
  207.  * @type struct<Color>
  208.  * @default {"R":"0","G":"0","B":"0","A":"0"}
  209.  *
  210.  * @param color_tone
  211.  * @parent blend
  212.  * @text Coloração
  213.  * @desc Tonalização da imagem em cores RGB (-255 a 255) mais tonalização em cinza.
  214.  * @type struct<Tone>
  215.  * @default {"R":"0","G":"0","B":"0","Gray":"0"}
  216.  *
  217. */
  218.  
  219. /////////////////////////////////////////////////////////////////////////////
  220.  
  221. /*~struct~Size:
  222.  * @param W @type number @text Largura @min 0
  223.  * @param H @type number @text Altura @min 0
  224. */
  225.  
  226. /*~struct~Point:
  227.  * @param X @type number @text Coordenada X @decimals 3
  228.  * @param Y @type number @text Coordenada Y @decimals 3
  229. */
  230.  
  231. /*~struct~Color:
  232.  * @param R @type number @text Red @min 0 @max 255
  233.  * @param G @type number @text Green @min 0 @max 255
  234.  * @param B @type number @text Blue @min 0 @max 255
  235.  * @param A @type number @text Alpha @min 0 @max 255
  236. */
  237.  
  238. /*~struct~Tone:
  239.  * @param R @type number @text Red @min -255 @max 255
  240.  * @param G @type number @text Green @min -255 @max 255
  241.  * @param B @type number @text Blue @min -255 @max 255
  242.  * @param Gray @type number @text Gray @min 0 @max 255
  243. */
  244.  
  245. ///////////////////////////////////////////////////////////////////////////////
  246.  
  247. (function() {
  248.  
  249.   // Lendo os parâmetros...
  250.   var params = PluginManager.parameters('RSM_BalloonUpgradePlus');
  251.   var list = JSON.parse(params['balloon_list']);
  252.   var items = [];
  253.   for (n = 0; n < list.length; n++) {
  254.     items[n] = JSON.parse(list[n]);
  255.     items[n].offset = JSON.parse(items[n].offset);
  256.     items[n].scale = JSON.parse(items[n].scale);
  257.     items[n].blend_color = JSON.parse(items[n].blend_color);
  258.     items[n].color_tone = JSON.parse(items[n].color_tone);
  259.     items[n].frame_size = JSON.parse(items[n].frame_size);
  260.   }
  261.  
  262.   /////////////////////////////////////////////////////////////////////////////
  263.  
  264.   // Repassando valor assim que este for iniciado
  265.   Sprite_Character.prototype.startBalloon = function() {
  266.     if (this._character.balloonId() > list.length) {
  267.       throw new Error("Erro: O índice do balão escolhido não está configurado. Favor configurar esse balão no Gerenciador de Plugins!");
  268.       return;
  269.     };
  270.     if (!this._balloonSprite) {
  271.       this._balloonSprite = new Sprite_Balloon(this._character.balloonId());
  272.     };
  273.     this.parent.addChild(this._balloonSprite);
  274.   };
  275.  
  276.   /////////////////////////////////////////////////////////////////////////////
  277.  
  278.   // Essencial repassar balloonId para initMembers
  279.   Sprite_Balloon.prototype.initialize = function(balloonId) {
  280.     Sprite_Base.prototype.initialize.call(this);
  281.     this.initMembers(balloonId);
  282.     this.loadBitmap();
  283.   };
  284.  
  285.     // Mudando nossas propriedades iniciais
  286.   Sprite_Balloon.prototype.initMembers = function(balloonId) {
  287.  
  288.     // Dados essenciais
  289.     this._balloonId = balloonId;
  290.     var i = items[balloonId - 1];
  291.  
  292.     // Posicionamento
  293.     this.anchor.x = Number(i.offset.X);
  294.     this.anchor.y = Number(i.offset.Y);
  295.     this.scale.x = Number(i.scale.X);
  296.     this.scale.y = Number(i.scale.Y);
  297.     this.rotation = Number(i.rotation);
  298.     this.fw = Number(i.frame_size.W);
  299.     this.fh = Number(i.frame_size.H);
  300.     this.z = Number(i.z_order);
  301.  
  302.     // Propriedades da Mistura
  303.     this.opacity = Number(i.opacity);
  304.     this.blendMode = eval(i.blend_mode); //Number(i.blend_mode);
  305.     var b = i.blend_color;
  306.     var c = i.color_tone;
  307.     this.setBlendColor([b['R'], b['G'], b['B'], b['A']]);
  308.     this.setColorTone([c['R'], c['G'], c['B'], c['Gray']]);
  309.  
  310.     // Detalhes da Animação
  311.     this.count = 0;
  312.     this.sfx_wait = Number(i.sfx_wait);
  313.     this.animation_id = Number(i.animation_id);
  314.     this.speed = Number(i.speed);
  315.     this.wait_time = Number(i.wait_time);
  316.     this._duration = Number(i.total_frames) * Number(i.speed) + Number(i.wait_time);
  317.     };
  318.  
  319.   // Carregando o arquivo que queremos
  320.   Sprite_Balloon.prototype.loadBitmap = function() {
  321.     this.bitmap = ImageManager.loadSystem(items[this._balloonId - 1].filename);
  322.     this.setFrame(0, 0, 0, 0);
  323.   };
  324.  
  325.   // Atualização do sprite
  326.   var _Sprite_Balloon_update = Sprite_Balloon.prototype.update;
  327.   Sprite_Balloon.prototype.update = function() {
  328.     _Sprite_Balloon_update.call(this);
  329.     var a = items[this._balloonId - 1];
  330.     if (this.sfx_wait == this.count){
  331.       AudioManager.playSe({name: a.sfx_filename, pan: a.sfx_pan, pitch: a.sfx_pitch, volume: a.sfx_volume});
  332.     };
  333.     this.count++;
  334.   };
  335.  
  336.   // Atualização do quadro de animação
  337.   Sprite_Balloon.prototype.updateFrame = function() {
  338.     var sx = this.frameIndex() * this.fw;
  339.     var sy = (this.animation_id - 1) * this.fh;
  340.     this.setFrame(sx, sy, this.fw, this.fh);
  341.   };
  342.  
  343.     // Velocidade da animação
  344.     Sprite_Balloon.prototype.speed = function() {
  345.         return Number(items[this._balloonId - 1].speed);
  346.     };
  347.  
  348.     // Espera adicional do quadro final
  349.     Sprite_Balloon.prototype.waitTime = function() {
  350.         return Number(items[this._balloonId - 1].wait_time);
  351.     };
  352.  
  353.   // Tem que ficar por algum motivo que ignoro...
  354.   Sprite_Balloon.prototype.frameIndex = function() {
  355.     var index = (this._duration - this.wait_time) / this.speed;
  356.     return items[this._balloonId - 1].total_frames - Math.max(Math.floor(index), 0);
  357.   };
  358.  
  359. })(); // Não deletar!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement