Рейтинг темы:
  • 0 Голос(ов) - 0 в среднем
  • 1
  • 2
  • 3
  • 4
  • 5
Проверка комбат зоны (итем)
#1
Помогите пожалуйста сюда запихнуть проверку на комбат зону (чтобы итем нельзя было юзануть, пока дерёшься)
Код:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

package net.sf.l2j.gameserver.handler.itemhandlers;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2PcIns tance;
import net.sf.l2j.gameserver.model.actor.instance.L2PetIn stance;
import net.sf.l2j.gameserver.model.actor.instance.L2Playa bleInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.serverpackets.MagicSkillUser ;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.util.FloodProtector;

public class FBuff implements IItemHandler
{
protected static final Logger _log = Logger.getLogger(Potions.class.getName());
private static final int[] ITEM_IDS = {1163};


private int _herbstask = 0;

private class HerbTask implements Runnable
{
private L2PcInstance _activeChar;
private int _magicId;
private int _level;
HerbTask(L2PcInstance activeChar, int magicId, int level)
{
_activeChar = activeChar;
_magicId = magicId;
_level = level;
}
public void run()
{
try
{
usePotion(_activeChar, _magicId, _level);
}
catch (Throwable t)
{
_log.log(Level.WARNING, "", t);
}
}
}
public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
{
L2PcInstance activeChar;
if (playable instanceof L2PcInstance)
activeChar = (L2PcInstance) playable;
else if (playable instanceof L2PetInstance)
activeChar = ((L2PetInstance) playable).getOwner();
else
return;
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVA ILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
if (activeChar.isAllSkillsDisabled())
{
activeChar.sendPacket(new ActionFailed());
return;
}

L2Skill skill;
int itemId = item.getItemId();
if (itemId == 1163)
{
skill = SkillTable.getInstance().getInfo(276, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(273, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(365, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(264, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(267, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(304, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(268, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1363, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1085, 3);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1303, 1);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1059, 3);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1040, 3);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1204, 2);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
skill = SkillTable.getInstance().getInfo(1062, 2);
skill.getEffects(activeChar, activeChar);
activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
}
}
public boolean usePotion(L2PcInstance activeChar, int magicId, int level)
{
if (activeChar.isCastingNow() && magicId>2277 && magicId<2285)
{
_herbstask += 100;
ThreadPoolManager.getInstance().scheduleAi(new HerbTask(activeChar, magicId, level), _herbstask);
}
else
{
if (magicId>2277 && magicId<2285 && _herbstask>=100) _herbstask -= 100;
L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
if (skill != null)
{
activeChar.doCast(skill);
if (!(activeChar.isSitting() && !skill.isPotion()))
return true;
}
}
return false;
} public int[] getItemIds()
{
return ITEM_IDS;
}
}
Я пытался что-то вроде этого вставить
Код:
if (activeChar.isInCombat())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_LEAVE_DURING_COMBAT));
return;
}
, но ничего не вышло.

Добавлено через 6 часов 48 минут
Можно закрывать тему, разобрался.
Ответ
#2
Дак ты если разобрался ты напиши что ты сделал , ато тема пустая останется и людям не поможет!
Ответ
#3
Evil-Soft Написал:Дак ты если разобрался ты напиши что ты сделал , ато тема пустая останется и людям не поможет!

Дак он уже выложил же по сути что надо)
судя по коду, то после
PHP код:
<?php 
if (activeChar.isInOlympiadMode())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVA ILABLE_FOR_THE_OLYMPIAD_EVENT));
return;
}
нужно добавить
PHP код:
<?php 
if (activeChar.isInCombat())
{
activeChar.sendPacket(new SystemMessage(SystemMessageId.YOU_CANNOT_LEAVE_DURING_COMBAT));
return;
}
Если помог, ткни плюсеГ, это же так просто
Ответ
#4
Нет, не комбат.
Импортим "AttackStanceTaskManager"
Код:
import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;
И пишем запрет
Код:
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(activeChar))
{
activeChar.sendMessage("Package will reject, a fighting zone!");
return;
}

А комбат - это во время атаки, а не во время боевой стойки.. это разные вещи Smile

Целый код:
Код:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/

package net.sf.l2j.gameserver.handler.itemhandlers;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.datatables.SkillTable;
import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2Skill;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PetInstance;
import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
import net.sf.l2j.gameserver.network.SystemMessageId;
import net.sf.l2j.gameserver.serverpackets.ActionFailed;
import net.sf.l2j.gameserver.serverpackets.MagicSkillUser;
import net.sf.l2j.gameserver.serverpackets.SystemMessage;
import net.sf.l2j.gameserver.util.FloodProtector;
import net.sf.l2j.gameserver.taskmanager.AttackStanceTaskManager;

