Jump to content

Question

4 answers to this question

Recommended Posts

  • 0
Posted
chry_fld,144,48,5	script	Gatcha Vending	562,{

	mes "[Gatcha  Ticket Vending]";
	mes "Use your Gatcha Ticket here.";
	next;
	switch(select("- Use:- See possibility:- Exit"))
	{
		case 1:		
			if ( !countitem(.itemuse) ) {
			mes "[Gatcha  Ticket Vending]";
			mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
			close;
			}
			delitem .itemuse, 1;
			getitem .temp_array[rand(0, getarraysize(.temp_array))], 1;
			end;
		case 2:
			next;
			mes "[Gatcha  Ticket Vending]";
			mes "Select possibility.";
			switch(select("- High Chance:- Mid Chance:- Low Chance:- Exit")){
			
				case 1:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(14003);
					mes F_MesItemInfo(40021);
					mes F_MesItemInfo(40028);
					mes F_MesItemInfo(40026);
					end;
				case 2:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(40030);
					mes F_MesItemInfo(40031);
					mes F_MesItemInfo(40039);
					mes F_MesItemInfo(40040);
					end;
					
				case 3:
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(40001);
					mes F_MesItemInfo(40033);
					mes F_MesItemInfo(40035);
					mes F_MesItemInfo(40041);
					mes F_MesItemInfo(40042);
					end;
					
				case 4:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes "Good Bye.";
					close;
			}
			
	}
	
OnInit:
	waitingroom "Gatcha Pot",0,0;
	.itemuse = 40022; 
	setarray .itemid[0], 14003,40021,40028,40026,40030,40031,40039,40040,40001,40033,40035,40041,40042;
	setarray .itemchance[0], 90,90,90,90,70,70,70,70,10,10,10,10,10;
	
	freeloop(1);
	.@counter = 0;
	for(.@i = 0; .@i < getarraysize(.itemid); .@i++) {
		for(.@k = 0; .@k < .itemchance[.@i]; .@k++) {
			.temp_array[.@counter] = .itemid[.@i];
			.@counter++;
		}
	}
	freeloop(0);
	end;
}

 

  • Upvote 1
  • 0
Posted
11 hours ago, EIysium said:
chry_fld,144,48,5	script	Gatcha Vending	562,{

	mes "[Gatcha  Ticket Vending]";
	mes "Use your Gatcha Ticket here.";
	next;
	switch(select("- Use:- See possibility:- Exit"))
	{
		case 1:		
			if ( !countitem(.itemuse) ) {
			mes "[Gatcha  Ticket Vending]";
			mes "A "+ getitemname(.itemuse) +" is needed to use this machine";
			close;
			}
			delitem .itemuse, 1;
			getitem .temp_array[rand(0, getarraysize(.temp_array))], 1;
			end;
		case 2:
			next;
			mes "[Gatcha  Ticket Vending]";
			mes "Select possibility.";
			switch(select("- High Chance:- Mid Chance:- Low Chance:- Exit")){
			
				case 1:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(14003);
					mes F_MesItemInfo(40021);
					mes F_MesItemInfo(40028);
					mes F_MesItemInfo(40026);
					end;
				case 2:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(40030);
					mes F_MesItemInfo(40031);
					mes F_MesItemInfo(40039);
					mes F_MesItemInfo(40040);
					end;
					
				case 3:
					mes "[Gatcha  Ticket Vending]";
					mes F_MesItemInfo(40001);
					mes F_MesItemInfo(40033);
					mes F_MesItemInfo(40035);
					mes F_MesItemInfo(40041);
					mes F_MesItemInfo(40042);
					end;
					
				case 4:
					next;
					mes "[Gatcha  Ticket Vending]";
					mes "Good Bye.";
					close;
			}
			
	}
	
OnInit:
	waitingroom "Gatcha Pot",0,0;
	.itemuse = 40022; 
	setarray .itemid[0], 14003,40021,40028,40026,40030,40031,40039,40040,40001,40033,40035,40041,40042;
	setarray .itemchance[0], 90,90,90,90,70,70,70,70,10,10,10,10,10;
	
	freeloop(1);
	.@counter = 0;
	for(.@i = 0; .@i < getarraysize(.itemid); .@i++) {
		for(.@k = 0; .@k < .itemchance[.@i]; .@k++) {
			.temp_array[.@counter] = .itemid[.@i];
			.@counter++;
		}
	}
	freeloop(0);
	end;
}

 

your the best @Elysium but question, what was wrong actually?

  • 0
Posted

actually, you can also consider another alternative like this

	.size = getarraysize(.itemid);
	for (.@i = 0; .@i < .size; .@i++)
		.total_chance += .itemchance[.@i];
.@rate = rand(.total_chance);
for (.@i = 0; .@i < .size; .@i++) {
	.@total_itemchance += .itemchance[.@i];
	if (.@rate < .@total_itemchance) {
		getitem .itemid[.@i], 1;
		end;
	}
}

this would greatly reduce your array size, and probably perform slightly better

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