14 return protocol::MOTION_WALK;
16 return protocol::MOTION_RUN;
18 return protocol::MOTION_ATTACK;
20 return protocol::MOTION_DEAD;
22 return protocol::MOTION_SKILL;
26 return protocol::MOTION_IDLE;
30 protocol::Player sent;
34 sent.set_name(player.
name);
36 *sent.mutable_looks() = *player.
looks;
38 sent.set_faction(player.
faction);
39 sent.set_yaw(player.
yaw);
42 sent.set_level(level);
43 sent.set_health(player.
health);
46 for (
const uint32_t item :
WornOf(player)) {
47 sent.add_wearing(item);
50 sent.set_skill(player.
skill);
51 sent.set_target(player.
target);
53 sent.set_casts(player.
casts);
59 protocol::Monster sent;
61 sent.set_kind(monster.
kind);
62 sent.set_x(monster.
x);
63 sent.set_z(monster.
z);
64 sent.set_yaw(monster.
yaw);
66 sent.set_level(monster.
level);
67 sent.set_health(monster.
health);
69 sent.set_height(monster.
height);
71 sent.set_phase(
static_cast<uint32_t
>(monster.
phase) + 1);
74 sent.set_skill(monster.
casting.id());
75 sent.set_lands_in(
static_cast<uint32_t
>(
76 std::chrono::duration_cast<std::chrono::milliseconds>(
77 std::chrono::milliseconds(monster.
casting.telegraph_ms()) -
87 sent.set_kind(npc.
kind);
90 sent.set_yaw(npc.
yaw);
94protocol::World
YouIn(uint32_t
id,
const Player& player, uint32_t seed,
95 int land, std::optional<uint32_t> acked) {
100 you.set_next_level(level.
next);
101 for (
const auto& [skill, left] : player.
cooldowns) {
102 (*you.mutable_cooldowns())[skill] =
static_cast<uint32_t
>(
103 std::chrono::duration_cast<std::chrono::milliseconds>(left).count());
105 you.mutable_skills()->Add(player.
skills.begin(), player.
skills.end());
107 you.set_respawn(
static_cast<uint32_t
>(
108 std::chrono::duration_cast<std::chrono::milliseconds>(player.
respawn)
112 you.mutable_crafting()->set_recipe(player.
crafting);
113 you.mutable_crafting()->set_done(
static_cast<uint32_t
>(
114 std::chrono::duration_cast<std::chrono::milliseconds>(player.
crafted)
118 you.set_land(
static_cast<uint32_t
>(land));
120 you.set_acked(*acked);
122 you.set_steered(player.
steered);
125 protocol::Player* here = you.add_players();
130 here->clear_max_health();
131 here->clear_weapon();
132 here->clear_faction();
143 protocol::World quests;
144 protocol::Quests* on = quests.mutable_quests();
145 on->mutable_on()->insert(player.
quests.begin(), player.
quests.end());
152 protocol::Event shown;
154 shown.set_amount(event.
amount);
155 switch (event.
kind) {
157 shown.set_kind(protocol::EVENT_HIT);
161 shown.set_kind(protocol::EVENT_HURT);
164 shown.set_kind(protocol::EVENT_HEAL);
167 shown.set_kind(protocol::EVENT_LEVEL);
168 shown.set_amount(event.
level);
const protocol::Inventory & items() const
std::optional< protocol::Event > ForPlayers(const Event &event)
protocol::World YouIn(uint32_t id, const Player &player, uint32_t seed, int land, std::optional< uint32_t > acked)
Level LevelFor(uint32_t experience)
protocol::World BagOf(const Player &player)
Their bag, and their quests, each as it goes when it's changed.
protocol::World QuestsOf(const Player &player)
protocol::Motion ToProtocol(Motion motion)
std::vector< uint32_t > WornOf(const Player &player)
int MaxHealthOf(const Player &player)
uint32_t MainHandOf(const Player &player)
uint32_t monster_id
The monster the player hit, by its id in the world.
uint32_t level
The level a player's reached.
uint32_t amount
The health a hit took, or that a potion or a skill gave back.
uint32_t player_id
The player's id in the world, which the clients know them by.
std::chrono::nanoseconds cast
bool boss() const
A monster with phases is a boss.
uint32_t kind
By its id in the monsters file.
uint32_t kind
By its id in the NPCs file.
std::chrono::nanoseconds respawn
While they're dead, how long until they can come back.
std::set< uint32_t > skills
The skills the player knows, by their ids in the skills file.
std::chrono::nanoseconds crafted
std::set< uint32_t > quests_done
The quests they've turned in, which they can't take again.
std::optional< protocol::Looks > looks
float yaw
In radians, around the vertical. Zero faces along z, towards the camera.
std::map< uint32_t, uint32_t > quests
std::map< uint32_t, std::chrono::nanoseconds > cooldowns
How long until each skill they've used is ready again, by its id.
Inventory inventory
What the player carries and wears.