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;
322 if (!pseudoprojectile)
323 pseudoprojectile = new(pseudoprojectile);
327 soundtoat(MSG_ONE, pseudoprojectile, it.WarpZone_findradius_nearest, CH_SHOTS, SND(NEXWHOOSH_RANDOM()), VOL_BASEVOICE, ATTEN_IDLE, 0);
328 it.WarpZone_findradius_hit = 0;
330 if (pseudoprojectile)
331 delete(pseudoprojectile);
338 foff = ExponentialFalloff(mindist, maxdist, halflifedist, it.railgundistance);
339 ffs = ExponentialFalloff(mindist, maxdist, forcehalflifedist, it.railgundistance);
341 if (accuracy_isgooddamage(this, it))
342 total_dmg += bdamage * foff;
347 Damage(it, this, this, bdamage * foff, deathtype, weaponentity, it.railgunhitloc, it.railgunforce * ffs);
348 if (it.solid == SOLID_SLIDEBOX)
349 Damage_DamageInfo(it.railgunhitloc, bdamage * foff, 0, 0,
350 bforce * ffs * normalize(it.railgunforce), deathtype, it.species, this);
354 it.railgunhit =
false;
355 it.railgunhitloc =
'0 0 0';
357 it.railgundistance = 0;
366 if (this.(weaponentity))
376 if (
vdist(hit - start, >, 16))
383 float spread,
float max_solid_penetration,
float damage,
384 float falloff_halflife,
float falloff_mindist,
385 float falloff_maxdist,
float headshot_multiplier,
386 float force,
float falloff_forcehalflife,
387 float dtype,
entity tracer_effect,
bool do_antilag)
395 float solid_penetration_fraction = 1;
396 float damage_fraction = 1;
397 float total_damage = 0;
410 bool headshot =
false;
443 bool is_weapclip =
false;
450 Damage_DamageInfo(start, damage * damage_fraction, 0, 0,
max(1, force) *
dir * damage_fraction, dtype, hit.species,
this);
458 MUTATOR_CALLHOOK(FireBullet_Hit,
this, hit, start, end, damage, this.(weaponentity));
459 damage =
M_ARGV(4,
float);
460 if (headshot_multiplier &&
Headshot(hit,
this, start, end))
462 damage *= headshot_multiplier;
467 float dealt_damage = damage * damage_fraction;
468 vector dealt_force = force *
dir * damage_fraction;
470 if (falloff_halflife || falloff_forcehalflife)
480 if (falloff_halflife)
481 dealt_damage *=
ExponentialFalloff(falloff_mindist, falloff_maxdist, falloff_halflife, dist);
483 if (falloff_forcehalflife)
484 dealt_force *=
ExponentialFalloff(falloff_mindist, falloff_maxdist, falloff_forcehalflife, dist);
487 Damage(hit,
this,
this, dealt_damage, dtype, weaponentity, start, dealt_force);
493 float added_damage =
min(damage - total_damage, damage * damage_fraction);
494 total_damage += damage * damage_fraction;
504 if (start.x >
world.maxs.x || start.y >
world.maxs.y || start.z >
world.maxs.z
505 || start.x <
world.mins.x || start.y <
world.mins.y || start.z <
world.mins.z)
510 if (max_solid_penetration < 0)
512 else if (hitstore.ballistics_density < -1)
514 else if (hitstore.ballistics_density < 0)
515 maxdist =
vlen(hit.maxs - hit.mins) + 1;
516 else if (hitstore.ballistics_density == 0)
517 maxdist = max_solid_penetration * solid_penetration_fraction;
519 maxdist = max_solid_penetration * solid_penetration_fraction / hitstore.ballistics_density;
531 float fraction_used_of_what_is_left = dist_taken / maxdist;
532 solid_penetration_fraction -= solid_penetration_fraction * fraction_used_of_what_is_left;
533 solid_penetration_fraction =
max(solid_penetration_fraction, 0);
558void 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)
560 fireBullet_falloff(
this, weaponentity, start,
dir, spread, max_solid_penetration, damage, 0, 0, 0, headshot_multiplier, force, 0, dtype, tracer_effect, do_antilag);
563void 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)
565 fireBullet_antilag(
this, weaponentity, start,
dir, spread, max_solid_penetration, damage, headshot_multiplier, force, dtype, tracer_effect,
true);
570 vector trace_start =
CS(pl).cursor_trace_start;
607 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(name,...)
#define M_ARGV(idx, type)
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
weapon has high calibur bullets that can penetrate thick walls (WEAPONTODO)
float W_WeaponSpeedFactor(entity this)