Release Healer Man 0.1.36
This commit is contained in:
1 parent
40d9f346d8
commit
03a4e3f51c
22 files changed
+1389
-153
No files matched your search
+81
-13
@@ -372,6 +372,7 @@ export interface MobCombatState {
|
||||
readonly lastDamageAt: number;
|
||||
readonly engaged: boolean;
|
||||
readonly combatPhase: "idle" | "chasing" | "attacking" | "returning";
|
||||
readonly navigationEvadeUntil?: number;
|
||||
readonly homePosition: CombatPosition | null;
|
||||
readonly nextAttackAt: number;
|
||||
readonly abilityReadyAt: Readonly<Record<string, number>>;
|
||||
@@ -723,6 +724,7 @@ export interface CombatState {
|
||||
cancelCast: (message?: string) => boolean;
|
||||
engageNearbyMobs: (now?: number, playerPosition?: CombatPosition) => number;
|
||||
advanceMobCombat: (now?: number, playerPosition?: CombatPosition) => number;
|
||||
resetMobForNavigation: (id: string, atHome: boolean, now?: number) => boolean;
|
||||
tick: (deltaSeconds: number, now?: number) => void;
|
||||
resetEncounter: (options?: {
|
||||
readonly preserveDefeated?: boolean;
|
||||
@@ -2418,6 +2420,7 @@ function engageMobGroup(
|
||||
let changed = false;
|
||||
for (const [id, mob] of Object.entries(mobs)) {
|
||||
if (mob.dead || mob.despawned || mobGroupId(id) !== groupId) continue;
|
||||
if (mob.combatPhase === "returning" || (mob.navigationEvadeUntil ?? 0) > now) continue;
|
||||
const threatByActor = groupWasEngaged
|
||||
? mob.threatByActor
|
||||
: seedActorThreat(mob.threatByActor, sourceActorId);
|
||||
@@ -2459,7 +2462,7 @@ function nearestAggroActorId(
|
||||
let nearestDistanceSquared = aggroRange * aggroRange;
|
||||
if (state.health > 0) {
|
||||
const playerDistanceSquared = distanceSquared(mobPosition, state.playerPosition);
|
||||
if (playerDistanceSquared <= nearestDistanceSquared) {
|
||||
if (playerDistanceSquared <= nearestDistanceSquared && combatHasLineOfSight(mobPosition, state.playerPosition)) {
|
||||
nearestId = PLAYER_AGGRO_ID;
|
||||
nearestDistanceSquared = playerDistanceSquared;
|
||||
}
|
||||
@@ -2469,7 +2472,7 @@ function nearestAggroActorId(
|
||||
const position = getPartyRuntimePosition(member.id);
|
||||
if (!position) continue;
|
||||
const memberDistanceSquared = distanceSquared(mobPosition, position);
|
||||
if (memberDistanceSquared < nearestDistanceSquared) {
|
||||
if (memberDistanceSquared < nearestDistanceSquared && combatHasLineOfSight(mobPosition, position)) {
|
||||
nearestId = member.id;
|
||||
nearestDistanceSquared = memberDistanceSquared;
|
||||
}
|
||||
@@ -2479,7 +2482,7 @@ function nearestAggroActorId(
|
||||
const position = getPartyRuntimePosition(actor.id);
|
||||
if (!position) continue;
|
||||
const actorDistanceSquared = distanceSquared(mobPosition, position);
|
||||
if (actorDistanceSquared < nearestDistanceSquared) {
|
||||
if (actorDistanceSquared < nearestDistanceSquared && combatHasLineOfSight(mobPosition, position)) {
|
||||
nearestId = actor.id;
|
||||
nearestDistanceSquared = actorDistanceSquared;
|
||||
}
|
||||
@@ -2487,7 +2490,7 @@ function nearestAggroActorId(
|
||||
for (const summon of state.summons) {
|
||||
if (summon.health <= 0) continue;
|
||||
const summonDistanceSquared = distanceSquared(mobPosition, summon.position);
|
||||
if (summonDistanceSquared < nearestDistanceSquared) {
|
||||
if (summonDistanceSquared < nearestDistanceSquared && combatHasLineOfSight(mobPosition, summon.position)) {
|
||||
nearestId = summon.id;
|
||||
nearestDistanceSquared = summonDistanceSquared;
|
||||
}
|
||||
@@ -2533,7 +2536,9 @@ function damageMobInWork(
|
||||
combatResult?: CombatResult,
|
||||
): DamageResult {
|
||||
const mob = work.mobs[id];
|
||||
if (!mob || mob.dead || amount <= 0) return { amount: 0, killed: false, xpAwarded: 0, levelsGained: 0 };
|
||||
if (!mob || mob.dead || amount <= 0 || (mob.navigationEvadeUntil ?? 0) > now) {
|
||||
return { amount: 0, killed: false, xpAwarded: 0, levelsGained: 0 };
|
||||
}
|
||||
const mitigatedBeforeAuras = combatResult?.finalDamage ?? damageAfterMobResistance(
|
||||
amount,
|
||||
mob,
|
||||
@@ -2678,7 +2683,7 @@ function resolveAndDamageMobInWork(
|
||||
rules: CombatResultRules = {},
|
||||
): DamageResult {
|
||||
const mob = work.mobs[id];
|
||||
if (!mob || mob.dead || amount <= 0) {
|
||||
if (!mob || mob.dead || amount <= 0 || (mob.navigationEvadeUntil ?? 0) > now) {
|
||||
return { amount: 0, killed: false, xpAwarded: 0, levelsGained: 0 };
|
||||
}
|
||||
const sourceAuras = aurasForEntity(work.auras, source.actorId);
|
||||
@@ -5656,7 +5661,7 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
|
||||
tauntMob: (id, source, durationMs, now = combatNow()) => {
|
||||
const target = get().mobs[id];
|
||||
if (!target || target.dead || durationMs <= 0) return false;
|
||||
if (!target || target.dead || durationMs <= 0 || (target.navigationEvadeUntil ?? 0) > now) return false;
|
||||
const previous = target.tauntDiminishingReturns;
|
||||
const applications = target.boss && previous && previous.resetAt > now ? previous.applications : 0;
|
||||
const multiplier = target.boss ? [1, 0.65, 0.4225, 0][Math.min(3, applications)] : 1;
|
||||
@@ -5676,6 +5681,7 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
));
|
||||
for (const [mobId, mob] of Object.entries(mobs)) {
|
||||
if (mob.dead || mobGroupId(mobId) !== groupId) continue;
|
||||
if ((mob.navigationEvadeUntil ?? 0) > now) continue;
|
||||
const seeded = groupWasEngaged
|
||||
? mob.threatByActor
|
||||
: seedActorThreat(mob.threatByActor, source.actorId);
|
||||
@@ -6441,7 +6447,8 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
let engagedGroups = 0;
|
||||
for (const id of Object.keys(mobs)) {
|
||||
const mob = mobs[id];
|
||||
if (mob.dead || mob.despawned || mob.engaged || mob.aggroRange <= 0) continue;
|
||||
if (mob.dead || mob.despawned || mob.engaged || mob.aggroRange <= 0
|
||||
|| mob.combatPhase === "returning" || (mob.navigationEvadeUntil ?? 0) > now) continue;
|
||||
const position = getMobPosition(id);
|
||||
if (!position) continue;
|
||||
const actorId = nearestAggroActorId(runtimeState, position, mob.aggroRange);
|
||||
@@ -6452,6 +6459,38 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
return engagedGroups;
|
||||
},
|
||||
|
||||
resetMobForNavigation: (id, atHome, now = combatNow()) => {
|
||||
const state = get();
|
||||
const mob = state.mobs[id];
|
||||
if (!mob || mob.dead || mob.despawned || !Number.isFinite(now)) return false;
|
||||
set({
|
||||
mobs: { ...state.mobs, [id]: {
|
||||
...mob,
|
||||
engaged: false,
|
||||
combatPhase: atHome ? "idle" : "returning",
|
||||
navigationEvadeUntil: Math.max(mob.navigationEvadeUntil ?? 0, now + 10_000),
|
||||
health: mob.maxHealth,
|
||||
statuses: [],
|
||||
controlDiminishingReturns: {},
|
||||
tauntDiminishingReturns: { applications: 0, resetAt: 0 },
|
||||
auras: [],
|
||||
abilityReadyAt: {},
|
||||
abilityCastCounts: {},
|
||||
activeCast: null,
|
||||
schoolLockedUntil: {},
|
||||
nextAttackAt: 0,
|
||||
nextAttackIndex: 0,
|
||||
threatByActor: {},
|
||||
targetActorId: null,
|
||||
forcedTarget: null,
|
||||
} },
|
||||
effects: state.effects.filter((effect) => effect.targetId !== id && effect.sourceActorId !== id),
|
||||
auras: state.auras.filter((aura) => aura.targetId !== id && aura.sourceId !== id),
|
||||
areaEffects: state.areaEffects.filter((area) => area.sourceActorId !== id),
|
||||
});
|
||||
return true;
|
||||
},
|
||||
|
||||
advanceMobCombat: (now = combatNow(), playerPosition) => {
|
||||
const state = get();
|
||||
const runtimeState = playerPosition
|
||||
@@ -6527,6 +6566,7 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
const dy = position[1] - targetPosition[1];
|
||||
const dz = position[2] - targetPosition[2];
|
||||
const distanceSquared = dx * dx + dy * dy + dz * dz;
|
||||
const targetVisible = combatHasLineOfSight(position, targetPosition);
|
||||
const abilityReadyAt = Object.keys(mob.abilityReadyAt).length
|
||||
? { ...mob.abilityReadyAt }
|
||||
: { ...initialEnemyAbilityReadyAt(mob, now) };
|
||||
@@ -6537,6 +6577,20 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
let enemyActiveCast = cannotAttack || (silenced && mob.activeCast?.school !== "physical")
|
||||
? null
|
||||
: mob.activeCast;
|
||||
if (enemyActiveCast) {
|
||||
const pendingAttack = mob.attacks.find((attack) => attack.id === enemyActiveCast!.attackId);
|
||||
const pendingPosition = enemyActiveCast.targetActorId
|
||||
? actorPosition(runtimeState, enemyActiveCast.targetActorId) : null;
|
||||
if (pendingAttack && enemyAbilityNeedsHostileRange(pendingAttack)
|
||||
&& (!pendingPosition || !combatHasLineOfSight(position, pendingPosition)
|
||||
|| Math.hypot(position[0] - pendingPosition[0], position[1] - pendingPosition[1],
|
||||
position[2] - pendingPosition[2]) > pendingAttack.range)) {
|
||||
emitEnemyAttackPresentation(mob, pendingAttack, "cast-cancel", now, position,
|
||||
enemyActiveCast.targetActorId, pendingPosition);
|
||||
abilityReadyAt[pendingAttack.id] = now + 250;
|
||||
enemyActiveCast = null;
|
||||
}
|
||||
}
|
||||
let completingEnemyCast = false;
|
||||
let selectedAttackIndex = -1;
|
||||
let selectedAttack: EnemyAttackDefinition | null = null;
|
||||
@@ -6551,7 +6605,7 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
const attack = mob.attacks[index];
|
||||
const attackKind = enemyAttackKind(attack);
|
||||
const inAbilityRange = !enemyAbilityNeedsHostileRange(attack)
|
||||
|| distanceSquared <= attack.range * attack.range;
|
||||
|| (targetVisible && distanceSquared <= attack.range * attack.range);
|
||||
if (
|
||||
inAbilityRange
|
||||
&& !(silenced && attackKind === "spell")
|
||||
@@ -6567,10 +6621,24 @@ export const useCombatStore = create<CombatState>((set, get) => ({
|
||||
}
|
||||
}
|
||||
}
|
||||
const inRange = mob.attacks.some((attack) => (
|
||||
!enemyAbilityNeedsHostileRange(attack)
|
||||
|| distanceSquared <= attack.range * attack.range
|
||||
));
|
||||
// A self buff/heal must not pin an otherwise blocked attacker in place.
|
||||
const hostileAttacks = mob.attacks.filter(enemyAbilityNeedsHostileRange);
|
||||
const inRange = targetVisible && (hostileAttacks.length
|
||||
? hostileAttacks.some((attack) => distanceSquared <= attack.range * attack.range)
|
||||
: distanceSquared <= mob.attackRange * mob.attackRange);
|
||||
if (selectedAttack && completingEnemyCast && enemyAbilityNeedsHostileRange(selectedAttack)) {
|
||||
const castTargetPosition = enemyActiveCast?.targetActorId
|
||||
? actorPosition(runtimeState, enemyActiveCast.targetActorId) : null;
|
||||
if (!castTargetPosition || !combatHasLineOfSight(position, castTargetPosition)
|
||||
|| Math.hypot(position[0] - castTargetPosition[0], position[1] - castTargetPosition[1],
|
||||
position[2] - castTargetPosition[2]) > selectedAttack.range) {
|
||||
emitEnemyAttackPresentation(mob, selectedAttack, "cast-cancel", now, position,
|
||||
enemyActiveCast?.targetActorId ?? resolution.targetActorId, castTargetPosition);
|
||||
abilityReadyAt[selectedAttack.id] = now + 250;
|
||||
enemyActiveCast = null;
|
||||
selectedAttack = null;
|
||||
}
|
||||
}
|
||||
const phase: MobCombatState["combatPhase"] = inRange ? "attacking" : rooted ? "idle" : "chasing";
|
||||
let nextAttackAt = Math.min(...Object.values(abilityReadyAt), Number.POSITIVE_INFINITY);
|
||||
let attackRevision = mob.attackRevision;
|
||||
|
||||
Reference in new issue
Block a user