@Override public void attackTarget(Creature target) { Npc npc = getOwner(); /** Check all prerequisites */ if (npc == null || npc.getLifeStats().isAlreadyDead() || !npc.isSpawned()) return; if (!npc.canAttack()) return; AI<?> ai = npc.getAi(); NpcGameStats gameStats = npc.getGameStats(); if (target == null || target.getLifeStats().isAlreadyDead()) { ai.handleEvent(Event.MOST_HATED_CHANGED); return; } /** notify attack observers */ super.attackTarget(target); /** Calculate and apply damage */ List<AttackResult> attackList = AttackUtil.calculateAttackResult(npc, target); int damage = 0; for (AttackResult result : attackList) { damage += result.getDamage(); } int attackType = 0; // TODO investigate attack types (0 or 1) PacketSendUtility.broadcastPacket( npc, new SM_ATTACK(npc, target, gameStats.getAttackCounter(), 274, attackType, attackList)); target.getController().onAttack(npc, damage, true); gameStats.increaseAttackCounter(); }
@Override public void startEffect(Effect effect) { final Creature effected = effect.getEffected(); effected.getController().cancelCurrentSkill(); effect.setAbnormal(EffectId.STUMBLE.getEffectId()); effected.getEffectController().setAbnormal(EffectId.STUMBLE.getEffectId()); PacketSendUtility.broadcastPacketAndReceive( effected, new SM_FORCED_MOVE(effect.getEffector(), effected)); }
@Override public void onPeriodicAction(Effect effect) { Creature effected = effect.getEffected(); Creature effector = effect.getEffector(); int valueWithDelta = value + delta * effect.getSkillLevel(); int damage = AttackUtil.calculateMagicalOverTimeSkillResult( effect, valueWithDelta, element, this.position); effected .getController() .onAttack(effector, effect.getSkillId(), TYPE.DAMAGE, damage, false, LOG.POISON); effected.getObserveController().notifyDotAttackedObservers(effector, effect); }