Jump to content
  • 0

Enchant Script not working with random option, getitem3 issue?


DrGruning

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  7
  • Reputation:   0
  • Joined:  12/30/18
  • Last Seen:  

prt_in,86,73,5	script	Bermund	654,{
	function get_rune_id;
	function get_rune_equip;
	function get_rune_zeny;
	function get_rune_success_rate;
	
	disable_items;
	mes "You want to fuse the MvP Core with your equipments?";
	mes "NOTE:";
	mes "Please by all means just have equipped the item you will enchant and once at time,that is to avoid any item lost or bug, you are already warned";
	mes "Enchanting an equipment will erase Item Options";
	.@color = select( "Shoes","Armor","Shield","Accesories","Headgear" );
	next;
	mes "I can transmute it depending on your budget and wiht it chances increases";
	.@rank = select( "Normal Services","Premiun Services","VIP Services" );
	
	.@enchant_slot = 4;
	.@equip_loc = get_rune_equip( .@color );
	.@rune_id = get_rune_id( .@color,.@rank );
	.@zeny_cost = get_rune_zeny( .@rank );
	.@success_rate = get_rune_success_rate( .@rank );
	.@item_id = getequipid( .@equip_loc );
	
	next;
	mes "Equipment: "+getitemname( .@item_id );
	mes "Rune: "+getitemname( .@rune_id );
	mes "Zeny: "+F_InsertComma( .@zeny_cost );
	mes "Success Rate: "+.@success_rate+"%";
	mes " ";
	if ( Zeny >= .@zeny_cost )
		if ( select( "Continue","Cancel" ) == 1 ) {
			if ( getitemslots( .@item_id ) >= .@enchant_slot ) {
				mes "This item slot cant be enchanted.";
			}
			else {
				
				Zeny -= .@zeny_cost;
				if ( rand(100) < .@success_rate ) {
					for ( .@card = 0; .@card < 4; .@card++ ) 
						.@slot[.@card] = getequipcardid( .@equip_loc,.@card );
					setarray .@OptID[0],0;
setarray .@OptID[1],0;
setarray .@OptID[2],0;
setarray .@OptID[3],0;
setarray .@OptID[4],0;
setarray .@OptVal[0],0;
setarray .@OptVal[1],0;
setarray .@OptVal[2],0;
setarray .@OptVal[3],0;
setarray .@OptVal[4],0;
setarray .@OptParam[0],0;
setarray .@OptParam[1],0;
setarray .@OptParam[2],0;
setarray .@OptParam[3],0;
setarray .@OptParam[4],0;

for (.@j = 0; .@j < 5; .@j++) {
setarray .@OptID[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_ID);
setarray .@OptVal[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_VALUE);
setarray .@OptParam[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_PARAM);
}
					.@refine = getequiprefinerycnt( .@equip_loc );
					.@slot[.@enchant_slot-1] = .@rune_id; 
					mes "Enchant Success";
					specialeffect2 EF_REFINEOK;
					delitem .@rune_id,1;
					delitem3 .@item_id,1,1,.@refine,0,.@slot[0],.@slot[1],.@slot[2],.@slot[3],.@OptID,.@OptVal,.@OptParam;
					getitem3 .@item_id,1,1,.@refine,0,.@slot[0],.@slot[1],.@slot[2],.@slot[3],.@OptID,.@OptVal,.@OptParam;
				}
				else {
					mes "Enchant Failed.";
					specialeffect2 EF_REFINEFAIL;
					delitem .@rune_id,1;
				}
			}
		}
	close;
	
	function	get_rune_id	{
		.@color = getarg(0,0);
		.@rank = getarg(1,0);
		
		switch( .@color ) {
			case 1: // Blue
				switch( .@rank ) {
					case 1: setarray .@rune_list,15495,15539,15482; break;
					case 2: setarray .@rune_list,15495,15539,15482; break;
					case 3: setarray .@rune_list,15495,15539,15482; break;
					default: break;
				}
				break;
			case 2: // Green
				switch( .@rank ) {
					case 1: setarray .@rune_list,15485,15501,15493,15500,15542,15501; break;
					case 2: setarray .@rune_list,15485,15501,15493,15500,15542,15501; break;
					case 3: setarray .@rune_list,15485,15501,15493,15500,15542,15501; break;
					default: break;
				}
				break;
			case 3: // Yellow
				switch( .@rank ) {
					case 1: setarray .@rune_list,15496,15502,15497; break;
					case 2: setarray .@rune_list,15496,15502,15497; break;
					case 3: setarray .@rune_list,15496,15502,15497; break;
					default: break;
				}
				break;
			case 4: // Red
				switch( .@rank ) {
					case 1: setarray .@rune_list,15494,15487,15489; break;
					case 2: setarray .@rune_list,15494,15487,15489; break;
					case 3: setarray .@rune_list,15494,15487,15489; break;
					default: break;
				}
				break;
			case 5: // Red
				switch( .@rank ) {
					case 1: setarray .@rune_list,15541,15544; break;
					case 2: setarray .@rune_list,15541,15544; break;
					case 3: setarray .@rune_list,15541,15544; break;
					default: break;
				}
				break;
			default: break;
		}
		.@rune_list_size = getarraysize( .@rune_list );
		
		if ( .@rune_list_size ) {
			while (  .@i < .@rune_list_size ) {
				.@menu$ = .@menu$ + ( ( countitem( .@rune_list[.@i] ) )? "^0055FF":"^777777" ) + getitemname( .@rune_list[.@i] ) + "^000000" + ":";
				.@i++;
			}
			.@i = select( .@menu$ ) - 1;
			
			if ( !countitem( .@rune_list[.@i] ) ) {
				mes "You don't have the required rune.";
				close;
			}
		}
		return .@rune_list[.@i];
	}

	function	get_rune_equip	{		
		.@color = getarg(0,0);
		
		switch ( .@color ) {
			case 1: // Blue
				setarray .@equip_loc_list,EQI_SHOES; 
				setarray .@equip_loc_name$,"SHOES"; 
				break;
			case 2: // Green
				setarray .@equip_loc_list,EQI_ARMOR; 
				setarray .@equip_loc_name$,"ARMOR"; 
				break;
			case 3: // Yellow
				setarray .@equip_loc_list,EQI_HAND_L; 
				setarray .@equip_loc_name$,"SHIELD"; 
				break;
			case 4: // Red
				setarray .@equip_loc_list,EQI_ACC_L,EQI_ACC_R;
				setarray .@equip_loc_name$,"ACCESSORY LEFT","ACCESSORY RIGHT"; 
				break;
			case 5: // Red
				setarray .@equip_loc_list,EQI_HEAD_LOW ;
				setarray .@equip_loc_name$,"LOWER HEADGEAR"; 
				break;
			default: break;
		}
		.@equip_loc_list_size = getarraysize( .@equip_loc_list );
		if ( .@equip_loc_list_size ) {
			while ( .@i < .@equip_loc_list_size ) {
				.@equip_id = getequipid( .@equip_loc_list[.@i] );
				.@menu$ = .@menu$ + ( ( .@equip_id <= 0 )?"^777777":"^0055FF" )  +.@equip_loc_name$[.@i] + " (" + getitemname( .@equip_id  ) + ")^000000" + ":";
				.@i++;
			}
			.@i = select( .@menu$ ) - 1;
			
			if ( getequipid( .@equip_loc_list[.@i] ) <= 0 ) {
				mes "You didnt equipped any equipment on this slot.";
				close;
			}
		}
		return .@equip_loc_list[.@i];
	}
	
	function	get_rune_zeny	{
		.@rank = getarg(0,0);
		switch( .@rank ) {
			case 1: return 1000000;		// Rare		- 1,000,000 Zeny
			case 2: return 10000000;	// Epic		- 10,000,000 Zeny
			case 3: return 25000000;	// Legend	- 80,000,000 Zeny
			default: return 0;
		}
	}
	
	function	get_rune_success_rate	{
		.@rank = getarg(0,0);
		switch( .@rank ) {
			case 1: return 10;		// Rare		- 90% success
			case 2: return 15;		// Epic		- 50% success
			case 3: return 20;		// Legend	- 20% success
			default: return 0;
		}
	}
}

