Making a Skill only usable once per actor (RMMV)

Hello!

I have a Skill called "Scavenge" that allows all Actors with this Skill to search for a random item once per day (using Orange's Time System Events). The problem is that if I have Actor1 use this Skill then I'm not sure how to make it so that Actor2 can also use that Skill without having to wait a day.

For example, right now my script turns 'Scavenge Switch: ON' when Scavenge is used by Actor1. However, now if Actor2 tries to use Scavenge, they can't because 'Scavenge Switch' is ON and won't turn off until a new day begins. How can I get around this so each actor can use Scavenge?

Thanks!
You'll basically have to set up an own switch for each actor instead of just a general switch for the skill and have them reset each day.
You could try use this plugin, it allows to use skill n-times and reset it.
For the problem you mentioned about usage skill by other party members if someone else it used...
Make several copies of that skill and each copy give to different party member.



I don't use and I don't know Orange's Time System Events, but I assume it has some plugin commands so if they are, you can call them in Yanfly's plugin to reset skill usage.
You'll basically have to set up an own switch for each actor instead of just a general switch for the skill and have them reset each day.

Unfortunately this won’t work because I’m using SRD’s Copy Actors so that there can be multiple instances of the same type of actor in a Party. Kind of like how in Pokémon you can have two of the same Pokémon.

You could try use this plugin, it allows to use skill n-times and reset it.
For the problem you mentioned about usage skill by other party members if someone else it used...
Make several copies of that skill and each copy give to different party member.



I don't use and I don't know Orange's Time System Events, but I assume it has some plugin commands so if they are, you can call them in Yanfly's plugin to reset skill usage.


This seems like it would definitely work but now I have to decide if it’s really worth spending $10 on. I might just keep trying to find another way to do this rather than shelling out money. Thanks for the help though!
Ok here's the basic logic (no code):

1. You want to keep track of which actors have used the skill or not
2. You want to be able to use this information as part of your skill condition or something
3. You want to be able to reset this information, like when a new day begins, or you use an item or something.

First, you can have your skill call a common event and just let the common event handle all of the logic. But the problem is you don't know who used it.

You can use the damage formula to set a variable like this. So basically you're setting the variable 1 to the ACTOR ID. This is important: remember which variable you used to store your actor ID.

1595957434716.png


There's this plugin that basically let's you write effect formulas in a note-tag, which might make things cleaner, but up to you. http://himeworks.com/2016/02/formula-effects-mv/ (note that it's an effect, not a damage formula. Effects occur after damage processing)

Note that the scope can't be NONE because otherwise by default the damage formula doesn't get applied when scope is NONE. I'm just using "user scope" to test it quickly.

Next, you have that common event that gets executed. You can test that it works and shows your actor ID

1595957488649.png


This is how you can connect skills to common events via scripts. Then your common event just needs to take that actor ID and do something with it.

A variable can store more than just numbers, if you're using script calls. You might store a javascript object instead. First, you make this script call to "initialize" your object:

Code:
// initialize variable object
var obj = $gameVariables.value(2)
if (obj === 0) {
  obj = {}
  $gameVariables.setValue(2, obj)
}

// initialize count for actor
var id = $gameVariables.value(1)
obj[id] = obj[id] || 0

Basically, give it a value of 0.

Then you make a conditional branch check.
Remember that variable 2 stores our custom object, and variable 1 was the actor id (based on the damage formula)

Code:
$gameVariables.value(2)[$gameVariables.value(1)] === 0

Then you increment the usage by 1 for that actor

Code:
// initialize variable object
var obj = $gameVariables.value(2)
obj[$gameVariables.value(1)] += 1

This how the full common event looks.

1595958276969.png


This is if you don't want to use ANY plugins to keep track of that skill usage. If you want to do a skill reset, then just make script call to re-initialize the object's values to 0. For example something quick and dirty like

Code:
$gameVariables.setValue(2, {})

Which basically wipes out all of the data, and next time you make the common event call, it will re-initialize it to 0 so that you can start using it again.

Video demo of results:
Ok here's the basic logic (no code):

1. You want to keep track of which actors have used the skill or not
2. You want to be able to use this information as part of your skill condition or something
3. You want to be able to reset this information, like when a new day begins, or you use an item or something.

First, you can have your skill call a common event and just let the common event handle all of the logic. But the problem is you don't know who used it.

You can use the damage formula to set a variable like this. So basically you're setting the variable 1 to the ACTOR ID. This is important: remember which variable you used to store your actor ID.

View attachment 153182

There's this plugin that basically let's you write effect formulas in a note-tag, which might make things cleaner, but up to you. http://himeworks.com/2016/02/formula-effects-mv/ (note that it's an effect, not a damage formula. Effects occur after damage processing)

Note that the scope can't be NONE because otherwise by default the damage formula doesn't get applied when scope is NONE. I'm just using "user scope" to test it quickly.

Next, you have that common event that gets executed. You can test that it works and shows your actor ID

View attachment 153183

This is how you can connect skills to common events via scripts. Then your common event just needs to take that actor ID and do something with it.

A variable can store more than just numbers, if you're using script calls. You might store a javascript object instead. First, you make this script call to "initialize" your object:

Code:
// initialize variable object
var obj = $gameVariables.value(2)
if (obj === 0) {
  obj = {}
  $gameVariables.setValue(2, obj)
}

// initialize count for actor
var id = $gameVariables.value(1)
obj[id] = obj[id] || 0

Basically, give it a value of 0.

Then you make a conditional branch check.
Remember that variable 2 stores our custom object, and variable 1 was the actor id (based on the damage formula)

Code:
$gameVariables.value(2)[$gameVariables.value(1)] === 0

Then you increment the usage by 1 for that actor

Code:
// initialize variable object
var obj = $gameVariables.value(2)
obj[$gameVariables.value(1)] += 1

This how the full common event looks.

View attachment 153185

This is if you don't want to use ANY plugins to keep track of that skill usage. If you want to do a skill reset, then just make script call to re-initialize the object's values to 0. For example something quick and dirty like

Code:
$gameVariables.setValue(2, {})

Which basically wipes out all of the data, and next time you make the common event call, it will re-initialize it to 0 so that you can start using it again.

Video demo of results:


Sorry for the late response, but this worked perfectly! Thank you so much for the great breakdown and explanation as well, it helped me to figure out exactly how and why it worked. I already use your Game Over Events plugin, so you helping me with this felt like a celebrity helping me out lol. Anyways, I appreciate the time you took to help me!

Original thread: https://forums.rpgmakerweb.com/threads/making-a-skill-only-usable-once-per-actor-rmmv.124620/