|
||
|
|||||||
| Custom Script Releases This forum is where you can release your custom scripts for other users to use. Please note: By releasing your scripts here you are submitting them to the public and as such agree to publish them under the GPL licensing terms. The RunUO Team has made its software GPL for you to use and enjoy you should do the same for anything based off of RunUO. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Forum Expert
|
Music Box with 51 Songs
There were 2 posts that were the inspiration for this. One was a 1.0 Music Player by Alambik. You had to [props it and select the Song, and it would broadcast it 100 tiles around. The other was by Erica, who showed me that there was a graphic for something called "Dawn's Music Box" in RunUO (and, I discovered later, several Cliloc entries.) Now, I do not play on OSI, so I am not exactly familiar with Dawn's Music Box, but from reading the Cliloc entries, I understand that there were songs you could 'Add' to the player that you could find like treasure. So, those were my inspirations for this release. UPDATES: 6-5-2007: Added Animation sequence. (Thanks Erica, for script suggestion that helped with idea) - NOTES on Animation: - I do not know why it sometimes works and sometimes does not. - The animation will last almost exactly for the length of the music. Changed the StopMusic method. - It will now send a packet for the Music of the current Region. 6/24/2007 - New and Improved version posted. - Includes new files. Now, you can obtain a MusicBox from an Addon Deed. - MusicBoxEastDeed and MusicBoxSouthDeed. - Better Animation and Timing handling. - Animation stops when supposed to. If song loops, Animation stops after first loop. - Name of Music Box changes appropriately when Stopped or Playing, including listing the Title of the song. - When played by GM and above, will play the song to surrounding players, and will stop their MusicBoxes too. WHAT'S INCLUDED: MusicBox: - It plays the title currently selected. - It has a Gump allowing you to see all of the Songs you have added to the player, with options to add more, and to select one that has been added. - It has a command for GM's called "AddAllSongs" which, of course, will add all 51 songs to the MusicBox. MusicBoxTracks: - There are 51 songs, released as individual tracks you can add to the player. - You can feel free to distribute however you wish, such as through drops, rewards or Vendors. - I tried to carefully match up the songs as they are compiled in the most current release. COMPATIBILITY: This should work on RunUO 2.0 RC1 or SVN. RC1 NOTE - all you need to do is comment out this line: #define SVN I believe Mondain's Legacy will be required on the client end, since some of the songs seem to be ML-related. INSTALLATION: Drop in customs and restart Server. BONUS FILE: I added the mp3 for Turfin, because I love it, and for some reason it was removed from UO some time ago. If you like the song, you can add it by renaming your existing file (in EA Games\Ultima Online Mondain's Legacy\Music\Digital\ folder) and placing this one there in it's place.
__________________
Advanced Player Gate with Shard Control - My Master Runebook - Linked Books & Bags - Full Toolbar (Fubar) - XML Bible system - Music Box - Enhancement Deeds - House Paints - Light Switch Last edited by Lokai; 06-24-2007 at 09:10 PM. Reason: Completed updates. |
|
|
|
|
|
#3 (permalink) |
|
Newbie
Join Date: Sep 2006
Location: USA
Age: 51
Posts: 92
|
The package installed and compiled fine. When I try to play a song, the index shows ALL songs as mega cliloc errors. I went to see if I could fix these, but what I am use to seeing, is only a list of ONLY numbers. ML is installed.
Any chance you could point me in the correct direction to fix this? I love this idea! thank you for scripting this. Last edited by madron; 05-27-2007 at 01:12 PM. |
|
|
|
|
|
#4 (permalink) | |
|
Forum Expert
|
Quote:
I could try. Best guess I can give you is that it has something to do with the version of UO Client I have. I am using 5.0.9.1 Patch 46. You might want to get a Cliloc Viewer, and see if those numbers match up with anything in the one you have. |
|
|
|
|
|
|
#5 (permalink) | |
|
Newbie
Join Date: Sep 2006
Location: USA
Age: 51
Posts: 92
|
Quote:
we are using 5.8.2, I am going to try 5.9.1, I will let you know. Thank you so much! ![]() Edited to add: I changed the client, but its still giving cliloc errors. Can't patch as I don't want the last patch of stuff they dished out. Cant find the strings, so maybe I can add them... I will try Last edited by madron; 05-27-2007 at 04:18 PM. |
|
|
|
|
|
|
#6 (permalink) |
|
Master of the Internet
|
ihave patch 5.0.6e and i see all of them with no problem, so unless you are using a custom cliloc, then i do not think it is causing the problem
and great scripts -- works and looks great ![]()
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#9 (permalink) |
|
Master of the Internet
|
single click it once to bring up the menu, then select song to play
once it is "playing" it will play the song once and stop even if you click stop - it still finishes the song ![]()
__________________
http://www.AoAUO.com
:) ..... Come for the Customs, Play for the Fun. Return to see your new Friends ..... :) |
|
|
|
|
|
#10 (permalink) |
|
Forum Novice
Join Date: Jun 2006
Age: 32
Posts: 344
|
Dawns music box is my most favorite item in uo.
and turfin is a track on the music box. there are 3 rarities of music tracks "gears found on golems and other blackthorn critters" dawns music box was a 8th age gift, and you can still get it with some other heritage token. i'll check it out and let ya know how osi accurate it is. |
|
|
|
|
|
#12 (permalink) | |
|
Forum Expert
|
Quote:
Of course feel free to release an OSI-faithful version, if you like. ![]() |
|
|
|
|
|
|
#14 (permalink) | |
|
Newbie
Join Date: Sep 2006
Location: USA
Age: 51
Posts: 92
|
Quote:
No custom cliloc. I have no idea what this could be. I am running SVN 156, could this be the cause? Edited to add: I figured it out. I was missing some files on my server, not sure how that happened... but its fixed. Thank you Greywolf, I figured it out after you posted what client you were using, thanks! This is awesome BTW...I love it! Last edited by madron; 05-28-2007 at 12:38 PM. |
|
|
|
|
|
|
#15 (permalink) |
|
Forum Novice
Join Date: Mar 2006
Location: upstate NY
Age: 36
Posts: 488
|
Im trying to convert this to 1.0, i got it to compile but now when I try to add a song I get a crash???
Code:
Server Crash Report =================== RunUO Version 1.0.0, Build 36918 Operating System: Microsoft Windows NT 5.1.2600.0 .NET Framework: 1.1.4322.2032 Time: 5/29/2007 2:42:13 PM Mobiles: 4551 Items: 200068 Clients: - Count: 1 Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at Server.Items.MusicBox.PlayListGump.Target(MusicBoxTrack target) at Server.Items.MusicBox.InternalTarget.OnTarget(Mobile from, Object o) at Server.Targeting.Target.Invoke(Mobile from, Object targeted) at Server.Network.PacketHandlers.TargetResponse(NetState state, PacketReader pvSrc) at Server.Network.MessagePump.HandleReceive(NetState ns) at Server.Network.MessagePump.Slice() at Server.Core.Main(String[] args) MusicBox.cs Code:
using System;
using System.Collections;
using Server;
using Server.Targeting;
using Server.Gumps;
using Server.ContextMenus;
using Server.Network;
using Server.Mobiles;
using Server.Items;
using Server.Scripts.Commands;
namespace Server.Items.MusicBox
{
[Flipable(0x2AF9, 0x2AFD)]
public class MusicBox : Item
{
public static void Initialize()
{
Server.Commands.Register("AddAllSongs", AccessLevel.GameMaster, new
CommandEventHandler(AddAllSongs_OnCommand));
}
[Usage("AddAllSongs")]
[Description("Adds all songs to the MusicBox.")]
public static void AddAllSongs_OnCommand(CommandEventArgs e)
{
e.Mobile.SendMessage("Target the MusicBox.");
e.Mobile.Target = new InternalTarget();
}
public class InternalTarget : Target
{
public InternalTarget()
: base(1, false, TargetFlags.None)
{
}
protected override void OnTarget(Mobile from, object o)
{
if (o is MusicBox)
{
from.SendMessage("All Tracks were added to the Music Box!");
((MusicBox)o).AddAllTracks();
}
else
from.SendMessage("That is not a Music Box!");
}
}
public const int SONGS = 51;
[Constructable]
public MusicBox()
: base(0x2AF9)
{
Name = "MusicBox: Stopped";
Weight = 3.0;
m_HasTrack = new bool[SONGS];
for (int x = 0; x < SONGS; x++)
{
m_HasTrack[x] = false;
}
}
public MusicBox(Serial serial)
: base(serial)
{
}
public override void GetContextMenuEntries( Mobile from, ArrayList list )
{
base.GetContextMenuEntries( from, list );
list.Add(new PlayListEntry(from, this));
}
bool playing;
public override void OnDoubleClick(Mobile from)
{
if (from.AccessLevel < AccessLevel.GameMaster)
{
if (playing)
{
StopMusic(from);
Name = "MusicBox: Stopped";
}
else
{
PlayMusic(from);
Name = "MusicBox: Playing";
}
}
else
{
IPooledEnumerable eable = from.Map.GetMobilesInRange(from.Location, m_Range);
ArrayList list = new ArrayList();
foreach (Mobile mob in eable)
{
if (playing)
StopMusic(mob);
else
PlayMusic(mob);
}
eable.Free();
if (playing)
Name = "MusicBox: Stopped";
else
Name = "MusicBox: Playing";
}
playing = !playing;
}
private static int[] m_Locals = new int[] { 1075131, 1075132, 1075133, 1075134, 1075135, 1075136,
1075137,
1075138, 1075139, 1075140, 1075142, 1075143, 1075144, 1075145, 1075146, 1075147, 1075148,
1075149,
1075150, 1075151, 1075152, 1075154, 1075155, 1075156, 1075157, 1075158, 1075159, 1075160,
1075163,
1075164, 1075165, 1075166, 1075167, 1075168, 1075170, 1075171, 1075172, 1075173, 1075174,
1075175,
1075176, 1075177, 1075178, 1075179, 1075180, 1075181, 1075182, 1075183, 1075184, 1075185, 1075186
};
private static MusicName[] m_Songs = new MusicName[] {
MusicName.OldUlt02,MusicName.Serpents,MusicName.Britain1,
MusicName.Britain2,MusicName.Bucsden,MusicName.Jhelom,MusicName.LBCastle,MusicName.Magincia,MusicName.Minoc,
MusicName.Ocllo,MusicName.Samlethe,MusicName.Skarabra,MusicName.Trinsic,MusicName.Vesper,MusicName.Wind,
MusicName.Yew,MusicName.Cave01,MusicName.Dungeon9,MusicName.Sailing,MusicName.Tavern01,MusicName.Tavern02,
MusicName.Tavern03,MusicName.Tavern04,MusicName.Combat1,MusicName.Combat3,MusicName.Death,MusicName.Victory,
MusicName.BTCastle,MusicName.Nujelm,MusicName.Dungeon2,MusicName.Cove,MusicName.Moonglow,MusicName.Zento,
MusicName.TokunoDungeon,MusicName.Linelle
};
public static int[] Locals
{
get { return m_Locals; }
}
public static MusicName[] Songs
{
get { return m_Songs; }
}
private bool[] m_HasTrack;
public bool[] HasTrack
{
get { return m_HasTrack; }
set { m_HasTrack = value; }
}
public void AddTrack(MusicBoxTrack track)
{
for (int x = 0; x < MusicBox.SONGS; x++)
{
if (track.Song == MusicBox.Songs[x])
{
m_HasTrack[x] = true;
}
}
}
public void AddAllTracks()
{
for (int x = 0; x < MusicBox.SONGS; x++)
{
m_HasTrack[x] = true;
}
}
private int m_Range = 10;
[CommandProperty(AccessLevel.GameMaster)]
public int Range
{
get { return m_Range; }
set { m_Range = value; }
}
private MusicName m_Music = MusicName.Invalid;
[CommandProperty(AccessLevel.GameMaster)]
public MusicName Music
{
get { return m_Music; }
set { m_Music = value; InvalidateProperties(); }
}
public virtual void PlayMusic(Mobile m)
{
if (m_Music != MusicName.Invalid && m.NetState != null)
m.Send( Network.PlayMusic.GetInstance(m_Music));
}
public virtual void StopMusic(Mobile m)
{
if (m_Music != MusicName.Invalid && m.NetState != null)
m.Send(Network.PlayMusic.InvalidInstance);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write((int)0); // version
writer.Write((int)m_Range);
writer.Write((int)m_Music);
for (int x = 0; x < SONGS; x++)
{
writer.Write((bool)m_HasTrack[x]);
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
m_Range = reader.ReadInt();
m_Music = (MusicName)reader.ReadInt();
m_HasTrack = new bool[SONGS];
for (int x = 0; x < SONGS; x++)
{
m_HasTrack[x] = reader.ReadBool();
}
Name = "MusicBox: Stopped";
}
}
public class PlayListEntry : ContextMenuEntry
{
private Mobile m_From;
private MusicBox m_Box;
public PlayListEntry(Mobile from, MusicBox box)
: base(10003, 1)
{
m_From = from;
m_Box = box;
}
public override void OnClick()
{
m_From.SendGump(new PlayListGump(m_From, m_Box));
}
}
public class PlayListGump : Gump
{
private MusicBox m_Box;
private Mobile m_From;
public PlayListGump(Mobile from, MusicBox box)
: base(30, 30)
{
from.CloseGump(typeof(PlayListGump));
m_Box = box;
m_From = from;
AddBackground(0, 0, 600, 480, 9400);
AddPage(0);
AddHtmlLocalized(250, 10, 180, 20, 1075130, 2124, false, false);
int Xpos = 26, Ypos = 42;
int z = 0;
for (int x = 0; x < 3; x++)
{
for (int y = 0; y < 17; y++)
{
bool has = (box.HasTrack[z]);
AddSongEntry(Xpos, Ypos, MusicBox.Locals[z], has ? 177 : 547, z + 100, has);
Ypos += 20;
z++;
}
Xpos += 200;
Ypos = 42;
}
AddLabel(250, 460, 2124, "Add Songs");
AddButton(220, 460, 1210, 1210, 99, GumpButtonType.Reply, 0);
}
private void AddSongEntry(int x, int y, int local, int color, int song, bool active)
{
AddHtmlLocalized(x, y, 180, 20, local, color, false, false);
if (active) AddButton(x - 20, y, 1210, 1210, song, GumpButtonType.Reply, 0);
}
public override void OnResponse(NetState sender, RelayInfo info)
{
if (info.ButtonID == 99)
{
m_From.Target = new InternalTarget(this);
}
else if (info.ButtonID > 99)
{
m_Box.Music = MusicBox.Songs[info.ButtonID - 100];
m_From.SendMessage("Now active:");
m_From.SendLocalizedMessage(MusicBox.Locals[info.ButtonID - 100]);
}
else
return;
}
public void Target(MusicBoxTrack target)
{
for (int x = 0; x < MusicBox.SONGS; x++)
{
if (target.Song == MusicBox.Songs[x])
{
if (!m_Box.HasTrack[x])
{
m_Box.HasTrack[x] = true;
target.Delete();
m_From.SendMessage("Song successfully added.");
}
else
m_From.SendMessage("That song is already added.");
}
}
}
public class InternalTarget : Target
{
private PlayListGump m_Owner;
public InternalTarget(PlayListGump owner)
: base(1, false, TargetFlags.None)
{
m_Owner = owner;
}
protected override void OnTarget(Mobile from, object o)
{
if (o is MusicBoxTrack)
{
m_Owner.Target((MusicBoxTrack)o);
}
else
from.SendMessage("That is not a Song Track!");
}
}
}
}
__________________
|
|
|
|
|
|
#16 (permalink) |
|
Forum Expert
|
I was going to say "What song were you adding?" but I was not sure that it would be relevant. Now I think it is. Look in your RunUO 1.0 Source Folder, you will find BaseRegion.cs. I was just looking at that, and noticed that there are about half as many songs there as in 2.0. That must be it. The enum is basically a glorified array of INTs, so by calling a "song" not listed, it is calling an integer outside the bounds of the array. (Not sure, but it's a working theory.)
|
|
|
|
|
|
#17 (permalink) | |
|
Forum Novice
Join Date: Mar 2006
Location: upstate NY
Age: 36
Posts: 488
|
Quote:
I was getting errors while it was trying to compile and i had to remove all the songs that my server didnt have. Code:
private static int[] m_Locals = new int[] { 1075142, 1075143, 1075144, 1075145, 1075146, 1075147, 1075148, 1075149, 1075150, 1075151, 1075152, 1075154, 1075155, 1075156, 1075157, 1075158, 1075159, 1075160, 1075163, 1075164, 1075165, 1075166, 1075167, 1075168, 1075170, 1075171, 1075172, 1075173, 1075174, 1075175, 1075176, 1075177, 1075178, 1075179, 1075185
};
private static MusicName[] m_Songs = new MusicName[] {
MusicName.OldUlt02,MusicName.Serpents,MusicName.Britain1,
MusicName.Britain2,MusicName.Bucsden,MusicName.Jhelom,MusicName.LBCastle,MusicName.Magincia,MusicName.Minoc,
MusicName.Ocllo,MusicName.Samlethe,MusicName.Skarabra,MusicName.Trinsic,MusicName.Vesper,MusicName.Wind,
MusicName.Yew,MusicName.Cave01,MusicName.Dungeon9,MusicName.Sailing,MusicName.Tavern01,MusicName.Tavern02,
MusicName.Tavern03,MusicName.Tavern04,MusicName.Combat1,MusicName.Combat3,MusicName.Death,MusicName.Victory,
MusicName.BTCastle,MusicName.Nujelm,MusicName.Dungeon2,MusicName.Cove,MusicName.Moonglow,MusicName.Zento,
MusicName.TokunoDungeon,MusicName.Linelle
};
I get the crash as soon as I try to pull up the gump to add a song, as player or admin.
__________________
|
|
|
|
|
|
|
#19 (permalink) | |
|
Forum Expert
|
Quote:
|
|
|
|
|
|
|
#23 (permalink) | |
|
Forum Novice
Join Date: Mar 2006
Location: upstate NY
Age: 36
Posts: 488
|
Quote:
I changed it to that now I get the gump showing but when I try to add a scroll i get the same crash. Edit: Ok Ive been messing around with this, if I leave it at 51 and take out just the musicname:XXXXX that are not found, then it compiles fine and I get the gump with all the songs, once I click on add song I get the crash. When I put it to 35 and take out the musicname:xxxx blah blah then it crashes as soon as i click index to get the gump. I have removed all the numbers connected to the songs in the "private static int[] m_Locals = new int[] { " tried it both with 35 songs and 51 songs and still it crashes. If I leave it at 51 then I get the gump to show up, if i put it to 35 the gump will not show up and it crashes. I tried taking out just one of the numbers and I got a crash when I clicked index, so the way it is now I can not remove any of the numbers or change the songs to anything other then 51 or I get the crash. With my admin I have added all the songs and they all play and show on the gump, if i choose a song that isnt there then i get the same crash. Just wondering is it suppose to stop the song right away when you click stop or just keep playing until the song is over
__________________
Last edited by Fixxxer; 05-30-2007 at 12:36 PM. Reason: new info |
|
|
|
|
|
|
#25 (permalink) | |
|
Forum Expert
|
Quote:
OK, you need to modify the Gump. I made it for exactly 51 entries. 3 x 17 = 51. In the Gump, I use 2 nested FOR loops, one goes up to 3, the other to 17, making a total of 51 passes for 51 songs. You will have to design your own system for getting 35 songs to fit in the Gump. Maybe 5 times 7? |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|