Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //=============================================================================
- // RSM_BalloonUpgradePlus.js
- // Rafael_Sol_Maker's Balloon Upgrade MV PLUS edition v1.0
- // Este trabalho é licenciado sob a Creative Commons Attribution 4.0 International License.
- //=============================================================================
- // A galera diz que esta é uma prática bacana...
- var Imported = Imported || {};
- Imported.RSM_BalloonUpgrade = true;
- var RSMTweaks = RSMTweaks || {};
- RSMTweaks.BalloonUpgrade = RSMTweaks.BalloonUpgrade || {};
- RSMTweaks.BalloonUpgrade.version = 1.0;
- /*:
- * @plugindesc RSM's Balloon Upgrade MV PLUS v1.0.
- * Um upgrade para o balão de expressão. Requer RPG Maker 1.5 ou superior.
- * @author Rafael_Sol_Maker (www.condadobraveheart.com/forum)
- * @help Este plugin permite a customização a fundo dos balões de expressão.
- *
- * ---------------------------------------------------------------
- * IMPORTANTE: ESSE PLUGIN SUBSTITUIRÁ OS BALÕES PADRÃO, E EXIGIRÁ A
- * RECONFIGURAÇÃO DOS MESMOS PARA SER UTILIZADO!
- * ---------------------------------------------------------------
- *
- * O índice na qual ele será apresentado nesta lista corresponde ao
- * que é exibido na lista de seleção via comandos de eventos.
- *
- * Não será possível utilizar um balão para além do que foi configurado
- * anteriormente. Ex.: Se você configurou apenas 3 balões, tentar usar o
- * 4o da lista resultará em ERRO.
- *
- * Em caso de dúvidas, bugs, críticas ou sugestões, não deixe de me procurar.
- * Atenciosamente,
- * ~RAFAEL_SOL_MAKER
- *
- * @param balloon_list
- * @text Configuração dos Balões
- * @desc Configure aqui cada propriedade de cada balão individualmente.
- * @type struct<Balloon>[]
- */
- /*~struct~Balloon:
- * @param animation
- * @text Animação
- * @desc Categoria que lida dos pormenores da animação
- * @default ===================================
- *
- * @param filename
- * @parent animation
- * @text Nome do Arquivo
- * @desc Nome do arquivo do qual será extraída a animação.
- * @type file
- * @dir img/system
- * @default Balloon
- *
- * @param animation_id
- * @parent animation
- * @text ID da Animação
- * @desc Determinação do índice da animação que será extraída do arquivo.
- * @type number
- * @min 1
- * @default 1
- *
- * @param total_frames
- * @parent animation
- * @text Total de Quadros
- * @desc Total de quadros para completar a animação.
- * @type number
- * @min 1
- * @default 8
- *
- * @param speed
- * @parent animation
- * @text Velocidade
- * @desc Tempo de exposição de cada quadro da animação, em quadros (1/60 segundo).
- * @type number
- * @min 1
- * @default 8
- *
- * @param wait_time
- * @parent animation
- * @text Espera Final
- * @desc Tempo de espera do último quadro da animação, em quadros (1/60 segundo).
- * @type number
- * @min 1
- * @default 12
- *
- * @param frame
- * @text Quadro da Animação
- * @desc Categoria do quadro de animação.
- * @default ===================================
- *
- * @param offset
- * @parent frame
- * @text Posição (Deslocamento)
- * @desc Deslocamento (offset) do balão de expressão em relação ao centro do personagem alvo. Valor em tiles.
- * @type struct<Point>
- * @default {"X":"0.250","Y":"0.500"}
- *
- * @param scale
- * @parent frame
- * @text Fator de Escala
- * @desc Fator de escala em múltiplos, para largura e altura. Use entre 0 e 1 para encolher e maior que 1 para ampliar.
- * @type struct<Point>
- * @default {"X":"1.000","Y":"1.000"}
- *
- * @param rotation
- * @parent frame
- * @text Rotação
- * @desc Rotação do balão, em radianos. Use valores de 0 a 2*PI.
- * @type number
- * @decimals 4
- * @default 0.0000
- *
- * @param frame_size
- * @parent frame
- * @text Tamanho do Quadro
- * @desc Tamanho do quadro da animação do balão.
- * @type struct<Size>
- * @default {"W":"48","H":"48"}
- *
- * @param z_order
- * @parent frame
- * @text Prioridade
- * @desc Prioridade de exibição. Quanto maior o valor, mais acima dos outros objetos aparecerá.
- * @type number
- * @default 7
- *
- * @param sfx
- * @text Efeito Sonoro
- * @desc Categoria onde colocamos a configuração de reprodução do efeito sonoro.
- * @default ===================================
- *
- * @param sfx_filename
- * @parent sfx
- * @text Nome de Arquivo
- * @desc O nome do arquivo de som a ser executado.
- * @type file
- * @dir audio/se
- * @default Cancel2
- *
- * @param sfx_volume
- * @parent sfx
- * @text Volume
- * @desc Volume que será executado o som (0 a 100).
- * @type number
- * @min 0
- * @max 100
- * @default 90
- *
- * @param sfx_pitch
- * @parent sfx
- * @text Tonalidade
- * @desc Altura (grave ou aguda) na qual será executado o som. O padrão é 100 (altura normal).
- * @type number
- * @min 50
- * @max 150
- * @default 100
- *
- * @param sfx_pan
- * @parent sfx
- * @text Balanço
- * @desc Balaço estéreo (esquerda-direita) do som. Use valores de -100 a 100.
- * @type number
- * @min -100
- * @max 100
- * @default 0
- *
- * @param sfx_wait
- * @parent sfx
- * @text Espera para Iniciar
- * @desc Espera, em quadros (1/60 segundo), antes de executar o som.
- * Não executará se a animação já tiver acabado.
- * @type number
- * @default 0
- *
- * @param blend
- * @text Opacidade e Mistura
- * @desc Categoria que lida com transparências e afins.
- * @default ===================================
- *
- * @param opacity
- * @parent blend
- * @text Opacidade
- * @desc Grau de transparência da imagem. Use valores de 0 a 255.
- * @type number
- * @min 0
- * @max 255
- * @default 255
- *
- * @param blend_mode
- * @parent blend
- * @text Modo de Mistura
- * @desc Modo de mistura (sobreposição) que a imagem será colocada sob as demais.
- * @type select
- * @option Graphics.BLEND_NORMAL
- * @option Graphics.BLEND_ADD
- * @option Graphics.BLEND_MULTIPLY
- * @option Graphics.BLEND_SCREEN
- * @default Graphics.BLEND_NORMAL
- *
- * @param blend_color
- * @parent blend
- * @text Cor de Mistura
- * @desc Cor RGB sob a qual será realizada a mistura do Modo de Mistura.
- * @type struct<Color>
- * @default {"R":"0","G":"0","B":"0","A":"0"}
- *
- * @param color_tone
- * @parent blend
- * @text Coloração
- * @desc Tonalização da imagem em cores RGB (-255 a 255) mais tonalização em cinza.
- * @type struct<Tone>
- * @default {"R":"0","G":"0","B":"0","Gray":"0"}
- *
- */
- /////////////////////////////////////////////////////////////////////////////
- /*~struct~Size:
- * @param W @type number @text Largura @min 0
- * @param H @type number @text Altura @min 0
- */
- /*~struct~Point:
- * @param X @type number @text Coordenada X @decimals 3
- * @param Y @type number @text Coordenada Y @decimals 3
- */
- /*~struct~Color:
- * @param R @type number @text Red @min 0 @max 255
- * @param G @type number @text Green @min 0 @max 255
- * @param B @type number @text Blue @min 0 @max 255
- * @param A @type number @text Alpha @min 0 @max 255
- */
- /*~struct~Tone:
- * @param R @type number @text Red @min -255 @max 255
- * @param G @type number @text Green @min -255 @max 255
- * @param B @type number @text Blue @min -255 @max 255
- * @param Gray @type number @text Gray @min 0 @max 255
- */
- ///////////////////////////////////////////////////////////////////////////////
- (function() {
- // Lendo os parâmetros...
- var params = PluginManager.parameters('RSM_BalloonUpgradePlus');
- var list = JSON.parse(params['balloon_list']);
- var items = [];
- for (n = 0; n < list.length; n++) {
- items[n] = JSON.parse(list[n]);
- items[n].offset = JSON.parse(items[n].offset);
- items[n].scale = JSON.parse(items[n].scale);
- items[n].blend_color = JSON.parse(items[n].blend_color);
- items[n].color_tone = JSON.parse(items[n].color_tone);
- items[n].frame_size = JSON.parse(items[n].frame_size);
- }
- /////////////////////////////////////////////////////////////////////////////
- // Repassando valor assim que este for iniciado
- Sprite_Character.prototype.startBalloon = function() {
- if (this._character.balloonId() > list.length) {
- throw new Error("Erro: O índice do balão escolhido não está configurado. Favor configurar esse balão no Gerenciador de Plugins!");
- return;
- };
- if (!this._balloonSprite) {
- this._balloonSprite = new Sprite_Balloon(this._character.balloonId());
- };
- this.parent.addChild(this._balloonSprite);
- };
- /////////////////////////////////////////////////////////////////////////////
- // Essencial repassar balloonId para initMembers
- Sprite_Balloon.prototype.initialize = function(balloonId) {
- Sprite_Base.prototype.initialize.call(this);
- this.initMembers(balloonId);
- this.loadBitmap();
- };
- // Mudando nossas propriedades iniciais
- Sprite_Balloon.prototype.initMembers = function(balloonId) {
- // Dados essenciais
- this._balloonId = balloonId;
- var i = items[balloonId - 1];
- // Posicionamento
- this.anchor.x = Number(i.offset.X);
- this.anchor.y = Number(i.offset.Y);
- this.scale.x = Number(i.scale.X);
- this.scale.y = Number(i.scale.Y);
- this.rotation = Number(i.rotation);
- this.fw = Number(i.frame_size.W);
- this.fh = Number(i.frame_size.H);
- this.z = Number(i.z_order);
- // Propriedades da Mistura
- this.opacity = Number(i.opacity);
- this.blendMode = eval(i.blend_mode); //Number(i.blend_mode);
- var b = i.blend_color;
- var c = i.color_tone;
- this.setBlendColor([b['R'], b['G'], b['B'], b['A']]);
- this.setColorTone([c['R'], c['G'], c['B'], c['Gray']]);
- // Detalhes da Animação
- this.count = 0;
- this.sfx_wait = Number(i.sfx_wait);
- this.animation_id = Number(i.animation_id);
- this.speed = Number(i.speed);
- this.wait_time = Number(i.wait_time);
- this._duration = Number(i.total_frames) * Number(i.speed) + Number(i.wait_time);
- };
- // Carregando o arquivo que queremos
- Sprite_Balloon.prototype.loadBitmap = function() {
- this.bitmap = ImageManager.loadSystem(items[this._balloonId - 1].filename);
- this.setFrame(0, 0, 0, 0);
- };
- // Atualização do sprite
- var _Sprite_Balloon_update = Sprite_Balloon.prototype.update;
- Sprite_Balloon.prototype.update = function() {
- _Sprite_Balloon_update.call(this);
- var a = items[this._balloonId - 1];
- if (this.sfx_wait == this.count){
- AudioManager.playSe({name: a.sfx_filename, pan: a.sfx_pan, pitch: a.sfx_pitch, volume: a.sfx_volume});
- };
- this.count++;
- };
- // Atualização do quadro de animação
- Sprite_Balloon.prototype.updateFrame = function() {
- var sx = this.frameIndex() * this.fw;
- var sy = (this.animation_id - 1) * this.fh;
- this.setFrame(sx, sy, this.fw, this.fh);
- };
- // Velocidade da animação
- Sprite_Balloon.prototype.speed = function() {
- return Number(items[this._balloonId - 1].speed);
- };
- // Espera adicional do quadro final
- Sprite_Balloon.prototype.waitTime = function() {
- return Number(items[this._balloonId - 1].wait_time);
- };
- // Tem que ficar por algum motivo que ignoro...
- Sprite_Balloon.prototype.frameIndex = function() {
- var index = (this._duration - this.wait_time) / this.speed;
- return items[this._balloonId - 1].total_frames - Math.max(Math.floor(index), 0);
- };
- })(); // Não deletar!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement