L2JLisvus

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

2 posters

    Forge of the Gods AI [Commited]

    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Forge of the Gods AI [Commited] Empty Forge of the Gods AI [Commited]

    Post  Karakan 8th July 2019, 20:56

    Forge of the Gods AI.


    Scarlet Stakato Noble
    Assassin Beetle
    Necromancer of Destruction
    Arimanes of Destruction
    Ashuras of Destruction
    Magma Drake


    - when HP is at : 20%
    - chance to cast death bomb skill : +- 30%
    - chance to spawn 5 clones on death : Not sure about chance. I set it to 30%



    Rest of the FoG mobs just cast death bomb without spawning clones.



    Note :
    Make sure to remove skill 4614 from npcskills (IDs below)





    Feel free to post suggestions on how to improve the code.

    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.datatables.SkillTable;
    import net.sf.l2j.gameserver.model.L2Attackable;
    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;
    import net.sf.l2j.gameserver.util.Util;
    import net.sf.l2j.util.Rnd;

    /**
     * @author Karakan
     * Forge of the Gods AI
     * TODO : Add "isPet" check in onSpellFinished
     */
    public class ForgeOfTheGods extends Quest
    {
      private static final Map<Integer,Integer[]> FOG_SUICIDE_AND_SPAWN = new HashMap<>();
      private static final Map<Integer,Integer[]> FOG_SUICIDE_ONLY = new HashMap<>();

      static
        {
          FOG_SUICIDE_AND_SPAWN.put(1378, new Integer[]{1652, 30}); //Scarlet Stakato Noble
          FOG_SUICIDE_AND_SPAWN.put(1381, new Integer[]{1653, 30}); //Assassin Beetle
          FOG_SUICIDE_AND_SPAWN.put(1384, new Integer[]{1654, 30}); //Necromancer of Destruction
          FOG_SUICIDE_AND_SPAWN.put(1387, new Integer[]{1655, 30}); //Arimanes of Destruction
          FOG_SUICIDE_AND_SPAWN.put(1390, new Integer[]{1656, 30}); //Ashuras of Destruction
          FOG_SUICIDE_AND_SPAWN.put(1393, new Integer[]{1657, 30}); //Magma Drake

          FOG_SUICIDE_ONLY.put(1376, new Integer[]{0, 30}); //Scarlet Stakato Walker
          FOG_SUICIDE_ONLY.put(1377, new Integer[]{0, 30}); //Scarlet Stakato Soldier
          FOG_SUICIDE_ONLY.put(1379,  new Integer[]{0, 30}); //Tepra Scorpion
          FOG_SUICIDE_ONLY.put(1380,  new Integer[]{0, 30}); //Tepra Scarab
          FOG_SUICIDE_ONLY.put(1382,  new Integer[]{0, 30}); //Mercenary of Destruction
          FOG_SUICIDE_ONLY.put(1383,  new Integer[]{0, 30}); //Knight of Destruction
          FOG_SUICIDE_ONLY.put(1385,  new Integer[]{0, 30}); //Lavastone Golem
          FOG_SUICIDE_ONLY.put(1386,  new Integer[]{0, 30}); //Magma Golem
          FOG_SUICIDE_ONLY.put(1388,  new Integer[]{0, 30}); //Iblis of Destruction
          FOG_SUICIDE_ONLY.put(1389,  new Integer[]{0, 30}); //Balrog of Destruction
          FOG_SUICIDE_ONLY.put(1391,  new Integer[]{0, 30}); //Lavasilisk
          FOG_SUICIDE_ONLY.put(1392,  new Integer[]{0, 30}); //Blazing Ifrit
          FOG_SUICIDE_ONLY.put(1394, new Integer[]{0, 30}); //Lavasaurus
          FOG_SUICIDE_ONLY.put(1395,  new Integer[]{0, 30});//Elder Lavasaurus
      }

      public ForgeOfTheGods (int questId, String name, String descr)
      {
            super(questId, name, descr);
            int[] mobs =
            {
              1378, 1381, 1384, 1387, 1390, 1393, 1376, 1377, 1379, 1380, 1382, 1383, 1385, 1386, 1388, 1389, 1391, 1392, 1394, 1395
            };
          registerMobs(mobs);
      }

      @Override
      public String onSpellFinished(L2NpcInstance npc, L2PcInstance player, L2Skill skill)
      { 
      if (FOG_SUICIDE_AND_SPAWN.containsKey(npc.getNpcId()) &&  (skill.getId() == 4614))
      {
      Integer[] suicide = FOG_SUICIDE_AND_SPAWN.get(npc.getNpcId());
      if (Rnd.get(100) < suicide[1])
      {
      for (int i = 0; i < 5; i++)
      {
      L2Attackable newNpc = (L2Attackable) addSpawn(suicide[0], npc.getX()+Rnd.get(150), npc.getY()+Rnd.get(150), npc.getZ(), 0, false, 0);

      if (player.getTarget() == npc)
      {
      newNpc.onAction(player);
      }
     newNpc.setRunning();
     newNpc.addDamageHate(player, 0, 100);
     newNpc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player);
      }
      }
      }

      return super.onSpellFinished(npc, player, skill);
      }

      @Override
      public String onAttack (L2NpcInstance npc, L2PcInstance attacker, int damage, boolean isPet)
      {
      if (FOG_SUICIDE_AND_SPAWN.containsKey(npc.getNpcId()) || FOG_SUICIDE_ONLY.containsKey(npc.getNpcId()))
      {
          if ((npc.getCurrentHp() < (npc.getStat().getMaxHp() * 20) / 100.0) && Rnd.get(100) < 30 ) // at 20% HP , 30% cast chance
          {
                  if (Util.checkIfInRange(150, npc, attacker, true)) // Skill Radius
                  {
                      npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
                      npc.doCast(SkillTable.getInstance().getInfo(4614,12)); // NPC Death Bomb
                  }
          }
      }

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

     @Override
     public String onSkillSee(L2NpcInstance npc, L2PcInstance caster, L2Skill skill, L2Object[] targets, boolean isPet)
     {
     if (skill.isMagic() && skill.isOffensive() && targets[0] == npc)
     {
      if (FOG_SUICIDE_AND_SPAWN.containsKey(npc.getNpcId()) || FOG_SUICIDE_ONLY.containsKey(npc.getNpcId()))
      {
          if ((npc.getCurrentHp() < (npc.getStat().getMaxHp() * 20) / 100.0) && Rnd.get(100) < 30 ) // at 20% HP , 30% cast chance
          {
          if (Util.checkIfInRange(150, npc, caster, true)) // Skill Radius
                    {
                      npc.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
                      npc.doCast(SkillTable.getInstance().getInfo(4614,12)); // NPC Death Bomb
                    }
          }
      }
     }

     return super.onSkillSee(npc, caster, skill, targets, isPet);
     }

      public static void main(String[] args)
      {
          // Quest class and state definition
          new ForgeOfTheGods(-1, "forgeofthegods", "ai/group_template");
      }
    }
    Back to top
    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  confejulian 13th September 2019, 22:00

    Hello Karakan, i just see this, i go to test it and do any devolution. Is this the last state? or have any more recent modifications?

    PD: thanks for this nice contribution.
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  Karakan 13th September 2019, 22:14

    This is the final version ,which DnR commited with few fixes, around July.
    If you see any flaws in the AI behaviour , feel free to let us know here in this thread.

    Regards Cool
    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  confejulian 14th September 2019, 21:57

    Well, i had go to l2 off server, and kill manually 100 mobs scarlet stakato walker & scarlet stakato noble. 40 minutes aprox killing mobs :V

    Results & differences:

    First difference: on 100 mobs killed at most 5 used bomb skill. This give 5% aprox of probability to use bomb skill. On lisvus idk the %, but it is much bigger.

    Second difference: on 100 mobs killed i obtain 9 mobs when they die they multiplied. This give 9% of probability to multiply when die. Later i kill 3 more and obtain other multiplication, I would dare to say the probability is 10%. On your is 30%, when i tested on lisvus before test on l2off i found it elevated, That's how it went.

    Third difference: This is the most important, If i don't look and test bad, on your code, the multiply only given when monsters use skill bomb. My test with 100 mobs killed on l2 off, give me a result of, when monsters dies, have multiplied, without using skill bomb. i mean, they can multiply when die only. Without importance if is for "natural death" or using skill bomb. On your code if i'm not bad, only happend when use skill bomb.

    I hope it helps.

    Regards
    Karakan
    Karakan


    Posts : 756
    Join date : 2013-10-04

    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  Karakan 14th September 2019, 22:27

    Well, not really differences, just lower chances on the server you tested on, it seems.

    Our current AI works like this..

    - IF mob-hp lower then 20%  --> 30% chance for death bomb trigger
    - On death -> 30% chance for spawn trigger


    The triggers for spawning monsters and using death bomb skill are not linked.
    It can happen that a mob dies without using the skill and still spawns monsters.

    Which server did you test that on btw ?

    I'm going to test this on L2Elite these days.

    Regards  Cool
    avatar
    confejulian


    Posts : 254
    Join date : 2016-08-27

    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  confejulian 14th September 2019, 22:36

    Karakan wrote:Well, not really differences, just lower chances on the server you tested on, it seems.

    Our current AI works like this..

    - IF mob-hp lower then 20%  --> 30% chance for death bomb trigger
    - On death -> 30% chance for spawn trigger


    The triggers for spawning monsters and using death bomb skill are not linked.
    It can happen that a mob dies without using the skill and still spawns monsters.

    Which server did you test that on btw ?

    I'm going to test this on L2Elite these days.

    Regards  Cool

    i tested it on L2ultra, but, when i tested on lisvus before test on l2off i found it elevated, is because i remember from others servers. But i dont know, i think this is a critery. And when you farm with polearms with this 30% i think is very OP, because spawns a lot of monsters if you array 30 monsters base before start killing it's so probabily you spawn new 45 mobs. more than double, to be exactly 150% more.

    Sponsored content


    Forge of the Gods AI [Commited] Empty Re: Forge of the Gods AI [Commited]

    Post  Sponsored content


      Current date/time is 19th May 2024, 09:24