Package npc.model

Examples of npc.model.SquashInstance


      if (_polimorphTask != null)
      {
        _polimorphTask.cancel(false);
        _polimorphTask = null;
      }
      final SquashInstance actor = getActor();
      if (actor != null)
      {
        actor.deleteMe();
      }
    }
    return false;
  }
View Full Code Here


   * @param caster Creature
   */
  @Override
  protected void onEvtSeeSpell(Skill skill, Creature caster)
  {
    final SquashInstance actor = getActor();
    if ((actor == null) || (skill.getId() != 2005))
    {
      return;
    }
    switch (_tryCount)
    {
      case 0:
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if (Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess0[Rnd.get(textSuccess0.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail0[Rnd.get(textFail0.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 1:
        if ((System.currentTimeMillis() - _lastNectarUse) < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if (Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess1[Rnd.get(textSuccess1.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail1[Rnd.get(textFail1.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 2:
        if ((System.currentTimeMillis() - _lastNectarUse) < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if (Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess2[Rnd.get(textSuccess2.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail2[Rnd.get(textFail2.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 3:
        if ((System.currentTimeMillis() - _lastNectarUse) < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if (Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess3[Rnd.get(textSuccess3.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail3[Rnd.get(textFail3.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 4:
        if ((System.currentTimeMillis() - _lastNectarUse) < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if (Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess4[Rnd.get(textSuccess4.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail4[Rnd.get(textFail4.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        if (_npcId == Young_Squash)
        {
          if (_nectar < 3)
          {
View Full Code Here

   * @param damage int
   */
  @Override
  protected void onEvtAttacked(Creature attacker, int damage)
  {
    final SquashInstance actor = getActor();
    if ((actor != null) && Rnd.chance(5))
    {
      Functions.npcSay(actor, textOnAttack[Rnd.get(textOnAttack.length)]);
    }
  }
View Full Code Here

   */
  @Override
  protected void onEvtDead(Creature killer)
  {
    _tryCount = -1;
    final SquashInstance actor = getActor();
    if (actor == null)
    {
      return;
    }
    double dropMod = 1.5;
    switch (_npcId)
    {
      case Low_Quality_Squash:
        dropMod *= 1;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case High_Quality_Squash:
        dropMod *= 2;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case King_Squash:
        dropMod *= 4;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case Low_Quality_Large_Squash:
        dropMod *= 12.5;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case High_Quality_Large_Squash:
        dropMod *= 25;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case Emperor_Squash:
        dropMod *= 50;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      default:
        dropMod *= 0;
        Functions.npcSay(actor, "Ouch, if I had died like this, you could obtain nothing!");
        Functions.npcSay(actor, "The news about my death shouldn't spread, oh!");
        break;
    }
    super.onEvtDead(actor);
    if (dropMod > 0)
    {
      if (_polimorphTask != null)
      {
        _polimorphTask.cancel(false);
        _polimorphTask = null;
        Log.add("TheFallHarvest :: Player " + actor.getSpawner().getName() + " tried to use cheat (SquashAI clone): killed " + actor + " after polymorfing started", "illegal-actions");
        return;
      }
      for (RewardData d : _dropList)
      {
        List<RewardItem> itd = d.roll(null, dropMod);
        for (RewardItem i : itd)
        {
          actor.dropItem(actor.getSpawner(), i.itemId, i.count);
        }
      }
    }
  }
View Full Code Here

     * Method runImpl.
     */
    @Override
    public void runImpl()
    {
      final SquashInstance actor = getActor();
      if (actor == null)
      {
        return;
      }
      SimpleSpawner spawn = null;
      try
      {
        spawn = new SimpleSpawner(NpcHolder.getInstance().getTemplate(_npcId));
        spawn.setLoc(actor.getLoc());
        final NpcInstance npc = spawn.doSpawn(true);
        npc.setAI(new SquashAI(npc));
        ((SquashInstance) npc).setSpawner(actor.getSpawner());
      }
      catch (Exception e)
      {
        e.printStackTrace();
      }
      _timeToUnspawn = Long.MAX_VALUE;
      actor.deleteMe();
    }
View Full Code Here

      {
        _polimorphTask.cancel(true);
        _polimorphTask = null;
      }
      stopAITask();
      SquashInstance actor = getActor();
      if(actor != null)
      {
        actor.deleteMe();
      }
    }
    return false;
  }
View Full Code Here

  }

  @Override
  protected void onEvtSeeSpell(L2Skill skill, L2Character caster)
  {
    SquashInstance actor = getActor();
    if(actor == null || skill.getId() != 2005)
    {
      return;
    }
    switch(_tryCount)
    {
      case 0:
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if(Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess0[Rnd.get(textSuccess0.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail0[Rnd.get(textFail0.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 1:
        if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if(Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess1[Rnd.get(textSuccess1.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail1[Rnd.get(textFail1.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 2:
        if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if(Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess2[Rnd.get(textSuccess2.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail2[Rnd.get(textFail2.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 3:
        if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if(Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess3[Rnd.get(textSuccess3.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail3[Rnd.get(textFail3.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        break;
      case 4:
        if(System.currentTimeMillis() - _lastNectarUse < NECTAR_REUSE)
        {
          Functions.npcSay(actor, textTooFast[Rnd.get(textTooFast.length)]);
          return;
        }
        _tryCount++;
        _lastNectarUse = System.currentTimeMillis();
        if(Rnd.chance(50))
        {
          _nectar++;
          Functions.npcSay(actor, textSuccess4[Rnd.get(textSuccess4.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Level_up, 1, NECTAR_REUSE, 0));
        }
        else
        {
          Functions.npcSay(actor, textFail4[Rnd.get(textFail4.length)]);
          actor.broadcastPacket(new MagicSkillUse(actor, actor, Squash_Poisoned, 1, NECTAR_REUSE, 0));
        }
        if(_npcId == Young_Squash)
        {
          if(_nectar < 3)
          {
View Full Code Here

  }

  @Override
  protected void onEvtAttacked(L2Character attacker, int damage)
  {
    SquashInstance actor = getActor();
    if(actor != null && Rnd.chance(5))
    {
      Functions.npcSay(actor, textOnAttack[Rnd.get(textOnAttack.length)]);
    }
  }
View Full Code Here

  @Override
  protected void onEvtDead(L2Character killer)
  {
    _tryCount = -1;
    SquashInstance actor = getActor();
    if(actor == null)
    {
      return;
    }
    double dropMod = 1.5;
    switch(_npcId)
    {
      case Low_Quality_Squash:
        dropMod *= 1;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case High_Quality_Squash:
        dropMod *= 2;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case King_Squash:
        dropMod *= 4;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case Low_Quality_Large_Squash:
        dropMod *= 12.5;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case High_Quality_Large_Squash:
        dropMod *= 25;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      case Emperor_Squash:
        dropMod *= 50;
        Functions.npcSay(actor, "The pampkin opens!!!");
        Functions.npcSay(actor, "ya yo! Opens! Good thing many...");
        break;
      default:
        dropMod *= 0;
        Functions.npcSay(actor, "Ouch, if I had died like this, you could obtain nothing!");
        Functions.npcSay(actor, "The news about my death shouldn't spread, oh!");
        break;
    }
    actor.broadcastPacket(new Die(actor));
    setIntention(AI_INTENTION_IDLE);
    if(dropMod > 0)
    {
      if(_polimorphTask != null)
      {
        _polimorphTask.cancel(true);
        _polimorphTask = null;
        Log.add("TheFallHarvest :: Player " + actor.getSpawner().getName() + " tried to use cheat (SquashAI clone): killed " + actor + " after polymorfing started", "illegal-actions");
        return; // при таких вариантах ничего не даем
      }
      for(L2DropData d : _dropList)
      {
        GArray<ItemToDrop> itd = d.roll(null, dropMod, false);
        for(ItemToDrop i : itd)
        {
          actor.dropItem(actor.getSpawner(), i.itemId, i.count);
        }
      }
    }
  }
View Full Code Here

{
  public class PolimorphTask implements Runnable
  {
    public void run()
    {
      SquashInstance actor = getActor();
      if(actor == null)
      {
        return;
      }
      L2Spawn spawn = null;
      try
      {
        spawn = new L2Spawn(NpcTable.getTemplate(_npcId));
        spawn.setLoc(actor.getLoc());
        L2NpcInstance npc = spawn.doSpawn(true);
        npc.setAI(new SquashAI(npc));
        ((SquashInstance) npc).setSpawner(actor.getSpawner());
      }
      catch(Exception e)
      {
        e.printStackTrace();
      }
      _timeToUnspawn = Long.MAX_VALUE;
      stopAITask();
      actor.deleteMe();
    }
View Full Code Here

TOP

Related Classes of npc.model.SquashInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.