mirror of
https://github.com/nzp-team/quakec.git
synced 2025-02-20 18:52:36 +00:00
CLIENT/SERVER: Implement game_songplay entity for music streaming
This commit is contained in:
parent
6fd6d0dafd
commit
8ac9ff87bf
6 changed files with 31 additions and 20 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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); }
|
||||
|
||||
//
|
||||
// ============================================================
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue