L2JLisvus

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

2 posters

    FallenOrcShaman AI [COMMITED]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    FallenOrcShaman AI [COMMITED] Empty FallenOrcShaman AI [COMMITED]

    Post  Karakan 14th May 2019, 02:00

    More c4/c5 retail like AI for Fall Orc Shamans.
    Now with "onSkillSee" support.


    To do :

    Auto-Targeting the spawned monster is working, but client wont update the target window.
    Nonetheless the player charakter will attack the spawned monster.



    L2Off Example :





    Note: If you use this version ,make sure to remove....  

    Code:
    1258: [1259, 100, 100], #Fallen Orc Shaman -> Sharp Talon Tiger

    from  "polymorphing_onAttack.py"



    FallenOrcShaman.java

    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.ai.CtrlIntention;
    import net.sf.l2j.gameserver.model.L2Attackable;
    import net.sf.l2j.gameserver.model.L2Character;
    import net.sf.l2j.gameserver.model.L2Object;
    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;

    /**
     * FALLEN_ORC_SHAMAN AI.
     * By Karakan for L2jLisvus
     */
    public class FallenOrcShaman extends Quest
    {
       public FallenOrcShaman (int questId, String name, String descr)
       {
          super(questId, name, descr);
            int[] mobs =
            {
             1258
          }; // Fallen Orc Shaman
            registerMobs(mobs);
       }

       @Override
       public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
       {
          if (skill.isOffensive() && targets[0] == npc)
          {
             npc.onDecay();
             L2Attackable newNpc = (L2Attackable) addSpawn (1259, npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0); //Sharp Talon Tiger
             
             if (caster.getTarget() == npc)
             {
                newNpc.onAction(caster);
             }

             newNpc.setRunning();

             L2Character originalCaster = isPet ? caster.getPet() : caster;
             if (originalCaster != null)
             {
                newNpc.addDamageHate(originalCaster, 0, 100);
                newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalCaster);
             }
          }

          return super.onSkillSee(npc, caster, skill, targets, isPet);
       }
       
       @Override
        public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
        {
             npc.onDecay();
             L2Attackable newNpc = (L2Attackable) addSpawn (1259, npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0); //Sharp Talon Tiger

             if (attacker.getTarget() == npc)
             {
                newNpc.onAction(attacker);
             }

             newNpc.setRunning();
             
             L2Character originalAttacker = isPet ? attacker.getPet() : attacker;
             if (originalAttacker != null)
             {
                newNpc.addDamageHate(originalAttacker, 0, 100);
                newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
             }

          return super.onAttack(npc, attacker, damage, isPet);
       }

        public static void main(String[] args)
        {
            // Quest class and state definition
            new FallenOrcShaman(-1, "fallenorcshaman", "ai/individual");
        }
    }



    scripts.cfg


    Code:
    ai/individual/FallenOrcShaman.java



    Regards Cool


    Last edited by Karakan on 25th July 2019, 19:31; edited 2 times in total
    DnR
    DnR
    Admin
    Admin


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

    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  DnR 30th May 2019, 15:26

    In cases when an NPC must automatically be targeted, I suggest that you use onAction method instead of setTarget since the first one has client support.
    Fixed and added to project.

    PS: I'm not sure if it reacts to skill casts in general or just aggro skills. Needs confirmation.

    Thank you so much. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  Karakan 30th May 2019, 23:15

    Code:
    PS: I'm not sure if it reacts to skill casts in general or just aggro skills. Needs confirmation.


    Thanks for commiting. Cool


    Just tested the "onCast" function and it works like a charm. cheers



    Im working on a Valley of Saints script but missing a function
    to remove drops/Xp rewards when a Npc "transforms".

    On retail they just unspawn.

    I tried the "npc.deleteMe()" function , but that one stops them from respawning  jocolor

    Maybe we could use something like "Npc.setMustRewardExpSp(false);"
    And create one for drops ,too ?



    Regards Cool
    DnR
    DnR
    Admin
    Admin


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

    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  DnR 5th June 2019, 03:24

    I haven't tested it but after checking code, onDecay method (L2NpcInstance) might do the trick and keep respawn task intact.
    If problem persists, we can proceed to using a more suitable solution. Wink

    Best regards,
    DnR
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  Karakan 5th June 2019, 14:56

    Great idea !
    Thanks for the hint. Cool
    Gonna do some testing and will post the result.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  Karakan 25th July 2019, 19:30

    Updated code on first post.

    - Fixed few little flaws in the code causing more then 1 Tiger getting spawned. (Thanks xlinkinx for reporting)
    - Added "Auto-Target" Tiger only IF Shaman was targeted before
    - Added Pet support


    Regards Cool

    Sponsored content


    FallenOrcShaman AI [COMMITED] Empty Re: FallenOrcShaman AI [COMMITED]

    Post  Sponsored content


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