Jump to content
  • 0

random option when opening a box for specific/random item


Question

Posted

so here is the script i made for specific item with a specific random option stats

//Test functions
function	script	F_CASH_SHOP_RANDOM	{
	setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS, RDMOPT_VAR_MAXHPAMOUNT;
	setarray .@OptVal[0],10,10;
	setarray .@OptParam[0],0,0;

	getitem3 5518,1,1,0,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;

end;
}

im figuring out how can i make it like random option for the "getitem3 5518"

and also random option if i want like random item box then when opened random option will be

put in the item

6 answers to this question

Recommended Posts

  • 0
Posted

BUMP to this post

 

here is the sample of the random item script for box i have

function	script	Costumes_R	{

	set .@Total,14;
	//<%>,<ItemID>,<Amount>	
	setarray .@P1[0],10,20764,1; //Fallen Angel Wing
	setarray .@P2[0],20,45008,1; //Flapping Angel Wing
	setarray .@P3[0],30,969,1; 	 //Gold
	setarray .@P4[0],30,7620,2;  //Enriched Oridecon
	setarray .@P5[0],30,7620,2;  //Enriched Elunium	
	setarray .@P6[0],70,7179,10; //Pods
	setarray .@P7[0],70,12259,2; //Miracle Medecine
	setarray .@P8[0],70,12684,10; //Speed Potion
	setarray .@P9[0],70,14586,5; //Spark Candy	
	setarray .@P10[0],70,16682,1; //Halter Box
	 
	setarray .@P11[0],90,12906,1; //Hwergelmir's Tonic
	setarray .@P12[0],90,12904,1; //Steamed Scorpion
	setarray .@P13[0],90,12903,1; //Steamed Tongue
	setarray .@P14[0],90,12908,1; //Immortal Stew
	
	setarray .@Default[0],45101,1; //Token Scrolls
	set .@i, rand(1,.@Total);
	if (rand(1,100) > getd(".@P"+.@i+"[0]"))
	{
		for(set .@j,0; .@j<getarraysize(.@Default); set .@j,.@j+2)
		{
			getitem .@Default[.@j], .@Default[.@j+1];
			if(!.@k[0])
				setarray .@k[0], .@Default[.@j], .@Default[.@j+1];
		}
	}
	else{
		for(set .@j,1; .@j<getarraysize(getd(".@P"+.@i)); set .@j,.@j+2)
		{
			getitem getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
			if (!.@k[0])
			{
				set .@gz,.@i;
				setarray .@k[0], getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
				break;
			}
		}
	}
	
	if(1<=.@gz&&.@gz<=9)
	announce ""+strcharinfo(0)+" has opened [Devil Scroll] and reward ["+getitemname(.@k[0])+" x "+.@k[1]+"]!",0;
	specialeffect2 251;
	end;
}

and what im trying to do is once i opened the box and got the item it has a random option in the item itself

RDMOPT_WEAPON_ATTR_TELEKINESIS, RDMOPT_VAR_MAXHPAMOUNT;

like this random option and more of this

 

thanks in advance i do really appreciate the help

  • 0
