[Release] Lotto

05/29/2009 23:11 Epic-Chaos#1
Koio did most of this code credits to him not me, also place this into NpcTalk.cs in CoEmu source.



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;
                    }
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.
05/29/2009 23:21 araXis#2
EpicChaos* im a new c# user.can u send me ur NpcTalk.cs ? i cant put this code, i dont know how to know edit this.
05/29/2009 23:31 kinshi88#3
Only make the code once, and just add
Code:
case 925:
case 926:
...
{
    // Code...
}
05/29/2009 23:32 Epic-Chaos#4
Quote:
Originally Posted by kinshi88 View Post
Only make the code once, and just add
Code:
case 925:
case 926:
...
{
    // Code...
}
thanks ill edit that.
05/29/2009 23:48 Kiyono#5
For some reason I win a lot of normal items...
05/30/2009 00:02 © Haydz#6
Quote:
Originally Posted by kinshi88 View Post
Only make the code once, and just add
Code:
case 925:
case 926:
...
{
    // Code...
}
Actually the best option, instead of all that long code

if (NPCDIALOGNUMBEROWHATEVERHERE >= 926 && <= 945)
{
}
05/30/2009 02:14 scottdavey#7
Quote:
Originally Posted by © Haydz View Post
Actually the best option, instead of all that long code

if (NPCDIALOGNUMBEROWHATEVERHERE >= 926 && <= 945)
{
}
Which is slower when checking through like 1000 npcs..
05/30/2009 02:28 © Haydz#8
Quote:
Originally Posted by scottdavey View Post
Which is slower when checking through like 1000 npcs..
far from it. its one If check on an id range of about 20.
insert that before the switch block, then return if it is.

We had a discussion on IF statements vs switch blocks. you must've missed it.
05/30/2009 02:31 Ultimatum#9
looks ok, if a varible value check can be mowed down to one-two ifs, then go for it, otherwise use switches.
05/30/2009 05:17 xXVamXx#10
Nice release koio and Epic
:)
05/30/2009 11:27 gad-legion#11
i see no code for quality of items in there so that means prob u can get a normal item from lottery and u better put lady luck on x 212 y 188 and coord for box teleport on x 215 y 190 :))
05/30/2009 11:53 Kiyono#12
Quote:
Originally Posted by gad-legion View Post
i see no code for quality of items in there so that means prob u can get a normal item from lottery and u better put lady luck on x 212 y 188 and coord for box teleport on x 215 y 190 :))
Well I've also won Ref/Uni/Eli/Sup items.
05/30/2009 12:37 koio#13
with the code you will win all kind of items (Normal Super Elite ...) equipment or mets ...
05/30/2009 12:44 Kiyono#14
Quote:
Originally Posted by koio View Post
with the code you will win all kind of items (Normal Super Elite ...) equipment or mets ...
You misspelled LOTF in your siggy.
05/30/2009 17:06 scottdavey#15
Quote:
Originally Posted by © Haydz View Post
far from it. its one If check on an id range of about 20.
insert that before the switch block, then return if it is.

We had a discussion on IF statements vs switch blocks. you must've missed it.
Perhaps, i go out with friends. Unlike alot of people on this forum.