All pastes #19272 Raw Edit

Untitled

public java v1 · immutable
#19272 ·published 2005-08-04 06:25 UTC
rendered paste body
// this is also just sorta pseudo-code....it will be different in the actual code its just to give an idea of how it works// this can also easily be modified for use with stun instead....// the formula essentially is://// rate = baseVal*(playerLVL/targetLVL * lvlModifier)*(lvlSkillLearnedAt/targetLVL)*(playerMATK/targetMDEF * matkModifier)*(playerWIT/targetWIT * witModifier)*chanceMultiplier//// variables:// baseVal = is the base chance of success (if all things are equal and modifiers are all equal to 1)// playerLVL = caster level// targetLVL = target level// lvlModifier = a number >0, 1 is neutral (doesnt do anthing). anything higher makes level difference count more, anything lower makes it count less// lvlSkillLearnedAt = the level that the current level of the skill was learned at. i.e. level 9 sleep learned at level 35// playerMATK = mATK of the caster// targetMDEF = mDEF of the target// matkModifier = a number >0, 1 is neutral (doesnt do anthing). anything higher makes matk/mdef difference count more, anything lower makes it count less// playerWIT = the WIT of the caster// targetWIT = the WIT of the target// witModifier = same as other modifiers, except for wit difference// chanceMultiplier = same as other modifiers. This one is applied to the overall success rate of the spell. Can be different for sleep, root, silence etc...// the numbers in this example is of a level 73 mage (i.e. SE) casting sleep on a level 62 fighter (i.e. GLADI), with a mage weapon on SE, self buffs for both, top b-grade jewellery all enchanted to +3 for gladi, and sleep level 9/*    	XML File contains    	<disabler type=sleep/root chanceMulti=1.3/1.12 baseRate=70/60> // greater than 1 = more chance of success. less than 1 = lower chance    	server config keeps base chance for each skill    	contiains max chance, and min chance (overall)    	also contains lvlModifier and matkModifier    	 ////////////////////////////////////////////    	 // the server.prop  file will also contain defaults of each    	 // of the vars so if sometin is not defined in the xml file, it'll default    	 // to whatever is set here     	 sleep/rootBaseLandRate = 70/60 // %    	     	 minChance = 2 // %    	 maxChance = 99 // %    	 lvlModifier = 1.05    	 matkModifier = 1.15    	 WITCheckForDebuff = true    	 witModifier = 0.73    	 sleep/rootChanceMulti = 1.3/1.12    	 ////////////////////////////////////////////*/    	int pLVL = player.getLevel(); = 73    	int tLVL = target.getLevel(); = 62    	double chanceMulti = xml.chanceMulti;    	double lvlModifier = config.lvlModifier = 1.05; // higher this number, the more level difference plays a part in success    	double matkModifier = config.matkModifier = 1.07; // higher this number, the more mdef/matk plays a part in success    	boolean witCheck = config.WITCheckForDebuff = true // compare wit?    	double witModifier = config.witModifier = 0.73; // higher this number, the more wit plays a part in success    	    	// compare player/targ lvl    	double baseVal = config.baseVal = 70%;    	baseVal *= pLVL/tLVL * lvlModifier = 1.2362903225806451612903225806452        	// baseVal = 70 * 1.236 = 86.54    	    	    	// compare skill/targ lvl    	L2PcInstance activecharPC = L2World.getInstance().getPlayer(L2Character.getName());    	ClassId classID = activecharPC.getClassId();    	int skillCheck = SkillTreeTable.getMinSkillLevel(skill.getId(), classID, skill.getLevel());    	    	//skill lvl = 9 = 35    	    	baseVal *= skillCheck / tLVL = 35 / 62 = 0.564 * 86.54 = 48.4624    	    	// compare p matk and targ mdef    	int pMATK = player.getTemplate().baseMAtk; = 900    	int pMDEF = target.getTemplate().baseMDef; = 700    	    	baseVal *= pMATK / pMDEF * matkModifier; = 900/700*1.07=1.4785 * baseVal = 66.670416;    	    	if ( witCheck == true ) {    		int pWIT = player.getTemplate().baseWIT; = 40    		int tWIT = target.getTemplate().baseWIT; = 28    		    		baseVal *= pWIT / tWIT * witModifier; = 40/28*.7 = 1.0428 * 66.67 = 69.527719542857142857142857142857    	}    	    	// TODO: factor in mental aegis-type buffs for sleep/root...    	    	baseVal *= chanceMulti; = 69.5277 * 1.3 = 90.38603;    	    	if ( baseVal < config.minChance ) baseVal = config.minChance;    	if ( baseVal > config.maxChance ) baseVal = config.maxChance;    	    	rate = baseVal;// based on tests with other conditions this seems to be very accurate