Jump to content
  • 0

R> a NPC with progressbar & those with % to get one of a list of items [Solved]


ItsFree

Question


  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

Hi, rAthena Community i wanna request a NPC with this... i guess is possible because i saw a similar time ago (was a fishing npc as i remember...)
The NPC Requested:

1.- the NPC will give you 1 item at random of a list of X amount of items (i dont know could get a jellopy or a fluff or a poring coing, etc).

2.- before the NPC give you that random item, first the npc will ask you to give 1 of the next 4 items: Bronze Coin(673), Silver Coin (675), Gold Coin (671) & Platinum Coin (677).

3.- if you give bronze coin, a progressbar will show with a duration of 10 seconds, if you give silver again a progressbar with 8 seconds... gold -> 5 seconds, platinum - 2 seconds.

The percent (%) of the items i want they be editable (i mean i can select if 10% which item, or 1%, etc).

After the progressbar start... the npc will deleted your item (coin).

Extra: if could add something like an announce when the player get a "very rare item" would be nice.

 

Thx... as i said i saw a similar NPC like this some years ago was a fishing script or something like that, that fishing npc tell you that you need a fishing bait, and stuff like that as i remember... that npc had the progress bar also the announce, the 1 item of a list and the % of the items, the only thing that didnt have was that option of "if you give this item the wait will be less"

 

i gonna try find that script to have a better idea... and adding that script here if helps :P thx... if dont understand something... just tell me to explain it better

 

Edit:

 

these are the scripts i found and were "similar" that i want:

 

prontera,160,172,0	script	Fishing Hole	844,{
	
//Fishing rod
set .@Rod,2764;
//Fishing Lure
set .@Lure,2775;
//Auto-Fish
set .@Auto,1;
//Auto-Fish on Fail
set .@AutoFail,1;
Fish:
	if (isequipped(.@Rod)) && (isequipped(.@Lure)){
		specialeffect EF_BUBBLE,"Fishing Hole";
		soundeffect "fishingrod.wav",0;
		dispbottom "[Fishing] Casting...";
		set .@fcast,15;
			if (isequipped(2550)) { //Fisher's Muffler
				set .@fcast,.@fcast - 2;
			}
			if (isequipped(2443)) { //Fisher's Boots
				set .@fcast,.@fcast - 2;
			}
			if (isequipped(2764)) { //Fishing Pole
				set .@fcast,.@fcast - 3;
			}
			if (isequipped(2775)) { //Fishing Lure
				set .@fcast,.@fcast - 1;
			}
		progressbar "ffffff",.@fcast;
		if (rand(1,20) == 2){
		getitem 6096,1; //Fish with Blue Back
		specialeffect2 EF_TEMP_OK;
		soundeffectall "success.wav",0,strcharinfo(3);
		mapannounce strcharinfo(3),strcharinfo(0)+" has caught a Blue Fish!",bc_map,"0xff77ff";
		if(.@Auto==1){
		goto Fish;}else{
		end;}
		}
			if (rand(1,6) == 1) ||(rand(1,6) == 3) || (rand(1,6) == 6){
			setarray .@Catch[0],579,908,909,963,956,6049,918,960,910,938,624;// List of Junk/Other
			set .@CatchRand,.@Catch[rand(getarraysize(.@Catch))];
			getitem .@CatchRand,1;
			}
			else {
			dispbottom "[Fishing] Nothing was caught...";
			if(.@AutoFail == 1){
			goto Fish;} else{
			end;}
			}
		if (rand(1,100) == 3){
		setarray .@Rare[0],644,603,617;
		set .@RareCatch, .@Rare[rand(getarraysize(.@Rare))];
		getitem .@RareCatch,1; //Reward
		mapannounce strcharinfo(3),strcharinfo(0)+" has caught a "+getitemname(.@RareCatch)+"!",bc_map,"0x33CC00";
		}
		if(.@Auto == 1){
		goto Fish;} else{
		end;}
		}
	else {
	dispbottom "[Fishing] You need a Rod and Lure.";
	end;
	}
}

