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
14{
15 return (e != WarpZone_SearchInRadius_otherent && e.takedamage
16 && (IS_PLAYER(e) || IS_MONSTER(e))
17 && !IS_DEAD(e) && GetResource(e, RES_HEALTH) > 0 && nade_current_freeze_time > 0
18 && (!e.revival_time || (time - e.revival_time) >= 1.5)
19 && !STAT(FROZEN, e) && !StatusEffects_active(STATUSEFFECT_Frozen, e));
20}
22{
24 {
25 delete(this);
26 return;
27 }
28
29 if (time >= this.ltime)
30 {
32 {
33 vector expcol_min = nades_PlayerColor(this.realowner, false);
34 vector expcol_max = nades_PlayerColor(this.realowner, true);
35 Send_Effect_Core(EFFECT_NADE_EXPLODE, this.origin + '0 0 1', '0 0 0', 1, expcol_min, expcol_max, -1, -1, -1, NULL);
36 sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
37
38 nade_normal_boom(this);
39 }
40 delete(this);
41 return;
42 }
43
44 this.nextthink = time + 0.1;
45
46 // gaussian
47 float randomr = random();
48 randomr = exp(-5 * randomr * randomr) * autocvar_g_nades_ice_radius;
49 float randomw = random() * (2 * M_PI);
50 vector randomp;
51 randomp.x = randomr * cos(randomw);
52 randomp.y = randomr * sin(randomw);
53 randomp.z = 1;
54 Send_Effect(EFFECT_ELECTRO_MUZZLEFLASH, this.origin + randomp, '0 0 0', 1);
55
56 if (time >= this.nade_special_time)
57 {
58 this.nade_special_time = time + 5/16; // 0.3125
59
60 Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
61 Send_Effect(EFFECT_ICEFIELD, this.origin, '0 0 0', 1);
62 }
63
67 for (; head; head = head.chain)
68 {
70 {
71 case 0: break; // affect everyone
72 default:
73 case 2: if (SAME_TEAM(head, this.realowner)) continue; // don't affect teammates
74 // fall through (check case 1 condition too)
75 case 1: if (head == this.realowner) continue; // don't affect the player who threw the nade
76 }
78 }
79}
80
82{
83 entity fountain = new(nade_ice_fountain);
84 fountain.owner = this.owner;
85 fountain.realowner = this.realowner;
86 fountain.origin = this.origin;
87 fountain.flags = FL_PROJECTILE;
88 IL_PUSH(g_projectiles, fountain);
89 setorigin(fountain, fountain.origin);
90 setthink(fountain, nade_ice_think);
91 fountain.nextthink = time;
92 fountain.pushltime = fountain.wait = fountain.ltime = time + autocvar_g_nades_ice_freeze_time;
93 fountain.team = this.team;
94 set_movetype(fountain, MOVETYPE_TOSS);
95 fountain.projectiledeathtype = DEATH_NADE_ICE.m_id;
96 fountain.bot_dodge = false;
97 setsize(fountain, '-16 -16 -16', '16 16 16');
98 fountain.nade_special_time = time + 0.3;
99 fountain.angles = this.angles;
100
102 {
103 setmodel(fountain, MDL_PROJECTILE_GRENADE);
104 entity timer = new(nade_timer);
105 setmodel(timer, MDL_NADE_TIMER);
106 setattachment(timer, fountain, "");
107 timer.colormap = this.colormap;
108 timer.glowmod = this.glowmod;
110 timer.nextthink = time;
111 timer.wait = fountain.wait;
112 timer.nade_lifetime = this.nade_lifetime;
113 timer.owner = fountain;
114 timer.skin = 10;
115 }
116 else
117 setmodel(fountain, MDL_Null);
118}
119#endif // SVQC
120#ifdef MENUQC
121METHOD(IceNade, describe, string(IceNade this))
122{
123 TC(IceNade, this);
125 PAR(_("The %s detonates after a short delay, freezing any enemies who walk within the explosion radius for a few seconds after the explosion. "
126 "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));
127 return PAGE_TEXT;
128}
129#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:189
#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:77
float time
float nextthink
float colormap
vector origin
vector glowmod
void Send_Effect_Core(entity eff, vector eff_loc, vector eff_vel, int eff_cnt, vector eff_col_min, vector eff_col_max, float eff_alpha_min, float eff_alpha_max, float eff_alpha_fade, entity ignore)
Definition all.qc:74
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:155
ent angles
Definition ent_cs.qc:146
float timer
Definition hud.qh:125
void nade_ice_freeze(entity freezefield, entity frost_target, float freezetime)
Definition ice.qc:4
bool nade_ice_think_cond(entity e)
Definition ice.qc:13
float nade_current_freeze_time
Definition ice.qc:12
void nade_ice_boom(entity this)
Definition ice.qc:81
void nade_ice_think(entity this)
Definition ice.qc:21
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 TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:94
entity WarpZone_SearchInRadius(vector org, float rad, float nomonsters, WarpZone_FindRadius_cond_callback_t cb)
Modified findradius aware of warpzones, that only includes entities that meet the "cb" criteria.
Definition common.qc:680
noref entity WarpZone_SearchInRadius_otherent
Free to use in the callback.
Definition common.qh:71
#define MOVE_NOTHING
Definition common.qh:35
float exp(float e)
Definition mathlib.qc:70
#define M_PI
pi
Definition mathlib.qh:114
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:139
void nade_normal_boom(entity this)
Definition normal.qc:4
#define METHOD(cname, name, prototype)
Definition oo.qh:274
#define NULL
Definition post.qh:14
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
#define setthink(e, f)
vector
Definition self.qh:96
IntrusiveList g_projectiles
Definition common.qh:70
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:651
#define PAR(...)
Adds an individually translatable paragraph to PAGE_TEXT without having to deal with strcat and sprin...
Definition string.qh:657
#define PAGE_TEXT_INIT()
Definition string.qh:650
vector nades_PlayerColor(entity this, bool isPants)
Definition sv_nades.qc:14
void nade_timer_think(entity this)
Definition sv_nades.qc:28
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