103 lines
2.8 KiB
Python
103 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Generate campaign mission 01 — FIRST PRESSING (map.bin + map.yaml + preview)."""
|
|
import os, struct
|
|
from PIL import Image
|
|
|
|
SIZE = 48
|
|
W = H = SIZE + 2
|
|
MAP = os.path.join(os.path.dirname(__file__), '..', 'mods', 'vinylgod', 'maps', 'm01')
|
|
os.makedirs(MAP, exist_ok=True)
|
|
|
|
WAX = [(14, 34, 5), (9, 43, 4), (25, 25, 5), (40, 14, 4)]
|
|
|
|
data = bytearray()
|
|
data += struct.pack('<BHH', 2, W, H)
|
|
data += struct.pack('<III', 17, 0, 3 * W * H + 17)
|
|
data += b'\xff\x00\x00' * (W * H)
|
|
res = bytearray(2 * W * H)
|
|
for cx, cy, r in WAX:
|
|
for x in range(cx - r, cx + r + 1):
|
|
for y in range(cy - r, cy + r + 1):
|
|
d2 = (x - cx) ** 2 + (y - cy) ** 2
|
|
if d2 <= r * r and 0 < x < W - 1 and 0 < y < H - 1:
|
|
o = 2 * (x * H + y)
|
|
res[o], res[o + 1] = 1, max(2, round(12 * (1 - (d2 ** 0.5) / (r + 1))))
|
|
data += res
|
|
open(os.path.join(MAP, 'map.bin'), 'wb').write(data)
|
|
|
|
ACTORS = [
|
|
('spawn0', 'mpspawn', 'Neutral', 9, 38),
|
|
('van', 'popupvan', 'Player', 9, 38),
|
|
('dig', 'digger', 'Player', 12, 38),
|
|
('grunt1', 'djgrunt', 'Player', 11, 41),
|
|
('grunt2', 'djgrunt', 'Player', 12, 41),
|
|
('outpost', 'transcoder', 'Enemy', 38, 9),
|
|
('pods', 'podfarm', 'Enemy', 41, 12),
|
|
('node', 'datacentre', 'Enemy', 36, 12),
|
|
('probe1', 'bufferbot', 'Enemy', 38, 14),
|
|
('probe2', 'bufferbot', 'Enemy', 39, 14),
|
|
('probe3', 'bufferbot', 'Enemy', 40, 14),
|
|
('probe4', 'crawler', 'Enemy', 37, 15),
|
|
]
|
|
actors = '\n'.join(f'\t{n}: {t}\n\t\tOwner: {o}\n\t\tLocation: {x},{y}' for n, t, o, x, y in ACTORS)
|
|
|
|
open(os.path.join(MAP, 'map.yaml'), 'w').write(f"""MapFormat: 12
|
|
|
|
RequiresMod: vinylgod
|
|
|
|
Title: 01 - First Pressing
|
|
|
|
Author: Monster Robot Party
|
|
|
|
Tileset: VINYLGOD
|
|
|
|
MapSize: {W},{H}
|
|
|
|
Bounds: 1,1,{SIZE},{SIZE}
|
|
|
|
Visibility: MissionSelector
|
|
|
|
Categories: Campaign
|
|
|
|
LockPreview: True
|
|
|
|
Players:
|
|
PlayerReference@Neutral:
|
|
Name: Neutral
|
|
OwnsWorld: True
|
|
NonCombatant: True
|
|
Faction: vinylgod
|
|
PlayerReference@Player:
|
|
Name: Player
|
|
Playable: True
|
|
Required: True
|
|
AllowBots: False
|
|
LockFaction: True
|
|
Faction: vinylgod
|
|
LockSpawn: True
|
|
LockTeam: True
|
|
Enemies: Enemy
|
|
PlayerReference@Enemy:
|
|
Name: Enemy
|
|
Faction: stream
|
|
Enemies: Player
|
|
|
|
Actors:
|
|
{actors}
|
|
|
|
Rules: vinylgod|rules/campaign.yaml, rules.yaml
|
|
|
|
FluentMessages: vinylgod|fluent/lua.ftl
|
|
""")
|
|
|
|
im = Image.new('RGB', (W, H), (55, 50, 52))
|
|
for cx, cy, r in WAX:
|
|
for x in range(cx - r, cx + r + 1):
|
|
for y in range(cy - r, cy + r + 1):
|
|
if (x - cx) ** 2 + (y - cy) ** 2 <= r * r and 0 <= x < W and 0 <= y < H:
|
|
im.putpixel((x, y), (255, 45, 150))
|
|
for _, _, o, x, y in ACTORS:
|
|
im.putpixel((x, y), (255, 255, 255) if o == 'Player' else (80, 150, 255))
|
|
im.resize((W * 3, H * 3), Image.NEAREST).save(os.path.join(MAP, 'map.png'))
|
|
print('m01 written')
|