Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
napalm.qc
Go to the documentation of this file.
1#include "napalm.qh"
2
3#ifdef SVQC
4void napalm_damage(entity this, float rad, float damage, float edgedamage, float burntime)
5{
6 if (damage < 0)
7 return;
8
9 // NOTE: W_Fireball_LaserPlay uses similar code, please keep them in sync
11 entity last = NULL;
12 float last_dist = 0;
13 // optimize code by comparing squared distances and avoiding vlen and sqrt calls as much as possible
14 float rad2 = rad * rad;
15 for (entity e = WarpZone_FindRadius(this.origin, rad, true); e; e = e.chain)
16 if (e.takedamage == DAMAGE_AIM
17 && (this.realowner != e || autocvar_g_nades_napalm_selfdamage)
18 && (!IS_PLAYER(e) || !this.realowner || DIFF_TEAM(e, this))
19 && !STAT(FROZEN, e))
20 {
21 vector p = e.origin;
22 p.x += e.mins.x + random() * (e.maxs.x - e.mins.x);
23 p.y += e.mins.y + random() * (e.maxs.y - e.mins.y);
24 p.z += e.mins.z + random() * (e.maxs.z - e.mins.z);
25 float dist2 = vlen2(WarpZone_UnTransformOrigin(e, this.origin) - p);
26 if (dist2 < rad2)
27 {
28 e.fireball_impactvec = p;
29 last = e;
30 last_dist = sqrt(dist2); // won't be recalculated if this entity is the only or last one found
31 RandomSelection_AddEnt(e, 1 / (1 + last_dist), !StatusEffects_active(STATUSEFFECT_Burning, e));
32 }
33 }
35 {
36 float dist;
38 dist = last_dist; // already calculated
39 else
41 dist = damage + (edgedamage - damage) * (dist / rad);
42 Fire_AddDamage(RandomSelection_chosen_ent, this.realowner, dist * burntime, burntime, this.projectiledeathtype);
43 //trailparticles(this, particleeffectnum(EFFECT_FIREBALL_LASER), this.origin, RandomSelection_chosen_ent.fireball_impactvec);
44 Send_Effect(EFFECT_FIREBALL_LASER, this.origin, RandomSelection_chosen_ent.fireball_impactvec - this.origin, 1);
45 }
46}
47
49{
51 || time > this.pushltime)
52 {
53 delete(this);
54 return;
55 }
56
57 vector midpoint = (this.absmin + this.absmax) * 0.5;
58 if (pointcontents(midpoint) == CONTENT_WATER)
59 {
60 this.velocity *= 0.5;
61
62 if (pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
63 this.velocity.z = 200;
64 }
65
66 this.angles = vectoangles(this.velocity);
67
70
71 this.nextthink = time + 0.1;
72}
73
75{
77
78 entity proj = new(grenade);
79 proj.owner = this.owner;
80 proj.realowner = this.realowner;
81 proj.team = this.owner.team;
82 proj.bot_dodge = true;
83 proj.bot_dodgerating = autocvar_g_nades_napalm_ball_damage;
85 proj.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
87 setmodel(proj, MDL_Null);
88 proj.scale = 1;//0.5;
89 setsize(proj, '-4 -4 -4', '4 4 4');
90 setorigin(proj, this.origin);
92 proj.nextthink = time;
94 proj.effects = EF_LOWPRECISION | EF_FLAME;
95
96 vector kick;
99 kick.z = autocvar_g_nades_napalm_ball_spread * (random() * 0.5 + 0.5);
100 proj.velocity = kick;
101
103
104 proj.angles = vectoangles(proj.velocity);
105 proj.flags = FL_PROJECTILE;
106 IL_PUSH(g_projectiles, proj);
107 IL_PUSH(g_bot_dodge, proj);
108 proj.missile_flags = MIF_SPLASH | MIF_PROXY | MIF_ARC;
109
110 //CSQCProjectile(proj, true, PROJECTILE_NAPALM_FIRE, true);
111}
112
114{
116 || time >= this.ltime)
117 {
118 delete(this);
119 return;
120 }
121
122 vector midpoint = (this.absmin + this.absmax) * 0.5;
123 if (pointcontents(midpoint) == CONTENT_WATER)
124 {
125 this.velocity *= 0.5;
126
127 if (pointcontents(midpoint + '0 0 16') == CONTENT_WATER)
128 this.velocity.z = 200;
129
131 }
132
135
136 this.nextthink = time + 0.1;
137 if (time >= this.nade_special_time)
138 {
140 nade_napalm_ball(this);
141 }
142}
143
145{
146 for (int c = 0; c < autocvar_g_nades_napalm_ball_count; ++c)
147 nade_napalm_ball(this);
148
149 entity fountain = new(nade_napalm_fountain);
150 fountain.owner = this.owner;
151 fountain.realowner = this.realowner;
152 fountain.origin = this.origin;
153 fountain.flags = FL_PROJECTILE;
154 IL_PUSH(g_projectiles, fountain);
155 IL_PUSH(g_bot_dodge, fountain);
156 setorigin(fountain, fountain.origin);
158 fountain.nextthink = time;
160 fountain.pushltime = fountain.ltime;
161 fountain.team = this.team;
162 set_movetype(fountain, MOVETYPE_TOSS);
163 fountain.projectiledeathtype = DEATH_NADE_NAPALM.m_id;
164 fountain.bot_dodge = true;
165 fountain.bot_dodgerating = autocvar_g_nades_napalm_fountain_damage;
166 fountain.nade_special_time = time;
167 setsize(fountain, '-16 -16 -16', '16 16 16');
168 CSQCProjectile(fountain, true, PROJECTILE_NAPALM_FOUNTAIN, true);
169}
170#endif // SVQC
171#ifdef MENUQC
172METHOD(NapalmNade, describe, string(NapalmNade this))
173{
174 TC(NapalmNade, this);
176 PAR(_("The %s detonates after a short delay, spreading fiery napalm globs around in a fountain. "
177 "The napalm fire balls burn for a while, and damage players who get too close."), COLORED_NAME(this));
178 return PAGE_TEXT;
179}
180#endif // MENUQC
IntrusiveList g_bot_dodge
Definition api.qh:150
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
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_PLAYER(s)
Definition player.qh:242
const int FL_PROJECTILE
Definition constants.qh:76
vector velocity
const float CONTENT_WATER
float time
const float EF_FLAME
float nextthink
vector absmax
vector origin
vector absmin
void UpdateCSQCProjectile(entity e)
void CSQCProjectile(entity e, float clientanimate, int type, float docull)
float Fire_AddDamage(entity e, entity o, float d, float t, float dt)
Definition damage.qc:965
float EF_LOWPRECISION
void Send_Effect(entity eff, vector eff_loc, vector eff_vel, int eff_cnt)
Definition all.qc:120
ent angles
Definition ent_cs.qc:146
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
float pushltime
Definition jumppads.qh:21
#define TC(T, sym)
Definition _all.inc:82
#define STAT(...)
Definition stats.qh:94
entity WarpZone_FindRadius(vector org, float rad, bool needlineofsight)
Definition common.qc:651
vector WarpZone_UnTransformOrigin(entity wz, vector v)
Definition common.qc:519
float random(void)
float vlen(vector v)
vector vectoangles(vector v)
float sqrt(float f)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_TOSS
Definition movetypes.qh:139
const int MOVETYPE_BOUNCE
Definition movetypes.qh:143
void nade_napalm_boom(entity this)
Definition napalm.qc:144
void napalm_fountain_think(entity this)
Definition napalm.qc:113
void nade_napalm_ball(entity this)
Definition napalm.qc:74
void napalm_damage(entity this, float rad, float damage, float edgedamage, float burntime)
Definition napalm.qc:4
void napalm_ball_think(entity this)
Definition napalm.qc:48
const int PROJECTILE_NAPALM_FOUNTAIN
Definition napalm.qh:27
float autocvar_g_nades_napalm_fountain_lifetime
Definition napalm.qh:13
float autocvar_g_nades_napalm_ball_damage
Definition napalm.qh:9
float autocvar_g_nades_napalm_fountain_radius
Definition napalm.qh:15
float autocvar_g_nades_napalm_ball_damageforcescale
Definition napalm.qh:10
int autocvar_g_nades_napalm_ball_count
Definition napalm.qh:7
float autocvar_g_nades_napalm_ball_lifetime
Definition napalm.qh:11
float autocvar_g_nades_napalm_fountain_edgedamage
Definition napalm.qh:17
float autocvar_g_nades_napalm_burntime
Definition napalm.qh:18
bool autocvar_g_nades_napalm_selfdamage
Definition napalm.qh:19
float autocvar_g_nades_napalm_fountain_delay
Definition napalm.qh:14
float autocvar_g_nades_napalm_ball_spread
Definition napalm.qh:8
float autocvar_g_nades_napalm_ball_radius
Definition napalm.qh:12
float autocvar_g_nades_napalm_fountain_damage
Definition napalm.qh:16
#define METHOD(cname, name, prototype)
Definition oo.qh:274
#define NULL
Definition post.qh:14
ERASEABLE void RandomSelection_Init()
Definition random.qc:4
#define RandomSelection_AddEnt(e, weight, priority)
Definition random.qh:14
entity RandomSelection_chosen_ent
Definition random.qh:5
#define crandom()
Returns a random number between -1.0 and 1.0.
Definition random.qh:32
#define round_handler_IsActive()
#define round_handler_IsRoundStarted()
#define setthink(e, f)
vector
Definition self.qh:96
const int MIF_SPLASH
Definition common.qh:46
int projectiledeathtype
Definition common.qh:21
IntrusiveList g_projectiles
Definition common.qh:58
const int MIF_PROXY
Definition common.qh:48
const int MIF_ARC
Definition common.qh:47
#define PROJECTILE_MAKETRIGGER(e)
Definition common.qh:34
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 SND_NADE_NAPALM_FIRE
Definition all.inc:185
float spamsound(entity e, int chan, Sound samp, float vol, float _atten)
use this one if you might be causing spam (e.g.
Definition all.qc:124
bool StatusEffects_active(StatusEffect this, entity actor)
#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
const int DAMAGE_AIM
Definition subs.qh:81
float nade_special_time
Definition sv_nades.qh:47
#define DIFF_TEAM(a, b)
Definition teams.qh:242
entity realowner
#define vlen2(v)
Definition vector.qh:4