also this
 

comodo,196,112,6 script School of Fish 723,{
if(countitem(632) < 1) goto L_Exit;
L_Exit:
mes "You do not have Fatty Chubby.";
close;
delitem 632,1;
if (isequipped(2764)) && (isequipped(2775)){
specialeffect2 EF_BUBBLE;
set .@fcast,15;
if (isequipped(2550)) set .@fcast,.@fcast-3; //Fisher's Muffler.
}
if (isequipped(2443)) set .@fcast,.@fcast-2; //Fish_Shoes
}
if (isequipped(5380)) set .@fcast,.@fcast-5; //Fish_Shoes
}
progressbar "ffffff",.@fcast;
if (rand(1,20) == 2) {
getitem 6096,5; //Big Fish
specialeffect EF_BUBBLE;
mapannounce "comodo","" + strcharinfo(0) + " has caught a 5 Tuna!!!",bc_map,"0xff77ff";
end;
}
set .@rhea_ran,rand(1,70);
if (.@rhea_ran < 20) {
specialeffect2 610;
getitem 29183,1; //Anchovy

}
else if (.@rhea_ran == 20) {
specialeffect2 610;
getitem 29184,1; //Bass

}
else if (.@rhea_ran == 21) {
specialeffect2 610;
getitem 29185,1; //Crab

}
else if (.@rhea_ran == 22) {
specialeffect2 610;
getitem 29186,1; //Eel

}
else if (.@rhea_ran == 23) {
specialeffect2 610;
getitem 29187,1; //Jelly Fish

}
else if (.@rhea_ran == 24) {
specialeffect2 610;
getitem 29188,1; //Lobster

}
else if (.@rhea_ran == 25) {
specialeffect2 610;
getitem 29189,1; //Perch

}
else if (.@rhea_ran == 26) {
specialeffect2 610;
getitem 29190,1; //Pike

}
else if (.@rhea_ran == 27) {
specialeffect2 610;
getitem 29191,1; //Puffer

}
else if (.@rhea_ran == 28) {
specialeffect2 610;
getitem 9192,1; //Salmon
}
else if ((.@rhea_ran > 28) && (.@rhea_ran < 40)) {
specialeffect2 610;
getitem 632,1; //Fatty Chubby Earthworm

}
else {
mes "Nothing was caught.";
specialeffect2 611;
close;
}
if (rand(1,200) == 3) {
getitem 6096,20; //Gift_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught a 20 Tuna Fish!!",bc_map,"0x0000ff";
}
if (rand(1,500) == 3) {
getitem 6096,30; //Old_Blue_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught an 30 Tuna Fish!",bc_map,"0x00ffff";
}
if (rand(1,3000) == 3) {
getitem 6096,50; //Old_Violet_Box
mapannounce "comodo","" + strcharinfo(0) + " has caught an 50 Tuna Fish!!",bc_map,"0x44ff44";
}
end;
}
else {
mes "Fish are swimming in the water.";
close;
}
}

comodo.gat,189,108,4 duplicate(School of Fish) School of Fish#1 1158
comodo.gat,183,111,4 duplicate(School of Fish) Tilapya#20 2082
comodo.gat,218,108,4 duplicate(School of Fish) School of Fish#21 1069
comodo.gat,228,108,3 duplicate(School of Fish) School of Fish#22 1158
comodo.gat,214,112,4 duplicate(School of Fish) School of Fish#23 723
comodo.gat,189,122,4 duplicate(School of Fish) Mr Crab#23 1073
comodo.gat,192,106,4 duplicate(School of Fish) Octopus#23 1144
//Shop
comodo,205,112,4 shop Bulantiro 1543,2764:50000000,2775:50000000,2550:100000000,2443:200000000

those scripts its to have a more clear idea

