Jump to content
  • 0

Chance items Box


Question

Posted (edited)
function	script	visualbox	{
	.@item = F_Rand(17041,17037,17043,17039,17038,17042,13999,12922,13996,7715,12103,674,28370,6239,6238,7712,7711,18849,2980,6235,6231,6439,6438,16771,12623,6380,6423,12208,12902,);

	getitem .@item, 1;
	announce "["+strcharinfo(0)+"] Ganhou: ["+getitemname( .@item )+"("+.@item+")] da caixa visual.",0;
	return;
	}

Change chance items

Ids     

1% =  6438,6239,6439

 

 

Edited by spawnn

11 answers to this question

Recommended Posts

  • 0
Posted (edited)
On 2/12/2019 at 6:45 AM, spawnn said:

Not work, no gain items.

This method is easier comparing to recompiling lolz.  comparing to editing database .txt all around

and this method is fully changable to event script's need easily..(on the fly changes)

 

Sorry for the broken previous script but this script tested working in current rathena version.

Put this part inside your npc files.

function	script	F_RBox	{

	// change Item ID here
	setarray @i1[0],607,608; // Common Items 
	setarray @i2[0],512,513; // Rare Items
	setarray @i3[0],514,515; // Super Rare Items

	set @i1rand,rand( getarraysize(@i1) ); // Randomize Common Items; just change max amount if you add items
	set @i2rand,rand( getarraysize(@i2) ); // Randomize Rare Items; just change max amount if you add items
	set @i3rand,rand( getarraysize(@i3) ); //Randomize Super Rare Items; just change max amount if you add items

	.chance = rand(100);

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

		// Rare Item 10%
		else if (.chance <= 11 && .chance >= 1){
			getitem @i[@i2rand],1;
			announce "["+strcharinfo(0)+"] won a ["+getitemname(@i2[@i2rand])+"] from the Rare Item Box.",0;
			end;
		} 

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

Note : above script is to be inside any .txt which are loaded in your npc folder

https://www.google.com/search?q=rathena+adding+npc+script&amp;oq=rathena+adding+npc+script&amp;aqs=chrome..69i57j69i60l3.4790j0j1&amp;sourceid=chrome&amp;ie=UTF-8

 

Put this line in you Item Script.

callfunc("F_RBox");

https://github.com/rathena/rathena/wiki/Adding-a-Script

example:

617,Old_Violet_Box,Old Purple Box,2,10000,,200,,,,,0xFFFFFFFF,63,2,,,,,,{ callfunc ( "F_RBox" ) ; },{},{}

https://github.com/rathena/rathena/wiki/Custom-Items

 

 

 

Edited by utofaery
  • Upvote 1
  • 0
Posted (edited)
2 hours ago, spawnn said:

function	script	visualbox	{
	.@item = F_Rand(17041,17037,17043,17039,17038,17042,13999,12922,13996,7715,12103,674,28370,6239,6238,7712,7711,18849,2980,6235,6231,6439,6438,16771,12623,6380,6423,12208,12902,);

	getitem .@item, 1;
	announce "["+strcharinfo(0)+"] Ganhou: ["+getitemname( .@item )+"("+.@item+")] da caixa visual.",0;
	return;
	}

Change chance items

Ids     

1% =  6438,6239,6439

 

 

Why you don`t want use item_group "getgroupitem(IG_MyItemGroup);" with announce?

Edited by Balfear
  • 0
Posted

I did answer your question in another topic by giving you suggestion already,

This is the two line in the script to change item id and item chances if you need further help post here.
    setarray    .itemId ,     502, 678, 607 ,608 ,2101 ,1505 ,609;// Item List
    setarray    .iRates,    15, 16, 17, 18, 19, 20, 21; // seperated item rates or chances to get which item is higher than other item in the array

  • 0
Posted
On 2/10/2019 at 7:03 PM, utofaery said:

I did answer your question in another topic by giving you suggestion already,

This is the two line in the script to change item id and item chances if you need further help post here.
    setarray    .itemId ,     502, 678, 607 ,608 ,2101 ,1505 ,609;// Item List
    setarray    .iRates,    15, 16, 17, 18, 19, 20, 21; // seperated item rates or chances to get which item is higher than other item in the array

Not work, no gain items.

  • 0
Posted (edited)
10 hours ago, spawnn said:

exemple plz

db/import/item_package.txt
GroupID, ItemID, Rate{, Amount, Random, isAnnounced, Duration, GUID, isBound, isNamed}
add

// MyBox
IG_MyBox,501,1,1,1,1,0,0
IG_MyBox,502,1,1,1,1,0,0

src/map/itemdb.hpp

add to the end of this group "e_random_item_group"

enum e_random_item_group {
.........
..........
...........
	IG_MyBox,
};

script_constants.hpp
add after /* item groups */

	/* item groups */
.......
.........
...........
	export_constant(IG_MyBox);

getgroupitem <group_id>{,<identify>{,<char_id>}};
Add this to your box script:

getgroupitem IG_MyBox;

 

Edited by Balfear
  • Upvote 1
  • 0
Posted
21 minutes ago, utofaery said:

This method is easier comparing to recompiling lolz.  comparing to editing database .txt all around

and this method is fully changable to event script's need easily..(on the fly changes)

 

Sorry for the broken previous script but this script tested working in current rathena version.

Put this part inside your npc files.


function	script	F_RBox	{

	// change Item ID here
	setarray @i1[0],607,608; // Common Items 
	setarray @i2[0],512,513; // Rare Items
	setarray @i3[0],514,515; // Super Rare Items

	set @i1rand,rand( getarraysize(@i1) ); // Randomize Common Items; just change max amount if you add items
	set @i2rand,rand( getarraysize(@i2) ); // Randomize Rare Items; just change max amount if you add items
	set @i3rand,rand( getarraysize(@i3) ); //Randomize Super Rare Items; just change max amount if you add items

	.chance = rand(100);

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

		// Rare Item 10%
		else if (.chance <= 11 && .chance >= 1){
			getitem @i[@i2rand],1;
			announce "["+strcharinfo(0)+"] won a ["+getitemname(@i2[@i2rand])+"] from the Rare Item Box.",0;
			end;
		} 

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

Note : above script is to be inside any .txt which are loaded in your npc folder

https://www.google.com/search?q=rathena+adding+npc+script&amp;oq=rathena+adding+npc+script&amp;aqs=chrome..69i57j69i60l3.4790j0j1&amp;sourceid=chrome&amp;ie=UTF-8

 

Put this line in you Item Script.

callfunc("F_RBox");

https://github.com/rathena/rathena/wiki/Adding-a-Script

example:

617,Old_Violet_Box,Old Purple Box,2,10000,,200,,,,,0xFFFFFFFF,63,2,,,,,,{ callfunc ( "F_RBox" ) ; },{},{}

https://github.com/rathena/rathena/wiki/Custom-Items

 

 

 

Error to gain super rare and rare.

[Error]: buildin_getitem: Nonexistant item 0 requested.
[Debug]: Source (NPC): FAKE_NPC (invisible/not on a map)

 

  • 0
Posted

@utofaery what if i wanted to have a specific amount of items, how can i do that?

On 2/13/2019 at 2:00 AM, utofaery said:

function script F_RBox { // change Item ID here setarray @i1[0],607,608; // Common Items setarray @i2[0],512,513; // Rare Items setarray @i3[0],514,515; // Super Rare Items set @i1rand,rand( getarraysize(@i1) ); // Randomize Common Items; just change max amount if you add items set @i2rand,rand( getarraysize(@i2) ); // Randomize Rare Items; just change max amount if you add items set @i3rand,rand( getarraysize(@i3) ); //Randomize Super Rare Items; just change max amount if you add items .chance = rand(100); // Super Rare Item 1% if (.chance == 1) { getitem @i[@i3rand],1; announce "["+strcharinfo(0)+"] won a ["+getitemname(@i3[@i3rand])+"] from the Super Rare Box.",0; end; } // Rare Item 10% else if (.chance <= 11 && .chance >= 1){ getitem @i[@i2rand],1; announce "["+strcharinfo(0)+"] won a ["+getitemname(@i2[@i2rand])+"] from the Rare Item Box.",0; end; }  // Common Items else { getitem @i1[@i1rand],1; end; } }

 

  • 0
Posted
On 2/12/2019 at 2:00 PM, utofaery said:

This method is easier comparing to recompiling lolz.  comparing to editing database .txt all around

and this method is fully changable to event script's need easily..(on the fly changes)

 

Sorry for the broken previous script but this script tested working in current rathena version.

Put this part inside your npc files.


function	script	F_RBox	{

	// change Item ID here
	setarray @i1[0],607,608; // Common Items 
	setarray @i2[0],512,513; // Rare Items
	setarray @i3[0],514,515; // Super Rare Items

	set @i1rand,rand( getarraysize(@i1) ); // Randomize Common Items; just change max amount if you add items
	set @i2rand,rand( getarraysize(@i2) ); // Randomize Rare Items; just change max amount if you add items
	set @i3rand,rand( getarraysize(@i3) ); //Randomize Super Rare Items; just change max amount if you add items

	.chance = rand(100);

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

		// Rare Item 10%
		else if (.chance <= 11 && .chance >= 1){
			getitem @i[@i2rand],1;
			announce "["+strcharinfo(0)+"] won a ["+getitemname(@i2[@i2rand])+"] from the Rare Item Box.",0;
			end;
		} 

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

Note : above script is to be inside any .txt which are loaded in your npc folder

https://www.google.com/search?q=rathena+adding+npc+script&amp;oq=rathena+adding+npc+script&amp;aqs=chrome..69i57j69i60l3.4790j0j1&amp;sourceid=chrome&amp;ie=UTF-8

 

Put this line in you Item Script.

callfunc("F_RBox");

https://github.com/rathena/rathena/wiki/Adding-a-Script

example:

617,Old_Violet_Box,Old Purple Box,2,10000,,200,,,,,0xFFFFFFFF,63,2,,,,,,{ callfunc ( "F_RBox" ) ; },{},{}

https://github.com/rathena/rathena/wiki/Custom-Items

 

 

 

@utofaery Hi! how can i add custom points? Ex. Pvp Points Hourly Points Cash Points

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...