- 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.
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.
