Refactor platform UI and data flow across core pages
All checks were successful
Build Org Website / build (push) Successful in 50s
All checks were successful
Build Org Website / build (push) Successful in 50s
This commit is contained in:
35
assets/scripts/pages/princess-lima-systems.js
Normal file → Executable file
35
assets/scripts/pages/princess-lima-systems.js
Normal file → Executable file
@@ -166,6 +166,38 @@
|
||||
return ratio > 0.66 ? 1 : ratio > 0.33 ? 2 : 3;
|
||||
}
|
||||
|
||||
const ATTACK_TIMING = Object.freeze({ windup: 85, active: 105, recovery: 135, cooldown: 360 });
|
||||
|
||||
function attackPhase(elapsed, timing) {
|
||||
const value = Math.max(0, Number(elapsed) || 0);
|
||||
const config = timing || ATTACK_TIMING;
|
||||
if (value < config.windup) return "windup";
|
||||
if (value < config.windup + config.active) return "active";
|
||||
if (value < config.windup + config.active + config.recovery) return "recovery";
|
||||
return "complete";
|
||||
}
|
||||
|
||||
function attackHitbox(facing, x, y) {
|
||||
const boxes = {
|
||||
north: { x: x - 25, y: y - 76, width: 50, height: 66, angle: 270 },
|
||||
south: { x: x - 25, y: y + 8, width: 50, height: 66, angle: 90 },
|
||||
west: { x: x - 76, y: y - 27, width: 66, height: 54, angle: 180 },
|
||||
east: { x: x + 10, y: y - 27, width: 66, height: 54, angle: 0 }
|
||||
};
|
||||
return boxes[facing] || boxes.south;
|
||||
}
|
||||
|
||||
function wallSafeKnockback(state, regionId, x, y, directionX, directionY, distance) {
|
||||
const push = normalizedVector(directionX, directionY, Math.max(0, Number(distance) || 0));
|
||||
const target = { x: x + push.x, y: y + push.y };
|
||||
if (isSafePosition(state, regionId, target.x, target.y)) return target;
|
||||
for (let scale = 0.75; scale >= 0; scale -= 0.25) {
|
||||
const candidate = { x: x + push.x * scale, y: y + push.y * scale };
|
||||
if (isSafePosition(state, regionId, candidate.x, candidate.y)) return candidate;
|
||||
}
|
||||
return { x, y };
|
||||
}
|
||||
|
||||
function respawn(state) {
|
||||
let next = copy(state);
|
||||
if (!next) return next;
|
||||
@@ -207,6 +239,7 @@
|
||||
return Object.freeze({
|
||||
normalizedVector, approachVelocity, pointInShape, activeObstacles, isSafePosition, nearestSafeSpawn,
|
||||
quantity, addItem, removeItem, useItem, startQuest, progressQuest, completeQuest, solvePuzzle,
|
||||
damage, bossPhase, respawn, recordBoss, currentObjective
|
||||
damage, bossPhase, ATTACK_TIMING, attackPhase, attackHitbox, wallSafeKnockback,
|
||||
respawn, recordBoss, currentObjective
|
||||
});
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user