]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mutators/mutator/status_effects/all.qh
Merge branch 'master' into terencehill/lms_updates
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / status_effects / all.qh
1 #pragma once
2
3 #ifdef GAMEQC
4     #include <common/sounds/all.qh>
5 #endif
6
7 REGISTRY(StatusEffect, 32)
8 REGISTER_REGISTRY(StatusEffect)
9 #define REGISTER_STATUSEFFECT(id, inst) REGISTER(StatusEffect, STATUSEFFECT, id, m_id, inst)
10
11 REGISTRY_SORT(StatusEffect)
12 REGISTRY_CHECK(StatusEffect)
13
14 REGISTRY_DEFINE_GET(StatusEffect, NULL)
15 STATIC_INIT(StatusEffect) { FOREACH(StatusEffect, true, it.m_id = i); }
16
17 enum
18 {
19     STATUSEFFECT_FLAG_ACTIVE = BIT(0),
20     STATUSEFFECT_FLAG_PERSISTENT = BIT(1) ///< Effect is currently being granted passively.
21 };
22
23 enum
24 {
25     STATUSEFFECT_REMOVE_NORMAL,        ///< Effect is being removed by a function, calls regular removal mechanics.
26     STATUSEFFECT_REMOVE_TIMEOUT,
27     STATUSEFFECT_REMOVE_CLEAR          ///< Effect is being forcibly removed without calling any additional mechanics.
28 };
29
30 CLASS(StatusEffects, Object)
31     ATTRIB(StatusEffects, m_id, int, 0);
32     ATTRIB(StatusEffects, m_name, string);
33     ATTRIB(StatusEffects, m_icon, string);
34     ATTRIB(StatusEffects, m_color, vector, '1 1 1');
35     /** Whether the effect is displayed in the HUD */
36     ATTRIB(StatusEffects, m_hidden, bool, false);
37     /** Lifetime scale for HUD progress bars */
38     ATTRIB(StatusEffects, m_lifetime, float, 30);
39 #ifdef GAMEQC
40     ATTRIB(StatusEffects, m_sound, Sound, SND_Null);
41     ATTRIB(StatusEffects, m_sound_rm, Sound, SND_Null);
42     METHOD(StatusEffects, m_tick, void(StatusEffects this, entity actor));
43     METHOD(StatusEffects, m_active, bool(StatusEffects this, entity actor));
44     /** Stores times of status effects, the id being the index */
45     ATTRIBARRAY(StatusEffects, statuseffect_time, float, REGISTRY_MAX(StatusEffect));
46     ATTRIBARRAY(StatusEffects, statuseffect_flags, int, REGISTRY_MAX(StatusEffect));
47 #endif
48 #ifdef SVQC
49     METHOD(StatusEffects, m_apply, void(StatusEffects this, entity actor, float eff_time, int eff_flags));
50     METHOD(StatusEffects, m_remove, void(StatusEffects this, entity actor, int removal_type));
51     /** Sets the persistent flag and updates client side if returning true */
52     METHOD(StatusEffects, m_persistent, bool(StatusEffects this, entity actor)) { return false; };
53 #endif
54     METHOD(StatusEffects, display, void(StatusEffects this, void(string name, string icon) returns))
55     {
56         TC(StatusEffects, this);
57         returns(this.m_name, this.m_icon ? sprintf("/gfx/hud/%s/%s", cvar_string("menu_skin"), this.m_icon) : string_null);
58     }
59 ENDCLASS(StatusEffects)