Learn Skill after x turns of being afflicted by a state

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
Is there any way by default in engine to check turn count for having a state applied through eventing during a loop?

Player affected by this
Check if taking damage this turn
TurnCountLeft-1

On turncount=0
Learn skill

theorized layout not actually proper pseudo code or code in general. Thank you for reading.

If i need to use visustella skill and state I would love to know the syntax required in the event
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,920
Reaction score
11,871
First Language
German
Primarily Uses
RMMV
you can start a parallel process with the skill that applies the state, and have the parallel process count the turns until it ends itself, giving the skill on count=0 before ending itself.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
you can start a parallel process with the skill that applies the state, and have the parallel process count the turns until it ends itself, giving the skill on count=0 before ending itself.
Currently the skill is enemy casts Venom Once -> applies a state of poison that ends upon battle end or it being cleansed by antidotes.
Should I just make it so the poison state ends automatically after a certain amount of turns and then count down the variable for learning the skill accordingly until it hits 0?
Ideally wondering if there is a way to verify and check for turn end which is where the tick damage is dealt so it can remove from the count. That way i can keep the state code the same. I will be able to give more exact context through code and screenshots when i am home
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,920
Reaction score
11,871
First Language
German
Primarily Uses
RMMV
Ideally wondering if there is a way to verify and check for turn end which is where the tick damage is dealt so it can remove from the count.
if the skill/state is only used in battle, make it a troop event running once per turn on turn end.
and probably a plugin for base troop events or you would have to copy that troop event into every troop.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
if the skill/state is only used in battle, make it a troop event running once per turn on turn end.
and probably a plugin for base troop events or you would have to copy that troop event into every troop.
Does VisuStella's Events and Movements core support base troop events so I don't have to copy paste it constantly?
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
Currently this is the code I have in a troop event, however it doesn't function as intended

Control Variables : #0010 Venom/Poison = 5 Loop If: Reid has learned Acid Resist I Break Loop Else If: Reid is affected by PoisonDamage Control Variables: #0010 Venom/Poison -= 1 If: Venom/Poison = 0 Change Skill: Reid, + Acid Resist I Text: "to tell the player they have learned the skill" break loop 3 end statements followed by Repeat Above
in the context of the eventing window obviously and not general JS code.
As of current, the player learns the skill after the very first instance is applied, which is definitely not intended
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,589
Reaction score
11,062
First Language
English
Primarily Uses
RMMV
As of current, the player learns the skill after the very first instance is applied, which is definitely not intended
There's nothing to make it not. A loop means "keep doing this code."

So you set your variable to 5, then you tell it to loop, so your Else condition will execute 5 times in a fraction of a second until it hits 0, Reid learns the skill, and you say to break out of the loop.

You should use your VisuStella state notetags in the state to check at the end of every turn, incrementing a variable on the actor until it hits 5 and teaches the skill.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
There's nothing to make it not. A loop means "keep doing this code."

So you set your variable to 5, then you tell it to loop, so your Else condition will execute 5 times in a fraction of a second until it hits 0, Reid learns the skill, and you say to break out of the loop.

You should use your VisuStella state notetags in the state to check at the end of every turn, incrementing a variable on the actor until it hits 5 and teaches the skill.
I am finding turn end and regeneration phase related documentation on the skills and states plugin page, but a majority of it applies to states with a set duration. I am looking at the master list for script calls and everything, but I do have a general question regarding the notetags on the state. Can you put a notetag within a notetag? Or should I keep them separated in the state's notes.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,589
Reaction score
11,062
First Language
English
Primarily Uses
RMMV
I am finding turn end and regeneration phase related documentation on the skills and states plugin page, but a majority of it applies to states with a set duration.
Sorry, I don't see what you're talking about. Notetags don't care whether your state has a fixed duration, random, or turn/battle end. Some of the notetags in there are for displaying turn counters and such, but they'll work on anything.

As it turns out, the turn end notetag isn't in Skills and States, it's in the Battle Core. I'd use JS Post-End Action or JS Pre-End Turn, depending on when you want it to display.

Of course, presuming this is the same poison state as your other thread, I dunno why you wouldn't simply include the code to increment a variable and learn the skill inside the existing JS Slip Damage tag.
Can you put a notetag within a notetag?
No, and I can't really think why you'd want to. But if there is a reason, just have all applicable notetags and copy the code into each.
 

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,920
Reaction score
11,871
First Language
German
Primarily Uses
RMMV
Currently this is the code I have in a troop event, however it doesn't function as intended
can you give us a screenshot of the entire troop event?
this code is missing the properties of the troop event, conditions and span, and those can change the behaviour of any event if set wrong.
 

ZombieKidzRule

