Allow maps to optionally specify custom treasures (#351)
This commit is contained in:
parent
03fea8fac2
commit
91c5f47886
5 changed files with 106 additions and 37 deletions
|
@ -1,24 +1,24 @@
|
||||||
# CTF Map
|
# CTF Map
|
||||||
|
|
||||||
This mod handles multiple maps.
|
This mod handles creating and loading maps.
|
||||||
|
|
||||||
# Creating a new map
|
## Creating a new map
|
||||||
|
|
||||||
## 1. Dependencies
|
### 1. Dependencies
|
||||||
|
|
||||||
* Minetest 0.4.16 or later.
|
* Minetest 0.4.16 or later.
|
||||||
* Mods
|
* Mods
|
||||||
* ctf_map (by copying the folder from this game to `minetest/mods`)
|
* ctf_map (by copying the folder from this game to `minetest/mods`)
|
||||||
* worldedit and worldedit_commands.
|
* worldedit and worldedit_commands.
|
||||||
|
|
||||||
## 2. Find an area
|
### 2. Find an area
|
||||||
|
|
||||||
* Can use Minetest Game and any mapgen.
|
* Can use Minetest Game and any mapgen.
|
||||||
* It must be a cube, and the barrier will be in the exact center.
|
* It must be a cube, and the barrier will be in the exact center.
|
||||||
* It should be around 230x230 in surface area, but this can vary.
|
* It should be around 230x230 in surface area, but this can vary.
|
||||||
* Feel free to modify the area to your needs.
|
* Feel free to modify the area to your needs.
|
||||||
|
|
||||||
## 3. Select the area
|
### 3. Select the area
|
||||||
|
|
||||||
There are multiple ways do this, this is the simplist in most cases.
|
There are multiple ways do this, this is the simplist in most cases.
|
||||||
|
|
||||||
|
@ -32,20 +32,53 @@ There are multiple ways do this, this is the simplist in most cases.
|
||||||
* Check that the center location is the right place for the barrier to go.
|
* Check that the center location is the right place for the barrier to go.
|
||||||
* Check that the bounds extend far enough.
|
* Check that the bounds extend far enough.
|
||||||
|
|
||||||
## 4. Place barriers
|
### 4. Place barriers
|
||||||
|
|
||||||
* Set the middle barrier direction. The barrier is a plane defined by a co-ordinate = 0.
|
* Set the middle barrier direction. The barrier is a plane defined by a co-ordinate = 0.
|
||||||
If the barrier is X=0, then it will placed with every node of the barrier having X=0.
|
If the barrier is X=0, then it will placed with every node of the barrier having X=0.
|
||||||
If the barrier is Z=0, then it will placed with every node of the barrier having Z=0.
|
If the barrier is Z=0, then it will placed with every node of the barrier having Z=0.
|
||||||
* Click "place barrier". Note that this command does not have an undo.
|
* Click "place barrier". Note that this command does not have an undo.
|
||||||
|
|
||||||
## 5. Meta data
|
### 5. Meta data
|
||||||
|
|
||||||
* Set the meta data
|
* Set the meta data
|
||||||
|
|
||||||
## 6. Export
|
### 6. Export
|
||||||
|
|
||||||
* Click export, and wait until completion.
|
* Click export, and wait until completion.
|
||||||
* Copy the two files from `worlddir/schemes/` to `ctf_map/maps/`.
|
* Copy the two files from `worlddir/schems/` to `ctf_map/maps/`.
|
||||||
* Rename the files so the two prefixed numbers are consistent to existing maps.
|
* Rename the files so the two prefixed numbers are consistent to existing maps.
|
||||||
* Profit!
|
* Profit!
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
### Map meta
|
||||||
|
|
||||||
|
Each map's metadata is stored in an accompanying .conf file containing the following data:
|
||||||
|
|
||||||
|
* `name`: Name of map.
|
||||||
|
* `author`: Author of the map.
|
||||||
|
* `hint`: [Optional] Helpful hint or tip for unique maps, to help players understand the map.
|
||||||
|
* `rotation`: Rotation of the schem. [`x`|`z`]
|
||||||
|
* `schematic`: Name of the map's schematic.
|
||||||
|
* `initial_stuff`: [Optional] Comma-separated list of itemstacks to be given to the player on join and on respawn.
|
||||||
|
* `treasures`: [Optional] List of treasures to be registered for the map, in a serialized format. Refer to the `treasures` sub-section for more details.
|
||||||
|
* `r`: Radius of the map.
|
||||||
|
* `h`: Height of the map.
|
||||||
|
* `team.i`: Name of team `i`.
|
||||||
|
* `team.i.color`: Color of team `i`.
|
||||||
|
* `team.i.pos`: Position of team `i`'s flag, relative to center of schem.
|
||||||
|
* `chests.i.from`, `chests.i.to`: [Optional] Positions of diagonal corners of custom chest zone `i`, relative to the center of the schem.
|
||||||
|
* `chests.i.n`: [Optional] Number of chests to place in custom chest zone `i`.
|
||||||
|
|
||||||
|
#### `treasures`
|
||||||
|
|
||||||
|
`treasures` is a list of treasures to be registered for this map in serialized format.
|
||||||
|
|
||||||
|
An example `treasures` value that registers steel pick, shotgun, and grenade:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
treasures = default:pick_steel,0.5,5,1,10;shooter:shotgun,0.04,2,1;shooter:grenade,0.08,2,1
|
||||||
|
```
|
||||||
|
|
||||||
|
(See [here](../../other/treasurer/README.md) to understand the magic numbers)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
default
|
default
|
||||||
|
ctf_treasure?
|
||||||
stairs?
|
stairs?
|
||||||
wool?
|
wool?
|
||||||
ctf_team_base?
|
ctf_team_base?
|
||||||
|
|
|
@ -137,10 +137,12 @@ function ctf_match.load_map_meta(idx, name)
|
||||||
local meta = Settings(conf_path)
|
local meta = Settings(conf_path)
|
||||||
|
|
||||||
if meta:get("r") == nil then
|
if meta:get("r") == nil then
|
||||||
error("Map was not properly configured " .. conf_path)
|
error("Map was not properly configured: " .. conf_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
local initial_stuff = meta:get("initial_stuff")
|
local initial_stuff = meta:get("initial_stuff")
|
||||||
|
local treasures = meta:get("treasures")
|
||||||
|
treasures = treasures and treasures:split(";")
|
||||||
local map = {
|
local map = {
|
||||||
idx = idx,
|
idx = idx,
|
||||||
name = meta:get("name"),
|
name = meta:get("name"),
|
||||||
|
@ -149,11 +151,12 @@ function ctf_match.load_map_meta(idx, name)
|
||||||
rotation = meta:get("rotation"),
|
rotation = meta:get("rotation"),
|
||||||
schematic = name .. ".mts",
|
schematic = name .. ".mts",
|
||||||
initial_stuff = initial_stuff and initial_stuff:split(","),
|
initial_stuff = initial_stuff and initial_stuff:split(","),
|
||||||
|
treasures = treasures,
|
||||||
r = tonumber(meta:get("r")),
|
r = tonumber(meta:get("r")),
|
||||||
h = tonumber(meta:get("h")),
|
h = tonumber(meta:get("h")),
|
||||||
offset = offset,
|
offset = offset,
|
||||||
teams = {},
|
teams = {},
|
||||||
chests = {},
|
chests = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(map.r <= max_r)
|
assert(map.r <= max_r)
|
||||||
|
@ -176,6 +179,35 @@ function ctf_match.load_map_meta(idx, name)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Register per-map treasures or the default set of treasures
|
||||||
|
-- if treasures field hasn't been defined in map meta
|
||||||
|
if treasurer and ctf_treasure then
|
||||||
|
treasurer.treasures = {}
|
||||||
|
if treasures then
|
||||||
|
for _, item in pairs(treasures) do
|
||||||
|
item = item:split(",")
|
||||||
|
-- treasurer.register_treasure(name, rarity, preciousness, count)
|
||||||
|
if #item == 4 then
|
||||||
|
treasurer.register_treasure(item[1],
|
||||||
|
tonumber(item[2]),
|
||||||
|
tonumber(item[3]),
|
||||||
|
tonumber(item[4]))
|
||||||
|
-- treasurer.register_treasure(name, rarity, preciousness, {min, max})
|
||||||
|
elseif #item == 5 then
|
||||||
|
treasurer.register_treasure(item[1],
|
||||||
|
tonumber(item[2]),
|
||||||
|
tonumber(item[3]),
|
||||||
|
{
|
||||||
|
tonumber(item[4]),
|
||||||
|
tonumber(item[5])
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
ctf_treasure.register_default_treasures()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Read custom chest zones from config
|
-- Read custom chest zones from config
|
||||||
i = 1
|
i = 1
|
||||||
while meta:get("chests." .. i .. ".from") do
|
while meta:get("chests." .. i .. ".from") do
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
treasurer
|
treasurer
|
||||||
default
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
ctf_treasure = {}
|
||||||
|
|
||||||
|
function ctf_treasure.register_default_treasures()
|
||||||
treasurer.register_treasure("default:ladder",0.3,5,{1,20})
|
treasurer.register_treasure("default:ladder",0.3,5,{1,20})
|
||||||
treasurer.register_treasure("default:torch",0.3,5,{1,20})
|
treasurer.register_treasure("default:torch",0.3,5,{1,20})
|
||||||
treasurer.register_treasure("default:cobble",0.4,5,{45,99})
|
treasurer.register_treasure("default:cobble",0.4,5,{45,99})
|
||||||
|
@ -19,3 +22,4 @@ treasurer.register_treasure("shooter:grenade",0.08,2,1)
|
||||||
treasurer.register_treasure("shooter:machine_gun",0.02,2,1)
|
treasurer.register_treasure("shooter:machine_gun",0.02,2,1)
|
||||||
treasurer.register_treasure("shooter:ammo",0.3,2,{1,10})
|
treasurer.register_treasure("shooter:ammo",0.3,2,{1,10})
|
||||||
treasurer.register_treasure("shooter:arrow_white",0.5,2,{2,18})
|
treasurer.register_treasure("shooter:arrow_white",0.5,2,{2,18})
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue