Make a character's chance to resist a state change according to variables?

Grandy12

Villager
Member
Joined
Oct 31, 2016
Messages
12
Reaction score
1
First Language
Portuguese
Primarily Uses
For example, a variable that follows how 'holy' a character it. Getting blessed at the church or using holy skills adds more to this variable.

Then an enemy uses a skill that inflicts a state called 'curse'.

I want to make the odds of resisting curse to be equal to 100%, minus how many holy points there are.

So if the character has 25 holy points, the chances of being affected by curse would be of 75%. If he has 27 holy points, it'd be 73%. And so on until the character is fully immune to curse at 100 holy points.

I imagine it'll take some coding to do it, and I do know a thing or two about coding, I'm more or less just asking for help with where to start the code, what functions to look for and so on.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
1,989
Reaction score
977
First Language
Spanish
Primarily Uses
RMVXA
not directly, as there is no tie to variables within the state controls, which is what controls the resistances most directly (indirectly, through the battle system, and there's no direct control except through the actor's own properties)
but you can make it a hybrid system by using a set of conditionals and global variables, and then creating a script call, which you *can* tie directly to the actor's properties, AND the battle system.
 

Grandy12

Villager
Member
Joined
Oct 31, 2016
Messages
12
Reaction score
1
First Language
Portuguese
Primarily Uses
not directly, as there is no tie to variables within the state controls, which is what controls the resistances most directly (indirectly, through the battle system, and there's no direct control except through the actor's own properties)
but you can make it a hybrid system by using a set of conditionals and global variables, and then creating a script call, which you *can* tie directly to the actor's properties, AND the battle system.
Thanks. If it's not asking too much, would you know a good tutorial for the basics of scripting?

EDIT: Scripting for MV in specific, I mean. I already have some experience scripting in general with javascript.
 

Heirukichi

Veteran
Veteran
Joined
Sep 24, 2015
Messages
1,356
Reaction score
575
First Language
Italian
Primarily Uses
RMVXA
If you add the curse state via damage formulae you can directly check the amount of holy points (even if you stored it in a variable) from your chance to apply the curse state. After that you can roll a random number and check if that number is enough to apply your state. If it is the state is applyied, if it is not the state is not applied. This way if the amount of holy points stored in the variable is 0 you still apply curse with the usual chance, if it is not 0 that chance is different based on the amount stored in the variable itself.
If you have a total of 9 actors you could transform a variable into an array and store the amount of holy points each actor has in its respective position in the array variable. This way you can access that value in the same way you access a symbol table (T(1)) and use that value to increase/decrese your chances to apply curse.

I am not 100% sure about this code here since I cannot access the engine right now and I do not remember MV script calls well enough to not make any mistake but it should look like something similar to this:
Code:
var holyPoints = $gameVariables(your_variable)[b.id - 1];
var curseChance = 0.75; // this is just an example, change it to your real chance
var curseChance -= (holyPoints / 100.0); // or any other formula based on holyPoints
var currentChance = Math.rand();
if (currentChance < curseChance) { b.addState(your_curse_state_id); }

Scripting for MV in specific
The most obvious way to learn how each class is implemented would be to open the code itself and read that particular class. There are plenty of tutorials about javascript but when it comes to MV classes I guess you have to learn how they are implemented. I hardly think there is any workaround. My personal advice would be to just start from things you need and learn about them, once you keep going on you will find many other things and learn about them.
 
Last edited:

Grandy12

Villager
Member
Joined
Oct 31, 2016
Messages
12
Reaction score
1
First Language
Portuguese
Primarily Uses
If you add the curse state via damage formulae you can directly check the amount of holy points (even if you stored it in a variable) from your chance to apply the curse state. After that you can roll a random number and check if that number is enough to apply your state. If it is the state is applyied, if it is not the state is not applied. This way if the amount of holy points stored in the variable is 0 you still apply curse with the usual chance, if it is not 0 that chance is different based on the amount stored in the variable itself.
If you have a total of 9 actors you could transform a variable into an array and store the amount of holy points each actor has in its respective position in the array variable. This way you can access that value in the same way you access a symbol table (T(1)) and use that value to increase/decrese your chances to apply curse.

I am not 100% sure about this code here since I cannot access the engine right now and I do not remember MV script calls well enough to not make any mistake but it should look like something similar to this:
Code:
var holyPoints = $gameVariables(your_variable)[b.id - 1];
var curseChance = 0.75; // this is just an example, change it to your real chance
var curseChance -= (holyPoints / 100.0); // or any other formula based on holyPoints
var currentChance = Math.rand();
if (currentChance < curseChance) { b.addState(your_curse_state_id); }


The most obvious way to learn how each class is implemented would be to open the code itself and read that particular class. There are plenty of tutorials about javascript but when it comes to MV classes I guess you have to learn how they are implemented. I hardly think there is any workaround. My personal advice would be to just start from things you need and learn about them, once you keep going on you will find many other things and learn about them.
Thank you, I'll do just that.
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Pft... people think the moon landing is fake. Nonsense. The moon doesnt even exist in the first place, it's just the reflection of the earth on the surface of space.
I don't know if anyone will get my old pop culture references. Item: Empty Basket. Description: Don't worry. Yogi Bear won't try to steal it.
My second childrens book is finally uploaded and approved and available to buy! I am so happy!
I just realized I passed 1,000 likes. I'm amazed you people actually like this crap. It's no surprise you'd like my high quality content. :kaopride:
Running on a creative high right now. Expanding my Redwood tile D with doors, windows, and some other odds and ends today.

Forum statistics

Threads
95,751
Messages
931,593
Members
126,141
Latest member
MrAbdullahX
Top