Yanfly Auto Passive State - Several States Help

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
511
Reaction score
176
First Language
English
Primarily Uses
RMMV
Hello!

Would anyone be able to help me out with creating a handful of passive state tags (using Yanflys Auto Passive States plugin).


I'm hoping to create passive states that can do the following:

1. Recovers the owner's HP by 5% each time a party member is defeated in battle.
2. Similar to the first, Increases ATK and DEF of the owner by 10% for each party member that is currently KO'ed.
3. Adding an 5% Chance to inflict a state if certain skill ID's are used
4. Halving the MP cost of certain skill ID's

5. If variable 1 is greater than or equal to variable 2, 5% MAT boost, otherwise 5% MDF boost
6. Boost ATK by (Variable 1 multiplied by 3)%

I realize this is quite a lot of passive requests, I'm hoping to wrap up some loose ends with player skills, and figured these would be too many to post each individually. Even if not for the entire list, I'd appreciate help with any of them.

Thank you!
 
Last edited:

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
511
Reaction score
176
First Language
English
Primarily Uses
RMMV
Bump

Also, I edited the OP to clear up a few things.
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
336
Reaction score
49
First Language
English
Primarily Uses
Hello!

Would anyone be able to help me out with creating a handful of passive state tags (using Yanflys Auto Passive States plugin).


I'm hoping to create passive states that can do the following:

1. Recovers the owner's HP by 5% each time a party member is defeated in battle.
2. Similar to the first, Increases ATK and DEF of the owner by 10% for each party member that is currently KO'ed.
3. Adding an 5% Chance to inflict a state if certain skill ID's are used
4. Halving the MP cost of certain skill ID's
5. If variable 1 is greater than or equal to variable 2, 5% MAT boost, otherwise 5% MDF boost
6. Boost ATK by (Variable 1 multiplied by 3)%

I realize this is quite a lot of passive requests, I'm hoping to wrap up some loose ends with player skills, and figured these would be too many to post each individually. Even if not for the entire list, I'd appreciate help with any of them.

Thank you!
Haven't tested them but in theory could work and needs some tweaking for your purposes but I think its a good base.

1. I Don't know how to do it that isnt insanely complicated.

2.
Code:
<Custom Action Start Effect>
var group = user.friendsUnit().aliveMembers();           // loop for checking allies
for (var i = 0; i < group.length; ++i) {
   var ally = group[i];
if (ally.isStateAffected(1)) {                            // for each ally with knockout state
   user.addBuff(2,1);                                     // adds atk buff for 1 round
   user.addBuff(3,1);}                                    // adds def buff for 1 round
}
</Custom Action Start Effect>
3.
Code:
<Custom Initiate Effect>
if (!user._hasAlreadyTriggerStateXX){                               // Change XX to this state ID
    user._hasAlreadyTriggerStateXX = true                           // Change XX to this state ID
    var skills = [];
    skills.push(x, y, z);                                           // Add all skills that will give it a chance.
    if (this.isSkill() && (skills.contains(this.item().id))) {
        var statechance = 0.05;                                     // Chance to apply state
        if (Math.random() < statechance) {                          // Checks the chance
           target.addState(A);}                                     // Sucessful check adds state A
        }
    }                                    
</Custom Initiate Effect>

<Custom Action End Effect>
user._hasAlreadyTriggerStateXX = false
</Custom Action End Effect>
4. I also want to do a state like this for half MP use but its annoying and I dont think it can be done. So what I do for my game is go in each skill individual.
Code:
<Custom MP Cost>
if (user.isStateAffected(35)){              // State that halves MP consumption
cost = 20;}                                 // Half of what the MP is normally
</Custom MP Cost>
5-6. I haven't played with variables in codes so anything I do would be a guess.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
511
Reaction score
176
First Language
English
Primarily Uses
RMMV
Thank you for your help! :)

Unfortunately, in the case of 2 and 3, I can't seem to get them to work. 2 I just pasted into a passive state, while for 3, I had edited it to look like this:

Code:
<Custom Initiate Effect>
if (!user._hasAlreadyTriggerState958){                               // Change XX to this state ID
    user._hasAlreadyTriggerState958 = true                           // Change XX to this state ID
    var skills = [];
    skills.push(1, 346, 347, 348, 349, 350, 351, 368, 369, 370);                                           // Add all skills that will give it a chance.
    if (this.isSkill() && (skills.contains(this.item().id))) {
        var statechance = 0.99;                                     // Chance to apply state
        if (Math.random() < statechance) {                          // Checks the chance
           target.addState(22);}                                     // Sucessful check adds state A
        }
    }                                   
</Custom Initiate Effect>

<Custom Action End Effect>
user._hasAlreadyTriggerState958 = false
</Custom Action End Effect>
As for the MP cost, that will work just fine. I am curious though, what would the syntax be to set up a ifelse statement, to allow a few different states to reduce the cost by different amounts?
 

