Commit 228743a6 authored by terencehill's avatar terencehill

Merge branch 'master' into terencehill/bot_fix

parents 66fc0a87 deafac15
Pipeline #5578232 failed with stage
in 11 minutes and 49 seconds
......@@ -63,7 +63,7 @@ void HUD_Powerups()
{
int allItems = STAT(ITEMS);
int allBuffs = STAT(BUFFS);
int strengthTime, shieldTime, superTime;
float strengthTime, shieldTime, superTime;
// Initialize items
if(!autocvar__hud_configure)
......@@ -72,7 +72,7 @@ void HUD_Powerups()
return;
if(STAT(HEALTH) <= 0 && autocvar_hud_panel_powerups_hide_ondeath)
return;
if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return;
//if(!(allItems & (ITEM_Strength.m_itemid | ITEM_Shield.m_itemid | IT_SUPERWEAPON)) && !allBuffs) return;
strengthTime = bound(0, STAT(STRENGTH_FINISHED) - time, 99);
shieldTime = bound(0, STAT(INVINCIBLE_FINISHED) - time, 99);
......
......@@ -312,10 +312,10 @@ void HUD_Radar()
else
{
vector c0, c1, c2, c3, span;
c0 = rotate(mi_min, teamradar_angle * DEG2RAD);
c1 = rotate(mi_max, teamradar_angle * DEG2RAD);
c2 = rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
c3 = rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
c0 = Rotate(mi_min, teamradar_angle * DEG2RAD);
c1 = Rotate(mi_max, teamradar_angle * DEG2RAD);
c2 = Rotate('1 0 0' * mi_min.x + '0 1 0' * mi_max.y, teamradar_angle * DEG2RAD);
c3 = Rotate('1 0 0' * mi_max.x + '0 1 0' * mi_min.y, teamradar_angle * DEG2RAD);
span = '0 0 0';
span.x = max(c0_x, c1_x, c2_x, c3_x) - min(c0_x, c1_x, c2_x, c3_x);
span.y = max(c0_y, c1_y, c2_y, c3_y) - min(c0_y, c1_y, c2_y, c3_y);
......
......@@ -31,7 +31,7 @@ vector HUD_GetFontsize(string cvarname);
float PreviewExists(string name);
vector rotate(vector v, float a);
vector Rotate(vector v, float a);
#define IS_DEAD(s) (((s).classname == "csqcmodel") ? (s).csqcmodel_isdead : ((s).health <= 0))
......
......@@ -20,7 +20,7 @@ vector teamradar_texcoord_to_2dcoord(vector in)
vector out;
in -= teamradar_origin3d_in_texcoord;
out = rotate(in, teamradar_angle * DEG2RAD);
out = Rotate(in, teamradar_angle * DEG2RAD);
out.y = - out.y; // screen space is reversed
out = out * teamradar_size;
......@@ -42,7 +42,7 @@ vector teamradar_2dcoord_to_texcoord(vector in)
out = out / teamradar_size;
out_y = - out_y; // screen space is reversed
out = rotate(out, -teamradar_angle * DEG2RAD);
out = Rotate(out, -teamradar_angle * DEG2RAD);
out += teamradar_origin3d_in_texcoord;
......
......@@ -13,9 +13,9 @@ MACRO_END
// #define PROP(public, fld, set, sv, cl)
#define ENTCS_NETPROPS(ent, PROP) PROP(false, sv_entnum, ENTCS_SET_NORMAL, {}, {}) /* sentinel */ \
PROP(false, origin, ENTCS_SET_NORMAL, \
{ WriteShort(chan, ent.origin.x); WriteShort(chan, ent.origin.y); \
WriteShort(chan, ent.origin.z); }, \
{ ent.has_sv_origin = true; vector v; v.x = ReadShort(); v.y = ReadShort(); v.z = ReadShort(); setorigin(ent, v); }) \
{ WriteCoord(chan, ent.origin.x); WriteCoord(chan, ent.origin.y); \
WriteCoord(chan, ent.origin.z); }, \
{ ent.has_sv_origin = true; vector v; v.x = ReadCoord(); v.y = ReadCoord(); v.z = ReadCoord(); setorigin(ent, v); }) \
\
PROP(false, angles_y, ENTCS_SET_NORMAL, \
{ WriteByte(chan, ent.angles.y / 360 * 256); }, \
......
......@@ -1638,7 +1638,7 @@ bool ons_Teleport(entity player, entity tele_target, float range, bool tele_effe
loc += tele_target.origin + '0 0 128' * iteration_scale;
tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(tele_target.origin, loc, MOVE_NOMONSTERS, tele_target); // double check to make sure we're not spawning outside the NULL
......@@ -1757,7 +1757,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn)
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 96' * iteration_scale;
loc += ('0 1 0' * random()) * 128 * iteration_scale;
tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the NULL
......@@ -1808,7 +1808,7 @@ MUTATOR_HOOKFUNCTION(ons, PlayerSpawn)
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 128' * iteration_scale;
loc += ('0 1 0' * random()) * 256 * iteration_scale;
tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the NULL
......
......@@ -4,7 +4,7 @@
#include "item.qh"
REGISTRY(Items, BITS(5))
REGISTRY(Items, BITS(7))
#define Items_from(i) _Items_from(i, NULL)
REGISTER_REGISTRY(Items)
#define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
......
......@@ -15,17 +15,33 @@ ENDCLASS(Inventory)
REGISTER_NET_LINKED(ENT_CLIENT_INVENTORY)
const int Inventory_groups_major = 16;
const int Inventory_groups_minor = 8; // ceil(Items_MAX / Inventory_groups_major)
#define G_MAJOR(id) (floor((id) / Inventory_groups_minor))
#define G_MINOR(id) ((id) % Inventory_groups_minor)
#ifdef CSQC
NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
{
make_pure(this);
const int bits = ReadInt24_t();
FOREACH(Items, bits & BIT(it.m_id), {
.int fld = inv_items[it.m_id];
int prev = this.(fld);
int next = this.(fld) = ReadByte();
LOG_TRACEF("%s: %.0f -> %.0f", it.m_name, prev, next);
});
const int majorBits = ReadShort();
for (int i = 0; i < Inventory_groups_major; ++i) {
if (!(majorBits & BIT(i))) {
continue;
}
const int minorBits = ReadByte();
for (int j = 0; j < Inventory_groups_minor; ++j) {
if (!(minorBits & BIT(j))) {
continue;
}
const GameItem it = Items_from(Inventory_groups_minor * i + j);
.int fld = inv_items[it.m_id];
int prev = this.(fld);
int next = this.(fld) = ReadByte();
LOG_TRACEF("%s: %.0f -> %.0f", it.m_name, prev, next);
}
}
return true;
}
#endif
......@@ -34,22 +50,56 @@ NET_HANDLE(ENT_CLIENT_INVENTORY, bool isnew)
void Inventory_Write(Inventory data)
{
if (!data) {
WriteInt24_t(MSG_ENTITY, 0);
WriteShort(MSG_ENTITY, 0);
return;
}
TC(Inventory, data);
int bits = 0;
int majorBits = 0;
FOREACH(Items, true, {
.int fld = inv_items[it.m_id];
bits = BITSET(bits, BIT(it.m_id), data.inventory.(fld) != (data.inventory.(fld) = data.(fld)));
const bool changed = data.inventory.(fld) != data.(fld);
if (changed) {
majorBits = BITSET(majorBits, BIT(G_MAJOR(it.m_id)), true);
}
});
WriteInt24_t(MSG_ENTITY, bits);
FOREACH(Items, bits & BIT(it.m_id), {
WriteByte(MSG_ENTITY, data.inv_items[it.m_id]);
WriteShort(MSG_ENTITY, majorBits);
int minorBits = 0;
int lastMaj = 0;
int maj = 0;
FOREACH(Items, majorBits & BIT(maj = G_MAJOR(it.m_id)), {
.int fld = inv_items[it.m_id];
const bool changed = data.inventory.(fld) != (data.inventory.(fld) = data.(fld));
if (changed) {
if (maj != lastMaj) {
lastMaj = maj;
#define X() MACRO_BEGIN \
if (minorBits) { \
WriteByte(MSG_ENTITY, minorBits); \
for (int j = 0; j < Inventory_groups_minor; ++j) { \
if (!(minorBits & BIT(j))) { \
continue; \
} \
const GameItem it = Items_from(Inventory_groups_minor * maj + j); \
WriteByte(MSG_ENTITY, data.inv_items[it.m_id]); \
} \
} \
MACRO_END
X();
minorBits = 0;
}
minorBits = BITSET(minorBits, BIT(G_MINOR(it.m_id)), true);
}
});
X();
#undef X
}
#endif
#undef G_MAJOR
#undef G_MINOR
#ifdef SVQC
bool Inventory_Send(Inventory this, Client to, int sf)
{
......
......@@ -34,7 +34,6 @@ const int IT_SUPERWEAPON = BIT(21); // suit
const int IT_STRENGTH = BIT(22);
// item masks
const int IT_AMMO = IT_FUEL | IT_SHELLS | IT_NAILS | IT_ROCKETS | IT_CELLS | IT_PLASMA;
const int IT_UNLIMITED_AMMO = IT_UNLIMITED_WEAPON_AMMO | IT_UNLIMITED_SUPERWEAPONS;
const int IT_PICKUPMASK = IT_UNLIMITED_AMMO | IT_JETPACK | IT_FUEL_REGEN; // strength and invincible are handled separately
......
This diff is collapsed.
......@@ -116,22 +116,22 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
switch(i)
{
case 0:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 + v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin - v_forward * 64 + v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
break;
case 1:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 64 - v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin - v_forward * 64 - v_right * 128 + v_up * 64, MOVE_NOMONSTERS, it);
break;
case 2:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin + v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin + v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
break;
case 3:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin - v_right * 192 + v_up * 64, MOVE_NOMONSTERS, it);
break;
case 4:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 + v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin - v_forward * 128 + v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
break;
case 5:
tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - v_forward * 128 - v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
tracebox(it.origin, STAT(PL_MIN, player), STAT(PL_MAX, player), it.origin - v_forward * 128 - v_right * 64 + v_up * 64, MOVE_NOMONSTERS, it);
break;
}
......@@ -141,17 +141,17 @@ MUTATOR_HOOKFUNCTION(spawn_near_teammate, PlayerSpawn)
// 400 is about the height of a typical laser jump (in overkill)
// not traceline because we need space for the whole player, not just his origin
tracebox(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), horizontal_trace_endpos - '0 0 400', MOVE_NORMAL, it);
tracebox(horizontal_trace_endpos, STAT(PL_MIN, player), STAT(PL_MAX, player), horizontal_trace_endpos - '0 0 400', MOVE_NORMAL, it);
vector vectical_trace_endpos = trace_endpos;
//te_lightning1(NULL, horizontal_trace_endpos, vectical_trace_endpos);
if (trace_startsolid) goto skip; // inside another player
if (trace_fraction == 1.0) goto skip; // above void or too high
if (trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY) goto skip;
if (pointcontents(vectical_trace_endpos) != CONTENT_EMPTY) goto skip; // no lava or slime (or water which i assume would be annoying anyway)
if (tracebox_hits_trigger_hurt(horizontal_trace_endpos, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), vectical_trace_endpos)) goto skip;
if (tracebox_hits_trigger_hurt(horizontal_trace_endpos, STAT(PL_MIN, player), STAT(PL_MAX, player), vectical_trace_endpos)) goto skip;
// make sure the spawned player will have floor ahead (or at least a wall - he shouldn't fall as soon as he starts moving)
vector floor_test_start = vectical_trace_endpos + v_up * STAT(PL_MAX, NULL).z + v_forward * STAT(PL_MAX, NULL).x; // top front of player's bbox - highest point we know is not inside solid
vector floor_test_start = vectical_trace_endpos + v_up * STAT(PL_MAX, player).z + v_forward * STAT(PL_MAX, player).x; // top front of player's bbox - highest point we know is not inside solid
traceline(floor_test_start, floor_test_start + v_forward * 100 - v_up * 128, MOVE_NOMONSTERS, it);
//te_beam(NULL, floor_test_start, trace_endpos);
if (trace_fraction == 1.0) goto skip;
......
......@@ -282,10 +282,10 @@ void drawrotpic(vector org, float rot, string pic, vector sz, vector hotspot, ve
// rotate them, and make them absolute
rot = -rot; // rotate by the opposite angle, as our coordinate system is reversed
v1 = rotate(v1, rot) + org;
v2 = rotate(v2, rot) + org;
v3 = rotate(v3, rot) + org;
v4 = rotate(v4, rot) + org;
v1 = Rotate(v1, rot) + org;
v2 = Rotate(v2, rot) + org;
v3 = Rotate(v3, rot) + org;
v4 = Rotate(v4, rot) + org;
// draw them
R_BeginPolygon(pic, f);
......@@ -319,9 +319,9 @@ void drawhealthbar(vector org, float rot, float h, vector sz, vector hotspot, fl
up = '0 1 0';
rot = -rot; // rotate by the opposite angle, as our coordinate system is reversed
o = rotate(o, rot) + org;
ri = rotate(ri, rot);
up = rotate(up, rot);
o = Rotate(o, rot) + org;
ri = Rotate(ri, rot);
up = Rotate(up, rot);
owidth = width + 2 * border;
o = o - up * (margin + border + theheight) + ri * (sz.x - owidth) * 0.5;
......@@ -348,19 +348,19 @@ vector drawspritearrow(vector o, float ang, vector rgb, float a, float t)
R_BeginPolygon("", DRAWFLAG_NORMAL);
R_PolygonVertex(o, '0 0 0', '0 0 0', a);
R_PolygonVertex(o + rotate(arrowY - borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + rotate(borderY - borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + rotate(borderY + borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + rotate(arrowY + borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + Rotate(arrowY - borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + Rotate(borderY - borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + Rotate(borderY + borderX, ang), '0 0 0', '0 0 0', a);
R_PolygonVertex(o + Rotate(arrowY + borderX, ang), '0 0 0', '0 0 0', a);
R_EndPolygon();
R_BeginPolygon("", DRAWFLAG_ADDITIVE);
R_PolygonVertex(o + rotate(eY * borderDiag, ang), '0 0 0', rgb, a);
R_PolygonVertex(o + rotate(arrowY - arrowX, ang), '0 0 0', rgb, a);
R_PolygonVertex(o + rotate(arrowY + arrowX, ang), '0 0 0', rgb, a);
R_PolygonVertex(o + Rotate(eY * borderDiag, ang), '0 0 0', rgb, a);
R_PolygonVertex(o + Rotate(arrowY - arrowX, ang), '0 0 0', rgb, a);
R_PolygonVertex(o + Rotate(arrowY + arrowX, ang), '0 0 0', rgb, a);
R_EndPolygon();
return o + rotate(eY * (borderDiag+size+margin), ang);
return o + Rotate(eY * (borderDiag+size+margin), ang);
}
// returns location of sprite healthbar
......
......@@ -115,7 +115,7 @@ void PM_ClientMovement_UpdateStatus(entity this)
// wants to stand, if currently crouching we need to check for a low ceiling first
if (IS_DUCKED(this))
{
tracebox(this.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), this.origin, MOVE_NORMAL, this);
tracebox(this.origin, STAT(PL_MIN, this), STAT(PL_MAX, this), this.origin, MOVE_NORMAL, this);
if (!trace_startsolid) UNSET_DUCKED(this);
}
}
......@@ -803,5 +803,10 @@ void CSQC_ClientMovement_PlayerMove_Frame(entity this)
#ifdef SVQC
this.pm_frametime = frametime;
#elif defined(CSQC)
if((ITEMS_STAT(this) & IT_USING_JETPACK) && !IS_DEAD(this) && !intermission)
this.csqcmodel_modelflags |= MF_ROCKET;
else
this.csqcmodel_modelflags &= ~MF_ROCKET;
#endif
}
......@@ -44,14 +44,14 @@ const int MAX_CL_STATS = 256;
REGISTER_STAT(WEAPONS, vectori)
REGISTER_STAT(WEAPONSINMAP, vectori)
REGISTER_STAT(PL_VIEW_OFS, vector, autocvar_sv_player_viewoffset)
REGISTER_STAT(PL_CROUCH_VIEW_OFS, vector, autocvar_sv_player_crouch_viewoffset)
REGISTER_STAT(PL_VIEW_OFS, vector)
REGISTER_STAT(PL_CROUCH_VIEW_OFS, vector)
REGISTER_STAT(PL_MIN, vector, autocvar_sv_player_mins)
REGISTER_STAT(PL_CROUCH_MIN, vector, autocvar_sv_player_crouch_mins)
REGISTER_STAT(PL_MIN, vector)
REGISTER_STAT(PL_CROUCH_MIN, vector)
REGISTER_STAT(PL_MAX, vector, autocvar_sv_player_maxs)
REGISTER_STAT(PL_CROUCH_MAX, vector, autocvar_sv_player_crouch_maxs)
REGISTER_STAT(PL_MAX, vector)
REGISTER_STAT(PL_CROUCH_MAX, vector)
REGISTER_STAT(KH_KEYS, int)
......
......@@ -393,7 +393,7 @@ bool have_pickup_item(entity this)
if(autocvar_g_pickup_items == 0)
return false;
if(g_weaponarena)
if(this.weapons || (this.items & IT_AMMO)) // no item or ammo pickups in weaponarena
if(this.weapons || this.itemdef.instanceOfAmmo) // no item or ammo pickups in weaponarena
return false;
}
return true;
......
......@@ -277,7 +277,7 @@ void trigger_push_findtarget(entity this)
{
// first calculate a typical start point for the jump
vector org = (this.absmin + this.absmax) * 0.5;
org_z = this.absmax.z - STAT(PL_MIN, NULL).z;
org.z = this.absmax.z - PL_MIN_CONST.z;
if (this.target)
{
......@@ -288,7 +288,7 @@ void trigger_push_findtarget(entity this)
#ifdef SVQC
entity e = spawn();
setorigin(e, org);
setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
setsize(e, PL_MIN_CONST, PL_MAX_CONST);
e.velocity = trigger_push_calculatevelocity(org, t, this.height);
tracetoss(e, e);
if(e.move_movetype == MOVETYPE_NONE)
......@@ -321,7 +321,7 @@ void trigger_push_findtarget(entity this)
{
entity e = spawn();
setorigin(e, org);
setsize(e, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
setsize(e, PL_MIN_CONST, PL_MAX_CONST);
e.velocity = this.movedir;
tracetoss(e, e);
waypoint_spawnforteleporter(this, trace_endpos, vlen(trace_endpos - org) / vlen(e.velocity));
......
......@@ -44,7 +44,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, .entity
}
}
bool hk_is_valid_target(entity this, entity e_target);
bool hk_is_valid_target(entity this, entity proj, entity targ);
void turret_hk_missile_think(entity this)
{
vector vu, vd, vf, vl, vr, ve; // Vector (direction)
......@@ -53,10 +53,7 @@ void turret_hk_missile_think(entity this)
float lt_for; // Length of Trace FORwrad
float lt_seek; // Length of Trace SEEK (left, right, up down)
float pt_seek; // Pitch of Trace SEEK (How mutch to angele left, right up, down trace towards v_forward)
vector pre_pos;
float myspeed;
entity e;
float ad,edist;
this.nextthink = time + this.ticrate;
......@@ -69,19 +66,17 @@ void turret_hk_missile_think(entity this)
// Pick the closest valid target.
if (!this.enemy)
{
e = findradius(this.origin, 5000);
while (e)
// in this case, the lighter check is to validate it first, and check distance if it is valid
IL_EACH(g_damagedbycontents, hk_is_valid_target(this.owner, this, it),
{
if (hk_is_valid_target(this, e))
{
if (!this.enemy)
this.enemy = e;
else
if (vlen2(this.origin - e.origin) < vlen2(this.origin - this.enemy.origin))
this.enemy = e;
}
e = e.chain;
}
if(vdist(it.origin, >, 5000))
continue;
if(!this.enemy)
this.enemy = it;
else if(vlen2(this.origin - it.origin) < vlen2(this.origin - this.enemy.origin))
this.enemy = it;
});
}
this.angles = vectoangles(this.velocity);
......@@ -91,16 +86,15 @@ void turret_hk_missile_think(entity this)
if (this.enemy)
{
edist = vlen(this.origin - this.enemy.origin);
// Close enougth to do decent damage?
if ( edist <= (this.owner.shot_radius * 0.25) )
if(vdist(this.origin - this.enemy.origin, <=, (this.owner.shot_radius * 0.25)))
{
turret_projectile_explode(this);
return;
}
// Get data on enemy position
pre_pos = this.enemy.origin +
vector pre_pos = this.enemy.origin +
this.enemy.velocity *
min((vlen(this.enemy.origin - this.origin) / vlen(this.velocity)),0.5);
......@@ -111,12 +105,11 @@ void turret_hk_missile_think(entity this)
}
else
{
edist = 0;
ve = '0 0 0';
ve = '0 0 0';
fe = 0;
}
if ((fe != 1) || (this.enemy == NULL) || (edist > 1000))
if ((fe != 1) || (this.enemy == NULL) || vdist(this.origin - this.enemy.origin, >, 1000))
{
myspeed = vlen(this.velocity);
......@@ -129,7 +122,7 @@ void turret_hk_missile_think(entity this)
ff = trace_fraction;
// Find angular offset
ad = vlen(vectoangles(normalize(this.enemy.origin - this.origin)) - this.angles);
float ad = vlen(vectoangles(normalize(this.enemy.origin - this.origin)) - this.angles);
// To close to something, Slow down!
if ( ((ff < 0.7) || (ad > 4)) && (myspeed > (autocvar_g_turrets_unit_hk_shot_speed)) )
......@@ -224,7 +217,7 @@ void turret_hk_missile_think(entity this)
#ifdef TURRET_DEBUG_HK
//if(this.atime < time) {
if ((fe <= 0.99)||(edist > 1000))
if ((fe <= 0.99)||vdist(this.origin - this.enemy.origin, >, 1000))
{
te_lightning2(NULL,this.origin, this.origin + vr * lt_seek);
te_lightning2(NULL,this.origin, this.origin + vl * lt_seek);
......@@ -246,35 +239,39 @@ void turret_hk_missile_think(entity this)
UpdateCSQCProjectile(this);
}
bool hk_is_valid_target(entity this, entity e_target)
bool hk_is_valid_target(entity this, entity proj, entity targ)
{
if (e_target == NULL)
if (!targ)
return false;
// we know for sure pure entities are bad targets
if(is_pure(targ))
return false;
// If only this was used more..
if (e_target.flags & FL_NOTARGET)
if (targ.flags & FL_NOTARGET)
return false;
// Cant touch this
if ((e_target.takedamage == DAMAGE_NO) || (e_target.health < 0))
if ((targ.takedamage == DAMAGE_NO) || (targ.health < 0))
return false;
// player
if (IS_CLIENT(e_target))
if (IS_PLAYER(targ))
{
if (this.owner.target_select_playerbias < 0)
if (this.target_select_playerbias < 0)
return false;
if (IS_DEAD(e_target))
if (IS_DEAD(targ))
return false;
}
// Missile
if ((e_target.flags & FL_PROJECTILE) && (this.owner.target_select_missilebias < 0))
if ((targ.flags & FL_PROJECTILE) && (this.target_select_missilebias < 0))
return false;
// Team check
if ((e_target.team == this.owner.team) || (this.owner.team == e_target.owner.team))
if ((targ.team == this.team) || (this.team == targ.owner.team))
return false;
return true;
......
......@@ -739,7 +739,8 @@ void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpa
// vehicle enter/exit handling
vector vehicles_findgoodexit(entity this, vector prefer_spot)
{
tracebox(this.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, this.owner);
// TODO: we actually want the player's size here
tracebox(this.origin + '0 0 32', PL_MIN_CONST, PL_MAX_CONST, prefer_spot, MOVE_NORMAL, this.owner);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return prefer_spot;
......@@ -751,7 +752,7 @@ vector vehicles_findgoodexit(entity this, vector prefer_spot)
v = randomvec();
v_z = 0;
v = v2 + normalize(v) * mysize;
tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, this.owner);
tracebox(v2, PL_MIN_CONST, PL_MAX_CONST, v, MOVE_NORMAL, this.owner);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return v;
}
......@@ -793,7 +794,7 @@ void vehicles_exit(entity vehic, bool eject)
WriteAngle(MSG_ONE, 0);
}
setsize(player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
setsize(player, STAT(PL_MIN,player), STAT(PL_MAX, player));
player.takedamage = DAMAGE_AIM;
player.solid = SOLID_SLIDEBOX;
......@@ -803,7 +804,7 @@ void vehicles_exit(entity vehic, bool eject)
player.alpha = 1;
player.PlayerPhysplug = func_null;
player.vehicle = NULL;
player.view_ofs = STAT(PL_VIEW_OFS, NULL);
player.view_ofs = STAT(PL_VIEW_OFS, player);
player.event_damage = PlayerDamage;
player.hud = HUD_NORMAL;
PS(player).m_switchweapon = vehic.m_switchweapon;
......@@ -959,8 +960,8 @@ void vehicles_enter(entity pl, entity veh)
veh.vehicle_hudmodel.viewmodelforclient = pl;
pl.crouch = false;
pl.view_ofs = STAT(PL_VIEW_OFS, NULL);
setsize (pl, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
pl.view_ofs = STAT(PL_VIEW_OFS, pl);
setsize (pl, STAT(PL_MIN, pl), STAT(PL_MAX, pl));
veh.event_damage = vehicles_damage;
veh.nextthink = 0;
......
......@@ -184,11 +184,11 @@ vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity p
//vector exitspot;
float mysize;
tracebox(gunner.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, player);
tracebox(gunner.origin + '0 0 32', STAT(PL_MIN, player), STAT(PL_MAX, player), prefer_spot, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return prefer_spot;
mysize = 1.5 * vlen(STAT(PL_MAX, NULL) - STAT(PL_MIN, NULL)); // can't use gunner's size, as they don't have a size
mysize = 1.5 * vlen(STAT(PL_MAX, player) - STAT(PL_MIN, player)); // can't use gunner's size, as they don't have a size
float i;
vector v, v2;
v2 = 0.5 * (gunner.absmin + gunner.absmax);
......@@ -197,7 +197,7 @@ vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity p
v = randomvec();
v_z = 0;
v = v2 + normalize(v) * mysize;
tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, player);
tracebox(v2, STAT(PL_MIN, player), STAT(PL_MAX, player), v, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
return v;
}
......@@ -224,7 +224,7 @@ void bumblebee_gunner_exit(entity this, int _exitflag)
}
CSQCVehicleSetup(player, HUD_NORMAL);
setsize(player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
setsize(player, STAT(PL_MIN, player), STAT(PL_MAX, player));
player.takedamage = DAMAGE_AIM;
player.solid = SOLID_SLIDEBOX;
......@@ -232,7 +232,7 @@ void bumblebee_gunner_exit(entity this, int _exitflag)
player.effects &= ~EF_NODRAW;
player.alpha = 1;
player.PlayerPhysplug = func_null;
player.view_ofs = STAT(PL_VIEW_OFS, NULL);
player.view_ofs = STAT(PL_VIEW_OFS, player);
player.event_damage = PlayerDamage;
player.hud = HUD_NORMAL;
player.teleportable = TELEPORT_NORMAL;
......
......@@ -133,7 +133,8 @@ void W_Porto_Touch(entity this, entity toucher)
norm = trace_plane_normal;
if(trace_ent.iscreature)
{
traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * STAT(PL_MIN, NULL).z, MOVE_WORLDONLY, this);
// TODO: why not use entity size?
traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * PL_MIN_CONST.z, MOVE_WORLDONLY, this);
if(trace_fraction >= 1)
return;
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP)
......
......@@ -283,7 +283,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit
}
METHOD(Shotgun, wr_setup, void(entity thiswep, entity actor))
{
actor.ammo_field = ammo_none;
actor.ammo_field = ammo_shells;
}
METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
{
......
......@@ -215,24 +215,24 @@ void W_Vaporizer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
W_DecreaseAmmo(thiswep, actor, ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)));
}
void W_RocketMinsta_Laser_Explode (entity this)
void W_RocketMinsta_Laser_Explode (entity this, entity directhitentity)
{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(this.realowner, other))
if(!IS_DEAD(other))
if(IsFlying(other))
if(directhitentity.takedamage == DAMAGE_AIM)
if(IS_PLAYER(directhitentity))
if(DIFF_TEAM(this.realowner, directhitentity))
if(!IS_DEAD(directhitentity))
if(IsFlying(directhitentity))
Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_ELECTROBITCH);
this.event_damage = func_null;
this.takedamage = DAMAGE_NO;
RadiusDamage (this, this.realowner, this.rm_damage, this.rm_edmg, autocvar_g_rm_laser_radius, NULL, NULL, this.rm_force, this.projectiledeathtype, other);
RadiusDamage (this, this.realowner, this.rm_damage, this.rm_edmg, autocvar_g_rm_laser_radius, NULL, NULL, this.rm_force, this.projectiledeathtype, directhitentity);
delete(this);
}
void W_RocketMinsta_Laser_Explode_use(entity this, entity actor, entity trigger)
{
W_RocketMinsta_Laser_Explode(this);
W_RocketMinsta_Laser_Explode(this, trigger); // we probably don't want trigger used here, but this matches closest to old behaviour
}
void W_RocketMinsta_Laser_Touch(entity this, entity toucher)
......
......@@ -109,15 +109,15 @@ void CSQCPlayer_SetMinsMaxs(entity this)
{
if (IS_DUCKED(this) || !this.isplayermodel)
{
this.mins = STAT(PL_CROUCH_MIN, NULL);
this.maxs = STAT(PL_CROUCH_MAX, NULL);
this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, NULL);
this.mins = STAT(PL_CROUCH_MIN, this);
this.maxs = STAT(PL_CROUCH_MAX, this);
this.view_ofs = STAT(PL_CROUCH_VIEW_OFS, this);
}
else
{
this.mins = STAT(PL_MIN, NULL);
this.maxs = STAT(PL_MAX, NULL);
this.view_ofs = STAT(PL_VIEW_OFS, NULL);
this.mins = STAT(PL_MIN, this);
this.maxs = STAT(PL_MAX, this);
this.view_ofs = STAT(PL_VIEW_OFS, this);
}
}
......@@ -226,8 +226,8 @@ void CSQCPlayer_SetCamera()
{
const vector v0 = ((intermission && !autocvar_cl_movement_intermissionrunning) ? '0 0 0' : pmove_vel); // TRICK: pmove_vel is set by the engine when we get here. No need to network velocity
const float vh = STAT(VIEWHEIGHT);
const vector pl_viewofs = STAT(PL_VIEW_OFS, NULL);
const vector pl_viewofs_crouch = STAT(PL_CROUCH_VIEW_OFS, NULL);
const vector pl_viewofs = STAT(PL_VIEW_OFS);
const vector pl_viewofs_crouch = STAT(PL_CROUCH_VIEW_OFS);
const entity e = csqcplayer;
if (e)
{
......
......@@ -101,7 +101,7 @@ noref vector _vec2;
noref vector _vec3;
#define vec3(_x, _y, _z) (_vec3.x = (_x), _vec3.y = (_y), _vec3.z = (_z), _vec3)