Edited by ItsFree
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 2

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");

	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	.@counter = 0;
	for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) {
		for(.@i = 0; .@i < @inventorylist_count; .@i++) {

			if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) {
				if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) {
					set(.@menu_coin_index[.@counter], .@coin_index);
					set(.@menu$, .@menu$ + ( .@menu$ == "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");
					.@counter++;
				}
			}
		}
	}
	freeloop(false);

	if (.@menu$ == "") {
		next;
		mes("You do not have any coins!");
		close;
	}

	// Display Option to Show them choices and how many coins they have...
	set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index
	set .@index, .@menu_coin_index[.@choice];

	// dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@index]) );
	// dispbottom("Progress bar Duration is: " + .exchange_duration[.@index] + " seconds.");

	mes("Goodluck");
	close2;

	progressbar("00FF00", .exchange_duration[.@index]); // Start the Progressbar

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[.@index], .exchange_amount[.@index]);
	freeloop(true);
	for(.@i = 0; .@i < getarraysize(.available_items); .@i++) {
		.@random = rand(1, 100);
		if (.@random <= .available_chance[.@i]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[.@i], .available_amount[.@i]);
			if (.available_chance[.@i] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.available_items[.@index]), bc_all, C_YELLOW);
			}
			close;
		}
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;

	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower

		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

This should work

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Crude and Highly Untested

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) {
		for(.@i = 0; .@i < @inventorylist_count, .@i++) {
			if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) {
				if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) {
					set(.@menu_coin_index[getarraysize(.@menu_coin_index)], .@coin_index);
					set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index
	set .@index, .@menu_coin_index[.@choice];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@index]) );

	progressbar("00FF00", .exchange_duration[.@index]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[.@index], .exchange_amount[.@index];
	freeloop(true);
	for(.@i = 0; .@i < getarraysize(.available_items); .@i++) {
		.@random = rand(1, 100); 
		if (.@random <= .available_chance[.@i]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[.@i], .available_amount[.@i]);
			if (.available_chance[.@i] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[.@index]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

Edited by Z3R0
Modfiied for >= for Count ID to allowed count
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

Thx i'll test it, some mistakes with ) ; i've fixed those mistakes only 2 "problems"

1.- you can check it on the image below (this problem happen just sometimes, most offen with 675 - silver coin)

2.- all the progress bar have the same duration. they had all the same but no, actually the one slower was the one with the error the silver coin (675) is the slowest, and the others 3, have a similar speed:

if i only have a coin of the same type all the progress are 10 seconds and when i've the 4, each one have the speed they should have, but after use gold or platinum bronze and silver change to 10 seconds (with bronze its ok, but with silver not).

Script fixed with the problems with ")" and ";".
 

prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) {
		for(.@i = 0; .@i < @inventorylist_count; .@i++) {
			if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) {
				if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) {
					set(.@menu_coin_index[getarraysize(.@menu_coin_index)], .@coin_index);
					set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index
	set .@index, .@menu_coin_index[.@choice];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@index]) );

	progressbar("00FF00", .exchange_duration[.@index]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[.@index], .exchange_amount[.@index]);
	freeloop(true);
	for(.@i = 0; .@i < getarraysize(.available_items); .@i++) {
		.@random = rand(1, 100); 
		if (.@random <= .available_chance[.@i]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[.@i], .available_amount[.@i]);
			if (.available_chance[.@i] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[.@index]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

2dabfbf41a6238e7c860d6228c0224da.png

Also... if i click somewhere else the progress bar cancel and i stuck (im agree with the cancel, but no with the stuck ><).

Edited by ItsFree
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Ok, I can look into it tonight, sorry, I am at work, just thought I would whip something up, I can test it out tonight late though if you don't have anyone to debunk it by then...

 

Sorry for it not working right off the bat :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  44
  • Topics Per Day:  0.01
  • Content Count:  121
  • Reputation:   7
  • Joined:  04/11/15
  • Last Seen:  

its ok i can wait thx ^^

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

@Z3R0 you can simplify this part

	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) {
		for(.@i = 0; .@i < @inventorylist_count, .@i++) {
			if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) {
				if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) {
					set(.@menu_coin_index[getarraysize(.@menu_coin_index)], .@coin_index);
					set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");
				}
			}
		}
	}
	freeloop(false);
	// Display Option to Show them choices and how many coins they have...
	set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index
	set .@index, .@menu_coin_index[.@choice];