Posted
function	script	F_CASH_SHOP_RANDOM	{
	.@item_id = getarg(0);
	.@amount = getarg(1);
	
	setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS, RDMOPT_VAR_MAXHPAMOUNT;
	setarray .@OptVal[0],10,10;
	setarray .@OptParam[0],0,0;
	
	.@item_type = getiteminfo(.@item_id, ITEMINFO_TYPE);
	if (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON)
		getitem3 .@item_id,.@amount,1,0,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
	else
		getitem .@item_id,.@amount;
	return;
}
function	script	Costumes_R	{

	set .@Total,14;
	//<%>,<ItemID>,<Amount>	
	setarray .@P1[0],10,20764,1; //Fallen Angel Wing
	setarray .@P2[0],20,45008,1; //Flapping Angel Wing
	setarray .@P3[0],30,969,1; 	 //Gold
	setarray .@P4[0],30,7620,2;  //Enriched Oridecon
	setarray .@P5[0],30,7620,2;  //Enriched Elunium	
	setarray .@P6[0],70,7179,10; //Pods
	setarray .@P7[0],70,12259,2; //Miracle Medecine
	setarray .@P8[0],70,12684,10; //Speed Potion
	setarray .@P9[0],70,14586,5; //Spark Candy	
	setarray .@P10[0],70,16682,1; //Halter Box
	 
	setarray .@P11[0],90,12906,1; //Hwergelmir's Tonic
	setarray .@P12[0],90,12904,1; //Steamed Scorpion
	setarray .@P13[0],90,12903,1; //Steamed Tongue
	setarray .@P14[0],90,12908,1; //Immortal Stew
	
	setarray .@Default[0],45101,1; //Token Scrolls
	set .@i, rand(1,.@Total);
	if (rand(1,100) > getd(".@P"+.@i+"[0]"))
	{
		for(set .@j,0; .@j<getarraysize(.@Default); set .@j,.@j+2)
		{
			// getitem .@Default[.@j], .@Default[.@j+1];
			callfunc("F_CASH_SHOP_RANDOM", .@Default[.@j], .@Default[.@j+1]);
			if(!.@k[0])
				setarray .@k[0], .@Default[.@j], .@Default[.@j+1];
		}
	}
	else{
		for(set .@j,1; .@j<getarraysize(getd(".@P"+.@i)); set .@j,.@j+2)
		{
			// getitem getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
			callfunc("F_CASH_SHOP_RANDOM", getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]"));
			if (!.@k[0])
			{
				set .@gz,.@i;
				setarray .@k[0], getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
				break;
			}
		}
	}
	
	if(1<=.@gz&&.@gz<=9)
		announce ""+strcharinfo(0)+" has opened [Devil Scroll] and reward ["+getitemname(.@k[0])+" x "+.@k[1]+"]!",0;
	specialeffect2 251;
	end;
}

 

  • MVP 1
  • 0
Posted
11 hours ago, Emistry said:
function	script	F_CASH_SHOP_RANDOM	{
	.@item_id = getarg(0);
	.@amount = getarg(1);
	
	setarray .@OptID[0],RDMOPT_WEAPON_ATTR_TELEKINESIS, RDMOPT_VAR_MAXHPAMOUNT;
	setarray .@OptVal[0],10,10;
	setarray .@OptParam[0],0,0;
	
	.@item_type = getiteminfo(.@item_id, ITEMINFO_TYPE);
	if (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON)
		getitem3 .@item_id,.@amount,1,0,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
	else
		getitem .@item_id,.@amount;
	return;
}
function	script	Costumes_R	{

	set .@Total,14;
	//<%>,<ItemID>,<Amount>	
	setarray .@P1[0],10,20764,1; //Fallen Angel Wing
	setarray .@P2[0],20,45008,1; //Flapping Angel Wing
	setarray .@P3[0],30,969,1; 	 //Gold
	setarray .@P4[0],30,7620,2;  //Enriched Oridecon
	setarray .@P5[0],30,7620,2;  //Enriched Elunium	
	setarray .@P6[0],70,7179,10; //Pods
	setarray .@P7[0],70,12259,2; //Miracle Medecine
	setarray .@P8[0],70,12684,10; //Speed Potion
	setarray .@P9[0],70,14586,5; //Spark Candy	
	setarray .@P10[0],70,16682,1; //Halter Box
	 
	setarray .@P11[0],90,12906,1; //Hwergelmir's Tonic
	setarray .@P12[0],90,12904,1; //Steamed Scorpion
	setarray .@P13[0],90,12903,1; //Steamed Tongue
	setarray .@P14[0],90,12908,1; //Immortal Stew
	
	setarray .@Default[0],45101,1; //Token Scrolls
	set .@i, rand(1,.@Total);
	if (rand(1,100) > getd(".@P"+.@i+"[0]"))
	{
		for(set .@j,0; .@j<getarraysize(.@Default); set .@j,.@j+2)
		{
			// getitem .@Default[.@j], .@Default[.@j+1];
			callfunc("F_CASH_SHOP_RANDOM", .@Default[.@j], .@Default[.@j+1]);
			if(!.@k[0])
				setarray .@k[0], .@Default[.@j], .@Default[.@j+1];
		}
	}
	else{
		for(set .@j,1; .@j<getarraysize(getd(".@P"+.@i)); set .@j,.@j+2)
		{
			// getitem getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
			callfunc("F_CASH_SHOP_RANDOM", getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]"));
			if (!.@k[0])
			{
				set .@gz,.@i;
				setarray .@k[0], getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
				break;
			}
		}
	}
	
	if(1<=.@gz&&.@gz<=9)
		announce ""+strcharinfo(0)+" has opened [Devil Scroll] and reward ["+getitemname(.@k[0])+" x "+.@k[1]+"]!",0;
	specialeffect2 251;
	end;
}

 

