I've been trying to code damage/healing items but when actor 1 eats the item it damages actor 2 and I'm not sure if my coding is bad.
const healingPercentage = 10; // Healing percentage (adjust as needed)
const damagePercentage = 30; // Damage percentage (adjust as needed)
$gameParty.members().forEach(actor => {
const actorID = actor.actorId();
let healingAmount = 0;
let damageAmount = 0;
if (actorID === 1) {
// Calculate healing amount for Actor 1
const maxHp = actor.mhp;
healingAmount = Math.floor((maxHp * healingPercentage) / 100);
actor.gainHp(healingAmount); // Apply healing to Actor 1
return;
} else if (actorID === 3) {
// Calculate healing amount for Actor 3
const maxHp = actor.mhp;
healingAmount = Math.floor((maxHp * healingPercentage) / 100);
actor.gainHp(healingAmount); // Apply healing to Actor 3
return;
} else if (actorID === 2) {
// Calculate damage amount for Actor 2
const maxHp = actor.mhp;
damageAmount = Math.floor((maxHp * damagePercentage) / 100);
actor.gainHp(-damageAmount); // Apply damage to Actor 2
return;
} else if (actorID === 4) {
// Calculate damage amount for Actor 4
const maxHp = actor.mhp;
damageAmount = Math.floor((maxHp * damagePercentage) / 100);
actor.gainHp(-damageAmount); // Apply damage to Actor 4
return;
}
});
const healingPercentage = 10; // Healing percentage (adjust as needed)
const damagePercentage = 30; // Damage percentage (adjust as needed)
$gameParty.members().forEach(actor => {
const actorID = actor.actorId();
let healingAmount = 0;
let damageAmount = 0;
if (actorID === 1) {
// Calculate healing amount for Actor 1
const maxHp = actor.mhp;
healingAmount = Math.floor((maxHp * healingPercentage) / 100);
actor.gainHp(healingAmount); // Apply healing to Actor 1
return;
} else if (actorID === 3) {
// Calculate healing amount for Actor 3
const maxHp = actor.mhp;
healingAmount = Math.floor((maxHp * healingPercentage) / 100);
actor.gainHp(healingAmount); // Apply healing to Actor 3
return;
} else if (actorID === 2) {
// Calculate damage amount for Actor 2
const maxHp = actor.mhp;
damageAmount = Math.floor((maxHp * damagePercentage) / 100);
actor.gainHp(-damageAmount); // Apply damage to Actor 2
return;
} else if (actorID === 4) {
// Calculate damage amount for Actor 4
const maxHp = actor.mhp;
damageAmount = Math.floor((maxHp * damagePercentage) / 100);
actor.gainHp(-damageAmount); // Apply damage to Actor 4
return;
}
});