]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/deathtypes/all.qh
Merge branch 'master' into DefaultUser/func_button_relay
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / deathtypes / all.qh
1 #pragma once
2
3 #include <common/notifications/all.qh>
4
5 REGISTRY(Deathtypes, BITS(8))
6 #define Deathtypes_from(i) _Deathtypes_from(i, NULL)
7 REGISTER_REGISTRY(Deathtypes)
8 REGISTRY_CHECK(Deathtypes)
9
10 .entity death_msgself;
11 .entity death_msgmurder;
12 .string death_msgextra;
13
14 #define REGISTER_DEATHTYPE(id, msg_death, msg_death_by, extra) \
15     REGISTER(Deathtypes, DEATH, id, m_id, new_pure(deathtype)) { \
16         this.m_id += DT_FIRST; \
17         this.nent_name = #id; \
18         this.death_msgextra = extra; \
19         this.death_msgself = msg_death; \
20         this.death_msgmurder = msg_death_by; \
21     }
22
23 const int DEATH_WEAPONMASK = BITS(8);
24 const int HITTYPE_SECONDARY = BITS(1) << 8;
25 /** automatically set by RadiusDamage */
26 const int HITTYPE_SPLASH = BITS(1) << 9;
27 const int HITTYPE_BOUNCE = BITS(1) << 10;
28 const int HITTYPE_ARMORPIERCE = BITS(1) << 11;
29 // unused yet
30 const int HITTYPE_RESERVED = BITS(1) << 12;
31 const int DEATH_HITTYPEMASK = HITTYPE_SECONDARY | HITTYPE_SPLASH | HITTYPE_BOUNCE | HITTYPE_ARMORPIERCE | HITTYPE_RESERVED;
32 // normal deaths begin
33 const int DT_FIRST = BIT(13);
34
35 #define DEATH_ISSPECIAL(t)      (t >= DT_FIRST)
36 #define DEATH_IS(t, dt)         (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)) == dt)
37 #define DEATH_ENT(t)            (DEATH_ISSPECIAL(t) ?  (Deathtypes_from(t - DT_FIRST)) : NULL)
38 #define DEATH_ISVEHICLE(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "vehicle")
39 #define DEATH_ISTURRET(t)       (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "turret")
40 #define DEATH_ISMONSTER(t)      (DEATH_ISSPECIAL(t) && (Deathtypes_from(t - DT_FIRST)).death_msgextra == "monster")
41 #define DEATH_WEAPONOF(t)       (DEATH_ISSPECIAL(t) ? WEP_Null : Weapons_from((t) & DEATH_WEAPONMASK))
42 #define DEATH_ISWEAPON(t, w)    (DEATH_WEAPONOF(t) == (w))
43
44 string Deathtype_Name(int deathtype);
45
46 #include "all.inc"