set g_balance_shotgun_primary_refire 0.5
set g_balance_shotgun_primary_animtime 0.2
set g_balance_shotgun_primary_ammo 1
-set g_balance_shotgun_primary_speed 12000
-set g_balance_shotgun_primary_bulletconstant 75 // 3.8qu
+set g_balance_shotgun_primary_solidpenetration 3.8
set g_balance_shotgun_secondary 1
set g_balance_shotgun_secondary_melee_delay 0.25 // 0.35 was too slow
set g_balance_shotgun_secondary_melee_range 120
set g_balance_uzi_sustained_refire 0.1
set g_balance_uzi_sustained_ammo 1
-set g_balance_uzi_speed 18000
-set g_balance_uzi_bulletconstant 115 // 13.1qu
+set g_balance_uzi_solidpenetration 13.1
set g_balance_uzi_switchdelay_drop 0.15
set g_balance_uzi_switchdelay_raise 0.15
set g_balance_shotgun_primary_refire 1
set g_balance_shotgun_primary_animtime 0.3
set g_balance_shotgun_primary_ammo 1
-set g_balance_shotgun_primary_speed 12000
-set g_balance_shotgun_primary_bulletconstant 75 // 3.8qu
+set g_balance_shotgun_primary_solidpenetration 3.8
set g_balance_shotgun_secondary 1
set g_balance_shotgun_secondary_melee_delay 0.25 // 0.35 was too slow
set g_balance_shotgun_secondary_melee_range 120
set g_balance_uzi_sustained_refire 0.1
set g_balance_uzi_sustained_ammo 1
-set g_balance_uzi_speed 18000
-set g_balance_uzi_bulletconstant 115 // 13.1qu
+set g_balance_uzi_solidpenetration 13.1
set g_balance_uzi_switchdelay_drop 0.15
set g_balance_uzi_switchdelay_raise 0.15
set g_balance_shotgun_primary_refire 0.75
set g_balance_shotgun_primary_animtime 0.2
set g_balance_shotgun_primary_ammo 1
-set g_balance_shotgun_primary_speed 8000
-set g_balance_shotgun_primary_bulletconstant 75 // 3.8qu
+set g_balance_shotgun_primary_solidpenetration 3.8
set g_balance_shotgun_secondary 1
set g_balance_shotgun_secondary_melee_delay 0.25 // 0.35 was too slow
set g_balance_shotgun_secondary_melee_range 120
set g_balance_uzi_sustained_refire 0.1
set g_balance_uzi_sustained_ammo 1
-set g_balance_uzi_speed 18000
-set g_balance_uzi_bulletconstant 115 // 13.1qu
+set g_balance_uzi_solidpenetration 13.1
set g_balance_uzi_switchdelay_drop 0
set g_balance_uzi_switchdelay_raise 0
set g_balance_shotgun_primary_refire 0.75
set g_balance_shotgun_primary_animtime 0.2
set g_balance_shotgun_primary_ammo 1
-set g_balance_shotgun_primary_speed 8000
-set g_balance_shotgun_primary_bulletconstant 75 // 3.8qu
+set g_balance_shotgun_primary_solidpenetration 3.8
set g_balance_shotgun_secondary 1
set g_balance_shotgun_secondary_melee_delay 0.25 // 0.35 was too slow
set g_balance_shotgun_secondary_melee_range 120
set g_balance_uzi_sustained_refire 0.1
set g_balance_uzi_sustained_ammo 1
-set g_balance_uzi_speed 18000
-set g_balance_uzi_bulletconstant 115 // 13.1qu
+set g_balance_uzi_solidpenetration 13.1
set g_balance_uzi_switchdelay_drop 0.2
set g_balance_uzi_switchdelay_raise 0.2
set g_balance_shotgun_primary_refire 0.75
set g_balance_shotgun_primary_animtime 0.2
set g_balance_shotgun_primary_ammo 1
-set g_balance_shotgun_primary_speed 8000
-set g_balance_shotgun_primary_bulletconstant 75 // 3.8qu
+set g_balance_shotgun_primary_solidpenetration 3.8
set g_balance_shotgun_secondary 1
set g_balance_shotgun_secondary_melee_delay 0.25 // 0.35 was too slow
set g_balance_shotgun_secondary_melee_range 120
set g_balance_uzi_sustained_refire 0.1
set g_balance_uzi_sustained_ammo 1
-set g_balance_uzi_speed 18000
-set g_balance_uzi_bulletconstant 115 // 13.1qu
+set g_balance_uzi_solidpenetration 13.1
set g_balance_uzi_switchdelay_drop 0.2
set g_balance_uzi_switchdelay_raise 0.2
// Quake-Joule: 1 qJ = 1 qN * 1 qu
// Quake-Pascal: 1 qPa = 1 qN / 1 qu^2
-set g_ballistics_materialconstant 1414213562
-set g_ballistics_mindistance 16
+set g_ballistics_mindistance 2 // enable ballistics starting from 2 qu
set g_ballistics_density_player 0.50 // players are 2x as easy to pass as walls
set g_ballistics_density_corpse 0.10 // corpses are 10x as easy to pass as walls
-// unit: qJ / qu^3 (energy needed per volume unit of solid to push/burn away
-// parameter: bullet constant: mass / area in g/qu^2
-// = mass / (pi/4 * caliber^2)
-// with caliber in inches, mass in grams:
-// = 1.273239544735163 * mass / caliber^2
-// with caliber in inches, mass in grains:
-// = 0.082633246453312 * mass / caliber^2
-
-// bullet max travel distance inside solid:
-// 0.5 * v^2 * bulletconstant / g_ballistics_materialconstant
-
-// some bullet constants:
-// http://hypertextbook.com/facts/2000/ShantayArmstrong.shtml
-// second bullet: caliber .45, mass 16.2g, bullet constant 101.859163578813
-// third bullet: caliber .338, mass 16.2g, bullet constant 180.5476053421592
-// fourth bullet: caliber .25, mass 2.3g, bullet constant 46.85521524625399
-// http://en.wikipedia.org/wiki/.50_BMG
-// caliber .5, 360 grains, bullet constant 118.9918748927693
-// AK-47:
-// caliber .3, 62 grains, bullet constant 56.92512533450383
-// .3 winchester magnum:
-// caliber .3, 150 grains, bullet constant 137.7220774221867
set cl_stripcolorcodes 0 "experimental feature (notes: strips ALL color codes from messages!)"
Net_ReadRace();
bHandled = true;
break;
- case TE_CSQC_ZCURVEPARTICLES:
- Net_ReadZCurveParticles();
- bHandled = true;
- break;
case TE_CSQC_NEXGUNBEAMPARTICLE:
Net_ReadNexgunBeamParticle();
bHandled = true;
self.draw = Draw_Snow;
}
-entity zcurve;
-void zcurveparticles(float effectnum, vector start, vector end, float end_dz, float speed, float depth)
-{
- // end_dz:
- // IF IT WERE A STRAIGHT LINE, it'd end end_dz above end
-
- vector mid;
- mid = (start + end) * 0.5;
-
- end_dz *= 0.25;
- mid_z += end_dz;
-
- --depth;
- if(depth < 0 || normalize(mid - start) * normalize(end - start) > 0.999999)
- // TODO make this a variable threshold
- // currently: 0.081 degrees
- // 0.99999 would be 0.256 degrees and is visible
- {
- zcurve.velocity = speed * normalize(end - start);
- trailparticles(zcurve, effectnum, start, end);
- }
- else
- {
- zcurveparticles(effectnum, start, mid, end_dz, speed, depth);
- zcurveparticles(effectnum, mid, end, end_dz, speed, depth);
- }
-}
-
-void Net_ReadZCurveParticles()
-{
- vector start, end;
- float end_dz;
- float effectnum, speed;
-
- if(!zcurve)
- {
- zcurve = spawn();
- zcurve.classname = "zcurve";
- }
-
- effectnum = ReadShort();
-
- start_x = ReadCoord();
- start_y = ReadCoord();
- start_z = ReadCoord();
-
- do
- {
- end_x = ReadCoord();
- end_y = ReadCoord();
- end_z = ReadCoord();
- end_dz = ReadCoord();
- speed = ReadShort();
- zcurveparticles(effectnum, start, end, end_dz, 16 * (speed & 0x7FFF), 5); // at most 32 segments
- }
- while(!(speed & 0x8000));
-}
-
void Net_ReadNexgunBeamParticle()
{
vector shotorg, endpos;
const float TE_CSQC_PICTURE = 100;
const float TE_CSQC_RACE = 101;
-const float TE_CSQC_ZCURVEPARTICLES = 102;
const float TE_CSQC_NEXGUNBEAMPARTICLE = 103;
const float TE_CSQC_LIGHTNINGARC = 104;
const float TE_CSQC_TEAMNAGGER = 105;
float autocvar_g_balance_rifle_bursttime;
float autocvar_g_balance_rifle_primary_ammo;
float autocvar_g_balance_rifle_primary_animtime;
-float autocvar_g_balance_rifle_primary_bulletconstant;
float autocvar_g_balance_rifle_primary_bullethail;
float autocvar_g_balance_rifle_primary_burstcost;
float autocvar_g_balance_rifle_primary_damage;
float autocvar_g_balance_rifle_primary_force;
-float autocvar_g_balance_rifle_primary_lifetime;
float autocvar_g_balance_rifle_primary_refire;
float autocvar_g_balance_rifle_primary_shots;
-float autocvar_g_balance_rifle_primary_speed;
+float autocvar_g_balance_rifle_primary_solidpenetration;
float autocvar_g_balance_rifle_primary_spread;
float autocvar_g_balance_rifle_primary_tracer;
float autocvar_g_balance_rifle_secondary;
float autocvar_g_balance_rifle_secondary_ammo;
float autocvar_g_balance_rifle_secondary_animtime;
-float autocvar_g_balance_rifle_secondary_bulletconstant;
float autocvar_g_balance_rifle_secondary_bullethail;
float autocvar_g_balance_rifle_secondary_burstcost;
float autocvar_g_balance_rifle_secondary_damage;
float autocvar_g_balance_rifle_secondary_force;
-float autocvar_g_balance_rifle_secondary_lifetime;
float autocvar_g_balance_rifle_secondary_reload;
float autocvar_g_balance_rifle_secondary_refire;
float autocvar_g_balance_rifle_secondary_shots;
-float autocvar_g_balance_rifle_secondary_speed;
+float autocvar_g_balance_rifle_secondary_solidpenetration;
float autocvar_g_balance_rifle_secondary_spread;
float autocvar_g_balance_rifle_secondary_tracer;
float autocvar_g_balance_rifle_reload_ammo;
float autocvar_g_balance_selfdamagepercent;
float autocvar_g_balance_shotgun_primary_ammo;
float autocvar_g_balance_shotgun_primary_animtime;
-float autocvar_g_balance_shotgun_primary_bulletconstant;
float autocvar_g_balance_shotgun_primary_bullets;
float autocvar_g_balance_shotgun_primary_damage;
float autocvar_g_balance_shotgun_primary_force;
float autocvar_g_balance_shotgun_primary_refire;
-float autocvar_g_balance_shotgun_primary_speed;
+float autocvar_g_balance_shotgun_primary_solidpenetration;
float autocvar_g_balance_shotgun_primary_spread;
float autocvar_g_balance_shotgun_secondary;
float autocvar_g_balance_shotgun_secondary_animtime;
float autocvar_g_balance_tuba_force;
float autocvar_g_balance_tuba_radius;
float autocvar_g_balance_tuba_refire;
-float autocvar_g_balance_uzi_bulletconstant;
float autocvar_g_balance_uzi_burst;
float autocvar_g_balance_uzi_burst_ammo;
float autocvar_g_balance_uzi_burst_animtime;
float autocvar_g_balance_uzi_first_refire;
float autocvar_g_balance_uzi_first_spread;
float autocvar_g_balance_uzi_mode;
-float autocvar_g_balance_uzi_speed;
+float autocvar_g_balance_uzi_solidpenetration;
float autocvar_g_balance_uzi_spread_add;
float autocvar_g_balance_uzi_spread_max;
float autocvar_g_balance_uzi_spread_min;
float autocvar_g_balance_uzi_reload_time;
float autocvar_g_ballistics_density_corpse;
float autocvar_g_ballistics_density_player;
-float autocvar_g_ballistics_materialconstant;
float autocvar_g_ballistics_mindistance;
float autocvar_g_ban_default_bantime;
float autocvar_g_ban_default_masksize;
c = trace_endpos;
}
- n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world, FALSE);
+ n += tracebox_inverted(c, mi, ma, b, MOVE_WORLDONLY, world, FALSE, world);
white += vlen(trace_endpos - c);
c = trace_endpos;
.string message2;
-vector railgun_start, railgun_end; // filled by FireRailgunBullet, used by damage code for head shot
.float stat_allow_oldnexbeam;
// reset to 0 on weapon switch
tracebox_antilag_force_wz(source, v1, mi, ma, v2, nomonst, forent, lag, TRUE);
}
-float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent, float stopatentity) // returns the number of traces done, for benchmarking
+float tracebox_inverted (vector v1, vector mi, vector ma, vector v2, float nomonsters, entity forent, float stopatentity, entity ignorestopatentity) // returns the number of traces done, for benchmarking
{
vector pos, dir, t;
float nudge;
for(;;)
{
- if((pos - v1) * dir >= (v2 - v1) * dir)
+ if(pos * dir >= v2 * dir)
{
// went too far
trace_fraction = 1;
pos = t + dir * nudge;
// but if we hit an entity, stop RIGHT before it
- if(stopatentity && stopentity)
+ if(stopatentity && stopentity && stopentity != ignorestopatentity)
{
trace_ent = stopentity;
trace_endpos = t;
}
}
-void traceline_inverted (vector v1, vector v2, float nomonsters, entity forent, float stopatentity)
+void traceline_inverted (vector v1, vector v2, float nomonsters, entity forent, float stopatentity, entity ignorestopatentity)
{
- tracebox_inverted(v1, '0 0 0', '0 0 0', v2, nomonsters, forent, stopatentity);
+ tracebox_inverted(v1, '0 0 0', '0 0 0', v2, nomonsters, forent, stopatentity, ignorestopatentity);
}
/*
return FALSE;
}
-float zcurveparticles_effectno;
-vector zcurveparticles_start;
-float zcurveparticles_spd;
-
-void endzcurveparticles()
-{
- if(zcurveparticles_effectno)
- {
- // terminator
- WriteShort(MSG_BROADCAST, zcurveparticles_spd | 0x8000);
- }
- zcurveparticles_effectno = 0;
-}
-
-void zcurveparticles(float effectno, vector start, vector end, float end_dz, float spd)
-{
- spd = bound(0, floor(spd / 16), 32767);
- if(effectno != zcurveparticles_effectno || start != zcurveparticles_start)
- {
- endzcurveparticles();
- WriteByte(MSG_BROADCAST, SVC_TEMPENTITY);
- WriteByte(MSG_BROADCAST, TE_CSQC_ZCURVEPARTICLES);
- WriteShort(MSG_BROADCAST, effectno);
- WriteCoord(MSG_BROADCAST, start_x);
- WriteCoord(MSG_BROADCAST, start_y);
- WriteCoord(MSG_BROADCAST, start_z);
- zcurveparticles_effectno = effectno;
- zcurveparticles_start = start;
- }
- else
- WriteShort(MSG_BROADCAST, zcurveparticles_spd);
- WriteCoord(MSG_BROADCAST, end_x);
- WriteCoord(MSG_BROADCAST, end_y);
- WriteCoord(MSG_BROADCAST, end_z);
- WriteCoord(MSG_BROADCAST, end_dz);
- zcurveparticles_spd = spd;
-}
-
-void zcurveparticles_from_tracetoss(float effectno, vector start, vector end, vector vel)
-{
- float end_dz;
- vector vecxy, velxy;
-
- vecxy = end - start;
- vecxy_z = 0;
- velxy = vel;
- velxy_z = 0;
-
- if (vlen(velxy) < 0.000001 * fabs(vel_z))
- {
- endzcurveparticles();
- trailparticles(world, effectno, start, end);
- return;
- }
-
- end_dz = vlen(vecxy) / vlen(velxy) * vel_z - (end_z - start_z);
- zcurveparticles(effectno, start, end, end_dz, vlen(vel));
-}
-
void write_recordmarker(entity pl, float tstart, float dt)
{
GameLogEcho(strcat(":recordset:", ftos(pl.playerid), ":", ftos(dt)));
//.float bulletcounter;
void turret_machinegun_attack()
{
- fireBallisticBullet (self.tur_shotorg, self.tur_shotdir_updated,self.shot_spread, self.shot_speed, 5, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0, autocvar_g_balance_uzi_bulletconstant);
- endFireBallisticBullet();
+ fireBullet (self.tur_shotorg, self.tur_shotdir_updated,self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_MACHINEGUN, 0);
UziFlash();
setattachment(self.muzzle_flash, self.tur_head, "tag_fire");
void walker_attack()
{
sound (self, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
- fireBallisticBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, self.shot_speed, 5, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0, autocvar_g_balance_uzi_bulletconstant);
- endFireBallisticBullet();
+ fireBullet (self.tur_shotorg, self.tur_shotdir_updated, self.shot_spread, 0, self.shot_dmg, self.shot_force, DEATH_TURRET_WALK_GUN, 0);
pointparticles(particleeffectnum("laser_muzzleflash"), self.tur_shotorg, self.tur_shotdir_updated * 1000, 1);
}
float autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
float autocvar_g_vehicle_spiderbot_minigun_force;
-float autocvar_g_vehicle_spiderbot_minigun_speed;
-float autocvar_g_vehicle_spiderbot_minigun_bulletconstant;
+float autocvar_g_vehicle_spiderbot_minigun_solidpenetration;
float autocvar_g_vehicle_spiderbot_rocket_damage;
float autocvar_g_vehicle_spiderbot_rocket_force;
v_forward = normalize(v_forward);
v += v_forward * 50;
-//void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float force, float dtype, float tracereffects, float bulletconstant)
-
- fireBallisticBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_speed,
- 5, autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0, autocvar_g_vehicle_spiderbot_minigun_bulletconstant);
-
- endFireBallisticBullet();
+ fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
+ autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
// fireBullet (v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_damage,
// autocvar_g_vehicle_spiderbot_minigun_spread, DEATH_VH_SPID_MINIGUN, 0);
pseudoprojectile = world;
- railgun_start = start;
- railgun_end = end;
-
dir = normalize(end - start);
length = vlen(end - start);
force = dir * bforce;
trace_dphitq3surfaceflags = endq3surfaceflags;
}
-.float dmg_force;
-.float dmg_radius;
-.float dmg_total;
-//.float last_yoda;
-void W_BallisticBullet_Hit (void)
-{
- float f, q, g;
-
- f = pow(bound(0, vlen(self.velocity) / vlen(self.oldvelocity), 1), 2); // energy multiplier
- q = 1 + self.dmg_edge / self.dmg;
-
- if(other.solid == SOLID_BSP || other.solid == SOLID_SLIDEBOX)
- Damage_DamageInfo(self.origin, self.dmg * f, 0, 0, max(1, self.dmg_force) * normalize(self.velocity) * f, self.projectiledeathtype, other.species, self);
-
- if(other && other != self.enemy)
- {
- endzcurveparticles();
-
- yoda = 0;
- railgun_start = self.origin - 2 * frametime * self.velocity;
- railgun_end = self.origin + 2 * frametime * self.velocity;
- g = accuracy_isgooddamage(self.realowner, other);
- Damage(other, self, self.realowner, self.dmg * f, self.projectiledeathtype, self.origin, self.dmg_force * normalize(self.velocity) * f);
-
- /*if(yoda && (time > (self.last_yoda + 5)))
- {
- Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_YODA);
- self.last_yoda = time;
- }*/
-
- // calculate hits for ballistic weapons
- if(g)
- {
- // do not exceed 100%
- q = min(self.dmg * q, self.dmg_total + f * self.dmg) - self.dmg_total;
- self.dmg_total += f * self.dmg;
- accuracy_add(self.realowner, self.realowner.weapon, 0, q);
- }
- }
-
- self.enemy = other; // don't hit the same player twice with the same bullet
-}
-
-.void(void) W_BallisticBullet_LeaveSolid_think_save;
-.float W_BallisticBullet_LeaveSolid_nextthink_save;
-.vector W_BallisticBullet_LeaveSolid_origin;
-.vector W_BallisticBullet_LeaveSolid_velocity;
-
-void W_BallisticBullet_LeaveSolid_think()
+float fireBullet_trace_callback_eff;
+entity fireBullet_last_hit;
+void fireBullet_trace_callback(vector start, vector hit, vector end)
{
- setorigin(self, self.W_BallisticBullet_LeaveSolid_origin);
- self.velocity = self.W_BallisticBullet_LeaveSolid_velocity;
-
- self.think = self.W_BallisticBullet_LeaveSolid_think_save;
- self.nextthink = max(time, self.W_BallisticBullet_LeaveSolid_nextthink_save);
- self.W_BallisticBullet_LeaveSolid_think_save = func_null;
-
- self.flags &= ~FL_ONGROUND;
-
- if(self.enemy.solid == SOLID_BSP)
- {
- float f;
- f = pow(bound(0, vlen(self.velocity) / vlen(self.oldvelocity), 1), 2); // energy multiplier
- Damage_DamageInfo(self.origin, 0, 0, 0, max(1, self.dmg_force) * normalize(self.velocity) * -f, self.projectiledeathtype, 0, self);
- }
-
- UpdateCSQCProjectile(self);
-}
-
-float W_BallisticBullet_LeaveSolid(float eff)
-{
- // move the entity along its velocity until it's out of solid, then let it resume
- vector vel = self.velocity;
- float dt, dst, velfactor, v0, vs;
- float maxdist;
- float E0_m, Es_m;
- float constant = self.dmg_radius * (other.ballistics_density ? other.ballistics_density : 1);
-
- // outside the world? forget it
- if(self.origin_x > world.maxs_x || self.origin_y > world.maxs_y || self.origin_z > world.maxs_z || self.origin_x < world.mins_x || self.origin_y < world.mins_y || self.origin_z < world.mins_z)
- return 0;
-
- // special case for zero density and zero bullet constant:
-
- if(self.dmg_radius == 0)
- {
- if(other.ballistics_density < 0)
- constant = 0; // infinite travel distance
- else
- return 0; // no penetration
- }
- else
- {
- if(other.ballistics_density < 0)
- constant = 0; // infinite travel distance
- else if(other.ballistics_density == 0)
- constant = self.dmg_radius;
- else
- constant = self.dmg_radius * other.ballistics_density;
- }
-
- // E(s) = E0 - constant * s, constant = area of bullet circle * material constant / mass
- v0 = vlen(vel);
-
- E0_m = 0.5 * v0 * v0;
-
- if(constant)
- {
- maxdist = E0_m / constant;
- // maxdist = 0.5 * v0 * v0 / constant
- // dprint("max dist = ", ftos(maxdist), "\n");
-
- if(maxdist <= autocvar_g_ballistics_mindistance)
- return 0;
- }
- else
- {
- maxdist = vlen(other.maxs - other.mins) + 1; // any distance, as long as we leave the entity
- }
-
- traceline_inverted (self.origin, self.origin + normalize(vel) * maxdist, MOVE_NORMAL, self, TRUE);
- if(trace_fraction == 1) // 1: we never got out of solid
- return 0;
-
- self.W_BallisticBullet_LeaveSolid_origin = trace_endpos;
-
- dst = max(autocvar_g_ballistics_mindistance, vlen(trace_endpos - self.origin));
- // E(s) = E0 - constant * s, constant = area of bullet circle * material constant / mass
- Es_m = E0_m - constant * dst;
- if(Es_m <= 0)
- {
- // roundoff errors got us
- return 0;
- }
- vs = sqrt(2 * Es_m);
- velfactor = vs / v0;
-
- dt = dst / (0.5 * (v0 + vs));
- // this is not correct, but the differential equations have no analytic
- // solution - and these times are very small anyway
- //print("dt = ", ftos(dt), "\n");
-
- self.W_BallisticBullet_LeaveSolid_think_save = self.think;
- self.W_BallisticBullet_LeaveSolid_nextthink_save = self.nextthink;
- self.think = W_BallisticBullet_LeaveSolid_think;
- self.nextthink = time + dt;
-
- vel = vel * velfactor;
-
- self.velocity = '0 0 0';
- self.flags |= FL_ONGROUND; // prevent moving
- self.W_BallisticBullet_LeaveSolid_velocity = vel;
-
- if(eff >= 0)
- if(vlen(trace_endpos - self.origin) > 4)
- {
- endzcurveparticles();
- trailparticles(self, eff, self.origin, trace_endpos);
- }
-
- return 1;
-}
-
-void W_BallisticBullet_Touch (void)
-{
- //float density;
-
- if(self.think == W_BallisticBullet_LeaveSolid_think) // skip this!
- return;
-
- PROJECTILE_TOUCH;
- W_BallisticBullet_Hit ();
-
- if(self.dmg_radius < 0) // these NEVER penetrate solid
- {
- remove(self);
- return;
- }
-
- // if we hit "weapclip", bail out
- //
- // rationale of this check:
- //
- // any shader that is solid, nodraw AND trans is meant to clip weapon
- // shots and players, but has no other effect!
- //
- // if it is not trans, it is caulk and should not have this side effect
- //
- // matching shaders:
- // common/weapclip (intended)
- // common/noimpact (is supposed to eat projectiles, but is erased farther above)
- if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
- if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
- if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
- {
- remove(self);
- return;
- }
-
- // go through solid!
- if(!W_BallisticBullet_LeaveSolid(-1))
- {
- remove(self);
- return;
- }
-
- self.projectiledeathtype |= HITTYPE_BOUNCE;
-}
-
-void endFireBallisticBullet()
-{
- endzcurveparticles();
-}
-
-entity fireBallisticBullet_trace_callback_ent;
-float fireBallisticBullet_trace_callback_eff;
-void fireBallisticBullet_trace_callback(vector start, vector hit, vector end)
-{
- if(vlen(trace_endpos - fireBallisticBullet_trace_callback_ent.origin) > 16)
- zcurveparticles_from_tracetoss(fireBallisticBullet_trace_callback_eff, fireBallisticBullet_trace_callback_ent.origin, trace_endpos, fireBallisticBullet_trace_callback_ent.velocity);
+ if(vlen(hit - start) > 16)
+ trailparticles(world, fireBullet_trace_callback_eff, start, hit);
WarpZone_trace_forent = world;
- self.owner = world;
+ fireBullet_last_hit = world;
}
-void fireBallisticBullet(vector start, vector dir, float spread, float pSpeed, float lifetime, float damage, float force, float dtype, float tracereffects, float bulletconstant)
+void fireBullet(vector start, vector dir, float spread, float max_solid_penetration, float damage, float force, float dtype, float tracereffects)
{
- float lag, dt, savetime; //, density;
- entity pl, oldself;
-
- entity proj;
- proj = spawn();
- proj.classname = "bullet";
- proj.owner = proj.realowner = self;
- PROJECTILE_MAKETRIGGER(proj);
- proj.movetype = MOVETYPE_FLY;
- proj.think = SUB_Remove;
- proj.nextthink = time + lifetime; // min(pLifetime, vlen(world.maxs - world.mins) / pSpeed);
- W_SetupProjectileVelocityEx(proj, dir, v_up, pSpeed, 0, 0, spread, TRUE);
- proj.angles = vectoangles(proj.velocity);
- if(bulletconstant > 0)
- proj.dmg_radius = autocvar_g_ballistics_materialconstant / bulletconstant;
- else if(bulletconstant == 0)
- proj.dmg_radius = 0;
- else
- proj.dmg_radius = -1;
- // so: bulletconstant = bullet mass / area of bullet circle
- setorigin(proj, start);
- proj.flags = FL_PROJECTILE;
-
- proj.touch = W_BallisticBullet_Touch;
- proj.dmg = damage;
- proj.dmg_force = force;
- proj.projectiledeathtype = dtype;
-
- proj.oldvelocity = proj.velocity;
+ // TODO antilag takeback
+ vector end;
- other = proj; MUTATOR_CALLHOOK(EditProjectile);
+ dir = normalize(dir + randomvec() * spread);
+ end = start + dir * MAX_SHOT_DISTANCE;
- float eff;
+ entity pl;
+ fireBullet_last_hit = world;
+ float solid_penetration_left = 1;
+ float total_damage = 0;
if(tracereffects & EF_RED)
- eff = particleeffectnum("tr_rifle");
+ fireBullet_trace_callback_eff = particleeffectnum("tr_rifle");
else if(tracereffects & EF_BLUE)
- eff = particleeffectnum("tr_rifle_weak");
+ fireBullet_trace_callback_eff = particleeffectnum("tr_rifle_weak");
else
- eff = particleeffectnum("tr_bullet");
+ fireBullet_trace_callback_eff = particleeffectnum("tr_bullet");
- // NOTE: this may severely throw off weapon balance
- lag = ANTILAG_LATENCY(self);
+ float lag = ANTILAG_LATENCY(self);
if(lag < 0.001)
lag = 0;
if (!IS_REAL_CLIENT(self))
lag = 0;
if(autocvar_g_antilag == 0 || self.cvar_cl_noantilag)
lag = 0; // only do hitscan, but no antilag
-
if(lag)
FOR_EACH_PLAYER(pl)
if(pl != self)
antilag_takeback(pl, time - lag);
- oldself = self;
- self = proj;
-
- savetime = frametime;
- frametime = 0.05;
+ WarpZone_trace_forent = self;
- for(;;)
+ for (;;)
{
- // DP tracetoss is stupid and always traces in 0.05s
- // ticks. This makes it trace in 0.05*0.125s ticks
- // instead.
- vector v0;
- v0 = self.velocity;
- self.velocity = self.velocity * 0.125;
- trace_fraction = 0;
- fireBallisticBullet_trace_callback_ent = self;
- fireBallisticBullet_trace_callback_eff = eff;
- WarpZone_TraceToss_ThroughZone(self, self.owner, world, fireBallisticBullet_trace_callback);
- self.velocity = v0;
-
- if(trace_fraction == 1)
+ // TODO also show effect while tracing
+ WarpZone_TraceBox_ThroughZone(start, '0 0 0', '0 0 0', end, FALSE, WarpZone_trace_forent, world, fireBullet_trace_callback);
+ dir = WarpZone_TransformVelocity(WarpZone_trace_transform, dir);
+ end = WarpZone_TransformOrigin(WarpZone_trace_transform, end);
+ start = trace_endpos;
+ entity hit = trace_ent;
+
+ // When hitting sky, stop.
+ if (pointcontents(start) == CONTENT_SKY)
break;
- // won't hit anything anytime soon (DP's
- // tracetoss does 200 tics of, here,
- // 0.05*0.125s, that is, 1.25 seconds
-
- other = trace_ent;
- dt = WarpZone_tracetoss_time * 0.125; // this is only approximate!
- setorigin(self, trace_endpos);
- self.velocity = WarpZone_tracetoss_velocity * (1 / 0.125);
-
- if(!SUB_OwnerCheck())
- {
- if(SUB_NoImpactCheck())
- break;
-
- // hit the player
- W_BallisticBullet_Hit();
- }
- if(proj.dmg_radius < 0) // these NEVER penetrate solid
+ if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
break;
// if we hit "weapclip", bail out
//
// matching shaders:
// common/weapclip (intended)
- // common/noimpact (is supposed to eat projectiles, but is erased farther above)
+ // common/noimpact (is supposed to eat projectiles, but is erased anyway)
+ float is_weapclip = 0;
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NODRAW)
if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NONSOLID))
if (!(trace_dphitcontents & DPCONTENTS_OPAQUE))
- break;
+ is_weapclip = 1;
- // go through solid!
- if(!W_BallisticBullet_LeaveSolid((other && (other.solid != SOLID_BSP)) ? eff : -1))
- break;
+ if(!hit || hit.solid == SOLID_BSP || hit.solid == SOLID_SLIDEBOX)
+ Damage_DamageInfo(start, damage * solid_penetration_left, 0, 0, max(1, force) * dir * solid_penetration_left, dtype, hit.species, self);
- W_BallisticBullet_LeaveSolid_think();
+ if (hit && hit != WarpZone_trace_forent && hit != fireBullet_last_hit) // Avoid self-damage (except after going through a warp); avoid hitting the same entity twice (engine bug).
+ {
+ fireBullet_last_hit = hit;
+ yoda = 0;
+ float g = accuracy_isgooddamage(self, hit);
+ Damage(hit, self, self, damage * solid_penetration_left, dtype, start, force * dir * solid_penetration_left);
+ // calculate hits for ballistic weapons
+ if(g)
+ {
+ // do not exceed 100%
+ float added_damage = min(damage - total_damage, damage * solid_penetration_left);
+ total_damage += damage * solid_penetration_left;
+ accuracy_add(self, self.weapon, 0, added_damage);
+ }
+ }
- self.projectiledeathtype |= HITTYPE_BOUNCE;
- }
- frametime = savetime;
- self = oldself;
+ if (is_weapclip)
+ break;
- if(lag)
- FOR_EACH_PLAYER(pl)
- if(pl != self)
- antilag_restore(pl);
+ // go through solid!
+ // outside the world? forget it
+ if(start_x > world.maxs_x || start_y > world.maxs_y || start_z > world.maxs_z || start_x < world.mins_x || start_y < world.mins_y || start_z < world.mins_z)
+ break;
- remove(proj);
+ float maxdist;
+ if(max_solid_penetration < 0)
+ break;
+ else if(hit.ballistics_density < -1)
+ break; // -2: no solid penetration, ever
+ else if(hit.ballistics_density < 0)
+ maxdist = vlen(hit.maxs - hit.mins) + 1; // -1: infinite travel distance
+ else if(hit.ballistics_density == 0)
+ maxdist = max_solid_penetration * solid_penetration_left;
+ else
+ maxdist = max_solid_penetration * solid_penetration_left * hit.ballistics_density;
- return;
-}
+ if(maxdist <= autocvar_g_ballistics_mindistance)
+ break;
-void fireBullet (vector start, vector dir, float spread, float damage, float force, float dtype, float tracer)
-{
- vector end;
+ // move the entity along its velocity until it's out of solid, then let it resume
+ // The previously hit entity is ignored here!
+ traceline_inverted (start, start + dir * maxdist, MOVE_NORMAL, WarpZone_trace_forent, TRUE, hit);
+ if(trace_fraction == 1) // 1: we never got out of solid
+ break;
- dir = normalize(dir + randomvec() * spread);
- end = start + dir * MAX_SHOT_DISTANCE;
- if(self.antilag_debug)
- traceline_antilag (self, start, end, FALSE, self, self.antilag_debug);
- else
- traceline_antilag (self, start, end, FALSE, self, ANTILAG_LATENCY(self));
+ float dist_taken = max(autocvar_g_ballistics_mindistance, vlen(trace_endpos - start));
+ solid_penetration_left *= (dist_taken / maxdist);
- end = trace_endpos;
+ // Only show effect when going through a player (invisible otherwise)
+ if (hit && (hit.solid != SOLID_BSP))
+ if(vlen(trace_endpos - start) > 4)
+ trailparticles(self, fireBullet_trace_callback_eff, start, trace_endpos);
- if (pointcontents (trace_endpos) != CONTENT_SKY)
- {
- if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT))
- Damage_DamageInfo(trace_endpos, damage, 0, 0, dir * max(1, force), dtype, trace_ent.species, self);
+ start = trace_endpos;
- Damage (trace_ent, self, self, damage, dtype, trace_endpos, dir * force);
+ if(hit.solid == SOLID_BSP)
+ Damage_DamageInfo(start, 0, 0, 0, max(1, force) * normalize(dir) * -solid_penetration_left, dtype, 0, self);
}
- trace_endpos = end;
+
+ if(lag)
+ FOR_EACH_PLAYER(pl)
+ if(pl != self)
+ antilag_restore(pl);
}
float W_CheckProjectileDamage(entity inflictor, entity projowner, float deathtype, float exception)
.float rifle_accumulator;
-void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSpeed, float pLifetime, float pAmmo, float deathtype, float pBulletConstant, float pTracer, float pShots, string pSound)
+void W_Rifle_FireBullet(float pSpread, float pDamage, float pForce, float pSolidPenetration, float pAmmo, float deathtype, float pTracer, float pShots, string pSound)
{
float i;
}
for(i = 0; i < pShots; ++i)
- fireBallisticBullet(w_shotorg, w_shotdir, pSpread, pSpeed, pLifetime, pDamage, pForce, deathtype, (pTracer ? EF_RED : EF_BLUE), pBulletConstant);
- endFireBallisticBullet();
+ fireBullet(w_shotorg, w_shotdir, pSpread, pSolidPenetration, pDamage, pForce, deathtype, (pTracer ? EF_RED : EF_BLUE));
if (autocvar_g_casings >= 2)
SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
void W_Rifle_Attack()
{
- W_Rifle_FireBullet(autocvar_g_balance_rifle_primary_spread, autocvar_g_balance_rifle_primary_damage, autocvar_g_balance_rifle_primary_force, autocvar_g_balance_rifle_primary_speed, autocvar_g_balance_rifle_primary_lifetime, autocvar_g_balance_rifle_primary_ammo, WEP_RIFLE, autocvar_g_balance_rifle_primary_bulletconstant, autocvar_g_balance_rifle_primary_tracer, autocvar_g_balance_rifle_primary_shots, "weapons/campingrifle_fire.wav");
+ W_Rifle_FireBullet(autocvar_g_balance_rifle_primary_spread, autocvar_g_balance_rifle_primary_damage, autocvar_g_balance_rifle_primary_force, autocvar_g_balance_rifle_primary_solidpenetration, autocvar_g_balance_rifle_primary_ammo, WEP_RIFLE, autocvar_g_balance_rifle_primary_tracer, autocvar_g_balance_rifle_primary_shots, "weapons/campingrifle_fire.wav");
}
void W_Rifle_Attack2()
{
- W_Rifle_FireBullet(autocvar_g_balance_rifle_secondary_spread, autocvar_g_balance_rifle_secondary_damage, autocvar_g_balance_rifle_secondary_force, autocvar_g_balance_rifle_secondary_speed, autocvar_g_balance_rifle_secondary_lifetime, autocvar_g_balance_rifle_secondary_ammo, WEP_RIFLE | HITTYPE_SECONDARY, autocvar_g_balance_rifle_secondary_bulletconstant, autocvar_g_balance_rifle_secondary_tracer, autocvar_g_balance_rifle_secondary_shots, "weapons/campingrifle_fire2.wav");
+ W_Rifle_FireBullet(autocvar_g_balance_rifle_secondary_spread, autocvar_g_balance_rifle_secondary_damage, autocvar_g_balance_rifle_secondary_force, autocvar_g_balance_rifle_secondary_solidpenetration, autocvar_g_balance_rifle_secondary_ammo, WEP_RIFLE | HITTYPE_SECONDARY, autocvar_g_balance_rifle_secondary_tracer, autocvar_g_balance_rifle_secondary_shots, "weapons/campingrifle_fire2.wav");
}
void spawnfunc_weapon_rifle (void)
self.bot_secondary_riflemooth = 0;
if(self.bot_secondary_riflemooth == 0)
{
- if(bot_aim(autocvar_g_balance_rifle_primary_speed, 0, autocvar_g_balance_rifle_primary_lifetime, FALSE))
+ if(bot_aim(1000000, 0, 0.001, FALSE))
{
self.BUTTON_ATCK = TRUE;
if(random() < 0.01) self.bot_secondary_riflemooth = 1;
}
else
{
- if(bot_aim(autocvar_g_balance_rifle_secondary_speed, 0, autocvar_g_balance_rifle_secondary_lifetime, FALSE))
+ if(bot_aim(1000000, 0, 0.001, FALSE))
{
self.BUTTON_ATCK2 = TRUE;
if(random() < 0.03) self.bot_secondary_riflemooth = 0;
float d;
float f;
float spread;
- float bulletspeed;
- float bulletconstant;
+ float solidpenetration;
entity flash;
ammoamount = autocvar_g_balance_shotgun_primary_ammo;
d = autocvar_g_balance_shotgun_primary_damage;
f = autocvar_g_balance_shotgun_primary_force;
spread = autocvar_g_balance_shotgun_primary_spread;
- bulletspeed = autocvar_g_balance_shotgun_primary_speed;
- bulletconstant = autocvar_g_balance_shotgun_primary_bulletconstant;
+ solidpenetration = autocvar_g_balance_shotgun_primary_solidpenetration;
W_DecreaseAmmo(ammo_shells, ammoamount, autocvar_g_balance_shotgun_reload_ammo);
W_SetupShot (self, TRUE, 5, "weapons/shotgun_fire.wav", CH_WEAPON_A, d * bullets);
for (sc = 0;sc < bullets;sc = sc + 1)
- fireBallisticBullet(w_shotorg, w_shotdir, spread, bulletspeed, 5, d, f, WEP_SHOTGUN, 0, bulletconstant);
- endFireBallisticBullet();
+ fireBullet(w_shotorg, w_shotdir, spread, solidpenetration, d, f, WEP_SHOTGUN, 0);
pointparticles(particleeffectnum("shotgun_muzzleflash"), w_shotorg, w_shotdir * 1000, autocvar_g_balance_shotgun_primary_ammo);
ATTACK_FINISHED(self) = time + autocvar_g_balance_uzi_first_refire * W_WeaponRateFactor();
if (self.misc_bulletcounter == 1)
- fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_first_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_first_damage, autocvar_g_balance_uzi_first_force, deathtype, 0, autocvar_g_balance_uzi_bulletconstant);
+ fireBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_first_spread, autocvar_g_balance_uzi_solidpenetration, autocvar_g_balance_uzi_first_damage, autocvar_g_balance_uzi_first_force, deathtype, 0);
else
- fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_sustained_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, deathtype, 0, autocvar_g_balance_uzi_bulletconstant);
- endFireBallisticBullet();
+ fireBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_sustained_spread, autocvar_g_balance_uzi_solidpenetration, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, deathtype, 0);
pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
}
uzi_spread = bound(autocvar_g_balance_uzi_spread_min, autocvar_g_balance_uzi_spread_min + (autocvar_g_balance_uzi_spread_add * self.misc_bulletcounter), autocvar_g_balance_uzi_spread_max);
- fireBallisticBullet(w_shotorg, w_shotdir, uzi_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, autocvar_g_balance_uzi_bulletconstant);
- endFireBallisticBullet();
+ fireBullet(w_shotorg, w_shotdir, uzi_spread, autocvar_g_balance_uzi_solidpenetration, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0);
self.misc_bulletcounter = self.misc_bulletcounter + 1;
self.punchangle_y = random () - 0.5;
}
- fireBallisticBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_burst_spread, autocvar_g_balance_uzi_speed, 5, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0, autocvar_g_balance_uzi_bulletconstant);
- endFireBallisticBullet();
-
+ fireBullet(w_shotorg, w_shotdir, autocvar_g_balance_uzi_burst_spread, autocvar_g_balance_uzi_solidpenetration, autocvar_g_balance_uzi_sustained_damage, autocvar_g_balance_uzi_sustained_force, WEP_UZI, 0);
pointparticles(particleeffectnum("uzi_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
set g_vehicle_spiderbot_minigun_refire 0.06
set g_vehicle_spiderbot_minigun_force 9
set g_vehicle_spiderbot_minigun_spread 0.015
-set g_vehicle_spiderbot_minigun_speed 45000 // ~ 32QU
-set g_vehicle_spiderbot_minigun_bulletconstant 110
+set g_vehicle_spiderbot_minigun_solidpenetration 32
set g_vehicle_spiderbot_minigun_ammo_cost 1
set g_vehicle_spiderbot_minigun_ammo_max 100
set g_vehicle_spiderbot_minigun_ammo_regen 40