• 0
Sign in to follow this  
kayko11

Random Box/Egg Function Script

Question

Posted (edited)
function	script	box____	{
	setarray [email protected],  14003, 100,
						14003, 100,
						12914, 100,
						12914, 100,
						12913, 100,
						12913, 100,
						12900, 100,
						12900, 100,
						13990, 100,
						13990, 100,
						14158, 100,
						14158, 100,
						12909, 100,
						12909, 100,
						14004, 100,
						14004, 100,
						12221, 100,
						12221, 100,
						7776, 100,
						7776, 100,
						12213, 15,
						6320, 15,
						19599, 3,
						20221, 3,
						19952, 3,
						19664, 3,
						19954, 3,
						20313, 3,
						19589, 3,
						19596, 3;
						
	set [email protected], getarraysize( [email protected] );
	for( set [email protected], 1; [email protected] < [email protected]; [email protected] += 2 ) {
		[email protected][[email protected]] = [email protected] + [email protected][[email protected]];
		[email protected] += [email protected][[email protected]];
	}
	[email protected] = rand( [email protected] +1 );
	for( set [email protected], 1; [email protected] < [email protected]; [email protected] += 2 )
		if( [email protected][[email protected]] > [email protected] )
			break;
	getitem [email protected][ [email protected] ], 1;
	end;
}

How can I make the 3% chance to be announced in all maps?

and >=15% there will be no announcement.

Edited by kayko11

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0
Posted (edited)
1 hour ago, crazyarashi said:

 

 Thank you @crazyarashi can you double check if the code I edited if it is correct?

function	script	box____	{
	setarray .i1[1],14003,14003,12914,12914,12913,12913,12900,12900,13990,13990,14158,14158,12909,12909,14004,14004,12221,12221,7776,7776; // Common Items
	set .i1rand,rand(1,20); // Randomize Common Items; just change max amount if you add items
	setarray .i2[1],12213,6320; // Rare Items
	set .i2rand,rand(1,2); // Randomize Rare Items; just change max amount if you add items
	setarray .i3[1],19599,20221,19952,19664,19954,20313,19589,19596; // Super Rare Items
	set .i3rand,rand(1,8); //Randomize Super Rare Items; just change max amount if you add items
	set .chance, rand(100);

		// Super Rare Item 3%
		if (.chance == 3){
		getitem .i3[.i3rand],1;
		announce "["+strcharinfo(0)+"] won a ["+getitemname(.i3[.i3rand])+"] from the Lucky Egg.",0;
		end;
		} 

		// Rare Item 15%
		else if (.chance == 15){
		getitem .i2[.i2rand],1;
		announce "["+strcharinfo(0)+"] won a ["+getitemname(.i2[.i2rand])+"] from the Lucky Egg.",0;
		end;
		} 

		// Common Items
		else {
		getitem .i1[.i1rand],1;
		end; 
		}
}

 

Edited by kayko11

Share this post


Link to post
Share on other sites
  • 0

You should replace

if (.chance == 3){

with

if (.chance < 3){

and

else if (.chance == 15){

with

else if (.chance < 15){

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this