FANDOM


Weapon proc chance formula

ISoliniaSpell procSpell = StateManager.getInstance().getConfigurationManager().getSpell(handItem.getWeaponabilityid());
                
                if (procSpell != null && attackerSolEntity.getLevel() > handItem.getMinLevel()) {
                    // Chance to proc
                    int procChance = getProcChancePct();
                    int roll = Utils.RandomBetween(0, 100);
    
                    if (roll < procChance) {
    
                        // TODO - For now apply self and group to attacker, else attach to target
                        switch (Utils.getSpellTargetType(procSpell.getTargettype())) {
                        case Self:
                            procSpell.tryApplyOnEntity(attackerSolEntity.getBukkitLivingEntity(), attackerSolEntity.getBukkitLivingEntity());
                            break;
                        case Group:
                            procSpell.tryApplyOnEntity(attackerSolEntity.getBukkitLivingEntity(), attackerSolEntity.getBukkitLivingEntity());
                            break;
                        default:
                            procSpell.tryApplyOnEntity(attackerSolEntity.getBukkitLivingEntity(), defenderSolEntity.getBukkitLivingEntity());
                        }
    
                    }
}
@Override
    public int getProcChancePct() {
        // (Dexterity / 35) / 25
        int dexterity = 75;
        if (this.getBukkitLivingEntity() instanceof Player) {
            try {
                ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) this.getBukkitLivingEntity());
                if (player != null)
                    dexterity = getDexterity();
            } catch (CoreStateInitException e) {

            }
        }

        if (this.getNpcid() > 0)
            dexterity = getDexterity();

        float dexdiv = (dexterity / 35);
        float fina = ((dexdiv / 25) * 100);
        return (int) Math.floor(fina);
}