nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
war.h
Go to the documentation of this file.
1#ifndef NANOMMO_BOT_WAR_H_
2#define NANOMMO_BOT_WAR_H_
3
4#include <cstddef>
5#include <cstdint>
6#include <optional>
7#include <string>
8#include <vector>
9
10#include "protocol/nanommo.pb.h"
11
12namespace nanommo {
13
14/// A bot at war is in one of two guilds, and fights the other's players.
15struct Side {
16 std::string guild;
17 std::string enemy;
18 /// For the first bot of each side, which founds the guild and leads it, the
19 /// rest of the side, by their names, whom it asks in. Empty for the rest,
20 /// who say yes when it asks.
21 std::vector<std::string> recruits;
22 /// Whether the bot is the first of its side, which leads it even when
23 /// nobody else is on it.
24 bool leads = false;
25 /// How many bots are on the side, its leader with them.
26 int size = 1;
27 /// Where the bot waits for the rest of its side to join, before the charge:
28 /// its place in its side's camp, either side of where new players come in.
29 float camp_x = 0.0f;
30 float camp_z = 0.0f;
31};
32
33/// What the side's leader does about its guild next, one thing at a time:
34/// founds it, asks the enemy to war until they're at war, and then asks in
35/// the first of its side who isn't in it yet, from the recruit after the one
36/// it asked last, next, round the list. Nothing for the rest of the side, or
37/// once everyone's in.
38std::optional<protocol::GuildAction> Enlist(const Side& side,
39 const protocol::Guild& guild,
40 std::size_t& next);
41
42/// The nearest player of the enemy guild the bot at x and z can see, alive,
43/// by their id, or 0 for none.
44uint32_t NearestEnemy(const Side& side, const protocol::World& seen, float x,
45 float z);
46
47} // namespace nanommo
48
49#endif // NANOMMO_BOT_WAR_H_
Definition chat.cc:9
uint32_t NearestEnemy(const Side &side, const protocol::World &seen, float x, float z)
Definition war.cc:43
std::optional< protocol::GuildAction > Enlist(const Side &side, const protocol::Guild &guild, std::size_t &next)
Definition war.cc:15
A bot at war is in one of two guilds, and fights the other's players.
Definition war.h:15
int size
How many bots are on the side, its leader with them.
Definition war.h:26
float camp_x
Definition war.h:29
std::string enemy
Definition war.h:17
std::vector< std::string > recruits
Definition war.h:21
bool leads
Definition war.h:24
std::string guild
Definition war.h:16
float camp_z
Definition war.h:30