Well, sort of . . .
If you've ever wanted the ability to play custom music in the zones that are part of your world--if for no other reason than to provide proper ambiance for each zone--now you can. I have been working on this for months, and have finally taken it to the point that it works on the server. It's not yet fully functional on the client, and I am struggling with the best way to approach that. So I'm submitting this in the hope it will spark an idea in someone. Here's what I've done so far:
1. Create custom wav files for the desired zones (I use Audacity, which is a free download and allows you to convert mp3 and other formats to wav). Name them sequentially as zonea.wav, zoneb.wav, zonec.wav, etc. Using mp3s would save a lot of space, but I cannot figure out how to get the media player to play in the background (see # 2 below) when using mp3s.
2. You'll need to run the music in the background to prevent constant interrupts by the Media player GUI as it launches each new wav file. To do that in Windows XP (Vista is more difficult), use these instructions:
Start,
Control Panel,
Folder Options,
File Types;
select file-type WAV;
Advanced;
New ...;
Action -
Hear;
Application Used to Perform Action -
C:\WINDOWS\system32\sndrec32.exe /embedding /play "%L" /Close;
checkmark Use DDE;
DDE Message leave blank;
Application -
sndrec32;
DDE Application Not Running -
leave blank;
Topic -
system;
OK;
Set Default;
OK;
Close.
3. Set up the following script in your C:\EQEmu\quests\templates\player.pl (create it if you don't have it; just know the template player.pl will be overridden by any zone-specific player.pl). I've included three zones in the sample below. You would of course change these to the zones you are using and add as many entries as you need:
Code:
sub EVENT_ENTERZONE
{
my $zone_music_end = 'cscript.exe /nologo C:\EQEmu\quests\music\stop.vbs';
system("$zone_music_end");
my $zone_music_a = 'C:\EQEmu\quests\music\runa.vbs'; #Zoneid 11
my $zone_music_b = 'C:\EQEmu\quests\music\runb.vbs'; #Zoneid 117
my $zone_music_c = 'C:\EQEmu\quests\music\runc.vbs'; #Zoneid 3
if($zoneid == 11)
{ #executes the corresponding vb script above
system("$zone_music_a");
}
elsif($zoneid == 117)
{
system("$zone_music_b");
}
elsif($zoneid == 3)
{
system("$zone_music_c");
}
}
4. Create a vb script for each zone for which you will have custom music. I've called mine "run_.vbs" replacing the underscore with a sequential letter (runa.vbs, runb.vbs, runc.vbs, etc.). You'll need to download and install Wscript to execute this (if you don't already have it). Notice below that the script launches a corresponding batch file (in this case, "runa.bat"). The batch file itself will launch the wav file. I use the vb script to execute the batch file in a "shell," which in turn allows the batch file to run in "silent" mode (i.e., it won't interrupt game play by opening a command line first). The script below can be used as a template. Just change the pathname and filename to whatever path/filename you're using. Create one of these for each wav file you'll be using.
Contents of run*.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "%comspec% /c C:\EQEmu\quests\music\runa.bat",0
Set WshShell = Nothing
5. Using the template below, create batch files for all zones for which you will have custom music. The batch file launches the .wav file for the zone (in this case, zonea.wav):
Contents of runa.bat
@echo off
start C:\EQEmu\quests\music\zonea.wav
6. Place all vb scripts, batch files, and wav files in the same folder (I've placed mine in c:\eqemu\quests\music\. Start game, and enter one of the zones for which you have created custom music.
This music system will work well on the computer that hosts the world server. However, there are still problems with the system that need to be resolved. They are:
1. Any client machine that enters a custom-music zone will trigger the music (via the player script) on the server machine only. And it will trigger it every time another player enters another custom-music zone.
2. The instructions above will not yet allow you to play custom music on the client machine. I have been experimenting with pstools (specifically, psexec); but for this to work you need to hard-code the computer name and the administrative login and password for each client in a listfile accessed by the server, and execute this in the run*.bat file for each zone. As well (since psexec does not like commands that run music on other computers) you would need to add a second layer of .vbs and .bat files that reside on the client machine and are executed by the original run*.bat (see example below)
On the server
run*.bat:
for /F "tokens=1,2,3*" %%A in (LISTFILE.TXT) do (
psexec \\%%A -u %%B -p %%C -i cscript.exe /nologo c:\EQEmu\Quests\music\musica.vbs
)
On the client machine
Contents of musica.vbs
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.run "%comspec% /c C:\EQEmu\quests\music\musica.bat",0
Set WshShell = Nothing
Contents of musica.bat
@echo off
start C:\EQEmu\quests\music\zonea.wav
But even with this, the music will begin playing on ALL machines indiscriminately whenever any one client (or server) enters a zone. I have not yet figured out a way to make the music play only on the machine that enters the zone. I assume there is something I could do to the player.pl that would isolate the function to the client machine that enters the zone, but I have no idea what that would be.
Any help on this would be greatly appreciated.