Skip to content

Commit 3a5b3a0

Browse files
authored
Updated export mods script to dump trade hashes (#165)
* modifier export saves trade hashes * two-stat mod support * three-mod stat trade hashes * four-stat mod trade hashes * five-stat mod trade hashes
1 parent 5b7563b commit 3a5b3a0

File tree

10 files changed

+9048
-9007
lines changed

10 files changed

+9048
-9007
lines changed

src/Data/ModCharm.lua

Lines changed: 51 additions & 51 deletions
Large diffs are not rendered by default.

src/Data/ModCorrupted.lua

Lines changed: 125 additions & 125 deletions
Large diffs are not rendered by default.

src/Data/ModFlask.lua

Lines changed: 78 additions & 78 deletions
Large diffs are not rendered by default.

src/Data/ModItem.lua

Lines changed: 4829 additions & 4829 deletions
Large diffs are not rendered by default.

src/Data/ModJewel.lua

Lines changed: 324 additions & 324 deletions
Large diffs are not rendered by default.

src/Data/ModUnique.lua

Lines changed: 3597 additions & 3597 deletions
Large diffs are not rendered by default.

src/Data/Uniques/staff.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Dusk Vigil
1515
Ashen Staff
1616
Implicits: 2
1717
Grants Skill: Level (1-20) Firebolt
18-
Grants Skill: Level (1-20) Ember Fussilade
18+
Grants Skill: Level (1-20) Ember Fusillade
1919
(60-80)% increased Spell Damage
2020
Gain (5-10) Life per Enemy Killed
2121
25% increased Mana Regeneration Rate

src/Export/Scripts/mods.lua

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,37 @@ local function writeMods(outName, condFunc)
171171
if mod.NodeType ~= 3 then
172172
out:write('nodeType = ', mod.NodeType, ', ')
173173
end
174+
175+
if mod.Stat5 and mod.Stat4 and mod.Stat3 and mod.Stat2 then
176+
local part_1 = intToBytes(mod.Stat1.Hash)
177+
local part_2 = intToBytes(mod.Stat2.Hash)
178+
local part_3 = intToBytes(mod.Stat3.Hash)
179+
local part_4 = intToBytes(mod.Stat4.Hash)
180+
local part_5 = intToBytes(mod.Stat5.Hash)
181+
local trade_hash = murmurHash2(part_1..part_2..part_3..part_4..part_5, 0x02312233)
182+
out:write('tradeHash = ', trade_hash, ', ')
183+
elseif mod.Stat4 and mod.Stat3 and mod.Stat2 then
184+
local part_1 = intToBytes(mod.Stat1.Hash)
185+
local part_2 = intToBytes(mod.Stat2.Hash)
186+
local part_3 = intToBytes(mod.Stat3.Hash)
187+
local part_4 = intToBytes(mod.Stat4.Hash)
188+
local trade_hash = murmurHash2(part_1..part_2..part_3..part_4, 0x02312233)
189+
out:write('tradeHash = ', trade_hash, ', ')
190+
elseif mod.Stat3 and mod.Stat2 then
191+
local part_1 = intToBytes(mod.Stat1.Hash)
192+
local part_2 = intToBytes(mod.Stat2.Hash)
193+
local part_3 = intToBytes(mod.Stat3.Hash)
194+
local trade_hash = murmurHash2(part_1..part_2..part_3, 0x02312233)
195+
out:write('tradeHash = ', trade_hash, ', ')
196+
elseif mod.Stat2 then
197+
local part_1 = intToBytes(mod.Stat1.Hash)
198+
local part_2 = intToBytes(mod.Stat2.Hash)
199+
local trade_hash = murmurHash2(part_1..part_2, 0x02312233)
200+
out:write('tradeHash = ', trade_hash, ', ')
201+
elseif mod.Stat1 then
202+
local trade_hash = murmurHash2(intToBytes(mod.Stat1.Hash), 0x02312233)
203+
out:write('tradeHash = ', trade_hash, ', ')
204+
end
174205
out:write('},\n')
175206
else
176207
print("Mod '"..mod.Id.."' has no stats")

src/Export/spec.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8834,12 +8834,12 @@ return {
88348834
list=false,
88358835
name="HASH32",
88368836
refTo="",
8837-
type="Int",
8837+
type="UInt",
88388838
width=150
88398839
},
88408840
[61]={
88418841
list=true,
8842-
name="BuffTemplate",
8842+
name="BuffTemplate2",
88438843
refTo="BuffTemplates",
88448844
type="Key",
88458845
width=150

src/Modules/Common.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,16 @@ function sanitiseText(text)
259259
or text
260260
end
261261

262+
-- Convert int to 4 bytes string
263+
function intToBytes(int)
264+
return string.char(
265+
bit.band(int, 0xFF),
266+
bit.band(bit.rshift(int, 8), 0xFF),
267+
bit.band(bit.rshift(int, 16), 0xFF),
268+
bit.band(bit.rshift(int, 24), 0xFF)
269+
)
270+
end
271+
262272
do
263273
local function toUnsigned(val)
264274
return val < 0 and val + 0x100000000 or val

0 commit comments

Comments
 (0)