]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/nades/all.qh
Registry: network and verify checksums on connect
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / nades / all.qh
1 #ifndef NADES_ALL_H
2 #define NADES_ALL_H
3
4 #include "../teams.qh"
5
6 .float healer_lifetime;
7 .float healer_radius;
8
9 // use slots 70-100
10 const int PROJECTILE_NADE = 71;
11 const int PROJECTILE_NADE_BURN = 72;
12 const int PROJECTILE_NADE_NAPALM = 73;
13 const int PROJECTILE_NADE_NAPALM_BURN = 74;
14 const int PROJECTILE_NAPALM_FOUNTAIN = 75;
15 const int PROJECTILE_NADE_ICE = 76;
16 const int PROJECTILE_NADE_ICE_BURN = 77;
17 const int PROJECTILE_NADE_TRANSLOCATE = 78;
18 const int PROJECTILE_NADE_SPAWN = 79;
19 const int PROJECTILE_NADE_HEAL = 80;
20 const int PROJECTILE_NADE_HEAL_BURN = 81;
21 const int PROJECTILE_NADE_MONSTER = 82;
22 const int PROJECTILE_NADE_MONSTER_BURN = 83;
23
24 REGISTRY(Nades, BITS(4))
25 #define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
26 REGISTER_REGISTRY(RegisterNades)
27 REGISTRY_CHECK(Nades)
28
29 #define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
30
31 CLASS(Nade, Object)
32     ATTRIB(Nade, m_id, int, 0)
33     ATTRIB(Nade, m_color, vector, '0 0 0')
34     ATTRIB(Nade, m_name, string, _("Grenade"))
35     ATTRIB(Nade, m_icon, string, "nade_normal")
36     ATTRIBARRAY(Nade, m_projectile, int, 2)
37     ATTRIBARRAY(Nade, m_trail, entity, 2)
38     METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) {
39         returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon));
40     }
41 ENDCLASS(Nade)
42
43 REGISTER_NADE(Null);
44
45 #ifdef SVQC
46 bool healer_send(entity this, entity to, int sf);
47 #endif
48
49 entity Nade_FromProjectile(float proj)
50 {
51     FOREACH(Nades, true, LAMBDA(
52         for (int j = 0; j < 2; j++)
53         {
54             if (it.m_projectile[j] == proj) return it;
55         }
56     ));
57     return NADE_TYPE_Null;
58 }
59
60 entity Nade_TrailEffect(int proj, int nade_team)
61 {
62     switch (proj)
63     {
64         case PROJECTILE_NADE:       return EFFECT_NADE_TRAIL(nade_team);
65         case PROJECTILE_NADE_BURN:  return EFFECT_NADE_TRAIL_BURN(nade_team);
66     }
67
68     FOREACH(Nades, true, LAMBDA(
69         for (int j = 0; j < 2; j++)
70         {
71             if (it.m_projectile[j] == proj)
72             {
73                 string trail = it.m_trail[j].eent_eff_name;
74                 if (trail) return it.m_trail[j];
75                 break;
76             }
77         }
78     ));
79
80     return EFFECT_Null;
81 }
82
83 #include "all.inc"
84
85 #endif