• 0
Sign in to follow this  
spawnn

Chance items Box

Question

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

Share this post


Link to post
Share on other sites

9 answers to this question

Recommended Posts

  • 0
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

Share this post


Link to post
Share on other sites
  • 0
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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0
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.

Share this post


Link to post
Share on other sites
  • 0
On 2/10/2019 at 4:17 PM, Balfear said:

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

exemple plz

Share this post


Link to post
Share on other sites
  • 0
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

Share this post


Link to post
Share on other sites
  • 0
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)

 

Share this post


Link to post
Share on other sites
  • 0

Solved:

getitem @i[@i3rand],1;

for

getitem @i3[@i3rand],1;

and

getitem @i[@i2rand],1;

for

getitem @i2[@i2rand],1;

Thx! @utofaery

Share this post


Link to post
Share on other sites
  • 0
16 hours ago, spawnn said:

Thx! @utofaery

Don't just thank me...

Thank everyone been around lol...

I leech from everyone too...

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