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,981
Reaction score
971
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 Profile Posts

My plan after learning to make my voice girly "Wow! You sounds cute!" "But actually I'm a man!" "Nooooo!!!" hehehe...
I get haunted from bugs that emit a terrible stench after being killed.
At first, I was going to put player objectives on the screen labeling it as "Helpful voices"... But that's dumb, I have a madness system. It will simply whisper objectives.... I mean they're probably objectives. The voices wouldn't lie right? They're friendly, and ...helpful. So clearly you should do what they say. Just watch the dark corners of your screen for advice and it will all work out! :LZSexcite:
Take care of your immune system: Go to sleep. If you looked at the clock an hour ago or four and it was way late then maybe now is the time. Mmm sleep...

Forum statistics

Threads
95,667
Messages
930,911
Members
126,005
Latest member
Rbennin
Top