Skip to content

Commit

Permalink
Update 1 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
id-mikerubits committed Oct 3, 2023
1 parent 60f2956 commit 8dc1fc9
Show file tree
Hide file tree
Showing 67 changed files with 1,802 additions and 1,475 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,10 @@ Called by the bot subsystem to use an item.

Fetch an item ID by a classname; for the bot subsystem.

### Edict_ForceLookAtPoint

Force the player to look at the given point - used for the nav editor.

### Entity_IsVisibleToPlayer

This function is for item instancing; the rerelease of Quake II supports instanced items, which will display only for the players who haven't picked it up yet. For online players, this simply removes the item if you've gotten it, but for split screen players it will show a ghost where the entity was on players that have already picked it up.
Expand Down
3 changes: 2 additions & 1 deletion rerelease/bg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ enum player_stat_t
STAT_SELECTED_ITEM_NAME,
// [Paril-KEX]
STAT_HEALTH_BARS, // two health bar values; 7 bits for value, 1 bit for active
// if active,
// [Paril-KEX]
STAT_ACTIVE_WEAPON,

// don't use; just for verification
STAT_LAST
Expand Down
37 changes: 37 additions & 0 deletions rerelease/bots/bot_exports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,40 @@ int32_t Bot_GetItemID( const char * classname ) {

return Item_Invalid;
}

/*
================
Edict_ForceLookAtPoint
================
*/
void Edict_ForceLookAtPoint( edict_t * edict, gvec3_cref_t point ) {
vec3_t viewOrigin = edict->s.origin;
if ( edict->client != nullptr ) {
viewOrigin += edict->client->ps.viewoffset;
}

const vec3_t ideal = ( point - viewOrigin ).normalized();

vec3_t viewAngles = vectoangles( ideal );
if ( viewAngles.x < -180.0f ) {
viewAngles.x = anglemod( viewAngles.x + 360.0f );
}

if ( edict->client != nullptr ) {
edict->client->ps.pmove.delta_angles = ( viewAngles - edict->client->resp.cmd_angles );
edict->client->ps.viewangles = {};
edict->client->v_angle = {};
edict->s.angles = {};
}
}

/*
================
Bot_PickedUpItem
Check if the given bot has picked up the given item or not.
================
*/
bool Bot_PickedUpItem( edict_t * bot, edict_t * item ) {
return item->item_picked_up_by[ ( bot->s.number - 1 ) ];
}
4 changes: 3 additions & 1 deletion rerelease/bots/bot_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
void Bot_SetWeapon( edict_t * bot, const int weaponIndex, const bool instantSwitch );
void Bot_TriggerEdict( edict_t * bot, edict_t * edict );
int32_t Bot_GetItemID( const char * classname );
void Bot_UseItem( edict_t * bot, const int32_t itemID );
void Bot_UseItem( edict_t * bot, const int32_t itemID );
void Edict_ForceLookAtPoint( edict_t * edict, gvec3_cref_t point );
bool Bot_PickedUpItem( edict_t * bot, edict_t * item );
5 changes: 1 addition & 4 deletions rerelease/bots/bot_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,6 @@ void Item_UpdateState( edict_t * item ) {
}
}

// track who has picked us up so far...
item->sv.pickedup_list = item->item_picked_up_by;

const item_id_t itemID = item->item->id;
if ( itemID == IT_FLAG1 || itemID == IT_FLAG2 ) {
item->sv.ent_flags |= SVFL_IS_OBJECTIVE;
Expand Down Expand Up @@ -529,4 +526,4 @@ const edict_t * FindActorUnderCrosshair( const edict_t * player ) {
}

return traceEnt;
}
}
3 changes: 1 addition & 2 deletions rerelease/cg_screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ static void CG_ExecuteLayoutString (const char *s, vrect_t hud_vrect, vrect_t hu
width = 3;
value = ps->stats[STAT_AMMO];

int32_t min_ammo = cgi.CL_GetWarnAmmoCount(ps->stats[STAT_ACTIVE_WHEEL_WEAPON]);
int32_t min_ammo = cgi.CL_GetWarnAmmoCount(ps->stats[STAT_ACTIVE_WEAPON]);

if (!min_ammo)
min_ammo = 5; // back compat
Expand Down Expand Up @@ -1702,7 +1702,6 @@ static void CG_DrawInventory(const player_state_t *ps, const std::array<int16_t,
else
{
const char *string = G_Fmt("{}", inventory[item]).data();
vec2_t strSz = cgi.SCR_MeasureFontString(string, scale);
cgi.SCR_DrawFontString(string, x + (216 * scale) - (16 * scale), y - (font_y_offset * scale), scale, (item == selected) ? alt_color : rgba_white, true, text_align_t::RIGHT);

string = cgi.Localize(cgi.get_configstring(CS_ITEMS + item), nullptr, 0);
Expand Down
32 changes: 31 additions & 1 deletion rerelease/ctf/g_ctf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ THINK(CTFDropFlagThink) (edict_t *ent) -> void
gi.LocBroadcast_Print(PRINT_HIGH, "$g_flag_returned",
CTFTeamName(CTF_TEAM2));
}

gi.sound(ent, CHAN_RELIABLE | CHAN_NO_PHS_ADD | CHAN_AUX, gi.soundindex("ctf/flagret.wav"), 1, ATTN_NONE, 0);
}

// Called from PlayerDie, to drop the flag from a dying player
Expand Down Expand Up @@ -1087,6 +1089,20 @@ void SetCTFStats(edict_t *ent)
p1 = imageindex_i_ctf1t;
break;
}

