Jump to content
  • 0

R> getitem script with announce and adjustable chance on random items


kevinyrchua

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  52
  • Reputation:   0
  • Joined:  07/14/17
  • Last Seen:  

Hi all,

I need help on scripting for this scroll,

Whole Idea:
1. Scroll that gives 1 item from a pool of items (Let's say like OBB)
2. You can set the chance of the item of how high or low it could be selected. (Let's say like chance rate)
3. If the item produced is less than 5%, it would announce the name and item received.
 

What I've tried and done,
1. Used custom OBB function and it's rate, seems okay but not sure if it could announce the name and item received. (also it's equips are unidentified)
2. Tried Stolao's Custom function, but understanding it, it's weight over total weight, so I plan to make a 1% chance out of a 100, I need to add multiple items until 100 to get that chance rate. seems very messy from what I've understand, (please correct me if I'm wrong), also not sure if I can add announce function here.

*if anything goes, will use Stolao's script.

{ callfunc "F_RandWeight",501,1,502,1503,1,504,1; },{},{}

 

Need help here ?

30100,Freya's_Scroll,Freya's Scroll,2,20,,10,,,,,0xFFFFFFFF,63,2,,,,,,{NEED HELP SCRIPT HERE},{},{}
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  68
  • Reputation:   8
  • Joined:  05/12/20
  • Last Seen:  

Maybe something like:
 

function	script	Get_FreyaItems	{
	setarray .@items,501,502,1503,504;
	setarray .@chance,10,5,5,15;
	
	set .@rand,rand(1,getarraysize(.@items));
	if (rand(99) < .@chance[.@rand]){
		getitem .@items[.@rand],1;
		if (.@chance[.@rand] < 6) 
			announce "A rare item has been created",bc_all;
	}
	end;
}

Note: I have not tested this script
Note: This script means you can get no items also. If you want something that always give at least a item, the summ of all items chance must be 100. And this script has to be different.

Edited by buraquera
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  52
  • Reputation:   0
  • Joined:  07/14/17
  • Last Seen:  

10 hours ago, buraquera said:

Maybe something like:
 


function	script	Get_FreyaItems	{
	setarray .@items,501,502,1503,504;
	setarray .@chance,10,5,5,15;
	
	set .@rand,rand(1,getarraysize(.@items));
	if (rand(99) < .@chance[.@rand]){
		getitem .@items[.@rand],1;
		if (.@chance[.@rand] < 6) 
			announce "A rare item has been created",bc_all;
	}
	end;
}

Note: I have not tested this script
Note: This script means you can get no items also. If you want something that always give at least a item, the summ of all items chance must be 100. And this script has to be different.

Tried it and I think I like it, I think the chance is specified to the specific item /99. so whether you have a ton of item on the array, it still pero item chance. 

 

function	script	Get_FreyaItems	{
	setarray .@items,20727,31313,20316,5979,13810,13534,12909,14003,13758,502,1503,504;
	setarray .@chance,1,2,3,4,10,10,10,10,10,10,15,15; //Total of 100%
	
	set .@rand,rand(1,getarraysize(.@items));
	if (rand(99) < .@chance[.@rand]){
		getitem .@items[.@rand],1;
		if (.@chance[.@rand] < 6) 
			announce "A rare item has been created",bc_all;
	}
	end;
}

but still I get  nothing alot. so I'm thinking that it's item specific over a hundred. can you please guide me on how to show the character name and item name that was created on the announce?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  68
  • Reputation:   8
  • Joined:  05/12/20
  • Last Seen:  

18 hours ago, kevinyrchua said:

Tried it and I think I like it, I think the chance is specified to the specific item /99. so whether you have a ton of item on the array, it still pero item chance. 

 


function	script	Get_FreyaItems	{
	setarray .@items,20727,31313,20316,5979,13810,13534,12909,14003,13758,502,1503,504;
	setarray .@chance,1,2,3,4,10,10,10,10,10,10,15,15; //Total of 100%
	
	set .@rand,rand(1,getarraysize(.@items));
	if (rand(99) < .@chance[.@rand]){
		getitem .@items[.@rand],1;
		if (.@chance[.@rand] < 6) 
			announce "A rare item has been created",bc_all;
	}
	end;
}

but still I get  nothing alot. so I'm thinking that it's item specific over a hundred. can you please guide me on how to show the character name and item name that was created on the announce?

If you want to get 100% chance of get at least a item this code will not work.

