Jump to content
  • 0
ItsFree

R> a NPC that change "YPoints" to x1 Random Item [Solved]

Question

Hi, rAthena Comunity yeah i know that this request can be maybe solve making a custom box (yep i know how do it) but the problem is that the custom box dont set the ammount :/ what i want is like a "gambler" or something like that i try to find some of them yeah i found some but got some errores or didnt work like i want... anyyway this is what i want:

The player change 1 point to a "try" the try can give you x1 red pot, x2 red pot, x10 red pot, x5 blue pot, x3 green pots.... etc in short words...

x1 point ==> X Item with Y Ammount.

Thx! if need more information tell me, also gonna edit trying to add examples what i wanted to help to have an idea~
 


is like this but maybe on "reverse" x1 point for a random item with X amount.

Edited by ItsFree

Share this post


Link to post
Share on other sites

12 answers to this question

Recommended Posts

  • 0
22 minutes ago, ItsFree said:

the "point" can be get it from other npc for "point" you can use cashpoints i guess is an example what i mean for "point" ><

MAP,X,Y,Z	script	GamblerNPC::spiritD	400,{

	if(#CASHPOINTS == 0){
		mes "You don't have enough points";
		close;
	}
	if(#CASHPOINTS > 0){
		mes "You have "+#CASHPOINTS+" cash points.";
		mes "One roll costs 1 cash point.";
		mes "Would you like to roll?";
		switch(select("No thanks:Yes please")){
		case 1:
			close;
		case 2:
			#CASHPOINTS--;		//subtract CASHPOINTS by 1
			[email protected] = rand(4);	//5 prizes to choose from (0-4)
			if([email protected] == 0){ getitem <PRIZE_ID>,1; }
			if([email protected] == 1){ getitem <PRIZE_ID>,1; }
			if([email protected] == 2){ getitem <PRIZE_ID>,1; }
			if([email protected] == 3){ getitem <PRIZE_ID>,1; }
			if([email protected] == 4){ getitem <PRIZE_ID>,1; }
			else { debugmes "[GamblerNPC] "+strcharinfo(0)+" is a hacker!!"; }
			mes "Congrats!";
			close;
		}
	}
}

Fill in your own NPC coordinates and prizes /no1

Share this post


Link to post
Share on other sites
  • 0

I can do this but:

16 minutes ago, ItsFree said:

The player change 1 point

What is the point? what should I take away from the player to give them a try?

Share this post


Link to post
Share on other sites
  • 0

the "point" can be get it from other npc for "point" you can use cashpoints i guess is an example what i mean for "point" ><

Share this post


Link to post
Share on other sites
  • 0

nice working now just 2 things:

1.- to add more is just add more...
 

			if([email protected] == 5){ getitem <PRIZE_ID>,1; }
			if([email protected] == 6){ getitem <PRIZE_ID>,1; }
			if([email protected] == 7){ getitem <PRIZE_ID>,1; }
			if([email protected] == 8){ getitem <PRIZE_ID>,1; }

just that or have to edit something else ¿?

2.- is there a way to add a "percent" about each item ¿? i mean to controll it and set all different % percent just like a custom box...

Thx! <3
 

Share this post


Link to post
Share on other sites
  • 0
4 minutes ago, ItsFree said:

just that or have to edit something else ¿?

you have it correct but there is one more thing to edit

			[email protected] = rand(4);	//5 prizes to choose from (0-4)