// [Paril-KEX] make sure there is a dropped version on the map somewhere
if (p1 == imageindex_i_ctf1d)
{
e = G_FindByString<&edict_t::classname>(e, "item_flag_team1");

if (e == nullptr)
{
CTFResetFlag(CTF_TEAM1);
gi.LocBroadcast_Print(PRINT_HIGH, "$g_flag_returned",
CTFTeamName(CTF_TEAM1));
gi.sound(ent, CHAN_RELIABLE | CHAN_NO_PHS_ADD | CHAN_AUX, gi.soundindex("ctf/flagret.wav"), 1, ATTN_NONE, 0);
}
}
}
else if (e->spawnflags.has(SPAWNFLAG_ITEM_DROPPED))
p1 = imageindex_i_ctf1d; // must be dropped
Expand All @@ -1108,6 +1124,20 @@ void SetCTFStats(edict_t *ent)
p2 = imageindex_i_ctf2t;
break;
}

// [Paril-KEX] make sure there is a dropped version on the map somewhere
if (p2 == imageindex_i_ctf2d)
{
e = G_FindByString<&edict_t::classname>(e, "item_flag_team2");

if (e == nullptr)
{
CTFResetFlag(CTF_TEAM2);
gi.LocBroadcast_Print(PRINT_HIGH, "$g_flag_returned",
CTFTeamName(CTF_TEAM2));
gi.sound(ent, CHAN_RELIABLE | CHAN_NO_PHS_ADD | CHAN_AUX, gi.soundindex("ctf/flagret.wav"), 1, ATTN_NONE, 0);
}
}
}
else if (e->spawnflags.has(SPAWNFLAG_ITEM_DROPPED))
p2 = imageindex_i_ctf2d; // must be dropped
Expand Down Expand Up @@ -2960,7 +2990,7 @@ bool CTFStartClient(edict_t *ent)

