]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/nades/nades.qh
Merge branch 'martin-t/gunalign' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / nades / nades.qh
1 #pragma once
2
3 #include <common/teams.qh>
4
5 // use slots 70-100
6 const int PROJECTILE_NADE = 71;
7 const int PROJECTILE_NADE_BURN = 72;
8 const int PROJECTILE_NADE_NAPALM = 73;
9 const int PROJECTILE_NADE_NAPALM_BURN = 74;
10 const int PROJECTILE_NAPALM_FOUNTAIN = 75;
11 const int PROJECTILE_NADE_ICE = 76;
12 const int PROJECTILE_NADE_ICE_BURN = 77;
13 const int PROJECTILE_NADE_TRANSLOCATE = 78;
14 const int PROJECTILE_NADE_SPAWN = 79;
15 const int PROJECTILE_NADE_HEAL = 80;
16 const int PROJECTILE_NADE_HEAL_BURN = 81;
17 const int PROJECTILE_NADE_MONSTER = 82;
18 const int PROJECTILE_NADE_MONSTER_BURN = 83;
19 const int PROJECTILE_NADE_ENTRAP = 84;
20 const int PROJECTILE_NADE_ENTRAP_BURN = 85;
21
22 REGISTRY(Nades, BITS(4))
23 #define Nades_from(i) _Nades_from(i, NADE_TYPE_Null)
24 REGISTER_REGISTRY(Nades)
25 REGISTRY_CHECK(Nades)
26
27 #define REGISTER_NADE(id) REGISTER(Nades, NADE_TYPE, id, m_id, NEW(Nade))
28
29 CLASS(Nade, Object)
30     ATTRIB(Nade, m_id, int, 0);
31     ATTRIB(Nade, m_color, vector, '0 0 0');
32     ATTRIB(Nade, m_name, string, _("Grenade"));
33     ATTRIB(Nade, m_icon, string, "nade_normal");
34     ATTRIBARRAY(Nade, m_projectile, int, 2);
35     ATTRIBARRAY(Nade, m_trail, entity, 2);
36     METHOD(Nade, display, void(entity this, void(string name, string icon) returns)) {
37         returns(this.m_name, sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon));
38     }
39 ENDCLASS(Nade)
40
41 REGISTER_NADE(Null);
42
43 Nade Nade_FromProjectile(int proj)
44 {
45     FOREACH(Nades, true, {
46         for (int j = 0; j < 2; j++)
47         {
48             if (it.m_projectile[j] == proj) return it;
49         }
50     });
51     return NADE_TYPE_Null;
52 }
53
54 #ifdef GAMEQC
55 #include "effects.inc"
56 #endif
57
58 #include "nades.inc"
59
60 .float orb_lifetime;
61 .float orb_radius;
62
63 #ifdef SVQC
64
65 .entity nade;
66 .entity fake_nade;
67 .float nade_timer = _STAT(NADE_TIMER);
68 .float nade_refire;
69 .float bonus_nades = _STAT(NADE_BONUS);
70 .float nade_special_time;
71 .float bonus_nade_score = _STAT(NADE_BONUS_SCORE);
72 .int nade_type = _STAT(NADE_BONUS_TYPE);
73 .string pokenade_type;
74 .entity nade_damage_target;
75 .float cvar_cl_nade_type;
76 .string cvar_cl_pokenade_type;
77 .float toss_time;
78 .float stat_healing_orb = _STAT(HEALING_ORB);
79 .float stat_healing_orb_alpha = _STAT(HEALING_ORB_ALPHA);
80 .float nade_show_particles;
81
82 bool orb_send(entity this, entity to, int sf);
83
84 // Remove nades that are being thrown
85 void nades_Clear(entity player);
86
87 // Give a bonus grenade to a player
88 void nades_GiveBonus(entity player, float score);
89
90 /**
91  * called to adjust nade damage and force on hit
92  */
93 #define EV_Nade_Damage(i, o) \
94     /** nade */   i(entity, MUTATOR_ARGV_0_entity) \
95         /** weapon */ i(entity, MUTATOR_ARGV_1_entity) \
96     /** force */  i(vector, MUTATOR_ARGV_2_vector) \
97     /**/          o(vector, MUTATOR_ARGV_2_vector) \
98         /** damage */ i(float,  MUTATOR_ARGV_3_float) \
99     /**/          o(float,  MUTATOR_ARGV_3_float) \
100     /**/
101 MUTATOR_HOOKABLE(Nade_Damage, EV_Nade_Damage);
102
103 #endif