                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 //
// [==================================================]
// [                 Battle Refiner                   ]
// [==================================================]
// [ Version 2                                        ]
// [==================================================]
// [ Description:                                     ]
// [--------------------------------------------------]
// [                                                  ]
// [ - Everytime when you kill a monster, it adds a   ]
// [ very little chance to successfully refine an     ]
// [ equiped item.                                    ]
// [                                                  ]
// [==================================================]
// [ Changelog:                                       ]
// [--------------------------------------------------]
// [                                                  ]
// [ v1: [Ivion]                                      ]
// [                                                  ]
// [ v2: [Ivion]                                      ]
// [ - Bugfix: Non monster enemies causes errors.     ]
// [ - It won't check non refinable slots (7 -> 10).  ]
// [ - Decreased the default chance by 50%.           ]
// [==================================================]

-	script	Battle Refiner	-1,{
OnInit:

// [==================================================]
// [ Configuration:                                   ]
// [--------------------------------------------------]

	set .r1,100;	// Rate. (%)

// [--------------------------------------------------]
// [ End of configuration.                            ]
// [==================================================]

end;

OnNPCKillEvent:
	set .@a,rand(1,6);
	if(getequipisequiped(.@a) && getequipisenableref(.@a)) {
		set .@c,getequiprefinerycnt(.@a);
		if(.@c < 10) {
			if((.@a == 3) || (.@a == 4)) set .@b,getequipweaponlv(.@a);
			else set .@b,3;
			set .@d,strmobinfo(3,killedrid);
			if(!.@d) end;
			if(!rand(pow(2,.@b + .@c) * 400 * pow(BaseLevel,2) / (pow(.@d * 2,2) * .r1))) successrefitem .@a;
		}
	}
}