void CTFObserver(edict_t *ent)
{
if (!G_TeamplayEnabled())
if (!G_TeamplayEnabled() || g_teamplay_force_join->integer)
return;

// start as 'observer'
Expand Down
93 changes: 66 additions & 27 deletions rerelease/g_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ void ai_stand(edict_t *self, float dist)
if (self->monsterinfo.aiflags & AI_STAND_GROUND)
{
// [Paril-KEX] check if we've been pushed out of our point_combat
if (self->movetarget)
if (!(self->monsterinfo.aiflags & AI_TEMP_STAND_GROUND) &&
self->movetarget && self->movetarget->classname && !strcmp(self->movetarget->classname, "point_combat"))
{
if (!boxes_intersect(self->absmin, self->absmax, self->movetarget->absmin, self->movetarget->absmax))
{
Expand All @@ -105,7 +106,7 @@ void ai_stand(edict_t *self, float dist)
}
}

if (self->enemy)
if (self->enemy && !(self->enemy->classname && !strcmp(self->enemy->classname, "player_noise")))
{
v = self->enemy->s.origin - self->s.origin;
self->ideal_yaw = vectoyaw(v);
Expand Down Expand Up @@ -453,6 +454,12 @@ bool infront(edict_t *self, edict_t *other)
vec = other->s.origin - self->s.origin;
vec.normalize();
dot = vec.dot(forward);

// [Paril-KEX] if we're an ambush monster, reduce our cone of
// vision to not ruin surprises, unless we already had an enemy.
if (self->spawnflags.has(SPAWNFLAG_MONSTER_AMBUSH) && !self->monsterinfo.trail_time && !self->enemy)
return dot > 0.15f;

return dot > -0.30f;
}

Expand Down Expand Up @@ -730,7 +737,31 @@ bool FindTarget(edict_t *self)
return false;

if (client == self->enemy)
return true; // JDC false;
{
bool skip_found = true;

// [Paril-KEX] slight special behavior if we are currently going to a sound
// and we hear a new one; because player noises are re-used, this can leave
// us with the "same" enemy even though it's a different noise.
if (heardit && (self->monsterinfo.aiflags & AI_SOUND_TARGET))
{
vec3_t temp = client->s.origin - self->s.origin;
self->ideal_yaw = vectoyaw(temp);

if (!FacingIdeal(self))
skip_found = false;
else if (!SV_CloseEnough(self, client, 8.f))
skip_found = false;

if (!skip_found && (self->monsterinfo.aiflags & AI_TEMP_STAND_GROUND))
{
self->monsterinfo.aiflags &= ~(AI_STAND_GROUND | AI_TEMP_STAND_GROUND);
}
}

if (skip_found)
return true; // JDC false;
}

// ROGUE - hintpath coop fix
if ((self->monsterinfo.aiflags & AI_HINT_PATH) && coop->integer)
Expand Down Expand Up @@ -873,7 +904,8 @@ bool FacingIdeal(edict_t *self)

//=============================================================================

MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
// [Paril-KEX] split this out so we can use it for the other bosses
bool M_CheckAttack_Base(edict_t *self, float stand_ground_chance, float melee_chance, float near_chance, float mid_chance, float far_chance, float strafe_scalar)
{
vec3_t spot1, spot2;
float chance;
Expand Down Expand Up @@ -903,7 +935,7 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
spot2[2] += self->enemy->viewheight;

tr = gi.traceline(spot1, spot2, self,
MASK_SOLID | CONTENTS_MONSTER | CONTENTS_PLAYER | CONTENTS_SLIME | CONTENTS_LAVA);
MASK_SOLID | CONTENTS_MONSTER | CONTENTS_PLAYER | CONTENTS_SLIME | CONTENTS_LAVA);
}
else
{
Expand Down Expand Up @@ -938,7 +970,7 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
{
// make sure we're not going to shoot a monster
tr = gi.traceline(spot1, self->monsterinfo.blind_fire_target, self,
CONTENTS_MONSTER);
CONTENTS_MONSTER);
if (tr.allsolid || tr.startsolid || ((tr.fraction < 1.0f) && (tr.ent != self->enemy)))
return false;

Expand Down Expand Up @@ -982,28 +1014,29 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
if (level.time < self->monsterinfo.attack_finished)
return false;

if (enemy_range > RANGE_MID)
return false;

if (self->monsterinfo.aiflags & AI_STAND_GROUND)
{
chance = 0.7f;
chance = stand_ground_chance;
}
else if (enemy_range <= RANGE_MELEE)
{
chance = 0.4f;
chance = melee_chance;
}
else if (enemy_range <= RANGE_NEAR)
{
chance = 0.25f;
chance = near_chance;
}
else if (enemy_range <= RANGE_MID)
{
chance = mid_chance;
}
else
{
chance = 0.06f;
chance = far_chance;
}

// PGM - go ahead and shoot every time if it's a info_notnull
if ((frandom() < chance) || (!self->enemy->client && self->enemy->solid == SOLID_NOT))
if ((!self->enemy->client && self->enemy->solid == SOLID_NOT) || (frandom() < chance))
{
self->monsterinfo.attack_state = AS_MISSILE;
self->monsterinfo.attack_finished = level.time;
Expand All @@ -1018,6 +1051,7 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
{
// originally, just 0.3
float strafe_chance;

if (!(strcmp(self->classname, "monster_daedalus")))
strafe_chance = 0.8f;
else
Expand All @@ -1026,16 +1060,21 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
// if enemy is tesla, never strafe
if ((self->enemy) && (self->enemy->classname) && (!strcmp(self->enemy->classname, "tesla_mine")))
strafe_chance = 0;
else
strafe_chance *= strafe_scalar;

monster_attack_state_t new_state = AS_STRAIGHT;
if (strafe_chance)
{
monster_attack_state_t new_state = AS_STRAIGHT;

if (frandom() < strafe_chance)
new_state = AS_SLIDING;
if (frandom() < strafe_chance)
new_state = AS_SLIDING;

if (new_state != self->monsterinfo.attack_state)
{
self->monsterinfo.strafe_check_time = level.time + random_time(1_sec, 3_sec);
self->monsterinfo.attack_state = new_state;
if (new_state != self->monsterinfo.attack_state)
{
self->monsterinfo.strafe_check_time = level.time + random_time(1_sec, 3_sec);
self->monsterinfo.attack_state = new_state;
}
}
}
}
Expand All @@ -1051,6 +1090,11 @@ MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
return false;
}

MONSTERINFO_CHECKATTACK(M_CheckAttack) (edict_t *self) -> bool
{
return M_CheckAttack_Base(self, 0.7f, 0.4f, 0.25f, 0.06f, 0.f, 1.0f);
}

/*
=============
ai_run_melee
Expand Down Expand Up @@ -1222,12 +1266,7 @@ bool ai_checkattack(edict_t *self, float dist)
}
else
{
if (self->monsterinfo.aiflags & AI_BRUTAL)
{
if (self->enemy->health <= self->enemy->gib_health)
hesDeadJim = true;
}
else
if (!(self->monsterinfo.aiflags & AI_BRUTAL))
{
if (self->enemy->health <= 0)
hesDeadJim = true;
Expand Down
Loading

0 comments on commit 8dc1fc9

Please sign in to comment.