Jump to content
  • 0

Doubt Initial items


Beret

Question


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   3
  • Joined:  06/19/12
  • Last Seen:  

I am creating an npc that gives items when you enter the server, but I have some questions how can I do, someone would know tell me.

 

- to have the item drop depend on chance

- Items with chance of 0.01 to 1 is made the announce.

 

 

prontera,150,105,4	script	 Itens	98,{

	setarray .@itens[0] "607","608","609","610","611","612";
	setarray .@qnt[0] "10","10","15","15","20","20";
	setarray .@chance$[0], "0.01","0.1","0.2","0.5","1","100";

	mes "[giveaway]";
	mes "Hello I am";
	mes "Selector that gives items";
	mes "very special, I would like to try his luck?";
	next;
	switch(select(try his luck:No thanks ")) {
	case 1:
		if (countitem (6040) > = 100 & & countitem (6075) > = 50 & & countitem (6080) > = 50 (6095) countitem & & > = 50 & & countitem (713) > = 1) {
		mes "[giveaway]";
		mes "I see that you have all items";
		delitem 6040.100;
		delitem 6075.50;
		delitem 6080.50;
		delitem 6095.50;
		delitem 713.1;
		getitem. @itens [.@i]. @qnt [.@i];,
                announce "the player ["+strcharinfo (0)+"] won 5 yggdrasil." .8;
		close;
	}
	case 2:
		mes "[giveaway]";
		mes "OK, come back when you want";
		close;
	}
}
Edited by Beret
Link to comment
Share on other sites

4 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  181
  • Reputation:   53
  • Joined:  04/07/13
  • Last Seen:  

Should the player get only one item from the list or are multiple items possible? If only one, it wouldn't make sense to put there an item with a chance of 100%.

 

This should work as you wanted.

 

prontera,150,105,4	script	 Items	98,{
	mes "[Gambler]";
	mes "Hello, I'm the gambler.";
	mes "If you bring me some items you can gamble for some pretty nice rewards.";
	switch(select("Gamble:Which items?:Which rewards?")) {
		next;
		case 1:
			for (.@i = 0; .@i < getarraysize(.required); .@i++) {
				if (countitem(.required[.@i]) >= .reqAmnt[.@i]) {
					.@enoughItems++;
				}
			}
			if (.@enoughItems != getarraysize(.required)) {
				mes "[Gambler]";
				mes "You don't have all the items I need.";
				mes "Please come back when you have everything.";
				close;
			}
			mes "[Gambler]";
			mes "So, you have everything.";
			mes "Are you sure you want to bet the items I want for one attempt to win a price?";
			if (select("Yes:No") == 2) {
				next;
				mes "[Gambler]";
				mes "Come back when you are ready.";
				close;
			}
			close2;
			for (.@i = 0; .@i < getarraysize(.required); .@i++) {
				delitem .required[.@i], .reqAmnt[.@i];
			}
			for (.@i = 0; .@i < getarraysize(.items); .@i++) {
				if (rand(1, 10000) <= .chances[.@i]) {
					if (.chances[.@i] <= .announceAt) {
						announce strcharinfo(0) + " has won " + .qnt[.@i] + "x " + getitemname(.items[.@i]) + "!",bc_all;
					}
					dispbottom "You have won " + .qnt[.@i] + "x " + getitemname(.items[.@i]) + "!";
					getitem .items[.@i], .qnt[.@i];
				}
			}
			end;
		case 2:
			mes "[Gambler]";
			mes "The items I need are those:";
			for (.@i = 0; .@i < getarraysize(.required); .@i++) {
				mes .reqAmnt[.@i] + "x " + getitemname(.required[.@i]) + " (ID: " + .required[.@i] + ")";
			}
			close;
			
		case 3:
			mes "[Gambler]";
			mes "The rewards can be a one or more of these:";
			for (.@i = 0; .@i < getarraysize(.items); .@i++) {
				mes .qnt[.@i] + "x " + getitemname(.items[.@i]) + " (ID: " + .items[.@i] + ")";
			}
			close;
	}
	next;
	
	OnInit:
		// announce if chance was lower or equal to ...
		.announceAt = 100;
	
		// Arrays for the rewards
		setarray .items, 607, 608, 609, 610, 611, 612;
		setarray .qnt,    10,  10,  15,  15,  20, 20;
		setarray .chances, 1,  10,  20,  50, 100, 10000;
		
		// Arrays for the required items
		setarray .required, 6040, 6075, 6080, 6095, 713;
		setarray .reqAmnt,   100,   50,   50,   50, 1;
}

 


 

Edited by DeadlySilence
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   3
  • Joined:  06/19/12
  • Last Seen:  

Should the player get only one item from the list or are multiple items possible? If only one, it wouldn't make sense to put there an item with a chance of 100%.

 

This should work as you wanted.

 

 

Thanks for replying DeadlySilence is earned only one item, added the 100 just for example, I will test and say if it worked. A doubt those chances configured 1 = 0.01?

 

:meow:

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  181
  • Reputation:   53
  • Joined:  04/07/13
  • Last Seen:  

Because rAthena scripts support only integers, I had to write the chances this way. It's correct: 1 = 0.01%, 10 = 0.1%, 100 = 1%, 1000 = 10%, 10000 = 100%.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  60
  • Topics Per Day:  0.01
  • Content Count:  174
  • Reputation:   3
  • Joined:  06/19/12
  • Last Seen:  

Thank you very much DeadlySilence it worked as I expected.

Edited by Beret
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...