Jump to content
  • 0

Pet eggs through an item group


Dori

Question


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  332
  • Reputation:   15
  • Joined:  12/11/11
  • Last Seen:  

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?

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

Have you tried to use makepet + callfunc F_Rand /?

Never use getitem on pet eggs /!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  332
  • Reputation:   15
  • Joined:  12/11/11
  • Last Seen:  

Could you please  show me how its done with a small example? because I also need to put a rate for these eggs.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  81
  • Topics Per Day:  0.02
  • Content Count:  1654
  • Reputation:   583
  • Joined:  08/09/12
  • Last Seen:  

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.";
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  105
  • Topics Per Day:  0.02
  • Content Count:  332
  • Reputation:   15
  • Joined:  12/11/11
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

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 by Kurofly
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  1443
  • Reputation:   337
  • Joined:  10/17/12
  • Last Seen:  

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

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   31
  • Joined:  07/08/14
  • Last Seen:  

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 by Kurofly
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...