1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#pragma once
#include "game/build_graph.hpp" // MaterialDef
#include <vector>
#include <string>
class ScriptEngine;
// A weapon definition, loaded from Lua (data/weapons.lua). Values are in our
// world units (scaled from the Forts data).
struct WeaponDef {
std::string name;
float muzzle_speed; // launch speed (units/s)
float reload; // seconds between shots
float splash_damage; // damage at blast centre
float splash_radius; // blast radius (units)
float knockback; // impulse applied to nearby nodes
float projectile_radius; // collision radius of the shell
float fire_chance; // 0..1 chance to ignite on impact (M4 fire)
float min_fire_angle; // firing-arc lower bound, radians rel. to mount
float max_fire_angle; // firing-arc upper bound, radians rel. to mount
bool is_beam; // laser (hitscan beam) vs ballistic shell
float beam_range; // max beam length (units)
float beam_dps; // HP damage per second to the struck strut
float beam_duration; // seconds the beam stays on
float energy_cost; // energy spent per shot (Forts EnergyFireCost)
float recoil; // velocity kick shoved back into the FIRING
// structure on each shot (Forts Recoil); 0 = none
std::string texture; // turret/base sprite (CC0 placeholder)
std::string projectile_texture; // shell sprite (CC0 placeholder)
std::string texture_forts; // preferred BYO Forts turret art
std::string projectile_texture_forts; // preferred BYO Forts shell art
};
// Loads the material table from <data_dir>/materials.lua, then applies every
// mod under <data_dir>/mods/<name>/ (each may define mod.lua with a Priority and
// a materials.lua that mutates the base table) in (priority, name) order.
// Returns the final material list. Empty on failure.
std::vector<MaterialDef> load_materials(ScriptEngine& script,
const std::string& data_dir);
// Loads weapons from <data_dir>/weapons.lua (+ mod overrides), same layering.
std::vector<WeaponDef> load_weapons(ScriptEngine& script,
const std::string& data_dir);
// A prebuilt strut of a scenario fort, kept in map data so a map can be rebuilt
// on demand (the dev UI switches maps at runtime).
struct MapBeam { float x1, y1, x2, y2; std::string material; };
// A device type (reactor / mine / turbine / battery / ...), from data/devices.lua.
struct DeviceDef {
std::string name;
float hp;
float energy_rate, metal_rate; // resources produced per second (mine e<0)
float energy_storage, metal_storage;// added to the resource caps
bool needs_deposit; // mine: only produces on a metal deposit
bool wind; // turbine: energy scales with height
float wind_max_rate, wind_max_height;
bool is_core; // reactor: destroying it decides the game
float half_w, half_h;
float cost_metal, cost_energy; // build cost
std::string texture; // CC0 placeholder ("" = flat colour)
std::string texture_forts; // preferred BYO Forts art, else texture
float r, g, b; // fallback colour when no texture
};
struct PlacedDevice { std::string type; float x, y; int team; };
struct PlacedWeapon { std::string type; float x, y; };
// One selectable scenario from data/maps.lua (+ mod layers): the ground height,
// metal deposits, pre-placed devices (reactors, generators), the player's
// starting weapons, and every prebuilt strut. Self-contained on purpose, so the
// dev UI can tear the world down and rebuild it from another map at runtime.
//
// NOTE: terrain is still a flat half-plane, so `ground_level` moves the ground
// up and down but cannot change its SHAPE. Real terrain is M6.
struct MapDef {
std::string name;
std::string description;
float ground_level = 1.0f;
std::vector<std::pair<float,float>> deposits;
std::vector<PlacedDevice> devices;
std::vector<PlacedWeapon> weapons;
std::vector<MapBeam> beams;
};
std::vector<DeviceDef> load_devices(ScriptEngine& script, const std::string& data_dir);
// Loads every map from <data_dir>/maps.lua (+ mods), same layering as the rest.
std::vector<MapDef> load_maps(ScriptEngine& script, const std::string& data_dir);
// Clears `graph` and rebuilds it from `m`: sets ground_level, then welds every
// prebuilt beam (creating/merging endpoint nodes, ground-level ones becoming
// foundations). Requires graph.materials to be loaded.
void build_map(const MapDef& m, BuildGraph& graph);
|