make sure the number is ONE LESS than the max amount of prizes so if you have 8 prizes the number inside the rand(#) will be 7 (because zero counts as one!)

 

the percent would involve some tricky math but it's possible... like you want prize#1 to be rare, prize#2 to be uncommon, and all the rest be common? I could do that but you would have to set up all your prizes and what percent you want them (and they should add up to be 100% otherwise im gonna dunk you :P)

Share this post


Link to post
Share on other sites
  • 0

its ok i even if is more work "for me" set 1 by 1... its ok i'll do it, what i want is "between more controlable the percents better" what i want is 
something like <prize_id>,#amount,<percent> if possible...

Share this post


Link to post
Share on other sites
  • 0
6 minutes ago, ItsFree said:

its ok i even if is more work "for me" set 1 by 1... its ok i'll do it, what i want is "between more controlable the percents better" what i want is 
something like <prize_id>,#amount,<percent> if possible...

im sure there is a cleaner way to do this but this should work:

			[email protected] = rand(99);  //100
			if ([email protected] >= 0 && [email protected] <= 4) { getitem <PRIZE_ID>,1; } //5% chance
			if ([email protected] >= 5 && [email protected] <= 9) { getitem <PRIZE_ID>,1; } //5% chance
			if ([email protected] >= 10 && [email protected] <= 19) { getitem <PRIZE_ID>,1; } //10% chance
			if ([email protected] >= 20 && [email protected] <= 29) { getitem <PRIZE_ID>,1; } //10% chance
			if ([email protected] >= 30 && [email protected] <= 49) { getitem <PRIZE_ID>,1; } //20% chance
			if ([email protected] >= 50 && [email protected] <= 99) { getitem <PRIZE_ID>,1; } //50% chance
			else { debugmes "[GamblerNPC] "+strcharinfo(0)+" is a hacker!!"; }

Do you understand this example?

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

not really about how to know what should i put to "configure" the percent of each one yeah if i copy&paste im sure will work but dont understand how edit it xD

the npc would be something like this i guess

 

prontera,145,171,5	script	GamblerNPC::spiritD	112,{

	if(#CASHPOINTS == 0){
		mes "You don't have enough points";
		close;
	}
	if(#CASHPOINTS > 0){
		mes "You have "+#CASHPOINTS+" cash points.";
		mes "One roll costs 1 cash point.";
		mes "Would you like to roll?";
		switch(select("No thanks:Yes please")){
		case 1:
			close;
		case 2:
			#CASHPOINTS--;		//subtract CASHPOINTS by 1
			[email protected] = rand(99);  //100
			if ([email protected] >= 0 && [email protected] <= 4) { getitem <PRIZE_ID>,1; } //5% chance
			if ([email protected] >= 5 && [email protected] <= 9) { getitem <PRIZE_ID>,1; } //5% chance
			if ([email protected] >= 10 && [email protected] <= 19) { getitem <PRIZE_ID>,1; } //10% chance
			if ([email protected] >= 20 && [email protected] <= 29) { getitem <PRIZE_ID>,1; } //10% chance
			if ([email protected] >= 30 && [email protected] <= 49) { getitem <PRIZE_ID>,1; } //20% chance
			if ([email protected] >= 50 && [email protected] <= 99) { getitem <PRIZE_ID>,1; } //50% chance
			else { debugmes "[GamblerNPC] "+strcharinfo(0)+" is a hacker!!"; }
			mes "Congrats!";
			close;
		}
	}
}


 

Share this post


Link to post
Share on other sites
  • 0
11 minutes ago, ItsFree said:

the npc would be something like this i guess

yes that is correct. If you want to create a list of items with quantities as well as the percentage they should be rewarded, I can configure the logic for you.

Share this post


Link to post
Share on other sites
  • 0
5 minutes ago, ItsFree said:

yeah i understand that the only thing i dont understand is how to set the percents >< i guess is something about this

if ([email protected] >= 0 && [email protected] <= 4)

but i dont get it 

https://www.mathsisfun.com/percentage.html

The script is saying if "winning Number" is greater than or equal to zero AND less than or equal to 4 (meaning 0-4) then you win a prize. Because there are 100 different numbers that are picked  randomly, therefore your chances to get numbers 0-4 is 5%

Edited by SpiritD
elaborated

Share this post


Link to post
Share on other sites
  • 0

oh seeing on that perspective ok now i get it (yeah i know maths... sometimes i just thinks would be more hard but now i see not, ok now i get it, thx!

  • Like 1

Share this post


Link to post
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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.