Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static final double calcPhysDam(L2Character attacker, L2Character target, L2Skill skill, byte shld, boolean crit, boolean ss)
- {
- if (attacker instanceof L2PcInstance)
- {
- L2PcInstance pcInst = (L2PcInstance) attacker;
- if (pcInst.isGM() && !pcInst.getAccessLevel().canGiveDamage())
- return 0;
- }
- double defence = target.getPDef(attacker);
- switch (shld)
- {
- case SHIELD_DEFENSE_SUCCEED:
- if (!Config.ALT_GAME_SHIELD_BLOCKS)
- defence += target.getShldDef();
- break;
- case SHIELD_DEFENSE_PERFECT_BLOCK: // perfect block
- return 1.;
- }
- final boolean isPvP = attacker instanceof L2Playable && target instanceof L2Playable;
- double damage = attacker.getPAtk(target);
- damage += calcValakasAttribute(attacker, target, skill);
- if (ss)
- damage *= 2;
- if (skill != null)
- {
- double skillpower = skill.getPower(attacker);
- final float ssBoost = skill.getSSBoost();
- if (ssBoost > 0 && ss)
- skillpower *= ssBoost;
- damage += skillpower;
- }
- // defence modifier depending of the attacker weapon
- Weapon weapon = attacker.getActiveWeaponItem();
- Stats stat = null;
- if (weapon != null)
- {
- switch (weapon.getItemType())
- {
- case BOW:
- stat = Stats.BOW_WPN_VULN;
- break;
- case BLUNT:
- stat = Stats.BLUNT_WPN_VULN;
- break;
- case BIGSWORD:
- stat = Stats.BIGSWORD_WPN_VULN;
- break;
- case BIGBLUNT:
- stat = Stats.BIGBLUNT_WPN_VULN;
- break;
- case DAGGER:
- stat = Stats.DAGGER_WPN_VULN;
- break;
- case DUAL:
- stat = Stats.DUAL_WPN_VULN;
- break;
- case DUALFIST:
- stat = Stats.DUALFIST_WPN_VULN;
- break;
- case POLE:
- stat = Stats.POLE_WPN_VULN;
- break;
- case SWORD:
- stat = Stats.SWORD_WPN_VULN;
- break;
- }
- }
- if (crit)
- {
- // Finally retail like formula
- damage = 2 * attacker.calcStat(Stats.CRITICAL_DAMAGE, 1, target, skill) * target.calcStat(Stats.CRIT_VULN, 1, target, null) * (70 * damage / defence);
- // Crit dmg add is almost useless in normal hits...
- damage += (attacker.calcStat(Stats.CRITICAL_DAMAGE_ADD, 0, target, skill) * 70 / defence);
- }
- else
- damage = 70 * damage / defence;
- if (stat != null)
- damage = target.calcStat(stat, damage, target, null);
- // Weapon random damage ; invalid for CHARGEDAM skills.
- if (skill == null || skill.getEffectType() != L2SkillType.CHARGEDAM)
- damage *= attacker.getRandomDamageMultiplier();
- if (shld > 0 && Config.ALT_GAME_SHIELD_BLOCKS)
- {
- damage -= target.getShldDef();
- if (damage < 0)
- damage = 0;
- }
- if (target instanceof L2Npc)
- {
- double multiplier;
- switch (((L2Npc) target).getTemplate().getRace())
- {
- case BEAST:
- multiplier = 1 + ((attacker.getPAtkMonsters(target) - target.getPDefMonsters(target)) / 100);
- damage *= multiplier;
- break;
- case ANIMAL:
- multiplier = 1 + ((attacker.getPAtkAnimals(target) - target.getPDefAnimals(target)) / 100);
- damage *= multiplier;
- break;
- case PLANT:
- multiplier = 1 + ((attacker.getPAtkPlants(target) - target.getPDefPlants(target)) / 100);
- damage *= multiplier;
- break;
- case DRAGON:
- multiplier = 1 + ((attacker.getPAtkDragons(target) - target.getPDefDragons(target)) / 100);
- damage *= multiplier;
- break;
- case BUG:
- multiplier = 1 + ((attacker.getPAtkInsects(target) - target.getPDefInsects(target)) / 100);
- damage *= multiplier;
- break;
- case GIANT:
- multiplier = 1 + ((attacker.getPAtkGiants(target) - target.getPDefGiants(target)) / 100);
- damage *= multiplier;
- break;
- case MAGICCREATURE:
- multiplier = 1 + ((attacker.getPAtkMagicCreatures(target) - target.getPDefMagicCreatures(target)) / 100);
- damage *= multiplier;
- break;
- }
- }
- if (damage > 0 && damage < 1)
- damage = 1;
- else if (damage < 0)
- damage = 0;
- // Dmg bonuses in PvP fight
- if (isPvP)
- {
- if (skill == null)
- damage *= attacker.calcStat(Stats.PVP_PHYSICAL_DMG, 1, null, null);
- else
- damage *= attacker.calcStat(Stats.PVP_PHYS_SKILL_DMG, 1, null, null);
- }
- // Weapon elemental damages
- damage += calcElemental(attacker, target, null);
- return damage;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement