Battle Voice Format Help

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
I've been working with the BattleVoice.js plugin that comes with the regular list of Kadokawa Plugins if you're using the Steam version.

The plugin works fine I was just trying to change it a bit the suit my needs. In my game I have added an extra skill type called "Master" that I want the characters to also speak for. However, just going into the plugin and changing the syntax of all "skills" to "Master" does not work and creates errors. I was wondering if there is anyone who can explain to me how to properly edit the plugin to add the "Master" skill type to the voices.


What I've been doing is taking anything that is like this

SoundManager.playActorVoice = function(actor, type){
var name = '';
switch(type){
case 'skill':
name = actor.meta.skillVoice;
break;
}
if(name){
var audio = AudioManager.createAudioByFileame(name);
AudioManager.playSe(audio);

And instead of

name = actor.meta.skillVoice; I would replace that with
name = actor.meta.masterVoice;

I would replace it with that instead with no results or errors. What I'm looking for is help on how to properly format it.
 

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,008
Reaction score
317
First Language
Dutch
Primarily Uses
RMMV
var audio = AudioManager.createAudioByFileame(name);
You missing an N in AudioFileName, idk if this cause the errors though, and I dont know the plugin by itself so I cant look
through it. but if it goes to "skill type" and you add "Master" than I asume every skill type in that list?
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
You missing an N in AudioFileName, idk if this cause the errors though, and I dont know the plugin by itself so I cant look
through it. but if it goes to "skill type" and you add "Master" than I asume every skill type in that list?
Well adding an N certainly fixed the errors but the plugin still refuses to add the added script call I've made. It plays a voice for skill but not for the master skill. Unfortunately the plugin doesn't go to skill types.

Here's the code I'm working with.

Code:
//
 
//
  // process parameters
  //
  var parameters = PluginManager.parameters('BattleVoice');
  var pitch = Number(parameters['pitch']) || 100;
  var volume = Number(parameters['volume']) || 90;

  AudioManager.createAudioByFilename = function(name){
    var audio = {};
    audio.name = name;
    audio.pitch = pitch;
    audio.volume = volume;
    return audio;
  };

  //
  // play actor voice
  //
  SoundManager.playActorVoice = function(actor, type){
    var name = '';
    switch(type){
      case 'attack':
        name = actor.meta.attackVoice;
        break;
      case 'recover':
        name = actor.meta.recoverVoice;
        break;
      case 'friendmagic':
        name = actor.meta.friendMagicVoice || actor.meta.magicVoice;
        break;
      case 'magic':
        name = actor.meta.magicVoice;
        break;
      case 'skill':
        name = actor.meta.skillVoice;
        break;
      case 'damage':
        name = actor.meta.damageVoice;
        break;
      case 'dead':
        name = actor.meta.defeatedVoice;
        break;
      case 'victory':
        name = actor.meta.victoryVoice;
        break;
     case 'master':
       name = actor.meta.skillVoice || actor.meta.skillMasterVoice;
       break;
    }
    if(name){
      var audio = AudioManager.createAudioByFilename(name);
      AudioManager.playSe(audio);
    }
  };

  //
  // functions for call actor voice.
  //
  var _Game_Actor_performAction = Game_Actor.prototype.performAction;
  Game_Actor.prototype.performAction = function(action) {
    _Game_Actor_performAction.call(this, action);
    if (action.isAttack()) {
      SoundManager.playActorVoice(this.actor(), 'attack');
    } else if (action.isMagicSkill() && action.isHpRecover()) {
      SoundManager.playActorVoice(this.actor(), 'recover');
    } else if (action.isMagicSkill() && action.isForFriend()) {
      SoundManager.playActorVoice(this.actor(), 'friendmagic');
    } else if (action.isMagicSkill()) {
      SoundManager.playActorVoice(this.actor(), 'magic');
    } else if (action.isSkill() && !action.isGuard()) {
      SoundManager.playActorVoice(this.actor(), 'skill');
     else if (action.isSkill() && !action.isSkillMaster()) {
      SoundManager.playActorVoice(this.actor(), 'master');
    }
  };

  var _Game_Actor_performDamage = Game_Actor.prototype.performDamage;
  Game_Actor.prototype.performDamage = function() {
    _Game_Actor_performDamage.call(this);
    SoundManager.playActorVoice(this.actor(), 'damage');
  };

  var _Game_Actor_performCollapse = Game_Actor.prototype.performCollapse;
  Game_Actor.prototype.performCollapse = function() {
    _Game_Actor_performCollapse.call(this);
    if ($gameParty.inBattle()) {
      SoundManager.playActorVoice(this.actor(), 'dead');
    }
  };

  var _BattleManager_processVictory = BattleManager.processVictory;
  BattleManager.processVictory = function() {
    var index = Math.randomInt($gameParty.aliveMembers().length);
    var actor = $gameParty.aliveMembers()[index].actor();
    SoundManager.playActorVoice(actor, 'victory');
    _BattleManager_processVictory.call(this);
  };

})();


})();
 
