MV Yanlfy Limited Skill Uses - I need to recover 1 use of a skill when it is used outside of battle.

In my game, there's a category of skills that have limited uses. Some of these can be used to solve puzzles in the overworld as well.
When these spells are used to interact with something in the overworld, I don't want it to cost a limited use(cuz I'm not a sadist)

So, I have a common event for each skill which can be used in this way which will trigger it's eventing functions. No trouble, I'll just tell it to recover the limited use of that skill in that common event, right?
Wrong (clearly, or I wouldn't be here lol)

The only functions described in the entirety of the help file are notetags for skills, items, and equipment; none of whose functions can be triggered through eventing outside of battle.

What I'm looking for is primarily one of two things:
1. A script to trigger a skill outside of battle (there must be SOMETHING right? That function DOES exist within the engine)

2. A script to recover one limited use of a specified skill (this could require digging into the code of the plugin and figuring out how it works, I'm guessing this ain't happening and I'm fine with that)

I already have a recover skill that works, I just can't trigger it through eventing and have to use it manually instead.

If anyone has any help they can provide it'd be greatly appreciated. ^.^
A script to trigger a skill outside of battle
and just to clarify, your common event is handling what the skill actually does outside of battle? all you need to do refund the player a use of the skill, correct?

you could call the function to restore a use in that common event, but looking at the webpage for the plugin, you could probably use one of the built in notetags. try this:
Code:
<Custom Skill x Limited Uses>
value += $gameParty.inBattle() ? 0 : 1;
</Custom Skill x Limited Uses>

otherwise, the script you'd use looks like its
Code:
$gameActors.actor(1).paySkillLimitedUseCost(skillId, -1)
or whatever battler reference you need
Hey, sorry for the late response. Thankyou for trying.

Yes, you are correct in understanding the only thing I need is to restore one limited use of a skill when it is used outside of battle.

I'm going to establish the names of two skills for clarities sake. The first is "SetFire". This is the actual skill. The second is "restore-F", the skill that, when used, restores one limited use of SetFire.


Neither of these scripts call the function of running a skill outside of battle, which is what I thought this was at first glance. I figure something like that MUST exist somewhere, and is likely still my best shot.

The first script is, of course, something to be placed in the notetag of SetFire itself; however, it does nothing when placed there. I also tried it in a common event, which also did nothing.
If I am supposed to alter the first script in any way, it is unclear both if, and if so: in what way I should alter it.

I have also tried the second script in a common event, including setting the "(skillId, -1)" to 20 (the skill ID of SetFire) 21, (the skill ID of restore-F) and leaving it unchanged as "-1". I have seen zero indication that any of these had any affect.

To clarify, everything I've tried has the exact same result, the one I was already getting: The skill cost is used, the common event activated and thus menu is closed, and when I reopen the spell menu, the cost has not been restored.


Edit: The more I think about it, the more I think I could make use of the ability to activate skills via scripts outside of battle in more ways than just this.
As such, I might want to shift my focus exclusively to this, which would not be plugin related any longer (or at least not Yanfly limited use related) so I might wanna make a new thread, or have this one renamed/moved.
edit2: just realized plugin and javascript support are one channel 😅

and just to clarify, your common event is handling what the skill actually does outside of battle? all you need to do refund the player a use of the skill, correct?

you could call the function to restore a use in that common event, but looking at the webpage for the plugin, you could probably use one of the built in notetags. try this:
Code:
<Custom Skill x Limited Uses>
value += $gameParty.inBattle() ? 0 : 1;
</Custom Skill x Limited Uses>

otherwise, the script you'd use looks like its
Code:
$gameActors.actor(1).paySkillLimitedUseCost(skillId, -1)
or whatever battler reference you need
The first script is, of course, something to be placed in the notetag of SetFire itself; however, it does nothing when placed there. I also tried it in a common event, which also did nothing.
If I am supposed to alter the first script in any way, it is unclear both if, and if so: in what way I should alter it.
replace the x in the notetag's opening and closing tags with the id of the skill its meant to alter the uses of.

I have also tried the second script in a common event, including setting the "(skillId, -1)" to 20 (the skill ID of SetFire) 21, (the skill ID of restore-F) and leaving it unchanged as "-1". I have seen zero indication that any of these had any affect.
Id need a screenshot to see exactly how you had it. assuming it was
Code:
$gameActors.actor(1).paySkillLimitedUseCost(20, -1)
it should have refunded actor 1 one use of skill 20.
if it doesnt and the notetag change doesnt work, i'll take a closer look
Ahhh, I see. I thought "skillid" was asking for the skill ID, not that it was supposed to be replaced with the skill ID!
Second script works now! (I need to activate a common event anyways, so I'll just go with this)
Thankyou so much! ^.^

I might still look into how to trigger skills within eventing outside of the battle scene, as I still can't imagine that wouldn't be a scripting function, but I guess I could search through the list of all existing javascript functions and find it that way. That just sounds super exhausting and I'm hoping there's someone out there who just like- knows hot to do that 😅

Alternatively I could always cheat it for something like a heal spell, but I'd need a way to deplete the limited use cost by 1. Wait tho- couldn't the second script be used to deplete the cost as well?
I just tried changing it to a positive value, but no dice.

You see, I have two ways you can activate a spell. One is through the regular skills menu, and the other is by hitting "S" and opening the skill-select menu. All spell functions are evented in that menu though, ofc, so if I wanted to actually consume the cost of a spell like "heal" (unlike the puzzle solving spells) then I would need a way to event that.


replace the x in the notetag's opening and closing tags with the id of the skill its meant to alter the uses of.


Id need a screenshot to see exactly how you had it. assuming it was
Code:
$gameActors.actor(1).paySkillLimitedUseCost(20, -1)
it should have refunded actor 1 one use of skill 20.
if it doesnt and the notetag change doesnt work, i'll take a closer look
Wait tho- couldn't the second script be used to deplete the cost as well?
I just tried changing it to a positive value, but no dice.
it should work. its exactly how the plugin normally deducts uses as you use the skill. youre still looking at actor 1 and youve made sure that youre using the correct skill id for battle version of that new skill, right? Once again, it always helps to attach a screenshot of exactly what you tried even if it seems incredibly insignificant

I might still look into how to trigger skills within eventing outside of the battle scene, as I still can't imagine that wouldn't be a scripting function, but I guess I could search through the list of all existing javascript functions and find it that way. That just sounds super exhausting and I'm hoping there's someone out there who just like- knows hot to do that
youll have to be more precise in what you mean when you say that. from a technical standpoint, thats a very vague question all things considered.

Original thread: https://forums.rpgmakerweb.com/threads/yanlfy-limited-skill-uses-i-need-to-recover-1-use-of-a-skill-when-it-is-used-outside-of-battle.178458/