L2JLisvus

Would you like to react to this message? Create an account in a few clicks or log in to continue.

2 posters

    CatsEyeBandit [COMMITED]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    CatsEyeBandit [COMMITED] Empty CatsEyeBandit [COMMITED]

    Post  Karakan 25th September 2015, 16:04

    Implemented onAttack/onKill retail speak lines to Cats Eye Bandits.

    ToDo: Need to check if they're suppose to run away when hp < 50%.


    Pastebin link


    Last edited by Karakan on 12th July 2019, 15:32; edited 1 time in total
    DnR
    DnR
    Admin
    Admin


    Posts : 1475
    Join date : 2012-12-03
    Age : 34

    CatsEyeBandit [COMMITED] Empty Re: CatsEyeBandit [COMMITED]

    Post  DnR 25th August 2017, 23:14

    Added to trunk. Cool
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    CatsEyeBandit [COMMITED] Empty Re: CatsEyeBandit [COMMITED]

    Post  Karakan 23rd June 2019, 17:04

    Update with more retail like AI.  Cool


    Diff...


    Code:

    Index: CatsEyeBandit.java
    ===================================================================
    --- CatsEyeBandit.java  (revision 617)
    +++ CatsEyeBandit.java  (working copy)

     package ai.individual;
     
    +import net.sf.l2j.gameserver.ai.CtrlIntention;
    +import net.sf.l2j.gameserver.model.L2CharPosition;
    +import net.sf.l2j.gameserver.model.L2Object;
    +import net.sf.l2j.gameserver.geoengine.GeoData;
    +import net.sf.l2j.gameserver.model.L2Skill;
     import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     import net.sf.l2j.gameserver.model.quest.Quest;
    @@ -21,40 +26,83 @@
     import net.sf.l2j.util.Rnd;
     
     /**
    + * Cats Eye Bandit AI
      * @by Karakan for L2JLisvus
      */
     public class CatsEyeBandit extends Quest
     {
    -  private static final int CATS_EYE_BANDIT = 5038;

    -  public CatsEyeBandit(int questId, String name, String descr)
    +  public CatsEyeBandit (int questId, String name, String descr)
        {
          super(questId, name, descr);
    -      int[] mobs =
    -      {
    -        CATS_EYE_BANDIT
    -      };
    +      int[] mobs = {5038};
          registerMobs(mobs);
        }
       
        @Override
    -  public String onAttack(L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
    -  {
    -      if ((npc.getNpcId() == CATS_EYE_BANDIT) && (Rnd.get(10) == 0))
    +    public String onSpawn(L2NpcInstance npc)
    +    {
    +      // Reset script value
    +        if (npc.getScriptValue() > 0)
    +        {
    +          npc.setScriptValue(0);
    +        }
    +        return super.onSpawn(npc);
    +    } 
    +
    +  @Override
    +    public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
    +    { 
    +      final int rndX = npc.getX() + Rnd.get(-1000, +1000);
    +      final int rndY = npc.getY() + Rnd.get(-1000, +1000);
    +
    +      if (!npc.isMoving() && GeoData.getInstance().canMove(npc.getX(), npc.getY(), npc.getZ(), rndX, rndY, npc.getZ())) 
          {
    -        npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), "You childish fool, do you think you can catch me?"));
    +        npc.disableCoreAI(true);
    +        npc.setRunning();
    +        npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(rndX, rndY, npc.getZ(), 0));
    +          if (npc.getScriptValue() == 0)
    +        {
    +            npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"You childish fool, do you think you can catch me?"));
    +            npc.setScriptValue(1);
    +        }
          }
    +
          return super.onAttack(npc, attacker, damage, isPet);
    +    }
    +
    +  @Override
    +  public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
    +  {
    +      final int rndX = npc.getX() + Rnd.get(-1000, +1000);
    +      final int rndY = npc.getY() + Rnd.get(-1000, +1000);
    +
    +      if (skill.isOffensive() && targets[0] == npc)
    +      {
    +        if (!npc.isMoving() && GeoData.getInstance().canMove(npc.getX(), npc.getY(), npc.getZ(), rndX, rndY, npc.getZ())) 
    +        {
    +            npc.disableCoreAI(true);
    +            npc.setRunning();
    +            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new L2CharPosition(rndX, rndY, npc.getZ(), 0));
    +            if (npc.getScriptValue() == 0)
    +            {
    +              npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"You childish fool, do you think you can catch me?"));
    +              npc.setScriptValue(1);
    +            }
    +        }
    +        }
    +
    +      return super.onSkillSee(npc, caster, skill, targets, isPet);
        }

    +
        @Override
    -  public String onKill(L2NpcInstance npc, L2PcInstance killer, boolean isPet)
    +  public String onKill (L2NpcInstance npc, L2PcInstance killer, boolean isPet)
        {
    -      if ((npc.getNpcId() == CATS_EYE_BANDIT) && (Rnd.get(10) == 0))
    +      if (Rnd.get(100) < 50)
          {
    -        npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), "I must do something about this shameful incident..."));
    +        npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"I must do something about this shameful incident..."));
          }
    -      return super.onKill(npc, killer, isPet);
    +
    +      return super.onKill(npc,killer,isPet);
        }
       
        public static void main(String[] args)

    DnR
    DnR
    Admin
    Admin


    Posts : 1475
    Join date : 2012-12-03
    Age : 34

    CatsEyeBandit [COMMITED] Empty Re: CatsEyeBandit [COMMITED]

    Post  DnR 30th June 2019, 18:05

    Script updated. Thanks for your work. Wink

    Sponsored content


    CatsEyeBandit [COMMITED] Empty Re: CatsEyeBandit [COMMITED]

    Post  Sponsored content


      Current date/time is 19th May 2024, 08:25