forked from Trivel/RMMV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMrTS_DeathSounds.js
91 lines (80 loc) · 3.01 KB
/
MrTS_DeathSounds.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
//=============================================================================
// MrTS_DeathSounds.js
//=============================================================================
/*:
* @plugindesc Makes players and enemies play a different sound on death.
* @author Mr. Trivel
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.0
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Actor/Enemy Tags
* --------------------------------------------------------------------------------
* Place the following tag into Actor or Enemy note fields. You can place multiple
* tags on same character - in that case a random sound will be picked to play.
* <Death: [SFX], [VOL], [PITCH]>
* [SFX] - SFX name
* [VOL] - Volume
* [PITCH] - Pitch
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/
(function() {
var _GameActor_setup = Game_Actor.prototype.setup;
Game_Actor.prototype.setup = function(actorId) {
_GameActor_setup.call(this, actorId);
this._deathSounds = this.parseDeathSounds(this.actor().note);
};
var _GameEnemy_setup = Game_Enemy.prototype.setup;
Game_Enemy.prototype.setup = function(enemyId, x, y) {
_GameEnemy_setup.call(this, enemyId, x, y);
this._deathSounds = this.parseDeathSounds(this.enemy().note);
};
Game_Battler.prototype.parseDeathSounds = function(note) {
var lines = note.split(/[\r\n]/);
var regex = /<Death:[ ]*(.+),[ ]*(\d+),[ ]*(\d+)>/i;
var results = [];
for (var i = 0; i < lines.length; i++) {
var regexMatch = regex.exec(lines[i]);
if (regexMatch)
{
results.push([regexMatch[1], Number(regexMatch[2]), Number(regexMatch[3])]);
}
};
return results;
};
var _GameBattler_performCollapse = Game_Battler.prototype.performCollapse;
Game_Battler.prototype.performCollapse = function() {
_GameBattler_performCollapse.call(this);
if (this._deathSounds.length > 0)
{
var sound = AudioManager.makeEmptyAudioObject();
var randomDeathSound = this._deathSounds[Math.floor(Math.random()*this._deathSounds.length)];
sound.name = randomDeathSound[0];
sound.volume = randomDeathSound[1];
sound.pitch = randomDeathSound[2];
AudioManager.loadStaticSe(sound);
AudioManager.playStaticSe(sound);
}
};
SoundManager.playEnemyCollapse = function() {
};
SoundManager.playBossCollapse1 = function() {
};
SoundManager.playBossCollapse2 = function() {
};
SoundManager.playActorCollapse = function() {
};
})();