Some fixes

This commit is contained in:
Aaron Dean 2023-09-06 13:53:31 -04:00
parent 8906c1a7e8
commit 94d0bef2ce
7 changed files with 129 additions and 122 deletions

View file

@ -28,7 +28,7 @@
edict_t *SelectTeamplaySpawnPoint (edict_t *);
bool FallingDamageAmnesty (edict_t * targ);
char * TeamName (int team);
const char * TeamName (int team);
void UpdateJoinMenu( void );
void OpenJoinMenu (edict_t *);
void OpenWeaponMenu (edict_t *);

View file

@ -585,7 +585,7 @@ void Cmd_Give_f(edict_t *ent)
ent->client->pers.inventory[i] = (it->flags & IF_KEY) ? 8 : 1;
}
G_CheckPowerArmor(ent);
//G_CheckPowerArmor(ent);
ent->client->pers.power_cubes = 0xFF;
return;
}

View file

@ -152,93 +152,95 @@ dflags these flags are used to control how T_Damage works
DAMAGE_NO_PROTECTION kills godmode, armor, everything
============
*/
static int CheckPowerArmor(edict_t *ent, const vec3_t &point, const vec3_t &normal, int damage, damageflags_t dflags)
{
gclient_t *client;
int save;
item_id_t power_armor_type;
int damagePerCell;
int pa_te_type;
int *power;
int power_used;
if (ent->health <= 0)
return 0;
// Action: No need for this
// static int CheckPowerArmor(edict_t *ent, const vec3_t &point, const vec3_t &normal, int damage, damageflags_t dflags)
// {
// gclient_t *client;
// int save;
// item_id_t power_armor_type;
// int damagePerCell;
// int pa_te_type;
// int *power;
// int power_used;
if (!damage)
return 0;
// if (ent->health <= 0)
// return 0;
client = ent->client;
// if (!damage)
// return 0;
if (dflags & (DAMAGE_NO_ARMOR | DAMAGE_NO_POWER_ARMOR)) // PGM
return 0;
// client = ent->client;
if (client)
{
power_armor_type = PowerArmorType(ent);
power = &client->pers.inventory[IT_AMMO_CELLS];
}
else if (ent->svflags & SVF_MONSTER)
{
power_armor_type = ent->monsterinfo.power_armor_type;
power = &ent->monsterinfo.power_armor_power;
}
else
return 0;
// if (dflags & (DAMAGE_NO_ARMOR | DAMAGE_NO_POWER_ARMOR)) // PGM
// return 0;
if (power_armor_type == IT_NULL)
return 0;
if (!*power)
return 0;
// if (client)
// {
// power_armor_type = PowerArmorType(ent);
// power = &client->pers.inventory[IT_AMMO_CELLS];
// }
// else if (ent->svflags & SVF_MONSTER)
// {
// power_armor_type = ent->monsterinfo.power_armor_type;
// power = &ent->monsterinfo.power_armor_power;
// }
// else
// return 0;
// Paril: fix small amounts of damage not
// being absorbed
damage = max(1, damage);
// if (power_armor_type == IT_NULL)
// return 0;
// if (!*power)
// return 0;
save = *power * damagePerCell;
// // Paril: fix small amounts of damage not
// // being absorbed
// damage = max(1, damage);
if (!save)
return 0;
// save = *power * damagePerCell;
// [Paril-KEX] energy damage should do more to power armor, not ETF Rifle shots.
if (dflags & DAMAGE_ENERGY)
save = max(1, save / 2);
// if (!save)
// return 0;
if (save > damage)
save = damage;
// // [Paril-KEX] energy damage should do more to power armor, not ETF Rifle shots.
// if (dflags & DAMAGE_ENERGY)
// save = max(1, save / 2);
// [Paril-KEX] energy damage should do more to power armor, not ETF Rifle shots.
if (dflags & DAMAGE_ENERGY)
power_used = (save / damagePerCell) * 2;
else
power_used = save / damagePerCell;
// if (save > damage)
// save = damage;
power_used = max(1, power_used);
// // [Paril-KEX] energy damage should do more to power armor, not ETF Rifle shots.
// // if (dflags & DAMAGE_ENERGY)
// // power_used = (save / damagePerCell) * 2;
// // else
// // power_used = save / damagePerCell;
SpawnDamage(pa_te_type, point, normal, save);
ent->powerarmor_time = level.time + 200_ms;
// power_used = max(1, power_used);
// Paril: adjustment so that power armor
// always uses damagePerCell even if it does
// only a single point of damage
//*power = max(0, *power - max(damagePerCell, power_used));
// SpawnDamage(pa_te_type, point, normal, save);
// ent->powerarmor_time = level.time + 200_ms;
// // check power armor turn-off states
// if (ent->client)
// G_CheckPowerArmor(ent);
// else if (!*power)
// {
// gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/mon_power2.wav"), 1.f, ATTN_NORM, 0.f);
// // Paril: adjustment so that power armor
// // always uses damagePerCell even if it does
// // only a single point of damage
// //*power = max(0, *power - max(damagePerCell, power_used));
// gi.WriteByte(svc_temp_entity);
// gi.WriteByte(TE_POWER_SPLASH);
// gi.WriteEntity(ent);
// gi.WriteByte((power_armor_type == IT_ITEM_POWER_SCREEN) ? 1 : 0);
// gi.multicast(ent->s.origin, MULTICAST_PHS, false);
// }
// // // check power armor turn-off states
// // if (ent->client)
// // G_CheckPowerArmor(ent);
// // else if (!*power)
// // {
// // gi.sound(ent, CHAN_AUTO, gi.soundindex("misc/mon_power2.wav"), 1.f, ATTN_NORM, 0.f);
return save;
}
// // gi.WriteByte(svc_temp_entity);
// // gi.WriteByte(TE_POWER_SPLASH);
// // gi.WriteEntity(ent);
// // gi.WriteByte((power_armor_type == IT_ITEM_POWER_SCREEN) ? 1 : 0);
// // gi.multicast(ent->s.origin, MULTICAST_PHS, false);
// // }
// return save;
// }
static int CheckArmor(edict_t *ent, const vec3_t &point, const vec3_t &normal, int damage, int te_sparks,
damageflags_t dflags)

View file

@ -332,7 +332,7 @@ inline bool G_AddAmmoAndCap(edict_t *other, item_id_t item, int32_t max, int32_t
if (other->client->pers.inventory[item] > max)
other->client->pers.inventory[item] = max;
G_CheckPowerArmor(other);
//G_CheckPowerArmor(other);
return true;
}
@ -596,7 +596,7 @@ void Drop_Ammo(edict_t *ent, gitem_t *item)
}
ent->client->pers.inventory[index] -= dropped->count;
G_CheckPowerArmor(ent);
//G_CheckPowerArmor(ent);
}
//======================================================================

View file

@ -2158,7 +2158,7 @@ gitem_t *GetItemByIndex(item_id_t index);
gitem_t *GetItemByAmmo(ammo_t ammo);
gitem_t *GetItemByPowerup(powerup_t powerup);
bool Add_Ammo(edict_t *ent, gitem_t *item, int count);
void G_CheckPowerArmor(edict_t *ent);
//void G_CheckPowerArmor(edict_t *ent);
void Touch_Item(edict_t *ent, edict_t *other, const trace_t &tr, bool other_touching_self);
void droptofloor(edict_t *ent);
void P_ToggleFlashlight(edict_t *ent, bool state);

View file

@ -696,12 +696,12 @@ void G_SetCoopStats(edict_t *ent)
ent->client->ps.stats[STAT_COOP_RESPAWN] = 0;
}
struct powerup_info_t
{
item_id_t item;
gtime_t gclient_t::*time_ptr = nullptr;
int32_t gclient_t::*count_ptr = nullptr;
} powerup_table[] = {
// struct powerup_info_t
// {
// item_id_t item;
// gtime_t gclient_t::*time_ptr = nullptr;
// int32_t gclient_t::*count_ptr = nullptr;
// } powerup_table[] = {
// { IT_ITEM_QUAD, &gclient_t::quad_time },
// { IT_ITEM_QUADFIRE, &gclient_t::quadfire_time },
// { IT_ITEM_DOUBLE, &gclient_t::double_time },
@ -711,7 +711,7 @@ struct powerup_info_t
// { IT_ITEM_REBREATHER, &gclient_t::breather_time },
// { IT_ITEM_IR_GOGGLES, &gclient_t::ir_time },
// { IT_ITEM_SILENCER, nullptr, &gclient_t::silencer_shots }
};
//};
/*
===============
@ -869,51 +869,53 @@ void G_SetStats(edict_t *ent)
ent->client->ps.stats[STAT_TIMER] = ceil(ent->client->owned_sphere->wait - level.time.seconds());
}
else
{
powerup_info_t *best_powerup = nullptr;
for (auto &powerup : powerup_table)
{
auto *powerup_time = powerup.time_ptr ? &(ent->client->*powerup.time_ptr) : nullptr;
auto *powerup_count = powerup.count_ptr ? &(ent->client->*powerup.count_ptr) : nullptr;
// Action: No need for powerup_info_t anymore
// else
// {
// powerup_info_t *best_powerup = nullptr;
if (powerup_time && *powerup_time <= level.time)
continue;
else if (powerup_count && !*powerup_count)
continue;
// for (auto &powerup : powerup_table)
// {
// auto *powerup_time = powerup.time_ptr ? &(ent->client->*powerup.time_ptr) : nullptr;
// auto *powerup_count = powerup.count_ptr ? &(ent->client->*powerup.count_ptr) : nullptr;
if (!best_powerup)
{
best_powerup = &powerup;
continue;
}
// if (powerup_time && *powerup_time <= level.time)
// continue;
// else if (powerup_count && !*powerup_count)
// continue;
// if (!best_powerup)
// {
// best_powerup = &powerup;
// continue;
// }
if (powerup_time && *powerup_time < ent->client->*best_powerup->time_ptr)
{
best_powerup = &powerup;
continue;
}
else if (powerup_count && !best_powerup->time_ptr)
{
best_powerup = &powerup;
continue;
}
}
// if (powerup_time && *powerup_time < ent->client->*best_powerup->time_ptr)
// {
// best_powerup = &powerup;
// continue;
// }
// else if (powerup_count && !best_powerup->time_ptr)
// {
// best_powerup = &powerup;
// continue;
// }
// }
if (best_powerup)
{
int16_t value;
// if (best_powerup)
// {
// int16_t value;
if (best_powerup->count_ptr)
value = (ent->client->*best_powerup->count_ptr);
else
value = ceil((ent->client->*best_powerup->time_ptr - level.time).seconds());
// if (best_powerup->count_ptr)
// value = (ent->client->*best_powerup->count_ptr);
// else
// value = ceil((ent->client->*best_powerup->time_ptr - level.time).seconds());
ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex(GetItemByIndex(best_powerup->item)->icon);
ent->client->ps.stats[STAT_TIMER] = value;
}
}
// ent->client->ps.stats[STAT_TIMER_ICON] = gi.imageindex(GetItemByIndex(best_powerup->item)->icon);
// ent->client->ps.stats[STAT_TIMER] = value;
// }
// }
// PGM
//

View file

@ -437,8 +437,8 @@ void G_RemoveAmmo(edict_t *ent, int32_t quantity)
if (!pre_warning && post_warning)
gi.local_sound(ent, CHAN_AUTO, gi.soundindex("weapons/lowammo.wav"), 1, ATTN_NORM, 0);
if (ent->client->pers.weapon->ammo == IT_AMMO_CELLS)
G_CheckPowerArmor(ent);
// if (ent->client->pers.weapon->ammo == IT_AMMO_CELLS)
// G_CheckPowerArmor(ent);
}
void G_RemoveAmmo(edict_t *ent)
@ -2554,7 +2554,10 @@ void M4_Fire(edict_t* ent)
P_AddWeaponKick(ent, kick_origin, kick_angles);
kick_origin[0] = crandom() * 0.35;
kick_angles[0] = ent->client->machinegun_shots * -.7;
VectorAdd(ent->client->v_angle, kick_angles, angles);
AngleVectors(angles, forward, right, NULL);
VectorSet(offset, 0, 8, ent->viewheight - height);
P_ProjectSource(ent, ent->client->v_angle, { 0, 7, -8 }, start, dir);
P_AddWeaponKick(ent, kick_origin, kick_angles);
// get start / end positions