(Yanfly) Passive state to increase stats based on user's current tp

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
I'm trying to create a passive state that increases the user's defense based on current tp. 


This is what I have so far


<Custom Passive Condition>
if ($gameParty.inBattle()) {
condition = user.tp >= 1;
} else {
condition = false;
}
</Custom Passive Condition>

<Custom Turn Start Effect>
user.def += Math.floor((user.tp / 100) * 50);
var defmod = user.def;
user.setStateCounter(68, defmod);
</Custom Turn Start Effect>

<Custom Turn End Effect>
user.def += Math.floor((user.tp / 100) * 50);
var defmod = user.def;
user.setStateCounter(68, defmod);
</Custom Turn End Effect>


First it checks to see if the user has TP, then at the start of the turn it adds defense based on the user's TP, and then it shows a counter that displays the user's defense after buff.


The problem I'm running into is that the user's stats aren't being increased, even as the tp increases or is maxed out.
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Are you checking if the condition is true? is the icon appearing? Well, if not first try putting the user.tp >= 1 between parentesis.


Second... why /100 * 50? Isn't this the same as /2?


Third... is the player at a level low enough a change of 50 def tops is that noticeable?


Try putting the def in a variable and making a window mention it every time, or even better, console.log($gameActor(x).def) or something. Is it really not changing, or is it just hard to notice?
 
Last edited by a moderator:

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
Are you checking if the condition is true? is the icon appearing? Well, if not first try putting the user.tp >= 1 between parentesis.


the icon is appearing correctly, so the state is applying. 

Second... why /100 * 50? Isn't this the same as /2?


haha i didn't even think about that, i will be changing that

Third... is the player at a level low enough a change of 50 def tops is that noticeable?


Try putting the def in a variable and making a window mention it every time, or even better, console.log($gameActor(x).def) or something. Is it really not changing, or is it just hard to notice?


also haven't really work out the formula yet for higher levels, just wanted to test the state. and yes it isn't changing at all
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
Found the problem.


Are you using YEP_BaseParamControl?


Because the def command itself... it is just a get, it can't be changed.


Just to add that if it could change the def, this small code wouldn't just add to the def, it would add to def at the start of turn, then add again at end, then the same next turn, and next, and next...
 
Last edited by a moderator:

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
it is just a get, it can't be changed.


yes i am using YEP_BaseParamControl.


does this mean this state cant be done this way? should I just use buffs instead?
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
As I said, you could use the Base Parameter Control plugin and change the plus value of defense.


But be warned of my edit in the previous post: as it is, the code will be adding to defense twice each turn, not just adjusting it every turn...
 

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
As I said, you could use the Base Parameter Control plugin and change the plus value of defense.


But be warned of my edit in the previous post: as it is, the code will be adding to defense twice each turn, not just adjusting it every turn...


i changed up the formula to increase the def up to 100%. Also I made it so the base value for def is stored at the beginning of the battle. Now i get Nan after the calculations.


Here is what i have so far: 

<Custom Battle Effect>
//store base defense value to variable
var bdef = user.def;
//show the users def as counter
user.setStateCounter(68, user.def);
</Custom Battle Effect>

<Custom Turn Start Effect>
//set def change based on users tp
var defmod = Math.floor(bdef * (user.tp / 100));
//add def change to user defense
user.addDef(defmod);
//refresh counter
user.setStateCounter(68, user.def);
//print defmod value to console
console.log(defmod);
</Custom Turn Start Effect>

<Custom Turn End Effect>
//set def change based on users tp
var defmod = Math.floor(bdef * (user.tp / 100));
//add def change to user defense
user.addDef(defmod);
//refresh counter
user.setStateCounter(68, user.def);
//print defmod value to console
console.log(defmod);
</Custom Turn End Effect>

<Custom Victory Effect>
//reset changes to defense values
user.clearParamPlus();
</Custom Victory Effect>



Can you see any problems with the code? Also, might it be better to use buffs instead of directly using the base parameters?
 
Last edited by a moderator:

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
try saving bdef as user.bdef, since I think that may be the problem, the variable not being saved in the battler.


Also, I'd personally set it on apply and remove instead of battle and victory. Else if something else changes def during battle it won't change, and if the player runs the defense stays...


And it still got the same problem, you are using adddef without resetting def first so at every turn, both at beginning and end, the value is being added... meaning that as battle goes on it just keeps increasing. Even if the counter doesn't show it, since it shows defmod instead of def itself.
 

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
try saving bdef as user.bdef, since I think that may be the problem, the variable not being saved in the battler.


how would you do that? would you just do


var user.bdef = user.def;


are would you need to declare it some other way? Also would you reference the value with just user.bdef?


Sorry about all the questions
 

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
<Custom Apply Effect>
//store base defense value to variable
var user.basedef = user.def;
var user.moddef = 0;
//show the users def as counter
user.setStateCounter(68, user.def);
</Custom Apply Effect>

<Custom Turn Start Effect>
//reset def changes
user.clearParamPlus();
//set def change based on users tp
user.moddef = Math.floor(user.basedef * (user.tp / 100));
//add def change to user defense
user.addDef(user.moddef);
//refresh counter
user.setStateCounter(68, user.def);
</Custom Turn Start Effect>

<Custom Turn End Effect>
//reset def changes
user.clearParamPlus();
//set def change based on users tp
user.moddef = Math.floor(user.basedef * (user.tp / 100));
//add def change to user defense
user.addDef(user.moddef);
//refresh counter
user.setStateCounter(68, user.def);
</Custom Turn End Effect>

<Custom Remove Effect>
//reset changes to defense values
user.clearParamPlus();
</Custom Remove Effect>

Ok so i declared them like normal variables and changed the names to ensure no conflicts. When i run a test i returns with NaN as the counter, argh...
 

YoraeRasante

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,643
Reaction score
420
First Language
Portuguese
Primarily Uses
RMMV
...


Try adding some console.log(variabçe you think might be the cause) and check the console.
 

ragnorak6608

Veteran
Veteran
Joined
May 25, 2014
Messages
54
Reaction score
1
First Language
English
...


Try adding some console.log(variabçe you think might be the cause) and check the console.


So I finally got it working!!! Im so happy, thanks for you help!

<Custom Battle Effect>
//store base defense value to variable
user.basedef = user.def;
user.moddef = 0;
console.log(user.basedef);
console.log(user.moddef);
console.log(user.def);
//show the users def as counter
user.setStateCounter(68, user.def);
</Custom Battle Effect>

<Custom Turn Start Effect>
//reset def changes
user.clearParamPlus();
//set def change based on users tp
user.moddef = Math.floor(user.basedef * (user.tp / 100));
//add def change to user defense
user.addDef(user.moddef);
//refresh counter
user.setStateCounter(68, user.def);
console.log(user.basedef);
console.log(user.moddef);
</Custom Turn Start Effect>

<Custom Turn End Effect>
//reset def changes
user.clearParamPlus();
//set def change based on users tp
user.moddef = Math.floor(user.basedef * (user.tp / 100));
//add def change to user defense
user.addDef(user.moddef);
//refresh counter
user.setStateCounter(68, user.def);
console.log(user.basedef);
console.log(user.moddef);
</Custom Turn End Effect>

<Custom Remove Effect>
//reset changes to defense values
user.clearParamPlus();
console.log(user.basedef);
console.log(user.moddef);
console.log(user.def);
</Custom Remove Effect>



Minus all the console.log. I might need to add more conditions so that it updates after gaining tp from damage to self and party members, but at least now I have a basis
 

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

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,049
Members
137,570
Latest member
fgfhdfg
Top