Jump to content
  • 0

NPC Give Random Item


Dolphin86

Question


  • Group:  Members
  • Topic Count:  253
  • Topics Per Day:  0.06
  • Content Count:  701
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

hye i found this script while browsing rathena, and could someone modify the script to how many item player will get. example if they got some potions, instead just 1 potion, i wana it to be 10 depends on the configuration.

example : with 1 ticket player can get this items on list by random

1. 10 white potion

2. 30 blue potion

3. 5 Ygg berry

4. 1 pod

and the list goes on, as i can see the current script did put random at 10 which i assume was 10% chances? soo if i add 0.1 means 0.1% ?

Sorry had to re-edit this post since lots of ppl confused with my question.

thanks for help.

Spoiler
neko_isle,77,127,5	script	Gatcha	562,{
	if ( !countitem(.itemuse) ) {
		mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
		close;
	}
	delitem .itemuse, 1;
	.@r = rand(.totalchance);
	for ( .@i = 0; ( .@r -= .itemchance[.@i] ) >= 0; ++.@i );
	getitem .itemid[.@i], 1;
	end;
OnInit:
	.itemuse = 40022; // poring coin
	setarray .itemid, 501,502,503,504,505,506,507,508,509;
	setarray .itemchance, 10,10,10,10,3,10,10,10,10;
	for ( .@i = 0; .itemid[.@i]; ++.@i )
		.totalchance += .itemchance[.@i];
	end;
}

 

 

Edited by Dolphin86
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  255
  • Reputation:   232
  • Joined:  07/24/13
  • Last Seen:  

50 minutes ago, Dolphin86 said:

hye i found this script while browsing rathena, and could someone modify the script to how many item player will get. example if they got some potions, instead just 1 potion, i wana it to be 10 or 50 depends on the configuration.

thanks for help.

  Reveal hidden contents
neko_isle,77,127,5	script	Gatcha	562,{
	if ( !countitem(.itemuse) ) {
		mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
		close;
	}
	delitem .itemuse, 1;
	.@r = rand(.totalchance);
	for ( .@i = 0; ( .@r -= .itemchance[.@i] ) >= 0; ++.@i );
	getitem .itemid[.@i], 1;
	end;
OnInit:
	.itemuse = 40022; // poring coin
	setarray .itemid, 501,502,503,504,505,506,507,508,509;
	setarray .itemchance, 10,10,10,10,3,10,10,10,10;
	for ( .@i = 0; .itemid[.@i]; ++.@i )
		.totalchance += .itemchance[.@i];
	end;
}

 

 

I remembered the old Aegis chance system ?
 

Quote
neko_isle,77,127,5	script	Gatcha	562,{
	if ( !countitem(.itemuse) ) {
		mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
		close;
	}
	delitem .itemuse, 1;
	getitem .temp_array[rand(0, getarraysize(.temp_array))], 1;
	end;
	
	
OnInit:
	.itemuse = 40022; // poring coin
	setarray .itemid[0], 501,502,503,504,505,506,507,508,509;
	setarray .itemchance[0], 10,10,10,10,3,10,10,10,10;
	
	.@counter = 0;
	for(.@i = 0; .@i < getarraysize(.itemid); .@i++) {
		for(.@k = 0; .@k < .itemchance[.@i]; .@k++) {
			.temp_array[.@counter] = .itemid[.@i];
			.@counter++;
		}
	}
	end;
}

 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  253
  • Topics Per Day:  0.06
  • Content Count:  701
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

14 hours ago, Balfear said:

I remembered the old Aegis chance system ?
 

 

i have edited the question but sure i will google it now

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