L2JLisvus

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

3 posters

    PlainsOfDion AI

    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 13:42

    Hello everyone, here is the working AI for PlainsOfDion, works almost as I saw on the PTS.

    PlainsOfDion AI 11110

    PlainsOfDion.java
    Code:
    /*
     * Copyright (C) 2004-2015 L2J DataPack
     *
     * This file is part of L2J DataPack.
     *
     * L2J DataPack 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.
     *
     * L2J DataPack 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 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.L2NpcInstance;
    import net.sf.l2j.gameserver.model.actor.instance.L2MonsterInstance;
    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.gameserver.util.Util;
    import net.sf.l2j.util.Rnd;

    /**
     * AI for mobs in Plains of Dion (near Floran Village).
     * for L2jLisvus
     */
    public final class PlainsOfDion extends Quest
    {
       private static final int DELU_LIZARDMEN[] =
       {
          1104, // Delu Lizardman Supplier
          1105, // Delu Lizardman Special Agent
          1107, // Delu Lizardman Commander
       };
       
       private static final String[] MONSTERS_MSG =
       {
          "$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[] MONSTERS_ASSIST_MSG =
       {
          "Die, you coward!",
          "Kill the coward!",
          "What are you looking at?!"
       };
       
       private PlainsOfDion()
       {
          super(-1, "plainsofdion", "ai/group_template");
          registerMobs(DELU_LIZARDMEN);
       }
       
       @Override
       public String onSpawn(L2NpcInstance npc)
       {
          if (npc.getScriptValue() > 0)
          {
             npc.setScriptValue(0);
          }
          return super.onSpawn(npc);
       } 
       
       @Override
       public String onAttack(L2NpcInstance npc, L2PcInstance player, int damage, boolean isPet)
       {
          if (npc.getScriptValue() == 0)
          {
            if (Rnd.get(100) <= 15)
            {
               final int i = Rnd.get(5);
               if (i < 2)
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i], player.getName()));
               }
               else
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i]));
               }
             
               for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(300))
               {
                  if (obj == null || !(obj instanceof L2MonsterInstance))
                     continue;
                 
                  if (Util.contains(DELU_LIZARDMEN, npc.getNpcId()) && !obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(npc, obj))
                  {
                     final L2MonsterInstance monster = (L2MonsterInstance) obj;
                     monster.setRunning();            
                       monster.addDamageHate(player, 0, 100);
                       monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
                     monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (MONSTERS_ASSIST_MSG[Rnd.get(3)])));
                  }
               }
             }
             npc.setScriptValue(1);
          }
          return super.onAttack(npc, player, 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) <= 15)
            {
               final int i = Rnd.get(5);
               if (i < 2)
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i], caster.getName()));
               }
               else
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i]));
               }
             
               for (L2Character obj : npc.getKnownList().getKnownCharactersInRadius(300))
               {
                  if (obj == null || !(obj instanceof L2MonsterInstance))
                     continue;
                 
                  if (Util.contains(DELU_LIZARDMEN, npc.getNpcId()) && !obj.isAttackingNow() && !obj.isDead() && GeoData.getInstance().canSeeTarget(npc, obj))
                  {
                     final L2MonsterInstance monster = (L2MonsterInstance) obj;
                     monster.setRunning();            
                       monster.addDamageHate(caster, 0, 100);
                       monster.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, caster);
                     monster.broadcastPacket(new CreatureSay(monster.getObjectId(), 0, monster.getName(), (MONSTERS_ASSIST_MSG[Rnd.get(3)])));
                  }
               }
             }
             npc.setScriptValue(1);
          }
          return super.onSkillSee(npc, caster, skill, targets, isPet);
       }
       
       public static void main(String[] args)
       {
          new PlainsOfDion();
       }
    }

    Also pay attention to our project has a nuance with the work of the AI, at 1 start of the server if the player is in the location where the AI operates then the full working capacity of the AI will come after 1 death of each monster, if it's easier until you kill all the monsters at least 1 time AI will work as it should.


    Last edited by xlinkinx on 23rd July 2019, 13:33; edited 1 time in total
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 17:16

    xlinkinx wrote:
    Hello everyone, here is the working AI for PlainsOfDion, works almost as I saw on the PTS.
    Also pay attention to our project has a nuance with the work of the AI, at 1 start of the server if the player is in the location where the AI operates then the full working capacity of the AI will come after 1 death of each monster, if it's easier until you kill all the monsters at least 1 time AI will work as it should.

    Would you mind pointing out few major differences with old script in terms of operation?

    You keep mentioning that AI thing. I cannot give you a proper answer without a proper report. I mean pictures would be really helpful.
    Also, you should keep in mind that a server based on project will operate using a time-based knownlist by default. This is the lightest method but might have issues at times.

    Best regards,
    DnR
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 17:31

    DnR wrote:
    xlinkinx wrote:
    Hello everyone, here is the working AI for PlainsOfDion, works almost as I saw on the PTS.
    Also pay attention to our project has a nuance with the work of the AI, at 1 start of the server if the player is in the location where the AI operates then the full working capacity of the AI will come after 1 death of each monster, if it's easier until you kill all the monsters at least 1 time AI will work as it should.

    Would you mind pointing out few major differences with old script in terms of operation?

    You keep mentioning that AI thing. I cannot give you a proper answer without a proper report. I mean pictures would be really helpful.
    Also, you should keep in mind that a server based on project will operate using a time-based knownlist by default. This is the lightest method but might have issues at times.

    Best regards,
    DnR

    The main differences of AI.
    1. AI works without specifying faction_id and faction_range, the AI that now this can not.
    2. The launch of AI has a 7% chance on the PTS in the same way, an AI that now has a 100% chance of launching.
    3. AI has a greater compliance with C4.

    As for the launch of the AI as a whole, I will try to describe it using the example of this AI, but most likely it will be for the other AIs as a whole.
    1. Move to the location with monsters for which this AI is made.
    2. Turn off the server and start again.
    3. We begin to attack the monster for which there is an AI (if the AI’s triggering chance is not indicated, then 100% will work, but only for this particular bridge, the AI will not act on other monsters until their first death).

    PS for this AI is not relevant because of the installation of a chance of triggering, players simply will not notice.
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 18:45

    xlinkinx wrote:
    The main differences of AI.
    1. AI works without specifying faction_id and faction_range, the AI that now this can not.
    2. The launch of AI has a 7% chance on the PTS in the same way, an AI that now has a 100% chance of launching.
    3. AI has a greater compliance with C4.

    1. The same goes for old one. It's not using faction stats.
    2. This is a really small check that could be added to existing script. In fact, I might be the one who accidentally deleted this.
    3. In what way?


    Except for minor details, this script is almost identical to old one but does not follow project's script coding conventions. It would be much better if you pointed out what is missing.
    About AI, I'll try to generate the problem and see what I find. Smile
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  Karakan 22nd July 2019, 18:53

    xlinkinx wrote:
    The main differences of AI.
    1. AI works without specifying faction_id and faction_range, the AI that now this can not.
    2. The launch of AI has a 7% chance on the PTS in the same way, an AI that now has a 100% chance of launching.
    3. AI has a greater compliance with C4.

    1. Commited script works way better and more efficient code wise.

    2. It def. had a higher chance then 7% ,on retail C4. (Not PTS).
    Besides : You should have added that line to the existing script, IN the existing thread instead....

    3. Commited script works way better and more efficient code wise.

    I honestly dont see why you post another version,which is 90% the same script me and DnR did, and claim that it is a "way better" script.

    On top of that you added unnecessary IF checks.  Rolling Eyes

    On top of that .... You created a new thread. Rolling Eyes Rolling Eyes

    On top of that .......You dont even give credits to me or DnR at all in the script. Rolling Eyes Rolling Eyes Rolling Eyes
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 20:14

    deleted.


    Last edited by xlinkinx on 22nd July 2019, 22:04; edited 1 time in total
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 20:51

    xlinkinx wrote:DnR
    1. That Ai that we now do not act as needed yesterday I checked many times.

    Just pay attention to this piece of code.
    Code:
     if (obj == null || !(obj instanceof L2MonsterInstance))
     {
     continue;
     }
    you reset obj and leave it only for L2MonsterInstance, but it does not make sense our object is of type L2PcInstance, not L2NpcInstance and the rest of the code will not work because there’s nothing to do.
    2. 3.  These are only my conclusions from the test on the server with PTS for example, every 12-15 monster launched this AI, which means I took the biggest chance.

    I think you are quite confused.
    The purpose of getKnownCharactersInRadius is to get L2Monsters around current NPC in a radius of 500 (should be 300 because monsters knownlist cannot watch
    other monsters to a further distance if they don't have an aggro or faction range).
    This check is correct and if you check your own code, it also contains an L2MonsterInstance check for known characters which ends up being the same, except for the fact that I avoid doing unecessary checks if NPC type is wrong.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  Karakan 22nd July 2019, 21:02


    It’s not real for one location to make 100% other AI, unless you add fireworks to the monsters and export antharas.

    Superfluous if checking? and this then what))

    What in the blue hell are you babbling about ?
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 21:10

    deleted.


    Last edited by xlinkinx on 22nd July 2019, 22:04; edited 1 time in total
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  Karakan 22nd July 2019, 21:19

    xlinkinx wrote:Maybe I'm in something wrong, well, I do not have the AI that I have now.

    Yesterday, while I was checking these 2 AI, I managed to fill LVL with rate x1.

    My AI also did not work, but then removing it, I received an exception.
    based on this and made their conclusions.

    Karakan
    why the hell, just 100% different AI is not realistic to do without adding completely different functions.


    Asking again..... What in the blue hell are you babbling about ?
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 21:31

    it’s not important, I already understood that I’m not saying the same thing as I spent too much yesterday with these mobs, I don’t know why your code didn’t work for me, now taking a piece of code everything works, I'll go and look again how your AI works.

    Dnr said correctly.

    Sorry in my opinion, I really just got everyone messed up, including myself. Crying or Very sad
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 21:36

    Let's not fight people, but solve this peacefully. Smile

    xlinkinx wrote:it’s not important, I already understood that I’m not saying the same thing as I spent too much yesterday with these mobs, I don’t know why your code didn’t work for me, now taking a piece of code everything works, I'll go and look again how your AI works.

    Dnr said correctly.

    Sorry in my opinion, I really just got everyone messed up, including myself. Crying or Very sad

    There's definitely been a misunderstanding which is nothing to worry about.

    About script, according to Karakan's report in another topic the "known characters" part stopped operating.
    After checking, script had a major flaw which was the reason it did not work for you.

    This check:
    Code:
    if (Util.contains(DELU_LIZARDMEN, npc.getNpcId()))
    is always checking if lizardmen list contains commander ID which is wrong.

    Fix makes it look like:
    Code:
    if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))

    I'm going to apply this fix and add a chance for commander to talk (7%) according to xlinkinx's feedback.
    I hope this solves all problems.

    Best regards,
    DnR
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 21:42

    DnR wrote:Let's not fight people, but solve this peacefully. Smile

    xlinkinx wrote:it’s not important, I already understood that I’m not saying the same thing as I spent too much yesterday with these mobs, I don’t know why your code didn’t work for me, now taking a piece of code everything works, I'll go and look again how your AI works.

    Dnr said correctly.

    Sorry in my opinion, I really just got everyone messed up, including myself. Crying or Very sad

    There's definitely been a misunderstanding which is nothing to worry about.

    About script, according to Karakan's report in another topic the "known characters" part stopped operating.
    After checking, script had a major flaw which was the reason it did not work for you.

    This check:
    Code:
    if (Util.contains(DELU_LIZARDMEN, npc.getNpcId()))
    is always checking if lizardmen list contains commander ID which is wrong.

    Fix makes it look like:
    Code:
    if (Util.contains(DELU_LIZARDMEN, monster.getNpcId()))

    I'm going to apply this fix and add a chance for commander to talk (7%) according to xlinkinx's feedback.
    I hope this solves all problems.

    Best regards,
    DnR

    I think Karakan is right and the chance of 7% will be small. It will be better to set 8, and it would be better to 9% just as well expand the list of phrases.

    Code:
               final int i = Rnd.get(5);
               if (i < 2)
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i], player.getName()));
               }
               else
               {
                  npc.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), MONSTERS_MSG[i]));
               }
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 21:46

    I suggest we set it to 15%. It's also low but enough since it's done only once anyway.
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 21:49

    DnR wrote:I suggest we set it to 15%. It's also low but enough since it's done only once anyway.
    I honestly do not even know already, chance 10% seemed to me frequent, let him decide the Karakan AI.

    or whatever you like. Very Happy
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  Karakan 22nd July 2019, 22:00

    xlinkinx wrote:
    I honestly do not even know already....

    All of sudden he cant remember that anymore. jocolor

    @DnR
    I suggest to close this thread.
    Since you commited a working and a way better script allready.
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 22:02

    Karakan wrote:
    xlinkinx wrote:
    I honestly do not even know already....

    All of sudden he cant remember that anymore. jocolor

    @DnR
    I suggest to close this thread.
    Since you commited a working and a way better script allready.

    it was meant that 7 is small, 10 seemed a lot, optimally 8-9, but you decide.
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 22nd July 2019, 22:09

    Okay, my final proposal is to stick to 10%. Let me know if any of you has any complaints.
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 22:11

    DnR wrote:Okay, my final proposal is to stick to 10%. Let me know if any of you has any complaints.

    The main thing is that it would work and close the topic with the dione. Very Happy
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 22nd July 2019, 22:32

    also requires a change from npс to monster.
    Code:
    monster.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
    DnR
    DnR
    Admin
    Admin


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  DnR 23rd July 2019, 01:01

    xlinkinx wrote:also requires a change from npс to monster.
    Code:
    monster.broadcastPacket(new CreatureSay(npc.getObjectId(), 0, npc.getName(), (NPC_STRING_ON_ASSIST[Rnd.get(3)])));
    Excellent notice, thanks!
    xlinkinx
    xlinkinx


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

    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  xlinkinx 23rd July 2019, 14:17

    DnR wrote:I suggest we set it to 15%. It's also low but enough since it's done only once anyway.
    The activation of the AI is carried out only by 1 monster, if I understood correctly, the chance can really not be set very low and will stop at 15%, as you said, in which the AI met the chance of 20%. In general, it is difficult to find the right chance, since on PTS it happens differently.

    Sponsored content


    PlainsOfDion AI Empty Re: PlainsOfDion AI

    Post  Sponsored content


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