From bc255068676fbfe89262c258ef5a0fe96f5fbaed Mon Sep 17 00:00:00 2001 From: Big Bad Waffle Date: Sun, 9 Sep 2018 21:19:07 +0200 Subject: [PATCH] fixes #411 --- src/client/images/questItems.png | Bin 3893 -> 4104 bytes src/client/images/questItems.pyxel | Bin 5755 -> 5878 bytes .../ui/templates/inventory/inventory.js | 4 +- .../ui/templates/tooltipItem/tooltipItem.js | 2 +- src/server/components/effects.js | 14 +++- src/server/components/inventory.js | 19 ++--- src/server/config/effects/effectTemplate.js | 4 +- .../mods/mounts/effects/effectMounted.js | 44 ++++++++++++ src/server/mods/mounts/index.js | 66 ++++++++++++++++++ src/server/objects/objBase.js | 22 ++++-- src/todo | 23 ------ 11 files changed, 154 insertions(+), 44 deletions(-) create mode 100644 src/server/mods/mounts/effects/effectMounted.js create mode 100644 src/server/mods/mounts/index.js diff --git a/src/client/images/questItems.png b/src/client/images/questItems.png index a434be646c4612609348b4935a54cf01fad95ac6..51c6f01de63ce19556f95fe880f054b9437f22ce 100644 GIT binary patch literal 4104 zcmeHKe^gV~9e;_5pb>(#28)G+bwf`@aGp}BC<(^dVk=We`5_`fixkviDiSOtd4p!r zaxiXodK7;&ZfZpl1STkugbayP1*!v$H6|ogVMG#ykU&VX?@Q2y8PE3jj`y70cXRLO z`{RCpzPE2}+=o8X1EwPg;uHJP%Jm2`1(tZ!dn!B@tfFcWgxnFkGA2I%{!MQ)M-Ft!}yN;`lA8EQaIy>Ba^DPkde4xL&_u$^bq1Gh?&;mC7 z;D=&|XV`I zZv+Q3o&l4rJk(M_;uqRF4NJntlab+6qpk&Ed*M7lllF^5A9J)Ts82MSyohAl3>&Y8 zDg8C0T0l=R)(Fyo-OK#rN&I7(((w&zHd<;JbF8*ZAy2r;QfF9J5km6i%$ZOFb>7EC z{mI{qnI!u^Nc?R`ZP@tTO^33>Y{tY0rFs?!a8unyvnT;+5zxP>6eaBF5s~sQ8x=%) zK~>U-8M`Q+0h2rL(5sr0BLX@Jt>3Be;%AVbeM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Lqz=anGfIiDFki~L%e_Ja+mhl&Y0EdtJfvHZbX$Rd59W|en-<%`huW#t zQb@HK_o6?_r>i}DzUr85g_InAM!j9;K^E1%hd3F9aol!V`>*{}>K3v;Fl|jTmI*#c zDn_%OinLA6FN+LUB%xPmY%QB&N&fV)lie!n(7aI9)1`zmFD}I*?2X>7k^L3VOg!Yy zHnOSjjT3P;;0r(-RT3<9yyrqK^`pG<$!4vWp0HvW3%p}!U_yf~JnlW#e1X7gsBL85 z2~@Ys4ZX4J^F3xFR+TiMh6zDXjmUQnFHRVdkxi`yE#j%RNY1miRiz06g@GVsVQd^X z8|v+@FOdG@2t`(H4V6ZtaX*rjv7CDGCu1i94-5n>vV%&}$?1e;;d5V6u;^ou1KlU_ zwYT`uN#(N+HnzPQ(SwI)CWFGXv6o_hThuC!eL=Qp&5;D&-I+Way%&){u}t;G%CpT4 zct3e|^W7&d!(HU1OCy58*rFkDlsl|S2^J+TWE)h6=c=-O2zeE2@? ztx~(pdxo>N4wHz4bEG?)7K7uKxVgkEp|+UKxV^8E^fEPegv2OzdinX_uuVdlj_KRi znVjwO29>gC{xu3X)hnh$9sySxPzTBmgVI)HOlW<=c8{P&g;Y+BR>@Y7B{*>Jp8%A; z$`ld|=I3^$hd4%JdQG~sjAR$kA6hB++c02hIF`Ddy4>mo_InHssGO}EuJbclyqstjbUK63BshYJ0^WxCf zQI8o98?uEr2C|n2i*}WtnwJeG{a%pCp?g+!+WZj%VBU;347_3B4Fmr#2KFqHVs;6S UzyEE_H3UMy!Jq?G`y;ac4R$|&W&i*H diff --git a/src/client/images/questItems.pyxel b/src/client/images/questItems.pyxel index 041fc6dbeca72484f0eef96da7925791b377f032..f0a8c716146ebb125957c363cc4aadded38eeae1 100644 GIT binary patch delta 3153 zcmZuz2{@E%8~(<=uVW2~aB%EoC)tfoelDH;=FO=&YU$)0@|M;m2d z$D|06A?qYMn*Yn-a{a){LUGH~4yT5NKfN&Ts9TWhVn1GD}S(|j^ zmG*pE04U-H05$*se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8pDxbTY zFiW|OqwC!dO=&3iH@j{iay%0L!w|JOfU;)ry zS}!>-aRN`rxe{uw`X!sQ6O2!SJbtAHPpc0T*z?&Hqx$9q`EV^_IIYOc3q%#*Jmn-x zMcrUF6;pbmNZohE9~gYHLsJL|Ptr$=u)H2@YrbwV7qnf5brq|>sgZ>e>T}B1H*pN4 z16|ZyL5)kTjvDl;shAjcXTo1FO{53Vt`<{S6!jR5# znsFjn%Ou2pnK8$U4_GqJI0x3>Q#`JaW z>j`#O%$T_<`dgAw$noXdV((cfFS&WU|7aHcX7(x?P|`+Y%lV<#>mU)p&Bqg7gQvO~ zS5rF2lgJ?#7kW$JA0Y-dgu1ngqz6T^K4$Uhv7GH23O(ql*-@xQT&YB^GF;%rMOr32 zY?Ahg$OVLox7y|6huiM>U0>)@ip-qe_PHiaXXZpB%=x`jYj@!f@b6(09YmQ&c2o_axv89fikf&TS}Bo=AfN#ZH(5J>>gS0tfM*G&?P^y4J4PXBA9nPHRWx6%vU$S7)lH1f~zO^o2b z8irV+{T<8=bil`8pudZ_G5cv$FwrvtObYw|T?GPdQJ@uJtfUQC!q_>}C_x}^r(4LM zIpLoeGz!KJCP$aTSP@6N*+fucP()M`(TL0budzT#6v?B^@-NB{7`rj{m&b)adEAck zw@4=9Qi=9EIFDF@9&JzRPs`A*Ozd!L8j^?fpFAQ%UW-6R=El=J6F81fTGb5P==MEn)_8IRun1NR*xM*si- diff --git a/src/client/ui/templates/inventory/inventory.js b/src/client/ui/templates/inventory/inventory.js index b47af3e0..c5cc0a71 100644 --- a/src/client/ui/templates/inventory/inventory.js +++ b/src/client/ui/templates/inventory/inventory.js @@ -312,7 +312,9 @@ define([ config.push(menuItems.learn); else if (item.type === 'mtx') config.push(menuItems.activate); - else if (item.type === 'toy' || item.type === 'consumable') { + else if (item.type === 'toy' || item.type === 'consumable' || item.useText) { + if (item.useText) + menuItems.use.text = item.useText; config.push(menuItems.use); if (!item.has('quickSlot')) config.push(menuItems.quickSlot); diff --git a/src/client/ui/templates/tooltipItem/tooltipItem.js b/src/client/ui/templates/tooltipItem/tooltipItem.js index a8f6e955..6e9db36c 100644 --- a/src/client/ui/templates/tooltipItem/tooltipItem.js +++ b/src/client/ui/templates/tooltipItem/tooltipItem.js @@ -285,7 +285,7 @@ define([ this.tooltip.find('.worth').html(item.worthText ? ('
value: ' + item.worthText) : ''); - if ((item.effects) && (item.type !== 'mtx')) { + if (item.effects && item.effects[0].text && item.type !== 'mtx') { let htmlEffects = ''; item.effects.forEach(function (e, i) { diff --git a/src/server/components/effects.js b/src/server/components/effects.js index 9ce9a8b7..c21a6608 100644 --- a/src/server/components/effects.js +++ b/src/server/components/effects.js @@ -38,7 +38,7 @@ module.exports = { let e = { type: 'effects', effects: this.effects - .map(f => f.save()) + .map(f => f.save ? f.save() : f) .filter(f => !!f) }; @@ -222,6 +222,10 @@ module.exports = { effect.destroy(); this.syncRemove(effect.id, effect.type, noMsg || effect.noMsg); effects.splice(i, 1); + + if (effect.destroy) + effect.destroy(); + return; } } @@ -234,7 +238,11 @@ module.exports = { if (effect.type === effectName) { this.syncRemove(effect.id, effect.type, noMsg || effects.noMsg); effects.splice(i, 1); - return; + + if (effect.destroy) + effect.destroy(); + + return effect; } } }, @@ -252,7 +260,7 @@ module.exports = { continue; } - if (e.ttl <= 0) + if (e.ttl === 0) continue; let events = e.events; if (!events) diff --git a/src/server/components/inventory.js b/src/server/components/inventory.js index bf092d0f..a9bb1774 100644 --- a/src/server/components/inventory.js +++ b/src/server/components/inventory.js @@ -307,6 +307,8 @@ module.exports = { let eLen = effects.length; for (let j = 0; j < eLen; j++) { let effect = effects[j]; + if (!effect.events) + continue; let effectEvent = effect.events.onConsumeItem; if (!effectEvent) @@ -536,9 +538,10 @@ module.exports = { statGenerator.generate(item); } else { let effectUrl = itemEffects.get(e.type); - let effectModule = require('../' + effectUrl); - - e.events = effectModule.events; + try { + let effectModule = require('../' + effectUrl); + e.events = effectModule.events; + } catch (error) {} } }); } @@ -812,11 +815,11 @@ module.exports = { e.events = mtxModule.events; } else if (e.type) { let effectUrl = itemEffects.get(e.type); - let effectModule = require('../' + effectUrl); - - e.text = effectModule.events.onGetText(item, e); - - e.events = effectModule.events; + try { + let effectModule = require('../' + effectUrl); + e.text = effectModule.events.onGetText(item, e); + e.events = effectModule.events; + } catch (error) {} } }); } diff --git a/src/server/config/effects/effectTemplate.js b/src/server/config/effects/effectTemplate.js index 7f182ceb..46c2de9c 100644 --- a/src/server/config/effects/effectTemplate.js +++ b/src/server/config/effects/effectTemplate.js @@ -12,8 +12,8 @@ module.exports = { values[p] = value; } - if (!this.expire) - this.expire = (+new Date()) + (this.ttl * 350); + if (!values.expire) + values.expire = (+new Date()) + (this.ttl * 350); return values; }, diff --git a/src/server/mods/mounts/effects/effectMounted.js b/src/server/mods/mounts/effects/effectMounted.js new file mode 100644 index 00000000..b6e65137 --- /dev/null +++ b/src/server/mods/mounts/effects/effectMounted.js @@ -0,0 +1,44 @@ +module.exports = { + type: 'mounted', + + oldCell: null, + oldSheetName: null, + + init: function () { + let obj = this.obj; + + this.oldCell = obj.cell; + this.oldSheetName = obj.sheetName; + + obj.cell = 35; + obj.sheetName = 'mobs'; + + let syncer = obj.syncer; + syncer.set(false, null, 'cell', obj.cell); + syncer.set(false, null, 'sheetName', obj.sheetName); + }, + + simplify: function () { + return { + type: 'mounted', + ttl: this.ttl + }; + }, + + destroy: function () { + let obj = this.obj; + + obj.cell = this.oldCell; + obj.sheetName = this.oldSheetName; + + let syncer = obj.syncer; + syncer.set(false, null, 'cell', obj.cell); + syncer.set(false, null, 'sheetName', obj.sheetName); + }, + + events: { + onBeforeTryMove: function (moveEvent) { + moveEvent.sprintChance = 200; + } + } +}; diff --git a/src/server/mods/mounts/index.js b/src/server/mods/mounts/index.js new file mode 100644 index 00000000..7c8ce13d --- /dev/null +++ b/src/server/mods/mounts/index.js @@ -0,0 +1,66 @@ +/* +Example of a mount: +{ + name: 'Brown Horse\'s Reins', + type: 'mount', + quality: 2, + noDrop: true, + noDestroy: true, + noSalvage: true, + cdMax: 10, + sprite: [0, 9], + spritesheet: 'images/questItems.png', + useText: 'mount', + description: 'Stout, dependable and at least faster than you', + effects: [{ + type: 'mount', + rolls: { + speed: 150, + cell: 5, + sheetName: 'mobs' + } + }] +} +*/ + +module.exports = { + name: 'Feature: Mounts', + + init: function () { + this.events.on('onBeforeUseItem', this.onBeforeUseItem.bind(this)); + this.events.on('onBeforeGetEffect', this.onBeforeGetEffect.bind(this)); + }, + + onBeforeUseItem: function (obj, item, result) { + if (item.type !== 'mount') + return; + + let syncer = obj.syncer; + + let currentEffect = obj.effects.removeEffectByName('mounted', true); + if (currentEffect) { + let currentItem = currentEffect.source; + currentItem.useText = 'mount'; + currentItem.cdMax = 0; + + syncer.setArray(true, 'inventory', 'getItems', currentItem); + + if (currentItem === item) + return; + } + + let builtEffect = obj.effects.addEffect({ + type: 'mounted', + ttl: -1 + }); + builtEffect.source = item; + + item.useText = 'unmount'; + syncer.setArray(true, 'inventory', 'getItems', item); + }, + + onBeforeGetEffect: function (result) { + if (result.type.toLowerCase() === 'mounted') + result.url = `${this.relativeFolderName}/effects/effectMounted.js`; + } +}; diff --git a/src/server/objects/objBase.js b/src/server/objects/objBase.js index 1837d407..bda70e3b 100644 --- a/src/server/objects/objBase.js +++ b/src/server/objects/objBase.js @@ -219,14 +219,24 @@ module.exports = { return; if (q.action === 'move') { + let maxDistance = 1; if ((this.actionQueue[0]) && (this.actionQueue[0].action === 'move')) { - let sprintChance = this.stats.values.sprintChance || 0; + let moveEvent = { + sprintChance: this.stats.values.sprintChance || 0 + }; + this.fireEvent('onBeforeTryMove', moveEvent); + let physics = this.instance.physics; - if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) { - q = this.dequeue(); - q.isDouble = true; - } + let sprintChance = moveEvent.sprintChance; + do { + if ((~~(Math.random() * 100) < sprintChance) && (!physics.isTileBlocking(q.data.x, q.data.y))) { + q = this.dequeue(); + maxDistance++; + } + sprintChance -= 100; + } while (sprintChance > 0 && this.actionQueue.length > 0); } + q.maxDistance = maxDistance; let success = this.performMove(q); if (!success) this.clearQueue(); @@ -255,7 +265,7 @@ module.exports = { return true; } - let maxDistance = action.isDouble ? 2 : 1; + let maxDistance = action.maxDistance || 1; let deltaX = Math.abs(this.x - data.x); let deltaY = Math.abs(this.y - data.y); diff --git a/src/todo b/src/todo index 33b766ee..03b59674 100644 --- a/src/todo +++ b/src/todo @@ -1,24 +1 @@ * Client side debuff icons aren't being removed - -Old -* The `Pumpkin Sailor` and his ship spawn south of the `Crab Ruins` -* New gather nodes: `Tiny Pumpkin`, `Pumpkin` and `Giant Pumpkin` that drop `Candy Corn` -* Pumpkins have a chance to spawn `Soul Nibblers` that drop extra `Candy Corn` -* `Soul Nibblers` also have a small chance to drop the `Summon Pumpkin Skeleton` -* Killing `Soul Nibblers` grants reputation with the `Pumpkin Sailor` -* Every few hours, `Lord Squash` spawns -* `Lord Squash` has a few lines he'll speak globally -* Killing `Lord Squash` grants a lot of reputation with the `Pumpkin Sailor` -* `Lord Squash` drops a lot of `Candy Corn` and has a small chance to drop `Haunted Ice Spear` -* `Lord Squash` has two abilities: `Scatter Pumpkin Pieces` and a 'target-all' `Projectile` -* The `Pumpkin Sailor` has dialogue options that explain his backstory a bit -* The `Pumpkin Sailor` has four rings for sale for different spirits. They each cost 400 `Candy Corn` and require you to be Friendly with his faction -* The `Pumpkin Sailor` has the `Pumpkin-Head Necromancer` skin for sale which costs 1200 `Candy Corn` and requires you to be Honored with his faction - -New -* Purchasable `Some Non Combat Pet` for x `Candy Corn` at y reputation from the `Pumpkin Sailor` -* Purchasable `100% Sprint Chance Mount` for x `Candy Corn` at y reputation from the `Pumpkin Sailor` -* `Lord Squash` has a small chance to drop a `Some Slot Item` that causes `Some Aura` to not reserve mana -* The `Hermit's House` and houses in `Fjolgard` should be decorated festively -* It should be possible to rarely fish up `Ghoslty Carp` that can be combined with `Emberleaf` to create a `Ghostly Elixir` which grants the player a ghostly aura -* A rare version of `Some Mob` should spawn in the `The Estuary` which has a chance to drop `Some Belt`