Project1
标题:
【迷你插件】单击开始游戏按钮随机播放自定义音效(更新v1.2
[打印本页]
作者:
526396987
时间:
2020-5-15 12:58
标题:
【迷你插件】单击开始游戏按钮随机播放自定义音效(更新v1.2
本帖最后由 526396987 于 2020-5-16 01:45 编辑
之前闲的时候写了一个简单的小插件,虽然我也不太确定是否有前辈或大佬开发过类似的,但如果本插件对一些人有帮助的话还是献一下丑啦~~
这个插件可以在标题界面点击【
新游戏
】按钮时播放自定义的SE,比如自己喜欢的音效或者人物语音之类的(不过确实没多大用处。。。)
本插件开源免费,
如果是js大佬的话,可以增加很多自己想要的功能。
我还是太菜了,大佬求轻喷
(可能大佬自己操作都比看这个插件来得快吧 hhhh)
可以直接复制也可以下载附件,复制的情况下,请重命名为"RandomSound"并以JavaScript的扩展名保存。谢谢!
[line]6[/line]
[fold=新手向插件帮助]
目前为止,本插件就一个参数,说不定以后有时间会完善更多东西。
参数——音声文件:(请按照以下格式在插件管理器中编辑)
文件名1, 音量(0-100),音调(50-150),声像(-100~100); 文件名2, 音量(0-100),音调(50-150),声像(-100~100)
同一个文件的不同属性用英文逗号隔开,不同的文件用英文分号隔开,空格随意。
注意:最后一个文件的结尾不需要加分号,参考下面例子例子:
Attack1, 100, 100, 0; Attack2, 90, 120, 0
[/fold]
[line]3[/line]
[fold=更新履历]
2020-5-15 v1.0 插件完成
2020-5-16 v1.1 优化随机播放的算法
2020-5-16 v1.2 增加对“继续游戏”随机播放音效的功能,同“新游戏”类似
[/fold]
[line]3[/line]
//=============================================================================
// New Game Random Sound
//=============================================================================
var Imported = Imported || {};
Imported.RandomSound = true;
var Sound = Sound || {};
//==============================================================================
/*:
* @author お兄ちゃん大好き
*
* @plugindesc (V1.2) Randomly play se when player press the "New Game" button
*
* @param Sound Files for New Game
*
* @desc List all sound files here you wish to play randomly for New Game. Seperate each sound file with ";".
*
* @param Sound Files for Continue
*
* @desc List all sound files here you wish to play randomly For Continue. Seperate each sound file with ";".
*
* @help
* This plugin only has one parameter, which is sound list that will be played
* randomly when player press the "New Game" button.
*
* **The form of the parameter**
* FileName1, volume, pitch, pan; FileName2, volume, pitch, pan
* E.g. Attack1,100,100,0; Attack2,90,120,0
*
* Spaces are allowed but NO TRAILING ";"
*
* //=========================================================================
* // Change Log
* //=========================================================================
* 2020-5-15 v1.0
* Plugin finished
*
* 2020-5-16 v1.1
* Optimisation of the algorithm for randomly playing sound effect
*
* 2020-5-16 v1.2
* New function that randomly play sound effect for Continue button, same as
* the "New Game"
*/
//=============================================================================
// Read Files and Initialsing
//=============================================================================
Sound.Param = PluginManager.parameters('RandomSound');
newGame = String(Sound.Param['Sound Files for New Game']);
newGame = newGame.split(';');
conti = String(Sound.Param['Sound Files for Continue']);
conti = conti.split(';');
for (i = 0; i < newGame.length; i++) {
var property = new Object(newGame[i].split(','));
newGame[i] = {};
newGame[i].name = String(property[0].trim());
newGame[i].volume = Number(property[1].trim());
newGame[i].pitch = Number(property[2].trim());
newGame[i].pan = Number(property[3].trim());
};
for (i = 0; i < conti.length; i++) {
var property = new Object(conti[i].split(','));
conti[i] = {};
conti[i].name = String(property[0].trim());
conti[i].volume = Number(property[1].trim());
conti[i].pitch = Number(property[2].trim());
conti[i].pan = Number(property[3].trim());
};
(function() {
//=============================================================================
// Override the new game function
//=============================================================================
var randomSound_NewGame = Window_TitleCommand.prototype.processOk;
Window_TitleCommand.prototype.processOk = function() {
randomSound_NewGame.call(this);
if (this.isCurrentItemEnabled() && Window_TitleCommand._lastCommandSymbol == 'newGame') {
this.playRandomSoundNewGame();
} else if (this.isCurrentItemEnabled() && Window_TitleCommand._lastCommandSymbol == 'continue') {
this.playRandomSoundContinue();
};
};
//=============================================================================
// Algorithm for randomly playing sound
//=============================================================================
Window_TitleCommand.prototype.playRandomSoundNewGame = function() {
var rate = 0;
if (newGame.length > 1) {
rate = Math.floor(Math.random() * newGame.length);
};
if (newGame.length != 0)
AudioManager.playSe( {"name":newGame[rate].name, "volume":newGame[rate].volume, "pitch":newGame[rate].pitch, "pan":newGame[rate].pan} );
};
Window_TitleCommand.prototype.playRandomSoundContinue = function() {
var rate = 0;
if (conti.length > 1) {
rate = Math.floor(Math.random() * conti.length);
};
if (conti.length != 0)
AudioManager.playSe( {"name":conti[rate].name, "volume":conti[rate].volume, "pitch":conti[rate].pitch, "pan":conti[rate].pan} );
};
})();
复制代码
作者:
shmily0725
时间:
2020-5-15 14:36
有点意思,谢谢分享
作者:
吃掉自己的玩家
时间:
2020-11-3 19:36
楼主,这个插件用不了,我试过了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X5.0