Hi all,
I'm building a plugin to help me create a different Battle System.
The easiest (or so I thought) way to do it was via a plugin that launchs every time a skill is used.
The plugin saves the Skill ID and the Target ID into two variable then it should launch a Common Event that takes care of all the skills and use.
Now the problem is that the only Common Event script call I found is ReserveCommonEvent that launch the CE at the first occasion... and that is after the battle.
I didn't found any command to launch the event straight away, is there any workaround?
If anyone wants to take a look to the code, here it is:
I'm building a plugin to help me create a different Battle System.
The easiest (or so I thought) way to do it was via a plugin that launchs every time a skill is used.
The plugin saves the Skill ID and the Target ID into two variable then it should launch a Common Event that takes care of all the skills and use.
Now the problem is that the only Common Event script call I found is ReserveCommonEvent that launch the CE at the first occasion... and that is after the battle.
I didn't found any command to launch the event straight away, is there any workaround?
If anyone wants to take a look to the code, here it is:
Code:
//=============================================================================
// Plugin Name: Combat Event Trigger
// Author: Winthorp Darkrites (Winter Dream Games Creator)
// Description: Triggers a Common Event during combat actions and sets variables.
// Use: Feel free to use for private and commercial projects. Feel free to edit. Please give credits.
//=============================================================================
/*:
* @target MZ
* @plugindesc Triggers a Common Event during combat actions and sets variables for Skill ID and Target ID.
* @author Winthorp Darkrites
*
* @help WD_CombatEventTrigger.js
*
* This plugin calls a Common Event on skill use.
*
* It does not provide plugin commands.
*/
(function() {
// Register a new Game_Action prototype method
Game_Action.prototype.executeAction = function(target) {
// Call the original executeAction method
this.executeActionOrig(target);
// Check if the action is performed in battle
if ($gameParty.inBattle()) {
// Trigger a Common Event ID when a combat action is executed
var commonEventId = 1; // Replace 1 with the Common Event ID you want to trigger if different
// Check if the Common Event ID is valid
if (commonEventId > 0) {
$gameTemp.reserveCommonEvent(commonEventId);
// Set a variable equal to the skill ID used
var skillIdVariable = 1; // Replace 1 with the Variable ID to store the skill ID if different
if (skillIdVariable > 0) {
$gameVariables.setValue(skillIdVariable, this.item().id);
}
// Set a variable equal to the target's actor or enemy ID
var targetIdVariable = 2; // Replace 2 with the Variable ID to store the target's ID if different
if (targetIdVariable > 0) {
$gameVariables.setValue(targetIdVariable, target.isActor() ? target.actorId() : target.enemyId());
}
}
}
};
})();