feat: Shrink Hammer, and Alt + scroll to size pieces with both hammers

A player asked to build below vanilla size for small details. The new
Shrink Hammer, craftable by any race, builds from 0.25 to 1; Trol's Hammer
keeps 1 to 3. With either hammer, Alt + scroll in build mode changes the
size in steps of 0.05, an Alt: Size row joins the build hints, and the size
floats over the ghost when it is not the default. With the repair tool, the
aimed piece shows the size it was built at. Both hammers get icons of their
own.
This commit is contained in:
kanym 2026-10-30 22:49:27 +01:00
commit 0d1f655598
17 changed files with 414 additions and 14 deletions

View file

@ -0,0 +1,51 @@
"""Paint the two sizing hammers' icons from the vanilla hammer's, so neither can pass for it in a
hotbar: Trol's Hammer gets a blue-steel head and a troll trophy, the Shrink Hammer a brass head and a
resize badge (a small square inside a big one, with an arrow between their corners).
Usage: py -3.14 -I paint_hammer_icons.py <pylib> <icons dir>
<icons dir> holds hammer.png and TrophyForestTroll.png (Sprites "hammer" and "TrophyForestTroll"
from bundle 6a33a62). Writes TrolsHammer_icon.png and ShrinkHammer_icon.png there; copy them to
JotunnModStub/Assets/Hammers/."""
import sys, os
sys.path.insert(0, sys.argv[1])
import numpy as np
from PIL import Image, ImageDraw, ImageFilter
d = sys.argv[2]
S = 128 # twice the vanilla icon, for sharper badges
def hammer_with_head(tint, lift):
hammer = Image.open(os.path.join(d, "hammer.png")).convert("RGBA").resize((S, S), Image.LANCZOS)
a = np.asarray(hammer, dtype=np.float32)/255
# the head: a rotated block in the upper part, its corners read off the 64 px sprite
head = Image.new("L", (S, S), 0)
ImageDraw.Draw(head).polygon([(x*2, y*2) for x, y in [(21,1), (57,13), (52,31), (16,19)]], fill=255)
head = np.asarray(head.filter(ImageFilter.GaussianBlur(1)), dtype=np.float32)/255
lum = a[...,:3] @ np.array([0.3, 0.55, 0.15])
metal = np.clip(lum[...,None]*np.array(tint) + np.array(lift), 0, 1)
a[...,:3] = a[...,:3]*(1 - head[...,None]) + metal*head[...,None]
return Image.fromarray((a*255).astype(np.uint8), "RGBA")
def with_rim(badge):
"""A dark rim around a badge, so it reads on any slot colour."""
rim = Image.new("RGBA", badge.size, (10, 10, 10, 0))
rim.putalpha(badge.split()[3].filter(ImageFilter.MaxFilter(5)).point(lambda v: min(v, 200)))
rim.alpha_composite(badge)
return rim
# Trol's Hammer
icon = hammer_with_head((1.05, 1.35, 1.9), (0.02, 0.05, 0.1))
trophy = Image.open(os.path.join(d, "TrophyForestTroll.png")).convert("RGBA").resize((60, 60), Image.LANCZOS)
icon.alpha_composite(with_rim(trophy), (S - 62, S - 62))
icon.save(os.path.join(d, "TrolsHammer_icon.png"))
# the Shrink Hammer
icon = hammer_with_head((1.9, 1.5, 0.75), (0.06, 0.04, 0.0))
B = 56
badge = Image.new("RGBA", (B, B), (0, 0, 0, 0))
g = ImageDraw.Draw(badge)
white = (240, 240, 235, 255)
g.rectangle([4, 4, B - 5, B - 5], outline=white, width=4) # the big square
g.rectangle([4, B - 23, 22, B - 5], fill=white) # the small one, in its corner
g.line([(20, B - 21), (B - 15, 14)], fill=white, width=4) # the arrow from small to big
g.polygon([(B - 9, 9), (B - 27, 12), (B - 12, 27)], fill=white)
icon.alpha_composite(with_rim(badge), (S - B - 4, S - B - 4))
icon.save(os.path.join(d, "ShrinkHammer_icon.png"))