Compare commits

...

3 Commits

10 changed files with 80 additions and 44 deletions

View File

@ -35,6 +35,7 @@ seta net_showUpdates 0 // Enable/disable console prints about entity updates.
// game console variables // game console variables
seta g_gravity 800 // Global gravity setting, in unit per second. seta g_gravity 800 // Global gravity setting, in unit per second.
seta g_mapCycle "mapcycle.txt" // Map cycle file for multiplayer games. seta g_mapCycle "mapcycle.txt" // Map cycle file for multiplayer games.
seta g_developer 0 // Prints game-logic specific debug messages when 1.
// input console variables // input console variables
seta in_zoomSensitivity 1.0 // Mouse sensitivity multiplier for when we're using the +zoomin command. seta in_zoomSensitivity 1.0 // Mouse sensitivity multiplier for when we're using the +zoomin command.
@ -69,6 +70,8 @@ seta xr_roomScale 1.0 // Scales world<>game translation.
seta xr_viewHeight -48.0 // Specifies the head offset when in XR mode. seta xr_viewHeight -48.0 // Specifies the head offset when in XR mode.
seta xr_testInputs 0 // Send faux XR input signals when enabled. seta xr_testInputs 0 // Send faux XR input signals when enabled.
seta s_developer 0 // Prints sound-logic specific debug messages when 1.
// aliases for the older commands (may be removed some day) // aliases for the older commands (may be removed some day)
alias cl_autojump pm_autoJump alias cl_autojump pm_autoJump
alias cl_showfps com_showFPS alias cl_showfps com_showFPS

View File

@ -30,7 +30,8 @@ Shoots model entities from its location.
- "m_iGibs" : Amount of models shot in total. - "m_iGibs" : Amount of models shot in total.
- "m_flDelay" : Delay before being able to be fired again. - "m_flDelay" : Delay before being able to be fired again.
- "m_flVelocity" : Speed of the models in units per second. - "m_flVelocity" : Speed of the models in units per second.
- "m_flVariance" : Delay between shots. - "delay" : Delay between shots.
- "m_flVariance" : Variance in shot trajectory.
- "m_flGibLife" : Life of the individual model piece. - "m_flGibLife" : Life of the individual model piece.
- "scale" : Scale modifier of the model pieces. - "scale" : Scale modifier of the model pieces.
@ -177,7 +178,7 @@ env_shooter::SpawnKey(string strKey, string strValue)
case "m_iGibs": case "m_iGibs":
m_iGibs = stoi(strValue); m_iGibs = stoi(strValue);
break; break;
case "m_flDelay": case "delay":
m_flDelay = stof(strValue); m_flDelay = stof(strValue);
break; break;
case "m_flVelocity": case "m_flVelocity":
@ -238,19 +239,19 @@ env_shooter::ShootGib(void)
switch (m_flShootSounds) { switch (m_flShootSounds) {
case 0: /* glass */ case 0: /* glass */
StartSoundDef("func_breakable.impact_glass", CHAN_VOICE, false); StartSoundDef("sfx_impact.glass", CHAN_VOICE, false);
break; break;
case 1: /* wood */ case 1: /* wood */
StartSoundDef("func_breakable.impact_wood", CHAN_VOICE, false); StartSoundDef("sfx_impact.wood", CHAN_VOICE, false);
break; break;
case 2: /* metal */ case 2: /* metal */
StartSoundDef("func_breakable.impact_metal", CHAN_VOICE, false); StartSoundDef("sfx_impact.metal", CHAN_VOICE, false);
break; break;
case 3: /* flesh */ case 3: /* flesh */
StartSoundDef("func_breakable.impact_flesh", CHAN_VOICE, false); StartSoundDef("sfx_impact.flesh", CHAN_VOICE, false);
break; break;
case 4: /* concrete */ case 4: /* concrete */
StartSoundDef("func_breakable.impact_concrete", CHAN_VOICE, false); StartSoundDef("sfx_impact.concrete", CHAN_VOICE, false);
break; break;
case -1: /* none */ case -1: /* none */
default: default:
@ -261,8 +262,11 @@ env_shooter::ShootGib(void)
m_flGibLife = 1.0f; m_flGibLife = 1.0f;
makevectors(GetAngles()); makevectors(GetAngles());
vecThrowVel = v_forward * m_flVelocity; vecThrowVel = v_forward;
vecThrowVel += [0.0f, 0.0f, 32.0f + (random() * 32.0f)]; vecThrowVel += (random(-1,1) * v_right) * m_flVariance;
vecThrowVel += (random(-1,1) * v_up) * m_flVariance;
vecThrowVel *= m_flVelocity;
vecSpinVel[0] = random(-1,1) * 32; vecSpinVel[0] = random(-1,1) * 32;
vecSpinVel[1] = random(-1,1) * 32; vecSpinVel[1] = random(-1,1) * 32;
vecSpinVel[2] = random(-1,1) * 32; vecSpinVel[2] = random(-1,1) * 32;
@ -272,8 +276,14 @@ env_shooter::ShootGib(void)
m_iGibsLeft--; m_iGibsLeft--;
/* keep shooting til we're done */
if (m_iGibsLeft) { if (m_iGibsLeft) {
ScheduleThink(ShootGib, m_flVariance); ScheduleThink(ShootGib, m_flDelay);
} else {
/* no more gibs left, destroy if wanted */
if (HasSpawnFlags(EVSHOOTER_REPEATABLE) == false) {
ScheduleThink(Destroy, m_flDelay);
}
} }
} }
@ -285,10 +295,12 @@ env_shooter::Trigger(entity act, triggermode_t state)
ReleaseThink(); ReleaseThink();
break; break;
case TRIG_ON: case TRIG_ON:
if (spawnflags & EVSHOOTER_REPEATABLE) /* reset gib count if repeatable. */
if (HasSpawnFlags(EVSHOOTER_REPEATABLE) == true) {
m_iGibsLeft = m_iGibs; m_iGibsLeft = m_iGibs;
}
ScheduleThink(ShootGib, m_flVariance); ScheduleThink(ShootGib, m_flDelay);
break; break;
default: default:
if (IsThinking() == false) if (IsThinking() == false)

