const intBASE_DEX_BONUS := 10; // base bonus to Dodge/Parry, lowered by equipped armor const intSHIELD_BASE_PARRY := 20; const intWEAPON_BASE_PARRY := 0.5; ........ // weapon or Defense stats if ( !objWeapon ) // Defense intBaseDefense := CInt( GetDexterity( mobWho ) / 5 ); intAR := CInt( intSkill / 10 ); else if ( objWeapon.isa( POLCLASS_ARMOR ) ) // shield Defense intBaseDefense := intSHIELD_BASE_PARRY; intAR := filArmors[objWeapon.objtype].Weight + 1; else // weapon Defense intBaseDefense := intWEAPON_BASE_PARRY * filWeapons[objWeapon.objtype].Speed; strSkill := filWeapons[objWeapon.objtype].Attribute; intAR := CInt( filWeapons[objWeapon.objtype].Weight / 2 ); endif endif // modify base defense for Dex penalties intBaseDefense := intBaseDefense + intBASE_DEX_BONUS + GetModifierSum( GetCurrentMods( mobWho, "dex", "equipped" ) ); // roll Defense intDefenseChance := intBaseDefense + ( 3 * intSkill ) / 10; if ( mobWho.cmdlevel or GetObjProperty( mobWho, "debugging" ) ) DebugMessage( mobWho, " Defense chance: " + intDefenseChance ); endif // lower Defense chance if PC and not in warmode if ( mobWho.account and !mobWho.warmode ) intDefenseChance := intDefenseChance - 10; endif // penalize Defense for parrying with long-reach weapon if( filArmors[objWeapon.objtype].MaxRange >= 2 ) intDefenseChance := intDefenseChance - intREACH_PENALTY * filArmors[objWeapon.objtype].MaxRange; endif var strDefenseText; intDefenseRoll := RandomDiceRoll( "1d100" ); if ( intDefenseRoll < 0.2 * intDefenseChance ) intDefenseAmt := -intAR; if (strSkill == "Parry" || strSkill == "Dodge") strDefenseText := "*Critical "+strSkill+"*"; endif else if ( intDefenseRoll < intDefenseChance ) intDefenseAmt := intAR; if (strSkill == "Parry" || strSkill == "Dodge") strDefenseText := "*"+strSkill+"*"; endif endif endif