L2SkillDecoy.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.skills.l2skills;
  16. import com.l2jserver.gameserver.datatables.NpcTable;
  17. import com.l2jserver.gameserver.idfactory.IdFactory;
  18. import com.l2jserver.gameserver.model.L2Object;
  19. import com.l2jserver.gameserver.model.L2Skill;
  20. import com.l2jserver.gameserver.model.StatsSet;
  21. import com.l2jserver.gameserver.model.actor.L2Character;
  22. import com.l2jserver.gameserver.model.actor.instance.L2DecoyInstance;
  23. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  24. import com.l2jserver.gameserver.templates.chars.L2NpcTemplate;
  25. public class L2SkillDecoy extends L2Skill
  26. {
  27. private final int _npcId;
  28. private final int _summonTotalLifeTime;
  29. public L2SkillDecoy(StatsSet set)
  30. {
  31. super(set);
  32. _npcId = set.getInteger("npcId", 0);
  33. _summonTotalLifeTime= set.getInteger("summonTotalLifeTime", 20000);
  34. }
  35. @Override
  36. public void useSkill(L2Character caster, L2Object[] targets)
  37. {
  38. if (caster.isAlikeDead() || !(caster instanceof L2PcInstance))
  39. return;
  40. if (_npcId == 0)
  41. return;
  42. final L2PcInstance activeChar = (L2PcInstance) caster;
  43. if (activeChar.inObserverMode())
  44. return;
  45. if (activeChar.getPet() != null || activeChar.isMounted())
  46. return;
  47. L2NpcTemplate DecoyTemplate = NpcTable.getInstance().getTemplate(_npcId);
  48. final L2DecoyInstance Decoy = new L2DecoyInstance(IdFactory.getInstance().getNextId(), DecoyTemplate, activeChar, this);
  49. Decoy.setCurrentHp(Decoy.getMaxHp());
  50. Decoy.setCurrentMp(Decoy.getMaxMp());
  51. Decoy.setHeading(activeChar.getHeading());
  52. activeChar.setDecoy(Decoy);
  53. //L2World.getInstance().storeObject(Decoy);
  54. Decoy.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ());
  55. }
  56. public final int getTotalLifeTime()
  57. {
  58. return _summonTotalLifeTime;
  59. }
  60. }