I'm creating a skill to do delayed fire damage to a target and I'm looking for a JavaScript template for other delayed skills later down the line. I know virtually no JavaScript, so a breakdown of how it works would be extremely appreciated.
MV Delayed Effects using JavaScript
Learning JavascriptThis can't be done without knowing how the engine itself works - javascript isn't a miracle worker.
Basically no skill has any form of timing involved in that form - and such a timing cannot be created by javascript either, not without rewriting the engine itself.
what you need to do is to use states.
states do have timing involved and that timing (like counting the number of turns until the state is removed) is handled by the engine automatically.
If I understand you correctly you want to include an effect at the moment when the state is removed automatically.
That is also not in the default engine, but such a function is easier to add by plugin than your original description.
There are a few plugins that already do this, you can look for them either as an inspiration on learning how to program this or to use them directly.
Basically no skill has any form of timing involved in that form - and such a timing cannot be created by javascript either, not without rewriting the engine itself.
what you need to do is to use states.
states do have timing involved and that timing (like counting the number of turns until the state is removed) is handled by the engine automatically.
If I understand you correctly you want to include an effect at the moment when the state is removed automatically.
That is also not in the default engine, but such a function is easier to add by plugin than your original description.
There are a few plugins that already do this, you can look for them either as an inspiration on learning how to program this or to use them directly.
I understand I need to use states and I have most of the Yanfly plugins ready, I just need to know how to use JavaScript to expand my flexibility of these things.
This article might help:
www.yanfly.moe
Notably, this state notetag to force use of a skill when the state elapses:
(Note:
Yanfly has a lot of similar articles here, in case you're interested:
www.yanfly.moe
Jump (MV Plugin Tips & Tricks) - Yanfly.moe Wiki
// Buffs & States Core
<Custom Leave Effect>
// Get the landing skill.
var skill = 200;
// Get the last targeted index.
var target = -2;
// Queue the forced action.
BattleManager.queueForceAction(user, skill, target);
</Custom Leave Effect>(Note:
queueForceAction is a shortcut defined by YEP_BattleEngineCore.)Yanfly has a lot of similar articles here, in case you're interested:
Category:RPG Maker MV Plugin Tips & Tricks - Yanfly.moe Wiki
I read the Jump article but I don't really understand what it means ie. the actual source code
For future reference: it can be more helpful to mention, if possible, exactly what it is that you don't understand, e.g.
- "What does
BattleManager.queueForceActiondo?"- It's basically a Force Action command.
- "How does the game know when to run this code?"
- When a state expires, the plugin processes its
<Custom Leave Effect>notetag.
- When a state expires, the plugin processes its
- "Where do I put these 'notetags'?"
- Database objects have a Note box (bottom-right); notetags go there.
- "What does
varmean?"- It defines a local variable: click here for technical details.
The notetag of interest for your situation, which I included in my post, contains 3 lines of code, each one commented with its purpose (lines starting with
// are comments). It requires Yanfly's Buffs & States Core plugin:Buffs & States Core (YEP) - Yanfly.moe Wiki
Rather than trying to cultivate a deep understanding of (object-oriented) programming, the JavaScript language, and RMMV's core scripts from the start, many people simply find/request relevant snippets of code from others who are more informed on the topic. For example:
RPG Maker MV / MZ Script Call List
This Script Call list applies to both RPG Maker MV and RPG Maker MZ. Link here to see the entire list. Supplementary Material for RPG Maker MZ: https://forums.rpgmakerweb.com/index.php?threads/rpg-maker-mz-script-call-reference.122501/ Have fun eventing~
forums.rpgmakerweb.com
JavaScript questions that don't deserve their own thread
Feel free to ask any questions here that you feel do not warrant their own threads. If you need help getting a plugin working, please start a NEW thread and include a link to where you downloaded the plugin from.
forums.rpgmakerweb.com
Thanks! This was very helpful.
Original thread: https://forums.rpgmakerweb.com/threads/delayed-effects-using-javascript.144975/