into this, using the countitem() to check if player has the item with them or not.

	.@exchange_ids_size = getarraysize(.exchange_ids);
	for (.@i = 0; .@i < .@exchange_ids_size; .@i++) {
		if (countitem(.exchange_ids[.@i]) >= .exchange_amount[.@i]) {
			.@menu$ = .@menu$ + getitemname(.exchange_ids[.@i]);
		}
		.@menu$ = .@menu$ + ":";
	}
	.@i = select(.@menu$) - 1;
	dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@i]) );

/lv

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Omg I completely forgot about countitem... zomg! This is how out I have been wow...

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  135
  • Reputation:   4
  • Joined:  07/29/17
  • Last Seen:  

On 8/2/2017 at 11:04 PM, Z3R0 said:

Crude and Highly Untested


prontera,158,173,4	script	CoinExchanger	88,{

	mes("Welcome");
	mes("Please give me your coins...");
	
	// Check Inventory for Coins
	getinventorylist;

	freeloop(true);
	for(.@coin_index = 0; .@coin_index < getarraysize(.exchange_ids); .@coin_index++) {
		for(.@i = 0; .@i < @inventorylist_count, .@i++) {
			if (@inventorylist_id[.@i] == .exchange_ids[.@coin_index]) {
				if (@inventorylist_amount[.@i] >= .exchange_amount[.@coin_index]) {
					set(.@menu_coin_index[getarraysize(.@menu_coin_index)], .@coin_index);
					set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");
				}
			}
		}
	}
	freeloop(false);

	// Display Option to Show them choices and how many coins they have...
	set .@choice, select(.@menu$) - 1; // Subtract 1 to get Array Index
	set .@index, .@menu_coin_index[.@choice];

	dispbottom("You have chosen to use " + getitemname(.exchange_ids[.@index]) );

	progressbar("00FF00", .exchange_duration[.@index]); // Start the Progressbar 

	// On Progress Bar Completion... let's see what we do here...
	delitem(.exchange_ids[.@index], .exchange_amount[.@index];
	freeloop(true);
	for(.@i = 0; .@i < getarraysize(.available_items); .@i++) {
		.@random = rand(1, 100); 
		if (.@random <= .available_chance[.@i]) { // GET THE ITEM
			mes "Here you go";
			getitem(.available_items[.@i], .available_amount[.@i]);
			if (.available_chance[.@i] <= .announce_level_chance) {
				announce(strcharinfo(0) + " just scored " + getitemname(.exchange_ids[.@index]), bc_all, C_YELLOW);
			}
			close;
		} 
	}
	freeloop(false);

	mes("You got the default prize...");
	getitem(.default_item, .default_amount);
	close;	
 
	OnInit:
		setarray(.exchange_ids, 673, 675, 671, 677);
		setarray(.exchange_amount, 1, 1, 1, 1);
		setarray(.exchange_duration, 10, 8, 5, 2); // # of seconds to progressbar...

		setarray(.available_items, 501, 502, 503, 504);
		setarray(.available_amount, 1, 1, 1, 1);
		setarray(.available_chance, 50, 40, 30, 10); // % of 100 

		set(.announce_level_chance, 10); // Will only display announce if they get item 504... since it's the only one with 10 chance or lower
		
		set(.default_item, 501);
		set(.default_amount, 1);
		end;

}

 

@Z3R0 may i ask a question.

what is the "?" all about on this code

set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

On 11/3/2017 at 8:48 PM, Nerks said:

what is the "?" all about on this code

set(.@menu$, ( .@menu$ = "" ? "" : ":" ) + getitemname(.exchange_ids[.@coin_index]) + "(" + @inventorylist_amount[.@i] + ")");

 

(a > b) ? a : b;

this an expression which returns one of two values, a or b. 
The condition, (a > b), is tested. 
If it is true the first value, a, is returned. 
If it is false, the second value, b, is returned.

Whichever value is returned is dependent on the conditional test, a > b. 

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