Last edited:

ShadowDragon

Veteran
Veteran
Joined
Oct 8, 2018
Messages
1,008
Reaction score
317
First Language
Dutch
Primarily Uses
RMMV
AudioManager.createAudioByFileame = function(name){
var audio = AudioManager.createAudioByFileame(name);
both those lines missing the N, but if that is corrected, than I have no clue,
idk if you can modify the BattleVoices.js plugin to read any skill type so it work,
or by adding the missing skill in "Master", but I think a good coder can help you out there.

I dont know how much a typo can fix things or not to be honest.
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
both those lines missing the N, but if that is corrected, than I have no clue,
idk if you can modify the BattleVoices.js plugin to read any skill type so it work,
or by adding the missing skill in "Master", but I think a good coder can help you out there.

I dont know how much a typo can fix things or not to be honest.
Yeah fixing the typo doesn't seem to do much in this case. Though thanks for the effort. I know it has something to do with the syntax I'm using but I'm not sure what. I'm no ace at JS and I'm pretty much just guessing that's how it's supposed to be written.
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
118
Reaction score
116
First Language
Danish
Primarily Uses
RMMV
Seems like you have a couple of mistakes. First in the playActorVoice in the case that it is 'master' then if skillVoice exists it would use that instead of skillMasterVoice.
Second (and biggest mistake) in performAction, look at the last if statement. It says that if the action is a skill and it is not guard then it would play the 'skill' voice. So your new if statement would only be reached if you're guarding. (I suppose this is not what you want) Furthermore, you actually say that it should only use the 'master' voice if it is not a master skill. The ! means not (or negate) so !action.isSkillMaster() means that the action is not a Master skill.
Try removing the ! and move the if statement up one place so it gets checked before the if statement with action.isGuard() :)
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
Second (and biggest mistake) in performAction, look at the last if statement. It says that if the action is a skill and it is not guard then it would play the 'skill' voice. So your new if statement would only be reached if you're guarding. (I suppose this is not what you want) Furthermore, you actually say that it should only use the 'master' voice if it is not a master skill....
I moved things around as you suggested and got rid of the "!" but now the entire plugin is being ignored somehow. Now it won't play any of the sounds. I'm starting to think that by adding the master skill the way I have the plugin does not even know what a "masterVoice" is. Since I added it in the database rather than in the games meta files itself.

I need to figure out what to write if it was added in the database, since master voice or master skill technically doesn't exist normally and I think that is what the "meta" code is for.

Changing it to "skillTypeMaster" does not work either
 

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
118
Reaction score
116
First Language
Danish
Primarily Uses
RMMV
If the entire plugin is being ignored then you probably have a syntax error somewhere preventing it from being loaded.
The meta data is defined in the database in the Note field. Meta tags are pretty much a specific type of note tags. Your meta tag for masterVoice is <masterVoice:NAME_OF_SOUNDEFFECT>

Do you actually even have a function isSkillMaster() define for actions which determines if a skill is a Master skill?

If you can wait a few days I'll just fix it all for you. I dont have access to a computer at the moment and I probably wont until Sunday
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
The meta data is defined in the database in the Note field. Meta tags are pretty much a specific type of note tags. Your meta tag for masterVoice is <masterVoice:NAME_OF_SOUNDEFFECT>

Do you actually even have a function isSkillMaster() define for actions which determines if a skill is a Master?...
No I dont have any such function within the plugin because I assumed it wasn't needed since the other lines didn't show anything like that either.

Im ok with waiting if you're willing to help me figure this out when you get back to your computer. I don't plan on releasing this demo for a while so I have time to really crack down on this plugin.
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,641
Reaction score
2,971
First Language
Tagalog
Primarily Uses
If the plugin didnt define those, that is probably because those exist on the base JS files (a lot of plugin relies on a lot of the default JS files)

Since the master skill is added by you, you actually need to write your own function which does the checking
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
Since the master skill is added by you, you actually need to write your own function which does the checking...
Ah that would make a lot of sense. Where in the plugin file would I need to add such a line and how would I format it as well?
something like this?
if function isSkillMaster() or do i need to write something else?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,641
Reaction score
2,971
First Language
Tagalog
Primarily Uses
You need to make an actual new function called isSkillMaster which does the checking and returns the results so that your case/if would actually work.

Something like

Code:
function isSkillMaster(parameters here) {
  do the check here
  return result
};
Since the way you made it is that master is a skill type (if Im correct) then the function would take the skill as its parameter and check if the skill's skill type ID is the one that master corresponds to.

Or instead of making a new function amd making your case/if call that function, you can inline the check in your case/if statement

So instead of

Code:
if isSkillMaster(params)
you'd do

Code:
if (skill type check here)
 
