Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarDamageTypes.hpp
blob: 632b2ee816147b0030b9b4495eee36aedcbe7f8e (plain)
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
#pragma once

#include "StarVector.hpp"
#include "StarDataStream.hpp"
#include "StarJson.hpp"
#include "StarGameTypes.hpp"

namespace Star {

enum DamageType : uint8_t { NoDamage, Damage, IgnoresDef, Knockback, Environment, Status };
extern EnumMap<DamageType> const DamageTypeNames;

enum class HitType { Hit, StrongHit, WeakHit, ShieldHit, Kill };
extern EnumMap<HitType> const HitTypeNames;

enum class TeamType : uint8_t {
  Null,
  // non-PvP-enabled players and player allied NPCs
  Friendly,
  // hostile and neutral NPCs and monsters
  Enemy,
  // PvP-enabled players
  PVP,
  // cannot damage anything, can be damaged by Friendly/PVP/Assistant
  Passive,
  // cannot damage or be damaged
  Ghostly,
  // cannot damage enemies, can be damaged by anything except enemy
  Environment,
  // damages anything except ghostly, damaged by anything except ghostly/passive
  // used for self damage
  Indiscriminate,
  // cannot damage friendlies and cannot be damaged by anything
  Assistant
};
extern EnumMap<TeamType> const TeamTypeNames;

typedef uint16_t TeamNumber;

struct EntityDamageTeam {
  EntityDamageTeam();
  explicit EntityDamageTeam(TeamType type, TeamNumber team = 0);
  explicit EntityDamageTeam(Json const& json);

  Json toJson() const;

  bool canDamage(EntityDamageTeam victim, bool victimIsSelf) const;

  bool operator==(EntityDamageTeam const& rhs) const;

  TeamType type;
  TeamNumber team;
};
DataStream& operator<<(DataStream& ds, EntityDamageTeam const& team);
DataStream& operator>>(DataStream& ds, EntityDamageTeam& team);

TeamNumber soloPvpTeam(ConnectionId clientId);
}