Icenick

Veteran
Veteran
Joined
Mar 28, 2012
Messages
336
Reaction score
49
First Language
English
Primarily Uses
Thank you for your help! :)

Unfortunately, in the case of 2 and 3, I can't seem to get them to work. 2 I just pasted into a passive state, while for 3, I had edited it to look like this:

Code:
<Custom Initiate Effect>
if (!user._hasAlreadyTriggerState958){                               // Change XX to this state ID
    user._hasAlreadyTriggerState958 = true                           // Change XX to this state ID
    var skills = [];
    skills.push(1, 346, 347, 348, 349, 350, 351, 368, 369, 370);                                           // Add all skills that will give it a chance.
    if (this.isSkill() && (skills.contains(this.item().id))) {
        var statechance = 0.99;                                     // Chance to apply state
        if (Math.random() < statechance) {                          // Checks the chance
           target.addState(22);}                                     // Sucessful check adds state A
        }
    }                                  
</Custom Initiate Effect>

<Custom Action End Effect>
user._hasAlreadyTriggerState958 = false
</Custom Action End Effect>
As for the MP cost, that will work just fine. I am curious though, what would the syntax be to set up a ifelse statement, to allow a few different states to reduce the cost by different amounts?
I see my mistake for 2, I had it check all alive members when it wont trigger since im checking to see whos dead! Heres the new code. Customise it for your purposes.
Code:
<Custom Turn Start Effect>
var group = $gameParty.allMembers();           
for (var i = 0; i < group.length; ++i) {
   var ally = group[i];
if (ally.isStateAffected(1)) {                           
   user.addBuff(2,1);                                     
   user.addBuff(3,1);}                                   
}
</Custom Turn Start Effect>
Here is 3, it works just fine for me, I assume you tried with basic attack and it did not work, its because the first code I posted had to check if it was a skill. I removed that. Also the "user._hasAlreadyTriggerState958" I use to prevent from triggering more than once per turn, if you have instant or combos you might have to remove it.
Code:
<Custom Initiate Effect>
if (!user._hasAlreadyTriggerState958){                               // Change XX to this state ID
    user._hasAlreadyTriggerState958 = true                           // Change XX to this state ID
    var skills = [];
    skills.push(1, 346, 347, 348, 349, 350, 351, 368, 369, 370);                                           // Add all skills that will give it a chance.
    if (skills.contains(this.item().id)) {
        var statechance = 0.75;                                     // Chance to apply state
        if (Math.random() < statechance) {                          // Checks the chance
           target.addState(21);}                                     // Sucessful check adds state A
        }
    }                                 
</Custom Initiate Effect>

<Custom Action End Effect>
user._hasAlreadyTriggerState958 = false
</Custom Action End Effect>

Havent tried the MP cost one but it should just need an else if and proper ordering, not 100% sure of it maybe someone can confirm. Best way is to look at Yanfly Tips and Tricks (MP cost example) and break down codes from similar skills. Thats how I learnt most of what I can do, that and a few people being really helpful on forums.
Code:
<Custom MP Cost>
if (user.isStateAffected(35)){              // State that halves MP consumption
cost = 20;}                                 // Half of what the MP is normally
else if (user.isStateAffected(36)){         // Different state
cost = 10;}                                 // Different MP cost
else if (user.isStateAffected(35) && user.isStateAffected(36)){
cost = 0;}                                  // Both states makes it cost 0 mp.
</Custom MP Cost>
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
511
Reaction score
176
First Language
English
Primarily Uses
RMMV
Thank you, from my testing, all three seem to be working great!

I do feel a bit bad, though. At first, I couldn't get these ones to work either, but after some searching around, I found that I had completely overlooked this warning on Yanfly's Auto Passives page:

NOTE: For those using Passive States with your skills, the passive states will only be applied from Learned Skills! They will not be applied from skills that are learned through traits. Why? Because without this restriction, a passive skill that applies a passive state that in turn provides a skill through its traits will cause an infinite loop in your game and cause it crash. So if you want your skills to provide a passive state, have your actors learn the skill instead of applying it through a trait.
Turns out, my last test for 2 and 3 wouldn't have worked eitherway, whoops... Glad to say all is working now, though.
 

Vis_Mage

Novice Magician
Veteran
Joined
Jul 28, 2013
Messages
511
Reaction score
176
First Language
English
Primarily Uses
RMMV
~Bump~

I've also marked off the three solved requests from the OP
 

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

Latest Threads

Latest Profile Posts

Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.
is there a script call that return how much turn has passed in battle?
Does anyone find this hard to read?

Enjoying my weekend at home to stay Covid free. How is everyone else doing?

Forum statistics

Threads
100,603
Messages
977,740
Members
132,216
Latest member
Darkscythe25
Top