Last edited:

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
118
Reaction score
116
First Language
Danish
Primarily Uses
RMMV
Okay so I made you this extension to BattleVoice. With this you can specify which skill types (by their ids) that should have its own battle voice. Then it works just like BattleVoice. E.g. if you have a skill type called Master (which you have specified in the parameters to have its own battle voice) then you can use the meta-tag <masterVoice:SOUND_EFFECT_NAME>
 

Attachments

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
Or instead of making a new function amd making your case/if call that function, you can inline the check in your case/if statement

So instead of

Code:
if isSkillMaster(params)
you'd do

Code:
if (skill type check here)
I'm not sure what you mean exactly by skill type check here? I'm not experienced with Js enough to know exactly how to write a skill check line of code. I'm going to need a bit more help than just that.

Okay so I made you this extension to BattleVoice...
Ok I placed the plugin in my project and I got the voices working again but the extension still doesn't play a sound for the skill type? I have your extension under the original battlevoice plugin and the parameter set to "3" since that is the type ID that the master skill is on and yet no dice. I did look at the .js and on the line where it says

var BV_parameters = PluginManager.parameters('BattleVoice');
var playSwitchId = Number(BV_parameters['ON switch ID']) || 21;

There is a 21. I not sure if I should manually change that to 3 or if that is even my problem?
 

Attachments

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
118
Reaction score
116
First Language
Danish
Primarily Uses
RMMV
That sounds odd. Judging from the images it looks like it have been set up correctly. I just tested it again and it seemed to work correctly.
There are a couple of things I can imagine might have gone wrong.
  • Which version of RPG Maker MV do you use? I made this for 1.6.1
  • Did you make direct changes to the BattleVoice plugin? (e.g. the spelling error for createAudioByFileame. You should NOT change this. The spelling error is consistent and I assume it to be there in the extension)
If you could also show me a screenshot of the console (typically opened with F8) when running the game it might help me figure out the error :)
 

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
  • Which version of RPG Maker MV do you use? I made this for 1.6.1
  • Did you make direct changes to the BattleVoice plugin? (e.g. the spelling error for createAudioByFileame. You should NOT change this. The spelling error is consistent and I assume it to be there in the extension)
If you could also show me a screenshot of the console (typically opened with F8) when running the game it might help me figure out the error :)
Ah that would make a lot of sense. I'm still running rpg maker on 1.5.2 as that is the most stable version that works with Terrax Lighting and a few Hime plugins. And yes I did edit the main battle voice plugin correcting those spelling errors as I was told earlier by another user that may have been my problem earlier.

Edit: So I ran another battle and pulled up the log and it would seem the error has something to do with the syntax of line 34.
 

Attachments

Magnus0808

Software Developer
Veteran
Joined
Feb 2, 2019
Messages
118
Reaction score
116
First Language
Danish
Primarily Uses
RMMV
Yep this was exactly what I had suspected. I used some syntax which does not work with version 1.5.2. I have rewritten with an older syntax :)
If you revert the BattleVoice back to before you made changes and apply this updated plugin then it should work :)
Btw you wondered what "var playSwitchId = Number(BV_parameters['ON switch ID']) || 21;" meant, more specifically the "|| 21" part. It simply sets the value of "playSwitchId" to 21 in case that "Number(BV_parameters['ON switch ID'])" is undifined/null :)
 

Attachments

Fangzarie

Veteran
Veteran
Joined
Apr 5, 2018
Messages
43
Reaction score
5
First Language
English
Primarily Uses
RMMV
Yep this was exactly what I had suspected. I used some syntax which does not work with version 1.5.2. I have rewritten with an older syntax :)
If you revert the BattleVoice back to before you made changes and apply this updated plugin then it should work :)
Btw you wondered what "var playSwitchId = Number(BV_parameters['ON switch ID']) || 21;" meant, more specifically the "|| 21" part. It simply sets the value of "playSwitchId" to 21 in case that "Number(BV_parameters['ON switch ID'])" is undifined/null :)
Sweet! That fix was exactly what needed to happen. We could have gotten to this point if I had stated my version up front so sorry about that, but regardless this did the trick like magic! Thanks so much and I'll be sure to credit you for the extension because it was a life saver!

Thanks for clarifying the whole 21 ID thing. It makes a lot of sense and im guessing is a good way to bypass errors of the plugin trying to find a voice that doesn't exist.

I'll be studying the way you made this extension so hopefully I can make these kind of fixes on my own later down the road and maybe help others.

Thanks again.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Behold! The Sea Doggo.
I am dead tired but at the same time I really wanna write a tutorial x_x
Looked out side and couldn't see the neighbor's house through the snow. That age old Christmas song started going through my head. "It's a lovely day to say the heck at home."
Last year, I planted a bunch of spinach, and one plant wasn't doing well, so I transferred it to a separate pot. All its kin died while it hibernated over winter. Now it thrives. I've named it Prince Spinach.
Scooby Doo on Zombie Island is anime and you cant change my mind.

Forum statistics

Threads
93,371
Messages
911,738
Members
122,864
Latest member
sxkira
Top