Jump to content
  • 0

Requesting NPC - require x to get y with fail chance


Question

Posted

Hi, I tried to make my own script for this NPC and failed miserably. I'd like to ask for a little help on this part.

What I need is an NPC that will ask players 100 Gold and 10m zeny to create one random castle drop. It will have at least 40% success rate.

 

Progressbar would be really appreciated and with accompanying upgrading/forging sound.
 

Thank you in advance :)

3 answers to this question

Recommended Posts

Posted

Maybe this will help you out enough with your script.

prontera,100,100,1	script	chance_get	101,{
	mes "[ Chancy ]";
	mes "Oh hello would you like to try my game?";
	next;
	if( select( "Yes:No" ) == 2 ) {
		mes "[ Chancy ]";
		mes "I'm sorry to hear that. Maybe next time then.";
		close;
	}
	mes "[ Chancy ]";
	if( countitem( .gold ) < .gold_amount ) {
		mes "You don't have enough "+getitemname( .gold )+".";
		mes "I require at least "+.gold_amount+".";
		close;
	} else if( Zeny < .zeny ) {
		mes "It looks like you don't have enough zeny...";
		mes "You need at least "+.zeny+".";
		close;
	}
	Zeny = Zeny - .zeny;
	delitem .gold, .gold_amount;
	if( rand( 101 ) <= .chance ) {
		.@rand = rand( .length );
		getitem .rewards[.@rand], .reward_amounts[.@rand];
		mes "Congratulations you got "+getitemname( .rewards[.@rand] )+" x"+.reward_amounts[.@rand]+"!!!";
	} else
		mes "I'm sorry you didn't get anything. Come back and try again!";
	close;
	
OnInit:
	.gold = 617;
	.gold_amount = 100;
	.zeny = 10000000;
	.chance = 40;
	setarray .rewards, 501, 502, 503, 504, 506;
	setarray .reward_amounts, 1, 1, 1, 2, 2;
	.length = getarraysize( .rewards );
}
  • Upvote 1

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...