Advertisement
Guest User

Untitled

a guest
Oct 5th, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.74 KB | None | 0 0
  1.     public void onMagicHitTimer(L2Character[] targets, L2Skill skill, int coolTime, boolean instant, boolean simultaneously)
  2.     {
  3.         if (skill == null)
  4.         {
  5.             abortCast();
  6.             setAttackingChar(null);
  7.             return;
  8.         }
  9.  
  10.         if ((targets == null || targets.length == 0) && skill.getTargetType() != SkillTargetType.TARGET_AURA)
  11.         {
  12.             abortCast();
  13.             setAttackingChar(null);
  14.             return;
  15.         }
  16.  
  17.         if (getFusionSkill() != null)
  18.         {
  19.             if (simultaneously)
  20.             {
  21.                 _skillCast2 = null;
  22.                 setIsCastingSimultaneouslyNow(false);
  23.             }
  24.             else
  25.             {
  26.                 _skillCast = null;
  27.                 setIsCastingNow(false);
  28.             }
  29.             if(targets!=null && targets.length>0)
  30.                 notifyQuestEventSkillFinished(skill, targets[0]);
  31.             getFusionSkill().onCastAbort();
  32.             return;
  33.         }
  34.  
  35.         L2Effect mog = getFirstEffect(L2EffectType.SIGNET_GROUND);
  36.         if (mog != null)
  37.         {
  38.             if (simultaneously)
  39.             {
  40.                 _skillCast2 = null;
  41.                 setIsCastingSimultaneouslyNow(false);
  42.             }
  43.             else
  44.             {
  45.                 _skillCast = null;
  46.                 setIsCastingNow(false);
  47.             }
  48.             mog.exit();
  49.             if(targets!=null && targets.length>0)
  50.                 notifyQuestEventSkillFinished(skill, targets[0]);
  51.             return;
  52.         }
  53.         if(Config.CONSUME_ON_SUCCESS)
  54.             consume(skill);
  55.         try
  56.         {
  57.             for (L2Object element : targets)
  58.             {
  59.                 if (element instanceof L2PlayableInstance)
  60.                 {
  61.                     L2Character target = (L2Character) element;
  62.  
  63.                     if (skill.getSkillType() == L2SkillType.BUFF)
  64.                     {
  65.                         SystemMessage smsg = new SystemMessage(SystemMessageId.YOU_FEEL_S1_EFFECT);
  66.                         smsg.addSkillName(skill);
  67.                         target.sendPacket(smsg);
  68.                     }
  69.  
  70.                     if (this instanceof L2PcInstance && target instanceof L2Summon)
  71.                         ((L2Summon) target).broadcastFullInfo();
  72.                 }
  73.             }
  74.  
  75.             // Consume Items if necessary and Send the Server->Client packet InventoryUpdate with Item modification to all the L2Character
  76.             if (skill.getItemConsume() > 0)
  77.             {
  78.                 if (!destroyItemByItemId("Consume", skill.getItemConsumeId(), skill.getItemConsume(), null, false))
  79.                 {
  80.                     sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);
  81.                     abortCast();
  82.                     return;
  83.                 }
  84.             }
  85.  
  86.             if (this instanceof L2PcInstance)
  87.             {
  88.                 L2PcInstance player = (L2PcInstance) this;
  89.                 // Consume Charges if necessary ... L2SkillChargeDmg does the consume by itself.
  90.                 if (skill.getNeededCharges() > 0 && !(skill instanceof L2SkillChargeDmg) && skill.getConsumeCharges())
  91.                     player.decreaseCharges(skill.getNeededCharges());
  92.             }
  93.  
  94.             // Launch the magic skill in order to calculate its effects
  95.                 callSkill(skill, targets);
  96.         }
  97.         catch (Exception e)
  98.         {
  99.            
  100.         }
  101.  
  102.         if (instant || coolTime == 0)
  103.             onMagicFinalizer(skill, (targets==null || targets.length==0)?null:targets[0], simultaneously);
  104.         else
  105.         {
  106.             if (simultaneously)
  107.                 _skillCast2 = ThreadPoolManager.getInstance().scheduleEffect(new MagicUseTask(targets, skill, coolTime, 3, simultaneously), coolTime);
  108.             else
  109.                 _skillCast = ThreadPoolManager.getInstance().scheduleEffect(new MagicUseTask(targets, skill, coolTime, 3, simultaneously), coolTime);
  110.         }
  111.     }
  112.  
  113.     /**
  114.      * Runs after skill hitTime+coolTime
  115.      */
  116.     public void onMagicFinalizer(L2Skill skill, L2Object target, boolean simultaneously)
  117.     {
  118.         if (simultaneously)
  119.         {
  120.             _skillCast2 = null;
  121.             setIsCastingSimultaneouslyNow(false);
  122.             return;
  123.         }
  124.  
  125.         _skillCast = null;
  126.         setIsCastingNow(false);
  127.         _castInterruptTime = 0;
  128.  
  129.         if (skill.isOffensive() && !skill.isNeutral() && skill.getSkillType() != L2SkillType.UNLOCK && skill.getSkillType() != L2SkillType.DELUXE_KEY_UNLOCK && skill.getSkillType() != L2SkillType.MAKE_KILLABLE)
  130.             getAI().clientStartAutoAttack();
  131.  
  132.         // Notify the AI of the L2Character with EVT_FINISH_CASTING
  133.         getAI().notifyEvent(CtrlEvent.EVT_FINISH_CASTING);
  134.  
  135.         notifyQuestEventSkillFinished(skill, target);
  136.  
  137.         if (getAI().getIntention() != AI_INTENTION_MOVE_TO)
  138.         {
  139.             switch (skill.getSkillType())
  140.             {
  141.             case PDAM:
  142.             case BLOW:
  143.             case CHARGEDAM:
  144.             case SPOIL:
  145.             case SOW:
  146.             case DRAIN_SOUL: // Soul Crystal casting
  147.                 if (getTarget() instanceof L2Character && getTarget() != this && target == getTarget())
  148.                     getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, getTarget());
  149.                 break;
  150.             }
  151.         }
  152.         if(_chanceSkills!=null && target!=null )
  153.             _chanceSkills.onAttack(target);
  154.  
  155.         if (this instanceof L2PcInstance)
  156.         {
  157.             L2PcInstance currPlayer = (L2PcInstance) this;
  158.             SkillDat queuedSkill = currPlayer.getQueuedSkill();
  159.  
  160.             currPlayer.setCurrentSkill(null, false, false);
  161.  
  162.             if (queuedSkill != null)
  163.             {
  164.                 currPlayer.setQueuedSkill(null, false, false);
  165.                 ThreadPoolManager.getInstance().executeAi(new QueuedMagicUseTask(currPlayer, queuedSkill.getSkill(), queuedSkill.isCtrlPressed(), queuedSkill.isShiftPressed()));
  166.             }
  167.             if(skill.getItemConsume()!=0)
  168.                 sendPacket(new InventoryUpdate());
  169.         }
  170.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement