You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.6 KiB
46 lines
1.6 KiB
|
3 weeks ago
|
/**
|
||
|
|
* 近战戳刺段时序:与弓 PROJECTILE_FLY_SPEED 同模型,
|
||
|
|
* duration = dist / (pxPerSec * aspd),戳刺像素速度随攻速线性提升。
|
||
|
|
*/
|
||
|
|
|
||
|
|
/** @aspd=1 瞄准插值基准秒数(角向,与距离无关) */
|
||
|
|
export const MELEE_AIM_SEC = 0.12;
|
||
|
|
|
||
|
|
/** @aspd=1 戳刺逻辑像素/秒(约 84px / 0.07s) */
|
||
|
|
export const MELEE_THRUST_PX_PER_SEC = 1200;
|
||
|
|
|
||
|
|
/** @aspd=1 收回逻辑像素/秒(约 84px / 0.1s) */
|
||
|
|
export const MELEE_RETURN_PX_PER_SEC = 840;
|
||
|
|
|
||
|
|
/** 戳刺/收回段最短时长,避免极短距离时帧级闪烁 */
|
||
|
|
export const MELEE_MIN_PHASE_SEC = 0.03;
|
||
|
|
|
||
|
|
/** 攻击被打断后 atkParent 复位插值(与攻速无关) */
|
||
|
|
export const MELEE_RESTORE_SEC = 0.1;
|
||
|
|
|
||
|
|
export interface MeleeThrustTimingOpts {
|
||
|
|
aimSec?: number;
|
||
|
|
thrustPxPerSec?: number;
|
||
|
|
returnPxPerSec?: number;
|
||
|
|
minPhaseSec?: number;
|
||
|
|
}
|
||
|
|
|
||
|
|
/** 按戳刺距离与攻速计算瞄准/戳刺/收回时长 */
|
||
|
|
export function calcMeleeThrustPhaseDurations(
|
||
|
|
thrustDistPx: number,
|
||
|
|
aspdScale: number,
|
||
|
|
opts?: MeleeThrustTimingOpts,
|
||
|
|
): { aimDur: number; thrustDur: number; returnDur: number } {
|
||
|
|
const aspd = Math.max(0.01, aspdScale);
|
||
|
|
const dist = Math.max(0, thrustDistPx);
|
||
|
|
const aimSec = opts?.aimSec ?? MELEE_AIM_SEC;
|
||
|
|
const thrustSpd = opts?.thrustPxPerSec ?? MELEE_THRUST_PX_PER_SEC;
|
||
|
|
const returnSpd = opts?.returnPxPerSec ?? MELEE_RETURN_PX_PER_SEC;
|
||
|
|
const minSec = opts?.minPhaseSec ?? MELEE_MIN_PHASE_SEC;
|
||
|
|
return {
|
||
|
|
aimDur: aimSec / aspd,
|
||
|
|
thrustDur: Math.max(minSec, dist / (thrustSpd * aspd)),
|
||
|
|
returnDur: Math.max(minSec, dist / (returnSpd * aspd)),
|
||
|
|
};
|
||
|
|
}
|