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,975
Reaction score
965
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

The main character for the first game was originally going to become a member of the party in the third game but I'm probably changing him to an important NPC instead. That brings the third game's total ensemble roster down to nine with one optional secret character.
Please check out my threads here:

1920's Character Sprites

As well as my YouTube channel:

Let's Play - 1927: The Age of Cthulhu
hi i would like to know if you could help me i am looking for resources for the character generator
I need medieval clothes, demon horns
Stress testing my latest version of the game with my new madness engine. :LZSexcite:

Hello, where can I find the list of all watched threads? I've been using the Watch function to save the Threads I want to keep but I don't find the list anywhere....

Forum statistics

Threads
95,589
Messages
930,292
Members
125,894
Latest member
Anistasya
Top