设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2676|回复: 3

[原创发布] 【迷你插件】单击开始游戏按钮随机播放自定义音效(更新v1.2

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2923
在线时间
140 小时
注册时间
2018-1-22
帖子
137
发表于 2020-5-15 12:58:34 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
本帖最后由 526396987 于 2020-5-16 01:45 编辑
之前闲的时候写了一个简单的小插件,虽然我也不太确定是否有前辈或大佬开发过类似的,但如果本插件对一些人有帮助的话还是献一下丑啦~~

这个插件可以在标题界面点击【新游戏】按钮时播放自定义的SE,比如自己喜欢的音效或者人物语音之类的(不过确实没多大用处。。。)
本插件开源免费,如果是js大佬的话,可以增加很多自己想要的功能。我还是太菜了,大佬求轻喷(可能大佬自己操作都比看这个插件来得快吧 hhhh)

可以直接复制也可以下载附件,复制的情况下,请重命名为"RandomSound"并以JavaScript的扩展名保存。谢谢!


新手向插件帮助


更新履历



  1. //=============================================================================
  2. //  New Game Random Sound
  3. //=============================================================================

  4. var Imported = Imported || {};
  5. Imported.RandomSound = true;
  6. var Sound = Sound || {};

  7. //==============================================================================
  8. /*:
  9. * @author お兄ちゃん大好き
  10. *
  11. * @plugindesc (V1.2) Randomly play se when player press the "New Game" button
  12. *
  13. * @param Sound Files for New Game
  14. *
  15. * @desc List all sound files here you wish to play randomly for New Game. Seperate each sound file with ";".
  16. *
  17. * @param Sound Files for Continue
  18. *
  19. * @desc List all sound files here you wish to play randomly For Continue. Seperate each sound file with ";".
  20. *
  21. * @help
  22. * This plugin only has one parameter, which is sound list that will be played
  23. * randomly when player press the "New Game" button.
  24. *
  25. *                 **The form of the parameter**
  26. * FileName1, volume, pitch, pan; FileName2, volume, pitch, pan
  27. * E.g. Attack1,100,100,0; Attack2,90,120,0
  28. *
  29. *                 Spaces are allowed but NO TRAILING ";"
  30. *
  31. * //=========================================================================
  32. * //                Change Log
  33. * //=========================================================================
  34. * 2020-5-15 v1.0
  35. *     Plugin finished
  36. *
  37. * 2020-5-16 v1.1
  38. *     Optimisation of the algorithm for randomly playing sound effect
  39. *
  40. * 2020-5-16 v1.2
  41. *     New function that randomly play sound effect for Continue button, same as
  42. *     the "New Game"
  43. */

  44.     //=============================================================================
  45.     //    Read Files and Initialsing
  46.     //=============================================================================
  47.     Sound.Param = PluginManager.parameters('RandomSound');
  48.     newGame = String(Sound.Param['Sound Files for New Game']);
  49.     newGame = newGame.split(';');
  50.     conti = String(Sound.Param['Sound Files for Continue']);
  51.     conti = conti.split(';');
  52.    
  53.     for (i = 0; i < newGame.length; i++) {
  54.         var property = new Object(newGame[i].split(','));
  55.         newGame[i] = {};
  56.         newGame[i].name = String(property[0].trim());
  57.         newGame[i].volume = Number(property[1].trim());
  58.         newGame[i].pitch = Number(property[2].trim());
  59.         newGame[i].pan = Number(property[3].trim());
  60.     };

  61.     for (i = 0; i < conti.length; i++) {
  62.         var property = new Object(conti[i].split(','));
  63.         conti[i] = {};
  64.         conti[i].name = String(property[0].trim());
  65.         conti[i].volume = Number(property[1].trim());
  66.         conti[i].pitch = Number(property[2].trim());
  67.         conti[i].pan = Number(property[3].trim());
  68.     };
  69.    
  70. (function() {
  71.     //=============================================================================
  72.     //    Override the new game function
  73.     //=============================================================================
  74.     var randomSound_NewGame = Window_TitleCommand.prototype.processOk;
  75.     Window_TitleCommand.prototype.processOk = function() {
  76.         randomSound_NewGame.call(this);

  77.         if (this.isCurrentItemEnabled() && Window_TitleCommand._lastCommandSymbol == 'newGame') {
  78.             this.playRandomSoundNewGame();
  79.         } else if (this.isCurrentItemEnabled() && Window_TitleCommand._lastCommandSymbol == 'continue') {
  80.             this.playRandomSoundContinue();
  81.         };
  82.     };

  83.     //=============================================================================
  84.     //    Algorithm for randomly playing sound
  85.     //=============================================================================
  86.     Window_TitleCommand.prototype.playRandomSoundNewGame = function() {
  87.         var rate = 0;

  88.         if (newGame.length > 1) {
  89.             rate = Math.floor(Math.random() * newGame.length);
  90.         };

  91.         if (newGame.length != 0)
  92.         AudioManager.playSe( {"name":newGame[rate].name, "volume":newGame[rate].volume, "pitch":newGame[rate].pitch, "pan":newGame[rate].pan} );
  93.     };

  94.     Window_TitleCommand.prototype.playRandomSoundContinue = function() {
  95.         var rate = 0;
  96.         
  97.         if (conti.length > 1) {
  98.             rate = Math.floor(Math.random() * conti.length);
  99.         };

  100.         if (conti.length != 0)
  101.         AudioManager.playSe( {"name":conti[rate].name, "volume":conti[rate].volume, "pitch":conti[rate].pitch, "pan":conti[rate].pan} );
  102.     };

  103. })();
复制代码





RandomSound.zip

1.29 KB, 下载次数: 87

评分

参与人数 2+2 收起 理由
白嫩白嫩的 + 1 大佬666
raisewing + 1 塞糖

查看全部评分

自分自身の神様になること

Lv3.寻梦者

梦石
0
星屑
1502
在线时间
115 小时
注册时间
2020-5-10
帖子
82
发表于 2020-5-15 14:36:54 | 显示全部楼层
有点意思,谢谢分享
"明るい夜"のために
回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
1443
在线时间
250 小时
注册时间
2020-9-1
帖子
15
发表于 2020-11-3 19:36:21 | 显示全部楼层
楼主,这个插件用不了,我试过了
搜狗截图20201103193334.jpg

点评

请问可以提供一下报错界面的截图吗?我自己这边是没有问题的  发表于 2020-12-5 21:55
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 14:32

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表