View File

@ -165,8 +165,7 @@ inet_refreshframe(void)
address = gethostcachestring(srv_fldAdress, i); address = gethostcachestring(srv_fldAdress, i);
/* skip LAN */ if (!address) {
if (!address || Server_IsLan(address)) {
continue; continue;
} }

View File

@ -62,7 +62,8 @@ lan_refreshframe(void)
string ping; string ping;
address = gethostcachestring(srv_fldAdress, i); address = gethostcachestring(srv_fldAdress, i);
if (!address || !Server_IsLan(address)) {
if (!address) {
continue; continue;
} }

View File

@ -14,6 +14,18 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
static bool
Server_IsLan(string address)
{
tokenizebyseparator(address, ".");
if (argv(0) == "192" && argv(1) == "168") {
return (1);
} else {
return (0);
}
}
string string
Master_Resolve(void) Master_Resolve(void)
{ {

View File

@ -949,21 +949,24 @@ bool NSEntity::StartSound( string strSample, float channel, float flags, bool br
return ( false ); return ( false );
if ( broadcast ) { if ( broadcast ) {
sound( this, channel, strSample, 1.0, ATTN_NORM ); sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_FOLLOW );
} else { } else {
#ifdef SERVER #ifdef SERVER
msg_entity = this; msg_entity = this;
sound( this, channel, strSample, 1.0, ATTN_NORM, 0, SOUNDFLAG_UNICAST ); sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_UNICAST | SOUNDFLAG_FOLLOW);
msg_entity = __NULL__; msg_entity = __NULL__;
#else #else
sound( this, channel, strSample, 1.0, ATTN_NORM ); sound( this, channel, strSample, 1.0f, ATTN_NORM, 0, SOUNDFLAG_FOLLOW );
#endif #endif
} }
SndLog( "^2%s::^3StartSound^7: %s (chan: %d bcast: %d) (%v)", classname, strSample, channel, broadcast, origin );
return ( true ); return ( true );
} }
bool NSEntity::StartSoundDef( string strSample, float channel, bool broadcast ) { bool NSEntity::StartSoundDef( string strSample, float channel, bool broadcast ) {
NSLog( "^2%s::^3StartSoundDef^7: %s (chan: %d bcast: %d)", classname, strSample, channel, broadcast ); SndLog( "^2%s::^3StartSoundDef^7: %s (chan: %d bcast: %d)", classname, strSample, channel, broadcast );
Sound_Play( this, channel, strSample ); Sound_Play( this, channel, strSample );
return ( true ); return ( true );
} }

