L2JLisvus

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

2 posters

    Honey Bear AI (c2-c4 retail like) [COMMITED]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Honey Bear AI (c2-c4 retail like) [COMMITED] Empty Honey Bear AI (c2-c4 retail like) [COMMITED]

    Post  Karakan 24th March 2016, 17:55

    Npc lines are taken from retail files
    Have fun hunting them^^


    Site Note : Im working on more "oldschool" c1-c4 monters AI's , stay tuned.



    Code:

    /*
     * 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 3 of the License, 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, see <http://www.gnu.org/licenses/>.
     */
    package ai.individual;

    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;
    import net.sf.l2j.gameserver.serverpackets.CreatureSay;
    import net.sf.l2j.util.Rnd;

    /**
     * @by Karakan for L2JLisvus
     */
    public class HoneyBear extends Quest
    {
     private static final int HONEY_BEAR = 5058;
     
     public HoneyBear (int questId, String name, String descr)
     {
     super(questId, name, descr);
     int[] mobs = {HONEY_BEAR};
     registerMobs(mobs);
     }

     @Override
     public String onSpawn(L2NpcInstance npc)
     {
     if (npc.getNpcId() == HONEY_BEAR && Rnd.get(10) == 0)
     {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"What does honey of this place taste like?!"));
     }
     else
     {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Give me some sweet, delicious golden honey!"));
     }
     return super.onSpawn(npc);
     }

     @Override
        public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
        {
            if (npc.getCurrentHp() / npc.getMaxHp() > 0.99) //to prevent chat spamming
            {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"If you give me some honey, I'll at least spare your life..."));
            }
     return super.onAttack(npc, attacker, damage, isPet);
        }

     @Override
     public String onKill (L2NpcInstance npc, L2PcInstance killer, boolean isPet)
     {
     if (npc.getNpcId() == HONEY_BEAR)
     {
     npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Only for lack of honey did I lose to the likes of you."));
     }
     return super.onKill(npc,killer,isPet);
     }

     public static void main(String[] args)
     {
     // now call the constructor (starts up the ai)
     new HoneyBear(-1, "honeybear", "ai/individual");
     }
    }



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


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

    Honey Bear AI (c2-c4 retail like) [COMMITED] Empty Re: Honey Bear AI (c2-c4 retail like) [COMMITED]

    Post  DnR 9th April 2016, 10:03

    Added to datapack. Thanks. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Honey Bear AI (c2-c4 retail like) [COMMITED] Empty Re: Honey Bear AI (c2-c4 retail like) [COMMITED]

    Post  Karakan 23rd June 2019, 17:12

    Updated code.
    Thanks DnR for the "ScriptValue" check in core sunny



    Code:

    Index: HoneyBear.java
    ===================================================================
    --- HoneyBear.java   (revision 617)
    +++ HoneyBear.java   (working copy)
    @@ -25,47 +25,58 @@
      */
     public class HoneyBear extends Quest
     {
    -    private static final int HONEY_BEAR = 5058;
    +   private static final int HONEY_BEAR = 5058;
    +   
    +   public HoneyBear (int questId, String name, String descr)
    +   {
    +      super(questId, name, descr);
    +      int[] mobs = {HONEY_BEAR};
    +      registerMobs(mobs);
    +   }
     
    -    public HoneyBear (int questId, String name, String descr)
    -    {
    -        super(questId, name, descr);
    -        int[] mobs = {HONEY_BEAR};
    -        registerMobs(mobs);
    -    }
    +   @Override
    +   public String onSpawn(L2NpcInstance npc)
    +   {
    +      // Reset script value
    +        if (npc.getScriptValue() > 0)
    +        {
    +           npc.setScriptValue(0);
    +        }      
     
    -    @Override
    -    public String onSpawn(L2NpcInstance npc)
    -    {
    -        if (npc.getNpcId() == HONEY_BEAR && Rnd.get(10) == 0)
    -            npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"What does honey of this place taste like?!"));
    -        else
    -            npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Give me some sweet, delicious golden honey!"));
    +      if (Rnd.get(100) <= 50)
    +      {
    +         npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"What does honey of this place taste like?!"));
    +      }
    +      else
    +      {
    +         npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"Give me some sweet, delicious golden honey!"));
    +      }   
    +      return super.onSpawn(npc);
    +   }
     
    -        return super.onSpawn(npc);
    -    }
    -
    -    @Override
    +   @Override
        public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
    -    {
    -        if (npc.getCurrentHp() / npc.getMaxHp() > 0.99) // to prevent chat spamming
    -            npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"If you give me some honey, I'll at least spare your life..."));
    +    {   
    +        if (npc.getScriptValue() == 0)
    +        {
    +         npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"If you give me some honey, I'll at least spare your life..."));
    +         npc.setScriptValue(1);
    +        }
     
    -        return super.onAttack(npc, attacker, damage, isPet);
    +      return super.onAttack(npc, attacker, damage, isPet);
        }
     
    -    @Override
    -    public String onKill (L2NpcInstance npc, L2PcInstance killer, boolean isPet)
    -    {
    -        if (npc.getNpcId() == HONEY_BEAR)
    -            npc.broadcastPacket(new CreatureSay(npc.getObjectId(),1,npc.getName(),"Only for lack of honey did I lose to the likes of you."));
    +   @Override
    +   public String onKill (L2NpcInstance npc, L2PcInstance killer, boolean isPet)
    +   {
    +      npc.broadcastPacket(new CreatureSay(npc.getObjectId(),0,npc.getName(),"Only for lack of honey did I lose to the likes of you."));
     
    -        return super.onKill(npc,killer,isPet);
    -    }
    +      return super.onKill(npc,killer,isPet);
    +   }
     
    -    public static void main(String[] args)
    -    {
    -        // now call the constructor (starts up the ai)
    -        new HoneyBear(-1, "honeybear", "ai");
    -    }
    +   public static void main(String[] args)
    +   {
    +      // now call the constructor (starts up the ai)
    +      new HoneyBear(-1, "honeybear", "ai/individual");
    +   }
     }
    \ No newline at end of file


    DnR
    DnR
    Admin
    Admin


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

    Honey Bear AI (c2-c4 retail like) [COMMITED] Empty Re: Honey Bear AI (c2-c4 retail like) [COMMITED]

    Post  DnR 30th June 2019, 18:07

    Script updated. Thanks for your work. Wink

    Sponsored content


    Honey Bear AI (c2-c4 retail like) [COMMITED] Empty Re: Honey Bear AI (c2-c4 retail like) [COMMITED]

    Post  Sponsored content


      Current date/time is 19th May 2024, 10:19