Because it is working-> Select a random item of the list, and then calculate a chance of get this item, so in you code for ex. the item 20727 has a very little chance as it has 1/12 (total of itens) of chance to choose the item and then 1% of get the item. Its something like 0.1% in the end of get item 20727.

 

function	script	Get_FreyaItems	{
	// If the summ != 100, Junk item is activated and has the difference in chance (45% in this example)
	set .@junk, 512; // Apple
	setarray .@items,20727,31313,20316,5979,13810,13534,12909,14003;
	setarray .@chance[1],1,3,6,10,20,30,40,55; // The difference from the previous number is the chance. So Item 5979 has a (10-6 = 4%chance)
	
	set .@rand,rand(1,100);
	for (.@i =1; .@i <= getarraysize(.@chance); .@i++){
		if (.@rand <= .@chance[.@i]){
			getitem .@items[.@i-1];
			if ((.@chance[.@i]- .@chance[.@i-1])) <6)
				announce "A rare item has been created",bc_all;
			end;
		}
	}
	getitem .@junk,1; //Get apple
	end;
}

This is what you want. There any many ways of doing that. I just did it quickly, please try it and tell me.

If the summs is 100% so jun item will not be activated.

About showing character name and item name, CTRL+F this article *strcharinfo and *getitemname
https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

In fact, i really recommend you reading in full.

Srry poor english and please tell me if it works. 

Edited by buraquera
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  52
  • Reputation:   0
  • Joined:  07/14/17
  • Last Seen:  

@buraquera

sorry for the very very late reply, just been doing other things than this. so I tried the script but only gives the Junk.

please see the code i made.

 

function	script	Get_MysteryBox	{
	// If the summ != 100, Junk item is activated and has the difference in chance (45% in this example)
	set .@junk, 19578; // Apple
	setarray .@items,19543,19525,31171,19620,19527,19733,20057;
	setarray .@chance[1],1,10,25,40,55,70,95; // The difference from the previous number is the chance. So Item 5979 has a (10-6 = 4%chance)
	
	set .@rand,rand(1,100);
	for (.@i =1; .@i <= getarraysize(.@chance); .@i++){
		if (.@rand <= .@chance[.@i]){
			getitem .@items[.@i-1];
			if ((.@chance[.@i]- .@chance[.@i-1])) <6)
				announce "A rare item has been created",bc_all;
			end;
		}
	}
	getitem .@junk,1; //Get apple
	end;
}

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  68
  • Reputation:   8
  • Joined:  05/12/20
  • Last Seen:  

On 8/8/2020 at 6:06 PM, kevinyrchua said:

@buraquera

sorry for the very very late reply, just been doing other things than this. so I tried the script but only gives the Junk.

please see the code i made.

 


function	script	Get_MysteryBox	{
	// If the summ != 100, Junk item is activated and has the difference in chance (45% in this example)
	set .@junk, 19578; // Apple
	setarray .@items,19543,19525,31171,19620,19527,19733,20057;
	setarray .@chance[1],1,10,25,40,55,70,95; // The difference from the previous number is the chance. So Item 5979 has a (10-6 = 4%chance)
	
	set .@rand,rand(1,100);
	for (.@i =1; .@i <= getarraysize(.@chance); .@i++){
		if (.@rand <= .@chance[.@i]){
			getitem .@items[.@i-1];
			if ((.@chance[.@i]- .@chance[.@i-1])) <6)
				announce "A rare item has been created",bc_all;
			end;
		}
	}
	getitem .@junk,1; //Get apple
	end;
}

 

Always see you mapserv.bat to see whats the error. It was mostly syntax in that case. 
Ive tried this and its working:
 

function	script	Get_MysteryBox	{
	// If the summ != 100, Junk item is activated and has the difference in chance (45% in this example)
	set .@junk, 19578; // Apple
	setarray .@items,1154,1183,1160,7110,1136,1101,1516;
	setarray .@chance[1],1,10,25,40,55,70,95; // The difference from the previous number is the chance. So Item 5979 has a (10-6 = 4%chance)
	
	set .@rand,rand(1,100);
	for (.@i =1; .@i <= getarraysize(.@chance); .@i++){
		if (.@rand <= .@chance[.@i]){
			getitem .@items[.@i-1],1;
			if ((.@chance[.@i]- .@chance[.@i-1])<6)
				announce "A rare item has been created",bc_all;
			end;
		}
	}
}


 

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