]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/nades/all.qh
Weapon priority list: fix invisible names
[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, BIT(3))
25 REGISTER_REGISTRY(RegisterNades)
26 #define REGISTER_NADE(id) REGISTER(RegisterNades, NADE_TYPE, Nades, id, m_id, NEW(Nade))
27
28 CLASS(Nade, Object)
29     ATTRIB(Nade, m_id, int, 0)
30     ATTRIB(Nade, m_color, vector, '0 0 0')
31     ATTRIB(Nade, m_name, string, _("Grenade"))
32     ATTRIB(Nade, m_icon, string, "nade_normal")
33     ATTRIBARRAY(Nade, m_projectile, int, 2)
34     ATTRIBARRAY(Nade, m_trail, entity, 2)
35     METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) {
36         returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon));
37     }
38 ENDCLASS(Nade)
39
40 REGISTER_NADE(Null);
41
42 #ifdef SVQC
43 bool healer_send(entity this, entity to, int sf);
44 #endif
45
46 entity Nade_FromProjectile(float proj)
47 {
48     FOREACH(Nades, true, LAMBDA(
49         for (int j = 0; j < 2; j++)
50         {
51             if (it.m_projectile[j] == proj) return it;
52         }
53     ));
54     return NADE_TYPE_Null;
55 }
56
57 entity Nade_TrailEffect(int proj, int nade_team)
58 {
59     switch (proj)
60     {
61         case PROJECTILE_NADE:       return EFFECT_NADE_TRAIL(nade_team);
62         case PROJECTILE_NADE_BURN:  return EFFECT_NADE_TRAIL_BURN(nade_team);
63     }
64
65     FOREACH(Nades, true, LAMBDA(
66         for (int j = 0; j < 2; j++)
67         {
68             if (it.m_projectile[j] == proj)
69             {
70                 string trail = it.m_trail[j].eent_eff_name;
71                 if (trail) return it.m_trail[j];
72                 break;
73             }
74         }
75     ));
76
77     return EFFECT_Null;
78 }
79
80 #include "all.inc"
81
82 #endif