I'm currently working on some on-map utility skills Golden Sun style. I already got the meat of the skill to work. As in, if I go into the main menu -> skills -> Geokinesis, I can make the boulder move as intended. The problem is, I don't want players to have to go through all those menus every time they want to cast one of these on-map skills. I already have both YEP_MapSelectSkill & YEP_ButtonCommonEvents installed. I put the plugin command MapSelectSkill 9 1 2 into one of my Common Events, which is bound to Spacebar (for now). I understand that YEP_MapSelectSkill simply saves a skillId into a variable. But I'm not sure what to do w/ that variable after it's set. I simply want the game to use the skill as if the player had gone through all the menus w/o actually going thru the motions. Any ideas?
MV Need Help Using YEP_MapSelectSkill
Javascript/Plugin SupportWhat are you trying to get the map select skill function to do?
Are you trying to make it bind to your use key when selecting a skill?
If that's the that case you could have one common event bound to your key of choice, and have it check the variable set by the map select skill. For example if you had 3 spells to choose from, the event would check if variable 1, 2, or 3 is active using conditional branches, and inside each branch put the appropriate skill.
But If you're trying to straight up bind skills to a set key then I don't see a need for the map select skill at all, it could be done straight through button common events (or mano input plugin). And you would build the skills in separate common events.
An example of a skill.
Let's say Geokinesis costs 5MP.
- Set a variable to the game data of your actor's current MP.
- Conditional branch if that variable is equal to or greater than 5.
- If so, subtract 5MP from the actor and run the skill + any animations
Are you trying to make it bind to your use key when selecting a skill?
If that's the that case you could have one common event bound to your key of choice, and have it check the variable set by the map select skill. For example if you had 3 spells to choose from, the event would check if variable 1, 2, or 3 is active using conditional branches, and inside each branch put the appropriate skill.
But If you're trying to straight up bind skills to a set key then I don't see a need for the map select skill at all, it could be done straight through button common events (or mano input plugin). And you would build the skills in separate common events.
An example of a skill.
Let's say Geokinesis costs 5MP.
- Set a variable to the game data of your actor's current MP.
- Conditional branch if that variable is equal to or greater than 5.
- If so, subtract 5MP from the actor and run the skill + any animations
Perhaps this video will explain my situation more clearly.
Ignore the cat meows, it's for testing purposes lol...
Edit:
Ignore the cat meows, it's for testing purposes lol...
Edit:
This is the part I'm having trouble with. Let's say I have a skillID saved to a variable from the MapSelectSkill plugin. I don't know what to put in a Common Event in order to cast/use the skill. I get that I'm supposed to reference the variable set by the MapSelectSkill plugin, but I can't find any command to actually use said skill.
I see what you mean, I think the best way to do this is to recreate what the skill does inside the common event. Does your skill currently work by running a common event? If so then a structure like this should work.
You just need to make sure anything the skill does is included, such as sound effects or animations. This is recreating the skill instead of telling the game to run it directly.
You just need to make sure anything the skill does is included, such as sound effects or animations. This is recreating the skill instead of telling the game to run it directly.
Hmm, I guess that'll have to do. Of course, having the game directly execute the skill would be preferable, but if it works, it works. I guess there really isn't a "use skill" command, huh? Unfortunate, but I'll make do, for now. Thanks!
Edit: Wait...shouldn't there be a way to use a skill (which is basically an item) with the useItem() function?
Edit: Wait...shouldn't there be a way to use a skill (which is basically an item) with the useItem() function?
No, you need to construct and apply a new action based on the item/skill. Check out this thread:
forums.rpgmakerweb.com
Notably the end result (mostly Aesica's work):
How to use a item in eventing?
Hi, I can't figure out how to use a item in the eventing window. I want this to happen on a main map on player touch Hero consume item 1 .. must i 'change items' and make a eventing of the items effect and restore?
forums.rpgmakerweb.com
You can swap
$dataItems for $dataSkills, I think everything else should be OK as-is?Hmm, I'm getting a "target.isDead" is not a function error. This is what my common event looks like now upon using the suggested code:
I didn't change anything other than $dataItems -> $dataSkills and also YOUR_ITEM_ID_HERE -> $gameVariables.value(9).
Edit: I disabled the YEP_OptimizeScriptCalls plugin, which seems to have fixed the error message. However, the skill doesn't actually execute. I added a Sound Effect just to make sure the Common Event was being invoked, which it was. The skill works when I use it normally from the menu, but nothing happens if I use it via this Common Event...
Edit2: Nvm, disabling YEP_OptimizeScriptCalls didn't make the error go away. It simply made it so the game doesn't crash. But in the console, the same error persists.
Edit3: I also tried using the original code (for Items) and tested it using a Health Potion. But I still get an error, albeit a different one.
That's odd for a couple of reasons:
For testing purposes you could add a bunch of console logs before the
Then check the console to see if the values match what you expect.
makeTargetsought to return an empty array for actions with Scope: None. The script call invokestestApplyonce per target, which should be 0 times for a skill with Scope: None.
- By default actors and enemies both inherit from
Game_BattlerBase, therefore have theisDeadmethod. ApparentlyGame_Action#makeTargetsis returning something different for you, though.
For testing purposes you could add a bunch of console logs before the
testApply line, e.g.(function(v,i,t,a,c,u,n) {
if (i = $dataSkills[+v || 0]) { console.log('using skill ID:', v);
u = $gameParty.members()[0]; console.log('skill user:', u);
a = new Game_Action(u);
a.setItemObject(i);
t = i.scope === 7 ? [u] : a.makeTargets(); console.log('targets:', t);
for (n in t) c = c || a.testApply(t[n]);
if (u.canUse(i) && (i.scope === 0 || c)) {
u.useItem(i);
for (n in t) for (var m = a.numRepeats(); m--;) a.apply(t[n]);
a.applyGlobal();
}}})($gameVariables.value(9));Then check the console to see if the values match what you expect.
The makeTargets() function is indeed returning an empty array (due to the scope being "None"), so that's all well and good right? LeTBS doesn't actually change anything in Game_Action. I know for sure that isDead() works elsewhere since I've used it several times before w/o incident. Here's the result of the console logs:
Edit: I also disabled all my LeTBS plugins and the error persists.
As I mentioned before, if the array is empty then
...with one of these:
developer.mozilla.org
Otherwise I think I'm out of ideas for now. 😴
testApply should not be being invoked at all. Perhaps the "empty" array has 1+ non-standard enumerable properties added to it? Try replacing this line: for (n in t) c = c || a.testApply(t[n]);...with one of these:
- For testing:
for (n in t) console.log('target', n, 'is:', t[n]);
- As an alternative:
for (n of t) c = c || a.testApply(n);
If that works, then you should also replace this line:
for (n in t) for (var m = a.numRepeats(); m--;) a.apply(t[n]);
...with this:
for (n of t) for (var m = a.numRepeats(); m--;) a.apply(n);
for...of - JavaScript | MDN
The for...of statement executes a loop that operates on a sequence of values sourced from an iterable object. Iterable objects include instances of built-ins such as Array, String, TypedArray, Map, Set, NodeList (and other DOM collections), as well as the arguments object, generators produced by...
That fixed it! Thank you!!
P.S. I was also able to trace the original issue to LeUtilities.js, which is a required plugin for LeTBS. This is the console logs in regards to that:
Edit: So basically, LeUtilities.js was adding extra enumerable properties? And due to this, the original code that was posted was reading those when we didn't want it to, correct? The issue is resolved, but I just wanted to learn what I can from this experience.
Great! 😂
Yes,
developer.mozilla.org
If you simply add a new property to an object, e.g.
developer.mozilla.org
Yes,
for...in iterates over all enumerable properties. By contrast, for...of references the object's iterator generator function to determine the iterated values, technical details here:
Symbol.iterator - JavaScript | MDN
The well-known Symbol.iterator symbol specifies the default iterator for an object. Used by for...of.
myObj.test = 123, that new property will be enumerable. Object.defineProperty can be used to specify a non-enumerable property. Details here:
Object.defineProperty() - JavaScript | MDN
The static method Object.defineProperty() defines a new property directly on an object, or modifies an existing property on an object, and returns the object.
I'm curious, why was
for...in chosen over for...of in the original code? Like, what advantage does it have in that use case that warrants for...in over for...of?I just copied Aesica's structure; my guess is that they were unaware of
As far as I'm aware,
For arrays, another option is to use a basic
for...of, or just forgot it exists (I can relate).As far as I'm aware,
for...of is a better option whenever you're doing any sort of "normal" loop over an object's values. for...in can be useful if you want to use the key names as well as the values, but that's not necessary in this case.For arrays, another option is to use a basic
for loop, from 0 to length - 1. 👋Original thread: https://forums.rpgmakerweb.com/threads/need-help-using-yep_mapselectskill.149178/