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{
16 {
17 delete(this);
18 return;
19 }
20
21 if(time >= this.ltime)
22 {
24 {
25 vector expcol_min = nades_PlayerColor(this.realowner, false);
26 vector expcol_max = nades_PlayerColor(this.realowner, true);
27 entity expef = EFFECT_NADE_EXPLODE;
28 Send_Effect_Except(expef, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, NULL);
29 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
30
31 nade_normal_boom(this);
32 }
33 delete(this);
34 return;
35 }
36
37
38 this.nextthink = time + 0.1;
39
40 // gaussian
41 float randomr;
42 randomr = random();
43 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_nade_radius;
44 float randomw;
45 randomw = random() * (2 * M_PI);
46 vector randomp;
47 randomp.x = randomr * cos(randomw);
48 randomp.y = randomr * sin(randomw);
49 randomp.z = 1;
50 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
51
52 if(time >= this.nade_special_time)
53 {
54 this.nade_special_time = time + 0.7;
55
56 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
57 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
58 }
59
60
61 float current_freeze_time = this.ltime - time - 0.1;
62
63 FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage
64 && (IS_PLAYER(it) || IS_MONSTER(it)) && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0
65 && (!it.revival_time || ((time - it.revival_time) >= 1.5))
66 && !STAT(FROZEN, it) && !StatusEffects_active(STATUSEFFECT_Frozen, it),
67 {
69 {
70 case 0: break; // affect everyone
71 default:
72 case 2: if(SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
73 // fall through (check case 1 condition too)
74 case 1: if(it == this.realowner) continue; // don't affect the player who threw the nade
75 }
76 nade_ice_freeze(this, it, current_freeze_time);
77 });
78}
79
81{
82 entity fountain = new(nade_ice_fountain);
83 fountain.owner = this.owner;
84 fountain.realowner = this.realowner;
85 fountain.origin = this.origin;
86 setorigin(fountain, fountain.origin);
87 setthink(fountain, nade_ice_think);
88 fountain.nextthink = time;
89 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
90 fountain.team = this.team;
91 set_movetype(fountain, MOVETYPE_TOSS);
92 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
93 fountain.bot_dodge = false;
94 setsize(fountain, '-16 -16 -16', '16 16 16');
95 fountain.nade_special_time = time + 0.3;
96 fountain.angles = this.angles;
97
99 {
100 setmodel(fountain, MDL_PROJECTILE_GRENADE);
101 entity timer = new(nade_timer);
102 setmodel(timer, MDL_NADE_TIMER);
103 setattachment(timer, fountain, "");
104 timer.colormap = this.colormap;
105 timer.glowmod = this.glowmod;
107 timer.nextthink = time;
108 timer.wait = fountain.wait;
109 timer.nade_lifetime = this.nade_lifetime;
110 timer.owner = fountain;
111 timer.skin = 10;
112 }
113 else
114 setmodel(fountain, MDL_Null);
115}
116#endif // SVQC
117#ifdef MENUQC
118METHOD(IceNade, describe, string(IceNade this))
119{
120 TC(IceNade, this);
122 PAR(_("The %s detonates after a short delay, freezing any enemies who walk within the explosion radius for a few seconds after the explosion. "
123 "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));
124 return PAGE_TEXT;
125}
126#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:17
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
#define IS_DEAD(s)
Definition player.qh:245
#define IS_PLAYER(s)
Definition player.qh:243
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:124
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:105
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:80
void nade_ice_think(entity this)
Definition ice.qc:12
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
#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:73
#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
float ltime
Definition net.qc:10
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
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:643
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:649
#define PAGE_TEXT_INIT()
Definition string.qh:642
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:13
void nade_timer_think(entity this)
Definition sv_nades.qc:23
float nade_lifetime
Definition sv_nades.qh:45
float autocvar_g_nades_nade_radius
Definition sv_nades.qh:21
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:21