Xonotic
shield.qc
Go to the documentation of this file.
1 #include "shield.qh"
2 
3 #ifdef SVQC
4 METHOD(Shield, m_remove, void(StatusEffects this, entity actor, int removal_type))
5 {
6  bool wasactive = (actor.statuseffects && (actor.statuseffects.statuseffect_flags[this.m_id] & STATUSEFFECT_FLAG_ACTIVE));
7  if(removal_type == STATUSEFFECT_REMOVE_TIMEOUT && wasactive && IS_PLAYER(actor))
8  {
9  //Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERDOWN_SHIELD, actor.netname);
10  Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_POWERDOWN_SHIELD);
11  }
12  if(wasactive)
13  stopsound(actor, CH_TRIGGER_SINGLE); // get rid of the pickup sound
14  actor.effects &= ~(EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
15  SUPER(Shield).m_remove(this, actor, removal_type);
16 }
17 METHOD(Shield, m_apply, void(StatusEffects this, entity actor, float eff_time, float eff_flags))
18 {
19  bool wasactive = (actor.statuseffects && (actor.statuseffects.statuseffect_flags[this.m_id] & STATUSEFFECT_FLAG_ACTIVE));
20  if(!wasactive && IS_PLAYER(actor))
21  {
22  if(!g_cts)
23  Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_POWERUP_SHIELD, actor.netname);
24  Send_Notification(NOTIF_ONE, actor, MSG_CENTER, CENTER_POWERUP_SHIELD);
25  }
26  SUPER(Shield).m_apply(this, actor, eff_time, eff_flags);
27 }
28 METHOD(Shield, m_tick, void(StatusEffects this, entity actor))
29 {
30  play_countdown(actor, StatusEffects_gettime(this, actor), SND_POWEROFF);
31  actor.effects |= (EF_RED | EF_ADDITIVE | EF_FULLBRIGHT);
32  SUPER(Shield).m_tick(this, actor);
33 }
34 #endif
35 #ifdef CSQC
36 METHOD(Shield, m_active, bool(StatusEffects this, entity actor))
37 {
39  return true;
40  return SUPER(Shield).m_active(this, actor);
41 }
42 METHOD(Shield, m_tick, void(StatusEffects this, entity actor))
43 {
44  if(this.m_hidden)
45  return;
46 
47  float currentTime = (autocvar__hud_configure) ? 27 : bound(0, actor.statuseffect_time[this.m_id] - time, 99);
48  addPowerupItem(this.m_name, this.m_icon, autocvar_hud_progressbar_shield_color, currentTime, this.m_lifetime, (actor.statuseffect_flags[this.m_id] & STATUSEFFECT_FLAG_PERSISTENT));
49 }
50 #endif
void play_countdown(entity this, float finished, Sound samp)
Definition: client.qc:1447
bool autocvar__hud_configure
Definition: hud_config.qh:3
Definition: shield.qh:55
entity() spawn
#define METHOD(cname, name, prototype)
Definition: oo.qh:257
void addPowerupItem(string name, string icon, vector color, float currentTime, float lifeTime, bool isInfinite)
Definition: powerups.qc:38
const float EF_ADDITIVE
Definition: csprogsdefs.qc:300
#define SUPER(cname)
Definition: oo.qh:219
const float EF_FULLBRIGHT
Definition: csprogsdefs.qc:303
int m_id
Definition: effect.qh:19
Effect is currently being granted passively.
Definition: all.qh:20
#define g_cts
Definition: cts.qh:36
#define NULL
Definition: post.qh:17
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
const float EF_RED
Definition: csprogsdefs.qc:307
float time
Definition: csprogsdefs.qc:16
vector autocvar_hud_progressbar_shield_color
Definition: powerups.qh:12
#define IS_PLAYER(v)
Definition: utils.qh:9
string m_name
Definition: scores.qh:135