Switching Party member Attached to skill

coorocrow

Villager
Member
Joined
Jun 1, 2014
Messages
15
Reaction score
2
First Language
English
Primarily Uses
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top