I’m back from my wilderness Snorlax retreat!
Regular
Joined
Jan 9, 2022
Messages
1,192
Reaction score
2,386
First Language
English
Primarily Uses
RMMZ
Just a quick, probably stupid question and then I will go back to the shadows and let the knowledgeable people solve this.

Why would you need a loop in this case at all?

If the event is only running once at the end of every turn in battle, why would it need to loop?

Couldn't you set the variable on the first page and then move to a 2nd page that just subtracts from said established variable until the skill is learned? But, of course, that wouldn't carry over to the next battle if the skill wasn't learned during the first battle.

Just wondering out loud, through typing text. Just ignore me if that question doesn't make sense.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
Sorry, I don't see what you're talking about. Notetags don't care whether your state has a fixed duration, random, or turn/battle end. Some of the notetags in there are for displaying turn counters and such, but they'll work on anything.

As it turns out, the turn end notetag isn't in Skills and States, it's in the Battle Core. I'd use JS Post-End Action or JS Pre-End Turn, depending on when you want it to display.

Of course, presuming this is the same poison state as your other thread, I dunno why you wouldn't simply include the code to increment a variable and learn the skill inside the existing JS Slip Damage tag.

No, and I can't really think why you'd want to. But if there is a reason, just have all applicable notetags and copy the code into each.
This is in fact the same poison state, I was wondering if I could put a notetag in a notetag purely for that reason because I didn't know if they acted properly when in the sames note but separately. Though, if I can do this with the same notetags, that is good to know. I found out how to set the variable in the notetag. My only question now regarding it after having found how to subtract from the variable(or add, either works really I believe) would be, could I store the variable globally so that say. The player takes 3 turns of tick damage in one battle, and then 2 in another and have them learn the skill in the second battle. The easier solution is to just do it in the notetag with a setValue and essentially an if statement, though I believe it would reset the variable each time the player is inflicted with the state.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
can you give us a screenshot of the entire troop event?
this code is missing the properties of the troop event, conditions and span, and those can change the behaviour of any event if set wrong.
I can recreate the event here in a moment and send a screenshot just for clarity and learning troop events better.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
can you give us a screenshot of the entire troop event?
this code is missing the properties of the troop event, conditions and span, and those can change the behaviour of any event if set wrong.
 

Attachments

  • screen1.PNG
    screen1.PNG
    329.1 KB · Views: 2
  • screen2.PNG
    screen2.PNG
    299.5 KB · Views: 2

Andar

Regular
Regular
Joined
Mar 5, 2013
Messages
39,920
Reaction score
11,871
First Language
German
Primarily Uses
RMMV
@Xarnic:
wrong span
the span determines hoow often a troop event is started - once per battle, once per turn, once per action (moment).
with that current setting, the event is run at the beginnin of the first turn and then never again. it should be span=turn to be able to run once per turn (at turn end).

with that change, the loop becomes unneccessary and wrong - you need to change the logic so that the event counts down once per turn.

which also means that the setting of the variable to 5 needs to be somewhere else, linked to the application of the state.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,589
Reaction score
11,062
First Language
English
Primarily Uses
RMMV
This is in fact the same poison state, I was wondering if I could put a notetag in a notetag purely for that reason because I didn't know if they acted properly when in the sames note but separately.
Code is code. The notetag it's inside of can't change anything about the code you write, it only determines when it happens.
I found out how to set the variable in the notetag. My only question now regarding it after having found how to subtract from the variable(or add, either works really I believe) would be, could I store the variable globally
If you set a variable on a player, it will stay there for the rest of the game. So inside of your JS HP Slip Damage, you'd do this:
Code:
<JS HP Slip Damage>
damage=Math.floor(user.mat * (target.isStateAffected(32) ? 0.3 : 0.5));

// Check for a poison counter, and create it if it's not there yet
target._poisonCount = target._poisonCount || 0;

// If they haven't already learned resistance...
if (target._poisonCount<5)
{
    // Increment the counter and possibly learn it
    if (++target._poisonCount==5)
    {
        var txt=target.name() + " has learned whatever your skill is called!";
        $gameMessage.add(txt);
        target.learnSkill(Y);
    }
}
</JS HP Slip Damage>
Make the text box suit your needs, and replace Y with the ID of your skill. If the battle ends before they've learned it, the _poisonCount variable will retain its value until the next time they're poisoned.