ill try this one out thanks again ?❤️

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

Why not use item_group_db.yml
its already support to give you random option
image.png.779d8df192255ce77c941ae377878c68.png

the git version im using doesnt have this

im having problems using the latest rathena git

 

@LearningRO

but if i use the latest rathena git

what are the steps to add a custom Itemgroup?

do i need to go to the src and const.txt or any new method?

Edited by AinsLord
  • 0
Posted

BUMP to this post

sir @Emistry thanks definitely working however it doesnt give random option

it provides the option listed in the OptID variable

is it possible like getting 1 option then probably randomize 2 or 3 options?

function	script	Costumes_R	{

	set .@Total,2;
	//<%>,<ItemID>,<Amount>	
	setarray .@P1[0],100,33002,1; //Fallen Angel Wing
	setarray .@P2[0],20,33001,1; //Flapping Angel Wing
	
	setarray .@Default[0],1230,1; //Token Scrolls
	set .@i, rand(1,.@Total);
	if (rand(1,100) > getd(".@P"+.@i+"[0]"))
	{
		for(set .@j,0; .@j<getarraysize(.@Default); set .@j,.@j+2)
		{
			// getitem .@Default[.@j], .@Default[.@j+1];
			callfunc("F_CASH_SHOP_RANDOM", .@Default[.@j], .@Default[.@j+1]);
			if(!.@k[0])
				setarray .@k[0], .@Default[.@j], .@Default[.@j+1];
		}
	}
	else{
		for(set .@j,1; .@j<getarraysize(getd(".@P"+.@i)); set .@j,.@j+2)
		{
			// getitem getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
			callfunc("F_CASH_SHOP_RANDOM", getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]"));
			if (!.@k[0])
			{
				set .@gz,.@i;
				setarray .@k[0], getd(".@P"+.@i+"["+.@j+"]"), getd(".@P"+.@i+"["+(.@j+1)+"]");
				break;
			}
		}
	}
	
	if(1<=.@gz&&.@gz<=9)
		announce ""+strcharinfo(0)+" has opened [Devil Scroll] and reward ["+getitemname(.@k[0])+" x "+.@k[1]+"]!",0;
	specialeffect2 251;
	end;
}




function	script	F_CASH_SHOP_RANDOM	{
	.@item_id = getarg(0);
	.@amount = getarg(1);
	
	setarray .@OptID[0],
	RDMOPT_WEAPON_ATTR_TELEKINESIS,
	RDMOPT_VAR_MAXHPAMOUNT,
	RDMOPT_VAR_INTAMOUNT,
	RDMOPT_VAR_LUKAMOUNT;

	setarray .@OptVal[0],10,10,10,10;
	setarray .@OptParam[0],1,2,3,4;
	
	.@item_type = getiteminfo(.@item_id, ITEMINFO_TYPE);
	if (.@item_type == IT_ARMOR || .@item_type == IT_WEAPON)
		getitem3 .@item_id,.@amount,1,0,0,0,0,0,0,.@OptID,.@OptVal,.@OptParam;
	else
		getitem .@item_id,.@amount;
	return;
}

again sir thank you so much for the help ?❤️ 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...