Trying to make a skill check for which actor is trying to use it, then call for a common event based on the actor. I'm new to scripts and only know the very basics, how would I do this?
How do I check for which actor is using an ability?
RPG Maker MV SupportNot really sure if it is possible without a plugin but I made a plugin for you that lets this be possible.
The plugin places the data of the last action into "$gameSystem._lastAction"
So then it can be used in a common event from the actions effect list
Example:
$gameSystem._lastAction._subjectActorId
In my test skill I used it like this:
Also if you want to get an enemy name using the last target index this is the code I used:
JavaScript:
$dataEnemies[$gameTroop._enemies[$gameSystem._lastAction._targetIndex]._enemyId].battlerName + $gameTroop._enemies[$gameSystem._lastAction._targetIndex]._letter
CTB_LastActionDataMV Plugin: Click Here to Download
Well hope that helps. Let me know how it goes. Should work nicely as needed. 🙂
Thank you so much!! This is exactly what I was looking for 🙂
thats a nice idea.. i am working on a plugin that affect actions & forceActions & expanded this idea a bit for more options: (added to GameAction apply)
JavaScript:
if (this._forcing == false) $gameSystem._lastNormalAction = this;
if (this._forcing == true) $gameSystem._lastForceAction = this;
$gameSystem._lastAction = this;
Thats supposed to help recall different actions depending if they were forced or not.. that way i can store different actions if one "normal action" forced another "forceAction".
this can be usefull for combo skills and mimic skills ect
I'm pretty sure, without plugins or scripts, you can only ever check who was attacked (by applying States then Conditional Branches) and not who was doing the attack.
But, thankfully, there are lots of helpful people on here who'll make plug-ins like the one above to fix that for those who need it!
But, thankfully, there are lots of helpful people on here who'll make plug-ins like the one above to fix that for those who need it!
Very much welcome! Glad I could help out 🙂
Interesting, good idea. Yep that could be useful too 🙂
v1.10 - Added that feature to the plugin (credited you for that part 😉 )
v1.20 - Added "lists" for the actions to be able to reference actions from the past (not really sure if that will ever be useful but hey lol it's there now if needed)
Although it's kind of a cool feature because now something like this can be done...
JavaScript:
$gameTemp._normalActionList.filter(v => v._subjectEnemyIndex >= 0)
JavaScript:
/*
* Places the data of the last action into "$gameSystem._lastAction"
* So then it can be used in a common event from the actions effect list
*
* Examples:
* $gameSystem._lastAction._subjectActorId
* $gameSystem._lastNormalAction._subjectActorId
* $gameSystem._lastForceAction._subjectActorId
*
* Can also now recall actions used from the past via list(s) of actions
* Last action:
* $gameTemp._actionList[$gameTemp._actionList.length-1]
*
* Normal action stored at 2 normal actions from the end of the list:
* $gameTemp._normalActionList[$gameTemp._normalActionList.length-3]
*
* Forced action stored at 5 forced actions from the end of the list:
* $gameTemp._forceActionList[$gameTemp._forceActionList.length-6]
*
* List of normal actions from only enemies:
* $gameTemp._normalActionList.filter(v => v._subjectEnemyIndex >= 0)
* Not really sure if the list(s) feature is really needed but it's there now lol
*
* Credit to dopan for lastNormalAction & lastForceAction
*/
Hmm... very interesting ...yep I think I'll expand on that now.
I think I might start storing "battle info" for every battle lol... not sure yet.. but I probably will.
...so like then way later in a game if a certain enemy used a certain move or something then an NPC could give you something or talk about that one time when the enemy used such and such attack on the player lol idk.. just total random ideas forming now 🤣
Yep.. pretty sure I must make a whole "battle/action info log" plugin now lol
With all the data of each action and battle info that has occurred in a game.
Add that to my never ending "todo" list lmao
Edit:
[v2.00] https://ct-bolt.itch.io/rmmv-lastaction-data
...
Huge overhaul... this plugin is actually now becoming something else entirely now lol
JavaScript:
//Can also now recall actions used from the past via list(s) of actions
//List of all actions in the Item Scene
$gameSystem.getActionList("Scene_Item")
//List of all actions in the Skill Scene
$gameSystem.getActionList("Scene_Skill")
//List of normal actions from only enemies in battle #1:
$gameSystem.getBattleActionList(1,'_normalActionList').filter(v => v._subjectEnemyIndex >= 0)
//List of all actions from all battles:
$gameSystem.getBattleActionList()
//Access an array of all the actionInfo objects
$gameSystem._actionInfo
Interresting! i like the idea of adding lists aswell!
but get they ever reseted?? wouldnt these list get very long after time?
in my srpg-plugin i could reset this list after every srpgBattle has ended (means if "srpgMode" is off) , but i am not sure where normal projects with default sv battle would do that.
(probably that could be done in any battlemanager function, or did you want to store all battleActions within the game?)
also no need to credit me,I am fine aslong i am allowed to add your ideas to my plugin aswell^^
edit:
another question is.. what happens with the skill actions that are used outside of sv battle (in the menu) ,? do they affect these lists?
edit2:
i saw the 2.0 version and that kind of answers my question^^
that gos way far than i would have expected..
- i will only use & reset the code for battles (means they get reseted after the whole battle is done)
but get they ever reseted?? wouldnt these list get very long after time?
in my srpg-plugin i could reset this list after every srpgBattle has ended (means if "srpgMode" is off) , but i am not sure where normal projects with default sv battle would do that.
(probably that could be done in any battlemanager function, or did you want to store all battleActions within the game?)
also no need to credit me,I am fine aslong i am allowed to add your ideas to my plugin aswell^^
edit:
another question is.. what happens with the skill actions that are used outside of sv battle (in the menu) ,? do they affect these lists?
edit2:
i saw the 2.0 version and that kind of answers my question^^
that gos way far than i would have expected..
- i will only use & reset the code for battles (means they get reseted after the whole battle is done)
Yep as you noticed the lists are separated by what scene the action was performed in. 🙂
Yeah lists could get really big if not cleared at some point, that was also a bit of a concern of mine too...
Just updated to version 2.11, big fix and added a parameter to execute custom code when the battle ends.
Basic example shown below will only keep the 2 battles before clearing it entirely...
or the default code now included in version 2.11...
JavaScript:
const scene = 'Scene_Battle';
$gameSystem._actionInfo[scene] = $gameSystem._actionInfo[scene] || [];
$gameSystem._actionInfo[scene]._actionList = $gameSystem.getBattleActionList($gameSystem.battleCount());
$gameSystem._actionInfo[scene]._normalActionList = $gameSystem.getBattleActionList($gameSystem.battleCount(),'_normalActionList');
$gameSystem._actionInfo[scene]._forceActionList = $gameSystem.getBattleActionList($gameSystem.battleCount(),'_forceActionList');
Parameter can customized to be used however the user sets it up.
This could also of course be done manually at any other point in the game for any of the lists.
Edit:
Updated to v2.21...
Just added another custom code parameter for a condition of if an action is added to the list or not
Could be useful if you only want to add actions to the "Scene_Battle" list
Example:
Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-check-for-which-actor-is-using-an-ability.151904/