L2JLisvus

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

4 posters

    Plains of Dion AI [Commited]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 16:45

    Plains of Dion - Delu Lizardmen AI


    Plains of Dion AI [Commited] 1110


    This took me a while to finish, but finally its here.  Cool

    Now its working 99% C4 retail like.
    Commanders will randomly shout, and call nearby lizardmen for help, who also got their shout msgs added.


    As always please...feel free to make suggestions on how to improve the code or add missing stuff.  Cool


    scripts.cfg

    Code:

    Index: scripts.cfg
    ===================================================================
    --- scripts.cfg (revision 624)
    +++ scripts.cfg (working copy)
    @@ -14,6 +14,7 @@
     ai/group_template/feedable_beasts.py
     ai/group_template/FleeingNpc.java
     ai/group_template/FrenzyOnAttack.java
    +ai/group_template/PlainsOfDion.java
     ai/group_template/SearchingMaster.java
     ai/group_template/TowerOfInsolence.java
     ai/group_template/ValleyOfSaints.java


    PlainsOfDion.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.Collection;

    import net.sf.l2j.gameserver.ai.CtrlIntention;
    import net.sf.l2j.gameserver.geoengine.GeoData;
    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.L2MonsterInstance;
    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.network.serverpackets.CreatureSay;
    import net.sf.l2j.gameserver.util.Util;
    import net.sf.l2j.util.Rnd;

    /**
     * @author Karakan , optimized by DnR
     *
     * Plains Of Dion - Delu Lizardman AI.
     */
    public class PlainsOfDion extends Quest
    {
       private static final int DELU_LIZARDMEN[] =
       {
          1104, // Delu Lizardman Supplier
          1105, // Delu Lizardman Special Agent
       };
       
       private static final String[] NPC_STRING =
       {
          "$s1! How dare you interrupt our fight ? Hey guys help!",
          "$s1! Hey, we are having a duel here!",
          "The duel is over, attack!!",
          "Foul, kill the coward!",
          "How dare you interrupt a sacred duel? You must be taught a lesson!"
       };
       
       private static final String[] NPC_STRING_ON_ASSIST =
       {
          "Die, you coward!",
          "Kill the coward!",
          "What are you looking at?!"
       };
       
       public PlainsOfDion(int questId, String name, String descr)
       {
          super(questId, name, descr);
          registerMobs(new int[]
          {
             1107
          }); // Delu Lizardman Commander
       }
       
       @Override
       public String onSpawn(L2NpcInstance npc)
       {
          if (npc.getScriptValue() > 0)
          {
             npc.setScriptValue(0);
          }
          return super.onSpawn(npc);
       }

       @Override
       public String onAttack(L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
       {
          if (npc.getScriptValue() == 0)
          {
             if (Rnd.get(100) < 10)
             {
                npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), NPC_STRING[Rnd.get(5)], attacker.getName()));
             }

             Collection<L2Character> characters = npc.getKnownList().getKnownCharactersInRadius(300);
             for (L2Character obj : characters)
             {
                if (obj == null || !(obj instanceof L2MonsterInstance))
                {
                   continue;
                }

                L2MonsterInstance monster = (L2MonsterInstance) obj;
                if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))
                {
                   if (!obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(obj, attacker))
                   {
                      monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
                      monster.setTarget(attacker);
                      monster.setRunning();

                      L2Character originalAttacker = isPet ? attacker.getPet() : attacker;
                      if (originalAttacker == null)
                      {
                         return null;
                      }
                      monster.addDamageHate(originalAttacker, 0, 100);
                      monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalAttacker);
                   }
                }
             }
             npc.setScriptValue(1);
          }
          
          return super.onAttack(npc, attacker, damage, isPet);
       }
       
       @Override
       public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
       {
          if (skill.isOffensive() && targets[0] == npc && npc.getScriptValue() == 0)
          {
             if (Rnd.get(100) < 10)
             {
                npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), NPC_STRING[Rnd.get(5)], caster.getName()));
             }

             Collection<L2Character> characters = npc.getKnownList().getKnownCharactersInRadius(300);
             for (L2Character obj : characters)
             {
                if (obj == null || !(obj instanceof L2MonsterInstance))
                {
                   continue;
                }

                L2MonsterInstance monster = (L2MonsterInstance) obj;
                if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))
                {
                   if (!obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(obj, caster))
                   {
                      monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
                      monster.setTarget(caster);
                      monster.setRunning();

                      L2Character originalCaster = isPet ? caster.getPet() : caster;
                      if (originalCaster == null)
                      {
                         return null;
                      }
                      monster.addDamageHate(originalCaster, 0, 100);
                      monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, originalCaster);
                   }
                }
             }
             npc.setScriptValue(1);
          }
          
          return super.onSkillSee(npc, caster, skill, targets, isPet);
       }
       
       public static void main(String[] args)
       {
          new PlainsOfDion(-1, "plainsofdion", "ai/group_template");
       }
    }


    Last edited by Karakan on 23rd July 2019, 02:50; edited 8 times in total
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 20:25

    I have not checked it out yet, but I am going to do it in the near future and I also noticed that in the list of the NPC, as far as I remember, these should be exactly:

    1102 - Watchman of the Plains
    1103 - Roughly Hewn Rock Golem
    1104 - Delu Lizardman Supplier
    1105 - Delu Lizardman Special Agent
    1107 - Delu Lizardman Commander
    1804 - Treasure Chest/box

    at the expense of those that you added, I honestly say not sure.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 20:45

    Check data NPC in PTS can conclude that the most likely of the AI for this location is not required due to the lack faction_id in PTS script, but it is better where it is clarified.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 21:50

    Code:
    I have not checked it out yet, but I am going to do it in the near future and I also noticed that in the list of the NPC, as far as I remember, these should be exactly:

    1102 - Watchman of the Plains
    1103 - Roughly Hewn Rock Golem
    1104 - Delu Lizardman Supplier
    1105 - Delu Lizardman Special Agent
    1107 - Delu Lizardman Commander
    1804 - Treasure Chest/box

    at the expense of those that you added, I honestly say not sure.


    1. I've never seen Treasure Chests beeing social, in Lineage II, in my life.  Cool

    2.  Lizardmen's suppose to help their own kin only.
    Never saw a Roughly Hewn Rock Golem coming to aid when i was spoiling around that area back in 2005-2006.  Cool


    Check data NPC in PTS can conclude that the most likely of the AI for this location is not required due to the lack faction_id in PTS script, but it is better where it is clarified.

    Lack of faction_id in npcdata doesnt mean there is no faction behaviour for that specific Monster.


    I made the scripts based on my experience on L2Off c4 servers.

    Besides the area where these monsters spawn has barely changed from C2 till H5.
    Same for their AI.


    And to answer your question on the other topic you started..

    Unfortunately, in С4 I don’t remember how this location worked

    Fortunatly there are other people who do remember, including myself.


    Last edited by Karakan on 20th July 2019, 15:20; edited 1 time in total
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 22:02

    I understood why we had a discrepancy in the understanding of the work of the AI and the monsters who participate in it.

    AI see this option in the Set faction_range it for what would any monster could help, and for that reason were golems, chests and other monsters and for the same reason, there is no PTS faction_id these monsters.

    PlainsOfDion.java
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 22:15

    Is that the script from L2j datapack ?
    Oh my ....They still havent included a "onSpellSee" segment in their ai scripts.... now thats laziness at its best.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 22:19

    Karakan wrote:Is that the script from L2j datapack ?
    Oh my ....They still havent included a "onSpellSee" segment in their ai scripts.... now thats laziness at its best.

    taken from the Acis project, unfortunately the best option is not found, but it meets our requirements.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 22:24

    I honestly can't see anything useful for us ,from that one.

    I posted a way more complete one in the first post.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 22:29

    Karakan wrote:I honestly can't see anything useful for us ,from that one.

    I posted a way more complete one in the first post.

    That's what's interesting.
    Code:
    for (Monster obj : npc.getKnownTypeInRadius(Monster.class, 300))

    In AI Waste, you also just need to specify that all neighboring monsters within a radius of 300 or 500 would help the Lizardmanas you like.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 23:05

    Good point!
    Allright im going to implement it that way.

    Gonna update first post when im done testing it.


    Last edited by Karakan on 10th July 2019, 23:21; edited 1 time in total
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 23:13

    Karakan wrote:Good point!
    Allright im going to implement it that way, at least we dont have to modify the npc table then.

    Gonna update first post when im done testing it.

    I'm glad you understood what I'm talking about. Waiting for an update.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 10th July 2019, 23:19

    Done. Cool
    This should be the final version.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 10th July 2019, 23:51

    Karakan wrote:Done.  Cool
    This should be the final version.

    without changing the NPC, the AI will not work, I think we should still think about it. Thanks for your work and sorry for having so many problems with this. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 11th July 2019, 00:01

    Thats why i kept the npc.sql diff. in the first post. Cool
    No need to be sorry, every bit of help/suggestion is welcome and helps getting things done better.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 11th July 2019, 13:10

    I tried to edit the AI today and concluded that we lack the knowledge to make a properly working AI only the DnR can handle it.
    DnR
    DnR
    Admin
    Admin


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  DnR 11th July 2019, 13:53

    xlinkinx wrote:I tried to edit the AI today and concluded that we lack the knowledge to make a properly working AI only the DnR can handle it.

    What about Karakan's share? Isn't it a bit closer to retail?
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 11th July 2019, 15:21

    xlinkinx wrote:I tried to edit the AI today and concluded that we lack the knowledge to make a properly working AI only the DnR can handle it.

    The version above is allready working ,and is very close to retail C4.

    I also "know" that all Delu Lizardmen were social, even if they've no faction_id in the l2off npcdata.
    That was prolly handled by their AI.


    If you dont like it, feel free to make your own contribution and post it.

    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 11th July 2019, 15:55

    DnR wrote:
    xlinkinx wrote:I tried to edit the AI today and concluded that we lack the knowledge to make a properly working AI only the DnR can handle it.

    What about Karakan's share? Isn't it a bit closer to retail?

    Karakan did a good job. There is no doubt about this, but his AI requires faction_id and this is not right, but I lack the knowledge to make another AI.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 11th July 2019, 16:08

    What is better ?

    - Using a allready existing check in npc table (faction_id)

    or

    - Creating a AI script and letting it check each npc_id for social behaviour.


    Besides that :
    Shamans won't be social at all without the npc fixes,
    since they are not part of the ai script.
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 11th July 2019, 16:24

    Karakan wrote:What is better ?

    - Using a allready existing check in npc table (faction_id)

    or

    - Creating a AI script and letting it check each npc_id for social behaviour.


    Besides that :
    Shamans won't be social at all without the npc fixes,
    since they are not part of the ai script.

    For me, it's better when all monsters at a distance of 300-500 AI issue a command to attack a character who attacked Lizardman.

    Such a decision is not my whim, but simply by the fact that more monsters must be involved and registering each faction_id will be a problem.

    AI is not only distributed to Plains Of Dion, but there are other places where Delu Lizardman Supplier and Delu Lizardman Special Agent are standing, for example, right next to Dion itself and for the monsters that are next to them you will also need to write faction_id.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 11th July 2019, 16:39

    For me, it's better when all monsters at a distance of 300-500 AI issue a command to attack a character who attacked Lizardman.

    Then do that on your local server since that is totally custom.


    Such a decision is not my whim, but simply by the fact that more monsters must be involved and registering each faction_id will be a problem.

    Which other monsters ?
    There are like 4-5 Delu Lizardmen types.
    And even if there were more ,why should that be a problem ? lol


    AI is not only distributed to Plains Of Dion, but there are other places where Delu Lizardman Supplier and Delu Lizardman Special Agent are standing, for example, right next to Dion itself and for the monsters that are next to them you will also need to write faction_id.


    No you dont. Because the other monsters never helped Lizardmen's in c4.
    I allready stated this several times in this topic.

    Maybe you shouldnt compare everything to Interlude or whatever server you are testing this on. (if at all)
    xlinkinx
    xlinkinx


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  xlinkinx 11th July 2019, 16:43

    Karakan wrote:
    For me, it's better when all monsters at a distance of 300-500 AI issue a command to attack a character who attacked Lizardman.

    Then do that on your local server since that is totally custom.


    Such a decision is not my whim, but simply by the fact that more monsters must be involved and registering each faction_id will be a problem.

    Which other monsters ?
    There are like 4-5 Delu Lizardmen types.
    And even if there were more ,why should that be a problem ? lol


    AI is not only distributed to Plains Of Dion, but there are other places where Delu Lizardman Supplier and Delu Lizardman Special Agent are standing, for example, right next to Dion itself and for the monsters that are next to them you will also need to write faction_id.


    No you dont. Because the other monsters never helped Lizardmen's in c4.
    I allready stated this several times in this topic.

    Maybe you shouldnt compare everything to Interlude or whatever server you are testing this on. (if at all)

    I think it is worthwhile to finish this conversation, I need to go for a couple of days, as I come specifically to check it on PTS c4 on those that are on the Internet or on my own.
    DnR
    DnR
    Admin
    Admin


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  DnR 11th July 2019, 16:51

    Okay, so let me present my own suggestion.
    I can see that you have created your own faction call mechanism inside AI file, while the mechanism in L2AttackableAI still applies to these monsters.
    In that matter, I would agree with xlinkinx that this solution has small flaws.

    I think that your idea of using faction IDs could work better by merely adding faction ID to npcs to let core do the rest and use only onFactionCall(L2NpcInstance npc, L2NpcInstance caller, L2PcInstance attacker, boolean isPet) event for social actions inside AI file.

    Also, core default faction call distance is (faction range + aggro range) so there might be no need for increasing faction range inside table.
    This is just my own thought.

    I'm late at commiting AI files on purpose, because this helps us contradict, test, apply, and improve.
    This topic proves that more than an individual can make the difference, so you should both not lose your temper. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Karakan 11th July 2019, 17:28

    Isnt this the purpose of a contribution section ? -> To discuss about codes and find out whats the best option. Cool

    I never said i made THE perfect AI script ,or im the uber java coder.

    I made the script based on my memories from the times i played on L2Paradise,
    which was the most complete C4 L2Off server back then.


    I think that your idea of using faction IDs could work better by merely adding faction ID to npcs to let core do the rest and use only onFactionCall(L2NpcInstance npc, L2NpcInstance caller, L2PcInstance attacker, boolean isPet) event for social actions inside AI file.


    onFactionCall ?

    Good call.
    I think i saw something similar in a Orfen AI script.
    Gonna take a good look and see if i can make something useful out of it.

    If not...I'll pass the ball to xlinkx.  Cool


    Also, core default faction call distance is (faction range + aggro range) so there might be no need for increasing faction range inside table.

    Does this also apply when faction ID ,faction range ,aggro range are set to Null/0 in db table ?


    Regards  Cool
    DnR
    DnR
    Admin
    Admin


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

    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  DnR 11th July 2019, 17:36

    Karakan wrote:
    Does this also apply when faction ID ,faction range ,aggro range are set to Null/0 in db table ?

    It does not, but I guess you can set NPCs faction range to higher than 0 and if aggro range is also 0, I believe faction range can be increased to 500 without issues.

    Sponsored content


    Plains of Dion AI [Commited] Empty Re: Plains of Dion AI [Commited]

    Post  Sponsored content


      Current date/time is 19th May 2024, 11:00