forked from phenom/healer-man
Release Healer Man 0.1.41
This commit is contained in:
1 parent
197a64117c
commit
c3f8a69b51
42 files changed
+886
-127
No files matched your search
+30
-16
@@ -56,6 +56,7 @@ import {
|
||||
import { normalizeActorResourcePool } from "./combatActors";
|
||||
import { advanceCombatResourcePool } from "./combatResources";
|
||||
import { channelAmountEffects } from "./combatChannelAmounts";
|
||||
import { healingAbilityCanAidOthers, healingAbilityHasPendingHot, healingRecipientIds } from "./healingAbilityRules";
|
||||
import {
|
||||
combatHasLineOfSight,
|
||||
combatSpatialActor,
|
||||
@@ -884,17 +885,22 @@ function choosePartySupportIntent(
|
||||
|| (right.maxHealth - right.health) - (left.maxHealth - left.health)
|
||||
|| left.id.localeCompare(right.id)
|
||||
));
|
||||
const target = injured[0];
|
||||
if (!target) return null;
|
||||
const ability = choosePartyAbility(member, {
|
||||
now,
|
||||
target: null,
|
||||
injuredAllies: injured.length,
|
||||
lowestHealthFraction: target.health / Math.max(1, target.maxHealth),
|
||||
});
|
||||
return ability?.effects.some((effect) => ["heal", "hot", "shield"].includes(effect.kind))
|
||||
? { ability, targetId: target.id }
|
||||
: null;
|
||||
for (const target of injured) {
|
||||
const ability = choosePartyAbility(member, {
|
||||
now,
|
||||
target: null,
|
||||
injuredAllies: injured.length,
|
||||
lowestHealthFraction: target.health / Math.max(1, target.maxHealth),
|
||||
canUseAbility: ability => ability.effects.some(effect => ["heal", "hot", "shield"].includes(effect.kind))
|
||||
&& (healingAbilityCanAidOthers(ability) || target.id === member.id)
|
||||
&& !(healingAbilityHasPendingHot(ability, member.id, target.id, combat.effects)
|
||||
&& (!ability.effects.some(effect => effect.kind === "heal") || target.health / target.maxHealth > 0.5))
|
||||
&& partyAbilityTargetIsValid(member, ability, ability.target === "self" ? member.id : target.id)
|
||||
&& !(ability.effects.some(effect => effect.kind === "shield") && (combat.actors[target.id]?.absorb ?? 0) > 0),
|
||||
});
|
||||
if (ability) return { ability, targetId: ability.target === "self" ? member.id : target.id };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function executePartyAbility(
|
||||
@@ -933,17 +939,23 @@ function executePartyAbility(
|
||||
if (effect.kind === "dot") {
|
||||
if (!groundAreaCreated) combat.applyTimedActorEffect(member.id, hostileTargetId, ability, effect, now);
|
||||
} else {
|
||||
effectiveAmount += combat.damageMob(
|
||||
const result = combat.damageMob(
|
||||
hostileTargetId,
|
||||
partyAbilityAmount(runtimeMember, ability, effect),
|
||||
now,
|
||||
{ actorId: member.id, role: member.role, abilityId: ability.id },
|
||||
spellSchool,
|
||||
).amount;
|
||||
);
|
||||
effectiveAmount += result.amount;
|
||||
if (effect.kind === "damage" && effect.onDamageResource && result.amount > 0) {
|
||||
combat.restoreActorResource(member.id, effect.onDamageResource.resource, effect.onDamageResource.amount,
|
||||
false, member.id, ability.id, now);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (effect.kind === "heal") {
|
||||
for (const friendlyTargetId of friendlyTargets) {
|
||||
for (const friendlyTargetId of healingRecipientIds(effect, member.id, targetId, combat.actors,
|
||||
id => partyFriendlyPosition(id) ?? getMobPosition(id), friendlyTargets, combatHasLineOfSight, now)) {
|
||||
const actor = useCombatStore.getState().actors[friendlyTargetId];
|
||||
if (!actor?.alive) continue;
|
||||
const requested = partyAbilityAmount(runtimeMember, ability, effect)
|
||||
@@ -959,11 +971,13 @@ function executePartyAbility(
|
||||
effectiveAmount += result.effectiveAmount;
|
||||
}
|
||||
} else if (effect.kind === "hot") {
|
||||
if (!groundAreaCreated) for (const friendlyTargetId of friendlyTargets) {
|
||||
if (!groundAreaCreated) for (const friendlyTargetId of healingRecipientIds(effect, member.id, targetId, combat.actors,
|
||||
id => partyFriendlyPosition(id) ?? getMobPosition(id), friendlyTargets, combatHasLineOfSight, now)) {
|
||||
useCombatStore.getState().applyTimedActorEffect(member.id, friendlyTargetId, ability, effect, now);
|
||||
}
|
||||
} else if (effect.kind === "shield") {
|
||||
for (const friendlyTargetId of friendlyTargets) {
|
||||
for (const friendlyTargetId of healingRecipientIds(effect, member.id, targetId, combat.actors,
|
||||
id => partyFriendlyPosition(id) ?? getMobPosition(id), friendlyTargets, combatHasLineOfSight, now)) {
|
||||
effectiveAmount += useCombatStore.getState().shieldActor(
|
||||
friendlyTargetId,
|
||||
partyAbilityAmount(runtimeMember, ability, effect),
|
||||
|
||||
Reference in new issue
Block a user