RPG Maker Forums

So I'm currently working on a plugin that attempts to use a skill to swap two specific characters back and forth.


My intention is to have to characters with skills that when used will have one character attack, swap places, and then the second character attack. This will leave the second character behind for the next turn, or to take the damage from enemy attacks.


I first want to be able to make a skill that can just swap the two characters. At the moment I have an event occuring at the start of the turn. 


Twins.Swap.BattleManager_startBattle = BattleManager.startBattle;
BattleManager.startBattle = function(result) {
Twins.Swap.BattleManager_startBattle.call(this, result);
this.catchStartingTwin();
};

BattleManager.catchStartingTwin = function() {
console.log("did this go through");
var group = $gameParty.allMembers();
var length = group.length;
for (var i = 0; i < length; ++i) {
var member = group.actorId();
if (member == 1 || member == 2){
Twins.Param.startingTwin = member;
}
}
console.log(Twins.Param.startingTwin);
};


That will log which ever character of the specific two was the first to start the fight, and I have an event that goes off at the end of the battle that putts the starting twin back in his original spot so they can start the next fight.


Twins.Swap.BattleManager_endBattle = BattleManager.endBattle;
BattleManager.endBattle = function(result) {
Twins.Swap.BattleManager_endBattle.call(this, result);
this.returnStartingTwin();
};

BattleManager.returnStartingTwin = function() {
console.log("did this go through");
var group = $gameParty.allMembers();
var length = group.length;
for (var i = 0; i < length; ++i) {
var member = group.actorId();
if (member == 1 || member == 2){
if (member != Twins.Param.startingTwin){
var index1 = $gameParty.members().indexOf($gameActors.actor(Twins.Param.startingTwin));
var index2 = i;
$gameParty.swapOrder(index1,index2);
}
}
}
console.log(Twins.Param.startingTwin);
};


My next concern is getting the Switch skill to work. I was looking at Yanfly's Actor Party Switch to figure out where to go next. But since they draw a screen and use a Battle menu command I can't understand where I can check to see what skill was used and where I can set the swap. I tried doing it with onSkillOk but it didn't seem to work.


Twins.Swap.Scene_Battle_onSkillOk = Scene_Battle.prototype.onSkillOk;
Scene_Battle.prototype.onSkillOk = function() {
var skill = this._skillWindow.item();
var action = BattleManager.inputtingAction();
action.setSkill(skill.id);
BattleManager.actor().setLastBattleSkill(skill);
this.onSelectAction();
this.executeSwap.bind(this, skill.id);
};

Scene_Battle.prototype.executeSwap = function(skillId){
console.log("did this even execute?");
if(skillId == Twins.Param.switchSkill){
var group = $gameParty.allMembers();
var length = group.length;
for (var i = 0; i < length; ++i) {
var member = group.actorId();
if (member == Twins.Param.twin1){
var index1 = $gameParty.members().indexOf($gameActors.actor(Twins.Param.twin2));
var index2 = i;
$gameParty.swapOrder(index1,index2);
break;
}
}
}

};


I don't know if i'm even going in the right direction so any help that can be given would be great.

Latest Threads

Latest Posts

Latest Profile Posts

He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!

Forum statistics

Threads
106,036
Messages
1,018,461
Members
137,821
Latest member
Capterson
Top