I have this custom enchant system right, but when i tried to adapt it to random option support it always delete the random options, and shows the following error at console:

error1.png.f53900a0833f1c0b4d512e9a83c8c034.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1677
  • Reputation:   703
  • Joined:  12/21/14
  • Last Seen:  

given that everything is right in the script , and your error is only on delitem3 , use 

delequip .@equip_loc;

instead of delitem3

you still need the information to create a new item , but this insure that even if you missed some information about the item (like identify and attribute) the item will get deleted safely and the player can't abuse the system

 

 

 

 

also you don't need those

setarray .@OptID[0],0;
setarray .@OptID[1],0;
setarray .@OptID[2],0;
setarray .@OptID[3],0;
setarray .@OptID[4],0;
setarray .@OptVal[0],0;
setarray .@OptVal[1],0;
setarray .@OptVal[2],0;
setarray .@OptVal[3],0;
setarray .@OptVal[4],0;
setarray .@OptParam[0],0;
setarray .@OptParam[1],0;
setarray .@OptParam[2],0;
setarray .@OptParam[3],0;
setarray .@OptParam[4],0;

 

and your forloop for getting the random options

from

for (.@j = 0; .@j < 5; .@j++) {
setarray .@OptID[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_ID);
setarray .@OptVal[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_VALUE);
setarray .@OptParam[.@j],getequiprandomoption(.@eq_loc,.@j,ROA_PARAM);
}

to

for (.@j = 0; .@j < 5; .@j++) {
	.@OptID[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_ID);
	.@OptVal[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_VALUE);
	.@OptParam[.@j] = getequiprandomoption(.@eq_loc,.@j,ROA_PARAM);
}

 

Edited by sader1992
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  7
  • Reputation:   0
  • Joined:  12/30/18
  • Last Seen:  

Thanks a lot for your input @sader1992. Aftter trying your fixes at first it didn't work but somehow after replacing .@eq_loc to .@equip_loc it worked!

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