Skip to content

Commit

Permalink
Allow specifying chamber locations relative to any map edge or corner…
Browse files Browse the repository at this point in the history
…, or relative to the map center
  • Loading branch information
CelticMinstrel committed Oct 11, 2019
1 parent ca6b63e commit 3ca44f3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
21 changes: 21 additions & 0 deletions data/lua/cave_map_generator.lua
Expand Up @@ -74,6 +74,27 @@ function callbacks.generate_map(params)
for chamber in wml.child_range(params, "chamber") do
local chance = tonumber(chamber.chance) or 100
local x, y = MG.random_location(chamber.x, chamber.y)
if chamber.relative_to == "top-right" then
x = map.w - x
elseif chamber.relative_to == "bottom-right" then
x = map.w - x
y = map.h - y
elseif chamber.relative_to == "bottom-left" then
y = map.h - y
elseif chamber.relative_to == "top-middle" then
x = (map.w / 2) + x
elseif chamber.relative_to == "bottom-middle" then
x = (map.w / 2) + x
y = map.h - y
elseif chamber.relative_to == "middle-left" then
y = (map.h / 2) + y
elseif chamber.relative_to == "middle-right" then
y = (map.h / 2) + y
x = map.w - x
elseif chamber.relative_to == "center" then
x = (map.w / 2) + x
y = (map.h / 2) + y
end -- Default is "top-left" which means no adjustments needed
local id = chamber.id
if chance == 0 or random(100) > chance then
-- Set chance to 0 so that the scenario generator can tell which chambers were used
Expand Down
11 changes: 6 additions & 5 deletions data/multiplayer/scenarios/Random_Scenario_Cave.cfg
Expand Up @@ -89,12 +89,13 @@ Rb,Rb,Rb,Rb,Rb,Rb,Rb,Rb^Uf,Rb^Ii,Sm,Sm,Uue,Rb^Fetd,Rb^Fdw#enddef
[/road_cost]
#enddef

#define PLAYER_CHAMBER NUMBER X Y
#define PLAYER_CHAMBER NUMBER X Y REL
[chamber]
id=player_{NUMBER}
require_player={NUMBER}
x={X}
y={Y}
relative_to={REL}
size=5
jagged=2
[item_location]
Expand Down Expand Up @@ -169,10 +170,10 @@ Rb,Rb,Rb,Rb,Rb,Rb,Rb,Rb^Uf,Rb^Ii,Sm,Sm,Uue,Rb^Fetd,Rb^Fdw#enddef
jagged=12
terrain_clear=Wwg
[/chamber]
{PLAYER_CHAMBER 1 3..10 3..10}
{PLAYER_CHAMBER 2 30..37 30..37}
{PLAYER_CHAMBER 3 3..10 30..37}
{PLAYER_CHAMBER 4 30..37 3..10}
{PLAYER_CHAMBER 1 3..10 3..10 top-left}
{PLAYER_CHAMBER 2 3..10 3..10 bottom-right}
{PLAYER_CHAMBER 3 3..10 3..10 bottom-left}
{PLAYER_CHAMBER 4 3..10 3..10 top-right}
[/generator]
[/multiplayer]

Expand Down

0 comments on commit 3ca44f3

Please sign in to comment.