Fix armor indirection bug. The compiler ought to warn about name conflicts like these.

This commit is contained in:
Marco Cawthorne 2020-05-28 19:53:24 +02:00
parent 68669fb701
commit 4d201c281b
10 changed files with 3480 additions and 3446 deletions

View file

@ -22,7 +22,8 @@ Draws a little notification for anyone using voice chat
=================
*/
void
Voice_DrawHUD(void) {
Voice_DrawHUD(void)
{
vector pos = video_mins + [video_res[0] - 160, video_res[1] - 136];
for (int i = -1; i > -32; i--) {
@ -61,7 +62,6 @@ Voice_DrawHUD(void) {
}
}
/*
=================
Player_PreDraw
@ -74,10 +74,10 @@ Voice_Draw3D(entity t)
vector vpos = t.origin + [0,0,48];
makevectors(view_angles);
R_BeginPolygon("gfx/vgui/icntlk_pl");
R_PolygonVertex(vpos + v_right*8 - v_up*8, '1 1', [1,1,1], 1);
R_PolygonVertex(vpos - v_right*8 - v_up*8, '0 1', [1,1,1], 1);
R_PolygonVertex(vpos - v_right*8 + v_up*8, '0 0', [1,1,1], 1);
R_PolygonVertex(vpos + v_right*8 + v_up*8, '1 0', [1,1,1], 1);
R_PolygonVertex(vpos + v_right * 8 - v_up * 8, [1,1], [1,1,1], 1.0f);
R_PolygonVertex(vpos - v_right * 8 - v_up * 8, [0,1], [1,1,1], 1.0f);
R_PolygonVertex(vpos - v_right * 8 + v_up * 8, [0,0], [1,1,1], 1.0f);
R_PolygonVertex(vpos + v_right * 8 + v_up * 8, [1,0], [1,1,1], 1.0f);
R_EndPolygon();
}
}

View file

@ -58,14 +58,15 @@ void func_recharge::PlayerUse(void)
return;
}
if (eActivator.armor >= 100) {
base_player pl = (base_player)eActivator;
if (pl.armor >= 100) {
eActivator.gflags &= ~GF_USE_RELEASED;
sound(this, CHAN_VOICE, m_strSndDone, 1.0, ATTN_NORM);
} else {
if (m_eUser == world) {
sound(this, CHAN_ITEM, m_strSndCharging, 1.0, ATTN_NORM);
}
eActivator.armor = bound(0, eActivator.armor += 1, 100);
pl.armor = bound(0, pl.armor += 1, 100);
}
m_eUser = eActivator;

View file

@ -27,7 +27,6 @@
#define CLASSEXPORT(classname,classa) void classname(void) { spawnfunc_##classa(); }
var int autocvar_mp_flashlight = TRUE;
var int g_hlbsp_materials = FALSE;
void FX_Impact(int, vector, vector);
void FX_Explosion(vector);
@ -55,7 +54,6 @@ entity g_eAttacker;
.int iBleeds;
.entity eUser;
.float material;
.float armor;
.float deaths;
.float fStepTime;

View file

@ -150,10 +150,8 @@ void initents(void)
}
}
fclose(fileMaterial);
g_hlbsp_materials = TRUE;
} else {
print("Failed to load sound/materials.txt!\n");
g_hlbsp_materials = FALSE;
}
}

View file

@ -42,10 +42,6 @@ Footsteps_HLBSP(entity target)
string mat_name = "";
string tex_name = "";
if (!g_hlbsp_materials) {
return;
}
traceline(target.origin + target.view_ofs, target.origin + [0,0,-48], FALSE, target);
tex_name = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos));

View file

@ -18,6 +18,8 @@
void
Damage_Apply(entity t, entity c, float dmg, int w, int type)
{
base_player tp = (base_player)t;
CGameRules rules = (CGameRules)g_grMode;
if (t.flags & FL_GODMODE) {
return;
@ -30,20 +32,20 @@ Damage_Apply(entity t, entity c, float dmg, int w, int type)
/* skip armor */
if not (type & DMG_SKIP_ARMOR)
if (t.armor && dmg > 0) {
if (tp.armor && dmg > 0) {
float flArmor;
float flNewDamage;
flNewDamage = dmg * 0.2;
flArmor = (dmg - flNewDamage) * 0.5;
if (flArmor > t.armor) {
flArmor = t.armor;
if (flArmor > tp.armor) {
flArmor = tp.armor;
flArmor *= (1/0.5);
flNewDamage = dmg - flArmor;
t.armor = 0;
tp.armor = 0;
} else {
t.armor -= flArmor;
tp.armor -= flArmor;
}
dmg = flNewDamage;
}

View file

@ -39,14 +39,16 @@ void item_battery::touch(void)
if (other.classname != "player") {
return;
}
base_player pl = (base_player)other;
if (other.armor >= 100) {
if (pl.armor >= 100) {
return;
}
/* Move this somewhere else? */
other.armor += Skill_GetValue("battery");
if (other.armor > 100) {
other.armor = 100;
pl.armor += Skill_GetValue("battery");
if (pl.armor > 100) {
pl.armor = 100;
}
Logging_Pickup(other, this, __NULL__);

File diff suppressed because it is too large Load diff

View file

@ -59,8 +59,8 @@ class base_player
int old_flags;
int old_activeweapon;
int old_items;
int old_health;
int old_armor;
float old_health;
float old_armor;
int old_movetype;
float old_viewofs;
int old_baseframe;

View file

@ -31,6 +31,7 @@ Tripmine Weapon
#ifdef SERVER
class monster_tripmine:CBaseMonster
{
float armor;
void(void) monster_tripmine;
virtual float(entity, float) SendEntity;
@ -43,15 +44,15 @@ float
monster_tripmine::SendEntity(entity pvsent, float flags)
{
WriteByte(MSG_ENTITY, ENT_TRIPMINE);
WriteCoord(MSG_ENTITY, self.origin[0]);
WriteCoord(MSG_ENTITY, self.origin[1]);
WriteCoord(MSG_ENTITY, self.origin[2]);
WriteCoord(MSG_ENTITY, self.angles[0]);
WriteCoord(MSG_ENTITY, self.angles[1]);
WriteCoord(MSG_ENTITY, self.angles[2]);
WriteFloat(MSG_ENTITY, self.armor);
WriteByte(MSG_ENTITY, self.health);
WriteShort(MSG_ENTITY, self.modelindex);
WriteCoord(MSG_ENTITY, origin[0]);
WriteCoord(MSG_ENTITY, origin[1]);
WriteCoord(MSG_ENTITY, origin[2]);
WriteCoord(MSG_ENTITY, angles[0]);
WriteCoord(MSG_ENTITY, angles[1]);
WriteCoord(MSG_ENTITY, angles[2]);
WriteFloat(MSG_ENTITY, armor);
WriteByte(MSG_ENTITY, health);
WriteShort(MSG_ENTITY, modelindex);
return TRUE;
}