Koio did most of this code credits to him not me, also place this into NpcTalk.cs in CoEmu source.
EDITED- better coded thxs to Kinshi
This needs improveing if you can improve it please let me know. and if i improve it i will update everything.
Code:
case 926://Lucky Box Coded by koio and alil by Epic-Chaos
case 925:
case 927:
case 928:
case 929:
case 930:
case 931:
case 932:
case 933:
case 934:
case 935:
case 936:
case 937:
case 938:
case 939:
case 940:
case 942:
case 943:
case 944:
case 945:
{
if (LinkBack == 0)
{
Text("Hi i am the Lucky Box. Tick me in order to get a random item", CSocket);
Link("I Will do it.", 1, CSocket);
Link("Nah No thanks!!", 255, CSocket);
End(CSocket);
}
if (LinkBack == 1)
{
Teleport(1036, 206, 213, 0, CSocket);
{
bool agien = true;
int pluss = 0;
while (agien)
{
int Times = 1;
for (int i = 0; i < Times; i++)
{
int lottoitem = Nano.Rand.Next(1, 10);
if (Calculation.PercentSuccess(90))
lottoitem = Nano.Rand.Next(2, 240);
if (Calculation.PercentSuccess(70))
lottoitem = Nano.Rand.Next(60, 3000);
if (Calculation.PercentSuccess(50))
lottoitem = Nano.Rand.Next(200, 4000);
if (Calculation.PercentSuccess(30))
lottoitem = Nano.Rand.Next(1000, 30000);
if (Calculation.PercentSuccess(100))
lottoitem = Nano.Rand.Next(2000, 50000);
if (Calculation.PercentSuccess(100))
lottoitem = Nano.Rand.Next(2000, 50000);
if (lottoitem < 100000)
lottoitem = lottoitem * 11;
if (Nano.Items.ContainsKey(lottoitem))
{
#region new item
Struct.ItemInfo Item = new Struct.ItemInfo();
Item.Bless = 0;
Item.Dura = Item.MaxDura;
Item.Enchant = 0;
Item.ItemID = lottoitem;
Item.Plus = pluss;
Item.Position = 0;
Item.Soc1 = 0;
Item.Soc2 = 0;
Item.Color = 0;
Item.UID = Nano.Rand.Next(1, 9999999);
bool created = Database.Database.NewItem(Item, CSocket);
while (!created)
{
Item.UID = Nano.Rand.Next(1, 9999999);
created = Database.Database.NewItem(Item, CSocket);
}
CSocket.Client.Inventory.Add(Item.UID, Item);
CSocket.Send(ConquerPacket.ItemInfo(Item.UID, Item.ItemID, Item.Plus, Item.Bless, Item.Enchant, Item.Soc1, Item.Soc2, Item.Dura, Item.MaxDura, Item.Position, Item.Color));
{
}
#endregion
agien = false;
}
}
}
}
}
break;
}
This needs improveing if you can improve it please let me know. and if i improve it i will update everything.