[Request] How to make a wishes tree

06/04/2010 20:09 masternek#1
hello everyone.

i wanna know, if it is possible to make something like... a wish tree, a player talk with the tree, and then he can writte his wish on it, and that wish, will be saved in a text file in a source folder with the infos:

character name, wish, date of wish.


please help :)
06/04/2010 21:48 dragon89928#2
I'm sure you can. just use a stream writer to write the wish name and w/e you want into a file. Problem is I think you will have to use NPCLink2 which correct me if I'm wrong has a limit in the length. so your "wish" can only be so long. I'll double check this.
06/04/2010 23:46 masternek#3
can you do something like... a lil guide? o.o
06/05/2010 08:17 dragon89928#4
you'd wanna do something like

in npcdialog:
Code:
#region wish tree
                            case 999999: // make sure you change this to the npc you want to use
                                {

                                    if (Control == 0)
                                    {
                                        GC.AddSend(Packets.NPCSay("What is your wish?"));
                                        GC.AddSend(Packets.NPCLink2("Type in your wish", 1));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    else if (Control == 1)
                                    {
                                        string wish = ReadString(Data);
                                        if (wish != null)
                                        {
                                            string path = "C:\\OldCODB\\wish.txt";
                                            StreamWriter SW;
                                            if (File.Exists(path))
                                            {
                                                SW = File.AppendText(path);
                                                SW.WriteLine(GC.MyChar.Name + ": " + wish);
                                                //will write  --   Name: My wish
                                                SW.Close();
                                                Console.WriteLine("A new wish has been made!");
                                            }
                                            else
                                            {
                                                SW = File.CreateText(path);
                                                SW.WriteLine(wish);
                                                SW.Close();
                                                Console.WriteLine("A new wish has been made!");
                                            }
                                        }
                                        GC.AddSend(Packets.NPCSay("Your Wish has been added into the file"));
                                        GC.AddSend(Packets.NPCLink2("Thanks", 255));
                                        GC.AddSend(Packets.NPCSetFace(N.Avatar));
                                        GC.AddSend(Packets.NPCFinish());
                                    }
                                    break;
                                }
                            #endregion
i didn't test this code. It should work though.
06/05/2010 10:46 masternek#5
it worked! you are awesome! thank you so much :)

by the way.. i have a last question... how can i make an item talk? like... open a dialogue
06/05/2010 10:50 MonstersAbroad#6
Like the boxes in lady luck ?

Give the NPC the mesh of the weapon.
06/05/2010 10:54 masternek#7
item name: DragonPot

item id: 710868

i dont know if its like the boxes, in my server, the boxes dont talk xD
06/05/2010 11:59 Arcо#8
Code:
                    Char.MyClient.DialogNPC = 666111;
                    PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
                    Char.MyClient.EndSend();
Should be able to make do with that.
Just remember you need to add an npc entry in npcdialog.cs and npcs.txt
06/05/2010 14:51 masternek#9
thx, arco, but where do i put this code?

Char.MyClient.DialogNPC = 666111;
PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
Char.MyClient.EndSend();

i put in packet.cs?

help? o.O
06/05/2010 16:55 .Summer#10
u put in command, npccontrol, whereever you want it to send it from.
06/05/2010 18:25 masternek#11
a lil guide please? xD
06/05/2010 18:55 masternek#12
so...?
06/05/2010 19:34 .Summer#13
When do you want it to come up?
06/05/2010 20:46 dragon89928#14
using arco's example, when an event that you want to happen is triggered and you want to send the box you would go:

Code:
bool someEventIsTriggered = true;
if (someEventIsTriggered){
	foreach(Game.Character Char in Game.World.H_Chars){
	Char.MyClient.DialogNPC = 666111;
	PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
	Char.MyClient.EndSend();
	}
}
06/05/2010 21:10 Arcо#15
Was hoping you'd be able to learn from what I gave you...
Guess not.
Btw stop double posting.
In character.cs with using items.
case 710868:
Char.MyClient.DialogNPC = 666111;
PacketHandling.NPCDialog.Handle(Char.MyClient, null, 666111, 0);
Char.MyClient.EndSend();
break;