diff --git a/client/webapp/index.html b/client/webapp/index.html --- a/client/webapp/index.html +++ b/client/webapp/index.html @@ -137,4 +137,4 @@ - + - W + 2 diff --git a/client/webapp/js/ui/skill_bar_controller.js b/client/webapp/js/ui/skill_bar_controller.js --- a/client/webapp/js/ui/skill_bar_controller.js +++ b/client/webapp/js/ui/skill_bar_controller.js @@ -44,4 +44,4 @@ - { id: '2', domId: 'skill-slot-w', key: 'W', numKey: '2', maxCd: 3.0, action: () => window.doThunder?.() }, + { id: '2', domId: 'skill-slot-w', key: '2', numKey: '2', maxCd: 3.0, action: () => window.doThunder?.() }, { id: '3', domId: 'skill-thunder', key: 'E', numKey: '3', maxCd: 4.0, action: () => window.doThunder?.() }, { id: '4', domId: 'skill-frost', key: 'R', numKey: '4', maxCd: 5.0, action: () => window.doFrost?.() }, - { id: '0', domId: 'skill-primary', key: 'LMB', numKey: '1', maxCd: 0.2, action: () => window.doPrimaryAttack?.() }, + { id: '0', domId: 'skill-primary', key: 'LMB', numKey: null, maxCd: 0.2, action: () => window.doPrimaryAttack?.() }, @@ -127,2 +127,3 @@ slot.charges--; + if (slot.slotId === 'dodge' && typeof window !== 'undefined') window.dodgeCharges = slot.charges; this._updateChargeBadge(slot); @@ -155,7 +156,12 @@ if (this.isSlotOnCooldown(slotId)) { this._flashBlockedFeedback(slot); return false; } + const chargesBefore = slot.charges; + const cdBefore = slot.cooldownRemaining; if (typeof slot.onActivate === 'function') slot.onActivate(slot); - if (slot.charges !== null) this.triggerCooldown(slotId, slot.rechargeDuration); - else if (slot.cooldownTotal > 0) this.triggerCooldown(slotId, slot.cooldownTotal); + const alreadyTriggered = (slot.charges !== null && slot.charges < chargesBefore) || + (slot.charges === null && slot.cooldownRemaining > cdBefore); + if (!alreadyTriggered) { + if (slot.charges !== null) this.triggerCooldown(slotId, slot.rechargeDuration); + else if (slot.cooldownTotal > 0) this.triggerCooldown(slotId, slot.cooldownTotal); + } return true; @@ -201,2 +207,3 @@ slot.charges = Math.min(slot.maxCharges, slot.charges + 1); + if (slot.slotId === 'dodge' && typeof window !== 'undefined') window.dodgeCharges = slot.charges; this._updateChargeBadge(slot); @@ -296,6 +303,5 @@ const slotKey = slot.key; if ( - (slotKey === pressedKey) || + (slotKey && slotKey !== 'W' && slotKey === pressedKey) || (slot.numKey && (k === slot.numKey.toLowerCase())) || - (slotKey === 'SPACE' && (e.code === 'Space' || k === ' ')) || - (slotKey === 'LMB' && (k === '1')) + (slotKey === 'SPACE' && (e.code === 'Space' || k === ' ')) ) { diff --git a/client/webapp/js/engine/combat_skills.js b/client/webapp/js/engine/combat_skills.js --- a/client/webapp/js/engine/combat_skills.js +++ b/client/webapp/js/engine/combat_skills.js @@ -234,1 +234,0 @@ - if (window.skillBarController) window.skillBarController.triggerCooldown('1', 1.5); @@ -256,1 +255,0 @@ - if (window.skillBarController) window.skillBarController.triggerCooldown('3', 4.0); @@ -278,1 +276,0 @@ - if (window.skillBarController) window.skillBarController.triggerCooldown('4', 5.0); @@ -297,1 +294,0 @@ - if (window.skillBarController) window.skillBarController.triggerCooldown('dodge', 3.0); @@ -317,1 +313,0 @@ - if (window.skillBarController) window.skillBarController.triggerCooldown('0', 0.2); @@ -338,24 +333,12 @@ function handleKey(k) { - if (k === 'q' || k === '1') doFire(); - if (k === 'w' || k === '2') doThunder(); - if (k === 'e' || k === '3') doThunder(); - if (k === 'r' || k === '4') doFrost(); - if (k === ' ' || k === 'space' || k === 'shift') doDodge(); - if (k === '4') { - if (typeof drinkHealthPotion === 'function') drinkHealthPotion(); - if (window.skillBarController) window.skillBarController.triggerCooldown('potion', 6.0); - } if (k === 'x' || k === 'tab') btnSwapWeapon?.click(); if (k === 'f' || k === 'enter') executeNearbyInteraction(); + // Direct non-slot fallback when skillBarController is not loaded + if (!window.skillBarController) { + if (k === 'q' || k === '1') doFire(); + if (k === '2' || k === 'e' || k === '3') doThunder(); + if (k === 'r' || k === '4') doFrost(); + if (k === ' ' || k === 'space' || k === 'shift') doDodge(); + if (k === '4' && typeof drinkHealthPotion === 'function') drinkHealthPotion(); + } } - - document.getElementById('skill-fire')?.addEventListener('click', doFire); - document.getElementById('skill-thunder')?.addEventListener('click', doThunder); - document.getElementById('skill-frost')?.addEventListener('click', doFrost); - document.getElementById('skill-dodge')?.addEventListener('click', doDodge); - document.getElementById('skill-primary')?.addEventListener('click', doPrimaryAttack); - document.getElementById('skill-slot-w')?.addEventListener('click', doThunder); - document.getElementById('skill-potion')?.addEventListener('click', () => { - if (typeof drinkHealthPotion === 'function') drinkHealthPotion(); - if (window.skillBarController) window.skillBarController.triggerCooldown('potion', 6.0); - });