Dori Posted May 24, 2015 Posted May 24, 2015 Hi, The pets in my server are obtained through a usable item box. The box gives random pet eggs using an item group in item_package.txt I receive the eggs from the box fine, the problem is when hatching the eggs break. Is there a way to fix this problem? If this cannot be fixed, is there away to do this somehow through a script and still keep the box item? Quote
nanakiwurtz Posted May 24, 2015 Posted May 24, 2015 Have you tried to use makepet + callfunc F_Rand Never use getitem on pet eggs Quote
Dori Posted May 24, 2015 Author Posted May 24, 2015 Could you please show me how its done with a small example? because I also need to put a rate for these eggs. Quote
nanakiwurtz Posted May 24, 2015 Posted May 24, 2015 If egg A chance = 0.01%, egg B = 0.5%, egg C = 20% .@i = rand(1,10000); if (.@i==1) makepet 1002; else if (.@i>=2 && .@i<=6) makepet 1003; else if (.@i>=7 && .@i<=2007) makepet 1004; else dispbottom "You are not lucky today."; Quote
Dori Posted May 24, 2015 Author Posted May 24, 2015 This way seems really annoying to do for over 500 pets.. Isn't there away to fix getitem issue for pet eggs? cuz long time ago I used the exact same method for my pet eggs (through a box) and worked like a charm. And back then pet eggs would break when hatching if the eggs were dropped by monsters, but that issue seems fixed now. It would be much better if I could fix this through src, would you know anything about how to fix it through src? Quote
Stolao Posted May 24, 2015 Posted May 24, 2015 This way seems really annoying to do for over 500 pets.. Isn't there away to fix getitem issue for pet eggs? cuz long time ago I used the exact same method for my pet eggs (through a box) and worked like a charm. And back then pet eggs would break when hatching if the eggs were dropped by monsters, but that issue seems fixed now. It would be much better if I could fix this through src, would you know anything about how to fix it through src? This way seems really annoying to do for over 500 pets.. Isn't there away to fix getitem issue for pet eggs? cuz long time ago I used the exact same method for my pet eggs (through a box) and worked like a charm. And back then pet eggs would break when hatching if the eggs were dropped by monsters, but that issue seems fixed now. It would be much better if I could fix this through src, would you know anything about how to fix it through src? try using a callfunc like switch(rand(7)){ case 0: makeegg rand(1001,1030); break; case 1: makeegg rand(1051,1097); break; case 2: makeegg rand(1101,1144); break; case 3: makeegg rand(1151,1222); break; case 4: makeegg rand(1341,1650); break; case 5: makeegg rand(1674,1730); break; case 6: makeegg rand(1777,1930); break; } using each case for the gaps between pet ids this wouldn't take more then 15 mins to code Quote
Kurofly Posted May 24, 2015 Posted May 24, 2015 (edited) Why don't you make a function similar to getrandgroup item? function script GetRandEgg { attachrid (getarg(0)); setarray .@PetEggId , 1002,1113,1131; setarray .@PetEggChance , 100,100,100; for (.@i = 0 ; .@i < getarraysize(.@PetEggChance) ; .@i++) .@total += .@PetEggChance[.@i]; .@rand = rand(.@total); for (.@i = 0 ; .@i < getarraysize(.@PetEggChance) ; .@i++) { if (.@rand < .@PetEggChance[.@i]) { makepet .@PetEggId[.@i] ; end;} .@rand -= .@PetEggChance[.@i]; } } //in you item script >> callfunc "GetRandEgg",getcharid(3,strcharinfo(0)); You just have to edit the '.@PetEggId' and '.@PetEggChance' arrays using the same way as getrandgroupitem Edited May 24, 2015 by Kurofly Quote
Stolao Posted May 24, 2015 Posted May 24, 2015 Why don't you make a function similar to getrandgroup item? function script GetRandEgg { attachrid (getarg(0)); setarray .@PetEggId , 1002,1113,1131; setarray .@PetEggChance , 100,100,100; for (.@i = 0 ; .@i < getarraysize(.@PetEggChance) ; .@i++) .@total += .@PetEggChance[.@i]; .@rand = rand(.@total); for (.@i = 0 ; .@i < getarraysize(.@PetEggChance) ; .@i++) { if (.@rand < .@PetEggChance[.@i]) { makepet .@PetEggId[.@i] ; end;} .@rand -= .@PetEggChance[.@i]; } } //in you item script >> callfunc "GetRandEgg",getcharid(3,strcharinfo(0)); You just have to edit the '.@PetEggId' and '.@PetEggChance' arrays using the same way as getrandgroupitem he said he had over 500 entries rA still has the 128 data limit for arrays Quote
Kurofly Posted May 24, 2015 Posted May 24, 2015 (edited) Oh yeah you're right. function script GetRandEgg { attachrid (getarg(0)); setarray .@PetEggId1 , 1002,1113,1131; setarray .@PetEggChance1 , 100,100,100; setarray .@PetEggId2 , 1002,1113,1131; setarray .@PetEggChance2 , 100,100,100; .@n = 1; while (getd(".@PetEggId"+.@n)) { for (.@i = 0 ; .@i < getarraysize(getd(".@PetEggChance"+.@n)) ; .@i++) .@total = .@total + getd(".@PetEggChance"+.@n+"["+.@i+"]"); .@n++; } .@rand = rand(.@total);debugmes ""+.@total; .@n = 1; while (getd(".@PetEggId"+.@n)) { for (.@i = 0 ; .@i < getarraysize(getd(".@PetEggChance"+.@n)) ; .@i++) { if (.@rand < getd(".@PetEggChance"+.@n+"["+.@i+"]")) { makepet getd(".@PetEggId"+.@n+"["+.@i+"]") ; end;} .@rand = .@rand - getd(".@PetEggChance"+.@n+"["+.@i+"]"); } .@n++; } } //in your item script >> callfunc "GetRandEgg",getcharid(3,strcharinfo(0)); Edited May 24, 2015 by Kurofly Quote
Question
Dori
Hi,
The pets in my server are obtained through a usable item box. The box gives random pet eggs using an item group in item_package.txt
I receive the eggs from the box fine, the problem is when hatching the eggs break.
Is there a way to fix this problem?
If this cannot be fixed, is there away to do this somehow through a script and still keep the box item?
8 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.