Hi All,
Looking for a bit of help here!!
This is my first attempt making a plugin of any kind. I'm attempting to create a function in my battle system that runs on a combo gauge and real time response. The idea is inspired by Vivi/Steiner swrd magic combination from FFIX. Basically when the gauge is full a combo option pops up. Depending on the abilities selected and the order they're selected in you can retrieve different results, this includes failures if you're experimenting. You can think of it as perhaps an open crafting system where you can combine ingredients trying to get different/better results, except in battle with battle skills. Here's my, probably aweful, attempt at this plugin. I can't even get the gauge to appear haha.
Looking for a bit of help here!!
This is my first attempt making a plugin of any kind. I'm attempting to create a function in my battle system that runs on a combo gauge and real time response. The idea is inspired by Vivi/Steiner swrd magic combination from FFIX. Basically when the gauge is full a combo option pops up. Depending on the abilities selected and the order they're selected in you can retrieve different results, this includes failures if you're experimenting. You can think of it as perhaps an open crafting system where you can combine ingredients trying to get different/better results, except in battle with battle skills. Here's my, probably aweful, attempt at this plugin. I can't even get the gauge to appear haha.
JavaScript:
//=============================================================================
// MyComboGauge.js
//=============================================================================
/*:
* @plugindesc Adds a combo gauge for the MyComboAttacks plugin.
* @author Nhobson
*
* @param Gauge Image
* @desc The filename of the image to use for the gauge.
* @default ComboGauge
* @require 1
* @dir img/pictures/
* @type file
*
* @param Gauge Width
* @desc The width of the gauge in pixels.
* @default 200
* @type number
*
* @param Gauge Height
* @desc The height of the gauge in pixels.
* @default 20
* @type number
*
* @param X Position
* @desc The X position of the gauge on the screen.
* @default 10
* @type number
*
* @param Y Position
* @desc The Y position of the gauge on the screen.
* @default 10
* @type number
*
* @help
* This plugin adds a combo gauge for the MyComboAttacks plugin.
*/
(function() {
var parameters = PluginManager.parameters('MyComboGauge');
var gaugeImage = parameters['Gauge Image'];
var gaugeWidth = parseInt(parameters['Gauge Width']);
var gaugeHeight = parseInt(parameters['Gauge Height']);
var gaugeX = parseInt(parameters['X Position']);
var gaugeY = parseInt(parameters['Y Position']);
// Create the combo gauge sprite
function ComboGauge() {
this.initialize.apply(this, arguments);
}
ComboGauge.prototype = Object.create(Sprite.prototype);
ComboGauge.prototype.constructor = ComboGauge;
ComboGauge.prototype.initialize = function() {
Sprite.prototype.initialize.call(this);
this.bitmap = ImageManager.loadPicture(gaugeImage);
this._currentValue = 0;
this._maxValue = 100;
this._fillColor = '#ff0000';
this._backgroundColor = '#ffffff';
this._drawWidth = gaugeWidth;
this._drawHeight = gaugeHeight;
this._frameWidth = this.bitmap.width;
this._frameHeight = this.bitmap.height;
this.anchor.x = 0.5;
this.anchor.y = 0.5;
this.x = gaugeX;
this.y = gaugeY;
};
ComboGauge.prototype.update = function() {
Sprite.prototype.update.call(this);
var comboCount = $gameParty._comboCount;
if (comboCount) {
this._currentValue = comboCount;
} else {
this._currentValue = 0;
}
this.drawGauge();
};
ComboGauge.prototype.drawGauge = function() {
var gaugeWidth = Math.floor(this._currentValue / this._maxValue * this._drawWidth);
var context = this.bitmap.context;
context.save();
context.clearRect(0, 0, this._frameWidth, this._frameHeight);
context.fillStyle = this._backgroundColor;
context.fillRect(0, 0, this._drawWidth, this._drawHeight);
context.fillStyle = this._fillColor;
context.fillRect(0, 0, gaugeWidth, this._drawHeight);
context.restore();
};
// Add the combo gauge to the game screen
var _Scene_Battle_createSpriteset = Scene_Battle.prototype.createSpriteset;
Scene_Battle.prototype.createSpriteset = function() {
_Scene_Battle_createSpriteset.call(this);
this._comboGauge = new ComboG
// Register the ComboGauge object with the game
function ComboGauge() {
this.initialize.apply(this, arguments);
}
ComboGauge.prototype = Object.create(Window_Base.prototype);
ComboGauge.prototype.constructor = ComboGauge;
ComboGauge.prototype.initialize = function(x, y) {
var width = this.windowWidth();
var height = this.windowHeight();
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._comboCount = 0;
this.refresh();
};
ComboGauge.prototype.windowWidth = function() {
return 240;
};
ComboGauge.prototype.windowHeight = function() {
return this.fittingHeight(1);
};
ComboGauge.prototype.refresh = function() {
this.contents.clear();
var x = this.textPadding();
var y = 0;
var text = "Combo: " + this._comboCount;
this.drawText(text, x, y, this.contentsWidth(), "center");
};
ComboGauge.prototype.setComboCount = function(comboCount) {
this._comboCount = comboCount;
this.refresh();
};
// Add a method to Game_Battler to increase the combo count
Game_Battler.prototype.increaseComboCount = function() {
if (!this._comboCount) {
this._comboCount = 0;
}
this._comboCount += 1;
};
// Add a method to Game_Battler to reset the combo count
Game_Battler.prototype.resetComboCount = function() {
this._comboCount = 0;
};
// Add a method to Scene_Battle to create and update the Combo Gauge
Scene_Battle.prototype.createComboGauge = function() {
this._comboGauge = new ComboGauge(Graphics.width - 240, 0);
this.addWindow(this._comboGauge);
};
Scene_Battle.prototype.updateComboGauge = function() {
if (this._comboGauge) {
var comboCount = $gameParty.members()[0]._comboCount;
this._comboGauge.setComboCount(comboCount);
}
};
// Add a hook to Scene_Battle to create the Combo Gauge window
var _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function() {
_Scene_Battle_createAllWindows.call(this);
this.createComboGauge();
};
// Add a hook to Scene_Battle to update the Combo Gauge window
var _Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
_Scene_Battle_update.call(this);
this.updateComboGauge();
};
JavaScript:
// MyComboAttacks.js
/*:
* @plugindesc A plugin that adds combo attacks to battles.
* @author Nhobson
* Last update: 3/8/2023
*
* @param comboDuration
* @text Combo Duration
* @desc The time (in frames) after a successful combo hit that allows for additional hits in the combo.
* @type number
* @default 60
*
* @param comboInput
* @text Combo Input
* @desc The input required to activate the combo attack.
* @type combo
* @option Input.up
* @option Input.down
* @option Input.left
* @option Input.right
*
* @help
* To use this plugin, simply install it and set the desired parameters.
* You can then create combo attacks by setting the 'combo' notetag on skills.
*/
(function () {
const parameters = PluginManager.parameters('MyComboAttacks');
const comboDuration = Number(parameters['comboDuration'] || 60);
const comboInput = parameters['comboInput'] || 'Input.right';
const _Game_Battler_performDamage = Game_Battler.prototype.performDamage;
Game_Battler.prototype.performDamage = function () {
_Game_Battler_performDamage.call(this);
this._comboHits = 0;
};
const _Scene_Battle_createAllWindows = Scene_Battle.prototype.createAllWindows;
Scene_Battle.prototype.createAllWindows = function () {
_Scene_Battle_createAllWindows.call(this);
this.createComboWindow();
};
Scene_Battle.prototype.createComboWindow = function () {
this._comboWindow = new Window_Combo();
this.addWindow(this._comboWindow);
};
const _Game_Action_apply = Game_Action.prototype.apply;
Game_Action.prototype.apply = function (target) {
_Game_Action_apply.call(this, target);
if (this.subject().isActor() && target.isEnemy() && target.result().isHit()) {
const skill = this.item();
if (skill.meta.combo) {
this.subject()._comboHits++;
const comboHits = this.subject()._comboHits;
const comboHitsNeeded = Number(skill.meta.combo);
if (comboHits >= comboHitsNeeded) {
this.subject()._comboHits = 0;
this.executeComboAttack(skill, comboHitsNeeded);
}
}
}
};
Game_Action.prototype.executeComboAttack = function (skill, comboHits) {
const action = new Game_Action(this.subject());
action.setSkill(skill.id);
for (let i = 0; i < comboHits - 1; i++) {
const lastTarget = BattleManager._targets[0];
action.apply(lastTarget);
if (lastTarget.result().isHit()) {
this.subject()._comboHits++;
} else {
break;
}
}
BattleManager.startAction(this.subject(), action, BattleManager._targets);
};
function Window_Combo() {
this.initialize.apply(this, arguments);
}
Window_Combo.prototype = Object.create(Window_Base.prototype);
Window_Combo.prototype.constructor = Window_Combo;
Window_Combo.prototype.initialize = function () {
const x = Graphics.boxWidth / 2 - this.windowWidth() / 2;
const y = Graphics.boxHeight / 2 - this.windowHeight() / 2;
Window_Base.prototype.initialize.call(this, x, y, this.windowWidth(), this.windowHeight());
this.opacity = 0;
this.contentsOpacity = 0;
this._comboCount = 0;
this._comboDuration = comboDuration;
MyComboAttacks.prototype.updateComboGauge = function() {
var gauge = $gameParty._comboGauge;
var maxCombo = this._parameters.maxCombo;
var comboSteps = this._parameters.comboSteps;
var comboStepsValues = this._parameters.comboStepsValues;
if (gauge < maxCombo) {
for (var i = 0; i < comboSteps.length; i++) {
if (gauge >= comboSteps[i]) {
if (!$gameSwitches.value(comboStepsValues[i])) {
$gameSwitches.setValue(comboStepsValues[i], true);
this.showComboStepMessage(comboStepsValues[i]);
}
}
}
}
this._comboGaugeWindow.refresh();
};
MyComboAttacks.prototype.showComboStepMessage = function(switchId) {
var message = this._parameters.comboStepMessages[switchId];
$gameMessage.add(message);
};
MyComboAttacks.prototype.resetComboSwitches = function() {
var comboStepsValues = this._parameters.comboStepsValues;
for (var i = 0; i < comboStepsValues.length; i++) {
$gameSwitches.setValue(comboStepsValues[i], false);
}
};
MyComboAttacks.prototype.resetComboGauge = function() {
$gameParty._comboGauge = 0;
this.resetComboSwitches();
this.updateComboGauge();
};
})();