public class FBuff implements IItemHandler
{
  protected static final Logger _log = Logger.getLogger(Potions.class.getName());
  private static final int[] ITEM_IDS = {1163};
    
    
  private int _herbstask = 0;

  private class HerbTask implements Runnable
  {
      private L2PcInstance _activeChar;
      private int _magicId;
      private int _level;
      HerbTask(L2PcInstance activeChar, int magicId, int level)
      {
        _activeChar = activeChar;
        _magicId = magicId;
        _level = level;
      }
      public void run()
      {
        try
        {
            usePotion(_activeChar, _magicId, _level);
        }
        catch (Throwable t)
        {
            _log.log(Level.WARNING, "", t);
        }
      }
  }
  public synchronized void useItem(L2PlayableInstance playable, L2ItemInstance item)
  {
      L2PcInstance activeChar;    
      if (playable instanceof L2PcInstance)
        activeChar = (L2PcInstance) playable;
      else if (playable instanceof L2PetInstance)
        activeChar = ((L2PetInstance) playable).getOwner();
      else
        return;    
      if (activeChar.isInOlympiadMode())
      {
        activeChar.sendPacket(new SystemMessage(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT));
        return;
      }
      if (activeChar.isAllSkillsDisabled())
      {
        activeChar.sendPacket(new ActionFailed());
        return;
      }
if (AttackStanceTaskManager.getInstance().getAttackStanceTask(activeChar))
{
activeChar.sendMessage("Package will reject, a fighting zone!");
return;
}

      if (activeChar.isInDuel())
      {
        activeChar.sendPacket(new ActionFailed());
        return;
      }

      if (activeChar.isInFunEvent())
      {
        activeChar.sendPacket(new ActionFailed());
        return;
      }

    
      L2Skill skill;
      int itemId = item.getItemId();
      if (itemId == 1163)
      {
        skill = SkillTable.getInstance().getInfo(276, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(273, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(365, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(264, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(267, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(304, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(268, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1363, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1085, 3);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1303, 1);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1059, 3);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1040, 3);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1204, 2);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
        skill = SkillTable.getInstance().getInfo(1062, 2);
        skill.getEffects(activeChar, activeChar);
        activeChar.broadcastPacket(new MagicSkillUser(activeChar, activeChar, skill.getId(), 1, skill.getHitTime(), 0));
      }
  }
  public boolean usePotion(L2PcInstance activeChar, int magicId, int level)
  {
      if (activeChar.isCastingNow() && magicId>2277 && magicId<2285)
      {
        _herbstask += 100;
        ThreadPoolManager.getInstance().scheduleAi(new HerbTask(activeChar, magicId, level), _herbstask);
      }
      else
      {
        if (magicId>2277 && magicId<2285 && _herbstask>=100) _herbstask -= 100;
        L2Skill skill = SkillTable.getInstance().getInfo(magicId, level);
        if (skill != null)
        {
            activeChar.doCast(skill);
            if (!(activeChar.isSitting() && !skill.isPotion()))
              return true;
        }
      }
      return false;
  }  public int[] getItemIds()
  {
      return ITEM_IDS;
  }
}

Дайте плюсеГ, если кому-нить пригодилось))
Ответ


Возможно похожие темы ...
Тема Автор Ответы Просмотры Последний пост
  Проверка на GameGuard dantest 0 1,065 09-21-2015, 07:49 PM
Последний пост: dantest
  Каст спела, проверка таргета Empatic 4 2,025 06-23-2015, 11:35 PM
Последний пост: Empatic
  Проверка Empatic 6 1,764 06-20-2015, 02:44 PM
Последний пост: Empatic
  Проверка условий в html NPC Fadd 0 1,540 12-15-2014, 11:45 PM
Последний пост: Fadd
  Проверка у Valakas Manager Snowball1 9 2,180 09-15-2014, 02:01 AM
Последний пост: Snowball1
  Создание ПВП зоны (Опены) ZIP 9 2,852 08-02-2014, 10:08 PM
Последний пост: ZIP
  Итем который нельзя ложить в банк Rolfer 9 2,502 05-20-2014, 08:23 PM
Последний пост: Rolfer
  Проверка времени mishut 7 2,047 04-16-2014, 07:03 PM
Последний пост: mishut
  Проверка на символы в нике desolator 0 1,602 02-27-2014, 10:38 PM
Последний пост: desolator
  Проверка на "combat=false" у скилла LastStand 12 2,251 12-09-2013, 04:34 PM
Последний пост: Aristocrat

Перейти к форуму:


Пользователи, просматривающие эту тему: 1 Гость(ей)