Register for your free account! | Forgot your password?

You last visited: Today at 10:10

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Drop loop?

Discussion on Drop loop? within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
Drop loop?

hey guys, so last night i was working on my monster drop system and i found something that's kinda confused me.

so here is how i make my monsters drop the things i want them.

Code:
 #region GreenCobra ston drop 

            if (Name == "GreenCobra" || Name == "Protector" || Name == "GhostFinder" && ServerBase.Kernel.percentSuccess(15))
            {

                uint Uid = 0;
                byte type = (byte)ServerBase.Kernel.Random.Next(1, 5);
                switch (type)
                {
                    case 1: Uid = 727851; break;
                    case 2: Uid = 727851; break;
                    case 3: Uid = 727851; break;
                    case 4: Uid = 1458958; break;
                    case 5: Uid = 1458958; break;

                }

                if (Uid != 0)
                {
                    ushort X = Owner.X, Y = Owner.Y;
                    Game.Map Map = ServerBase.Kernel.Maps[Owner.MapID];
                    if (Map.SelectCoordonates(ref X, ref Y))
                    {
                        Network.GamePackets.FloorItem floorItem = new Network.GamePackets.FloorItem(true);
                        floorItem.Item = new Network.GamePackets.ConquerItem(true);
                        floorItem.Item.ID = Uid;
                        floorItem.Item.MaximDurability = floorItem.Item.Durability = 65535;
                        floorItem.Item.MobDropped = true;
                        floorItem.Item.StackSize = 1;
                        floorItem.Item.MaxStackSize = 65535;
                        floorItem.Item.UID = Network.GamePackets.ConquerItem.ItemUID.Next;
                        floorItem.ValueType = Network.GamePackets.FloorItem.FloorValueType.Item;
                        floorItem.ItemID = Uid;
                        floorItem.MapID = Owner.MapID;
                        floorItem.MapObjType = Game.MapObjectType.Item;
                        floorItem.X = X;
                        floorItem.Y = Y;
                        floorItem.Type = Network.GamePackets.FloorItem.Drop;
                        floorItem.OnFloor = Time32.Now;
                        floorItem.ItemColor = floorItem.Item.Color;
                        floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                        while (Map.Npcs.ContainsKey(floorItem.UID))
                            floorItem.UID = Network.GamePackets.FloorItem.FloorUID.Next;
                        Map.AddFloorItem(floorItem);
                        SendScreenSpawn(floorItem);
                    }
                }
            }
            #endregion

but somehow when i add more then 1 monster in this code , it start to loop. as you can see it says 15% only but when i kill the monster its 100% drop on all of them.

but if i make the code use only 1 monster not 3 it works fine.
LordGragen. is offline  
Old 04/13/2013, 17:25   #2
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Your logic is wrong...

You need to put all your OR code in brackets.

if pheasant AND chancesuccess

that means it has to be both

if pheasant OR turtledove AND chancesuccess

this means pheasants will give 100 percent droprates and turtledoves will give chancesuccess drop rate.


(turtledove OR pheasant OR robin) AND chancesuccess

that's what you're looking for
pro4never is offline  
Thanks
1 User
Old 04/13/2013, 17:41   #3
 
elite*gold: 0
Join Date: Sep 2012
Posts: 51
Received Thanks: 30
Quote:
Originally Posted by LordGragen. View Post
Code:
                byte type = (byte)ServerBase.Kernel.Random.Next(1, 5);
                switch (type)
                {
                    case 1: Uid = 727851; break;
                    case 2: Uid = 727851; break;
                    case 3: Uid = 727851; break;
                    case 4: Uid = 1458958; break;
                    case 5: Uid = 1458958; break;
                }
case 5 will never trigger, as you get a random less than 5, not including 5.
urgabel is offline  
Thanks
1 User
Old 04/13/2013, 18:24   #4
 
LordGragen.'s Avatar
 
elite*gold: 0
Join Date: Dec 2012
Posts: 606
Received Thanks: 67
thank you pro4never.

@urgabel thank you i didn't even notice that i just checked you where right.

when you get a bit of free time please do explain little more XD like what changes i may do to make it work. no need to give out codes if you don't want just clear words will put me in the right position.
LordGragen. is offline  
Old 04/13/2013, 18:33   #5
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314
&& binds more closely than ||

_tao4229_ is offline  
Old 04/13/2013, 19:39   #6
 
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,376
Quote:
Originally Posted by LordGragen. View Post
thank you pro4never.

@urgabel thank you i didn't even notice that i just checked you where right.

when you get a bit of free time please do explain little more XD like what changes i may do to make it work. no need to give out codes if you don't want just clear words will put me in the right position.
Tao already answered your question but here's a somewhat simplified version.

Think of it like in math.

1 + 10 * 5

In that case * takes precedence and the answer can be thought of as 1 + 50 because you perform the multiplication first. BEDMAS and all that random highschool math ****

Order of operations - Wikipedia, the free encyclopedia

The same is true of boolean operations with AND statements taking priority over OR statements. As such you have to put in your own brackets to force the logic to flow the way you want.

He already provided a link explaining it so I'll leave you to your reading ^^

if((mob.name == "Pheasant" || mob.name == "Turtledove") && chanceSuccess(15))
{
//run
}

That's what you're looking for in this case.
pro4never is offline  
Thanks
2 Users
Reply


Similar Threads Similar Threads
RappelzSro[Exp/350 SP/350 PT Exp/400 Gold Drop/100% Sox Item Drop/50% /100K Silk]
05/24/2012 - SRO PServer Advertising - 12 Replies
# Just Fixing Everything
Drop´s von der Sensi Truhe mit Doppel drop chance beeinflussbar?
12/28/2009 - Metin2 - 11 Replies
Allso ich hatte eine kleine diskusion mit meinem "Spielpartner". Er möchte do gerne Noch ein Giftschwert haben und meinte das er die Sensenmann Truhe öffnen möchte, weil er ja Doppel drop chance aus dem 90ger Metin bekommen habe... Ich hab dem nätürlich erklärt das es totaler unsinn ist, doch nun bin ich mir selber nicht mehr ganz sicher. Ist es wirklich möglich mit dem zusatz Item (egal aus dem Item-Shop oder gedropt) Doppel drop chance, die Rate zu erhöhe was "Gutes" Wie 75ger Waffen raus...
Agbot loop dosnt loop
10/18/2008 - Silkroad Online - 1 Replies
my agbot after i tele will go through the 20 sec wait then says in bot concle feature not available yet feature not available yet idk whats wrong



All times are GMT +2. The time now is 10:10.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2024 elitepvpers All Rights Reserved.