CLIENT/SERVER: Implement game_songplay entity for music streaming

This commit is contained in:
Steam Deck User 2023-03-25 20:23:42 -04:00
parent 6fd6d0dafd
commit 8ac9ff87bf
6 changed files with 31 additions and 20 deletions

View file

@ -1167,6 +1167,10 @@ noref void() CSQC_Parse_Event =
if (chaptertitle == "")
chaptertitle = "'Nazi Zombies'";
break;
case EVENT_SONGPLAY:
string track_name = readstring();
localsound_enhanced(strcat("tracks/", track_name, ".ogg"), CHAN_MUSIC, 1);
break;
case EVENT_ACHIEVEMENT:
float ach = readbyte();

View file

@ -65,6 +65,14 @@ void(entity to, float type, float cost, float weapon) useprint = {
msg_entity = to;
multicast('0 0 0', MULTICAST_ONE);
}
void(string track_name) songegg =
{
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EVENT_SONGPLAY);
WriteString(MSG_MULTICAST, track_name);
multicast('0 0 0', MULTICAST_ALL);
};
#endif // FTE
void(vector org) CallExplosion = {

View file

@ -46,6 +46,8 @@ float framecount;
float deathmatch;
float coop;
float music_override;
#ifndef FTE
void(string com) SV_ParseClientCommand;
@ -518,9 +520,6 @@ float G_WORLDTEXT;
float G_PERKS;
float G_PERKPOWER;
//song easter egg
float sndTriggerCnt;
float sndActivCnt;
.float activated;
//teleporter

View file

@ -138,25 +138,20 @@ void() teddy_spawn =
/* ==================
Custom Song Code
================== */
void() touch_songtrigger = {
if (other.classname != "player" || self.activated)
return;
if (other.button7) {
sound(self, CHAN_VOICE, self.tune, 1, ATTN_NORM);
self.activated = true;
sndActivCnt++;
if (sndTriggerCnt == sndActivCnt)
playSoundAtPlayers(world.song);
}
void() game_songtriggered =
{
songegg(self.aistatus);
music_override = time + self.cost;
}
void() trigger_song = {
remove(self);
}
void() game_songplay =
{
self.use = game_songtriggered;
};
// Old gross ent..
void() trigger_song = { remove(self); }
//
// ============================================================

View file

@ -97,6 +97,10 @@ float() getZombieTotal = {
void(string s) playSoundAtPlayers =
{
// Don't play any round stuff while there's a song egg happening.
if (music_override > time)
return;
local entity p;
p = find(world,classname,"player");
while(p)

View file

@ -54,6 +54,7 @@ const float EVENT_REVIVEON = 37;
const float EVENT_REVIVEOFF = 38;
const float EVENT_REVIVECHANGE = 39;
const float EVENT_WEAPONRECOIL = 40;
const float EVENT_SONGPLAY = 41;
// Define our FTE platform
#ifndef STANDARD