public PetRewardDescription getRandomReward() { for (PetRewardDescription descr : getResults()) { if (descr.getChance() == 0) continue; if (Rnd.get(100) <= descr.getChance()) return descr; } return null; }
@Override public void checkShield(List<AttackResult> attackList, Creature attacker) { for (AttackResult attackResult : attackList) { if (attackResult.getAttackStatus().toString().contains("DODGE") || attackResult.getAttackStatus().toString().contains("RESIST")) continue; switch (attackType) { case MAGICAL_SKILL: if (attackResult.getDamageType() == DamageType.PHYSICAL) continue; case PHYSICAL_SKILL: if (attackResult.getDamageType() == DamageType.MAGICAL) continue; } if (Rnd.get(0, 100) > probability) continue; if (shieldType == 2) // shield type 2, normal shield { int damage = attackResult.getDamage(); int absorbedDamage = 0; if (percent) absorbedDamage = damage * hit / 100; else absorbedDamage = damage >= hit ? hit : damage; absorbedDamage = absorbedDamage >= value ? value : absorbedDamage; value -= absorbedDamage; if (absorbedDamage > 0) attackResult.setShieldType(shieldType); attackResult.setDamage(damage - absorbedDamage); if (value <= 0) { effect.endEffect(); return; } } else if (shieldType == 1) // shield type 1, reflected damage { int radius = value; if (MathUtil.isIn3dRange(attacker, effect.getEffected(), radius)) { attackResult.setShieldType(shieldType); attackResult.setReflectedDamage(hit); attackResult.setSkillId(effect.getSkillId()); attacker .getController() .onAttack(effect.getEffected(), hit, AttackStatus.NORMALHIT, false); if (effect.getEffected() instanceof Player) PacketSendUtility.sendPacket( (Player) effect.getEffected(), SM_SYSTEM_MESSAGE.STR_SKILL_PROC_EFFECT_OCCURRED( effect.getSkillTemplate().getNameId())); } } else if (shieldType == 4) // shield type 4, protect { int range = hit; if (effect.getEffector().getLifeStats().isAlreadyDead()) { effect.endEffect(); break; } if (MathUtil.isIn3dRange(effect.getEffector(), effect.getEffected(), range)) { int damageProtected = 0; if (percent) damageProtected = ((int) (attackResult.getDamage() * value * 0.01)); else damageProtected = value; int finalDamage = attackResult.getDamage() - damageProtected; attackResult.setDamage((finalDamage <= 0 ? 0 : finalDamage)); attackResult.setShieldType(shieldType); attackResult.setSkillId(effect.getSkillId()); effect .getEffector() .getController() .onAttack(attacker, damageProtected, AttackStatus.NORMALHIT, false); } } } }