]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/buffs/module.inc
Merge branch 'master' into Mario/bulldozer
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / buffs / module.inc
1 #include "all.qc"
2 #ifdef SVQC
3 #include "buffs.qc"
4 #endif
5
6 #ifdef IMPLEMENTATION
7
8 string BUFF_NAME(int i)
9 {
10     Buff b = Buffs_from(i);
11     return sprintf("%s%s", rgb_to_hexcolor(b.m_color), b.m_prettyName);
12 }
13
14 #ifndef MENUQC
15 REGISTER_MUTATOR(buffs_flight, true);
16 MUTATOR_HOOKFUNCTION(buffs_flight, IsFlying)
17 {
18     noref entity e = MUTATOR_ARGV(0, entity);
19         return BUFFS_STAT(e) & BUFF_FLIGHT.m_itemid;
20 }
21 #endif
22
23 #ifdef CSQC
24 REGISTER_MUTATOR(cl_buffs, true);
25 MUTATOR_HOOKFUNCTION(cl_buffs, HUD_Powerups_add)
26 {
27     int allBuffs = getstati(STAT_BUFFS, 0, 24);
28     FOREACH(Buffs, it.m_itemid & allBuffs, LAMBDA(
29                 addPowerupItem(it.m_prettyName, strcat("buff_", it.m_name), it.m_color, bound(0, getstatf(STAT_BUFF_TIME) - time, 99), 60);
30         ));
31 }
32 MUTATOR_HOOKFUNCTION(cl_buffs, WP_Format)
33 {
34     entity this = MUTATOR_ARGV(0, entity);
35     string s = MUTATOR_ARGV(0, string);
36     if (s == WP_Buff.netname || s == RADARICON_Buff.netname)
37     {
38         Buff b = Buffs_from(this.wp_extra);
39         MUTATOR_ARGV(0, vector) = b.m_color;
40         MUTATOR_ARGV(0, string) = b.m_prettyName;
41         return true;
42     }
43 }
44
45 #endif
46 #endif