L2JLisvus

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

2 posters

    PolymorphingOnAttack AI

    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 15:08

    Hello everyone, here is the AI for PolymorphingOnAttack.

    Differences from the previously posted version:
    - Fixed display of phrases of monsters (now they can be seen).
    - Auto switch target.
    - As Karakan advised, npc.deleteMe was changed to npc.onDecay.
    - Monsters listed in ValleyOfSaints.java and FallenOrcShaman.java are excluded.

    I also wanted to note that ScriptValue and onSkillSee are not required for this AI to work.

    PolymorphingOnAttack.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.group_template;

    import java.util.HashMap;
    import java.util.Map;

    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.actor.instance.L2NpcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
    import net.sf.l2j.gameserver.model.quest.Quest;
    import net.sf.l2j.util.Rnd;

    /**
     * for L2jLisvus
     */
    public class PolymorphingOnAttack extends Quest
    {
     private static final Map<Integer,Integer[]> MOBSPAWNS = new HashMap<>();
     static
     {
     MOBSPAWNS.put(1261, new Integer[] { 1262, 100, 20, 0 }); //Ol Mahum Transcender 1st stage
     MOBSPAWNS.put(1262, new Integer[] { 1263, 100, 10, 1 }); //Ol Mahum Transcender 2nd stage
     MOBSPAWNS.put(1263, new Integer[] { 1264, 100, 5, 2 }); //Ol Mahum Transcender 3rd stage
     MOBSPAWNS.put(1265, new Integer[] { 1271, 100, 33, 0 }); //Cave Ant Larva -> Cave Ant
     MOBSPAWNS.put(1266, new Integer[] { 1269, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant (always polymorphs)
     MOBSPAWNS.put(1267, new Integer[] { 1270, 100, 100, -1 }); //Cave Ant Larva -> Cave Ant Soldier (always polymorphs)
     MOBSPAWNS.put(1271, new Integer[] { 1272, 66, 10, 1 }); //Cave Ant -> Cave Ant Soldier
     MOBSPAWNS.put(1272, new Integer[] { 1273, 33, 5, 2 }); //Cave Ant Soldier -> Cave Noble Ant
     }
     protected static final String[][] MOBTEXTS =
     {
     new String[]{"Enough fooling around. Get ready to die!", "You idiot! I've just been toying with you!", "Now the fun starts!"},
     new String[]{"I must admit, no one makes my blood boil quite like you do!", "Now the battle begins!", "Witness my true power!"},
     new String[]{"Prepare to die!", "I'll double my strength!", "You have more skill than I thought"}
     };

     public PolymorphingOnAttack(int questId, String name, String descr)
     {
     super(questId, name, descr);
     int[] mobs =
        {
          1261, 1262, 1263, 1265, 1266, 1267, 1271, 1272
        };
     registerMobs(mobs);
     }

     @Override
     public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
     {
     if (npc.isVisible() && !npc.isDead())
     {
      if (MOBSPAWNS.containsKey(npc.getNpcId()))
      {
      Integer[] tmp = MOBSPAWNS.get(npc.getNpcId());
      if (npc.getCurrentHp() <= (npc.getMaxHp() * tmp[1]/100.0)&& Rnd.get(100) < tmp[2])
      {
      L2Attackable newNpc = (L2Attackable) addSpawn(tmp[0], npc.getX(), npc.getY(), npc.getZ()+10, npc.getHeading(), false, 0);
      L2Character originalAttacker = isPet? attacker.getPet(): attacker;
      
      if (tmp[3] >= 0)
      {
      String text = MOBTEXTS[tmp[3]][Rnd.get(MOBTEXTS[tmp[3]].length)];
      newNpc.broadcastPacket(new CreatureSay(newNpc.getObjectId(),0,newNpc.getName(),text));
      }
     
      npc.getSpawn().decreaseCount(npc);
      //npc.doDie(npc);
      //npc.deleteMe();
      npc.onDecay();
     
      newNpc.onAction(attacker);
      newNpc.setRunning();
      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)
     {
     new PolymorphingOnAttack(-1,"polymorphing_on_attack","ai/group_template");
     }
    }

    Please understand me correctly, I do not confirm that this is the best option, it can be changed to other conditions if necessary.

    I also want to offer option 2.
    Divide this AI into 2 parts.

    ai.individual
    OlMahumTranscender.java
    - requires verification.

    Spoiler:

    ai.group_template
    TheAntNest.java

    Requires corrections.
    - remove unnecessary dialogues (if any).
    - after the appearance of a new monster, he does not attack, so in PolymorphingOnAttack.java (only for these monsters).

    Spoiler:

    onSkillSee not used as it causes a wave effect.


    Last edited by xlinkinx on 26th July 2019, 05:19; edited 3 times in total
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 16:02

    I posted this in the other thread... let me rePost it just for you :

    The whole purpose of me doing "area based" AI scripts ,is for better overview and structure.



    Dear Karakan, I ask you first to check how it works in the game, and then render your verdict.

    I've no time for this sorry.
    There are more stuff we should concentrate on finishing/implementing, instead of re-doing "very good" scripts over and over again.

    You just re-merged the scripts, which i seperated few revisions ago for better overview/structure.
    Whats the point of that ? Cool



    Differences from the previously posted version:
    - Fallen Orc Shaman -> Sharp Talon Tiger, done the same as in (ValleyOfSaints.java).
    physical attack - 1 tiger.
    skill attack - 2 tigers.
    debuff - 1 tiger.
    - Fixed display of phrases of monsters (now they can be seen).
    - Auto switch target.
    - As Karakan advised, npc.deleteMe was changed to npc.onDecay.


    All of this stuff were added into svn allready.
    The scripts I and DnR coded includes all of the needed functions.


    About Fallen Orc Shamans i think you never checked this one on a l2off server.
    They never spawn 2 Tigers, no matter what Atk. you use on them.


    I appreciate your work .. but kinda dont get the whole point of it.

    Instead ,you could try adding things our projects misses like...

    Orc Barracks
    Abandoned Camp

    Monster AI.


    Time to move on ! Cool



    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 16:58

    I understand what you are saying to me and this code can be adjusted by me to eliminate the ValleyOfSaints.java monsters and translate polymorphing_onAttack.py into java.

    It is a pity that you do not have time to check, now polymorphing_onAttack.py has no monsters sayings. Also, the work ValleyOfSaints.java you say needs to be fixed, I repeated your action with Fallen Orc Shamans in my AI.


    Last edited by xlinkinx on 25th July 2019, 19:27; edited 1 time in total
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 17:13

    Also, the work ValleyOfSaints.java you say needs to be fixed

    Care to point to what needs to be fixed ?

    VoS script works as intended.

    You wont find a better one in any other project. Wink



    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 17:28

    Here is PolymorphingOnAttack.java, the monsters of ValleyOfSaints.java are excluded from the code.

    Spoiler:

    Now your AI works like this:
    - Fallen Orc Shaman -> Sharp Talon Tiger
    physical attack - 1 tiger.
    skill attack - 2 tigers.
    debuff - 1 tiger.

    You said that there was always 1 tiger on the l2off, and therefore it requires correction.

    Pay attention to this, I'm not looking for you to do extra work, just this is shown by my checks when creating the AI.

    I don’t see any other AI, we already have 2 options, but with 1 problem and it’s necessary to solve it it’s not important whether 1 or 2 AI.


    Last edited by xlinkinx on 25th July 2019, 18:22; edited 1 time in total
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 18:15

    Not sure which script you used but
    Shamans dissapear right before the Tiger spawns.

    There is no chance for a 2nd Tiger spawn.

    The script DnR commited was tested several times.
    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 18:46

    I checked again.

    I took all the AIs from scripts and scripts.cfg.

    Restarted 3 times and checked every time.

    always the result is this.

    Spoiler:

    Spoiler:

    Let it be my bug report.


    Last edited by xlinkinx on 25th July 2019, 19:27; edited 1 time in total
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 18:59

    Hmm very odd.

    I'll be at home in few mins , gonna start up the server and double check that.



    Meanwhile...Could you test this version ? (Edited on Mobile Phone)  Cool



    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");
        }
    }
    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 19:03

    now I'll check.


    Last edited by xlinkinx on 25th July 2019, 19:26; edited 1 time in total
    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 19:09

    Now 1 tiger. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 19:15

    So there was a little flaw in the original code.
    I'm going to update the other thread after checking it at home.

    Nice find, thanks ! Cool

    Now tell me about the Valley of Saints bug you mentioned.

    Oh and do me a favor : Dont quote everything. Page gets bigger and bigger. We dont need that. Cool
    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 19:18

    Valley of Saints has no errors, I did not see that Fallen Orc Shaman has its own AI, sorry.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 19:25

    Oh and do me a favor : Dont quote everything. Page gets bigger and bigger. We dont need that.

    .............

    Neutral jocolor
    xlinkinx
    xlinkinx


    Posts : 244
    Join date : 2012-12-11
    Age : 32
    Location : Russian Federation

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  xlinkinx 25th July 2019, 19:29

    That's better? I will now change 1 of my message, I will not lead people in the wrong direction.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Karakan 25th July 2019, 19:35

    In general the more you quote old posts, the harder it gets to read the whole thread.  

    Guess this topic can be closed by DnR.

    Sponsored content


    PolymorphingOnAttack AI Empty Re: PolymorphingOnAttack AI

    Post  Sponsored content


      Current date/time is 19th May 2024, 07:02