diff --git a/source/client/main.qc b/source/client/main.qc index d22e8f2..3344e5b 100644 --- a/source/client/main.qc +++ b/source/client/main.qc @@ -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(); diff --git a/source/client/menu.qc b/source/client/menu.qc index 7628390..4d1d69f 100644 --- a/source/client/menu.qc +++ b/source/client/menu.qc @@ -1872,15 +1872,15 @@ void() Draw_Menu = { // main menu theme iterating if (menu_initialized == false && in_menu == MENU_MAIN) { - localsound_enhanced("tracks/tensioned_by_the_damned.mp3", CHAN_MUSIC, 1); - menu_sound_length = 490; // have to hard code because soundlength() doesn't like MP3 media it seems.. + localsound_enhanced("tracks/tensioned_by_the_damned.ogg", CHAN_MUSIC, 1); + menu_sound_length = 490; menu_sound_time = 0; menu_initialized = true; } // restart the track if it has ended if (menu_initialized == true && (menu_sound_time >= menu_sound_length - 1)) { - localsound_enhanced("tracks/tensioned_by_the_damned.mp3", CHAN_MUSIC, 1); + localsound_enhanced("tracks/tensioned_by_the_damned.ogg", CHAN_MUSIC, 1); menu_sound_time = 0; } diff --git a/source/server/clientfuncs.qc b/source/server/clientfuncs.qc index cb9dbb7..490018d 100644 --- a/source/server/clientfuncs.qc +++ b/source/server/clientfuncs.qc @@ -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 = { diff --git a/source/server/defs/custom.qc b/source/server/defs/custom.qc index 6f8d62b..2f07aa5 100644 --- a/source/server/defs/custom.qc +++ b/source/server/defs/custom.qc @@ -46,6 +46,8 @@ float framecount; float deathmatch; float coop; +float music_override; + #ifndef FTE void(string com) SV_ParseClientCommand; @@ -53,6 +55,7 @@ void(string com) SV_ParseClientCommand; .float recoil_delay; .float mapversion; .float ammo; +.float frags; #endif // FTE @@ -517,9 +520,6 @@ float G_WORLDTEXT; float G_PERKS; float G_PERKPOWER; -//song easter egg -float sndTriggerCnt; -float sndActivCnt; .float activated; //teleporter diff --git a/source/server/entities/explosive_barrel.qc b/source/server/entities/explosive_barrel.qc index 423fc43..f0a6ca5 100644 --- a/source/server/entities/explosive_barrel.qc +++ b/source/server/entities/explosive_barrel.qc @@ -42,6 +42,7 @@ void() Barrel_Explode = CallExplosion(self.origin); + SUB_UseTargets (); SUB_Remove (); }; diff --git a/source/server/entities/map_entities.qc b/source/server/entities/map_entities.qc index 157ae33..bd9db85 100644 --- a/source/server/entities/map_entities.qc +++ b/source/server/entities/map_entities.qc @@ -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); } // // ============================================================ @@ -359,4 +354,37 @@ void() place_model = // Now just execute the misc_model spawn function. misc_model(); -}; \ No newline at end of file +}; + +// +// game_counter() +// Quick and dirty game_counter implementation, referenced +// from TWHL docs (https://twhl.info/index.php/wiki/page/game_counter) +// +#define SPAWNFLAG_COUNTER_REMOVEONFIRE 1 +#define SPAWNFLAG_COUNTER_RESETONFIRE 2 +void() game_counter_increment = +{ + self.frags++; + + if (self.frags == self.health) { + SUB_UseTargets(); + + if (self.spawnflags & SPAWNFLAG_COUNTER_REMOVEONFIRE) { + remove(self); + } else if (self.spawnflags & SPAWNFLAG_COUNTER_RESETONFIRE) { + self.frags = self.cost; + } + } +} + +void() game_counter = +{ + // TODO: master checking.. + + // Store the initial value in case RESET ON FIRE is set. + self.cost = self.frags; + + // Every time its triggered, increment. + self.use = game_counter_increment; +} \ No newline at end of file diff --git a/source/server/entities/sub_functions.qc b/source/server/entities/sub_functions.qc index 3c39908..5860ed4 100644 --- a/source/server/entities/sub_functions.qc +++ b/source/server/entities/sub_functions.qc @@ -64,6 +64,9 @@ void() SUB_UseTargets = temptotal = 0; tempcount = 0; breakthis = false; + + if (self.target) + tempcount = tempcount + 1; if (self.target2) tempcount = tempcount + 1; if (self.target3) diff --git a/source/server/rounds.qc b/source/server/rounds.qc index 5c68f89..44e313f 100644 --- a/source/server/rounds.qc +++ b/source/server/rounds.qc @@ -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) diff --git a/source/shared/defs/custom.qc b/source/shared/defs/custom.qc index b3eed8c..0667ac2 100644 --- a/source/shared/defs/custom.qc +++ b/source/shared/defs/custom.qc @@ -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 diff --git a/source/shared/weapon_defines.qc b/source/shared/weapon_defines.qc index 42fe57f..b2763f1 100644 --- a/source/shared/weapon_defines.qc +++ b/source/shared/weapon_defines.qc @@ -152,7 +152,7 @@ string(float wep) GetWeaponName = case W_PORTER: return "Porter's X2 Ray Gun"; case W_SAWNOFF: - return "Sawnoff shotgun"; + return "Sawed-Off Shotgun"; case W_SNUFF: return "The Snuff Box"; case W_STG: