Add VGUI_Active() which returns whether or not we're drawing VGUI elements,

add SNDFL_ALERTS to sound shaders, which will alert enemy AI of suspicious
behaviour, fix a health-setting bug in NSSurfacePropEntity and remove
playerslot check in item_pickup from base/
This commit is contained in:
Marco Cawthorne 2022-01-28 16:02:00 -08:00
parent abdce0b61d
commit 578da4a779
Signed by: eukara
GPG Key ID: C196CD8BA993248A
10 changed files with 68 additions and 17 deletions

View File

@ -70,7 +70,7 @@ item_pickup::Respawn(void)
think = __NULL__; think = __NULL__;
nextthink = -1; nextthink = -1;
if (!m_iWasDropped && cvar("sv_playerslots") > 1) { if (!m_iWasDropped) {
m_iClip = -1; m_iClip = -1;
} }

View File

@ -492,7 +492,10 @@ CSQC_InputEvent(float fEventType, float fKey, float fCharacter, float fDeviceID)
setcursormode(FALSE, "gfx/cursor", [0,0,0], 1.0f); setcursormode(FALSE, "gfx/cursor", [0,0,0], 1.0f);
} }
return (0); if (VGUI_Active())
return (1);
else
return (0);
} }
/* /*
@ -508,7 +511,7 @@ CSQC_Input_Frame(void)
CSQC_UpdateSeat(); CSQC_UpdateSeat();
/* If we are inside a VGUI, don't let the client do stuff outside */ /* If we are inside a VGUI, don't let the client do stuff outside */
if (g_vguiWidgetCount > 0) { if (VGUI_Active()) {
input_impulse = 0; input_impulse = 0;
input_buttons = 0; input_buttons = 0;
return; return;

View File

@ -316,18 +316,15 @@ func_breakable::Respawn(void)
} }
/* initially set the health to that of the ent-data */ /* initially set the health to that of the ent-data */
health = GetSpawnHealth(); float sh = GetSpawnHealth();
if (HasPropData() == TRUE) { if (HasPropData() == TRUE && sh == 0) {
/* assign propdata health */ /* assign propdata health */
health = GetPropData(PROPINFO_HEALTH); health = GetPropData(PROPINFO_HEALTH);
/* didn't supply valid health */
if (health <= 0)
health = GetSpawnHealth();
m_flExplodeMag = GetPropData(PROPINFO_EXPLOSIVE_DMG); m_flExplodeMag = GetPropData(PROPINFO_EXPLOSIVE_DMG);
m_flExplodeRad = GetPropData(PROPINFO_EXPLOSIVE_RADIUS); m_flExplodeRad = GetPropData(PROPINFO_EXPLOSIVE_RADIUS);
} else {
health = sh;
} }
/* unassigned health isn't valid */ /* unassigned health isn't valid */

View File

@ -283,4 +283,6 @@ class NSMonster:NSSurfacePropEntity
#ifdef CLIENT #ifdef CLIENT
string Sentences_GetSamples(string); string Sentences_GetSamples(string);
string Sentences_ProcessSample(string); string Sentences_ProcessSample(string);
#else
void NSMonster_AlertEnemyAlliance(vector pos, float radius, int alliance);
#endif #endif

View File

@ -993,4 +993,36 @@ NSMonster_ReadEntity(float new)
} }
me.ReceiveEntity(new, readfloat()); me.ReceiveEntity(new, readfloat());
} }
#else
void
NSMonster_AlertEnemyAlliance(vector pos, float radius, int alliance)
{
for (entity w = world; (w = findfloat(w, ::takedamage, DAMAGE_YES));) {
/* out of radius */
if (vlen(pos - w.origin) > radius)
continue;
/* only target monsters */
if (!(w.flags & FL_MONSTER))
continue;
NSMonster f = (NSMonster)w;
/* they already got a target of some kind */
if (f.m_eEnemy)
continue;
/* if they're our friend... ignore*/
if (f.IsFriend(alliance))
continue;
/* if the monster is dead... ignore */
if (f.health <= 0)
continue;
/* we've heard a noise. investigate the location */
f.ClearRoute();
f.NewRoute(pos);
f.m_flSequenceSpeed = 140;
}
}
#endif #endif

View File

@ -95,7 +95,7 @@ NSSurfacePropEntity::Respawn(void)
NSRenderableEntity::Respawn(); NSRenderableEntity::Respawn();
/* only use spawndata's health if we aren't overriding it */ /* only use spawndata's health if we aren't overriding it */
if (HasPropData() == TRUE && sh == -1) { if (HasPropData() == TRUE && sh <= 0) {
health = (float)GetPropData(PROPINFO_HEALTH); health = (float)GetPropData(PROPINFO_HEALTH);
} else { } else {
health = sh; health = sh;
@ -182,8 +182,7 @@ NSSurfacePropEntity::SpawnKey(string strKey, string strValue)
{ {
switch (strKey) { switch (strKey) {
case "health": case "health":
int h = stoi(strValue); health = stof(strValue);
health = (float)h;
m_oldHealth = health; m_oldHealth = health;
break; break;
case "propdata": case "propdata":
@ -303,7 +302,6 @@ NSSurfacePropEntity::NSSurfacePropEntity(void)
#ifdef SERVER #ifdef SERVER
m_iPropData = -1; m_iPropData = -1;
m_iMaterial = -1; m_iMaterial = -1;
m_oldHealth = health = -1;
super::NSRenderableEntity(); super::NSRenderableEntity();

View File

@ -26,8 +26,9 @@ typedef enumflags
SNDFL_NOREVERB, /* skip reverb */ SNDFL_NOREVERB, /* skip reverb */
SNDFL_OMNI, /* volume on all channels is equal */ SNDFL_OMNI, /* volume on all channels is equal */
SNDFL_PRIVATE, /* only play on target */ SNDFL_PRIVATE, /* only play on target */
SNDFL_STEP, /* volume is calculated from entity speed */ SNDFL_STEP, /* volume is calculated from entity speed */
SNDFL_FOLLOW SNDFL_FOLLOW,
SNDFL_ALERTS /* this sounds alerts AI, takes distance into account */
} soundFlag_t; } soundFlag_t;
typedef struct typedef struct

View File

@ -161,6 +161,10 @@ Sound_ParseField(int i, int a)
case "distshader": case "distshader":
g_sounds[i].distshader = argv(1); g_sounds[i].distshader = argv(1);
break; break;
case "alerts":
dprint("\tSound set to alert enemy AI\n");
g_sounds[i].flags |= SNDFL_ALERTS;
break;
case "sample": case "sample":
if (a == 2) { if (a == 2) {
dprint("\tAdded sample "); dprint("\tAdded sample ");
@ -456,6 +460,9 @@ Sound_Play(entity target, int chan, string shader)
flag |= SOUNDFLAG_UNICAST; flag |= SOUNDFLAG_UNICAST;
msg_entity = target; msg_entity = target;
} }
if (g_sounds[sample].flags & SNDFL_ALERTS) {
NSMonster_AlertEnemyAlliance(target.origin, g_sounds[sample].dist_max, target.m_iAlliance);
}
#endif #endif
#ifdef DEVELOPER #ifdef DEVELOPER

View File

@ -25,6 +25,12 @@ var int g_vguiWidgetCount;
var float UI_MAINALPHA; var float UI_MAINALPHA;
#endif #endif
void
VGUI_Active(void)
{
return (g_vguiWidgetCount > 0) ? TRUE : FALSE;
}
int int
Util_MouseAbove(vector vecMousePos, vector vecPos, vector vecSize) Util_MouseAbove(vector vecMousePos, vector vecPos, vector vecSize)
{ {

View File

@ -7,7 +7,12 @@ if [ ! -f "$SRCPATH"/bin/worldspawn ]; then
fi fi
cd "$SRCPATH"/bin cd "$SRCPATH"/bin
./worldspawn
if [[ -z "${NUCLIDE_GDB}" ]]; then
./worldspawn ../ $*
else
gdb --args ./worldspawn ../ $*
fi