I'm currently making a game that uses SumRndmDde's Shaking text plugin, and I would really like to use Galv's message sound effects in conjunction with it, but they don't seem to be compatible. Can someone who understands code help me to make these compatible? I'm sure it would be helpful to a whole lot of other people as well.
SumRndmDde's Shaking Text
Galv's Message Sound Effects
Thank you in advance for any help you can provide!
SumRndmDde's Shaking Text
Code:
/*:
* @plugindesc Allows you to add Shaking Text to your Show Text events!
* @author SumRndmDde
*
* @param Reset Shaking per Box
* @desc If this is set to 'true', then all shaking effects will be reset every time the Message Window is cleared.
* @default true
*
* @param Default Shaking Power
* @desc The Shaking Power used when using \Shake without any parameters.
* @default $.randomNum(0.2, 0.5)
*
* @param Default Shaking Max
* @desc The Shaking Max used when using \Shake without any parameters.
* @default 1
*
* @param Default Wave Power
* @desc The Wave Power used when using \Wave without any parameters.
* @default 0.5
*
* @param Default Wave Max
* @desc The Wave Max used when using \Wave without any parameters.
* @default 4
*
* @param Default Slide Power
* @desc The Slide Power used when using \Slide without any parameters.
* @default 0.5
*
* @param Default Slide Max
* @desc The Slide Max used when using \Slide without any parameters.
* @default 4
*
* @param Copy Outline
* @desc If 'true', the outline function will be copied.
* @default true
*
* @help
*
* Shaking Text
* Version 1.12
* SumRndmDde
*
*
* This Plugin allows you to add animated text effects to your Show Text
* events.
*
* This can be done using very simple escape codes within the Show Text
* events themselves. Doing so will allow you to customize your own
* shaking and wavy effects!
*
*
* ==========================================================================
* Show Text Escape Codes
* ==========================================================================
*
* Use the following escape codes in any Show Text event:
*
* \Shake - Sets text to default shaking values
* \Shake<power> - Creates a shake effect from simple number
* \Shake<xSpd, ySpd> - Creates shake from seperate x and y speeds
* \Shake<xSpd, ySpd, xMax, yMax> - Gives absolute control over shaking
* effect; can control x/y speed, along with
* the maximum distance the characters can
* travel before reversing.
*
* -------------------------------------------------------------------------
*
* \Wave - Sets wave effect based off of default
* wave values
* \Wave<speed, max> - Sets wave effect based off of speed and
* max distance the characters can travel
*
* -------------------------------------------------------------------------
*
* \Slide - Sets slide effect based off of default
* slide values
* \Slide<speed, max> - Sets slide effect based off of speed and
* max distance the characters can travel
*
* -------------------------------------------------------------------------
*
* \Circle - Sets circle effect.
*
* -------------------------------------------------------------------------
*
* \ResetShake - Resets all shaking
*
*
* ==========================================================================
* End of Help File
* ==========================================================================
*
* Welcome to the bottom of the Help file.
*
*
* Thanks for reading!
* If you have questions, or if you enjoyed this Plugin, please check
* out my YouTube channel!
*
* https://www.youtube.com/c/SumRndmDde
*
*
* Until next time,
* ~ SumRndmDde
*
*/
var SRD = SRD || {};
SRD.ShakingText = SRD.ShakingText || {};
var Imported = Imported || {};
Imported["SumRndmDde Shaking Text"] = 1.12;
(function(_) {
var params = PluginManager.parameters('SRD_ShakingText');
_.resetShaking = String(params['Reset Shaking per Box']).trim().toLowerCase() === 'true';
_.defaultShakePower = String(params['Default Shaking Power']);
_.defaultShakeMax = String(params['Default Shaking Max']);
_.defaultWavePower = String(params['Default Wave Power']);
_.defaultWaveMax = String(params['Default Wave Max']);
_.outline = String(params['Copy Outline']).trim().toLowerCase() === 'true';
var $ = {};
$.randomNum = function(min, max) {
var temp = (max - min) * 100;
var temp2 = min * 100;
if(temp <= 0) alert("When using the 'randomNum' function, the minimum number was greater than the maximum.");
return Number(Math.floor(Math.randomInt(temp) + temp2) / 100);
}
//-----------------------------------------------------------------------------
// Window_Message
//-----------------------------------------------------------------------------
var _Window_Message_initialize = Window_Message.prototype.initialize;
Window_Message.prototype.initialize = function(x, y, width, height) {
_Window_Message_initialize.call(this, x, y, width, height);
this._textShaking = [0, 0, 0, 0];
this._shakingSprites = [];
this._fastShakeInterval = 0;
};
var _Window_Message_processNormalCharacter = Window_Message.prototype.processNormalCharacter;
Window_Message.prototype.processNormalCharacter = function(textState) {
if(this.isShakingActive() && !this._checkWordWrapMode) {
if(Imported.YEP_MessageCore && this.checkWordWrap(textState)) {
return this.processNewLine(textState);
}
var c = textState.text[textState.index++];
var w = this.textWidth(c);
var h = textState.height;
this.createShakingCharacter(textState, c, w, h);
textState.x += w;
} else {
_Window_Message_processNormalCharacter.call(this, textState);
}
};
var _Window_Message_obtainEscapeCode = Window_Message.prototype.obtainEscapeCode;
Window_Message.prototype.obtainEscapeCode = function(textState) {
var shake = (Imported.YEP_MessageCore) ? !this._checkWordWrapMode : true;
textState.index++;
if(textState.text.slice(textState.index, textState.index+5).match(/shake/i)) {
textState.index += 5;
return (shake) ? "SHAKE" : "";
} else if(textState.text.slice(textState.index, textState.index+4).match(/wave/i)) {
textState.index += 4;
return (shake) ? "WAVE" : "";
} else if(textState.text.slice(textState.index, textState.index+5).match(/slide/i)) {
textState.index += 5;
return (shake) ? "SLIDE" : "";
} else if(textState.text.slice(textState.index, textState.index+6).match(/circle/i)) {
textState.index += 6;
return (shake) ? "CIRCLE" : "";
} else if(textState.text.slice(textState.index, textState.index+10).match(/resetshake/i)) {
textState.index += 10;
return (shake) ? "RESETSHAKE" : "";
} else {
textState.index--;
return _Window_Message_obtainEscapeCode.call(this, textState);
}
};
Window_Message.prototype.isShakingActive = function() {
return (this._textShaking[0] > 0 || this._textShaking[0] === 'circle') ||
this._textShaking[1] > 0 || this._textShaking[2] > 0 || this._textShaking[3] > 0;
};
Window_Message.prototype.createShakingCharacter = function(textState, c, w, h) {
if(this._textShaking[0] === 'circle') {
var sprite = new Sprite_Shake(new Bitmap(w, h), 'circle', 0, 0, 0);
} else {
var sprite = new Sprite_Shake(new Bitmap(w, h), eval(this._textShaking[0]), eval(this._textShaking[1]),
eval(this._textShaking[2]), eval(this._textShaking[3]));
}
sprite.bitmap.textColor = this.contents.textColor;
sprite.bitmap.paintOpacity = this.contents.paintOpacity;
sprite.bitmap.fontSize = this.contents.fontSize;
sprite.bitmap.fontFace = this.contents.fontFace;
if(_.outline) sprite.bitmap._drawTextOutline = this.contents._drawTextOutline;
sprite.bitmap.drawText(c, 0, 0, w, h);
sprite.x = textState.x + this.standardPadding();
sprite.y = textState.y + this.standardPadding();
sprite._xBase = sprite.x;
sprite._yBase = sprite.y;
this.addChild(sprite);
this._shakingSprites.push(sprite);
if(this._showFast || this._lineShowFast) {
for(var i = 0; i < this._fastShakeInterval; i++) {
sprite.update();
}
this._fastShakeInterval += 2;
} else {
this._fastShakeInterval = 0;
}
};
var _Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
Window_Message.prototype.processEscapeCharacter = function(code, textState) {
switch (code) {
case 'SHAKE':
var params = this.obtainShakingTextParams(textState);
var info = String(params).match(/(.+)\s*,\s*(.+)\s*,\s*(.*)\s*,\s*(.*)/);
var info2 = String(params).match(/(.+)\s*,\s*(.+)/);
var info3 = String(params).match(/(.+)/);
if(info) {
this._textShaking[0] = String(info[1]);
this._textShaking[1] = String(info[2]);
this._textShaking[2] = String(info[3]);
this._textShaking[3] = String(info[4]);
} else if(info2) {
this._textShaking[0] = String(info2[1]);
this._textShaking[1] = String(info2[2]);
this._textShaking[2] = _.defaultShakeMax;
this._textShaking[3] = _.defaultShakeMax;
} else if(info3) {
var spd = "Math.random() + " + String(Math.floor((Number(info3[1]) / 10) * 100) / 100);
this._textShaking[0] = spd;
this._textShaking[1] = spd;
this._textShaking[2] = _.defaultShakeMax;
this._textShaking[3] = _.defaultShakeMax;
} else {
this._textShaking[0] = _.defaultShakePower;
this._textShaking[1] = _.defaultShakePower;
this._textShaking[2] = _.defaultShakeMax;
this._textShaking[3] = _.defaultShakeMax;
}
break;
case 'WAVE':
var info = String(this.obtainShakingTextParams(textState)).match(/(.+)\s*,\s*(.+)/);
this._textShaking[0] = "0";
this._textShaking[2] = "0";
if(info) {
this._textShaking[1] = String(info[1]);
this._textShaking[3] = String(info[2]);
} else {
this._textShaking[1] = _.defaultWavePower;
this._textShaking[3] = _.defaultWaveMax;
}
break;
case 'SLIDE':
var info = String(this.obtainShakingTextParams(textState)).match(/(.+)\s*,\s*(.+)/);
this._textShaking[1] = "0";
this._textShaking[3] = "0";
if(info) {
this._textShaking[0] = String(info[1]);
this._textShaking[2] = String(info[2]);
} else {
this._textShaking[0] = _.defaultWavePower;
this._textShaking[2] = _.defaultWaveMax;
}
break;
case 'CIRCLE':
this._textShaking[0] = "circle";
this._textShaking[1] = 0;
this._textShaking[2] = 0;
this._textShaking[3] = 0;
break;
case 'RESETSHAKE':
this.resetShaking();
break;
default:
_Window_Message_processEscapeCharacter.call(this, code, textState);
break;
}
};
Window_Message.prototype.obtainShakingTextParams = function(textState) {
var arr = /^\<.+\>/.exec(textState.text.slice(textState.index));
if (arr) {
textState.index += arr[0].length;
return String(arr[0].slice(1, arr[0].length-1));
} else {
return '';
}
};
var _Window_Message_open = Window_Message.prototype.open;
Window_Message.prototype.open = function() {
_Window_Message_open.call(this);
for(var i = 0; i < this._shakingSprites.length; i++) {
this._shakingSprites[i].opacity = 255;
}
};
var _Window_Message_close = Window_Message.prototype.close;
Window_Message.prototype.close = function() {
_Window_Message_close.call(this);
for(var i = 0; i < this._shakingSprites.length; i++) {
this._shakingSprites[i].opacity = 0;
}
};
Window_Message.prototype.removeShakingSprites = function() {
for(var i = 0; i < this._shakingSprites.length; i++) {
this.removeChild(this._shakingSprites[i]);
}
};
Window_Message.prototype.resetShaking = function() {
for(var i = 0; i < this._textShaking.length; i++) {
this._textShaking[i] = 0;
}
};
var _Window_Message_newPage = Window_Message.prototype.newPage;
Window_Message.prototype.newPage = function(textState) {
_Window_Message_newPage.call(this, textState);
this.removeShakingSprites();
if(_.resetShaking) this.resetShaking();
};
//-----------------------------------------------------------------------------
// Sprite_Shake
//-----------------------------------------------------------------------------
function Sprite_Shake() {
this.initialize.apply(this, arguments);
}
Sprite_Shake.prototype = Object.create(Sprite.prototype);
Sprite_Shake.prototype.constructor = Sprite_Shake;
Sprite_Shake.prototype.initialize = function(bitmap, xSpd, ySpd, xMax, yMax) {
Sprite.prototype.initialize.call(this, bitmap);
if(xSpd === 'circle') {
this._xSpd = 'circle';
this._aniCouter = 0;
this._xBase = this.x;
this._yBase = this.y;
} else {
this._xSpd = xSpd;
this._ySpd = ySpd;
this._xMax = xMax;
this._yMax = yMax;
this._xBase = this.x;
this._yBase = this.y;
}
};
Sprite_Shake.prototype.update = function() {
Sprite.prototype.update.call(this);
if(this._xSpd === 'circle') {
this._aniCouter -= (Math.PI * 0.06);
if(this._aniCouter > (Math.PI * 2)) this._aniCouter -= (Math.PI * 2);
this._xAniOff = Math.cos(this._aniCouter) * 3;
this._yAniOff = Math.sin(this._aniCouter) * 3;
this.x = this._xBase + this._xAniOff;
this.y = this._yBase + this._yAniOff;
} else {
this.x += this._xSpd;
this.y += this._ySpd;
if(Math.abs(this.x - this._xBase) > this._xMax) this._xSpd *= (-1);
if(Math.abs(this.y - this._yBase) > this._yMax) this._ySpd *= (-1);
}
};
})(SRD.ShakingText);
Galv's Message Sound Effects
Code:
//-----------------------------------------------------------------------------
// Galv's Message Sound Effects
//-----------------------------------------------------------------------------
// For: RPGMAKER MV
// GALV_MessageSoundEffects.js
//-----------------------------------------------------------------------------
// 2016-10-31 - Version 1.4 - Made aliasing globally obtainable, set ability
// to change the pan of sound effects.
// 2015-11-12 - Version 1.3 - Added delay time to sound effect
// 2015-11-12 - Version 1.2 - Fixed some code that didnt break anything
// 2015-11-11 - Version 1.1 - added Galv plugin command efficiency code
// 2015-11-04 - Version 1.0 - release
//-----------------------------------------------------------------------------
// Terms can be found at:
// galvs-scripts.com
//-----------------------------------------------------------------------------
var Imported = Imported || {};
Imported.Galv_MessageSE = true;
var Galv = Galv || {}; // Galv's main object
Galv.pCmd = Galv.pCmd || {}; // Plugin Command manager
Galv.MSE = Galv.MSE || {}; // Galv's stuff
//-----------------------------------------------------------------------------
/*:
* @plugindesc Play sound effects when during Show Text event commands.
*
* @author Galv - galvs-scripts.com
*
* @param Delay Time
* @desc PEriod of time (frames) after each SE that the next SE cannot play for
* @default 10
*
* @param Default Talk SE
* @desc Sound effect played during each character in a Show Text
* message. FileName,volume,pitch,pan(optional).
* @default Cursor1,80,150
*
* @param Default Confirm SE
* @desc Sound effect played When player confirms message to
* continue. FileName,volume,pitch,pan(optional).
* @default Cursor2,80,150
*
* @param -----------
* @desc Doesn't do anything
*
* @default
*
* @param Quick SE 1
* @desc To use in the quick talk plugin command as 1.
*
* @default
*
* @param Quick SE 2
* @desc To use in the quick talk plugin command as 2.
*
* @default
*
* @param Quick SE 3
* @desc To use in the quick talk plugin command as 3.
*
* @default
*
* @param Quick SE 4
* @desc To use in the quick talk plugin command as 4.
*
* @default
*
* @help
* Galv's Message Sound Effects
* -----------------------------------------------------------------------------
* Set the default sound effects in the plugin settings for characters showing
* and for confirming the Show Text message. The parameters are:
*
* SoundName,volume,pitch,pan(optional)
*
* Separated by commas. For example, the below will play the Cursor1 SE at 80
* volume and 150 pitch:
* Cursor1,80,150
*
* While this plugin allows you to do more or less, RPG Maker MV usually
* restricts users to certain amounts:
* Volume: 0 - 100
* Pitch: 50 - 150
*
* -----------------------------------------------------------------------------
* PLUGIN COMMANDS
* -----------------------------------------------------------------------------
* MSGSE TALK CLEAR // Removes talk SE
* MSGSE TALK DEFAULT // Returns talk SE to default
* MSGSE TALK SoundName vol pit pan // Sets talk SE to a specific sound
* MSGSE TALK x // Change talk SE to a quick talk. x = 1-4
*
* MSGSE CONFIRM CLEAR // Removes the confirm SE
* MSGSE CONFIRM DEFAULT // Returns confirm SE to default
* MSGSE CONFIRM SoundName vol pit pan // Sets confirm SE to a specific sound
* MSGSE CONFIRM x // Change confirm SE to a quick SE 1-4
* -----------------------------------------------------------------------------
* Note: pan settings can be left out to return to 0 (default).
* Once a plugin is called, the SE's will stay changed until changed again.
*/
(function() {
// GALV'S PLUGIN MANAGEMENT. INCLUDED IN ALL GALV PLUGINS THAT HAVE PLUGIN COMMAND CALLS, BUT ONLY RUN ONCE.
if (!Galv.aliased) {
Galv.MSE.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function(command, args) {
if (Galv.pCmd[command]) {
Galv.pCmd[command](args);
return;
};
Galv.MSE.Game_Interpreter_pluginCommand.call(this, command, args);
};
Galv.aliased = true; // Don't keep aliasing for other Galv scripts.
};
// Direct to Plugin Object
Galv.pCmd.MSGSE = function(arguments) {
Galv.MSE.plugin(arguments);
};
// END GALV'S PLUGIN MANAGEMENT
Galv.MSE.plugin = function(arr) {
if (arr[0] !== "TALK" && arr[0] !== "CONFIRM") return;
// Get Sound
switch (arr[1]) {
case "CLEAR":
sound = Galv.MSE.makeSound(["",0,100]);
break;
case "DEFAULT":
sound = "default";
break;
case "1": case "2": case "3": case "4":
// Quick SE
sound = Galv.MSE.quickSE[Number(arr[1])];
break;
default:
obj = {
name: arr[1],
pan: Number(arr[4]) || 0,
pitch: Number(arr[3]),
volume: Number(arr[2])
};
sound = obj;
break;
};
// Set sound
if (arr[0] === "TALK") {
if (sound === "default") {
$gameMessage.msgSe = Galv.MSE.defaultSe;
} else {
$gameMessage.msgSe = sound;
};
} else if (arr[0] === "CONFIRM") {
if (sound === "default") {
$gameMessage.msgConfirmSe = Galv.MSE.defaultConfirmSe;
} else {
$gameMessage.msgConfirmSe = sound;
};
};
};
Galv.MSE.makeSound = function(txt) {
if (Array.isArray(txt)) {
var arr = txt;
} else {
var arr = txt.split(",");
};
var obj = {
name: arr[0],
pan: Number(arr[3]) || 0,
pitch: Number(arr[2]),
volume: Number(arr[1])
};
return obj;
};
Galv.MSE.delay = Number(PluginManager.parameters('GALV_MessageSoundEffects')["Delay Time"]);
Galv.MSE.defaultSe = Galv.MSE.makeSound(PluginManager.parameters('GALV_MessageSoundEffects')["Default Talk SE"]);
Galv.MSE.defaultConfirmSe = Galv.MSE.makeSound(PluginManager.parameters('GALV_MessageSoundEffects')["Default Confirm SE"]);
Galv.MSE.quickSE = [];
for (var i = 1; i < 5; i++) {
var name = "Quick SE " + i
Galv.MSE.quickSE[i] = Galv.MSE.makeSound(PluginManager.parameters('GALV_MessageSoundEffects')[name]);
};
Galv.MSE.Game_Message_initialize = Game_Message.prototype.initialize;
Game_Message.prototype.initialize = function() {
this.msgSe = Galv.MSE.defaultSe;
this.msgConfirmSe = Galv.MSE.defaultConfirmSe;
Galv.MSE.Game_Message_initialize.call(this);
};
Galv.MSE.Window_Message_startMessage = Window_Message.prototype.startMessage;
Window_Message.prototype.startMessage = function() {
this.delayTime = Galv.MSE.delay;
Galv.MSE.Window_Message_startMessage.call(this);
};
Galv.MSE.Window_Message_updateMessage = Window_Message.prototype.updateMessage;
Window_Message.prototype.updateMessage = function() {
this.delayTime += 1;
return Galv.MSE.Window_Message_updateMessage.call(this);
};
Galv.MSE.Window_Message_processNormalCharacter = Window_Base.prototype.processNormalCharacter;
Window_Message.prototype.processNormalCharacter = function(textState) {
if (!this._showFast) {
if (this.delayTime >= Galv.MSE.delay) {
AudioManager.playSe($gameMessage.msgSe);
this.delayTime = 0;
};
};
Galv.MSE.Window_Message_processNormalCharacter.call(this, textState);
};
Galv.MSE.Window_Message_terminateMessage = Window_Message.prototype.terminateMessage;
Window_Message.prototype.terminateMessage = function() {
AudioManager.playSe($gameMessage.msgConfirmSe);
this.delayTime = Galv.MSE.delay;
Galv.MSE.Window_Message_terminateMessage.call(this);
};
})();
Thank you in advance for any help you can provide!