Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
heal.qc
Go to the documentation of this file.
1#include "heal.qh"
2
3#ifdef SVQC
6
8{
10 || IS_DEAD(toucher) || STAT(FROZEN, toucher))
11 return;
12
13 float health_factor = autocvar_g_nades_heal_rate * frametime * 0.5;
14 if (toucher != this.realowner)
15 health_factor *= (SAME_TEAM(toucher, this.realowner))
18
19 if (health_factor > 0)
20 {
21 float maxhealth = (IS_MONSTER(toucher))
22 ? toucher.max_health
24 if (GetResource(toucher, RES_HEALTH) < maxhealth)
25 {
26 if (this.nade_show_particles)
27 Send_Effect(EFFECT_HEALING, toucher.origin, vec2(toucher.velocity), 1);
28
29 GiveResourceWithLimit(toucher, RES_HEALTH, health_factor, maxhealth);
30 }
31 }
32 else if (health_factor < 0)
33 Damage(toucher, this, this.realowner,
34 -health_factor,
35 DEATH_NADE_HEAL.m_id,
37 toucher.origin,
38 '0 0 0'
39 );
40
41 float armor_factor = autocvar_g_nades_heal_armor_rate * frametime * 0.5;
42 if (toucher != this.realowner)
43 armor_factor *= autocvar_g_nades_heal_friend;
44
45 if (SAME_TEAM(toucher, this))
46 {
47 float maxarmor = autocvar_g_pickup_armormega_max;
48 if (GetResource(toucher, RES_ARMOR) < maxarmor)
49 GiveResourceWithLimit(toucher, RES_ARMOR, armor_factor, maxarmor);
50 }
51}
52
58#endif // SVQC
59#ifdef MENUQC
60METHOD(HealNade, describe, string(HealNade this))
61{
62 TC(HealNade, this);
64 PAR(_("The %s detonates after a short delay, temporarily creating a healing orb around the point where it detonated for several seconds. "
65 "If your team members enter the orb they will recover health, and if enemies enter the sphere they will be harmed."), COLORED_NAME(this));
66 return PAGE_TEXT;
67}
68#endif // MENUQC
int autocvar_g_pickup_armormega_max
Definition armor.qh:180
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define COLORED_NAME(this)
Definition color.qh:195
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
float frametime
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:493
#define DMG_NOWEP
Definition damage.qh:104
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
RES_ARMOR
Definition ent_cs.qc:130
int autocvar_g_pickup_healthmega_max
Definition health.qh:179
#define TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:82
void nade_heal_boom(entity this)
Definition heal.qc:53
void nade_heal_touch(entity this, entity toucher)
Definition heal.qc:7
float autocvar_g_nades_heal_friend
Definition heal.qh:10
float autocvar_g_nades_heal_time
Definition heal.qh:7
float autocvar_g_nades_heal_rate
Definition heal.qh:8
float autocvar_g_nades_heal_radius
Definition heal.qh:12
float autocvar_g_nades_heal_armor_rate
Definition heal.qh:9
float autocvar_g_nades_heal_foe
Definition heal.qh:11
#define METHOD(cname, name, prototype)
Definition oo.qh:269
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
#define PAGE_TEXT
Definition string.qh:642
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:648
#define PAGE_TEXT_INIT()
Definition string.qh:641
entity nades_spawn_orb(entity this, float orb_lifetime, float orb_rad)
Spawns an orb for some nade types.
Definition sv_nades.qc:79
bool nade_show_particles
Definition sv_nades.qh:53
void GiveResourceWithLimit(entity receiver, Resource res_type, float amount, float limit)
Gives an entity some resource but not more than a limit.
#define SAME_TEAM(a, b)
Definition teams.qh:241
entity realowner
#define IS_MONSTER(v)
Definition utils.qh:23
#define IS_VEHICLE(v)
Definition utils.qh:24
#define vec2(...)
Definition vector.qh:90