Jump to content
  • 0

Custom Enchant NPC : script line for success percentage


kamirie

Question


  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

Good Day,

 I want to create my custom script for an enchanting npc like this .

I'm currently studying this script with malangdo enchant script for guidance. I'm a newbie in scripting and this will only be my 2nd npc script to date. I have the following questions .

How do I specify success rate based on enchant results like this :

Success%     Enchant Result

       1%      -    4900 // MHP+5%

       10%    -    4686 // MHP+4%

       30%    -    4867 // MHP+3%

       75%    -    6743 // HP+1%

 

Thanks in Advance

Edited by kamirie
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

I tried to study the Armor Enchant Script and Correct me if I'm wrong but as to my understanding of this ,

switch (rand(1,.@failrate)) {
			case 1: set .@addpart,4702;break;
			case 2: set .@addpart,4712;break;
			case 3: set .@addpart,4722;break;
			case 4: set .@addpart,4732;break;
			case 5: set .@addpart,4742;break;
			case 6: set .@addpart,4752;break;
			case 7:
			case 8: set .@addpart,4701;break;
			case 9:
			case 10: set .@addpart,4711;break;
			case 11:
			case 12: set .@addpart,4721;break;
			case 13:
			case 14: set .@addpart,4731;break;
			case 15:
			case 16: set .@addpart,4741;break;
			case 17:
			case 18: set .@addpart,4751;break;
			case 19:
			case 20:
			case 21: set .@addpart,4700;break;
			case 22:
			case 23:
			case 24: set .@addpart,4710;break;
			case 25:
			case 26:
			case 27: set .@addpart,4720;break;
			case 28:
			case 29:
			case 30: set .@addpart,4730;break;
			case 31:
			case 32:
			case 33: set .@addpart,4740;break;
			case 34:
			case 35:
			case 36: set .@addpart,4750;break;
			default:
				specialeffect2 EF_PHARMACY_FAIL;
				mes "[Apprentice Craftsman]";
				mes "Well that's too bad.";
				mes "The requested equipment has failed to enchant.";
				close;
		}
getitem2 .@itemid, 1, 1, 0, 0, 0, 0, 0, .@addpart;

This is the line that adds the specific stat to the chosen armor. So If I chose a High Grade armor, I will have a @failrate of 60 as set to this line


S_EnchantArmor:
	set .@itemid,getarg(0);
set .@failrate,getarg(1);

which is 60 based on this

case 3:
			setarray .@Items[0],2364,2365,2391,2374,2375,2376,2377,2378,2379,2380,2381,2382,2387,2388,2389,2390;
set .@j,60;

So I will get an enchant based on what case # I get from rand(1,60)

If I get a case # without set , My enchantment failed? AND if get any rand()  37-59 It will also fail because there's no case# 37-59?

 Is this random result basis rather than percentage basis of some sort?

 

Edited by kamirie
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:  

Well, kinda... that makes it almost 50% chance...

 

36/60... where as ALL 60 #'s would be 100%

so 36/60 would be 60/100 = 36/X   .... so cross multiply / divide ==.... 100  * 36 / 60 = 60% chance refine rate... it would have been the same as doing... 1 outta 5... and only accept 1,2,3 and not accepting 4,5 ...

The issue, is that you have to break it down to the common denominator... since you want a 1% chance you will most likely need to do it out of a full 100....

set .@chance, rand(1,100);

if (.@chance == 1) { // The 1% chance is successful! }
elseif (.@chance <= 10) { // 10% chance }
elseif (.@chance <= 30) { // 30% chance }
elseif (.@chance <= 75) { // 75% chance }
else {
  mes "Failed"; close;
}

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

Thanks @ZER0 so using this , I just have to goto to the specific addparts

 set .@chance, rand(1,100);

if (.@chance == 1) { goto E_mhp5 // The 1% chance is successful! }
elseif (.@chance <= 10) { goto E_mhp4 // 10% chance }
elseif (.@chance <= 30) { goto E_mhp3  // 30% chance }
elseif (.@chance <= 75) { goto E_mhp1  // 75% chance }
else {
  mes "Failed"; close;
} 

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

I think I understand now malangdo. So it doesn't give higher chances of enchant depending on coins, just additional or improved versions of the enchantments.

case 1: //Anger_Seagod - Short Range
			set .@i, rand(1,555);
			     if (.@i < 81)  set .@enchant,4732; //Agility3 (I will get agi+3 if my.@i is 2-80)
			else if (.@i < 161) set .@enchant,4820; //Fighting_Spirit5 (I will get FS5 if my.@i is 81-160)
			else if (.@i < 241) set .@enchant,4843; //Sharp4 (I will get sharp4 if my.@i is 161-240)
			else if (.@i < 311) set .@enchant,4733; //Agility4 (I will get agi+4 if my.@i is 240-310)
			else if (.@i < 371) set .@enchant,4821; //Fighting_Spirit6 (I will get FS6 if my.@i is 311-370)
			else if (.@i < 431) set .@enchant,4844; //Sharp5 (I will get sharp5 if my.@i is 371-430)
			else if (.@i < 476) set .@enchant,4734; //Agility5 (I will get agi+5 if my.@i is 431-475)
			else if (.@i < 516) set .@enchant,4822; //Fighting_Spirit7 (I will get FS7 if my.@i is 476-515)
			else if (.@i < 526) set .@enchant,4807; //Atk_Speed1 (I will get aspd+1 if my.@i is 515-525)
			else if (.@i < 546) set .@enchant,4735; //Agility6 (I will get agi+ if my.@i is 525-545)
			else if (.@i < 551) set .@enchant,4823; //Fighting_Spirit8 (I will get FS8 if my.@i is 546-550)
			else if (.@i < 556) set .@enchant,4807; //Atk_Speed1 (I will get aspd+1 if my.@i is 550-555)
			else set .@enchant,9; 
break;

I

Edited by kamirie
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:  

Correct it will continue down to the next else if if the first if fails... so it just tiers downwards...

 

so if it never falls between X number then it doesn't work... the difference, is the more "chance" you want to give, the higher the initial value needs to be...

especially when dealing with multiple cases... for instance in that case he went from 1 to 555... he could have gone from 1 to 100, but that would lower the chances between the items since you only have 100 total options, and have to split them among X number of items... so by increasing the base number from 100 to 555, he increased the chance range between goods so that they have a higher chance of hitting...

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  37
  • Reputation:   3
  • Joined:  08/26/17
  • Last Seen:  

10 hours ago, Z3R0 said:

Correct it will continue down to the next else if if the first if fails... so it just tiers downwards...

 

so if it never falls between X number then it doesn't work... the difference, is the more "chance" you want to give, the higher the initial value needs to be...

especially when dealing with multiple cases... for instance in that case he went from 1 to 555... he could have gone from 1 to 100, but that would lower the chances between the items since you only have 100 total options, and have to split them among X number of items... so by increasing the base number from 100 to 555, he increased the chance range between goods so that they have a higher chance of hitting...

 

Thanks Z3R0 , I was able to make my script function as intended with your help .

  • Upvote 1
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...