Full Version : Hiding information
xmlspawner >>Scripting Support >>Hiding information
<< Prev | Next >>
ozzy- 01-12-2007
Im trying to get it to change the color of the robe to a random color each time he says ( change hue )
ArteGordon- 01-12-2007
You have a couple of options then.
You can add a check into the DoSpeech method of your playermobile to look for that phrase, and then check to see if the robe is equipped, and then change the color of the robe.
Note, you have to ADD this code to the existing DoSpeech method in playermobile.cs, not replace any existing code.

CODE
if(text == "change hue") { // find the robe Item robe = FindItemOnLayer( Layer.OuterTorso); if(robe is OzzysMysteryRobeOfPower)
{
robe.Hue = Utility.Random(2, 1200);
}
}

You could also add a speech handler for it, but it essentially does the same thing.
ozzy- 01-12-2007
Ill give this a try see how it goes, if possible I would like to add a speech handler to the robe script, and not have any mods in the playermobile at all, but dont think thats possible lol.
ArteGordon- 01-12-2007
it can be done, but it involves more code.
ArteGordon- 01-12-2007
in your robe script you would add

CODE
public static new void Initialize() { EventSink.Speech += new SpeechEventHandler(EventSink_Speech); } public static void EventSink_Speech(SpeechEventArgs args)
{
Mobile from = args.Mobile;
if (from == null || !from.Player) return;
if (args.Speech != null && args.Speech == "change hue")
{
// find the robe
Item robe = from.FindItemOnLayer( Layer.OuterTorso);
if(robe is OzzysMysteryRobeOfPower)
{
robe.Hue = Utility.Random(2, 1200);
}
}
}

ozzy- 01-12-2007
Hmm would you be willing to help me with that. I know I have bothered you enough already, but I love drop and go scripts if modding is not needed to the other scripts it makes me happy lol.
ArteGordon- 01-12-2007
that's exactly what that code is. Just add it to your robe script.
ozzy- 01-12-2007
Hmm, ok i tryed the one in playermobile.cs and it worked to change the robe colors, but then i couldnt do anything else like [admin [unhide, and my speech would not pop up like it should above my head. I commented it out for now and tryed the robe code. I can do my commands now and speech works fine, but the robe wont change color did i do something wrong? Here is the code thats in my script for the robe.

CODE
public static new void Initialize() { EventSink.Speech += new SpeechEventHandler(EventSink_Speech); } public static void EventSink_Speech(SpeechEventArgs args)
{
Mobile from = args.Mobile;
if (from == null || !from.Player) return;
if (args.Speech != null && args.Speech == "change hue")
{
// find the robe
Item robe = from.FindItemOnLayer( Layer.OuterTorso);
if(robe is OzzysMysteryRobeOfPower)
{
robe.Hue = Utility.Random(2, 1200);
}
}
}

ArteGordon- 01-12-2007
your first problem was because you probably added the code incorrectly to DoSpeech. You probably replaced the existing code rather than just adding that bit of code.
The speech handler approach should work. You have to have the robe equipped and you have to type the phrase "change hue" exactly like that, all lower case and with the space in there.
Also, check the layer that your robe is on. It might not be on 'Layer.OuterTorso', try 'Layer.Cloak' instead.
ozzy- 01-12-2007
OMG I think i typed change hue wrong lol i tryed it again and it works fine. Hmm, well crap now its done I dont know what to do lol. Thank you so much. If you want a copy of a lowly begginers script let me know Ill gladly share with you my Lord lol.
ArteGordon- 01-12-2007
and another way to do it is by adding an OnSpeech override to your robe script. All three methods basically do the same thing.

CODE
public override bool HandlesOnSpeech { get { return Parent is PlayerMobile; } } public override void OnSpeech(SpeechEventArgs e)
{
if (e.Speech == "change hue" && e.Mobile == Parent)
{
Hue = Utility.Random(2, 1200);
}
}

ozzy- 01-12-2007
Ok I like the way the second code there looks its nice and short. I tryed it to see how it does and got an error. Im going to guess Im missing a user directive am I right? Here is the error.

CODE
- Error: Scripts\New Stuff\Ozz Armor\OzzysMysteryRobeOfPower.cs: CS0246: (line 140, column 35) The type or namespace name 'PlayerMobile' could not be found (ar e you missing a using directive or an assembly reference?)

ArteGordon- 01-12-2007
you will need to add

CODE
using Server.Mobiles;

to the top. I also added a little check to make sure that the player speaking also has to be the player wearing the cloak in order to change it. Otherwise you could change other peoples cloaks too
ozzy- 01-12-2007
YES!! IT LIVES lol Ill stop bugging you now thank you so much. Here is what all it does now, first off it looks like a normal robe it only shows its name nothing else, adds hiding and stealth gain that will go over there individual skill caps, along with all the normal mods, adds 2 to taming slots. When double clicked turns into a shroud changing your name to a shrouded figure, and hides guild info, also uses the hiding skill to hide you. If a player reveals you or you fail to stealth it still just shows a shrouded figure, and no guild info when double clicked again unhides you and shows your name and guild info again then changes hue on comand. I love it lol, If you want a copy of the script just say so.