Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
ice.qc
Go to the documentation of this file.
1#include "ice.qh"
2
3#ifdef SVQC
4void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
5{
6 Send_Effect(EFFECT_ELECTRO_IMPACT, frost_target.origin, '0 0 0', 1);
7 StatusEffects_apply(STATUSEFFECT_Frozen, frost_target, time + freezetime, 0);
8
9 //Drop_Special_Items(frost_target);
10}
11
13{
15 {
16 delete(this);
17 return;
18 }
19
20 if (time >= this.ltime)
21 {
23 {
24 vector expcol_min = nades_PlayerColor(this.realowner, false);
25 vector expcol_max = nades_PlayerColor(this.realowner, true);
26 Send_Effect_Except(EFFECT_NADE_EXPLODE, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, NULL);
27 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
28
29 nade_normal_boom(this);
30 }
31 delete(this);
32 return;
33 }
34
35 this.nextthink = time + 0.1;
36
37 // gaussian
38 float randomr = random();
39 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_ice_radius;
40 float randomw = random() * (2 * M_PI);
41 vector randomp;
42 randomp.x = randomr * cos(randomw);
43 randomp.y = randomr * sin(randomw);
44 randomp.z = 1;
45 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
46
47 if (time >= this.nade_special_time)
48 {
49 this.nade_special_time = time + 0.7;
50
51 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
52 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
53 }
54
55 float current_freeze_time = this.ltime - time - 0.1;
56
57 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_ice_radius, it != this && it.takedamage
58 && (IS_PLAYER(it) || IS_MONSTER(it)) && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0
59 && (!it.revival_time || ((time - it.revival_time) >= 1.5))
60 && !STAT(FROZEN, it) && !StatusEffects_active(STATUSEFFECT_Frozen, it),
61 {
63 {
64 case 0: break; // affect everyone
65 default:
66 case 2: if (SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
67 // fall through (check case 1 condition too)
68 case 1: if (it == this.realowner) continue; // don't affect the player who threw the nade
69 }
70 nade_ice_freeze(this, it, current_freeze_time);
71 });
72}
73
75{
76 entity fountain = new(nade_ice_fountain);
77 fountain.owner = this.owner;
78 fountain.realowner = this.realowner;
79 fountain.origin = this.origin;
80 fountain.flags = FL_PROJECTILE;
81 IL_PUSH(g_projectiles, fountain);
82 setorigin(fountain, fountain.origin);
83 setthink(fountain, nade_ice_think);
84 fountain.nextthink = time;
85 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
86 fountain.team = this.team;
87 set_movetype(fountain, MOVETYPE_TOSS);
88 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
89 fountain.bot_dodge = false;
90 setsize(fountain, '-16 -16 -16', '16 16 16');
91 fountain.nade_special_time = time + 0.3;
92 fountain.angles = this.angles;
93
95 {
96 setmodel(fountain, MDL_PROJECTILE_GRENADE);
97 entity timer = new(nade_timer);
98 setmodel(timer, MDL_NADE_TIMER);
99 setattachment(timer, fountain, "");
100 timer.colormap = this.colormap;
101 timer.glowmod = this.glowmod;
103 timer.nextthink = time;
104 timer.wait = fountain.wait;
105 timer.nade_lifetime = this.nade_lifetime;
106 timer.owner = fountain;
107 timer.skin = 10;
108 }
109 else
110 setmodel(fountain, MDL_Null);
111}
112#endif // SVQC
113#ifdef MENUQC
114METHOD(IceNade, describe, string(IceNade this))
115{
116 TC(IceNade, this);
118 PAR(_("The %s detonates after a short delay, freezing any enemies who walk within the explosion radius for a few seconds after the explosion. "
119 "While frozen, players can't move or shoot, leaving them vulnerable to damage, but if left too long they'll unfreeze and run away!"), COLORED_NAME(this));
120 return PAGE_TEXT;
121}
122#endif // MENUQC
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.
Definition ice.qh:20
entity owner
Definition main.qh:87
int team
Definition main.qh:188
#define COLORED_NAME(this)
Definition color.qh:195
#define setmodel(this, m)
Definition model.qh:26
float ltime
Definition net.qh:10
#define IS_DEAD(s)
Definition player.qh:244
#define IS_PLAYER(s)
Definition player.qh:242
const int FL_PROJECTILE
Definition constants.qh:85
float time
float nextthink
float colormap
vector origin
vector glowmod
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
void Send_Effect_Except(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, entity ignore)
Definition all.qc:101
ent angles
Definition ent_cs.qc:121
float timer
Definition hud.qh:125
void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
Definition ice.qc:4
void nade_ice_boom(entity this)
Definition ice.qc:74
void nade_ice_think(entity this)
Definition ice.qc:12
float autocvar_g_nades_ice_radius
Definition ice.qh:10
bool autocvar_g_nades_ice_explode
Definition ice.qh:8
float autocvar_g_nades_ice_freeze_time
Definition ice.qh:7
bool autocvar_g_nades_ice_teamcheck
Definition ice.qh:9
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define FOREACH_ENTITY_RADIUS(org, dist, cond, body)
Definition iter.qh:160
#define TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:82
float exp(float e)
Definition mathlib.qc:74
#define M_PI
Definition mathlib.qh:108
float cos(float f)
float random(void)
float sin(float f)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_TOSS
Definition movetypes.qh:135
void nade_normal_boom(entity this)
Definition normal.qc:4
#define METHOD(cname, name, prototype)
Definition oo.qh:269
#define NULL
Definition post.qh:14
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
#define setthink(e, f)
vector
Definition self.qh:92
IntrusiveList g_projectiles
Definition common.qh:58
const float VOL_BASE
Definition sound.qh:36
const int CH_SHOTS
Definition sound.qh:14
const float ATTEN_NORM
Definition sound.qh:30
#define sound(e, c, s, v, a)
Definition sound.qh:52
bool StatusEffects_active(StatusEffect this, entity actor)
void StatusEffects_apply(StatusEffect this, entity actor, float eff_time, int eff_flags)
#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
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:13
void nade_timer_think(entity this)
Definition sv_nades.qc:27
float nade_lifetime
Definition sv_nades.qh:45
float nade_special_time
Definition sv_nades.qh:47
#define SAME_TEAM(a, b)
Definition teams.qh:241
entity realowner
#define IS_MONSTER(v)
Definition utils.qh:23