24void W_SetupShot_Dir_ProjectileSize_Range(
entity ent, .
entity weaponentity,
vector s_forward,
vector mi,
vector ma,
float antilag,
float recoil,
Sound snd,
float chan,
float maxdamage,
float range,
int deathtype)
28 float oldsolid = ent.dphitcontentsmask;
45 vector view_org = ent.origin + ent.view_ofs;
76 vector dv = right * -md.y + up * md.z;
107 if (antilag && !
CS_CVAR(ent).cvar_cl_noantilag)
148 ent.dphitcontentsmask = oldsolid;
151 ent.punchangle_x = -recoil;
169 vector offset =
'0 37.5 -12.5';
170 if (bullet_count & 2)
171 offset.y = -offset.y;
172 if (bullet_count & 1)
173 offset.z = -offset.z;
182 float mspeed =
vlen(mvelocity);
190 if (proj.owner ==
NULL)
191 error(
"Unowned missile");
193 dir += upDir * (pUpSpeed / pSpeed);
194 dir.z += pZSpeed / pSpeed;
201 mspercallsum = mspercallcount = 0;
212 LOG_INFO(
"avg: ",
ftos(mspercallcount / mspercallsum),
" per sec");
228 vector headmins =
org +
'0.6 0 0' * targ.mins_x +
'0 0.6 0' * targ.mins_y +
'0 0 1' * (1.3 * targ.view_ofs_z - 0.3 * targ.maxs_z);
229 vector headmaxs =
org +
'0.6 0 0' * targ.maxs_x +
'0 0.6 0' * targ.maxs_y +
'0 0 1' * targ.maxs_z;
245 length2 = vlen2(dir);
247 ? start + dir * bound(0, ((it.origin - start) * dir) / length2, 1)
251 if (!it.WarpZone_findradius_hit || vlen2(it.origin - nearest) < vlen2(it.origin - it.WarpZone_findradius_nearest))
256 it.WarpZone_findradius_nearest = nearest;
257 it.WarpZone_findradius_hit = 1;
261void FireRailgunBullet(
entity this, .
entity weaponentity,
vector start,
vector end,
float bdamage,
bool headshot_notify,
float bforce,
float mindist,
float maxdist,
float halflifedist,
float forcehalflifedist,
int deathtype)
267 bool headshot =
false;
319 if (!pseudoprojectile)
320 pseudoprojectile = new(pseudoprojectile);
324 soundtoat(MSG_ONE, pseudoprojectile, it.WarpZone_findradius_nearest, CH_SHOTS, SND(NEXWHOOSH_RANDOM()), VOL_BASEVOICE, ATTEN_IDLE, 0);
325 it.WarpZone_findradius_hit = 0;
327 if (pseudoprojectile)
328 delete(pseudoprojectile);
335 foff = ExponentialFalloff(mindist, maxdist, halflifedist, it.railgundistance);
336 ffs = ExponentialFalloff(mindist, maxdist, forcehalflifedist, it.railgundistance);
338 if (accuracy_isgooddamage(this, it))
339 total_dmg += bdamage * foff;
344 Damage(it, this, this, bdamage * foff, deathtype, weaponentity, it.railgunhitloc, it.railgunforce * ffs);
345 if (it.solid == SOLID_SLIDEBOX)
346 Damage_DamageInfo(it.railgunhitloc, bdamage * foff, 0, 0,
347 bforce * ffs * normalize(it.railgunforce), deathtype, it.species, this);
351 it.railgunhit =
false;
352 it.railgunhitloc =
'0 0 0';
354 it.railgundistance = 0;
363 if (this.(weaponentity))
373 if (
vdist(hit - start, >, 16))
380 float spread,
float max_solid_penetration,
float damage,
381 float falloff_halflife,
float falloff_mindist,
382 float falloff_maxdist,
float headshot_multiplier,
383 float force,
float falloff_forcehalflife,
384 float dtype,
entity tracer_effect,
bool do_antilag)
392 float solid_penetration_fraction = 1;
393 float damage_fraction = 1;
394 float total_damage = 0;
407 bool headshot =
false;
440 bool is_weapclip =
false;
447 Damage_DamageInfo(start, damage * damage_fraction, 0, 0,
max(1, force) *
dir * damage_fraction, dtype, hit.species,
this);
455 MUTATOR_CALLHOOK(FireBullet_Hit,
this, hit, start, end, damage, this.(weaponentity));
456 damage =
M_ARGV(4,
float);
457 if (headshot_multiplier &&
Headshot(hit,
this, start, end))
459 damage *= headshot_multiplier;
464 float dealt_damage = damage * damage_fraction;
465 vector dealt_force = force *
dir * damage_fraction;
467 if (falloff_halflife || falloff_forcehalflife)
477 if (falloff_halflife)
478 dealt_damage *=
ExponentialFalloff(falloff_mindist, falloff_maxdist, falloff_halflife, dist);
480 if (falloff_forcehalflife)
481 dealt_force *=
ExponentialFalloff(falloff_mindist, falloff_maxdist, falloff_forcehalflife, dist);
484 Damage(hit,
this,
this, dealt_damage, dtype, weaponentity, start, dealt_force);
490 float added_damage =
min(damage - total_damage, damage * damage_fraction);
491 total_damage += damage * damage_fraction;
501 if (start.x >
world.maxs.x || start.y >
world.maxs.y || start.z >
world.maxs.z
502 || start.x <
world.mins.x || start.y <
world.mins.y || start.z <
world.mins.z)
507 if (max_solid_penetration < 0)
509 else if (hitstore.ballistics_density < -1)
511 else if (hitstore.ballistics_density < 0)
512 maxdist =
vlen(hit.maxs - hit.mins) + 1;
513 else if (hitstore.ballistics_density == 0)
514 maxdist = max_solid_penetration * solid_penetration_fraction;
516 maxdist = max_solid_penetration * solid_penetration_fraction / hitstore.ballistics_density;
528 float fraction_used_of_what_is_left = dist_taken / maxdist;
529 solid_penetration_fraction -= solid_penetration_fraction * fraction_used_of_what_is_left;
530 solid_penetration_fraction =
max(solid_penetration_fraction, 0);
555void fireBullet_antilag(
entity this, .
entity weaponentity,
vector start,
vector dir,
float spread,
float max_solid_penetration,
float damage,
float headshot_multiplier,
float force,
float dtype,
entity tracer_effect,
bool do_antilag)
557 fireBullet_falloff(
this, weaponentity, start,
dir, spread, max_solid_penetration, damage, 0, 0, 0, headshot_multiplier, force, 0, dtype, tracer_effect, do_antilag);
560void fireBullet(
entity this, .
entity weaponentity,
vector start,
vector dir,
float spread,
float max_solid_penetration,
float damage,
float headshot_multiplier,
float force,
float dtype,
entity tracer_effect)
562 fireBullet_antilag(
this, weaponentity, start,
dir, spread, max_solid_penetration, damage, headshot_multiplier, force, dtype, tracer_effect,
true);
567 vector trace_start =
CS(pl).cursor_trace_start;
604 vector trace_start =
CS(pl).cursor_trace_start;
void accuracy_add(entity this, Weapon w, float fired, float hit, float real)
update accuracy stats
bool accuracy_isgooddamage(entity attacker, entity targ)
does this damage count towards accuracy stats?
bool accuracy_canbegooddamage(entity attacker)
if damage were to occur, would accuracy_isgooddamage be able to return true?
void tracebox_antilag(entity source, vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent, float lag)
void antilag_takeback_all(entity ignore, float lag)
void WarpZone_traceline_antilag(entity source, vector v1, vector v2, float nomonsters, entity forent, float lag)
void traceline_antilag(entity source, vector v1, vector v2, float nomonsters, entity forent, float lag)
void tracebox_antilag_force_wz(entity source, vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent, float lag, bool wz, WarpZone_trace_callback_t cb)
A version of traceline that must be used by SOLID_SLIDEBOX things that want to hit SOLID_CORPSE thing...
float antilag_getlag(entity e)
void antilag_restore_all(entity ignore)
#define traceline_antilag_force(source, v1, v2, nomonsters, forent, lag)
#define ANTILAG_LATENCY(e)
#define MUTATOR_CALLHOOK(id,...)
vector W_CalculateSpread(vector dir, float spread, int spread_style, bool must_normalize)
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
int spawnflags
M: flags : WEPSPAWNFLAG_... combined.
vector get_shotvelocity(vector myvel, vector mydir, float spd, float newton_style, float mi, float ma)
float trace_hits_box(vector start, vector end, vector thmi, vector thma)
void traceline_inverted(vector v1, vector v2, float nomonsters, entity forent, float stopatentity, entity ignorestopatentity)
const float MOVE_NOMONSTERS
const float SOLID_SLIDEBOX
float trace_dphitcontents
float Q3SURFACEFLAG_NONSOLID
const float SOLID_TRIGGER
float Q3SURFACEFLAG_NODRAW
float trace_dphitq3surfaceflags
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void Damage_DamageInfo(vector org, float coredamage, float edgedamage, float rad, vector force, int deathtype, float bloodtype, entity dmgowner)
#define DEATH_WEAPONOF(t)
vector cursor_trace_endpos
#define trailparticles(e, effect, org, vel)
void W_HitPlotAnalysis(entity player, entity wep, vector screenforward, vector screenright, vector screenup)
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define IL_EACH(this, cond, body)
#define IL_CLEAR(this)
Remove all elements.
#define FOREACH_ENTITY_FLOAT(fld, match, body)
vector WarpZone_UnTransformOrigin(entity wz, vector org)
Transforms origin org backwards through warpzone wz, as the inverse of WarpZone_TransformOrigin.
vector WarpZone_TransformOrigin(entity wz, vector org)
Transforms origin org across warpzone wz.
int WarpZone_findradius_hit
vector WarpZone_TransformVelocity(entity wz, vector vel)
Transforms velocity v across warpzone wz.
entity WarpZone_trace_firstzone
First warpzone hit by a trace (can differ from the requested zone in case of _ThroughZone,...
#define WarpZone_TraceLine(org, end, nomonsters, forent)
#define WarpZone_TraceLine_ThroughZone(org, end, nomonsters, forent, zone, cb)
entity WarpZone_trace_transform
Transform accumulator during a trace.
entity WarpZone_trace_forent
Temp, callback is allowed to change it.
ERASEABLE float ExponentialFalloff(float mindist, float maxdist, float halflifedist, float d)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
void W_PlayStrengthSound(entity player)
bool W_DualWielding(entity player)
#define sound(e, c, s, v, a)
ClientState CS(Client this)
vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute)
void FireRailgunBullet_cb(vector start, vector hit, vector end)
Updates the nearest point of the beam to each player, with the new segment from start to hit.
bool Headshot(entity targ, entity ent, vector start, vector end)
void fireBullet(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect)
entity FireRailgunBullet_cb_this
void W_SetupShot_Dir_ProjectileSize_Range(entity ent,.entity weaponentity, vector s_forward, vector mi, vector ma, float antilag, float recoil, Sound snd, float chan, float maxdamage, float range, int deathtype)
This function calculates w_shotorg and w_shotdir based on the weapon model offset,...
void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float pSpeed, float pUpSpeed, float pZSpeed, float spread, float forceAbsolute)
void fireBullet_trace_callback(vector start, vector hit, vector end)
void fireBullet_falloff(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float falloff_halflife, float falloff_mindist, float falloff_maxdist, float headshot_multiplier, float force, float falloff_forcehalflife, float dtype, entity tracer_effect, bool do_antilag)
void crosshair_trace(entity pl)
void crosshair_trace_plusvisibletriggers(entity pl)
void WarpZone_crosshair_trace_plusvisibletriggers(entity pl)
void crosshair_trace_plusvisibletriggers__is_wz(entity pl, bool is_wz)
void fireBullet_antilag(entity this,.entity weaponentity, vector start, vector dir, float spread, float max_solid_penetration, float damage, float headshot_multiplier, float force, float dtype, entity tracer_effect, bool do_antilag)
void FireRailgunBullet(entity this,.entity weaponentity, vector start, vector end, float bdamage, bool headshot_notify, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, int deathtype)
vector W_SetupShot_GetAlternatingOffset(int bullet_count)
void WarpZone_crosshair_trace(entity pl)
int autocvar_g_projectiles_spread_style
IntrusiveList g_railgunhit
float autocvar_g_projectiles_newton_style_2_maxfactor
float autocvar_g_trueaim_minrange
float autocvar_g_ballistics_mindistance
IntrusiveList g_ctrace_changed
int autocvar_g_hitscan_spread_style
int autocvar_g_projectiles_newton_style
float autocvar_g_projectiles_newton_style_2_minfactor
float autocvar_g_ballistics_solidpenetration_exponent
bool autocvar_g_ballistics_penetrate_clips
entity fireBullet_trace_callback_eff
entity fireBullet_last_hit
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt().
const int WEP_FLAG_PENETRATEWALLS
float W_WeaponSpeedFactor(entity this)