With all of yanfly's plugins, how would I reduce a skills cooldown by 2 per enemy hit? Would I need a state to be applied or could it just work inside a <Post-Damage Eval> in the notepad of the skill? I don't want it to reduce on a miss.
Edit: This seems to work but I am not sure if it's the most efficient method.
<Post-Damage Eval>
var turns = 4;
if (a.isActor()){
(a.setCooldown(293, turns - $gameTroop.aliveMembers().length))
}
</Post-Damage Eval>
JavaScript questions that don't deserve their own thread
● ARCHIVED · READ-ONLY
-
-
When using the plugin included with RPGMaker MZ official release (in the DLC folder) to add an Equip command to battle (ChangeEquipOnBattleMZ.js), how would I alter the script to make it so the Equip Command only appears for actors who meet a certain condition (preferably having a State), instead of it always appearing?
I figure it'd be something in the bit of code under "add command to actor command window" note:
Code:// add command to actor command window // const _Scene_Battle_createActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow; Scene_Battle.prototype.createActorCommandWindow = function() { _Scene_Battle_createActorCommandWindow.call(this); this._actorCommandWindow.setHandler('equip', this.commandEquip.bind(this)); }; const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { this.addEquipCommand(); } }; Window_ActorCommand.prototype.addEquipCommand = function() { this.addCommand(commandName, 'equip'); }; //
But I'm not sure on the exact syntax. I attempt to add "&& actor.isStateAffected(x)" [x being the number of the state] to the "if (this._actor)" part in the second paragraph, but to no avail. I have a feeling the exact code I'd need to add should be rather simple though, I'm just lacking the terminology. Anybody able to help me out?
Thanks in advance. -
When using the plugin included with RPGMaker MZ official release (in the DLC folder) to add an Equip command to battle (ChangeEquipOnBattleMZ.js), how would I alter the script to make it so the Equip Command only appears for actors who meet a certain condition (preferably having a State), instead of it always appearing?
I figure it'd be something in the bit of code under "add command to actor command window" note:
Code:// add command to actor command window // const _Scene_Battle_createActorCommandWindow = Scene_Battle.prototype.createActorCommandWindow; Scene_Battle.prototype.createActorCommandWindow = function() { _Scene_Battle_createActorCommandWindow.call(this); this._actorCommandWindow.setHandler('equip', this.commandEquip.bind(this)); }; const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { this.addEquipCommand(); } }; Window_ActorCommand.prototype.addEquipCommand = function() { this.addCommand(commandName, 'equip'); }; //
But I'm not sure on the exact syntax. I attempt to add "&& actor.isStateAffected(x)" [x being the number of the state] to the "if (this._actor)" part in the second paragraph, but to no avail. I have a feeling the exact code I'd need to add should be rather simple though, I'm just lacking the terminology. Anybody able to help me out?
Thanks in advance.
JavaScript:const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { this.addCommand(commandName, 'equip'); } };
I don't know MZ, but so far it seems quite similar. In MV I had issues for some reason, when putting anything other than "this.addCommand()" methods into the MakteCommandList method. So what I would do is directly insert the addCommand method, as seen above.
Hope that works. -
Thanks for the reply; Replacing the bit of code in the script I listed with your suggestion indeed doesn't break it and it still works (so all actors are able to use the equip command in battle, as the original code allows), but still seem to be struggling to figure out a way to get it to do it only when certain conditions are met.JavaScript:
const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { this.addCommand(commandName, 'equip'); } };
I don't know MZ, but so far it seems quite similar. In MV I had issues for some reason, when putting anything other than "this.addCommand()" methods into the MakteCommandList method. So what I would do is directly insert the addCommand method, as seen above.
Hope that works.
I tried removing the bits of code in the script (that I displayed in the previous post) that add the equip battle command altogether from the script itself, then attempting to add the battle command via script in an event script call instead using the code shown, but while it doesn't crash the game the equip command won't appear (for anyone). Adding other requirements referencing specific actors or states in the actual script itself still causes the game to crash with method /isundefined errors and whatnot.
I don't know anything about javascript besides some basic stuff I did through javascript notetags in the past (lunatic mode from yanfly's old MV scripts and the like, attack formulas, or specific javascript conditions in event choice forks), so I'm probably missing a middle-man here that the script requires to call these sort of filtering functions (otherwise, most terminology I'd use in MV still seems to work in other things in MZ, so stuff like .isStateAffected(x) or .isEquipped(x) still works, just not here for some reason).
Any further help would be appreciated, cheers. -
Thanks for the reply; Replacing the bit of code in the script I listed with your suggestion indeed doesn't break it and it still works (so all actors are able to use the equip command in battle, as the original code allows), but still seem to be struggling to figure out a way to get it to do it only when certain conditions are met.
I tried removing the bits of code in the script (that I displayed in the previous post) that add the equip battle command altogether from the script itself, then attempting to add the battle command via script in an event script call instead using the code shown, but while it doesn't crash the game the equip command won't appear (for anyone). Adding other requirements referencing specific actors or states in the actual script itself still causes the game to crash with method /isundefined errors and whatnot.
I don't know anything about javascript besides some basic stuff I did through javascript notetags in the past (lunatic mode from yanfly's old MV scripts and the like, attack formulas, or specific javascript conditions in event choice forks), so I'm probably missing a middle-man here that the script requires to call these sort of filtering functions (otherwise, most terminology I'd use in MV still seems to work in other things in MZ, so stuff like .isStateAffected(x) or .isEquipped(x) still works, just not here for some reason).
Any further help would be appreciated, cheers.
Ok, I think I might understand your problem now.
Is this what you are looking for? Works for MV, should work for MZ too, if the methods remained the same.
JavaScript:_Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { if (this._actor._states.length > 0) this.addCommand(commandName, 'equip'); // checking if actor has any state if (this._actor.isStateAffected(x)) this.addCommand(commandName, 'equip'); // checking if actor has state x } };
/Edit:
Changed the code a little bit to make it look better and added the if (this._actor) condition I forgot to put in. -
Thanks again, yeah I think something somewhere must have changed.
Even though things like .isStateAffected seem to work elsewhere, attempting to use the code suggested results in "Cannot read property '_states' of undefined" if attempting to use the first parameter (checking if actor has any state), and errors with "Cannot read property 'isStateAffected' of undefined" when attempting to use the second parameter (checking if actor has state x, I changed the x to an actual state number of course).
I then attempted to instead be more specific with
Code:just for testing, and in this case it didn't throw a fit over isStateAffected, and worked as you might expect - so long as Actor 2 was Poisoned, everybody would get access to the Equip Command. If poison was removed from actor 2, it would disappear for everyone. A step closer, but not what I'm aiming for.if ($gameActors.actor(2).isStateAffected(5)) this.addCommand(commandName, 'equip'); // checking if actor 2 is poisoned };
EDIT: Oh nevermind, saw you updated your post. Your newer code works perfectly. Thankyou graciously!
Knew it was probably just me missing something simple that needed to be there. It's good so much stuff is still so similar in MZ as it is in MV, makes getting help with things like this easier.
Sorry if my earlier explanations weren't clear, I have a nasty tendency to over-explain confusing people by making stuff sound more complicated than it needs to be ^_^. -
Thanks again, yeah I think something somewhere must have changed.
Even though things like .isStateAffected seem to work elsewhere, attempting to use the code suggested results in "Cannot read property '_states' of undefined" if attempting to use the first parameter (checking if actor has any state), and errors with "Cannot read property 'isStateAffected' of undefined" when attempting to use the second parameter (checking if actor has state x, I changed the x to an actual state number of course).
I then attempted to instead be more specific with
Code:just for testing, and in this case it didn't throw a fit over isStateAffected, and worked as you might expect - so long as Actor 2 was Poisoned, everybody would get access to the Equip Command. If poison was removed from actor 2, it would disappear for everyone. A step closer, but not what I'm aiming for.if ($gameActors.actor(2).isStateAffected(5)) this.addCommand(commandName, 'equip'); // checking if actor 2 is poisoned };
EDIT: Oh nevermind, saw you updated your post. Your new code works. Thankyou!
I edited the code a couple times after posting. Can you confirm, you have the latest version?
Edit:
Btw, checking the actor in Window_ActorCommand, only checks for the actor which is currently selected.
Doing it over $gameActors will allow you to check for every actor if it has a state effect. Is that what you want? -
I edited the code a couple times after posting. Can you confirm, you have the latest version?
Edit:
Btw, checking the actor in Window_ActorCommand, only checks for the actor which is currently selected.
Doing it over $gameActors will allow you to check for every actor if it has a state effect. Is that what you want?
The latest version worked perfectly and was what I wanted. I didn't see your edit till after I posted, and then immediately edited my reply, but maybe I didn't edit it fast enough :).
The version of the code I ended up with was:
JavaScript:While that works perfectly for what I wanted, if you do have some other examples like you mentioned, checking over every actor, I'd still be happy to see them for future reference. Could be useful for anybody else reading this too.const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { // if (this._actor._states.length > 0) this.addCommand(commandName, 'equip'); // checking if actor has any state if (this._actor.isStateAffected(x)) this.addCommand(commandName, 'equip'); // checking if actor has state x } }; -
I'm very proficient in Ruby (used RMXP for years) and I want to switch to JavaScript for MV/MZ.
How can I choose what "preprocessor" to use? I've read that CoffeeScript is slightly similar to Ruby/RGGS. How can I use that in a MZ project? Does it break anything? Does it prevent me from using non-CoffeeScript plugins?
What resources can I use to learn JavaScript, preferably taking advantage of my Ruby background?
Any other advice? -
The latest version worked perfectly and was what I wanted. I didn't see your edit till after I posted, and then immediately edited my reply, but maybe I didn't edit it fast enough :).
The version of the code I ended up with was:
JavaScript:While that works perfectly for what I wanted, if you do have some other examples like you mentioned, checking over every actor, I'd still be happy to see them for future reference. Could be useful for anybody else reading this too.const _Window_ActorCommand_makeCommandList = Window_ActorCommand.prototype.makeCommandList; Window_ActorCommand.prototype.makeCommandList = function() { _Window_ActorCommand_makeCommandList.call(this); if (this._actor) { // if (this._actor._states.length > 0) this.addCommand(commandName, 'equip'); // checking if actor has any state if (this._actor.isStateAffected(x)) this.addCommand(commandName, 'equip'); // checking if actor has state x } };
For checking every actor:
JavaScript:for (i = 0; i < $gameActors._data.length; i++) { if ($gameActors._data[i]._states.length > 0) this.addCommand(yourCommand, 'nameCommand'); }
Or any other condition check you want.
Edit:
Keep in mind though, that the above code will add a new command line in Window_ActorCommand for EVERY actor that has a state.
So if you want to only add one command if anybody has a state, then use this:
JavaScript:var anyStateActive = false; for (i = 0; i < $gameActors._data.length; i++) { if ($gameActors._data[i]._states.length > 0) anyStateActive = true; } if (anyStateActive) this.addCommand(yourCommand, 'nameCommand');
Sorry, it's been a long day lol -
Is it possible to set a variable to a number containing a decimal point? If so, how?
-
Is it possible to set a variable to a number containing a decimal point? If so, how?
As far as I know this can only be accomplished via script call:
JavaScript:$gameVariables._data[x] = yourDecimalValue; // x being the variable id -
https://forums.rpgmakerweb.com/inde...t-deserve-their-own-thread.46341/post-1107904
JavaScript questions that don't deserve their own thread To add to my previous question, and regarding this other message, where can I reference all of those variables/values? In RMXP I can simply call the interpreter script calls as an event would, so I can sort of get creative and skip the event editor sometimes. Any similar directories to learn from for RMMZ? -
https://forums.rpgmakerweb.com/inde...t-deserve-their-own-thread.46341/post-1107904
JavaScript questions that don't deserve their own thread To add to my previous question, and regarding this other message, where can I reference all of those variables/values? In RMXP I can simply call the interpreter script calls as an event would, so I can sort of get creative and skip the event editor sometimes. Any similar directories to learn from for RMMZ?
This excel sheet with script calls for simple tasks helped me out at the beginning.
If you want to discover more functions you can also open the console with F8 and type in for example $gameParty. and it will show you all functions and properties. You will quickly fall into a rabbit hole, depending on how committed you are.
Also if you want to learn basic javascript to help you out, I highly recommend Freecodecamp.
That and making my own game taught me alot about javascript. -
Any ideas on how to lock certain characters in formation? I would like to prevent the main protagonist from being removed from the active team.
-
Any ideas on how to lock certain characters in formation? I would like to prevent the main protagonist from being removed from the active team.
So you want the player to be able to change all actors around, except for main protagonist (actor id 1 I assume?). Does the main character have to remain in the first position or does it not matter as long as the main actor remains in the party? -
Maintaining the main protagonist (there are two selectable ones on the beginning) in the first position seems enough and (I guess) simplier to achieve.
-
Maintaining the main protagonist (there are two selectable ones on the beginning) in the first position seems enough and (I guess) simplier to achieve.
Try this plugin I made.
I hope you are using MV otherwise it's useless lol. -
I asked this question awhile back and I didn't get an answer anywhere but that doesn't matter anymore for, like a madlad, I've created the Neurotoxin state by combining Yanfly's Custom DoT and Pokemon Paralysis Tips and Tricks with the use of If-Else statement. Just gonna leave the state here for everyone else to see.So, I wish to make a state that is like a hybrid of poison and Pokemon's paralysis. I'll call it Neurotoxin and it's a state that lasts for 5 turns. Every turn the opponent will take poison damage (slightly stronger than the normal poison) but there is a 1/4th chance that instead of getting poison damage for that turn they instead get immobilized, unable to fully execute the action they're suppose to do in that turn. For my poison I prefer using Yanfly's Custom DoT and I am also aware of Yanfly's Paralysis Tips and Tricks. The question is: is it possible to make this state?
State: Neurotoxin<Turn Start: 5>
<Cancel Instant Skill: 1 to 2000>
<Cancel Instant Item: 1 to 2000>
<Custom Apply Effect>
target._mercuryNeuro = Math.ceil(20 + origin.mat * 0.25 + origin.atk * 0.25);
</Custom Apply Effect>
<Custom Remove Effect>
target._mercuryNeuro = undefined;
</Custom Remove Effect>
<Custom Action Start Effect>
var paralyzeRate = 0.30;
if (Math.random() < paralyzeRate) {
user.startAnimation(64);
if (user.currentAction()) {
user.useItem(user.currentAction().item());
}
user.clearActions();
var logWindow = SceneManager._scene._logWindow;
if (state.message3) {
var msg = '<CENTER>' + user.name() + state.message3;
logWindow.addText(msg);
}
BattleManager.actionWaitForAnimation();
logWindow.push('clear');
}
else {
target._mercuryNeuro = target._mercuryNeuro || Math.ceil(10 + origin.mat * 0.25 + origin.atk * 0.25);
target.startAnimation(59);
target.gainHp(-target._mercuryNeuro);
target.startDamagePopup();
if (target.isDead()) {
target.performCollapse();
}
target.clearResult();
}
</Custom Action Start Effect> -
Howdy, partners!
How do I store an Actor's name into a variable?
I tried to use the "Control Variables" command with the Script option below, with no success...