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
+18
-12
@@ -10,6 +10,8 @@ import { aiHintsForAbility, runeCostForAbility } from "./abilityRules";
|
||||
import { spendDeathKnightRunes } from "./combatResources";
|
||||
import { equipmentAdjustedCombatAmount, type MobCombatState } from "./combatStore";
|
||||
import type { PartyMember } from "./partyStore";
|
||||
import { baseResourcesFor } from "./wotlkStats";
|
||||
import { companionResourceMaximum } from "./combatActorAuthority";
|
||||
|
||||
export interface PartyAbilityContext {
|
||||
readonly now: number;
|
||||
@@ -27,10 +29,12 @@ function currentResource(member: PartyMember, type: ResourceType): number {
|
||||
return member.resourcePools[type] ?? (type === member.resourceType ? member.resource : 0);
|
||||
}
|
||||
|
||||
function abilityCosts(ability: AbilityDefinition): readonly { resource: ResourceType; amount: number }[] {
|
||||
function abilityCosts(member: PartyMember, ability: AbilityDefinition): readonly { resource: ResourceType; amount: number }[] {
|
||||
return (ability.costs?.length ? ability.costs : [ability.cost]).map((cost) => ({
|
||||
resource: cost.resource,
|
||||
amount: cost.percentage ? cost.amount / 100 : cost.amount,
|
||||
amount: cost.percentage ? cost.amount / 100 * (cost.percentageBasis === "base-mana"
|
||||
? baseResourcesFor(member.classId, member.level).mana
|
||||
: cost.resource === "health" ? member.maxHealth : companionResourceMaximum(member, cost.resource)) : cost.amount,
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -40,12 +44,8 @@ export function partyAbilityIsReady(member: PartyMember, ability: AbilityDefinit
|
||||
if (member.globalCooldownEndsAt > now || (member.cooldowns[ability.id] ?? 0) > now) return false;
|
||||
if ((member.schoolLockedUntil[ability.castRules?.school ?? "physical"] ?? 0) > now) return false;
|
||||
if (aiHintsForAbility(ability).categories.includes("taunt") && member.tauntReadyAt > now) return false;
|
||||
if (abilityCosts(ability).some((cost) => {
|
||||
const amount = cost.amount <= 1 && ability.cost.percentage
|
||||
? (cost.resource === member.resourceType ? member.maxResource : 100) * cost.amount
|
||||
: cost.amount;
|
||||
return currentResource(member, cost.resource) < amount;
|
||||
})) return false;
|
||||
if (abilityCosts(member, ability).some(cost => cost.resource === "health"
|
||||
? member.health <= cost.amount : currentResource(member, cost.resource) < cost.amount)) return false;
|
||||
const runeCost = member.classId === "death-knight" ? runeCostForAbility(ability) : null;
|
||||
return !runeCost || spendDeathKnightRunes(member.runes, runeCost, now) !== null;
|
||||
}
|
||||
@@ -78,7 +78,11 @@ function scoreAbility(member: PartyMember, ability: AbilityDefinition, context:
|
||||
if ((context.lowestHealthFraction ?? 1) < 0.3 && categories.has("emergency-heal")) score += 950;
|
||||
if ((context.injuredAllies ?? 0) >= 3 && categories.has("area-heal")) score += 850;
|
||||
if ((context.lowestHealthFraction ?? 1) < 0.9 && categories.has("heal")) score += 600;
|
||||
if (categories.has("mitigation")) score += 350;
|
||||
if (categories.has("mitigation") && ((context.lowestHealthFraction ?? 1) < 0.8 || member.health / member.maxHealth < 0.8)) score += 350;
|
||||
if ((context.lowestHealthFraction ?? 1) < 0.9 && categories.has("heal")) {
|
||||
score += Math.min(150, ability.effects.reduce((total, effect) => total + (effect.kind === "heal" || effect.kind === "hot"
|
||||
? partyAbilityAmount(member, ability, effect) * (effect.kind === "hot" ? Math.min(3, effect.ticks) : 1) : 0), 0) / member.maxHealth * 100);
|
||||
}
|
||||
if (context.target?.activeCast && categories.has("interrupt")) score += 250;
|
||||
if (categories.has("damage")) score += 80;
|
||||
} else {
|
||||
@@ -114,9 +118,10 @@ export function commitPartyAbilityUse(
|
||||
const resourcePools = { ...member.resourcePools };
|
||||
const lastResourceSpentAt = { ...member.lastResourceSpentAt };
|
||||
let resource = member.resource;
|
||||
for (const cost of abilityCosts(ability)) {
|
||||
const maximum = cost.resource === member.resourceType ? member.maxResource : 100;
|
||||
const amount = cost.amount <= 1 && ability.cost.percentage ? maximum * cost.amount : cost.amount;
|
||||
let health = member.health;
|
||||
for (const cost of abilityCosts(member, ability)) {
|
||||
const amount = cost.amount;
|
||||
if (cost.resource === "health") { health -= amount; continue; }
|
||||
const current = currentResource(member, cost.resource);
|
||||
resourcePools[cost.resource] = Math.max(0, current - amount);
|
||||
if (amount > 0) lastResourceSpentAt[cost.resource] = now;
|
||||
@@ -127,6 +132,7 @@ export function commitPartyAbilityUse(
|
||||
if (!runes) return null;
|
||||
return {
|
||||
...member,
|
||||
health,
|
||||
resource,
|
||||
resourcePools,
|
||||
lastResourceSpentAt,
|
||||
|
||||
Reference in new issue
Block a user