Land templates

3 replies [Last post]
KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 19 hours ago. Offline
Joined: 2010-12-25
Posts: 564

I just discovered that map templates are hard-coded in the engine and there's probably lot of work to add them. I thought I could maybe make a template editor, but even if it would generate code ready to be paste there, it's still not perfect solution. Is making templates more portable even an option? Like, they would be stored in files similar to theme.cfg somewhere and all of them would be loaded on engine startup or something.

Wuzzy
Wuzzy's picture
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 2012-06-20
Posts: 1301

I considered to move the Lua-based mapgens (DiagonalMaze, ShoppaMap, Tunnels) to the map type drop-down list where they belong.

I think a graphical editor for map generators would be overkill. I also think your suggestion isn't really clear; I'm not sure what you want to achieve exactly. :-/

Hi, I am a Hedgewars developer. Smile

KoBeWi
KoBeWi's picture
User offline. Last seen 3 days 19 hours ago. Offline
Joined: 2010-12-25
Posts: 564

Wuzzy allegedly wrote:
I'm not sure what you want to achieve exactly. :-/
Simplifying the process of adding new templates.

Right now, if you want to add new template, you need to provide points.

uLandTemplates.pas allegedly wrote:
const Template0Points: array[0..18] of TSDL_Rect =
(
(x: 810; y: 1424; w: 1; h: 1),
(x: 560; y: 1160; w: 130; h: 170),
(x: 742; y: 1106; w: 316; h: 150),
(x: 638; y: 786; w: 270; h: 180),
(x: 646; y: 576; w: 242; h: 156),
(x: 952; y: 528; w: 610; h: 300),
(x: 1150; y: 868; w: 352; h: 324),
(x: 1050; y: 1424; w: 500; h: 1),
(x: 1650; y: 1500; w: 1; h: 1),
(x: 1890; y: 1424; w: 1; h: 1),
(x: 1852; y: 1304; w: 74; h: 12),
(x: 1648; y: 975; w: 68; h: 425),
(x: 1826; y: 992; w: 140; h: 142),
(x: 1710; y: 592; w: 150; h: 350),
(x: 1988; y: 594; w: 148; h: 242),
(x: 2018; y: 872; w: 276; h: 314),
(x: 2110; y: 1250; w: 130; h: 86),
(x: 2134; y: 1424; w: 1; h: 1),
(x: NTPX; y: 0; w: 1; h: 1)
);
Template0FPoints: array[0..0] of TPoint =
(
(x: 1023; y: 0)
);
This is where graphical editor would help. Unless there's some method of picking points I'm not aware of.

Then, you need to configure it below in the same file.

uLandTemplates.pas allegedly wrote:
(
(BasePoints: PPointArray(@Template0Points);
BasePointsCount: Succ(High(Template0Points));
FillPoints: PPointArray(@Template0FPoints);
FillPointsCount: Succ(High(Template0FPoints));
BezierizeCount: 3;
RandPassesCount: 8;
TemplateHeight: 1424; TemplateWidth: 3072;
canMirror: true; canFlip: false; isNegative: false; canInvert: false;
hasGirders: true;
MaxHedgeHogs: 18;
),
It's all stored in an array, so you have to write it in right place and change all dependent numbers.

Finally, there's this list.

uLandTemplates.pas allegedly wrote:
const CavernTemplates: array[0..5] of Longword = (36, 2, 3, 21, 29, 45);const CavernTemplates: array[0..5] of Longword = (36, 2, 3, 21, 29, 45);

To sum up, you need to know what points to add, then make changes in few places in the code. If few people want to contribute templates, they have to make sure that their files are in sync, because you have to do this manually.

Now that you mentioned LUA scripts, it seems like they do something similar. But does it have same capabilities as normal map-gen? I mean, these templates define rough shape, but they are further processed by engine. Not sure if you can do the same with scripts, like e.g. replace the default templates.

Also, I'm not sure if adding more templates is planned, but it wouldn't hurt to have more, right? XD

Wuzzy
Wuzzy's picture
User offline. Last seen 4 days 20 hours ago. Offline
Joined: 2012-06-20
Posts: 1301

I'm still busy with hunting down bugs for the 0.9.23 release, I don't want to think about these things yet.

Hi, I am a Hedgewars developer. Smile

Copyright © 2004-2023 Hedgewars Project. All rights reserved. [ contact ]