MZ How can I transfer Actor A’s equipment to Actor B?

I currently have Actor A and Actor B.
I want Actor B, when they appear in the game, to wear the same equipment that Actor A is wearing, meaning the equipment on Actor A should be transferred to Actor B, not duplicated into a second set.

I do not have any equipment enhancement or upgrade systems in my game.
If necessary, it is also acceptable to remove or destroy the equipment currently worn by Actor A and then equip Actor B with a set of equipment that has the same IDs.

How can I ensure that they are wearing equipment with the same equipment IDs, rather than two separate copies?
I am using the VisuStella plugin series, though I’m not sure whether that helps in this case.
If anyone knows how to achieve this, I would greatly appreciate the help!:LZSexcite:
run this as a script call, replace the value of x with actor B' actor id, and y with actor A's id:
Code:
var x = 1;
var y = 2;
for (var i = 0; i < $gameActors.actor(x).equips().length; i++){
    $gameActors.actor(x).forceChangeEquip(i, $gameActors.actor(y).equips()[i]);
    $gameActors.actor(y).forceChangeEquip(i, null);
}
I notice Robro ninja'd me, but my suggestion is a li'l different so...

For use in a Script command (untested):
JavaScript:
const actorA = $gameActors.actor(1);
const actorB = $gameActors.actor(2);
if (actorA && actorB) {
  const items = actorA.equips();
  const slotCount = actorA.equipSlots().length;
  for (let slotId = 0; n < slotCount; ++n) {
    const item = items[slotId];
    if (actorA.isEquipChangeOk(slotId)) {
      actorA.changeEquip(slotId, null);  // from A to inventory
      actorB.changeEquip(slotId, item);  // from inventory to B
    }
  }
}
In theory this would transfer equipment from actor ID 1 to actor ID 2; change those numbers as needed.

[Edit: removed && actorB.canEquip(item) after actorA.isEquipChangeOk(slotId). If B cannot equip it, the item will end up in inventory instead.]
run this as a script call, replace the value of x with actor B' actor id, and y with actor A's id:
Code:
var x = 1;
var y = 2;
for (var i = 0; i < $gameActors.actor(x).equips().length; i++){
    $gameActors.actor(x).forceChangeEquip(i, $gameActors.actor(y).equips()[i]);
    $gameActors.actor(y).forceChangeEquip(i, null);
}
It works!Thank you

I notice Robro ninja'd me, but my suggestion is a li'l different so...

For use in a Script command (untested):
JavaScript:
const actorA = $gameActors.actor(1);
const actorB = $gameActors.actor(2);
if (actorA && actorB) {
  const items = actorA.equips();
  const slotCount = actorA.equipSlots().length;
  for (let slotId = 0; n < slotCount; ++n) {
    const item = items[slotId];
    if (actorA.isEquipChangeOk(slotId)) {
      actorA.changeEquip(slotId, null);  // from A to inventory
      actorB.changeEquip(slotId, item);  // from inventory to B
    }
  }
}
In theory this would transfer equipment from actor ID 1 to actor ID 2; change those numbers as needed.

[Edit: removed && actorB.canEquip(item) after actorA.isEquipChangeOk(slotId). If B cannot equip it, the item will end up in inventory instead.]
I notice Robro ninja'd me, but my suggestion is a li'l different so...

For use in a Script command (untested):
JavaScript:
const actorA = $gameActors.actor(1);
const actorB = $gameActors.actor(2);
if (actorA && actorB) {
  const items = actorA.equips();
  const slotCount = actorA.equipSlots().length;
  for (let slotId = 0; n < slotCount; ++n) {
    const item = items[slotId];
    if (actorA.isEquipChangeOk(slotId)) {
      actorA.changeEquip(slotId, null);  // from A to inventory
      actorB.changeEquip(slotId, item);  // from inventory to B
    }
  }
}
In theory this would transfer equipment from actor ID 1 to actor ID 2; change those numbers as needed.

[Edit: removed && actorB.canEquip(item) after actorA.isEquipChangeOk(slotId). If B cannot equip it, the item will end up in inventory instead.]

I notice Robro ninja'd me, but my suggestion is a li'l different so...

For use in a Script command (untested):
JavaScript:
const actorA = $gameActors.actor(1);
const actorB = $gameActors.actor(2);
if (actorA && actorB) {
  const items = actorA.equips();
  const slotCount = actorA.equipSlots().length;
  for (let slotId = 0; n < slotCount; ++n) {
    const item = items[slotId];
    if (actorA.isEquipChangeOk(slotId)) {
      actorA.changeEquip(slotId, null);  // from A to inventory
      actorB.changeEquip(slotId, item);  // from inventory to B
    }
  }
}
In theory this would transfer equipment from actor ID 1 to actor ID 2; change those numbers as needed.

[Edit: removed && actorB.canEquip(item) after actorA.isEquipChangeOk(slotId). If B cannot equip it, the item will end up in inventory instead.]
Thank you! I also tried your code:LZSsmile:but I’m not sure why it didn’t work on my end.
That said, Robro’s solution works for me, so that’s enough for now.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-transfer-actor-as-equipment-to-actor-b.181914/