Release Healer Man 0.1.38
This commit is contained in:
1 parent
361734bc41
commit
b417b7c3c3
48 files changed
+1982
-90
No files matched your search
+114
-15
@@ -28,6 +28,7 @@ import {
|
||||
updatePartyRuntimePosition,
|
||||
} from "./partyRuntimeRegistry";
|
||||
import { usePartyStore, type PartyCommand, type PartyMember } from "./partyStore";
|
||||
import { baseClassFor, classById } from "../app/characterCatalog";
|
||||
import { useGameStore } from "./store";
|
||||
import { useManastormStore } from "./manastormStore";
|
||||
import { activeDungeonCompletedObjectiveIds } from "./dungeonEncounterRuntime";
|
||||
@@ -54,6 +55,7 @@ import {
|
||||
} from "./partyAbilityAi";
|
||||
import { normalizeActorResourcePool } from "./combatActors";
|
||||
import { advanceCombatResourcePool } from "./combatResources";
|
||||
import { channelAmountEffects } from "./combatChannelAmounts";
|
||||
import {
|
||||
combatHasLineOfSight,
|
||||
combatSpatialActor,
|
||||
@@ -69,6 +71,7 @@ const TANK_TAUNT_COOLDOWN_MS = 8_000;
|
||||
const TANK_TAUNT_DURATION_MS = 3_000;
|
||||
let lastAdvanceAt = 0;
|
||||
let nextRegenAt = 0;
|
||||
const nextWeaponAttackAt = new Map<string, number>();
|
||||
|
||||
export interface PartyPresentationIdentity {
|
||||
readonly spellId: number;
|
||||
@@ -141,6 +144,7 @@ export function activePartyBossObjectives(): readonly PartyBossObjective[] {
|
||||
export function resetPartyRuntimeClock(): void {
|
||||
lastAdvanceAt = 0;
|
||||
nextRegenAt = 0;
|
||||
nextWeaponAttackAt.clear();
|
||||
}
|
||||
|
||||
export function activePartyTargetId(
|
||||
@@ -167,7 +171,7 @@ export function partyAttackDamage(
|
||||
specialization: member.specialization ?? "",
|
||||
role: member.role,
|
||||
})
|
||||
? classId === "hunter" ? "ranged" : "spell"
|
||||
? baseClassFor(classId) === "hunter" ? "ranged" : "spell"
|
||||
: "melee";
|
||||
const weapon = kind === "ranged" ? gear.rangedWeapon : kind === "melee" ? gear.meleeWeapon : null;
|
||||
const equipmentPower = kind === "spell"
|
||||
@@ -193,15 +197,30 @@ export function partyAttackDamage(
|
||||
}
|
||||
|
||||
export function partyUsesRangedAttacks(
|
||||
member: Pick<PartyMember, "classId" | "specialization" | "role">,
|
||||
member: Pick<PartyMember, "classId" | "specialization" | "role"> & Partial<Pick<PartyMember, "level" | "talentRanks">>,
|
||||
): boolean {
|
||||
if (member.role === "tank") return false;
|
||||
if (member.role === "healer") return true;
|
||||
const definition = classById(member.classId);
|
||||
if (definition.mode !== "classic") {
|
||||
return (baseClassFor(member.classId) === "hunter"
|
||||
|| ["intellect", "wisdom", "spirit"].includes(definition.primaryStat))
|
||||
&& partyCatalogAttackRange(member) > 5;
|
||||
}
|
||||
return ["hunter", "mage", "priest", "warlock"].includes(member.classId)
|
||||
|| member.specialization === "Elemental"
|
||||
|| member.specialization === "Balance";
|
||||
}
|
||||
|
||||
function partyCatalogAttackRange(member: Pick<PartyMember, "classId"> & Partial<Pick<PartyMember, "level" | "talentRanks">>): number {
|
||||
return Math.max(0, ...abilitiesForClass(member.classId)
|
||||
.filter((ability) => !ability.passive && ability.unlockLevel <= (member.level ?? 80)
|
||||
&& (ability.talentEntryId === undefined || (member.talentRanks?.[`coa-entry-${ability.talentEntryId}`] ?? 0) > 0))
|
||||
.map((ability) => abilityAtLevel(ability, member.level ?? 80))
|
||||
.filter((ability) => ability.effects.some((effect) => ["damage", "dot", "finisher-damage", "execute"].includes(effect.kind)))
|
||||
.map((ability) => ability.range.max));
|
||||
}
|
||||
|
||||
export function partyAttackRange(member: Pick<PartyMember, "classId" | "specialization" | "role">): number {
|
||||
if (member.role === "tank") return 3.8;
|
||||
if (partyUsesRangedAttacks(member)) return 19;
|
||||
@@ -236,9 +255,18 @@ const MELEE_DAMAGE_COMBAT_RANGE_BAND: PartyCombatRangeBand = Object.freeze({
|
||||
* target instead of treating the tank's position as their own.
|
||||
*/
|
||||
export function partyCombatRangeBand(
|
||||
member: Pick<PartyMember, "classId" | "specialization" | "role">,
|
||||
member: Pick<PartyMember, "classId" | "specialization" | "role"> & Partial<Pick<PartyMember, "level" | "talentRanks">>,
|
||||
): PartyCombatRangeBand {
|
||||
if (partyUsesRangedAttacks(member)) return RANGED_COMBAT_RANGE_BAND;
|
||||
if (partyUsesRangedAttacks(member)) {
|
||||
if (classById(member.classId).mode !== "classic") {
|
||||
const attackRange = partyCatalogAttackRange(member);
|
||||
if (attackRange <= 5) return RANGED_COMBAT_RANGE_BAND;
|
||||
const maximum = Math.min(RANGED_COMBAT_RANGE_BAND.maximum, attackRange - 0.1);
|
||||
const preferred = Math.min(RANGED_COMBAT_RANGE_BAND.preferred, maximum - 0.5);
|
||||
return { minimum: Math.min(RANGED_COMBAT_RANGE_BAND.minimum, preferred - 0.5), preferred, maximum };
|
||||
}
|
||||
return RANGED_COMBAT_RANGE_BAND;
|
||||
}
|
||||
return member.role === "tank" ? TANK_COMBAT_RANGE_BAND : MELEE_DAMAGE_COMBAT_RANGE_BAND;
|
||||
}
|
||||
|
||||
@@ -599,7 +627,7 @@ function memberSwingMs(member: PartyMember): number {
|
||||
ratingPercent(
|
||||
member.gearStats.hasteRating,
|
||||
partyUsesRangedAttacks(member)
|
||||
? member.classId === "hunter" ? "rangedHaste" : "spellHaste"
|
||||
? baseClassFor(member.classId) === "hunter" ? "rangedHaste" : "spellHaste"
|
||||
: "meleeHaste",
|
||||
member.level,
|
||||
member.classId,
|
||||
@@ -639,6 +667,33 @@ function emitPartyAbility(
|
||||
});
|
||||
}
|
||||
|
||||
/** Weapon swings continue during the GCD and supply Rage for paid attacks. */
|
||||
function advancePartyWeaponAttack(member: PartyMember, targetId: string, now: number): PartyMember {
|
||||
if (partyUsesRangedAttacks(member) && baseClassFor(member.classId) !== "hunter") return member;
|
||||
const origin = getPartyRuntimePosition(member.id) ?? useCombatStore.getState().playerPosition;
|
||||
const targetPosition = getMobPosition(targetId);
|
||||
const spatial = combatSpatialActor(member.id);
|
||||
if (!targetPosition || !partyRuntimeTargetVisible(member.id, targetId)
|
||||
|| distanceSquared(origin, targetPosition) > partyAttackRange(member) ** 2
|
||||
|| Math.abs(origin[1] - targetPosition[1]) > 8
|
||||
|| !combatHasLineOfSight(origin, targetPosition)
|
||||
|| (spatial && !isPositionInFacingArc(spatial, targetPosition, Math.PI))
|
||||
|| now < (nextWeaponAttackAt.get(member.id) ?? 0)) return member;
|
||||
nextWeaponAttackAt.set(member.id, now + memberSwingMs(member));
|
||||
const abilityId = "party-auto-attack";
|
||||
const result = useCombatStore.getState().damageMob(targetId, partyAttackDamage(member), now,
|
||||
{ actorId: member.id, role: member.role, abilityId }, "physical");
|
||||
const identity = partyAttackPresentation(member);
|
||||
for (const phase of ["release", "impact"] as const) {
|
||||
emitCombatPresentation({ occurredAt: now, phase, actorGroup: "party", sourceActorId: member.id,
|
||||
targetActorId: targetId, abilityId, name: "Auto Attack", source: "fallback", school: "physical",
|
||||
delivery: baseClassFor(member.classId) === "hunter" ? "projectile" : identity.delivery, origin, targetPosition, instantCast: true });
|
||||
}
|
||||
if (member.resourceType !== "rage" || result.amount <= 0) return member;
|
||||
const resource = Math.min(member.maxResource, member.resource + 6);
|
||||
return { ...member, resource, resourcePools: { ...member.resourcePools, rage: resource } };
|
||||
}
|
||||
|
||||
function partyFriendlyPosition(actorId: string): MobVector3 | null {
|
||||
if (actorId === PLAYER_AGGRO_ID) return useCombatStore.getState().playerPosition;
|
||||
return getPartyRuntimePosition(actorId);
|
||||
@@ -661,8 +716,11 @@ function partyAbilityTargetIsValid(
|
||||
if (!hostile && (!targetActor?.alive || targetActor.health <= 0)
|
||||
&& !ability.effects.some((effect) => effect.kind === "resurrection")) return false;
|
||||
const distance = Math.sqrt(distanceSquared(origin, targetPosition));
|
||||
if (distance < ability.range.min || distance > ability.range.max || Math.abs(origin[1] - targetPosition[1]) > 8) return false;
|
||||
const targeting = targetingRulesForAbility(ability);
|
||||
const maximumRange = hostile && ability.target === "self"
|
||||
? targeting.radius ?? ability.radius ?? ability.range.max
|
||||
: ability.range.max;
|
||||
if (distance < ability.range.min || distance > maximumRange || Math.abs(origin[1] - targetPosition[1]) > 8) return false;
|
||||
if (targeting.requiresLineOfSight && !combatHasLineOfSight(origin, targetPosition)) return false;
|
||||
if (hostile && targeting.requiresFacing) {
|
||||
const sourceSpatial = combatSpatialActor(member.id);
|
||||
@@ -706,7 +764,7 @@ function partyHostileTargets(
|
||||
.filter((mob) => {
|
||||
const position = getMobPosition(mob.id);
|
||||
return !mob.dead && Boolean(position
|
||||
&& distanceSquared(origin, position) <= ability.range.max ** 2
|
||||
&& distanceSquared(origin, position) <= (targeting.radius ?? ability.radius ?? ability.range.max) ** 2
|
||||
&& combatHasLineOfSight(origin, position)
|
||||
&& (!memberSpatial || isPositionInFacingArc(memberSpatial, position, targeting.attackArcRadians ?? Math.PI / 2)));
|
||||
})
|
||||
@@ -715,12 +773,13 @@ function partyHostileTargets(
|
||||
}
|
||||
if (targeting.shape === "circle" || targeting.shape === "ground" || ability.radius !== undefined) {
|
||||
const radius = targeting.radius ?? ability.radius ?? 0;
|
||||
const center = ability.target === "self" ? origin : primaryPosition;
|
||||
return Object.values(combat.mobs)
|
||||
.filter((mob) => {
|
||||
const position = getMobPosition(mob.id);
|
||||
return !mob.dead && Boolean(position
|
||||
&& distanceSquared(primaryPosition, position) <= radius * radius
|
||||
&& combatHasLineOfSight(primaryPosition, position));
|
||||
&& distanceSquared(center, position) <= radius * radius
|
||||
&& combatHasLineOfSight(center, position));
|
||||
})
|
||||
.map((mob) => mob.id)
|
||||
.sort();
|
||||
@@ -856,7 +915,7 @@ function executePartyAbility(
|
||||
? Boolean(useCombatStore.getState().createActorAreaEffect(
|
||||
member.id,
|
||||
ability,
|
||||
getMobPosition(targetId) ?? partyFriendlyPosition(targetId) ?? origin,
|
||||
ability.target === "self" ? origin : getMobPosition(targetId) ?? partyFriendlyPosition(targetId) ?? origin,
|
||||
now,
|
||||
))
|
||||
: false;
|
||||
@@ -1143,6 +1202,7 @@ export function advanceDungeonPartyCombat(now = Date.now()): void {
|
||||
member = activeMember;
|
||||
const currentCombat = useCombatStore.getState();
|
||||
if (member.activeCast) {
|
||||
const activeCast = member.activeCast;
|
||||
const castingAbility = abilityById(member.activeCast.abilityId);
|
||||
const castTargetId = member.activeCastTargetId;
|
||||
if (!castingAbility || !castTargetId) {
|
||||
@@ -1163,7 +1223,31 @@ export function advanceDungeonPartyCombat(now = Date.now()): void {
|
||||
status: "advancing", nextActionAt: now + 250 };
|
||||
continue;
|
||||
}
|
||||
if (now < member.activeCast.completesAt) {
|
||||
if (member.activeCast.mode === "channel") {
|
||||
const cast = member.activeCast;
|
||||
if (!partyAbilityTargetIsValid(member, castingAbility, castTargetId, cast.origin)) {
|
||||
emitPartyAbility(member, castingAbility, castTargetId, "cast-cancel", now);
|
||||
nextMembers[index] = { ...member, activeCast: null, activeCastTargetId: null, status: "advancing", nextActionAt: now + 250 };
|
||||
continue;
|
||||
}
|
||||
const interval = Math.max(1, cast.originalDurationMs / 5);
|
||||
let completed = cast.channelTicksCompleted ?? 0;
|
||||
while (completed < 5 && cast.startedAt + (completed + 1) * interval <= now) {
|
||||
const effects: AbilityEffect[] = channelAmountEffects(castingAbility, 5).map(({ effect, multiplier }) => ({
|
||||
kind: effect.kind === "heal" || effect.kind === "hot" ? "heal" : "damage",
|
||||
coefficient: 0, basePoints: Math.round(partyAbilityAmount(member, castingAbility, effect) * multiplier),
|
||||
bonusPowerCoefficient: 0, sourceLevel: member.level,
|
||||
...(effect.kind === "heal" && effect.percentMaxHealth !== undefined
|
||||
? { percentMaxHealth: effect.percentMaxHealth * multiplier } : {}),
|
||||
}));
|
||||
const execution = executePartyAbility(member, { ...castingAbility, effects }, castTargetId,
|
||||
cast.startedAt + (completed + 1) * interval, nextMembers, 0, true);
|
||||
member = execution.member;
|
||||
completed += 1;
|
||||
}
|
||||
member = { ...member, activeCast: { ...cast, channelTicksCompleted: completed } };
|
||||
}
|
||||
if (now < activeCast.completesAt) {
|
||||
nextMembers[index] = member.status === desiredStatus ? member : { ...member, status: desiredStatus };
|
||||
if (hostileCast) memberTargetIds[member.id] = castTargetId;
|
||||
continue;
|
||||
@@ -1173,12 +1257,14 @@ export function advanceDungeonPartyCombat(now = Date.now()): void {
|
||||
completedMember,
|
||||
castingAbility,
|
||||
castTargetId,
|
||||
member.activeCast.origin,
|
||||
activeCast.origin,
|
||||
);
|
||||
if (valid) {
|
||||
const execution = executePartyAbility(
|
||||
completedMember,
|
||||
castingAbility,
|
||||
activeCast.mode === "channel"
|
||||
? { ...castingAbility, effects: castingAbility.effects.filter((effect) => !["damage", "dot", "heal", "hot"].includes(effect.kind)) }
|
||||
: castingAbility,
|
||||
castTargetId,
|
||||
now,
|
||||
nextMembers,
|
||||
@@ -1284,7 +1370,11 @@ export function advanceDungeonPartyCombat(now = Date.now()): void {
|
||||
const targetVisible = Boolean(
|
||||
targetPosition && partyRuntimeTargetVisible(member.id, memberTargetId)
|
||||
);
|
||||
let runtimeMember = member;
|
||||
let runtimeMember = targetVisible ? advancePartyWeaponAttack(member, memberTargetId, now) : member;
|
||||
if (useCombatStore.getState().mobs[memberTargetId]?.dead) {
|
||||
nextMembers[index] = { ...runtimeMember, status: desiredStatus };
|
||||
continue;
|
||||
}
|
||||
const targetMob = currentCombat.mobs[memberTargetId];
|
||||
if (now < member.nextActionAt) {
|
||||
if (runtimeMember.status !== desiredStatus) {
|
||||
@@ -1297,9 +1387,18 @@ export function advanceDungeonPartyCombat(now = Date.now()): void {
|
||||
now,
|
||||
target: targetMob ?? null,
|
||||
targetIsLoose: member.role === "tank" && targetMob?.targetActorId !== member.id,
|
||||
canUseAbility: (ability) => partyAbilityTargetIsValid(runtimeMember, ability, memberTargetId)
|
||||
// Let maintained effects tick instead of resetting their first tick on every GCD.
|
||||
&& !currentCombat.effects.some((effect) => effect.sourceActorId === member.id
|
||||
&& effect.sourceAbilityId === ability.id && effect.targetId === memberTargetId && effect.remainingTicks > 0)
|
||||
&& !ability.effects.some((effect) => effect.kind === "apply-aura"
|
||||
&& currentCombat.auras.some((aura) => aura.sourceId === member.id
|
||||
&& aura.definition.id === effect.aura.id && aura.targetId === memberTargetId)),
|
||||
});
|
||||
if (!selectedAbility) {
|
||||
nextMembers[index] = { ...runtimeMember, status: desiredStatus, nextActionAt: now + 250 };
|
||||
const inAttackRange = targetVisible && targetPosition
|
||||
&& distanceSquared(memberPosition, targetPosition) <= partyAttackRange(member) ** 2;
|
||||
nextMembers[index] = { ...runtimeMember, status: inAttackRange ? desiredStatus : "advancing", nextActionAt: now + 250 };
|
||||
continue;
|
||||
}
|
||||
const inRange = targetVisible && partyAbilityTargetIsValid(runtimeMember, selectedAbility, memberTargetId);
|
||||
|
||||
Reference in new issue
Block a user