View File

@ -959,23 +959,23 @@ NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData
case 1004: /* plays a sound on CHAN_BODY */ case 1004: /* plays a sound on CHAN_BODY */
#ifdef CLIENT #ifdef CLIENT
if (substring(strData, 0, 1) == "*") if (substring(strData, 0, 1) == "*")
sound(self, CHAN_BODY, substring(strData, 1, -1), 1.0f, ATTN_NORM); StartSound(substring(strData, 1, -1), CHAN_BODY, 0, true);
else else
sound(self, CHAN_BODY, strData, 1.0f, ATTN_NORM); StartSound(strData, CHAN_BODY, 0, true);
#endif #endif
break; break;
case 1008: /* plays a sound on CHAN_VOICE */ case 1008: /* plays a sound on CHAN_VOICE */
#ifdef CLIENT #ifdef CLIENT
if (substring(strData, 0, 1) == "*") if (substring(strData, 0, 1) == "*")
sound(self, CHAN_VOICE, substring(strData, 1, -1), 1.0f, ATTN_NORM); StartSound(substring(strData, 1, -1), CHAN_VOICE, 0, true);
else else
sound(self, CHAN_VOICE, strData, 1.0f, ATTN_NORM); StartSound(strData, CHAN_VOICE, 0, true);
#endif #endif
break; break;
#ifdef CLIENT
case 5004: /* view model sound? */ case 5004: /* view model sound? */
sound(this, CHAN_AUTO, strData, 1.0, ATTN_NORM, 100, SOUNDFLAG_FOLLOW | SOUNDFLAG_NOSPACIALISE); StartSound(strData, CHAN_AUTO, 0, true);
break; break;
#ifdef CLIENT
case 5001: /* muzzle flash on attachment 0 */ case 5001: /* muzzle flash on attachment 0 */
EV_MuzzleFlash_Create(this, m_iNumBones, m_flMuzzleScale, m_iMuzzleModel); EV_MuzzleFlash_Create(this, m_iNumBones, m_flMuzzleScale, m_iMuzzleModel);
break; break;
@ -993,10 +993,10 @@ NSRenderableEntity::HandleAnimEvent(float flTimeStamp, int iCode, string strData
for (entity f = world; (f = find(f, ::targetname, strData));) { for (entity f = world; (f = find(f, ::targetname, strData));) {
NSEntity trigger = (NSEntity)f; NSEntity trigger = (NSEntity)f;
if (trigger.Trigger != __NULL__) { if (trigger.Trigger != __NULL__) {
trigger.Trigger(self, TRIG_TOGGLE); trigger.Trigger(this, TRIG_TOGGLE);
NSLog("^2%s^7::^3ModelEvent^7: " \ NSLog("^2%s^7::^3ModelEvent^7: " \
"Calling trigger '%s'\n", "Calling trigger '%s'\n",
self.classname, strData); classname, strData);
} }
} }
break; break;

View File

@ -18,7 +18,7 @@
@brief Constants macro loader @brief Constants macro loader
Scripters and level designers are able to define parameters through the use Scripters and level designers are able to define parameters through the use
of name-based lookups. of name-based lookups, so they can change them later in one convenient place.
In the game directory, they are defined within `scripts/constants.txt`. In the game directory, they are defined within `scripts/constants.txt`.
An example file looks like this: An example file looks like this:
@ -41,7 +41,7 @@ That would look something like this:
The same applies to data read within level files and most routines related to parsing key/value pairs, so it is not limited to usage within EntityDef. The same applies to data read within level files and most routines related to parsing key/value pairs, so it is not limited to usage within EntityDef.
*/ */
/** Called upon world init internally to populate our look-up table. /** Called upon game init internally to populate our look-up table.
*/ */
void Constants_Init(void); void Constants_Init(void);

View File

@ -28,6 +28,15 @@
.float maxspeed; .float maxspeed;
.float flags; .float flags;
var bool autocvar_s_developer = false;
void
_Sound_Log(string msg)
{
if (autocvar_s_developer == true)
print(sprintf("%f %s\n", time, msg));
}
#define SndLog(...) _Sound_Log(sprintf(__VA_ARGS__))
/** Global hash table for name > soundDef id lookup. */ /** Global hash table for name > soundDef id lookup. */
var hashtable g_hashsounds; var hashtable g_hashsounds;

View File

@ -396,9 +396,9 @@ Sound_Precache(string shader)
index = g_sounds_count; index = g_sounds_count;
dprint("[SOUND] Precaching sound shader "); SndLog("Precaching SoundDef ");
dprint(shader); SndLog(shader);
dprint("\n"); SndLog("\n");
/* create the hash-table if it doesn't exist */ /* create the hash-table if it doesn't exist */
if (!g_hashsounds) { if (!g_hashsounds) {
@ -411,7 +411,7 @@ Sound_Precache(string shader)
cache = (int)hash_get(g_hashsounds, shader, -1); cache = (int)hash_get(g_hashsounds, shader, -1);
if (cache >= 0) { if (cache >= 0) {
NSLog("^1Sound_Precache: shader %s already precached", shader); SndLog("^1Sound_Precache: def %s already precached", shader);
return cache; return cache;
} }
} }
@ -458,7 +458,7 @@ Sound_Precache(string shader)
fclose(fh); fclose(fh);
} }
print("^1no soundDef found for "); print("^1no SoundDef found for ");
print(shader); print(shader);
print("\n"); print("\n");
g_sounds_count--; g_sounds_count--;
@ -481,7 +481,7 @@ Sound_Distance(entity target, string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_Distance: shader %s is not precached\n", shader)); crossprint(sprintf("^1Sound_Distance: def %s is not precached\n", shader));
return; return;
} }
@ -544,7 +544,7 @@ Sound_DistancePos(vector pos, string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_DistancePos: shader %s is not precached (SERVER)\n", shader)); SndLog("^1Sound_DistancePos: def %s is not precached (SERVER)\n", shader);
return; return;
} }
@ -577,10 +577,7 @@ Sound_DistancePos(vector pos, string shader)
} }
#endif #endif
#ifdef DEVELOPER SndLog(sprintf("Sound_DistancePos: %s\n", argv(r)));
print(sprintf("Sound_DistancePos: %s\n", argv(r)));
#endif
pointsound_proper(pos, argv(r), volume, ATTN_NONE, pitch); pointsound_proper(pos, argv(r), volume, ATTN_NONE, pitch);
} }
@ -601,7 +598,7 @@ Sound_Play(entity target, int chan, string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_Play: shader %s is not precached\n", shader)); SndLog("^1Sound_Play: def %s is not precached\n", shader);
return; return;
} }
@ -724,7 +721,7 @@ Sound_PlayAt(vector pos, string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_PlayAt: shader %s is not precached\n", shader)); SndLog("^1Sound_PlayAt: def %s is not precached\n", shader);
return; return;
} }
@ -780,7 +777,7 @@ Sound_PlayLocal(string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_PlayLocal: shader %s is not precached\n", shader)); SndLog("^1Sound_PlayLocal: def %s is not precached\n", shader);
return; return;
} }
@ -866,7 +863,7 @@ Sound_Speak(entity target, string shader)
sample = (int)hash_get(g_hashsounds, shader, -1); sample = (int)hash_get(g_hashsounds, shader, -1);
if (sample < 0) { if (sample < 0) {
crossprint(sprintf("^1Sound_Speak: shader %s is not precached (SERVER)\n", shader)); SndLog("^1Sound_Speak: def %s is not precached (SERVER)\n", shader);
return; return;
} }