nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
reactions.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_REACTIONS_H_
2#define NANOMMO_CLIENT_REACTIONS_H_
3
4#include <cstdint>
5#include <map>
6#include <vector>
7
8#include "client/animator.h"
9
10namespace nanommo {
11
12/// How the monsters take the blows that land on them: each lights up, and
13/// rocks back away from whoever hit it, and one thrown up tumbles as it goes.
14class Reactions {
15 public:
16 /// How long a flash takes to fade, in seconds.
17 static constexpr float kFlashTime = 0.15f;
18 /// How far a blow rocks a monster back at most, in radians, and how fast it
19 /// gets there and comes back.
20 static constexpr float kRock = 0.3f;
21 static constexpr float kRockIn = 0.03f;
22 static constexpr float kRockOut = 0.12f;
23 /// How far over a monster in the air tips, in radians, for each metre up.
24 static constexpr float kTumble = 0.6f;
25 /// How long a blow's kept, in seconds: long enough for a monster it threw
26 /// up to come down again, tipped the way it sent it.
27 static constexpr float kHeld = 2.0f;
28
29 /// The player hit the monster, both by their ids.
30 void Hit(uint32_t monster, uint32_t player);
31
32 /// Moves each blow's reaction on.
33 void Update(float seconds);
34
35 /// Lights up, rocks and tips the monsters, as their blows have them now.
36 void Apply(std::vector<Figure>& figures);
37
38 private:
39 struct Blow {
40 uint32_t player = 0;
41 /// Seconds since it landed.
42 float age = 0.0f;
43 /// Away from the player, as a yaw, once we've seen where they are.
44 float away = 0.0f;
45 bool aimed = false;
46 };
47 /// The last blow on each monster, by its id.
48 std::map<uint32_t, Blow> blows_;
49};
50
51} // namespace nanommo
52
53#endif // NANOMMO_CLIENT_REACTIONS_H_
static constexpr float kRockOut
Definition reactions.h:22
void Apply(std::vector< Figure > &figures)
Lights up, rocks and tips the monsters, as their blows have them now.
Definition reactions.cc:23
static constexpr float kRockIn
Definition reactions.h:21
static constexpr float kFlashTime
How long a flash takes to fade, in seconds.
Definition reactions.h:17
void Hit(uint32_t monster, uint32_t player)
The player hit the monster, both by their ids.
Definition reactions.cc:10
static constexpr float kHeld
Definition reactions.h:27
void Update(float seconds)
Moves each blow's reaction on.
Definition reactions.cc:14
static constexpr float kRock
Definition reactions.h:20
static constexpr float kTumble
How far over a monster in the air tips, in radians, for each metre up.
Definition reactions.h:24
Definition chat.cc:9