Advertisement
Guest User

kapuk99

a guest
Jan 1st, 2010
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.74 KB | None | 0 0
  1. /*
  2. This file is part of the OdinMS Maple Story Server
  3. Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
  4. Matthias Butz <matze@odinms.de>
  5. Jan Christian Meyer <vimes@odinms.de>
  6.  
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU Affero General Public License version 3
  9. as published by the Free Software Foundation. You may not use, modify
  10. or distribute this program under any other version of the
  11. GNU Affero General Public License.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU Affero General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Affero General Public License
  19. along with this program.  If not, see <http://www.gnu.org/licenses/>.
  20.  */
  21. package net.sf.odinms.net.channel.handler;
  22.  
  23. import java.util.List;
  24. import java.util.concurrent.ScheduledFuture;
  25. import net.sf.odinms.client.ISkill;
  26. import net.sf.odinms.client.MapleCharacter;
  27. import net.sf.odinms.client.MapleCharacter.CancelCooldownAction;
  28. import net.sf.odinms.client.MapleClient;
  29. import net.sf.odinms.client.SkillFactory;
  30. import net.sf.odinms.net.MaplePacket;
  31. import net.sf.odinms.server.MapleStatEffect;
  32. import net.sf.odinms.server.TimerManager;
  33. import net.sf.odinms.tools.MaplePacketCreator;
  34. import net.sf.odinms.tools.Pair;
  35. import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
  36.  
  37. public class MagicDamageHandler extends AbstractDealDamageHandler {
  38.     @Override
  39.     public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
  40.         //attack air
  41.         //23 00 03 01 00 00 00 00 00 90 01 04 DB 82 A9 00 FB FC D7 00
  42.         //attack air
  43.         //25 00 03 01 BE BC 21 00 00 2F 06 06 A1 1B 66 01 00 00 5F 00
  44.  
  45.         AttackInfo attack = parseDamage(c.getPlayer(), slea, false);
  46.  
  47.         MapleCharacter player = c.getPlayer();
  48.  
  49.         if (player.isOnCoolDown(attack.skill)) {
  50.             c.disconnect(); // Naughty, no hacking. Not Made this autoban because of lag
  51.             return;
  52.         }
  53.  
  54.         MaplePacket packet = MaplePacketCreator.magicAttack(player.getId(), attack.skill, attack.stance,
  55.             attack.numAttackedAndDamage, attack.allDamage, -1, attack.speed);
  56.             if (attack.skill == 2121001 || attack.skill == 2221001 || attack.skill == 2321001) {
  57.                 packet = MaplePacketCreator.magicAttack(player.getId(), attack.skill, attack.stance,
  58.                     attack.numAttackedAndDamage, attack.allDamage, attack.charge, attack.speed);
  59.             }
  60.  
  61.  
  62.         player.getMap().broadcastMessage(player, packet, false, true);
  63.  
  64.         MapleStatEffect effect = attack.getAttackEffect(c.getPlayer());
  65.         int maxdamage;
  66.  
  67.         // TODO fix magic damage calculation
  68.         maxdamage = 199999;
  69.  
  70.         ISkill skill = SkillFactory.getSkill(attack.skill);
  71.         int skillLevel = c.getPlayer().getSkillLevel(skill);
  72.         MapleStatEffect effect_ = skill.getEffect(skillLevel);
  73.         if (effect_.getCooldown() > 0) {
  74.             c.getSession().write(MaplePacketCreator.skillCooldown(attack.skill, effect_.getCooldown()));
  75.             ScheduledFuture<?> timer = TimerManager.getInstance().schedule(new CancelCooldownAction(c.getPlayer(), attack.skill), effect_.getCooldown() * 1000);
  76.             c.getPlayer().addCooldown(attack.skill, System.currentTimeMillis(), effect_.getCooldown() * 1000, timer);
  77.         }
  78.  
  79.         applyAttack(attack, player, maxdamage, effect.getAttackCount());
  80.  
  81.         // MP Eater
  82.         for (int i = 1; i <= 3; i++) {
  83.             ISkill eaterSkill = SkillFactory.getSkill(2000000 + i * 100000);
  84.             int eaterLevel = player.getSkillLevel(eaterSkill);
  85.             if (eaterLevel > 0) {
  86.                 for (Pair<Integer, List<Integer>> singleDamage : attack.allDamage) {
  87.                     eaterSkill.getEffect(eaterLevel).applyPassive(player, player.getMap().getMapObject(singleDamage.getLeft()), 0);
  88.                 }
  89.                 break;
  90.             }
  91.         }
  92.     }
  93. }
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement