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,912
Reaction score
921
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,344
Reaction score
566
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

"Your service has been identified as part of an outage. This is expected to be restored by 7pm IN SEVEN DAYS!!!" Guess I won't be around as much over the next week :(
Ami
tethering is my lifesaver,especially when computer or laptop doesn't support internet connection.
convention concluded, i'm glad the books well received and sold out
not every content is decent, but i'll be better for the next work.

now back to game developing
I hope to be able to post my vxace resource edits this Wednesday.
Not sure if I'll get to the library though.
Me: Man, I'm definitely burned out this time. Time for a break. Me three hours later: I'm ready to work again, let's go! Me another hour later: Okay, I can't do this anymore. Repeat for infinity.

Forum statistics

Threads
94,464
Messages
921,112
Members
124,293
Latest member
ravichah
Top