NPCDialog.cs cleaned abit and made the NPC's run faster,
Replace all your npcdialog.cs with this (Made warehouses work, and a few other npcs, added leave jail )
Removed CheckWarehouse Password because I will code a decent one later on.
Replace all your npcdialog.cs with this (Made warehouses work, and a few other npcs, added leave jail )
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using COEmulator.Game;
namespace COEmulator.PacketHandling
{
public class NPCDialog
{
static string ReadString(byte[] Data)
{
string Name = "";
for (int i = 14; i < 14 + Data[13]; i++)
Name += Convert.ToChar(Data[i]);
return Name;
}
static void Say(string Text, Main.GameClient GC)
{
GC.AddSend(Packets.NPCSay(Text));
}
static void Link(string Text, byte DialNR, Main.GameClient GC)
{
GC.AddSend(Packets.NPCLink(Text, DialNR));
}
static void End(ushort Face, Main.GameClient GC)
{
GC.AddSend(Packets.NPCSetFace(Face));
GC.AddSend(Packets.NPCFinish());
}
static void Teleport(ushort Map, ushort X, ushort Y, Main.GameClient GC)
{
GC.MyChar.Teleport(Map, X, Y);
}
public static void Handle(Main.GameClient GC, byte[] Data, uint NPC, byte Control)
{
Random Rnd = new Random();
try
{
if (Game.World.H_NPCs.Contains(NPC) || (NPC >= 6700 && NPC <= 6702) || (NPC == 12))
if (Control != 255)
{
Game.NPC N = (Game.NPC)Game.World.H_NPCs[NPC];
switch (NPC)
{
#region Leave TG
case 453001://Leave TG
{
switch (Control)
{
case 0:
{
Say("Do you want to leave?", GC);
Link("Yes.", 1, GC);
Link("Yes.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Game.Vector2 V = (Game.Vector2)Database.DefaultCoords[GC.MyChar.Loc.PreviousMap];
Teleport(GC.MyChar.Loc.PreviousMap, V.X, V.Y, GC);
break;
}
}
break;
}
#endregion
#region LeaveJail
case 42:
{
switch (Control)
{
case 0:
{
Say("Do you want to leave here?", GC);
Link("Yeah.", 1, GC);
Link("Just passing by.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
if (GC.MyChar.PKPoints <= 100)
{
Teleport(1002, 400, 400, GC);
}
else
{
Say("You must wait untill your PKPoints are below 100. Current PKPoints: " + GC.MyChar.PKPoints + ".", GC);
Link("Okay.", 255, GC);
End(N.Avatar, GC);
}
break;
}
}
break;
}
#endregion
#region LeaveGW
case 453002://Leave GW
{
switch (Control)
{
case 0:
{
Say("Do you want to go back to TwinCity?", GC);
Link("Yes please.", 1, GC);
Link("I'll stay.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Teleport(1002, 355, 337, GC);
break;
}
}
break;
}
#endregion
#region Enter Jail
case 43:
{
switch (Control)
{
case 0:
{
Say("What can I do for you?", GC);
Link("Visit the jail.", 1, GC);
Link("Just passing by.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Say("Give me 1000 silver, I will teleport you there. If your PK points are 100+, you will be put into the jail.", GC);
Link("I will pay", 2, GC);
Link("I will stay here.", 255, GC);
End(N.Avatar, GC);
break;
}
case 2:
{
if (GC.MyChar.Silvers >= 1000)
{
GC.MyChar.Silvers -= 1000;
Teleport(6000, 100, 100, GC);
}
else
{
Say("You do not have 1000 silvers.", GC);
Link("Ok.", 255, GC);
End(N.Avatar, GC);
}
break;
}
}
break;
}
#endregion
#region Enter Arena
case 10021:
{
switch (Control)
{
case 0:
{
Say("Do you want to enter the PKArena for an amount of 50 silvers?", GC);
Link("Hell Yea.", 1, GC);
Link("No Thanks.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
if (GC.MyChar.Silvers >= 50)
{
GC.MyChar.Silvers -= 50;
Teleport(1005, 51, 71, GC);
}
else
{
Say("You do not have enough silvers.", GC);
Link("I'll be back.", 255, GC);
End(N.Avatar, GC);
}
break;
}
}
break;
}
#endregion
#region Enter GW
case 380://Enter GW
{
switch (Control)
{
case 0:
{
Say("Do you want to enter the GuildWar?", GC);
Link("Yeah.", 1, GC);
Link("Not really.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Teleport(1038, 350, 350, GC);
break;
}
}
break;
}
#endregion
#region Enter TwinCity Mine
case 453006:
{
switch (Control)
{
case 0:
{
Say("Do you want to visit the mine?", GC);
Link("Yeah.", 1, GC);
Link("No.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Random EMine = new Random();
int Nr = EMine.Next(1, 4);
if (Nr == 1)
{
Say("Answer the correct question to enter.", GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
Link("Pick Me.", 3, GC);
End(N.Avatar, GC);
}
if (Nr == 2)
{
Say("Answer the correct question to enter.", GC);
Link("Don't Pick Me.", 2, GC);
Link("Pick me.", 3, GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
End(N.Avatar, GC);
}
if (Nr == 3)
{
Say("Answer the correct question to enter.", GC);
Link("Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 3, GC);
End(N.Avatar, GC);
}
if (Nr == 4)
{
Say("Answer the correct question to enter.", GC);
Link("Don't Pick Me.", 2, GC);
Link("Don't Pick Me.", 2, GC);
Link("Pick Me.", 3, GC);
Link("Don't Pick Me.", 2, GC);
End(N.Avatar, GC);
}
break;
}
case 2:
{
Say("You didn't pick the right one. Wonna try again?", GC);
Link("Yeah.", 1, GC);
Link("Nah.", 255, GC);
End(N.Avatar, GC);
break;
}
case 3:
{
Teleport(1028, 155, 95, GC);
break;
}
}
break;
}
#endregion
#region Clear INV
case 453007:
{
switch (Control)
{
case 0:
{
Say("I can clear your inventory for free.", GC);
Link("Clear it.", 1, GC);
Link("No thanks.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
foreach (Game.Item I in GC.MyChar.Inventory)
GC.AddSend(Packets.ItemPacket(I.UID, 0, 3));
GC.MyChar.Inventory = new ArrayList(40);
break;
}
}
break;
}
#endregion
#region Enter DesertCity
case 453008:
{
switch (Control)
{
case 0:
{
Say("Want to enter Desert Island?", GC);
Link("Yes.", 1, GC);
Link("Not really.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Teleport(1000, 973, 668, GC);
break;
}
}
break;
}
#endregion
#region WeaponSockets
case 453009:
{
switch (Control)
{
case 0:
{
Say("Do you want to make sockets in your weapon for free?", GC);
Link("Yea.", 1, GC);
Link("No.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
Game.Item I = GC.MyChar.Equips.RightHand;
if (I.ID != 0)
{
if (I.Soc1 == COEmulator.Game.Item.Gem.NoSocket)
{
GC.MyChar.EquipStats(4, false);
I.Soc1 = COEmulator.Game.Item.Gem.EmptySocket;
GC.MyChar.Equips.Replace(4, I, GC.MyChar);
GC.MyChar.EquipStats(4, true);
Say("Here you are.", GC);
Link("Thanks.", 255, GC);
End(N.Avatar, GC);
}
else if (I.Soc2 == COEmulator.Game.Item.Gem.NoSocket)
{
GC.MyChar.EquipStats(4, false);
I.Soc2 = COEmulator.Game.Item.Gem.EmptySocket;
GC.MyChar.Equips.Replace(4, I, GC.MyChar);
GC.MyChar.EquipStats(4, true);
Say("Here you are.", GC);
Link("Thanks.", 255, GC);
End(N.Avatar, GC);
}
else
{
Say("Socketing failed.", GC);
Link("I see.", 255, GC);
End(N.Avatar, GC);
}
}
break;
}
}
break;
}
#endregion
#region Enter TG
case 453010:
case 453011:
case 453012:
case 453013:
case 453014:
{
switch (Control)
{
case 0:
{
Say("I can send you into TG for 1000 silvers.", GC);
Link("Send me in.", 1, GC);
Link("Dont need.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
if (GC.MyChar.Silvers >= 1000)
{
GC.MyChar.Silvers -= 1000;
Teleport(1039, 300, 300, GC);
Say("Welcome to the training ground's.", GC);
Link("Thanks.", 255, GC);
End(N.Avatar, GC);
}
else
{
Say("You do not have enough silvers.", GC);
Link("I'll be back.", 255, GC);
End(N.Avatar, GC);
}
break;
}
}
break;
}
#endregion
#region WuxenOven
case 453016:
{
switch (Control)
{
case 0:
{
Say("What do you want?", GC);
Link("Compose.", 1, GC);
Link("Enchant.", 2, GC);
Link("Bless.", 3, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 1, N.Loc.X, N.Loc.Y, 0x7e));
break;
}
case 2:
{
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 0x443, GC.MyChar.Loc.X, GC.MyChar.Loc.Y, 116));
break;
}
case 3:
{
Say("It will cost you 10 TortoiseGem's each Bless you want to add in your equipments.", GC);
Say("The machine still needs to be done with repair, before I can start doing this again.", GC);
Link("Okay", 255, GC);
End(N.Avatar, GC);
break;
}
}
break;
}
#endregion
#region Warehouses
case 8:
case 10012:
case 10028:
case 10011:
case 10027:
case 44:
case 4101:
{
GC.LocalMessage(2000, "You have successfull opened your warehouse.");
GC.AddSend(Packets.GeneralData(GC.MyChar.EntityID, 4, N.Loc.X, N.Loc.Y, 0x7e));
break;
}
#endregion
#region CPAdmin
case 453024:
{
switch (Control)
{
case 0:
{
Say("I can exchange DB's to CPs", GC);
Link("Take my DragonBall.", 1, GC);
Link("Take my DragonBall Scroll", 2, GC);
Link("Just passing by.", 255, GC);
End(N.Avatar, GC);
break;
}
case 1:
{
if (GC.MyChar.InventoryContains(1088000, 1))
{
Game.Item DB = null;
foreach (Game.Item I in GC.MyChar.Inventory)
if (I.ID == 1088000)
{DB = I; break;}
if (DB != null)
{
GC.MyChar.CPs += 215;
GC.MyChar.RemoveItem(DB);
}
}
break;
}
case 2:
{
if (GC.MyChar.InventoryContains(720028, 1))
{
Game.Item DB = null;
foreach (Game.Item I in GC.MyChar.Inventory)
if (I.ID == 720028)
{DB = I; break;}
if (DB != null)
{
GC.MyChar.CPs += 2150;
GC.MyChar.RemoveItem(DB);
}
}
break;
}
}
break;
}
#endregion
default:
{
if (GC.MyChar.MyClient.AuthInfo.Status == "[PM]" || GC.MyChar.MyClient.AuthInfo.Status == "[GM]")
{
GC.LocalMessage(2000, "This NPC is not used. NPCID: " + NPC.ToString());
}
else
{
Say("Hello, I have no function for now.", GC);
Link("OK.", 255, GC);
if (N != null)
GC.AddSend(Packets.NPCSetFace(N.Avatar));
else
GC.AddSend(Packets.NPCSetFace(30));
GC.AddSend(Packets.NPCFinish());
}
break;
}
}
}
}
catch (Exception Exc) { Console.WriteLine(Exc); }
}
}
}