Jump to content
  • 0

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


ItsFree

Question


  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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
			.@winNum = rand(4);	//5 prizes to choose from (0-4)
			if(.@winNum == 0){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 1){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 2){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 3){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

nice working now just 2 things:

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

			if(.@winNum == 5){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 6){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 7){ getitem <PRIZE_ID>,1; }
			if(.@winNum == 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
 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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

			.@winNum = 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)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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:

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

Do you understand this example?

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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
			.@winNum = rand(99);  //100
			if (.@winNum >= 0 && .@winNum <= 4) { getitem <PRIZE_ID>,1; } //5% chance
			if (.@winNum >= 5 && .@winNum <= 9) { getitem <PRIZE_ID>,1; } //5% chance
			if (.@winNum >= 10 && .@winNum <= 19) { getitem <PRIZE_ID>,1; } //10% chance
			if (.@winNum >= 20 && .@winNum <= 29) { getitem <PRIZE_ID>,1; } //10% chance
			if (.@winNum >= 30 && .@winNum <= 49) { getitem <PRIZE_ID>,1; } //20% chance
			if (.@winNum >= 50 && .@winNum <= 99) { getitem <PRIZE_ID>,1; } //50% chance
			else { debugmes "[GamblerNPC] "+strcharinfo(0)+" is a hacker!!"; }
			mes "Congrats!";
			close;
		}
	}
}


 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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

 

if (.@winNum >= 0 && .@winNum <= 4)

but i dont get it 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  75
  • Reputation:   7
  • Joined:  08/10/17
  • Last Seen:  

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 (.@winNum >= 0 && .@winNum <= 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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

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