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,900
Reaction score
906
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
565
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 Profile Posts

fighting game fans might really enjoy my game battle wise, and I feel non fighting fans might learn some stuff. thanks row system. pokes, neutral, and zoning time...
This community is awesome. They helped me get my eventing processes to work. I love you all.
suspended on twitter for calling an ahole an ahole & appealing the tweet; furious at myself for being even slightly upset with my suspension: oh no, you've been temporarily banned from hell. GET OVER IT, me.
how can you download the tiles from a forum post here? HELP
That moment when you post the wrong download link to your game and wonder why it got so few downloads... :mad:

Forum statistics

Threads
94,250
Messages
919,395
Members
123,961
Latest member
safrasnativa
Top