I'd suggest you browse and read through Yanfly's Tips & Tricks articles. They're for MV, so the actual plugins required and notetags used will be different, but it will give you a good idea of the timing parts of a turn that can be used to activate effects, and how some of the code for various things works.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
I'd suggest you browse and read through Yanfly's Tips & Tricks articles. They're for MV, so the actual plugins required and notetags used will be different, but it will give you a good idea of the timing parts of a turn that can be used to activate effects, and how some of the code for various things works.
Alright, will do. I appreciate all the help, thank you. I put in the code suggested, and everything works seemingly except for the incrementing of the variable and learning the skill.
<JS HP Slip Damage> damage=Math.floor(user.mat * (target.isStateAffected(32) ? 0.3 : 0.5)); // Check for a poison counter, and create it if it's not there yet target.PoisonCounter = target.PoisonCounter || 0; // If they haven't already learned resistance... if (target.PoisonCounter<5) { target.PoisonCounter+=1; console.log(target.PoisonCounter); // Increment the counter and possibly learn it if (target.PoisonCounter==5) { var txt=target + " has learned whatever your skill is called!"; $gameMessage.add(txt); target.learnSkill(231); } } </JS HP Slip Damage>


And what I originally tried <JS HP Slip Damage> damage=target.states().includes($dataStates[32]) ? Math.floor(user.mat * 0.3) : Math.floor(user.mat * 0.5); target.PoisonCounter = target.PoisonCounter || 0; //if they haven't learned already if (target.PoisonCounter<5) { //increment till 5 if(++target.PoisonCounter==5) { var txt=target.name() + "has learned the trait Acid Resist I!"; $gameMessage.add(txt); target.learnSkill(231); } } </JS HP Slip Damage>

Just checked with the use of the console and it is only adding the initial count of 1 throughout a whole battle.
 

Trihan

Speedy Scripter
Regular
Joined
Apr 12, 2012
Messages
6,838
Reaction score
7,852
First Language
English
Primarily Uses
RMMZ
JS HP Slip Damage is only evaluated once when the state is applied to avoid lag from constant recalculation. Use JS Pre-Regenerate instead.
 

ATT_Turan

Forewarner of the Black Wind
Regular
Joined
Jul 2, 2014
Messages
12,589
Reaction score
11,062
First Language
English
Primarily Uses
RMMV
Sorry! I actually noticed that when I was looking it up for your other thread, but forgot about it.

There's also a Slip Refresh notetag or something you can call to make it execute again, but moving the skill part into Pre-Regeneration is probably the better idea.
 

Xarnic

Villager
Member
Joined
Jan 29, 2022
Messages
28
Reaction score
5
First Language
English
Primarily Uses
RMMZ
Sorry! I actually noticed that when I was looking it up for your other thread, but forgot about it.

There's also a Slip Refresh notetag or something you can call to make it execute again, but moving the skill part into Pre-Regeneration is probably the better idea.
So I would do the following? <JS HP Slip Damage> damage=Math.floor(user.mat * (target.isStateAffected(32) ? 0.3 : 0.5)); </JS HP Slip Damage> ////////////////////////////////////////////////////////////////////////////// <JS Pre-Regenerate> // Check for a poison counter, and create it if it's not there yet target.PoisonCounter = target.PoisonCounter || 0; // If they haven't already learned resistance... if (target.PoisonCounter<5) { target.PoisonCounter=target.PoisonCounter+1; console.log(target.PoisonCounter); // Increment the counter and possibly learn it if (target.PoisonCounter==5) { var txt=target + " has learned the trait 'Acid Resist I'!"; $gameMessage.add(txt); target.learnSkill(231); } } </JS Pre-Regenerate>

Editing cause for some reason I didn't properly copy over the starting less than symbol for the notetag for slip damage, testing again now lol.

Edit code works and the player can learn the skill! However I had to change the damage calc back to what I had before.
From: damage=Math.floor(user.mat * (target.isStateAffected(32) ? 0.3 : 0.5));
To: damage=target.states().includes($dataStates[32]) ? Math.floor(user.mat * 0.3) : Math.floor(user.mat * 0.5);
I do not know for sure why it's finnicky like that but it is.

Also, there is one issue I am seeing as well when these lines plays out:
var txt=target + " has learned the trait 'Acid Resist I'!"; $gameMessage.add(txt);
it displays, however it outputs "object Object has learned the trait..." etc.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Me with the fireplace, a space heater, and a heated blanket. My preferred lizard temperature.

I'm gonna riff on Macross's "Deculture" and adopt "Descope" as my motto! :wub God knows I'm gonna need it...

As an aside, did any of ya sweeties watch Macross Delta and if so, was it good, bad, or horrible?
Is an extension for the jam time limit from 20 min to 30 min possible? :ysad::ysad::ysad: My entry will have a few battles, it seems >.<
Background and composition study
GAbBmfDaIAAEzVM

Forum statistics

Threads
136,711
Messages
1,269,014
Members
180,431
Latest member
ZOOMNOTA
Top