Jump to content

Question

Posted

NPC that gives random cards for amount of 1m per roll  normal monster 100% chance and 10% chance for mini monster cards that i can add or remove cards thanks in advance

1 answer to this question

Recommended Posts

  • 0
Posted

I go that to my github.  but here is your request i added a boss chance too . The code is user friendly so you can customize it with your desire . If it helps make sure to up my response so other player will know that the post is solve

 

prontera,155,185,5	script	Random Card NPC	100,{
	.@zeny_cost = 1000000; // Zeny cost per roll
	.@normal_chance = 89; // Normal monster card chance (89%)
	.@mini_chance = 10; // Mini monster card chance (10%)
	.@boss_chance = 1; // Boss card chance (1%)

	menu "Welcome to the Random Card NPC! What would you like to do?",
		"Roll for a random card (" + .@zeny_cost + " Zeny)", Roll,
		"Nevermind", Quit;

OnInit:
	setarray .@normal_cards, 4001, 4002, 4003; // Example normal monster card IDs (You can add or remove as needed)
	setarray .@mini_cards, 4004, 4005, 4006; // Example mini monster card IDs (You can add or remove as needed)
	setarray .@boss_cards, 4007, 4008, 4009; // Example boss monster card IDs (You can add or remove as needed)
	end;

Roll:
	if (countitem(zeny) < .@zeny_cost) {
		mes "[Random Card NPC]";
		mes "You don't have enough Zeny.";
		close;
	}
	
	delitem zeny, .@zeny_cost;
	
	.@roll = rand(100); // Roll a random number between 0 and 99
	
	if (.@roll < .@normal_chance) {
		// Player gets a normal monster card
		.@card_id = .@normal_cards[rand(getarraysize(.@normal_cards))];
		getitem .@card_id, 1;
		mes "[Random Card NPC]";
		mes "Congratulations! You got a normal monster card.";
		close;
	} else if (.@roll < .@normal_chance + .@mini_chance) {
		// Player gets a mini monster card
		.@card_id = .@mini_cards[rand(getarraysize(.@mini_cards))];
		getitem .@card_id, 1;
		mes "[Random Card NPC]";
		mes "Congratulations! You got a mini monster card.";
		close;
	} else if (.@roll < .@normal_chance + .@mini_chance + .@boss_chance) {
		// Player gets a boss monster card
		.@card_id = .@boss_cards[rand(getarraysize(.@boss_cards))];
		getitem .@card_id, 1;
		mes "[Random Card NPC]";
		mes "Congratulations! You got a boss monster card.";
		close;
	} else {
		// Player gets nothing
		mes "[Random Card NPC]";
		mes "Sorry, you didn't get any card this time.";
		close;
	}
	
Quit:
	mes "[Random Card NPC]";
	mes "Come back anytime if you want to try your luck again!";
	close;
}

 

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