Cuprite

Previously Golden
Veteran
Joined
Feb 6, 2017
Messages
144
Reaction score
67
First Language
English
Primarily Uses
RMMV
Is there a reliable way to make something akin to D&D's Wild Magic? For those unfamiliar, it's basically magic that has a chance of doing something different than intended (Say you're going to use a Fire spell, it "goes wild" and instead of using the Fire spell, buffs an enemy's Attack stat or casts an AOE Fire spell targeting yourself, or even doing a more powerful spell on the enemy. Stuff like that). My current MV project (that isn't currently shelved indefinitely) would heavily utilize that mechanic, with each spell having some sort of stability rating (Be it 99% (Only a 1% chance of "going wild") or 10% (A whopping 90% chance of "going wild")). I imagine there'd be some way of twisting it to your advantage rather than having it be 100% RNG whether it's positive or negative, maybe with equipment or some passive skill?
I think it could probably be done with Yanfly's "Action Sequence" set of plugins? But I have absolutely no clue how I would actually set it up. :/
Idk, if anyone has any idea, I really appreciate the help. This one is especially important cause the whole concept is the foundation of this whole new project of mine. Lol.
(I understand if this is too complex to easily do, if it is, I might have to figure something else out)

(also apologies if i got anything about d&d's wild magic wrong thats just how i understand it)
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
5,423
Reaction score
5,112
First Language
English
Primarily Uses
RMMZ
I'm actually doing something akin to this for one of the casters in my game who isn't brilliant at magic in the beginning. The approach I'm taking is to have a pre-apply notetag which chooses a random number in the range of possible alternative effects and then changes the action to be that skill's ID instead of the original.
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
1,137
Reaction score
992
First Language
English
Primarily Uses
N/A
I don't think you'd even need plugins for this. You can have a given skill call a common event that determines things like which spell you actually cast.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,216
Reaction score
4,195
First Language
English
Primarily Uses
RMMV
I don't think you'd even need plugins for this. You can have a given skill call a common event that determines things like which spell you actually cast.
How would you do this? Common events get called after all other effects of a skill resolve, so I don't see how it could change the skill at the time of using it.
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
1,137
Reaction score
992
First Language
English
Primarily Uses
N/A
How would you do this? Common events get called after all other effects of a skill resolve, so I don't see how it could change the skill at the time of using it.
Let's say you have a skill that 90% of the time does 50 damage to target enemy and 10% of the time does something random from 10 other options.
  • Base Skill: Wild Firebolt. This is what the character learns. It does nothing but target an enemy, no animation or name popup or anything. It then calls up a common event "Check Wild Firebolt"
  • Firebolt: This is the skill that does 50 damage to the enemy. Do animations, damage formula, etc to this skill.
  • 10 other skills are set up to do whatever they do with whatever name you want. Because these are wild skills, it might make sense for them to have scopes like 1 random enemy, All allies, The User, etc.
  • Check Wild Firebolt: Have this common event roll a variable from 0-99, then have it force the user to use Firebolt on the last target (I love so much MV can do that) if the number is above 9. Then for each number from 0-9, have another skill get force used by the user.
If a skill that does nothing but target an enemy doesn't work (I honestly just can't remember if there's anything weird about that), then have it apply a state that does nothing (low priority and no icon too) and then remove the state with the common event.

The most important part of the skill is having it do literally nothing from the player's perspective. That'll make it jump to the "correct" skill instantly. Some issues without plugins;

  1. This is actor specific. You can jump through more hoops to try and find who used the skill but that requires more complications such as making the base skill target the user (which then gives user the invisible state and then checks who has the state, but you can't choose the Firebolt target then) or maybe by calling another common event first to set a variable to the user (which doesn't check party position and can cause issues).
  2. The base skill might still "appear" to be used through some visual action or whatnot, which could lead to something like two lead ups to a skill use.
Action Sequences can solve both those issues. I don't know the exact solution off the top of my head, but I know what you want to do is have the Setup Action decide randomly which skill is used, then have every skill that can be used do nothing during Setup. But it might also just be easier to check a random number during Setup, then choose what the skill actually does in Whole/Target Action. I think there's a thread all about asking for help with Action Sequences that would know more than I do at the moment. But I always try to find a solution without plugins first to see if I need them or not.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,216
Reaction score
4,195
First Language
English
Primarily Uses
RMMV
Base Skill: Wild Firebolt. This is what the character learns. It does nothing but target an enemy, no animation or name popup or anything. It then calls up a common event "Check Wild Firebolt"
I see what you're getting at. I would consider these:
  1. This is actor specific...
  2. The base skill might still "appear" to be used...
to be pretty big drawbacks to this proposed method, but I understand what you're saying. :wink:

Action Sequences can solve both those issues.
Action Sequences is definitely a more unnecessarily complicated solution than the skill notetag Trihan mentioned in post #2. You could do it that way, but like doing it through a common event, there's really not a reason to. His solution involves one plugin and, like, two lines of code (depending on how you want to implement the random other spell).

But I always try to find a solution without plugins first to see if I need them or not.
That's a sensible consideration for stuff that you'd need to pay for. When Yanfly's Skill Core is free and makes the solution to this pretty trivial, I don't see a reason to try to circumvent it (unless it's just a mental exercise, which is absolutely fine in and of itself).

Thanks for the explanation.
 

kirbwarrior

Veteran
Veteran
Joined
Nov 13, 2014
Messages
1,137
Reaction score
992
First Language
English
Primarily Uses
N/A
I see what you're getting at. I would consider these:
to be pretty big drawbacks to this proposed method
Absolutely agree. The first one at least isn't always an issue (some games don't use class changing) but yeah the second one can always be an issue. MV has some odd places in battle that are 'slow' that this method exacerbates and I do want to figure out ways to fix those (not asking here, that would derail the thread).

Action Sequences is definitely a more unnecessarily complicated solution than the skill notetag Trihan mentioned in post #2. You could do it that way, but like doing it through a common event, there's really not a reason to. His solution involves one plugin and, like, two lines of code (depending on how you want to implement the random other spell).
I wasn't sure what Trihan was explaining or what plugin that would use. Or it's not part of a plugin and...

I don't see a reason to try to circumvent it
It's because I don't know enough of what MV is and more importantly isn't capable of. Further, if the base engine can do something without a plugin, it gives the option of not using that plugin for whatever various reason. There's even some free plugins I remember being made that were entirely unnecessary because the plugin creator didn't know it was already possible in engine.

Thanks for the explanation.
You're welcome! And yeah, I have Yanfly's plugins and I don't ever see myself not using any in a given game I make (outside of challenges), but I also don't want that to be the go to response. Some people even avoid using them for one reason or another.
 

Cuprite

Previously Golden
Veteran
Joined
Feb 6, 2017
Messages
144
Reaction score
67
First Language
English
Primarily Uses
RMMV
I'm actually doing something akin to this for one of the casters in my game who isn't brilliant at magic in the beginning. The approach I'm taking is to have a pre-apply notetag which chooses a random number in the range of possible alternative effects and then changes the action to be that skill's ID instead of the original.
Apologies for the late reply. What exactly do you mean with the "pre-apply" notetag? I just wanna make sure I definitely understand. Lol.
(Thank you for replying btw)
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,216
Reaction score
4,195
First Language
English
Primarily Uses
RMMV
Apologies for the late reply. What exactly do you mean with the "pre-apply" notetag?
That's a notetag from the VisuStella suite. Since you use MV, your version would be in Yanfly's Skill Core, the Pre-Damage Eval (maybe even the Before Eval, to change the skill as soon as possible).
 

Cuprite

Previously Golden
Veteran
Joined
Feb 6, 2017
Messages
144
Reaction score
67
First Language
English
Primarily Uses
RMMV
That's a notetag from the VisuStella suite. Since you use MV, your version would be in Yanfly's Skill Core, the Pre-Damage Eval (maybe even the Before Eval, to change the skill as soon as possible).
Ah, that makes sense. Thank you.
This is what I have so far (Currently applying it to a debug skill to fully test it out first, 95% stability (Maybe having it be 50/50 would be better for a debug skill, but whatever)).

<Before Eval> var stability = Math.floor(Math.random()*100) + 1; if stability > 95 [Flash screen purple, play SE, replace skill being used with a new random one from a set list] </Before Eval>

Decided to do "Before" just to (Hopefully) guarantee it changes it.
Only thing left (I think) is to substitute the skill being used with another one entirely, and maybe have that be influenced by certain equipment (So it's not 100% RNG and can be manipulated in your favor), which is currently just placeholder text.
(I wish I actually understood code better, I feel dumb. Lol)
 
Last edited:

Cuprite

Previously Golden
Veteran
Joined
Feb 6, 2017
Messages
144
Reaction score
67
First Language
English
Primarily Uses
RMMV
Update: I have it set up like this now (First half was put together with the MV Script Call list, second half was found in a thread going over a purely random skill (Specifically a comment from Trihan (What a coincidence))), but it doesn't do anything. I know I'm not just hitting the 1% every time (Kinda why I set it to 1%), but I can't for the life of me figure out how to make it work. .-.

<Before Eval> var stability = Math.floor(Math.random()*100) + 1; if stability > 1 //Flash screen purple, play SE, replace skill being used with a new random one from a set list. $gameScreen.startFlash([187, 0, 255, 170], 40); AudioManager.playSe({name: 'Magic5', volume: 80, pitch: 100, pan: 0}); this.wait(40); var possibleSkills = [8, 9, 10]; // IDs of the skills that might be cast var index = Math.randomInt(possibleSkills.length); var skillId = possibleSkills[index]; BattleManager._subject.forceAction(skillId, -2); </Before Eval>

I feel like it's worth mentioning that the flash and sound effect part of the script works perfectly when used on a normal event, but not in the skill notetags for some reason.
 

eomereolsson

Veteran
Veteran
Joined
Sep 29, 2021
Messages
543
Reaction score
460
First Language
German
Primarily Uses
RMMV
Pro tip: even if plan to give some effect a specific chance later on, set this chance to 100% for testing purposes. Otherwise you will never know if there is a bug in your code or you are just randomly always hitting the chance for the effect to not occur.

Second I don't think your if condition is valid javascript syntax. If you open the console while executing your skill you will probably see an error pop up.
Try instead:
JavaScript:
if(stability > 1) {
   //your code here
}
I don't believe the (...) can be omitted. The {...} can be omitted and still be valid javascript. However then only the next statement is actually bound to the condition. In your case that is the screen flash. Any code after that will always be executed.
 

Cuprite

Previously Golden
Veteran
Joined
Feb 6, 2017
Messages
144
Reaction score
67
First Language
English
Primarily Uses
RMMV
Pro tip: even if plan to give some effect a specific chance later on, set this chance to 100% for testing purposes. Otherwise you will never know if there is a bug in your code or you are just randomly always hitting the chance for the effect to not occur.

Second I don't think your if condition is valid javascript syntax. If you open the console while executing your skill you will probably see an error pop up.
Try instead:
JavaScript:
if(stability > 1) {
   //your code here
}
I don't believe the (...) can be omitted. The {...} can be omitted and still be valid javascript. However then only the next statement is actually bound to the condition. In your case that is the screen flash. Any code after that will always be executed.
Ok, this did help, it now does the effect. Only problem is that it still does the original skill before doing it (Tho it doesn't start a new skill from the selection). Thank you for this tho, I'm one step closer now. :)

And ye, what you said about the effect percentage makes sense. I'll keep that in mind from now on.

<Before Eval> var stability = Math.floor(Math.random()*100) + 1; if (stability > 0) { //Flash screen purple, play SE, replace skill being used with a new random one from a set list. $gameScreen.startFlash([187, 0, 255, 170], 40); AudioManager.playSe({name: 'Magic5', volume: 80, pitch: 100, pan: 0}); this.wait(40); var possibleSkills = [8, 9, 10]; // IDs of the skills that might be cast var index = Math.randomInt(possibleSkills.length); var skillId = possibleSkills[index]; BattleManager._subject.forceAction(skillId, -2); } </Before Eval>

Update: Putting the skill stuff before the flash makes it happen, but it still does the original skill first. I'm not quite sure how to stop the original skill from going off (If it's possible at all). .-.

<Before Eval> var stability = Math.floor(Math.random()*100) + 1; if (stability > 0) { var possibleSkills = [8, 9, 10]; // IDs of the skills that might be cast var index = Math.randomInt(possibleSkills.length); var skillId = possibleSkills[index]; BattleManager._subject.forceAction(skillId, -2); //Flash screen purple, play SE, replace skill being used with a new random one from a set list. $gameScreen.startFlash([187, 0, 255, 170], 40); AudioManager.playSe({name: 'Magic5', volume: 80, pitch: 100, pan: 0}); this.wait(40); } </Before Eval>

I suppose I could just have two versions of each spell, but that seems... inefficient. :/

Update 2: Doing the 2 copies thing for now, it functions pretty well (Just looks a bit janky). Now I just gotta think of a way to make equipment play a part in what it chooses to do. That might get complicated tho...

Edit: Forgot to show the "final"(?) code earlier. If there's anything that can be improved, someone please let me know. Lol.

<Before Eval> var stability = Math.floor(Math.random()*100) + 1; if (stability > 0) { var possibleSkills = [12, 13, 14]; // IDs of the skills that might be cast var index = Math.randomInt(possibleSkills.length); var skillId = possibleSkills[index]; BattleManager._subject.forceAction(skillId, -2); //Flash screen purple, play SE, replace skill being used with a new random one from a set list. $gameScreen.startFlash([187, 0, 255, 170], 40); AudioManager.playSe({name: 'Magic5', volume: 80, pitch: 100, pan: 0}); this.wait(40); } else { BattleManager._subject.forceAction(15, -2); //Flash screen white (Low intensity), play SE, use the correct skill's copy. $gameScreen.startFlash([255, 255, 255, 70], 40); AudioManager.playSe({name: 'Magic1', volume: 85, pitch: 100, pan: 0}); this.wait(40); } </Before Eval>
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,216
Reaction score
4,195
First Language
English
Primarily Uses
RMMV
So you're only doing one part of what is typically done with forcing actions - setting it on the battler. The other half is telling the BattleManager to execute it.

Code:
BattleManager._subject.forceAction(skillId, -2);
why go through all that instead of just typing user.forceAction() ?
But then,
Code:
BattleManager.forceAction(user);
 

Latest Threads

Latest Posts

Latest Profile Posts

no longer using rm2k3
Don't you hate when you're trying to sleep and suddenly the smoke detector needs batteries? That's exactly what happened to me. Now I'm sluggish and tired after that darn thing started chirping at 11:30 at night. Man I wish I had one of those smart smoke detectors that sends a message to your phone way before it starts chirping.
Interior of a bus, may do more vehicle interiors :kaoswt2:
1670089782219.png
I can hardly believe it is the third day of Christmas and I have yet to put up decorations! Spending my morning cooking breakfast and getting them up.
https://itch.io/s/83641/1-week-sale Do you want a Roguelike game like a turn-based Hades? Get Zodiac Hunters now while it's on sale!

Forum statistics

Threads
127,016
Messages
1,183,202
Members
166,878
Latest member
Phunction
Top