Add swords, damage affinities, sprites, tipped arrows, and elemental spell trees.
Craftable swords with dual metal/leather tint, mob weakness/resistance by damage type, elemental sprite mobs with essence drops, alchemy arrow coatings with tip UI and triple-channel tint, and replace Spark with full damage ladders for all seven magic elements.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">AB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">AB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#48a838"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">BL</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#48a838"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">BL</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">BO</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">BO</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">CA</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">CA</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">CY</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">CY</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#5a3878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">DB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#5a3878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">DB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#4080d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">DE</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#4080d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">DE</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">EB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">EB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#5a3878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">EC</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#5a3878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">EC</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#e8d878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">FL</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#e8d878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">FL</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">GA</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">GA</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#5a3878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">GL</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#5a3878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">GL</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">HU</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">HU</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#e8d878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">JU</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#e8d878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">JU</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">LS</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">LS</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#e8d878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">LB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#e8d878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">LB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#4080d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">MA</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#4080d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">MA</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#5a3878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">OB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#5a3878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">OB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#48a838"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">PL</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#48a838"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">PL</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#48a838"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">PB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#48a838"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">PB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">QU</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#8a6a38"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">QU</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#e8d878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">RA</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#e8d878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">RA</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#e8d878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">SB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#e8d878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">SB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TE</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#90b8d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TE</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#4080d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TO</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#4080d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TO</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#48a838"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TX</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#48a838"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">TX</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#48a838"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">VC</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#48a838"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">VC</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#5a3878"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">VL</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#5a3878"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">VL</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#4080d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">WB</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#4080d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">WB</text>4
</svg>@@ -0,0 +1,4 @@
1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
2
<rect width="32" height="32" rx="6" fill="#4080d0"/>
3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">WS</text>
4
</svg>
@@ -0,0 +1,4 @@1
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">2
<rect width="32" height="32" rx="6" fill="#4080d0"/>3
<text x="16" y="21" text-anchor="middle" fill="#f0ece0" font-size="11" font-family="Segoe UI,sans-serif" font-weight="600">WS</text>4
</svg>@@ -820,7 +820,8 @@ export function initTileConfigModal ({
820
820
addBtn.addEventListener("click", () =>
821
821
{
822
822
const available = Object.values(SPELL_DEFINITIONS).find((def) =>
823
!spellsDraft.some((line) => line.spellId === def.spellId));
823
!def.mobOnly
824
&& !spellsDraft.some((line) => line.spellId === def.spellId));
824
825
if (!available)
825
826
{ return; }
826
827
spellsDraft.push({ spellId: available.spellId });
@@ -875,6 +876,8 @@ export function initTileConfigModal ({
875
876
const select = document.createElement("select");
876
877
for (const spell of Object.values(SPELL_DEFINITIONS))
877
878
{
879
if (spell.mobOnly)
880
{ continue; }
878
881
const opt = document.createElement("option");
879
882
opt.value = spell.spellId;
880
883
const minLv = spell.minMagicLevel | 0 || 1;
@@ -820,7 +820,8 @@ export function initTileConfigModal ({820
addBtn.addEventListener("click", () =>820
addBtn.addEventListener("click", () =>821
{821
{822
const available = Object.values(SPELL_DEFINITIONS).find((def) =>822
const available = Object.values(SPELL_DEFINITIONS).find((def) =>823
!spellsDraft.some((line) => line.spellId === def.spellId));823
!def.mobOnly824
&& !spellsDraft.some((line) => line.spellId === def.spellId));824
if (!available)825
if (!available)825
{ return; }826
{ return; }826
spellsDraft.push({ spellId: available.spellId });827
spellsDraft.push({ spellId: available.spellId });@@ -875,6 +876,8 @@ export function initTileConfigModal ({875
const select = document.createElement("select");876
const select = document.createElement("select");876
for (const spell of Object.values(SPELL_DEFINITIONS))877
for (const spell of Object.values(SPELL_DEFINITIONS))877
{878
{879
if (spell.mobOnly)880
{ continue; }878
const opt = document.createElement("option");881
const opt = document.createElement("option");879
opt.value = spell.spellId;882
opt.value = spell.spellId;880
const minLv = spell.minMagicLevel | 0 || 1;883
const minLv = spell.minMagicLevel | 0 || 1;@@ -28,7 +28,8 @@ export function initInventory ({
28
28
contextMenu,
29
29
resolveSpriteUrl,
30
30
getFriends,
31
getLocalName
31
getLocalName,
32
tipArrows = null
32
33
})
33
34
{
34
35
const bagPanel = document.getElementById("bag-panel");
@@ -379,10 +380,20 @@ export function initInventory ({
379
380
}
380
381
if (slot.itemId === ItemId.potion && slot.instance?.kind === "potion")
381
382
{
382
items.push({
383
label: "Drink",
384
onSelect: () => socket.send({ type: MessageType.drinkItem, slotIndex })
385
});
383
if (tipArrows?.isArrowCoatingPotion?.(slot))
384
{
385
items.push({
386
label: "Apply to arrows",
387
onSelect: () => tipArrows.open(slotIndex)
388
});
389
}
390
else
391
{
392
items.push({
393
label: "Drink",
394
onSelect: () => socket.send({ type: MessageType.drinkItem, slotIndex })
395
});
396
}
386
397
}
387
398
items.push({
388
399
label: "Drop",
@@ -971,6 +982,13 @@ export function initInventory ({
971
982
{
972
983
return bag.inventory ?? [];
973
984
},
985
getBag ()
986
{
987
return {
988
slots: bag.inventory ?? [],
989
equipment: bag.equipment ?? null
990
};
991
},
974
992
getEquipment ()
975
993
{
976
994
return bag.equipment?.slots ?? bag.equipment ?? {};
@@ -28,7 +28,8 @@ export function initInventory ({28
contextMenu,28
contextMenu,29
resolveSpriteUrl,29
resolveSpriteUrl,30
getFriends,30
getFriends,31
getLocalName31
getLocalName,32
tipArrows = null32
})33
})33
{34
{34
const bagPanel = document.getElementById("bag-panel");35
const bagPanel = document.getElementById("bag-panel");@@ -379,10 +380,20 @@ export function initInventory ({379
}380
}380
if (slot.itemId === ItemId.potion && slot.instance?.kind === "potion")381
if (slot.itemId === ItemId.potion && slot.instance?.kind === "potion")381
{382
{382
items.push({383
if (tipArrows?.isArrowCoatingPotion?.(slot))383
label: "Drink",384
{384
onSelect: () => socket.send({ type: MessageType.drinkItem, slotIndex })385
items.push({385
});386
label: "Apply to arrows",387
onSelect: () => tipArrows.open(slotIndex)388
});389
}390
else391
{392
items.push({393
label: "Drink",394
onSelect: () => socket.send({ type: MessageType.drinkItem, slotIndex })395
});396
}386
}397
}387
items.push({398
items.push({388
label: "Drop",399
label: "Drop",@@ -971,6 +982,13 @@ export function initInventory ({971
{982
{972
return bag.inventory ?? [];983
return bag.inventory ?? [];973
},984
},985
getBag ()986
{987
return {988
slots: bag.inventory ?? [],989
equipment: bag.equipment ?? null990
};991
},974
getEquipment ()992
getEquipment ()975
{993
{976
return bag.equipment?.slots ?? bag.equipment ?? {};994
return bag.equipment?.slots ?? bag.equipment ?? {};@@ -14,6 +14,7 @@ import { initSkills } from "./skills.js";
14
14
import { initSpells } from "./spells.js";
15
15
import { initCrafting } from "./crafting.js";
16
16
import { initAlchemy } from "./alchemy.js";
17
import { initTipArrows } from "./tipArrows.js";
17
18
import { initStamina } from "./stamina.js";
18
19
import { initHealth } from "./health.js";
19
20
import { initStatusEffects } from "./statusEffects.js";
@@ -1347,10 +1348,19 @@ async function main ()
1347
1348
}
1348
1349
});
1349
1350
contextMenu = initContextMenu({ onSuppressWorldClick: consumeWorldClick });
1351
const tipArrows = initTipArrows({
1352
socket: { send (payload) { socket.send(payload); } },
1353
MessageType,
1354
getInventoryBag ()
1355
{
1356
return inventory?.getBag?.() ?? null;
1357
}
1358
});
1350
1359
inventory = initInventory({
1351
1360
socket: { send (payload) { socket.send(payload); } },
1352
1361
MessageType,
1353
1362
contextMenu,
1363
tipArrows,
1354
1364
resolveSpriteUrl (name)
1355
1365
{
1356
1366
return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;
@@ -14,6 +14,7 @@ import { initSkills } from "./skills.js";14
import { initSpells } from "./spells.js";14
import { initSpells } from "./spells.js";15
import { initCrafting } from "./crafting.js";15
import { initCrafting } from "./crafting.js";16
import { initAlchemy } from "./alchemy.js";16
import { initAlchemy } from "./alchemy.js";17
import { initTipArrows } from "./tipArrows.js";17
import { initStamina } from "./stamina.js";18
import { initStamina } from "./stamina.js";18
import { initHealth } from "./health.js";19
import { initHealth } from "./health.js";19
import { initStatusEffects } from "./statusEffects.js";20
import { initStatusEffects } from "./statusEffects.js";@@ -1347,10 +1348,19 @@ async function main ()1347
}1348
}1348
});1349
});1349
contextMenu = initContextMenu({ onSuppressWorldClick: consumeWorldClick });1350
contextMenu = initContextMenu({ onSuppressWorldClick: consumeWorldClick });1351
const tipArrows = initTipArrows({1352
socket: { send (payload) { socket.send(payload); } },1353
MessageType,1354
getInventoryBag ()1355
{1356
return inventory?.getBag?.() ?? null;1357
}1358
});1350
inventory = initInventory({1359
inventory = initInventory({1351
socket: { send (payload) { socket.send(payload); } },1360
socket: { send (payload) { socket.send(payload); } },1352
MessageType,1361
MessageType,1353
contextMenu,1362
contextMenu,1363
tipArrows,1354
resolveSpriteUrl (name)1364
resolveSpriteUrl (name)1355
{1365
{1356
return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;1366
return catalog?.images?.find((entry) => entry.name === name)?.url ?? null;@@ -0,0 +1,245 @@
1
import { ItemId, itemDefinition, itemDisplayName } from "/shared/definitions/items.js";
2
import { EquipmentKind } from "/shared/definitions/equipmentKinds.js";
3
import { ARROW_COATING_ARROWS_PER_USE, alchemyPotionDefinition } from "/shared/definitions/alchemy.js";
4
import { stackQuantity } from "/shared/items/inventory.js";
5
import { applyItemIcon } from "../render/potionIcon.js";
6
7
function coatingEffect (stack)
8
{
9
if (!stack || stack.itemId !== ItemId.potion || stack.instance?.kind !== "potion")
10
{ return null; }
11
if (stack.instance.effect?.type === "arrow-coating")
12
{ return stack.instance.effect; }
13
const def = alchemyPotionDefinition(stack.instance.potionKey);
14
return def?.effect?.type === "arrow-coating" ? def.effect : null;
15
}
16
17
/**
18
* Modal: apply arrow coating potion to untipped arrows in the bag.
19
*/
20
export function initTipArrows ({
21
socket,
22
MessageType,
23
getInventoryBag,
24
root = document.body
25
})
26
{
27
const backdrop = document.createElement("div");
28
backdrop.className = "modal-backdrop";
29
backdrop.hidden = true;
30
backdrop.id = "tip-arrows-backdrop";
31
32
const panel = document.createElement("div");
33
panel.id = "tip-arrows-panel";
34
panel.innerHTML = `
35
<h2>Apply to arrows</h2>
36
<p class="tip-arrows-hint"></p>
37
<div class="tip-arrows-row">
38
<div class="tip-arrows-slot" data-role="coating"></div>
39
<span class="tip-arrows-arrow">→</span>
40
<button type="button" class="tip-arrows-slot tip-arrows-pick" data-role="arrow" title="Choose arrows"></button>
41
</div>
42
<label class="tip-arrows-qty-label">Quantity
43
<input type="number" class="tip-arrows-qty" min="1" value="1" />
44
</label>
45
<p class="tip-arrows-capacity"></p>
46
<div class="tip-arrows-actions">
47
<button type="button" class="tip-arrows-apply">Apply</button>
48
<button type="button" class="tip-arrows-cancel">Cancel</button>
49
</div>
50
<div class="tip-arrows-picker" hidden></div>
51
`;
52
backdrop.append(panel);
53
root.append(backdrop);
54
55
const hintEl = panel.querySelector(".tip-arrows-hint");
56
const coatingEl = panel.querySelector('[data-role="coating"]');
57
const arrowEl = panel.querySelector('[data-role="arrow"]');
58
const qtyInput = panel.querySelector(".tip-arrows-qty");
59
const capacityEl = panel.querySelector(".tip-arrows-capacity");
60
const pickerEl = panel.querySelector(".tip-arrows-picker");
61
const applyBtn = panel.querySelector(".tip-arrows-apply");
62
const cancelBtn = panel.querySelector(".tip-arrows-cancel");
63
64
let coatingSlotIndex = -1;
65
let arrowSlotIndex = -1;
66
67
function bag ()
68
{
69
return getInventoryBag?.() ?? null;
70
}
71
72
function coatingStack ()
73
{
74
return bag()?.slots?.[coatingSlotIndex] ?? null;
75
}
76
77
function arrowStack ()
78
{
79
return bag()?.slots?.[arrowSlotIndex] ?? null;
80
}
81
82
function coatingCharges ()
83
{
84
const stack = coatingStack();
85
if (!stack)
86
{ return 0; }
87
const fill = Math.max(1, Math.min(5, stack.instance?.fillLevel | 0 || 4));
88
return stackQuantity(stack.quantity) * fill;
89
}
90
91
function maxTipWithCoating ()
92
{
93
return coatingCharges() * ARROW_COATING_ARROWS_PER_USE;
94
}
95
96
function maxTipForSelection ()
97
{
98
const arrows = arrowStack();
99
const arrowQty = arrows ? stackQuantity(arrows.quantity) : 0;
100
return Math.min(arrowQty, ARROW_COATING_ARROWS_PER_USE, maxTipWithCoating());
101
}
102
103
function renderSlot (el, stack)
104
{
105
el.replaceChildren();
106
if (!stack)
107
{
108
el.textContent = "+";
109
return;
110
}
111
const img = document.createElement("img");
112
img.alt = "";
113
applyItemIcon(img, stack);
114
el.append(img);
115
const qty = stackQuantity(stack.quantity);
116
if (qty > 1)
117
{
118
const span = document.createElement("span");
119
span.className = "qty";
120
span.textContent = String(qty);
121
el.append(span);
122
}
123
}
124
125
function refresh ()
126
{
127
const coating = coatingStack();
128
const name = coating?.instance?.displayName ?? "Coating";
129
hintEl.textContent = `${name} tips up to ${ARROW_COATING_ARROWS_PER_USE} arrows per use.`;
130
renderSlot(coatingEl, coating);
131
renderSlot(arrowEl, arrowStack());
132
const max = maxTipForSelection();
133
qtyInput.max = String(Math.max(1, max));
134
if ((qtyInput.value | 0) > max || (qtyInput.value | 0) < 1)
135
{ qtyInput.value = String(Math.max(1, max)); }
136
capacityEl.textContent = coating
137
? `This coating can tip up to ${maxTipWithCoating()} arrows in total.`
138
: "";
139
applyBtn.disabled = !coating || !arrowStack() || max <= 0;
140
}
141
142
function listUntippedArrowSlots ()
143
{
144
const slots = bag()?.slots ?? [];
145
const out = [];
146
for (let i = 0; i < slots.length; i++)
147
{
148
const slot = slots[i];
149
if (!slot)
150
{ continue; }
151
const def = itemDefinition(slot.itemId);
152
if (def?.equipment?.kind !== EquipmentKind.arrowAmmo)
153
{ continue; }
154
if (slot.instance?.kind === "tipped-arrow")
155
{ continue; }
156
out.push({ slotIndex: i, stack: slot });
157
}
158
return out;
159
}
160
161
function openPicker ()
162
{
163
pickerEl.hidden = false;
164
pickerEl.replaceChildren();
165
const options = listUntippedArrowSlots();
166
if (!options.length)
167
{
168
pickerEl.textContent = "No untipped arrows in your bag.";
169
return;
170
}
171
for (const opt of options)
172
{
173
const btn = document.createElement("button");
174
btn.type = "button";
175
btn.className = "tip-arrows-pick-option";
176
const img = document.createElement("img");
177
img.alt = "";
178
applyItemIcon(img, opt.stack);
179
btn.append(img);
180
const label = document.createElement("span");
181
label.textContent = `${itemDisplayName(opt.stack)} ×${stackQuantity(opt.stack.quantity)}`;
182
btn.append(label);
183
btn.addEventListener("click", () =>
184
{
185
arrowSlotIndex = opt.slotIndex;
186
pickerEl.hidden = true;
187
const max = maxTipForSelection();
188
qtyInput.value = String(Math.max(1, max));
189
refresh();
190
});
191
pickerEl.append(btn);
192
}
193
}
194
195
function close ()
196
{
197
backdrop.hidden = true;
198
pickerEl.hidden = true;
199
coatingSlotIndex = -1;
200
arrowSlotIndex = -1;
201
}
202
203
function open (slotIndex)
204
{
205
coatingSlotIndex = slotIndex | 0;
206
arrowSlotIndex = -1;
207
pickerEl.hidden = true;
208
backdrop.hidden = false;
209
qtyInput.value = "1";
210
refresh();
211
}
212
213
arrowEl.addEventListener("click", () => openPicker());
214
cancelBtn.addEventListener("click", () => close());
215
backdrop.addEventListener("click", (event) =>
216
{
217
if (event.target === backdrop)
218
{ close(); }
219
});
220
panel.addEventListener("click", (event) => event.stopPropagation());
221
applyBtn.addEventListener("click", () =>
222
{
223
const qty = Math.max(1, qtyInput.value | 0 || 1);
224
if (coatingSlotIndex < 0 || arrowSlotIndex < 0)
225
{ return; }
226
socket.send({
227
type: MessageType.tipArrows,
228
coatingSlotIndex,
229
arrowSlotIndex,
230
quantity: qty
231
});
232
close();
233
});
234
qtyInput.addEventListener("change", () => refresh());
235
236
return {
237
open,
238
close,
239
isOpen: () => !backdrop.hidden,
240
isArrowCoatingPotion (stack)
241
{
242
return !!coatingEffect(stack);
243
}
244
};
245
}
@@ -0,0 +1,245 @@1
import { ItemId, itemDefinition, itemDisplayName } from "/shared/definitions/items.js";2
import { EquipmentKind } from "/shared/definitions/equipmentKinds.js";3
import { ARROW_COATING_ARROWS_PER_USE, alchemyPotionDefinition } from "/shared/definitions/alchemy.js";4
import { stackQuantity } from "/shared/items/inventory.js";5
import { applyItemIcon } from "../render/potionIcon.js";6
7
function coatingEffect (stack)8
{9
if (!stack || stack.itemId !== ItemId.potion || stack.instance?.kind !== "potion")10
{ return null; }11
if (stack.instance.effect?.type === "arrow-coating")12
{ return stack.instance.effect; }13
const def = alchemyPotionDefinition(stack.instance.potionKey);14
return def?.effect?.type === "arrow-coating" ? def.effect : null;15
}16
17
/**18
* Modal: apply arrow coating potion to untipped arrows in the bag.19
*/20
export function initTipArrows ({21
socket,22
MessageType,23
getInventoryBag,24
root = document.body25
})26
{27
const backdrop = document.createElement("div");28
backdrop.className = "modal-backdrop";29
backdrop.hidden = true;30
backdrop.id = "tip-arrows-backdrop";31
32
const panel = document.createElement("div");33
panel.id = "tip-arrows-panel";34
panel.innerHTML = `35
<h2>Apply to arrows</h2>36
<p class="tip-arrows-hint"></p>37
<div class="tip-arrows-row">38
<div class="tip-arrows-slot" data-role="coating"></div>39
<span class="tip-arrows-arrow">→</span>40
<button type="button" class="tip-arrows-slot tip-arrows-pick" data-role="arrow" title="Choose arrows"></button>41
</div>42
<label class="tip-arrows-qty-label">Quantity43
<input type="number" class="tip-arrows-qty" min="1" value="1" />44
</label>45
<p class="tip-arrows-capacity"></p>46
<div class="tip-arrows-actions">47
<button type="button" class="tip-arrows-apply">Apply</button>48
<button type="button" class="tip-arrows-cancel">Cancel</button>49
</div>50
<div class="tip-arrows-picker" hidden></div>51
`;52
backdrop.append(panel);53
root.append(backdrop);54
55
const hintEl = panel.querySelector(".tip-arrows-hint");56
const coatingEl = panel.querySelector('[data-role="coating"]');57
const arrowEl = panel.querySelector('[data-role="arrow"]');58
const qtyInput = panel.querySelector(".tip-arrows-qty");59
const capacityEl = panel.querySelector(".tip-arrows-capacity");60
const pickerEl = panel.querySelector(".tip-arrows-picker");61
const applyBtn = panel.querySelector(".tip-arrows-apply");62
const cancelBtn = panel.querySelector(".tip-arrows-cancel");63
64
let coatingSlotIndex = -1;65
let arrowSlotIndex = -1;66
67
function bag ()68
{69
return getInventoryBag?.() ?? null;70
}71
72
function coatingStack ()73
{74
return bag()?.slots?.[coatingSlotIndex] ?? null;75
}76
77
function arrowStack ()78
{79
return bag()?.slots?.[arrowSlotIndex] ?? null;80
}81
82
function coatingCharges ()83
{84
const stack = coatingStack();85
if (!stack)86
{ return 0; }87
const fill = Math.max(1, Math.min(5, stack.instance?.fillLevel | 0 || 4));88
return stackQuantity(stack.quantity) * fill;89
}90
91
function maxTipWithCoating ()92
{93
return coatingCharges() * ARROW_COATING_ARROWS_PER_USE;94
}95
96
function maxTipForSelection ()97
{98
const arrows = arrowStack();99
const arrowQty = arrows ? stackQuantity(arrows.quantity) : 0;100
return Math.min(arrowQty, ARROW_COATING_ARROWS_PER_USE, maxTipWithCoating());101
}102
103
function renderSlot (el, stack)104
{105
el.replaceChildren();106
if (!stack)107
{108
el.textContent = "+";109
return;110
}111
const img = document.createElement("img");112
img.alt = "";113
applyItemIcon(img, stack);114
el.append(img);115
const qty = stackQuantity(stack.quantity);116
if (qty > 1)117
{118
const span = document.createElement("span");119
span.className = "qty";120
span.textContent = String(qty);121
el.append(span);122
}123
}124
125
function refresh ()126
{127
const coating = coatingStack();128
const name = coating?.instance?.displayName ?? "Coating";129
hintEl.textContent = `${name} tips up to ${ARROW_COATING_ARROWS_PER_USE} arrows per use.`;130
renderSlot(coatingEl, coating);131
renderSlot(arrowEl, arrowStack());132
const max = maxTipForSelection();133
qtyInput.max = String(Math.max(1, max));134
if ((qtyInput.value | 0) > max || (qtyInput.value | 0) < 1)135
{ qtyInput.value = String(Math.max(1, max)); }136
capacityEl.textContent = coating137
? `This coating can tip up to ${maxTipWithCoating()} arrows in total.`138
: "";139
applyBtn.disabled = !coating || !arrowStack() || max <= 0;140
}141
142
function listUntippedArrowSlots ()143
{144
const slots = bag()?.slots ?? [];145
const out = [];146
for (let i = 0; i < slots.length; i++)147
{148
const slot = slots[i];149
if (!slot)150
{ continue; }151
const def = itemDefinition(slot.itemId);152
if (def?.equipment?.kind !== EquipmentKind.arrowAmmo)153
{ continue; }154
if (slot.instance?.kind === "tipped-arrow")155
{ continue; }156
out.push({ slotIndex: i, stack: slot });157
}158
return out;159
}160
161
function openPicker ()162
{163
pickerEl.hidden = false;164
pickerEl.replaceChildren();165
const options = listUntippedArrowSlots();166
if (!options.length)167
{168
pickerEl.textContent = "No untipped arrows in your bag.";169
return;170
}171
for (const opt of options)172
{173
const btn = document.createElement("button");174
btn.type = "button";175
btn.className = "tip-arrows-pick-option";176
const img = document.createElement("img");177
img.alt = "";178
applyItemIcon(img, opt.stack);179
btn.append(img);180
const label = document.createElement("span");181
label.textContent = `${itemDisplayName(opt.stack)} ×${stackQuantity(opt.stack.quantity)}`;182
btn.append(label);183
btn.addEventListener("click", () =>184
{185
arrowSlotIndex = opt.slotIndex;186
pickerEl.hidden = true;187
const max = maxTipForSelection();188
qtyInput.value = String(Math.max(1, max));189
refresh();190
});191
pickerEl.append(btn);192
}193
}194
195
function close ()196
{197
backdrop.hidden = true;198
pickerEl.hidden = true;199
coatingSlotIndex = -1;200
arrowSlotIndex = -1;201
}202
203
function open (slotIndex)204
{205
coatingSlotIndex = slotIndex | 0;206
arrowSlotIndex = -1;207
pickerEl.hidden = true;208
backdrop.hidden = false;209
qtyInput.value = "1";210
refresh();211
}212
213
arrowEl.addEventListener("click", () => openPicker());214
cancelBtn.addEventListener("click", () => close());215
backdrop.addEventListener("click", (event) =>216
{217
if (event.target === backdrop)218
{ close(); }219
});220
panel.addEventListener("click", (event) => event.stopPropagation());221
applyBtn.addEventListener("click", () =>222
{223
const qty = Math.max(1, qtyInput.value | 0 || 1);224
if (coatingSlotIndex < 0 || arrowSlotIndex < 0)225
{ return; }226
socket.send({227
type: MessageType.tipArrows,228
coatingSlotIndex,229
arrowSlotIndex,230
quantity: qty231
});232
close();233
});234
qtyInput.addEventListener("change", () => refresh());235
236
return {237
open,238
close,239
isOpen: () => !backdrop.hidden,240
isArrowCoatingPotion (stack)241
{242
return !!coatingEffect(stack);243
}244
};245
}@@ -99,10 +99,11 @@ export async function tintedItemIconDataUrl (assetPath, tint)
99
99
return url;
100
100
}
101
101
102
/** Dual-channel arrow icon (red shaft + blue tip masks). */
102
/** Dual/triple-channel arrow icon (red shaft + blue tip + optional green coat). */
103
103
export async function dualTintedItemIconDataUrl (assetPath, dualTint)
104
104
{
105
const key = `dual|${assetPath}|${colorKey(dualTint.shaft)}|${colorKey(dualTint.tip)}`;
105
const coatKey = dualTint.coat ? colorKey(dualTint.coat) : "-";
106
const key = `dual|${assetPath}|${colorKey(dualTint.shaft)}|${colorKey(dualTint.tip)}|${coatKey}`;
106
107
if (urlCache.has(key))
107
108
{ return urlCache.get(key); }
108
109
const img = await loadImage(assetPath);
@@ -99,10 +99,11 @@ export async function tintedItemIconDataUrl (assetPath, tint)99
return url;99
return url;100
}100
}101
101
102
/** Dual-channel arrow icon (red shaft + blue tip masks). */102
/** Dual/triple-channel arrow icon (red shaft + blue tip + optional green coat). */103
export async function dualTintedItemIconDataUrl (assetPath, dualTint)103
export async function dualTintedItemIconDataUrl (assetPath, dualTint)104
{104
{105
const key = `dual|${assetPath}|${colorKey(dualTint.shaft)}|${colorKey(dualTint.tip)}`;105
const coatKey = dualTint.coat ? colorKey(dualTint.coat) : "-";106
const key = `dual|${assetPath}|${colorKey(dualTint.shaft)}|${colorKey(dualTint.tip)}|${coatKey}`;106
if (urlCache.has(key))107
if (urlCache.has(key))107
{ return urlCache.get(key); }108
{ return urlCache.get(key); }108
const img = await loadImage(assetPath);109
const img = await loadImage(assetPath);@@ -152,7 +152,8 @@ const TINT_LIT_SPRITE_FRAG = [
152
152
"}"
153
153
].join("\n");
154
154
155
/** Dual-channel tint: red = shaft/wood, blue = tip/string, white unchanged; then darkness. */
155
/** Dual/triple-channel tint: red = shaft, blue = tip, green = coat; then darkness.
156
* Equal non-dominant channels lighten the assigned tint toward white. */
156
157
const DUAL_TINT_LIT_SPRITE_FRAG = [
157
158
"precision mediump float;",
158
159
"varying vec2 v_texCoord;",
@@ -163,26 +164,36 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [
163
164
"uniform float u_spriteHeight;",
164
165
"uniform vec3 u_shaftTint;",
165
166
"uniform vec3 u_tipTint;",
167
"uniform vec3 u_coatTint;",
168
"uniform float u_hasCoat;",
169
"vec3 channelTint(float L, float o1, float o2, vec3 tint) {",
170
" float equal = step(abs(o1 - o2), 0.04);",
171
" float blend = L > 0.0 ? clamp(mix(min(o1, o2), o1, equal) / L, 0.0, 1.0) : 0.0;",
172
" float tintLuma = dot(tint, vec3(0.2126, 0.7152, 0.0722));",
173
" vec3 toward = mix(vec3(tintLuma), vec3(1.0), equal);",
174
" return mix(tint, toward, blend) * L;",
175
"}",
166
176
"void main() {",
167
177
" vec4 color = texture2D(u_texture, v_texCoord);",
168
178
" if (color.a <= 0.0) { discard; }",
169
179
" float fromBottom = (1.0 - v_texCoord.y) * max(u_spriteHeight, 1.0);",
170
180
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",
171
181
" vec3 rgb = color.rgb;",
182
" if (u_hasCoat > 0.5) {",
183
" float coatMask = clamp((color.g - max(color.r, color.b)) * 1.75, 0.0, 1.0);",
184
" if (coatMask > 0.0) {",
185
" vec3 coatCol = channelTint(color.g, color.r, color.b, u_coatTint);",
186
" rgb = mix(rgb, coatCol, coatMask);",
187
" }",
188
" }",
172
189
" float tipMask = clamp((color.b - max(color.r, color.g)) * 1.75, 0.0, 1.0);",
173
190
" if (tipMask > 0.0) {",
174
" float L = color.b;",
175
" float gBlend = L > 0.0 ? clamp(color.g / L, 0.0, 1.0) : 0.0;",
176
" float tipLuma = dot(u_tipTint, vec3(0.2126, 0.7152, 0.0722));",
177
" vec3 tipCol = mix(u_tipTint, vec3(tipLuma), gBlend) * L;",
191
" vec3 tipCol = channelTint(color.b, color.r, color.g, u_tipTint);",
178
192
" rgb = mix(rgb, tipCol, tipMask);",
179
193
" }",
180
194
" float shaftMask = clamp((color.r - max(color.g, color.b)) * 1.75, 0.0, 1.0);",
181
195
" if (shaftMask > 0.0) {",
182
" float L = color.r;",
183
" float gBlend = L > 0.0 ? clamp(color.g / L, 0.0, 1.0) : 0.0;",
184
" float shaftLuma = dot(u_shaftTint, vec3(0.2126, 0.7152, 0.0722));",
185
" vec3 shaftCol = mix(u_shaftTint, vec3(shaftLuma), gBlend) * L;",
196
" vec3 shaftCol = channelTint(color.r, color.g, color.b, u_shaftTint);",
186
197
" rgb = mix(rgb, shaftCol, shaftMask);",
187
198
" }",
188
199
" if (u_wade > 0.5 && fromBottom < 5.0) {",
@@ -983,6 +994,7 @@ export class WorldView
983
994
{
984
995
const shaft = normalizeRgb(dualTint.shaft);
985
996
const tip = normalizeRgb(dualTint.tip);
997
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;
986
998
shader = getDualTintLitSpriteShader();
987
999
uniforms = {
988
1000
u_darkness: 0,
@@ -990,7 +1002,9 @@ export class WorldView
990
1002
u_wade: 0,
991
1003
u_spriteHeight: height,
992
1004
u_shaftTint: [shaft.r, shaft.g, shaft.b],
993
u_tipTint: [tip.r, tip.g, tip.b]
1005
u_tipTint: [tip.r, tip.g, tip.b],
1006
u_coatTint: coat ? [coat.r, coat.g, coat.b] : [0, 0, 0],
1007
u_hasCoat: coat ? 1 : 0
994
1008
};
995
1009
}
996
1010
else if (tightFit && bodyHtml && maskUniforms)
@@ -2079,6 +2093,8 @@ export class WorldView
2079
2093
entity.object.renderer.sprite = this.game.images[base];
2080
2094
this.#startIdleAnimation(entity.object);
2081
2095
}
2096
entity.bodyTint = layers[0]?.tint ? normalizeRgb(layers[0].tint) : null;
2097
entity.bloomBody = !!layers[0]?.bloomBody;
2082
2098
for (const overlay of entity.overlays ?? [])
2083
2099
{ overlay.destroy(); }
2084
2100
for (const overlay of entity.bloomOverlays ?? [])
@@ -2088,6 +2104,21 @@ export class WorldView
2088
2104
entity.overlayDualTints = [];
2089
2105
entity.overlayTightFit = [];
2090
2106
entity.bloomOverlays = [];
2107
entity.bloomOverlayTints = [];
2108
if (entity.bloomBody && this.game.images[base])
2109
{
2110
const bloomName = bloomCompanionName(base);
2111
const bloomImage = this.game.images[bloomName] ?? this.game.images[base];
2112
if (bloomImage)
2113
{
2114
const bloom = new GameObject(0, 0, bloomImage, SORT_ENTITY);
2115
bloom.renderer.layer = RENDER_LAYER_BLOOM;
2116
this.#markUnlit(bloom);
2117
this.scene.addObject(bloom);
2118
entity.bloomOverlays.push(bloom);
2119
entity.bloomOverlayTints.push(entity.bodyTint);
2120
}
2121
}
2091
2122
for (const layer of layers.slice(1))
2092
2123
{
2093
2124
const image = this.game.images[layer.sprite];
@@ -2118,6 +2149,9 @@ export class WorldView
2118
2149
this.#markUnlit(bloom);
2119
2150
this.scene.addObject(bloom);
2120
2151
entity.bloomOverlays.push(bloom);
2152
entity.bloomOverlayTints.push(
2153
layer.tint ? normalizeRgb(layer.tint) : null
2154
);
2121
2155
}
2122
2156
}
2123
2157
@@ -2143,7 +2177,7 @@ export class WorldView
2143
2177
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);
2144
2178
2145
2179
entity.object.transform.rotation = walkTilt;
2146
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade);
2180
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null);
2147
2181
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1);
2148
2182
for (let index = 0; index < (entity.overlays ?? []).length; index++)
2149
2183
{
@@ -2172,13 +2206,20 @@ export class WorldView
2172
2206
}
2173
2207
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1);
2174
2208
}
2175
for (const overlay of entity.bloomOverlays ?? [])
2209
for (let index = 0; index < (entity.bloomOverlays ?? []).length; index++)
2176
2210
{
2211
const overlay = entity.bloomOverlays[index];
2177
2212
this.#setRendererVisible(overlay, this.bloomEnabled);
2178
2213
if (!this.bloomEnabled)
2179
2214
{ continue; }
2180
2215
overlay.transform.rotation = walkTilt;
2181
this.#syncLitSprite(overlay, tileShade, flashStrength, wade);
2216
this.#syncLitSprite(
2217
overlay,
2218
tileShade,
2219
flashStrength,
2220
wade,
2221
entity.bloomOverlayTints?.[index] ?? entity.bodyTint ?? null
2222
);
2182
2223
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1);
2183
2224
}
2184
2225
this.#placeHpBar(entity, pivotX, pivotY);
@@ -2305,6 +2346,7 @@ export class WorldView
2305
2346
object._lit = true;
2306
2347
const shaft = normalizeRgb(dualTint.shaft);
2307
2348
const tip = normalizeRgb(dualTint.tip);
2349
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;
2308
2350
const dark = Math.min(1, Math.max(0, darkness ?? 0));
2309
2351
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));
2310
2352
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;
@@ -2315,7 +2357,9 @@ export class WorldView
2315
2357
u_wade: wade ? 1 : 0,
2316
2358
u_spriteHeight: height,
2317
2359
u_shaftTint: [shaft.r, shaft.g, shaft.b],
2318
u_tipTint: [tip.r, tip.g, tip.b]
2360
u_tipTint: [tip.r, tip.g, tip.b],
2361
u_coatTint: coat ? [coat.r, coat.g, coat.b] : [0, 0, 0],
2362
u_hasCoat: coat ? 1 : 0
2319
2363
};
2320
2364
object.renderer.secondaryMap = null;
2321
2365
}
@@ -2485,7 +2529,11 @@ export class WorldView
2485
2529
{
2486
2530
if (!payload?.shaftTint || !payload?.tipTint)
2487
2531
{ return null; }
2488
return { shaft: payload.shaftTint, tip: payload.tipTint };
2532
return {
2533
shaft: payload.shaftTint,
2534
tip: payload.tipTint,
2535
...(payload.coatTint ? { coat: payload.coatTint } : {})
2536
};
2489
2537
}
2490
2538
2491
2539
#syncHpBar (entity)
@@ -152,7 +152,8 @@ const TINT_LIT_SPRITE_FRAG = [152
"}"152
"}"153
].join("\n");153
].join("\n");154
154
155
/** Dual-channel tint: red = shaft/wood, blue = tip/string, white unchanged; then darkness. */155
/** Dual/triple-channel tint: red = shaft, blue = tip, green = coat; then darkness.156
* Equal non-dominant channels lighten the assigned tint toward white. */156
const DUAL_TINT_LIT_SPRITE_FRAG = [157
const DUAL_TINT_LIT_SPRITE_FRAG = [157
"precision mediump float;",158
"precision mediump float;",158
"varying vec2 v_texCoord;",159
"varying vec2 v_texCoord;",@@ -163,26 +164,36 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [163
"uniform float u_spriteHeight;",164
"uniform float u_spriteHeight;",164
"uniform vec3 u_shaftTint;",165
"uniform vec3 u_shaftTint;",165
"uniform vec3 u_tipTint;",166
"uniform vec3 u_tipTint;",167
"uniform vec3 u_coatTint;",168
"uniform float u_hasCoat;",169
"vec3 channelTint(float L, float o1, float o2, vec3 tint) {",170
" float equal = step(abs(o1 - o2), 0.04);",171
" float blend = L > 0.0 ? clamp(mix(min(o1, o2), o1, equal) / L, 0.0, 1.0) : 0.0;",172
" float tintLuma = dot(tint, vec3(0.2126, 0.7152, 0.0722));",173
" vec3 toward = mix(vec3(tintLuma), vec3(1.0), equal);",174
" return mix(tint, toward, blend) * L;",175
"}",166
"void main() {",176
"void main() {",167
" vec4 color = texture2D(u_texture, v_texCoord);",177
" vec4 color = texture2D(u_texture, v_texCoord);",168
" if (color.a <= 0.0) { discard; }",178
" if (color.a <= 0.0) { discard; }",169
" float fromBottom = (1.0 - v_texCoord.y) * max(u_spriteHeight, 1.0);",179
" float fromBottom = (1.0 - v_texCoord.y) * max(u_spriteHeight, 1.0);",170
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",180
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",171
" vec3 rgb = color.rgb;",181
" vec3 rgb = color.rgb;",182
" if (u_hasCoat > 0.5) {",183
" float coatMask = clamp((color.g - max(color.r, color.b)) * 1.75, 0.0, 1.0);",184
" if (coatMask > 0.0) {",185
" vec3 coatCol = channelTint(color.g, color.r, color.b, u_coatTint);",186
" rgb = mix(rgb, coatCol, coatMask);",187
" }",188
" }",172
" float tipMask = clamp((color.b - max(color.r, color.g)) * 1.75, 0.0, 1.0);",189
" float tipMask = clamp((color.b - max(color.r, color.g)) * 1.75, 0.0, 1.0);",173
" if (tipMask > 0.0) {",190
" if (tipMask > 0.0) {",174
" float L = color.b;",191
" vec3 tipCol = channelTint(color.b, color.r, color.g, u_tipTint);",175
" float gBlend = L > 0.0 ? clamp(color.g / L, 0.0, 1.0) : 0.0;",176
" float tipLuma = dot(u_tipTint, vec3(0.2126, 0.7152, 0.0722));",177
" vec3 tipCol = mix(u_tipTint, vec3(tipLuma), gBlend) * L;",178
" rgb = mix(rgb, tipCol, tipMask);",192
" rgb = mix(rgb, tipCol, tipMask);",179
" }",193
" }",180
" float shaftMask = clamp((color.r - max(color.g, color.b)) * 1.75, 0.0, 1.0);",194
" float shaftMask = clamp((color.r - max(color.g, color.b)) * 1.75, 0.0, 1.0);",181
" if (shaftMask > 0.0) {",195
" if (shaftMask > 0.0) {",182
" float L = color.r;",196
" vec3 shaftCol = channelTint(color.r, color.g, color.b, u_shaftTint);",183
" float gBlend = L > 0.0 ? clamp(color.g / L, 0.0, 1.0) : 0.0;",184
" float shaftLuma = dot(u_shaftTint, vec3(0.2126, 0.7152, 0.0722));",185
" vec3 shaftCol = mix(u_shaftTint, vec3(shaftLuma), gBlend) * L;",186
" rgb = mix(rgb, shaftCol, shaftMask);",197
" rgb = mix(rgb, shaftCol, shaftMask);",187
" }",198
" }",188
" if (u_wade > 0.5 && fromBottom < 5.0) {",199
" if (u_wade > 0.5 && fromBottom < 5.0) {",@@ -983,6 +994,7 @@ export class WorldView983
{994
{984
const shaft = normalizeRgb(dualTint.shaft);995
const shaft = normalizeRgb(dualTint.shaft);985
const tip = normalizeRgb(dualTint.tip);996
const tip = normalizeRgb(dualTint.tip);997
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;986
shader = getDualTintLitSpriteShader();998
shader = getDualTintLitSpriteShader();987
uniforms = {999
uniforms = {988
u_darkness: 0,1000
u_darkness: 0,@@ -990,7 +1002,9 @@ export class WorldView990
u_wade: 0,1002
u_wade: 0,991
u_spriteHeight: height,1003
u_spriteHeight: height,992
u_shaftTint: [shaft.r, shaft.g, shaft.b],1004
u_shaftTint: [shaft.r, shaft.g, shaft.b],993
u_tipTint: [tip.r, tip.g, tip.b]1005
u_tipTint: [tip.r, tip.g, tip.b],1006
u_coatTint: coat ? [coat.r, coat.g, coat.b] : [0, 0, 0],1007
u_hasCoat: coat ? 1 : 0994
};1008
};995
}1009
}996
else if (tightFit && bodyHtml && maskUniforms)1010
else if (tightFit && bodyHtml && maskUniforms)@@ -2079,6 +2093,8 @@ export class WorldView2079
entity.object.renderer.sprite = this.game.images[base];2093
entity.object.renderer.sprite = this.game.images[base];2080
this.#startIdleAnimation(entity.object);2094
this.#startIdleAnimation(entity.object);2081
}2095
}2096
entity.bodyTint = layers[0]?.tint ? normalizeRgb(layers[0].tint) : null;2097
entity.bloomBody = !!layers[0]?.bloomBody;2082
for (const overlay of entity.overlays ?? [])2098
for (const overlay of entity.overlays ?? [])2083
{ overlay.destroy(); }2099
{ overlay.destroy(); }2084
for (const overlay of entity.bloomOverlays ?? [])2100
for (const overlay of entity.bloomOverlays ?? [])@@ -2088,6 +2104,21 @@ export class WorldView2088
entity.overlayDualTints = [];2104
entity.overlayDualTints = [];2089
entity.overlayTightFit = [];2105
entity.overlayTightFit = [];2090
entity.bloomOverlays = [];2106
entity.bloomOverlays = [];2107
entity.bloomOverlayTints = [];2108
if (entity.bloomBody && this.game.images[base])2109
{2110
const bloomName = bloomCompanionName(base);2111
const bloomImage = this.game.images[bloomName] ?? this.game.images[base];2112
if (bloomImage)2113
{2114
const bloom = new GameObject(0, 0, bloomImage, SORT_ENTITY);2115
bloom.renderer.layer = RENDER_LAYER_BLOOM;2116
this.#markUnlit(bloom);2117
this.scene.addObject(bloom);2118
entity.bloomOverlays.push(bloom);2119
entity.bloomOverlayTints.push(entity.bodyTint);2120
}2121
}2091
for (const layer of layers.slice(1))2122
for (const layer of layers.slice(1))2092
{2123
{2093
const image = this.game.images[layer.sprite];2124
const image = this.game.images[layer.sprite];@@ -2118,6 +2149,9 @@ export class WorldView2118
this.#markUnlit(bloom);2149
this.#markUnlit(bloom);2119
this.scene.addObject(bloom);2150
this.scene.addObject(bloom);2120
entity.bloomOverlays.push(bloom);2151
entity.bloomOverlays.push(bloom);2152
entity.bloomOverlayTints.push(2153
layer.tint ? normalizeRgb(layer.tint) : null2154
);2121
}2155
}2122
}2156
}2123
2157
@@ -2143,7 +2177,7 @@ export class WorldView2143
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);2177
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);2144
2178
2145
entity.object.transform.rotation = walkTilt;2179
entity.object.transform.rotation = walkTilt;2146
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade);2180
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null);2147
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1);2181
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1);2148
for (let index = 0; index < (entity.overlays ?? []).length; index++)2182
for (let index = 0; index < (entity.overlays ?? []).length; index++)2149
{2183
{@@ -2172,13 +2206,20 @@ export class WorldView2172
}2206
}2173
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1);2207
this.#placePivoted(overlay, pivotX, pivotY, overlaySortY, SORT_ENTITY, entity.visualScale ?? 1);2174
}2208
}2175
for (const overlay of entity.bloomOverlays ?? [])2209
for (let index = 0; index < (entity.bloomOverlays ?? []).length; index++)2176
{2210
{2211
const overlay = entity.bloomOverlays[index];2177
this.#setRendererVisible(overlay, this.bloomEnabled);2212
this.#setRendererVisible(overlay, this.bloomEnabled);2178
if (!this.bloomEnabled)2213
if (!this.bloomEnabled)2179
{ continue; }2214
{ continue; }2180
overlay.transform.rotation = walkTilt;2215
overlay.transform.rotation = walkTilt;2181
this.#syncLitSprite(overlay, tileShade, flashStrength, wade);2216
this.#syncLitSprite(2217
overlay,2218
tileShade,2219
flashStrength,2220
wade,2221
entity.bloomOverlayTints?.[index] ?? entity.bodyTint ?? null2222
);2182
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1);2223
this.#placePivoted(overlay, pivotX, pivotY, pivotY + 0.002, SORT_ENTITY, entity.visualScale ?? 1);2183
}2224
}2184
this.#placeHpBar(entity, pivotX, pivotY);2225
this.#placeHpBar(entity, pivotX, pivotY);@@ -2305,6 +2346,7 @@ export class WorldView2305
object._lit = true;2346
object._lit = true;2306
const shaft = normalizeRgb(dualTint.shaft);2347
const shaft = normalizeRgb(dualTint.shaft);2307
const tip = normalizeRgb(dualTint.tip);2348
const tip = normalizeRgb(dualTint.tip);2349
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;2308
const dark = Math.min(1, Math.max(0, darkness ?? 0));2350
const dark = Math.min(1, Math.max(0, darkness ?? 0));2309
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));2351
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));2310
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;2352
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;@@ -2315,7 +2357,9 @@ export class WorldView2315
u_wade: wade ? 1 : 0,2357
u_wade: wade ? 1 : 0,2316
u_spriteHeight: height,2358
u_spriteHeight: height,2317
u_shaftTint: [shaft.r, shaft.g, shaft.b],2359
u_shaftTint: [shaft.r, shaft.g, shaft.b],2318
u_tipTint: [tip.r, tip.g, tip.b]2360
u_tipTint: [tip.r, tip.g, tip.b],2361
u_coatTint: coat ? [coat.r, coat.g, coat.b] : [0, 0, 0],2362
u_hasCoat: coat ? 1 : 02319
};2363
};2320
object.renderer.secondaryMap = null;2364
object.renderer.secondaryMap = null;2321
}2365
}@@ -2485,7 +2529,11 @@ export class WorldView2485
{2529
{2486
if (!payload?.shaftTint || !payload?.tipTint)2530
if (!payload?.shaftTint || !payload?.tipTint)2487
{ return null; }2531
{ return null; }2488
return { shaft: payload.shaftTint, tip: payload.tipTint };2532
return {2533
shaft: payload.shaftTint,2534
tip: payload.tipTint,2535
...(payload.coatTint ? { coat: payload.coatTint } : {})2536
};2489
}2537
}2490
2538
2491
#syncHpBar (entity)2539
#syncHpBar (entity)@@ -1345,6 +1345,125 @@ button.friend-account-name:hover {
1345
1345
display: none !important;
1346
1346
}
1347
1347
1348
#tip-arrows-panel {
1349
position: fixed;
1350
z-index: 6;
1351
top: 50%;
1352
left: 50%;
1353
transform: translate(-50%, -50%);
1354
width: min(360px, 92vw);
1355
padding: 1rem 1.1rem 1.1rem;
1356
background: #1a1e26;
1357
border: 1px solid #2c3340;
1358
border-radius: 6px;
1359
color: #d6dbe4;
1360
}
1361
1362
#tip-arrows-panel h2 {
1363
margin: 0 0 0.35rem;
1364
font-size: 1.05rem;
1365
}
1366
1367
.tip-arrows-hint,
1368
.tip-arrows-capacity {
1369
margin: 0.25rem 0 0.75rem;
1370
font-size: 0.85rem;
1371
opacity: 0.85;
1372
}
1373
1374
.tip-arrows-row {
1375
display: flex;
1376
align-items: center;
1377
justify-content: center;
1378
gap: 0.75rem;
1379
margin: 0.75rem 0;
1380
}
1381
1382
.tip-arrows-slot {
1383
position: relative;
1384
width: 48px;
1385
height: 48px;
1386
border: 1px solid #3a4454;
1387
background: #12161d;
1388
display: grid;
1389
place-items: center;
1390
padding: 0;
1391
color: #8a94a6;
1392
cursor: default;
1393
}
1394
1395
.tip-arrows-slot img {
1396
width: 40px;
1397
height: 40px;
1398
object-fit: contain;
1399
image-rendering: pixelated;
1400
}
1401
1402
.tip-arrows-slot .qty {
1403
position: absolute;
1404
right: 2px;
1405
bottom: 1px;
1406
font-size: 0.7rem;
1407
}
1408
1409
.tip-arrows-pick {
1410
cursor: pointer;
1411
}
1412
1413
.tip-arrows-arrow {
1414
opacity: 0.6;
1415
}
1416
1417
.tip-arrows-qty-label {
1418
display: flex;
1419
flex-direction: column;
1420
gap: 0.25rem;
1421
font-size: 0.85rem;
1422
margin-bottom: 0.5rem;
1423
}
1424
1425
.tip-arrows-qty {
1426
width: 6rem;
1427
padding: 0.25rem 0.4rem;
1428
background: #12161d;
1429
border: 1px solid #3a4454;
1430
color: inherit;
1431
}
1432
1433
.tip-arrows-actions {
1434
display: flex;
1435
gap: 0.5rem;
1436
margin-top: 0.75rem;
1437
}
1438
1439
.tip-arrows-picker {
1440
margin-top: 0.75rem;
1441
max-height: 180px;
1442
overflow: auto;
1443
display: flex;
1444
flex-direction: column;
1445
gap: 0.35rem;
1446
}
1447
1448
.tip-arrows-pick-option {
1449
display: flex;
1450
align-items: center;
1451
gap: 0.5rem;
1452
padding: 0.35rem 0.5rem;
1453
background: #12161d;
1454
border: 1px solid #2c3340;
1455
color: inherit;
1456
cursor: pointer;
1457
text-align: left;
1458
}
1459
1460
.tip-arrows-pick-option img {
1461
width: 28px;
1462
height: 28px;
1463
object-fit: contain;
1464
image-rendering: pixelated;
1465
}
1466
1348
1467
.send-item {
1349
1468
display: flex;
1350
1469
align-items: center;
@@ -1345,6 +1345,125 @@ button.friend-account-name:hover {1345
display: none !important;1345
display: none !important;1346
}1346
}1347
1347
1348
#tip-arrows-panel {1349
position: fixed;1350
z-index: 6;1351
top: 50%;1352
left: 50%;1353
transform: translate(-50%, -50%);1354
width: min(360px, 92vw);1355
padding: 1rem 1.1rem 1.1rem;1356
background: #1a1e26;1357
border: 1px solid #2c3340;1358
border-radius: 6px;1359
color: #d6dbe4;1360
}1361
1362
#tip-arrows-panel h2 {1363
margin: 0 0 0.35rem;1364
font-size: 1.05rem;1365
}1366
1367
.tip-arrows-hint,1368
.tip-arrows-capacity {1369
margin: 0.25rem 0 0.75rem;1370
font-size: 0.85rem;1371
opacity: 0.85;1372
}1373
1374
.tip-arrows-row {1375
display: flex;1376
align-items: center;1377
justify-content: center;1378
gap: 0.75rem;1379
margin: 0.75rem 0;1380
}1381
1382
.tip-arrows-slot {1383
position: relative;1384
width: 48px;1385
height: 48px;1386
border: 1px solid #3a4454;1387
background: #12161d;1388
display: grid;1389
place-items: center;1390
padding: 0;1391
color: #8a94a6;1392
cursor: default;1393
}1394
1395
.tip-arrows-slot img {1396
width: 40px;1397
height: 40px;1398
object-fit: contain;1399
image-rendering: pixelated;1400
}1401
1402
.tip-arrows-slot .qty {1403
position: absolute;1404
right: 2px;1405
bottom: 1px;1406
font-size: 0.7rem;1407
}1408
1409
.tip-arrows-pick {1410
cursor: pointer;1411
}1412
1413
.tip-arrows-arrow {1414
opacity: 0.6;1415
}1416
1417
.tip-arrows-qty-label {1418
display: flex;1419
flex-direction: column;1420
gap: 0.25rem;1421
font-size: 0.85rem;1422
margin-bottom: 0.5rem;1423
}1424
1425
.tip-arrows-qty {1426
width: 6rem;1427
padding: 0.25rem 0.4rem;1428
background: #12161d;1429
border: 1px solid #3a4454;1430
color: inherit;1431
}1432
1433
.tip-arrows-actions {1434
display: flex;1435
gap: 0.5rem;1436
margin-top: 0.75rem;1437
}1438
1439
.tip-arrows-picker {1440
margin-top: 0.75rem;1441
max-height: 180px;1442
overflow: auto;1443
display: flex;1444
flex-direction: column;1445
gap: 0.35rem;1446
}1447
1448
.tip-arrows-pick-option {1449
display: flex;1450
align-items: center;1451
gap: 0.5rem;1452
padding: 0.35rem 0.5rem;1453
background: #12161d;1454
border: 1px solid #2c3340;1455
color: inherit;1456
cursor: pointer;1457
text-align: left;1458
}1459
1460
.tip-arrows-pick-option img {1461
width: 28px;1462
height: 28px;1463
object-fit: contain;1464
image-rendering: pixelated;1465
}1466
1348
.send-item {1467
.send-item {1349
display: flex;1468
display: flex;1350
align-items: center;1469
align-items: center;@@ -13,6 +13,8 @@ import
13
13
} from "../../../shared/definitions/mobCombat.js";
14
14
import { spellDefinition } from "../../../shared/definitions/spells.js";
15
15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";
16
import { mobDamageAffinities } from "../../../shared/combat/magic.js";
17
import { AttackType } from "../../../shared/definitions/attackTypes.js";
16
18
import
17
19
{
18
20
effectiveHitSkillInDarkness,
@@ -42,6 +44,7 @@ import { tileToChunk } from "../world/coordinates.js";
42
44
import { stackQuantity } from "../../../shared/items/inventory.js";
43
45
import { addGroundItem, publicGroundItem } from "../items/bags.js";
44
46
import { resolveItemDualTint } from "../../../shared/render/tint.js";
47
import { essenceItemIdForElement } from "../../../shared/definitions/essenceItems.js";
45
48
import { castMobAttackSpell } from "../spells/mobCast.js";
46
49
import { attachOrigins, lootOrigin } from "../../../shared/items/origin.js";
47
50
import { scheduleSpawnerRespawn } from "../simulation/spawners.js";
@@ -219,6 +222,18 @@ function arrowStackInOffhand (equipment)
219
222
return stack;
220
223
}
221
224
225
/** Physical attack type, or tipped-arrow magic element when present. */
226
function resolveAttackDamageType (ecs, attackerHandle, profile)
227
{
228
if (attackerHandle != null && profile?.mode === "ranged")
229
{
230
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));
231
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)
232
{ return stack.instance.element; }
233
}
234
return profile?.attackType ?? AttackType.blunt;
235
}
236
222
237
function consumeArrow (ecs, handle)
223
238
{
224
239
const equipment = ecs.get(handle, Component.equipment);
@@ -267,6 +282,12 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
267
282
...(def?.drops ?? []),
268
283
...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])
269
284
];
285
if (creature.element && (def?.essenceDropChance ?? 0) > 0)
286
{
287
const essenceId = essenceItemIdForElement(creature.element);
288
if (essenceId)
289
{ dropTable.push({ itemId: essenceId, chance: def.essenceDropChance }); }
290
}
270
291
for (const drop of dropTable)
271
292
{
272
293
if (Math.random() > (drop.chance ?? 1))
@@ -327,13 +348,23 @@ function projectileDualTintFromAttacker (ecs, handle)
327
348
return resolveItemDualTint(stack, itemDefinition(stack.itemId));
328
349
}
329
350
351
function projectileSpriteFromAttacker (ecs, handle)
352
{
353
const equipment = ecs.get(handle, Component.equipment);
354
const stack = arrowStackInOffhand(equipment);
355
if (stack?.instance?.kind === "tipped-arrow")
356
{ return "fx:projectile:arrow-tipped"; }
357
return "fx:projectile:arrow";
358
}
359
330
360
function publicDualTint (dualTint)
331
361
{
332
362
if (!dualTint)
333
363
{ return null; }
334
364
return {
335
365
shaftTint: dualTint.shaft,
336
tipTint: dualTint.tip
366
tipTint: dualTint.tip,
367
...(dualTint.coat ? { coatTint: dualTint.coat } : {})
337
368
};
338
369
}
339
370
@@ -543,7 +574,9 @@ export function stepCombat (world, now = Date.now())
543
574
&& dist === 1
544
575
&& world.isClearStanding?.(entity.entityId, entity.position.tileX, entity.position.tileY);
545
576
const attackSpells = isCreature ? eligibleMobAttackSpells(world.ecs, entity.handle) : [];
546
const shouldCast = isCreature && attackSpells.length > 0 && (isStaff || !canSwing);
577
const preferSpell = isCreature
578
&& !!mobDefinition(world.ecs.get(entity.handle, Component.creature)?.mobTypeId)?.preferSpellAttack;
579
const shouldCast = isCreature && attackSpells.length > 0 && (isStaff || !canSwing || preferSpell);
547
580
548
581
if (shouldCast)
549
582
{
@@ -871,9 +904,20 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D
871
904
{ return events; }
872
905
const isCreature = !!world.ecs.get(attackerHandle, Component.creature)
873
906
&& !world.ecs.get(attackerHandle, Component.character);
907
const arrowTint = projectileDualTintFromAttacker(world.ecs, attackerHandle);
908
const arrowSprite = projectileSpriteFromAttacker(world.ecs, attackerHandle);
909
const tipElement = (() =>
910
{
911
const stack = arrowStackInOffhand(world.ecs.get(attackerHandle, Component.equipment));
912
return stack?.instance?.kind === "tipped-arrow" ? stack.instance.element : null;
913
})();
874
914
if (!isCreature && !consumeArrow(world.ecs, attackerHandle))
875
915
{ return events; }
876
916
917
const shotProfile = tipElement
918
? { ...profile, attackType: tipElement }
919
: profile;
920
877
921
const snapshot = { tileX: targetPos.tileX, tileY: targetPos.tileY };
878
922
const target = resolveCombatTarget(world, targetId);
879
923
if (!target)
@@ -885,15 +929,16 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D
885
929
type: "remote-ranged-resolve",
886
930
attackerId,
887
931
targetId,
888
profile,
889
attackerLevels: attackerCombatLevels(world.ecs, attackerHandle, profile, world.settings),
932
profile: shotProfile,
933
attackerLevels: attackerCombatLevels(world.ecs, attackerHandle, shotProfile, world.settings),
890
934
attackerIsPlayer: !!world.ecs.get(attackerHandle, Component.character),
891
935
now,
892
936
tileX: snapshot.tileX,
893
937
tileY: snapshot.tileY,
894
938
fromTileX: from.tileX,
895
939
fromTileY: from.tileY,
896
...(publicDualTint(projectileDualTintFromAttacker(world.ecs, attackerHandle)) ?? {})
940
sprite: arrowSprite,
941
...(publicDualTint(arrowTint) ?? {})
897
942
});
898
943
return events;
899
944
}
@@ -904,7 +949,7 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D
904
949
targetId,
905
950
attackerHandle,
906
951
target.handle,
907
profile,
952
shotProfile,
908
953
now,
909
954
snapshot
910
955
);
@@ -937,7 +982,8 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D
937
982
tileY: endY,
938
983
durationMs: RANGED_PROJECTILE_MS,
939
984
trackTarget: outcome?.type !== "combat-miss",
940
...(publicDualTint(projectileDualTintFromAttacker(world.ecs, attackerHandle)) ?? {})
985
sprite: arrowSprite,
986
...(publicDualTint(arrowTint) ?? {})
941
987
});
942
988
return events.concat(hitEvents);
943
989
}
@@ -1132,8 +1178,10 @@ export function applyRemoteRangedShot (world, payload)
1132
1178
tileY: endY,
1133
1179
durationMs: RANGED_PROJECTILE_MS,
1134
1180
trackTarget: outcome?.type !== "combat-miss",
1181
sprite: payload.sprite ?? "fx:projectile:arrow",
1135
1182
shaftTint: payload.shaftTint ?? null,
1136
tipTint: payload.tipTint ?? null
1183
tipTint: payload.tipTint ?? null,
1184
coatTint: payload.coatTint ?? null
1137
1185
}, ...hitEvents];
1138
1186
1139
1187
const forwards = [];
@@ -1250,6 +1298,11 @@ function applyLocalMeleeHit (
1250
1298
world.settings
1251
1299
);
1252
1300
1301
const attackType = resolveAttackDamageType(world.ecs, attackerHandle, profile);
1302
const targetCreature = world.ecs.get(targetHandle, Component.creature);
1303
const targetAffinities = targetCreature
1304
? mobDamageAffinities(mobDefinition(targetCreature.mobTypeId))
1305
: {};
1253
1306
const resolved = resolvePhysicalAttack({
1254
1307
hitSkillLevel: effectiveHitSkillInDarkness(
1255
1308
attackerLevels.hitLevel,
@@ -1257,7 +1310,9 @@ function applyLocalMeleeHit (
1257
1310
),
1258
1311
agilitySkillLevel: agilityLevel,
1259
1312
damageSkillLevel: attackerLevels.damageLevel,
1260
defenceSkillLevel: defenceLevel
1313
defenceSkillLevel: defenceLevel,
1314
attackType,
1315
targetAffinities
1261
1316
});
1262
1317
1263
1318
if (resolved.outcome === "miss")
@@ -13,6 +13,8 @@ import13
} from "../../../shared/definitions/mobCombat.js";13
} from "../../../shared/definitions/mobCombat.js";14
import { spellDefinition } from "../../../shared/definitions/spells.js";14
import { spellDefinition } from "../../../shared/definitions/spells.js";15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";16
import { mobDamageAffinities } from "../../../shared/combat/magic.js";17
import { AttackType } from "../../../shared/definitions/attackTypes.js";16
import18
import17
{19
{18
effectiveHitSkillInDarkness,20
effectiveHitSkillInDarkness,@@ -42,6 +44,7 @@ import { tileToChunk } from "../world/coordinates.js";42
import { stackQuantity } from "../../../shared/items/inventory.js";44
import { stackQuantity } from "../../../shared/items/inventory.js";43
import { addGroundItem, publicGroundItem } from "../items/bags.js";45
import { addGroundItem, publicGroundItem } from "../items/bags.js";44
import { resolveItemDualTint } from "../../../shared/render/tint.js";46
import { resolveItemDualTint } from "../../../shared/render/tint.js";47
import { essenceItemIdForElement } from "../../../shared/definitions/essenceItems.js";45
import { castMobAttackSpell } from "../spells/mobCast.js";48
import { castMobAttackSpell } from "../spells/mobCast.js";46
import { attachOrigins, lootOrigin } from "../../../shared/items/origin.js";49
import { attachOrigins, lootOrigin } from "../../../shared/items/origin.js";47
import { scheduleSpawnerRespawn } from "../simulation/spawners.js";50
import { scheduleSpawnerRespawn } from "../simulation/spawners.js";@@ -219,6 +222,18 @@ function arrowStackInOffhand (equipment)219
return stack;222
return stack;220
}223
}221
224
225
/** Physical attack type, or tipped-arrow magic element when present. */226
function resolveAttackDamageType (ecs, attackerHandle, profile)227
{228
if (attackerHandle != null && profile?.mode === "ranged")229
{230
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));231
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)232
{ return stack.instance.element; }233
}234
return profile?.attackType ?? AttackType.blunt;235
}236
222
function consumeArrow (ecs, handle)237
function consumeArrow (ecs, handle)223
{238
{224
const equipment = ecs.get(handle, Component.equipment);239
const equipment = ecs.get(handle, Component.equipment);@@ -267,6 +282,12 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul267
...(def?.drops ?? []),282
...(def?.drops ?? []),268
...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])283
...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])269
];284
];285
if (creature.element && (def?.essenceDropChance ?? 0) > 0)286
{287
const essenceId = essenceItemIdForElement(creature.element);288
if (essenceId)289
{ dropTable.push({ itemId: essenceId, chance: def.essenceDropChance }); }290
}270
for (const drop of dropTable)291
for (const drop of dropTable)271
{292
{272
if (Math.random() > (drop.chance ?? 1))293
if (Math.random() > (drop.chance ?? 1))@@ -327,13 +348,23 @@ function projectileDualTintFromAttacker (ecs, handle)327
return resolveItemDualTint(stack, itemDefinition(stack.itemId));348
return resolveItemDualTint(stack, itemDefinition(stack.itemId));328
}349
}329
350
351
function projectileSpriteFromAttacker (ecs, handle)352
{353
const equipment = ecs.get(handle, Component.equipment);354
const stack = arrowStackInOffhand(equipment);355
if (stack?.instance?.kind === "tipped-arrow")356
{ return "fx:projectile:arrow-tipped"; }357
return "fx:projectile:arrow";358
}359
330
function publicDualTint (dualTint)360
function publicDualTint (dualTint)331
{361
{332
if (!dualTint)362
if (!dualTint)333
{ return null; }363
{ return null; }334
return {364
return {335
shaftTint: dualTint.shaft,365
shaftTint: dualTint.shaft,336
tipTint: dualTint.tip366
tipTint: dualTint.tip,367
...(dualTint.coat ? { coatTint: dualTint.coat } : {})337
};368
};338
}369
}339
370
@@ -543,7 +574,9 @@ export function stepCombat (world, now = Date.now())543
&& dist === 1574
&& dist === 1544
&& world.isClearStanding?.(entity.entityId, entity.position.tileX, entity.position.tileY);575
&& world.isClearStanding?.(entity.entityId, entity.position.tileX, entity.position.tileY);545
const attackSpells = isCreature ? eligibleMobAttackSpells(world.ecs, entity.handle) : [];576
const attackSpells = isCreature ? eligibleMobAttackSpells(world.ecs, entity.handle) : [];546
const shouldCast = isCreature && attackSpells.length > 0 && (isStaff || !canSwing);577
const preferSpell = isCreature578
&& !!mobDefinition(world.ecs.get(entity.handle, Component.creature)?.mobTypeId)?.preferSpellAttack;579
const shouldCast = isCreature && attackSpells.length > 0 && (isStaff || !canSwing || preferSpell);547
580
548
if (shouldCast)581
if (shouldCast)549
{582
{@@ -871,9 +904,20 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D871
{ return events; }904
{ return events; }872
const isCreature = !!world.ecs.get(attackerHandle, Component.creature)905
const isCreature = !!world.ecs.get(attackerHandle, Component.creature)873
&& !world.ecs.get(attackerHandle, Component.character);906
&& !world.ecs.get(attackerHandle, Component.character);907
const arrowTint = projectileDualTintFromAttacker(world.ecs, attackerHandle);908
const arrowSprite = projectileSpriteFromAttacker(world.ecs, attackerHandle);909
const tipElement = (() =>910
{911
const stack = arrowStackInOffhand(world.ecs.get(attackerHandle, Component.equipment));912
return stack?.instance?.kind === "tipped-arrow" ? stack.instance.element : null;913
})();874
if (!isCreature && !consumeArrow(world.ecs, attackerHandle))914
if (!isCreature && !consumeArrow(world.ecs, attackerHandle))875
{ return events; }915
{ return events; }876
916
917
const shotProfile = tipElement918
? { ...profile, attackType: tipElement }919
: profile;920
877
const snapshot = { tileX: targetPos.tileX, tileY: targetPos.tileY };921
const snapshot = { tileX: targetPos.tileX, tileY: targetPos.tileY };878
const target = resolveCombatTarget(world, targetId);922
const target = resolveCombatTarget(world, targetId);879
if (!target)923
if (!target)@@ -885,15 +929,16 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D885
type: "remote-ranged-resolve",929
type: "remote-ranged-resolve",886
attackerId,930
attackerId,887
targetId,931
targetId,888
profile,932
profile: shotProfile,889
attackerLevels: attackerCombatLevels(world.ecs, attackerHandle, profile, world.settings),933
attackerLevels: attackerCombatLevels(world.ecs, attackerHandle, shotProfile, world.settings),890
attackerIsPlayer: !!world.ecs.get(attackerHandle, Component.character),934
attackerIsPlayer: !!world.ecs.get(attackerHandle, Component.character),891
now,935
now,892
tileX: snapshot.tileX,936
tileX: snapshot.tileX,893
tileY: snapshot.tileY,937
tileY: snapshot.tileY,894
fromTileX: from.tileX,938
fromTileX: from.tileX,895
fromTileY: from.tileY,939
fromTileY: from.tileY,896
...(publicDualTint(projectileDualTintFromAttacker(world.ecs, attackerHandle)) ?? {})940
sprite: arrowSprite,941
...(publicDualTint(arrowTint) ?? {})897
});942
});898
return events;943
return events;899
}944
}@@ -904,7 +949,7 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D904
targetId,949
targetId,905
attackerHandle,950
attackerHandle,906
target.handle,951
target.handle,907
profile,952
shotProfile,908
now,953
now,909
snapshot954
snapshot910
);955
);@@ -937,7 +982,8 @@ export function resolveRangedShot (world, attackerId, targetId, profile, now = D937
tileY: endY,982
tileY: endY,938
durationMs: RANGED_PROJECTILE_MS,983
durationMs: RANGED_PROJECTILE_MS,939
trackTarget: outcome?.type !== "combat-miss",984
trackTarget: outcome?.type !== "combat-miss",940
...(publicDualTint(projectileDualTintFromAttacker(world.ecs, attackerHandle)) ?? {})985
sprite: arrowSprite,986
...(publicDualTint(arrowTint) ?? {})941
});987
});942
return events.concat(hitEvents);988
return events.concat(hitEvents);943
}989
}@@ -1132,8 +1178,10 @@ export function applyRemoteRangedShot (world, payload)1132
tileY: endY,1178
tileY: endY,1133
durationMs: RANGED_PROJECTILE_MS,1179
durationMs: RANGED_PROJECTILE_MS,1134
trackTarget: outcome?.type !== "combat-miss",1180
trackTarget: outcome?.type !== "combat-miss",1181
sprite: payload.sprite ?? "fx:projectile:arrow",1135
shaftTint: payload.shaftTint ?? null,1182
shaftTint: payload.shaftTint ?? null,1136
tipTint: payload.tipTint ?? null1183
tipTint: payload.tipTint ?? null,1184
coatTint: payload.coatTint ?? null1137
}, ...hitEvents];1185
}, ...hitEvents];1138
1186
1139
const forwards = [];1187
const forwards = [];@@ -1250,6 +1298,11 @@ function applyLocalMeleeHit (1250
world.settings1298
world.settings1251
);1299
);1252
1300
1301
const attackType = resolveAttackDamageType(world.ecs, attackerHandle, profile);1302
const targetCreature = world.ecs.get(targetHandle, Component.creature);1303
const targetAffinities = targetCreature1304
? mobDamageAffinities(mobDefinition(targetCreature.mobTypeId))1305
: {};1253
const resolved = resolvePhysicalAttack({1306
const resolved = resolvePhysicalAttack({1254
hitSkillLevel: effectiveHitSkillInDarkness(1307
hitSkillLevel: effectiveHitSkillInDarkness(1255
attackerLevels.hitLevel,1308
attackerLevels.hitLevel,@@ -1257,7 +1310,9 @@ function applyLocalMeleeHit (1257
),1310
),1258
agilitySkillLevel: agilityLevel,1311
agilitySkillLevel: agilityLevel,1259
damageSkillLevel: attackerLevels.damageLevel,1312
damageSkillLevel: attackerLevels.damageLevel,1260
defenceSkillLevel: defenceLevel1313
defenceSkillLevel: defenceLevel,1314
attackType,1315
targetAffinities1261
});1316
});1262
1317
1263
if (resolved.outcome === "miss")1318
if (resolved.outcome === "miss")@@ -81,6 +81,8 @@ export function publicEntityView (ecs, entityId)
81
81
const isMob = !!creature && !character;
82
82
const gearLight = equippedLightRadiusTiles(equipment);
83
83
const effectLight = statusExtraLightRadius(statusEffects, now);
84
const creatureLight = creature?.lightRadiusTiles
85
?? (mob?.lightRadiusTiles ?? 0);
84
86
return {
85
87
entityId,
86
88
tileX: position.tileX,
@@ -95,6 +97,7 @@ export function publicEntityView (ecs, entityId)
95
97
characterId: character?.characterId ?? null,
96
98
accountId: character?.accountId ?? null,
97
99
mobTypeId: creature?.mobTypeId ?? null,
100
element: creature?.element ?? null,
98
101
canFight: mob ? mobCanFight(mob) : !!character,
99
102
hostile: !!mob?.hostile,
100
103
talkable: !!mob?.talkable || shopHasInterface(ecs.get(handle, Component.shop)),
@@ -107,7 +110,7 @@ export function publicEntityView (ecs, entityId)
107
110
maxHealth: health ? health.max : undefined,
108
111
sprite: layers[0]?.sprite ?? null,
109
112
layers,
110
lightRadiusTiles: Math.max(gearLight, effectLight),
113
lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),
111
114
visualScale: statusVisualScale(statusEffects, now),
112
115
statusEffects: publicStatusEffectsView(statusEffects, now)
113
116
};
@@ -81,6 +81,8 @@ export function publicEntityView (ecs, entityId)81
const isMob = !!creature && !character;81
const isMob = !!creature && !character;82
const gearLight = equippedLightRadiusTiles(equipment);82
const gearLight = equippedLightRadiusTiles(equipment);83
const effectLight = statusExtraLightRadius(statusEffects, now);83
const effectLight = statusExtraLightRadius(statusEffects, now);84
const creatureLight = creature?.lightRadiusTiles85
?? (mob?.lightRadiusTiles ?? 0);84
return {86
return {85
entityId,87
entityId,86
tileX: position.tileX,88
tileX: position.tileX,@@ -95,6 +97,7 @@ export function publicEntityView (ecs, entityId)95
characterId: character?.characterId ?? null,97
characterId: character?.characterId ?? null,96
accountId: character?.accountId ?? null,98
accountId: character?.accountId ?? null,97
mobTypeId: creature?.mobTypeId ?? null,99
mobTypeId: creature?.mobTypeId ?? null,100
element: creature?.element ?? null,98
canFight: mob ? mobCanFight(mob) : !!character,101
canFight: mob ? mobCanFight(mob) : !!character,99
hostile: !!mob?.hostile,102
hostile: !!mob?.hostile,100
talkable: !!mob?.talkable || shopHasInterface(ecs.get(handle, Component.shop)),103
talkable: !!mob?.talkable || shopHasInterface(ecs.get(handle, Component.shop)),@@ -107,7 +110,7 @@ export function publicEntityView (ecs, entityId)107
maxHealth: health ? health.max : undefined,110
maxHealth: health ? health.max : undefined,108
sprite: layers[0]?.sprite ?? null,111
sprite: layers[0]?.sprite ?? null,109
layers,112
layers,110
lightRadiusTiles: Math.max(gearLight, effectLight),113
lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),111
visualScale: statusVisualScale(statusEffects, now),114
visualScale: statusVisualScale(statusEffects, now),112
statusEffects: publicStatusEffectsView(statusEffects, now)115
statusEffects: publicStatusEffectsView(statusEffects, now)113
};116
};@@ -286,6 +286,16 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,
286
286
slotIndex: message.slotIndex | 0
287
287
});
288
288
break;
289
case MessageType.tipArrows:
290
requirePlaying(session);
291
simulation.enqueue(session.id, {
292
type: "tip-arrows",
293
characterId: session.characterId,
294
coatingSlotIndex: message.coatingSlotIndex | 0,
295
arrowSlotIndex: message.arrowSlotIndex | 0,
296
quantity: message.quantity | 0
297
});
298
break;
289
299
case MessageType.openBank:
290
300
requirePlaying(session);
291
301
simulation.enqueue(session.id, {
@@ -286,6 +286,16 @@ export function attachGateway ({ httpServer, auth, stateDb, characters, friends,286
slotIndex: message.slotIndex | 0286
slotIndex: message.slotIndex | 0287
});287
});288
break;288
break;289
case MessageType.tipArrows:290
requirePlaying(session);291
simulation.enqueue(session.id, {292
type: "tip-arrows",293
characterId: session.characterId,294
coatingSlotIndex: message.coatingSlotIndex | 0,295
arrowSlotIndex: message.arrowSlotIndex | 0,296
quantity: message.quantity | 0297
});298
break;289
case MessageType.openBank:299
case MessageType.openBank:290
requirePlaying(session);300
requirePlaying(session);291
simulation.enqueue(session.id, {301
simulation.enqueue(session.id, {@@ -29,6 +29,7 @@ import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
29
29
import { randomUUID } from "node:crypto";
30
30
import { tileShoveTowardBlock } from "../simulation/tileInteract.js";
31
31
import { resolvePotionEffect } from "../../../shared/alchemy/recipes.js";
32
import { ARROW_COATING_ARROWS_PER_USE } from "../../../shared/definitions/alchemy.js";
32
33
import
33
34
{
34
35
applyStatusEffect,
@@ -175,6 +176,8 @@ export function handleItemCommand (world, sessionId, command, now)
175
176
return eatItem(world, sessionId, command);
176
177
case "drink-item":
177
178
return drinkItem(world, sessionId, command);
179
case "tip-arrows":
180
return tipArrows(world, sessionId, command);
178
181
default:
179
182
return null;
180
183
}
@@ -533,6 +536,91 @@ function drinkItem (world, sessionId, command)
533
536
};
534
537
}
535
538
539
/**
540
* Apply an arrow-coating potion to untipped arrows in the bag.
541
* Consumes one coating fill charge; tips up to ARROW_COATING_ARROWS_PER_USE arrows.
542
*/
543
function tipArrows (world, sessionId, command)
544
{
545
const { handle } = world.requireOwnedEntity(sessionId, command.characterId);
546
const inventory = ensureInventory(world.ecs, handle);
547
const coatingSlotIndex = command.coatingSlotIndex | 0;
548
const arrowSlotIndex = command.arrowSlotIndex | 0;
549
const wantQty = Math.max(1, command.quantity | 0 || 1);
550
551
const coating = inventory.slots[coatingSlotIndex];
552
if (!coating || coating.itemId !== ItemId.potion || coating.instance?.kind !== "potion")
553
{ throw userError("That is not a coating."); }
554
const effect = coating.instance.effect
555
?? resolvePotionEffect(coating.instance);
556
if (effect?.type !== "arrow-coating" || !effect.element)
557
{ throw userError("That brew cannot tip arrows."); }
558
const element = effect.element;
559
560
const arrowSlot = inventory.slots[arrowSlotIndex];
561
if (!arrowSlot)
562
{ throw userError("Select arrows to tip."); }
563
const arrowDef = itemDefinition(arrowSlot.itemId);
564
if (arrowDef?.equipment?.kind !== EquipmentKind.arrowAmmo)
565
{ throw userError("That is not an arrow."); }
566
if (arrowSlot.instance?.kind === "tipped-arrow")
567
{ throw userError("Those arrows are already tipped."); }
568
569
const available = stackQuantity(arrowSlot.quantity);
570
const tipQty = Math.min(wantQty, available, ARROW_COATING_ARROWS_PER_USE);
571
if (tipQty <= 0)
572
{ throw userError("No arrows to tip."); }
573
574
const taken = takeFromSlot(inventory.slots, arrowSlotIndex, tipQty);
575
if (!taken.ok || !taken.taken)
576
{ throw userError("Could not take those arrows."); }
577
inventory.slots = taken.slots;
578
579
const tipped = attachOrigins({
580
itemId: arrowSlot.itemId,
581
quantity: tipQty,
582
instance: { kind: "tipped-arrow", element },
583
origins: taken.taken.origins ?? []
584
});
585
const inserted = insertStack(inventory.slots, tipped, itemDefinition(arrowSlot.itemId));
586
if (!inserted.ok || inserted.remainder > 0)
587
{
588
const refund = insertStack(
589
inventory.slots,
590
attachOrigins({
591
itemId: arrowSlot.itemId,
592
quantity: tipQty,
593
instance: null,
594
origins: taken.taken.origins ?? []
595
}),
596
arrowDef
597
);
598
inventory.slots = refund.slots;
599
throw userError("Need bag space for the tipped arrows.");
600
}
601
inventory.slots = inserted.slots;
602
603
const consumed = consumeFillCharge(inventory.slots, coatingSlotIndex, {
604
kind: "potion",
605
itemId: ItemId.potion,
606
returnEmptyItemId: ItemId.glassBottle
607
});
608
if (!consumed.ok)
609
{
610
throw userError(
611
consumed.reason === "space"
612
? "Need bag space to keep the partially used coating (or empty bottle)."
613
: "That coating is gone."
614
);
615
}
616
inventory.slots = consumed.slots;
617
618
return {
619
events: [],
620
private: bagView(world.ecs, handle)
621
};
622
}
623
536
624
function ensureStatusEffects (ecs, handle)
537
625
{
538
626
let component = ecs.get(handle, Component.statusEffects);
@@ -557,6 +645,9 @@ function applyPotionEffect (ecs, handle, effect)
557
645
const health = ecs.get(handle, Component.health);
558
646
const type = effect.type;
559
647
648
if (type === "arrow-coating")
649
{ return result; }
650
560
651
if (type === "heal" && health)
561
652
{
562
653
const amount = Math.max(0, effect.amount | 0 || 0);
@@ -29,6 +29,7 @@ import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";29
import { randomUUID } from "node:crypto";29
import { randomUUID } from "node:crypto";30
import { tileShoveTowardBlock } from "../simulation/tileInteract.js";30
import { tileShoveTowardBlock } from "../simulation/tileInteract.js";31
import { resolvePotionEffect } from "../../../shared/alchemy/recipes.js";31
import { resolvePotionEffect } from "../../../shared/alchemy/recipes.js";32
import { ARROW_COATING_ARROWS_PER_USE } from "../../../shared/definitions/alchemy.js";32
import33
import33
{34
{34
applyStatusEffect,35
applyStatusEffect,@@ -175,6 +176,8 @@ export function handleItemCommand (world, sessionId, command, now)175
return eatItem(world, sessionId, command);176
return eatItem(world, sessionId, command);176
case "drink-item":177
case "drink-item":177
return drinkItem(world, sessionId, command);178
return drinkItem(world, sessionId, command);179
case "tip-arrows":180
return tipArrows(world, sessionId, command);178
default:181
default:179
return null;182
return null;180
}183
}@@ -533,6 +536,91 @@ function drinkItem (world, sessionId, command)533
};536
};534
}537
}535
538
539
/**540
* Apply an arrow-coating potion to untipped arrows in the bag.541
* Consumes one coating fill charge; tips up to ARROW_COATING_ARROWS_PER_USE arrows.542
*/543
function tipArrows (world, sessionId, command)544
{545
const { handle } = world.requireOwnedEntity(sessionId, command.characterId);546
const inventory = ensureInventory(world.ecs, handle);547
const coatingSlotIndex = command.coatingSlotIndex | 0;548
const arrowSlotIndex = command.arrowSlotIndex | 0;549
const wantQty = Math.max(1, command.quantity | 0 || 1);550
551
const coating = inventory.slots[coatingSlotIndex];552
if (!coating || coating.itemId !== ItemId.potion || coating.instance?.kind !== "potion")553
{ throw userError("That is not a coating."); }554
const effect = coating.instance.effect555
?? resolvePotionEffect(coating.instance);556
if (effect?.type !== "arrow-coating" || !effect.element)557
{ throw userError("That brew cannot tip arrows."); }558
const element = effect.element;559
560
const arrowSlot = inventory.slots[arrowSlotIndex];561
if (!arrowSlot)562
{ throw userError("Select arrows to tip."); }563
const arrowDef = itemDefinition(arrowSlot.itemId);564
if (arrowDef?.equipment?.kind !== EquipmentKind.arrowAmmo)565
{ throw userError("That is not an arrow."); }566
if (arrowSlot.instance?.kind === "tipped-arrow")567
{ throw userError("Those arrows are already tipped."); }568
569
const available = stackQuantity(arrowSlot.quantity);570
const tipQty = Math.min(wantQty, available, ARROW_COATING_ARROWS_PER_USE);571
if (tipQty <= 0)572
{ throw userError("No arrows to tip."); }573
574
const taken = takeFromSlot(inventory.slots, arrowSlotIndex, tipQty);575
if (!taken.ok || !taken.taken)576
{ throw userError("Could not take those arrows."); }577
inventory.slots = taken.slots;578
579
const tipped = attachOrigins({580
itemId: arrowSlot.itemId,581
quantity: tipQty,582
instance: { kind: "tipped-arrow", element },583
origins: taken.taken.origins ?? []584
});585
const inserted = insertStack(inventory.slots, tipped, itemDefinition(arrowSlot.itemId));586
if (!inserted.ok || inserted.remainder > 0)587
{588
const refund = insertStack(589
inventory.slots,590
attachOrigins({591
itemId: arrowSlot.itemId,592
quantity: tipQty,593
instance: null,594
origins: taken.taken.origins ?? []595
}),596
arrowDef597
);598
inventory.slots = refund.slots;599
throw userError("Need bag space for the tipped arrows.");600
}601
inventory.slots = inserted.slots;602
603
const consumed = consumeFillCharge(inventory.slots, coatingSlotIndex, {604
kind: "potion",605
itemId: ItemId.potion,606
returnEmptyItemId: ItemId.glassBottle607
});608
if (!consumed.ok)609
{610
throw userError(611
consumed.reason === "space"612
? "Need bag space to keep the partially used coating (or empty bottle)."613
: "That coating is gone."614
);615
}616
inventory.slots = consumed.slots;617
618
return {619
events: [],620
private: bagView(world.ecs, handle)621
};622
}623
536
function ensureStatusEffects (ecs, handle)624
function ensureStatusEffects (ecs, handle)537
{625
{538
let component = ecs.get(handle, Component.statusEffects);626
let component = ecs.get(handle, Component.statusEffects);@@ -557,6 +645,9 @@ function applyPotionEffect (ecs, handle, effect)557
const health = ecs.get(handle, Component.health);645
const health = ecs.get(handle, Component.health);558
const type = effect.type;646
const type = effect.type;559
647
648
if (type === "arrow-coating")649
{ return result; }650
560
if (type === "heal" && health)651
if (type === "heal" && health)561
{652
{562
const amount = Math.max(0, effect.amount | 0 || 0);653
const amount = Math.max(0, effect.amount | 0 || 0);@@ -15,7 +15,8 @@ import {
15
15
isTownGuardMob,
16
16
isHumanoidMob
17
17
} from "../../../shared/definitions/mobs.js";
18
import { spellDefinition } from "../../../shared/definitions/spells.js";
18
import { spellDefinition, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";
19
import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";
19
20
import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";
20
21
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";
21
22
import { emptyEquipment } from "../../../shared/items/inventory.js";
@@ -236,6 +237,17 @@ export function mobComponents (request)
236
237
{ appearance.sprite = sprite; }
237
238
}
238
239
240
let element = request.element ?? null;
241
if (def.randomElementOnSpawn && !element)
242
{
243
element = MAGIC_ELEMENT_ORDER[Math.floor(Math.random() * MAGIC_ELEMENT_ORDER.length)];
244
}
245
if (element)
246
{
247
appearance.tint = magicElementTint(element);
248
appearance.bloomBody = !!def.bloomBody;
249
}
250
239
251
const maxHp = mobHealthForLevel(def, level);
240
252
const components = {
241
253
position: {
@@ -246,7 +258,12 @@ export function mobComponents (request)
246
258
movement: { gait: def.gait ?? GAIT.walk, walkCarry: 0 },
247
259
path: { tiles: [] },
248
260
appearance,
249
creature: { mobTypeId: def.mobTypeId, level },
261
creature: {
262
mobTypeId: def.mobTypeId,
263
level,
264
...(element ? { element } : {}),
265
...(def.lightRadiusTiles ? { lightRadiusTiles: def.lightRadiusTiles } : {})
266
},
250
267
health: { current: maxHp, max: maxHp }
251
268
};
252
269
if (request.spawnerId)
@@ -296,9 +313,15 @@ export function mobComponents (request)
296
313
}
297
314
298
315
const knownSpells = normalizeMobSpells(request.spells, level);
316
if (element && SPRITE_BOLT_SPELL_BY_ELEMENT[element])
317
{
318
const boltId = SPRITE_BOLT_SPELL_BY_ELEMENT[element];
319
if (!knownSpells.some((entry) => entry.spellId === boltId))
320
{ knownSpells.push({ spellId: boltId }); }
321
}
299
322
if (knownSpells.length)
300
323
{
301
const castChance = mobSpellCastChancePercent(level);
324
const castChance = element ? 100 : mobSpellCastChancePercent(level);
302
325
components.spells = {
303
326
known: knownSpells.map((entry) => entry.spellId),
304
327
favorites: [],
@@ -15,7 +15,8 @@ import {15
isTownGuardMob,15
isTownGuardMob,16
isHumanoidMob16
isHumanoidMob17
} from "../../../shared/definitions/mobs.js";17
} from "../../../shared/definitions/mobs.js";18
import { spellDefinition } from "../../../shared/definitions/spells.js";18
import { spellDefinition, SPRITE_BOLT_SPELL_BY_ELEMENT } from "../../../shared/definitions/spells.js";19
import { MAGIC_ELEMENT_ORDER, magicElementTint } from "../../../shared/definitions/attackTypes.js";19
import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";20
import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";20
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";21
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";21
import { emptyEquipment } from "../../../shared/items/inventory.js";22
import { emptyEquipment } from "../../../shared/items/inventory.js";@@ -236,6 +237,17 @@ export function mobComponents (request)236
{ appearance.sprite = sprite; }237
{ appearance.sprite = sprite; }237
}238
}238
239
240
let element = request.element ?? null;241
if (def.randomElementOnSpawn && !element)242
{243
element = MAGIC_ELEMENT_ORDER[Math.floor(Math.random() * MAGIC_ELEMENT_ORDER.length)];244
}245
if (element)246
{247
appearance.tint = magicElementTint(element);248
appearance.bloomBody = !!def.bloomBody;249
}250
239
const maxHp = mobHealthForLevel(def, level);251
const maxHp = mobHealthForLevel(def, level);240
const components = {252
const components = {241
position: {253
position: {@@ -246,7 +258,12 @@ export function mobComponents (request)246
movement: { gait: def.gait ?? GAIT.walk, walkCarry: 0 },258
movement: { gait: def.gait ?? GAIT.walk, walkCarry: 0 },247
path: { tiles: [] },259
path: { tiles: [] },248
appearance,260
appearance,249
creature: { mobTypeId: def.mobTypeId, level },261
creature: {262
mobTypeId: def.mobTypeId,263
level,264
...(element ? { element } : {}),265
...(def.lightRadiusTiles ? { lightRadiusTiles: def.lightRadiusTiles } : {})266
},250
health: { current: maxHp, max: maxHp }267
health: { current: maxHp, max: maxHp }251
};268
};252
if (request.spawnerId)269
if (request.spawnerId)@@ -296,9 +313,15 @@ export function mobComponents (request)296
}313
}297
314
298
const knownSpells = normalizeMobSpells(request.spells, level);315
const knownSpells = normalizeMobSpells(request.spells, level);316
if (element && SPRITE_BOLT_SPELL_BY_ELEMENT[element])317
{318
const boltId = SPRITE_BOLT_SPELL_BY_ELEMENT[element];319
if (!knownSpells.some((entry) => entry.spellId === boltId))320
{ knownSpells.push({ spellId: boltId }); }321
}299
if (knownSpells.length)322
if (knownSpells.length)300
{323
{301
const castChance = mobSpellCastChancePercent(level);324
const castChance = element ? 100 : mobSpellCastChancePercent(level);302
components.spells = {325
components.spells = {303
known: knownSpells.map((entry) => entry.spellId),326
known: knownSpells.map((entry) => entry.spellId),304
favorites: [],327
favorites: [],@@ -23,6 +23,7 @@ import
23
23
} from "../../../shared/spells/constants.js";
24
24
import
25
25
{
26
mobDamageAffinities,
26
27
mobElementAffinities,
27
28
ElementMultiplier,
28
29
resolveMagicAttack,
@@ -469,7 +470,7 @@ function targetAffinitiesForEntity (world, entityId)
469
470
const creature = world.ecs.get(handle, Component.creature);
470
471
if (!creature)
471
472
{ return {}; }
472
return mobElementAffinities(mobDefinition(creature.mobTypeId));
473
return mobDamageAffinities(mobDefinition(creature.mobTypeId));
473
474
}
474
475
475
476
function applySpellImpact (world, impact, now)
@@ -23,6 +23,7 @@ import23
} from "../../../shared/spells/constants.js";23
} from "../../../shared/spells/constants.js";24
import24
import25
{25
{26
mobDamageAffinities,26
mobElementAffinities,27
mobElementAffinities,27
ElementMultiplier,28
ElementMultiplier,28
resolveMagicAttack,29
resolveMagicAttack,@@ -469,7 +470,7 @@ function targetAffinitiesForEntity (world, entityId)469
const creature = world.ecs.get(handle, Component.creature);470
const creature = world.ecs.get(handle, Component.creature);470
if (!creature)471
if (!creature)471
{ return {}; }472
{ return {}; }472
return mobElementAffinities(mobDefinition(creature.mobTypeId));473
return mobDamageAffinities(mobDefinition(creature.mobTypeId));473
}474
}474
475
475
function applySpellImpact (world, impact, now)476
function applySpellImpact (world, impact, now)@@ -91,6 +91,39 @@ test("physical attack hit applies rolled damage when not blocked", () =>
91
91
assert.equal(result.damage, 3);
92
92
});
93
93
94
test("physical attack applies weakness and resistance multipliers", () =>
95
{
96
let i = 0;
97
const rolls = [0.9, 0, 0.5, 0];
98
const rng = () => rolls[i++];
99
const weak = resolvePhysicalAttack({
100
hitSkillLevel: 10,
101
agilitySkillLevel: 1,
102
damageSkillLevel: 5,
103
defenceSkillLevel: 1,
104
attackType: "slashing",
105
targetAffinities: { slashing: "weak" },
106
rng
107
});
108
assert.equal(weak.outcome, "hit");
109
assert.equal(weak.damage, 6);
110
assert.equal(weak.multiplier, 2);
111
112
i = 0;
113
const resist = resolvePhysicalAttack({
114
hitSkillLevel: 10,
115
agilitySkillLevel: 1,
116
damageSkillLevel: 5,
117
defenceSkillLevel: 1,
118
attackType: "blunt",
119
targetAffinities: { blunt: "resistant" },
120
rng
121
});
122
assert.equal(resist.outcome, "hit");
123
assert.equal(resist.damage, 1);
124
assert.equal(resist.multiplier, 0.5);
125
});
126
94
127
test("physical damage is the damage skill roll only", () =>
95
128
{
96
129
let i = 0;
@@ -91,6 +91,39 @@ test("physical attack hit applies rolled damage when not blocked", () =>91
assert.equal(result.damage, 3);91
assert.equal(result.damage, 3);92
});92
});93
93
94
test("physical attack applies weakness and resistance multipliers", () =>95
{96
let i = 0;97
const rolls = [0.9, 0, 0.5, 0];98
const rng = () => rolls[i++];99
const weak = resolvePhysicalAttack({100
hitSkillLevel: 10,101
agilitySkillLevel: 1,102
damageSkillLevel: 5,103
defenceSkillLevel: 1,104
attackType: "slashing",105
targetAffinities: { slashing: "weak" },106
rng107
});108
assert.equal(weak.outcome, "hit");109
assert.equal(weak.damage, 6);110
assert.equal(weak.multiplier, 2);111
112
i = 0;113
const resist = resolvePhysicalAttack({114
hitSkillLevel: 10,115
agilitySkillLevel: 1,116
damageSkillLevel: 5,117
defenceSkillLevel: 1,118
attackType: "blunt",119
targetAffinities: { blunt: "resistant" },120
rng121
});122
assert.equal(resist.outcome, "hit");123
assert.equal(resist.damage, 1);124
assert.equal(resist.multiplier, 0.5);125
});126
94
test("physical damage is the damage skill roll only", () =>127
test("physical damage is the damage skill roll only", () =>95
{128
{96
let i = 0;129
let i = 0;@@ -2,6 +2,7 @@ import test from "node:test";
2
2
import assert from "node:assert/strict";
3
3
import { resolveMagicAttack, resolveMagicEffect, resolveSpellCast } from "../../shared/combat/magic.js";
4
4
import { spellDefinition, spellDifficulty, SpellId } from "../../shared/definitions/spells.js";
5
import { spellDifficultyFromTier } from "../../shared/spells/constants.js";
5
6
6
7
test("spell cast fails when difficulty roll beats magic roll", () =>
7
8
{
@@ -83,8 +84,16 @@ test("non-damage spell applies effect only after a successful cast roll", () =>
83
84
84
85
test("spell definitions expose tier-based difficulty", () =>
85
86
{
86
const spark = spellDefinition(SpellId.spark);
87
assert.equal(spellDifficulty(spark), 4);
88
assert.equal(spark.element, "fire");
87
const firebolt = spellDefinition(SpellId.firebolt);
88
assert.equal(spellDifficulty(firebolt), spellDifficultyFromTier(3));
89
assert.equal(firebolt.element, "fire");
90
assert.equal(spellDefinition("spark"), null);
89
91
assert.ok(spellDefinition(SpellId.light));
92
assert.ok(spellDefinition(SpellId.waterbolt));
93
assert.ok(spellDefinition(SpellId.maelstrom));
94
assert.ok(spellDefinition(SpellId.hurricane));
95
assert.ok(spellDefinition(SpellId.cataclysm));
96
assert.ok(spellDefinition(SpellId.judgment));
97
assert.ok(spellDefinition(SpellId.oblivion));
98
assert.ok(spellDefinition(SpellId.blight));
90
99
});
@@ -2,6 +2,7 @@ import test from "node:test";2
import assert from "node:assert/strict";2
import assert from "node:assert/strict";3
import { resolveMagicAttack, resolveMagicEffect, resolveSpellCast } from "../../shared/combat/magic.js";3
import { resolveMagicAttack, resolveMagicEffect, resolveSpellCast } from "../../shared/combat/magic.js";4
import { spellDefinition, spellDifficulty, SpellId } from "../../shared/definitions/spells.js";4
import { spellDefinition, spellDifficulty, SpellId } from "../../shared/definitions/spells.js";5
import { spellDifficultyFromTier } from "../../shared/spells/constants.js";5
6
6
test("spell cast fails when difficulty roll beats magic roll", () =>7
test("spell cast fails when difficulty roll beats magic roll", () =>7
{8
{@@ -83,8 +84,16 @@ test("non-damage spell applies effect only after a successful cast roll", () =>83
84
84
test("spell definitions expose tier-based difficulty", () =>85
test("spell definitions expose tier-based difficulty", () =>85
{86
{86
const spark = spellDefinition(SpellId.spark);87
const firebolt = spellDefinition(SpellId.firebolt);87
assert.equal(spellDifficulty(spark), 4);88
assert.equal(spellDifficulty(firebolt), spellDifficultyFromTier(3));88
assert.equal(spark.element, "fire");89
assert.equal(firebolt.element, "fire");90
assert.equal(spellDefinition("spark"), null);89
assert.ok(spellDefinition(SpellId.light));91
assert.ok(spellDefinition(SpellId.light));92
assert.ok(spellDefinition(SpellId.waterbolt));93
assert.ok(spellDefinition(SpellId.maelstrom));94
assert.ok(spellDefinition(SpellId.hurricane));95
assert.ok(spellDefinition(SpellId.cataclysm));96
assert.ok(spellDefinition(SpellId.judgment));97
assert.ok(spellDefinition(SpellId.oblivion));98
assert.ok(spellDefinition(SpellId.blight));90
});99
});@@ -1,12 +1,13 @@
1
1
import test from "node:test";
2
2
import assert from "node:assert/strict";
3
import {
4
MobId,
5
normalizeSpawnerConfig,
6
mobMaxHealthForLevel,
7
mobLevelDisplayName,
8
mobDefinition
9
} from "../../shared/definitions/mobs.js";
3
import
4
{
5
MobId,
6
normalizeSpawnerConfig,
7
mobMaxHealthForLevel,
8
mobLevelDisplayName,
9
mobDefinition
10
} from "../../shared/definitions/mobs.js";
10
11
import { mobCanFight, mobSpellCastChancePercent } from "../../shared/definitions/mobCombat.js";
11
12
import { SpellId } from "../../shared/definitions/spells.js";
12
13
import { SkillId } from "../../shared/definitions/skills.js";
@@ -50,19 +51,35 @@ test("spawner config keeps bounty, level, and spells", () =>
50
51
level: 5,
51
52
bounty: 25,
52
53
spells: [
53
{ spellId: SpellId.spark, chance: 75 },
54
{ spellId: SpellId.firebolt, chance: 75 },
54
55
{ spellId: SpellId.light, chance: 0 },
55
{ spellId: SpellId.spark, chance: 10 }
56
{ spellId: SpellId.firebolt, chance: 10 }
56
57
]
57
58
}, "s1");
58
59
assert.equal(config.level, 5);
59
60
assert.equal(config.bounty, 25);
60
61
assert.equal(config.spells.length, 2);
61
assert.equal(config.spells[0].spellId, SpellId.spark);
62
assert.equal(config.spells[0].spellId, SpellId.firebolt);
62
63
assert.equal(config.spells[0].chance, undefined);
63
64
assert.equal(config.spells[1].spellId, SpellId.light);
64
65
});
65
66
67
test("spawner config drops retired spark spell without failing", () =>
68
{
69
const config = normalizeSpawnerConfig({
70
mobTypeId: MobId.humanoid,
71
spells: [
72
{ spellId: "spark" },
73
{ spellId: SpellId.light },
74
{ spellId: SpellId.firebolt }
75
]
76
}, "legacy-spark");
77
assert.deepEqual(
78
config.spells.map((row) => row.spellId),
79
[SpellId.light, SpellId.firebolt]
80
);
81
});
82
66
83
test("humanoid aggressive forces bounty to 0", () =>
67
84
{
68
85
const config = normalizeSpawnerConfig({
@@ -101,7 +118,7 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
101
118
displayName: "Captain",
102
119
sex: "male",
103
120
spells: [
104
{ spellId: SpellId.spark },
121
{ spellId: SpellId.firebolt },
105
122
{ spellId: SpellId.light }
106
123
]
107
124
});
@@ -112,9 +129,9 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells
112
129
assert.equal(components.skills.levels[SkillId.unarmed], 4);
113
130
assert.equal(components.spawnOrigin.bounty, 12);
114
131
assert.equal(components.spawnOrigin.townGuard, true);
115
assert.ok(components.spells.known.includes(SpellId.spark));
132
assert.ok(components.spells.known.includes(SpellId.firebolt));
116
133
assert.ok(components.spells.known.includes(SpellId.light));
117
assert.equal(components.spells.castChances[SpellId.spark], mobSpellCastChancePercent(4));
134
assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(4));
118
135
assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(4));
119
136
});
120
137
@@ -126,7 +143,7 @@ test("mobs below spell minMagicLevel do not learn the spell", () =>
126
143
mobTypeId: MobId.rat,
127
144
spawnerId: "0:0:4",
128
145
level: 1,
129
spells: [{ spellId: SpellId.spark }]
146
spells: [{ spellId: SpellId.firebolt }]
130
147
});
131
148
assert.equal(components.spells, undefined);
132
149
});
@@ -1,12 +1,13 @@1
import test from "node:test";1
import test from "node:test";2
import assert from "node:assert/strict";2
import assert from "node:assert/strict";3
import {3
import4
MobId,4
{5
normalizeSpawnerConfig,5
MobId,6
mobMaxHealthForLevel,6
normalizeSpawnerConfig,7
mobLevelDisplayName,7
mobMaxHealthForLevel,8
mobDefinition8
mobLevelDisplayName,9
} from "../../shared/definitions/mobs.js";9
mobDefinition10
} from "../../shared/definitions/mobs.js";10
import { mobCanFight, mobSpellCastChancePercent } from "../../shared/definitions/mobCombat.js";11
import { mobCanFight, mobSpellCastChancePercent } from "../../shared/definitions/mobCombat.js";11
import { SpellId } from "../../shared/definitions/spells.js";12
import { SpellId } from "../../shared/definitions/spells.js";12
import { SkillId } from "../../shared/definitions/skills.js";13
import { SkillId } from "../../shared/definitions/skills.js";@@ -50,19 +51,35 @@ test("spawner config keeps bounty, level, and spells", () =>50
level: 5,51
level: 5,51
bounty: 25,52
bounty: 25,52
spells: [53
spells: [53
{ spellId: SpellId.spark, chance: 75 },54
{ spellId: SpellId.firebolt, chance: 75 },54
{ spellId: SpellId.light, chance: 0 },55
{ spellId: SpellId.light, chance: 0 },55
{ spellId: SpellId.spark, chance: 10 }56
{ spellId: SpellId.firebolt, chance: 10 }56
]57
]57
}, "s1");58
}, "s1");58
assert.equal(config.level, 5);59
assert.equal(config.level, 5);59
assert.equal(config.bounty, 25);60
assert.equal(config.bounty, 25);60
assert.equal(config.spells.length, 2);61
assert.equal(config.spells.length, 2);61
assert.equal(config.spells[0].spellId, SpellId.spark);62
assert.equal(config.spells[0].spellId, SpellId.firebolt);62
assert.equal(config.spells[0].chance, undefined);63
assert.equal(config.spells[0].chance, undefined);63
assert.equal(config.spells[1].spellId, SpellId.light);64
assert.equal(config.spells[1].spellId, SpellId.light);64
});65
});65
66
67
test("spawner config drops retired spark spell without failing", () =>68
{69
const config = normalizeSpawnerConfig({70
mobTypeId: MobId.humanoid,71
spells: [72
{ spellId: "spark" },73
{ spellId: SpellId.light },74
{ spellId: SpellId.firebolt }75
]76
}, "legacy-spark");77
assert.deepEqual(78
config.spells.map((row) => row.spellId),79
[SpellId.light, SpellId.firebolt]80
);81
});82
66
test("humanoid aggressive forces bounty to 0", () =>83
test("humanoid aggressive forces bounty to 0", () =>67
{84
{68
const config = normalizeSpawnerConfig({85
const config = normalizeSpawnerConfig({@@ -101,7 +118,7 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells101
displayName: "Captain",118
displayName: "Captain",102
sex: "male",119
sex: "male",103
spells: [120
spells: [104
{ spellId: SpellId.spark },121
{ spellId: SpellId.firebolt },105
{ spellId: SpellId.light }122
{ spellId: SpellId.light }106
]123
]107
});124
});@@ -112,9 +129,9 @@ test("mob components use spawner level for skills, HP, bounty origin, and spells112
assert.equal(components.skills.levels[SkillId.unarmed], 4);129
assert.equal(components.skills.levels[SkillId.unarmed], 4);113
assert.equal(components.spawnOrigin.bounty, 12);130
assert.equal(components.spawnOrigin.bounty, 12);114
assert.equal(components.spawnOrigin.townGuard, true);131
assert.equal(components.spawnOrigin.townGuard, true);115
assert.ok(components.spells.known.includes(SpellId.spark));132
assert.ok(components.spells.known.includes(SpellId.firebolt));116
assert.ok(components.spells.known.includes(SpellId.light));133
assert.ok(components.spells.known.includes(SpellId.light));117
assert.equal(components.spells.castChances[SpellId.spark], mobSpellCastChancePercent(4));134
assert.equal(components.spells.castChances[SpellId.firebolt], mobSpellCastChancePercent(4));118
assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(4));135
assert.equal(components.spells.castChances[SpellId.light], mobSpellCastChancePercent(4));119
});136
});120
137
@@ -126,7 +143,7 @@ test("mobs below spell minMagicLevel do not learn the spell", () =>126
mobTypeId: MobId.rat,143
mobTypeId: MobId.rat,127
spawnerId: "0:0:4",144
spawnerId: "0:0:4",128
level: 1,145
level: 1,129
spells: [{ spellId: SpellId.spark }]146
spells: [{ spellId: SpellId.firebolt }]130
});147
});131
assert.equal(components.spells, undefined);148
assert.equal(components.spells, undefined);132
});149
});