Download combat-sword.js from Saedmh/Saed: direct link, hf CLI and curl.
- Browser
- Download file 5.55 kB
-
https://huggingface.co/spaces/Saedmh/Saed/resolve/main/combat-sword.js
- Command line
-
hf download hf://spaces/Saedmh/Saed/combat-sword.js
-
curl -L -o combat-sword.js https://huggingface.co/spaces/Saedmh/Saed/resolve/main/combat-sword.js
5.55 kB
| ; | |
| /** | |
| * Sword Combat — مهارات السيف المحترفة | |
| * كومبو، كريتيكال، بلوك، سبارك، حركات متقدمة | |
| */ | |
| const { EventEmitter } = require('events'); | |
| const sleep = ms => new Promise(r => setTimeout(r, Math.max(0, ms))); | |
| const rand = (a, b) => Math.floor(Math.random() * (b - a + 1)) + a; | |
| const chance = pct => Math.random() * 100 < pct; | |
| class SwordCombat extends EventEmitter { | |
| constructor(bot) { | |
| super(); | |
| this.bot = bot; | |
| this._comboCount = 0; | |
| this._lastHit = 0; | |
| this._critMode = false; | |
| this._log('INIT', 'مهارات السيف جاهزة'); | |
| } | |
| _log(tag, msg) { | |
| const ts = new Date().toISOString().replace('T', ' ').slice(0, 19); | |
| console.log(`[${ts}] [SWORD] ${tag} ${msg}`); | |
| } | |
| // ═══ كومبو — ضربات سريعة متتالية ═══ | |
| async combo(target, hits = 3) { | |
| if (!this.bot?.entity || !target) return; | |
| this._log('⚔️', `كومبو: ${hits} ضربات على ${target.name}`); | |
| for (let i = 0; i < hits; i++) { | |
| if (!this.bot?.entity || !target || target.health <= 0) break; | |
| // ا approached | |
| const d = this.bot.entity.position.distanceTo(target.position); | |
| if (d > 3) await this._approach(target); | |
| // اضرب | |
| try { | |
| await this.bot.attack(target); | |
| this._comboCount++; | |
| this._lastHit = Date.now(); | |
| } catch(_) {} | |
| // تأخير صغير بين الضربات (كومبو سريع) | |
| await sleep(rand(150, 250)); | |
| } | |
| this._log('✅', `كومبو اكتمل: ${this._comboCount} ضربة`); | |
| this.emit('combo', this._comboCount); | |
| } | |
| // ═══ كريتيكال — ضربة قوية بالقفز ═══ | |
| async criticalHit(target) { | |
| if (!this.bot?.entity || !target) return; | |
| this._log('💥', `كريتيكال على ${target.name}`); | |
| // اقفز | |
| this.bot.setControlState('jump', true); | |
| await sleep(rand(100, 200)); | |
| this.bot.setControlState('jump', false); | |
| // اضرب وأنت نازل (في الهواء) | |
| await sleep(rand(100, 150)); | |
| try { | |
| await this.bot.attack(target); | |
| this._log('💥', 'كريتيكال نجح!'); | |
| this.emit('critical', target.name); | |
| } catch(_) {} | |
| } | |
| // ═══ بلوك — حماية بالسيف ═══ | |
| async block(duration = 500) { | |
| if (!this.bot) return; | |
| this._log('🛡️', 'بلوك بالسيف'); | |
| // مسك زر يمين (بلوك) | |
| this.bot.activateItem(); // right click = block with sword | |
| await sleep(duration); | |
| this.bot.deactivateItem(); | |
| } | |
| // ═══ سبارك — حركة سريعة للهجوم ═══ | |
| async sparkle(target) { | |
| if (!this.bot?.entity || !target) return; | |
| this._log('✨', `سبارك على ${target.name}`); | |
| // سبرنت + اضرب | |
| this.bot.setControlState('sprint', true); | |
| await this._approach(target); | |
| try { | |
| await this.bot.attack(target); | |
| } catch(_) {} | |
| this.bot.setControlState('sprint', false); | |
| // حركة جانبية بعد الضربة | |
| this._strafe(); | |
| } | |
| // ═══ كومبو + كريتيكال ═══ | |
| async comboCritical(target, hits = 2) { | |
| if (!this.bot?.entity || !target) return; | |
| // كومبو عادي | |
| await this.combo(target, hits); | |
| // كريتيكال في الآخر | |
| await this.criticalHit(target); | |
| } | |
| // ═══ هجوم مباغت ═══ | |
| async surpriseAttack(target) { | |
| if (!this.bot?.entity || !target) return; | |
| this._log(' surprise', `هجوم مباغت على ${target.name}`); | |
| // امشي بشكل عادي | |
| this.bot.setControlState('forward', true); | |
| await sleep(rand(500, 1000)); | |
| this.bot.setControlState('forward', false); | |
| // فجأة سبرنت + اضرب | |
| this.bot.setControlState('sprint', true); | |
| await this._approach(target); | |
| await sleep(rand(100, 200)); | |
| try { | |
| await this.bot.attack(target); | |
| // كومبو سريع | |
| for (let i = 0; i < 3; i++) { | |
| await sleep(rand(150, 250)); | |
| await this.bot.attack(target); | |
| } | |
| } catch(_) {} | |
| this.bot.setControlState('sprint', false); | |
| } | |
| // ═══ مقاربة ═══ | |
| async _approach(target) { | |
| if (!this.bot?.entity || !target) return; | |
| const yaw = Math.atan2( | |
| target.position.z - this.bot.entity.position.z, | |
| target.position.x - this.bot.entity.position.x | |
| ); | |
| this.bot.look(yaw, 0, false); | |
| this.bot.setControlState('forward', true); | |
| await sleep(rand(200, 400)); | |
| this.bot.setControlState('forward', false); | |
| } | |
| // ═══ حركة جانبية ═══ | |
| _strafe() { | |
| if (!this.bot) return; | |
| const dir = chance(50) ? 'left' : 'right'; | |
| this.bot.setControlState(dir, true); | |
| setTimeout(() => { try { this.bot.setControlState(dir, false); } catch(_) {} }, rand(200, 400)); | |
| } | |
| // ═══ تحليل الأسلوب ═══ | |
| analyzeTarget(target) { | |
| if (!target) return { style: 'aggressive' }; | |
| const health = target.health || 20; | |
| const dist = this.bot?.entity?.position?.distanceTo(target.position) || 10; | |
| if (health < 6) return { style: 'finishing', reason: 'health low' }; | |
| if (dist < 2) return { style: 'close', reason: 'very close' }; | |
| if (dist > 5) return { style: 'approaching', reason: 'far away' }; | |
| return { style: 'balanced' }; | |
| } | |
| getStats() { | |
| return { comboCount: this._comboCount, lastHit: this._lastHit }; | |
| } | |
| destroy() { this.removeAllListeners(); } | |
| } | |
| module.exports = { SwordCombat }; | |