Skip to content

Commit

Permalink
Merge pull request #1282 from newbytf/dev-cur
Browse files Browse the repository at this point in the history
Dev cur
  • Loading branch information
newbytf authored Jan 18, 2024
2 parents 737c19a + ad2f844 commit f5a98be
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 32 deletions.
3 changes: 1 addition & 2 deletions csqc/weapon_predict.qc
Original file line number Diff line number Diff line change
Expand Up @@ -1777,8 +1777,7 @@ void WP_Attack() {
PP_CreateProjectile(FPP_TRANQ, PM_Org() + v_forward * 8 + '0 0 16');
break;
case WEAP_RAILGUN:
if (!NewBalanceActive())
PP_CreateProjectile(FPP_RAILGUN, PM_Org() + '0 0 16');
PP_CreateProjectile(FPP_RAILGUN, PM_Org() + '0 0 16');
break;

case WEAP_ASSAULT_CANNON:
Expand Down
2 changes: 1 addition & 1 deletion share/weapons.qc
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static FO_WeapModels weapon_models[] = {
{ WEAP_DETPACK, "" },
{ WEAP_TRANQ, "progs/v_tranq.mdl" },
{ WEAP_RAILGUN, "progs/v_rail.mdl" },
{ WEAP_IMPELLER, "progs/v_rail.mdl" },
{ WEAP_IMPELLER, "progs/v_light.mdl" },
};

// REQUIRES: Order must match above.
Expand Down
7 changes: 6 additions & 1 deletion ssqc/client.qc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ void ActivateNewBalance() {
PC_PYRO_AIRBLAST_COOLDOWN = 10;
PC_ENGINEER_GRENADE_TYPE_2_RANGE = 200;

float use_new_conc = CF_GetSetting("nbc", "new_balance_concs", "1");
float use_new_conc = CF_GetSetting("nbc", "new_balance_concs", "4");
if (use_new_conc == 4 && ServerRegion() == kRegionOCE)
use_new_conc = 1;
else
use_new_conc = 0;

if (!use_new_conc)
fo_config.new_balance_flags |= NBF_OLD_CONC;
float no_cap = CF_GetSetting("nbnc", "new_balance_no_cap", "0");
Expand Down
145 changes: 117 additions & 28 deletions ssqc/engineer.qc
Original file line number Diff line number Diff line change
Expand Up @@ -93,46 +93,135 @@ static void ImpellerTouch() {
dremove(self);
}

void W_FireImpeller() {
vector vec, org;

makevectors(self.v_angle);
org = (self.absmin + self.absmax) / 2;
static float ValidImpellerTarget(entity t) {
if (t.classname != "player")
return FALSE;

traceline(org, org + 1500 * v_forward, MOVE_WORLDONLY, world);
if (cb_prematch) // Shoot anyone in prematch
return TRUE;

self.special_next = time + 3;
return (t.team_no != self.team_no && t.has_flag);
}

if (trace_fraction == 1)
return;
static entity FindImpellerTarget(vector org, float min_a, float* direct) {

if (pointcontents(trace_endpos) == CONTENT_SKY)
return;
traceline(org, org + 1500 * v_forward, MOVE_NORMAL, world);
if (trace_fraction != 1 && ValidImpellerTarget(trace_ent))
return trace_ent;

vector term = trace_endpos;
vector vec = normalize(term - org);
int count;
entity* players;
float best_a = min_a;
entity best_p = world;

pointparticles(particleeffectnum("fo_airblast"), term);
players = find_list(classname, "player", EV_STRING, count);
for (int i = 0; i < count; i++) {
entity p = players[i];

entity proj = FOProj_Create(FPP_RAILGUN);
proj.owner = proj; // Want collisions with everyone
proj.real_owner = self;
proj.enemy = self;
proj.movetype = MOVETYPE_FLYMISSILE;
proj.solid = SOLID_BBOX;
if (!ValidImpellerTarget(p))
continue;

proj.velocity = -vec * 2250;
proj.angles = vectoangles(proj.velocity);
vector dir = normalize(p.origin - org);
float a = v_forward * dir;

proj.nextthink = time + 5;
proj.think = SUB_Remove;
proj.touch = ImpellerTouch;
proj.classname = "railslug";
traceline(org, p.origin, MOVE_NORMAL, world);
if (trace_fraction < 1) {
if (trace_ent != p) {
continue; // Something in the way
} else {
*direct = TRUE;
return p;
}
}

setorigin(proj, term);
FOProj_Finalize(proj);
if (a < best_a)
continue; // Not in AA cone

best_a = a;
best_p = p;
}

return best_p;
}

static vector find_closest(vector a, vector b, vector p) {
vector v = b - a, u = a - p;
float t = -(v * u) / (v * v);

if (t >= 0 && t <= 1)
return (1 - t) * a + t * b;
return b;
}

static void draw_beam(vector a, vector b, int effect) {
WriteByte(MSG_MULTICAST, SVC_TEMPENTITY);
WriteByte(MSG_MULTICAST, effect);
WriteEntity(MSG_MULTICAST, world);
WriteCoord(MSG_MULTICAST, a_x);
WriteCoord(MSG_MULTICAST, a_y);
WriteCoord(MSG_MULTICAST, a_z);
WriteCoord(MSG_MULTICAST, b_x);
WriteCoord(MSG_MULTICAST, b_y);
WriteCoord(MSG_MULTICAST, b_z);
multicast(a, MULTICAST_PHS);
}

void W_FireImpeller() {
if (!cb_prematch) {
self.special_next = time + 3;
}

FO_Sound(self, CHAN_WEAPON, "weapons/lhit.wav", 1, ATTN_NORM);
makevectors(self.v_angle);

vector org = self.origin + '0 0 16';
float direct = FALSE, jump = FALSE;
entity t = FindImpellerTarget(org, 0.985, &direct);
vector end = t.origin;
vector imp;

float mag = 250;
entity hit;

if (t == world) {
traceline(org, org + 350 * v_forward, MOVE_WORLDONLY, world);
if (trace_fraction == 1)
return;

end = trace_endpos;
hit = self;
draw_beam(org, trace_endpos, TE_LIGHTNING2);
} else {
hit = t;

if (direct) {
end = t.origin;
draw_beam(org, t.origin, TE_LIGHTNING2);
} else {
vector a = org, b = org + 1000 * v_forward;
traceline(a, b, MOVE_WORLDONLY, world);
if (trace_fraction == 1)
return;
end = trace_endpos;
vector x = find_closest(a, end, t.origin);

draw_beam(a, x, TE_LIGHTNING2);
draw_beam(x, t.origin, TE_LIGHTNING2);

// Discount knockback by help given
mag -= max(10, vlen(t.origin - x));
}

hit = t;
end = t.origin;
}

Pred_Sound(SND_RAILGUN);
TF_T_Damage(hit, self, self, 5, 2, TF_TD_ELECTRICITY | TF_TD_NOMOMENTUM);
hit.flags &= ~FL_ONGROUND;
hit.velocity -= mag * normalize(end - org);
if (other.has_flag)
mag *= 2;
}

void () W_FireRailgun = {
Expand Down

0 comments on commit f5a98be

Please sign in to comment.