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

● ARCHIVED · READ-ONLY
Started by ragnorak6608 13 posts View original ↗
  1. 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.
  2. 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?
  3. Waterguy said:
    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. 

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



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

    Waterguy said:
    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
  4. 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...
  5. Waterguy said:
    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?
  6. 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...
  7. Waterguy said:
    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: 

    Spoiler
    <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?
  8. 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.
  9. Waterguy said:
    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
  10. Maybe. Give it a try.
  11. Spoiler
    <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...
  12. ...


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


    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!

    Spoiler
    <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