Не могу найти ошибку в AI Тараса

  • Автор темы Автор темы Maiden7
  • Дата начала Дата начала

Maiden7

Величайший
Проверенный
Старожил I степени
За заслуги перед форумом
Стратег Данных
Знаток письма
Любитель реакций
Сообщения
808
Розыгрыши
0
Решения
3
Репутация
170
Реакции
657
Баллы
1 563
Хроники
  1. Chaotic Throne: High Five
Исходники
Присутствуют
Сборка
L2J Mobius
Доброго времени суток!
И так, для локи Фафуриона перерисовал скрипт Тараса.
Заменил только ID и сами названия, но вырезал момент с телепортом при атаке.
И после смерти он теперь не переходит в статус "DEAD" ну и соответственно сферка не спавнится и тд и тп.

JavaScript:
/*
 * This file is part of the L2J Mobius project.
 *
 * 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.bosses.Fafurion;

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

import org.l2jmobius.Config;
import org.l2jmobius.gameserver.ai.CtrlIntention;
import org.l2jmobius.gameserver.enums.MountType;
import org.l2jmobius.gameserver.instancemanager.GrandBossManager;
import org.l2jmobius.gameserver.instancemanager.ZoneManager;
import org.l2jmobius.gameserver.model.Location;
import org.l2jmobius.gameserver.model.Party;
import org.l2jmobius.gameserver.model.StatSet;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.gameserver.model.actor.Attackable;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.Npc;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.actor.instance.GrandBoss;
import org.l2jmobius.gameserver.model.holders.SkillHolder;
import org.l2jmobius.gameserver.model.skill.Skill;
import org.l2jmobius.gameserver.model.zone.type.NoRestartZone;
import org.l2jmobius.gameserver.network.NpcStringId;
import org.l2jmobius.gameserver.network.serverpackets.Earthquake;
import org.l2jmobius.gameserver.network.serverpackets.ExShowScreenMessage;
import org.l2jmobius.gameserver.network.serverpackets.PlaySound;
import org.l2jmobius.gameserver.network.serverpackets.SocialAction;
import org.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
import org.l2jmobius.gameserver.util.Broadcast;
import org.l2jmobius.gameserver.util.Util;

import ai.AbstractNpcAI;

/**
 * Antharas AI.
 * @author St3eT
 */
public class Fafurion extends AbstractNpcAI
{
    // NPCs
    private static final int FAFURION = 40024; // Antharas
    private static final int FAFURION_KINDRED = 18482; // Water Dragon
    private static final int FAFURION_HERALD_LOKNESS = 40027; // Tarask Dragon
    private static final int NAIAD = 40026; // Water Niad
    private static final int HEART = 40025; // Heart of Warding
    private static final int CUBE = 31859; // Teleportation Cubic
    private static final Map<Integer, Location> INVISIBLE_NPC = new HashMap<>();
    static  
    {
        INVISIBLE_NPC.put(40026, new Location(177386, 245051, -14848)); // antaras_clear_npc_1
        INVISIBLE_NPC.put(40026, new Location(177809, 245393, -14848)); // antaras_clear_npc_2
        INVISIBLE_NPC.put(40026, new Location(178443, 246255, -14848)); // antaras_clear_npc_3
        INVISIBLE_NPC.put(40026, new Location(178301, 247041, -14848)); // antaras_clear_npc_4
        INVISIBLE_NPC.put(40026, new Location(178059, 247357, -14848)); // antaras_clear_npc_5
        INVISIBLE_NPC.put(40026, new Location(176950, 247614, -14848)); // antaras_clear_npc_6
        INVISIBLE_NPC.put(40026, new Location(175794, 247629, -14848)); // antaras_clear_npc_7
        INVISIBLE_NPC.put(40026, new Location(174617, 247480, -14848)); // antaras_clear_npc_8
        INVISIBLE_NPC.put(40026, new Location(173643, 247099, -14848)); // antaras_clear_npc_9
        INVISIBLE_NPC.put(40026, new Location(173452, 246616, -14848)); // antaras_clear_npc_10
        INVISIBLE_NPC.put(40026, new Location(173896, 245644, -14848)); // antaras_clear_npc_11
        INVISIBLE_NPC.put(40026, new Location(174213, 244934, -14848)); // antaras_clear_npc_12
        INVISIBLE_NPC.put(40026, new Location(174420, 244725, -14848)); // antaras_clear_npc_13
        INVISIBLE_NPC.put(40026, new Location(175020, 244554, -14848)); // antaras_clear_npc_14
        INVISIBLE_NPC.put(40026, new Location(175615, 244236, -14848)); // antaras_clear_npc_15
        INVISIBLE_NPC.put(40026, new Location(176564, 244063, -14848)); // antaras_clear_npc_16
        INVISIBLE_NPC.put(40026, new Location(177381, 244082, -14848)); // antaras_clear_npc_17
        INVISIBLE_NPC.put(40026, new Location(177638, 244527, -14848)); // antaras_clear_npc_18
    }
    // Item
    private static final int STONE = 3865; // Portal Stone
    // Skill
    private static final SkillHolder ANTH_JUMP = new SkillHolder(6291, 1); // Antharas Stun
    private static final SkillHolder ANTH_TAIL = new SkillHolder(702, 1); // Antharas Stun
    private static final SkillHolder ANTH_FEAR = new SkillHolder(6325, 1); // Antharas Terror
    private static final SkillHolder ANTH_DEBUFF = new SkillHolder(753, 1); // Curse of Antharas
    private static final SkillHolder ANTH_MOUTH = new SkillHolder(1528, 2); // Breath Attack
    private static final SkillHolder ANTH_BREATH = new SkillHolder(8238, 1); // Antharas Fossilization
    private static final SkillHolder ANTH_NORM_ATTACK = new SkillHolder(8242, 1); // Ordinary Attack
    private static final SkillHolder ANTH_NORM_ATTACK_EX = new SkillHolder(907, 1); // Animal doing ordinary attack
    private static final SkillHolder ANTH_REGEN_1 = new SkillHolder(870, 1); // Antharas Regeneration
    private static final SkillHolder ANTH_REGEN_2 = new SkillHolder(6450, 1); // Antharas Regeneration
    private static final SkillHolder ANTH_REGEN_3 = new SkillHolder(6858, 1); // Antharas Regeneration
    private static final SkillHolder ANTH_REGEN_4 = new SkillHolder(23341, 1); // Antharas Regeneration
    private static final SkillHolder DISPEL_BOM = new SkillHolder(1560, 1); // NPC Dispel Bomb
    private static final SkillHolder ANTH_ANTI_STRIDER = new SkillHolder(10006, 1); // Hinder Strider
    private static final SkillHolder ANTH_FEAR_SHORT = new SkillHolder(23341, 1); // Antharas Terror
    private static final SkillHolder ANTH_METEOR = new SkillHolder(23343, 1); // Antharas Meteor
    // Zone
    private static final NoRestartZone zone = ZoneManager.getInstance().getZoneById(40024, NoRestartZone.class); // Fafurion Nest zone
    // Status
    private static final int ALIVE = 0;
    private static final int WAITING = 1;
    private static final int IN_FIGHT = 2;
    private static final int DEAD = 3;
    // Misc
    private static final int MAX_PEOPLE = 200; // Max allowed players
    private GrandBoss _fafurion = null;
    private static long _lastAttack = 0;
    private static int _minionCount = 0;
    private static int minionMultipler = 0;
    private static int moveChance = 0;
    private static int sandStorm = 0;
    private static Player attacker_1 = null;
    private static Player attacker_2 = null;
    private static Player attacker_3 = null;
    private static int attacker_1_hate = 0;
    private static int attacker_2_hate = 0;
    private static int attacker_3_hate = 0;
   
    private Fafurion()
    {
        addStartNpc(HEART, CUBE);
        addTalkId(HEART, CUBE);
        addFirstTalkId(HEART);
        addSpawnId(INVISIBLE_NPC.keySet());
        addSpawnId(FAFURION);
        addMoveFinishedId(NAIAD);
        addAggroRangeEnterId(NAIAD);
        addSpellFinishedId(FAFURION);
        addAttackId(FAFURION, NAIAD, FAFURION_KINDRED, FAFURION_HERALD_LOKNESS);
        addKillId(FAFURION, FAFURION_HERALD_LOKNESS, FAFURION_KINDRED);
       
        final StatSet info = GrandBossManager.getInstance().getStatSet(FAFURION);
        final double curr_hp = info.getDouble("currentHP");
        final double curr_mp = info.getDouble("currentMP");
        final int loc_x = info.getInt("loc_x");
        final int loc_y = info.getInt("loc_y");
        final int loc_z = info.getInt("loc_z");
        final int heading = info.getInt("heading");
        final long respawnTime = info.getLong("respawn_time");
       
        switch (getStatus())
        {    // Статус 0
            case ALIVE:
            {
                _fafurion = (GrandBoss) addSpawn(FAFURION, 185708, 114298, -8221, 0, false, 0);
                _fafurion.setCurrentHpMp(curr_hp, curr_mp);
                addBoss(_fafurion);
                break;
            }// Статус 1
            case WAITING:
            {
                _fafurion = (GrandBoss) addSpawn(FAFURION, 185708, 114298, -8221, 0, false, 0);
                _fafurion.setCurrentHpMp(curr_hp, curr_mp);
                addBoss(_fafurion);
                startQuestTimer("SPAWN_FAFURION", Config.FAFURION_WAIT_TIME * 60000, null, null);
                break;
            }
            case IN_FIGHT:
            {// Статус 2
                _fafurion = (GrandBoss) addSpawn(FAFURION, loc_x, loc_y, loc_z, heading, false, 0);
                _fafurion.setCurrentHpMp(curr_hp, curr_mp);
                addBoss(_fafurion);
                _lastAttack = System.currentTimeMillis();
                startQuestTimer("CHECK_ATTACK", 15000, _fafurion, null);
                startQuestTimer("SPAWN_MINION", 30000, _fafurion, null);
                break;
            }// Статус 3
            case DEAD:
            {
                final long remain = respawnTime - System.currentTimeMillis();
                if (remain > 0)
                {
                    startQuestTimer("CLEAR_STATUS", remain, null, null);
                }
                else
                {
                    setStatus(ALIVE);
                    _fafurion = (GrandBoss) addSpawn(FAFURION, 175762, 245289, -14848, 0, false, 0);
                    addBoss(_fafurion);
                }
                break;
            }
        }
    }
   
    @Override
    public String onEvent(String event, Npc npc, Player player)
    {
        switch (event)
        {
            case "enter":
            {
                String htmltext = null;
                if (getStatus() == DEAD)
                {
                    htmltext = "40025-01.html";
                }
                else if (getStatus() == IN_FIGHT)
                {
                    htmltext = "40025-02.html";
                }
                else if (zone.getPlayersInside().size() >= MAX_PEOPLE)
                {
                    htmltext = "40025-04.html";
                }
                else if (player.isInParty())
                {
                    final Party party = player.getParty();
                    final boolean isInCC = party.isInCommandChannel();
                    final List<Player> members = isInCC ? party.getCommandChannel().getMembers() : party.getMembers();
                    final boolean isPartyLeader = isInCC ? party.getCommandChannel().isLeader(player) : party.isLeader(player);
                    if (!isPartyLeader)
                    {
                        htmltext = "40025-05.html";
                    }
                    else if (!hasQuestItems(player, STONE))
                    {
                        htmltext = "40025-03.html";
                    }
                    else if (members.size() > (MAX_PEOPLE - zone.getPlayersInside().size()))
                    {
                        htmltext = "40025-04.html";
                    }
                    else
                    {
                        for (Player member : members)
                        {
                            if (member.isInsideRadius3D(npc, 1000))
                            {
                                member.teleToLocation(175788 + getRandom(700), 246939 + getRandom(2100), -14848);
                            }
                        }
                        if (getStatus() != WAITING)
                        {
                            setStatus(WAITING);
                            startQuestTimer("SPAWN_FAFURION", Config.FAFURION_WAIT_TIME * 60000, null, null);
                        }
                    }
                }
                else if (!hasQuestItems(player, STONE))
                {
                    htmltext = "40025-03.html";
                }
                else
                {
                    player.teleToLocation(175788 + getRandom(700), 246939 + getRandom(2100), -14848);
                    if (getStatus() != WAITING)
                    {
                        setStatus(WAITING);
                        startQuestTimer("SPAWN_FAFURION", Config.FAFURION_WAIT_TIME * 60000, null, null);
                    }
                }
                return htmltext;
            }
            case "teleportOut":
            {
                player.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
                break;
            }
            case "SPAWN_FAFURION":
            {
                _fafurion.disableCoreAI(true);
                _fafurion.setRandomWalking(false);
                _fafurion.teleToLocation(175760, 245303, -14848, 32542);
                setStatus(IN_FIGHT);
                _lastAttack = System.currentTimeMillis();
                zone.broadcastPacket(new PlaySound("BS02_A"));
                startQuestTimer("CAMERA_1", 23, _fafurion, null);
                break;
            }
            case "CAMERA_1":
            {
                zone.broadcastPacket(new SpecialCamera(npc, 700, 13, -19, 0, 10000, 20000, 0, 0, 0, 0, 0));
                startQuestTimer("CAMERA_2", 3000, npc, null);
                break;
            }
            case "CAMERA_2":
            {
                zone.broadcastPacket(new SpecialCamera(npc, 700, 13, 0, 6000, 10000, 20000, 0, 0, 0, 0, 0));
                startQuestTimer("CAMERA_3", 10000, npc, null);
                break;
            }
            case "CAMERA_3":
            {
                zone.broadcastPacket(new SpecialCamera(npc, 3700, 0, -3, 0, 10000, 10000, 0, 0, 0, 0, 0));
                zone.broadcastPacket(new SocialAction(npc.getObjectId(), 1));
                startQuestTimer("CAMERA_4", 200, npc, null);
                startQuestTimer("SOCIAL", 5200, npc, null);
                break;
            }
            case "CAMERA_4":
            {
                zone.broadcastPacket(new SpecialCamera(npc, 1100, 0, -3, 22000, 10000, 30000, 0, 0, 0, 0, 0));
                startQuestTimer("CAMERA_5", 10800, npc, null);
                break;
            }
            case "CAMERA_5":
            {
                zone.broadcastPacket(new SpecialCamera(npc, 1100, 0, -3, 300, 10000, 7000, 0, 0, 0, 0, 0));
                startQuestTimer("START_MOVE", 1900, npc, null);
                break;
            }
            case "SOCIAL":
            {
                zone.broadcastPacket(new SocialAction(npc.getObjectId(), 2));
                break;
            }
            case "START_MOVE":
            {
                _fafurion.disableCoreAI(false);
                _fafurion.setRandomWalking(true);
               
                for (Player players : World.getInstance().getVisibleObjectsInRange(npc, Player.class, 4000))
                {
                    if (players.isHero())
                    {
                        zone.broadcastPacket(new ExShowScreenMessage(NpcStringId.S1_YOU_CANNOT_HOPE_TO_DEFEAT_ME_WITH_YOUR_MEAGER_STRENGTH, 2, 4000, players.getName()));
                        break;
                    }
                }
                npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(179011, 114871, -7704));
                startQuestTimer("CHECK_ATTACK", 60000, npc, null);
                startQuestTimer("SPAWN_MINION", 300000, npc, null);
                break;
            }
            case "SET_REGEN":
            {
                if (npc != null)
                {
                    if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
                    {
                        if (!npc.isAffectedBySkill(ANTH_REGEN_4.getSkillId()))
                        {
                            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, ANTH_REGEN_4.getSkill(), npc);
                        }
                    }
                    else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5))
                    {
                        if (!npc.isAffectedBySkill(ANTH_REGEN_3.getSkillId()))
                        {
                            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, ANTH_REGEN_3.getSkill(), npc);
                        }
                    }
                    else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))
                    {
                        if (!npc.isAffectedBySkill(ANTH_REGEN_2.getSkillId()))
                        {
                            npc.getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, ANTH_REGEN_2.getSkill(), npc);
                        }
                    }
                    else if (!npc.isAffectedBySkill(ANTH_REGEN_1.getSkillId()))
                    {
                        npc.getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, ANTH_REGEN_1.getSkill(), npc);
                    }
                    startQuestTimer("SET_REGEN", 60000, npc, null);
                }
                break;
            }
            case "CHECK_ATTACK":
            {
                if ((npc != null) && ((_lastAttack + 900000) < System.currentTimeMillis()))
                {
                    setStatus(ALIVE);
                    for (Creature creature : zone.getCharactersInside())
                    {
                        if (creature != null)
                        {
                            if (creature.isNpc())
                            {
                                if (creature.getId() == FAFURION)
                                {
                                    creature.teleToLocation(175745, 245178, -14848);
                                }
                                else
                                {
                                    creature.deleteMe();
                                }
                            }
                            else if (creature.isPlayer())
                            {
                                creature.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
                            }
                        }
                    }
                    cancelQuestTimer("CHECK_ATTACK", npc, null);
                    cancelQuestTimer("SPAWN_MINION", npc, null);
                }
                else if (npc != null)
                {
                    if (attacker_1_hate > 10)
                    {
                        attacker_1_hate -= getRandom(10);
                    }
                    if (attacker_2_hate > 10)
                    {
                        attacker_2_hate -= getRandom(10);
                    }
                    if (attacker_3_hate > 10)
                    {
                        attacker_3_hate -= getRandom(10);
                    }
                    manageSkills(npc);
                    startQuestTimer("CHECK_ATTACK", 60000, npc, null);
                }
                break;
            }
            case "SPAWN_MINION":
            {
                if ((minionMultipler > 1) && (_minionCount < (100 - (minionMultipler * 2))))
                {
                    for (int i = 0; i < minionMultipler; i++)
                    {
                        addSpawn(FAFURION_KINDRED, npc, true);
                        addSpawn(FAFURION_HERALD_LOKNESS, npc, true);
                    }
                    _minionCount += minionMultipler * 2;
                }
                else if (_minionCount < 98)
                {
                    addSpawn(FAFURION_KINDRED, npc, true);
                    addSpawn(FAFURION_HERALD_LOKNESS, npc, true);
                    _minionCount += 2;
                }
                else if (_minionCount < 99)
                {
                    addSpawn(getRandomBoolean() ? FAFURION_KINDRED : FAFURION_HERALD_LOKNESS, npc, true);
                    _minionCount++;
                }
               
                if ((getRandom(100) > 10) && (minionMultipler < 4))
                {
                    minionMultipler++;
                }
                startQuestTimer("SPAWN_MINION", 300000, npc, null);
                break;
            }
            case "CLEAR_ZONE":
            {
                for (Creature creature : zone.getCharactersInside())
                {
                    if (creature != null)
                    {
                        if (creature.isNpc())
                        {
                            creature.deleteMe();
                        }
                        else if (creature.isPlayer())
                        {
                            creature.teleToLocation(79800 + getRandom(600), 151200 + getRandom(1100), -3534);
                        }
                    }
                }
                break;
            }
            case "TID_USED_FEAR":
            {
                if ((npc != null) && (sandStorm == 0))
                {
                    sandStorm = 1;
                    npc.disableCoreAI(true);
                    npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(175745, 245178, -14848));
                    startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 2000, npc, null);
                    startQuestTimer("TID_FEAR_COOLTIME", 300000, npc, null);
                }
                break;
            }
            case "TID_FEAR_COOLTIME":
            {
                sandStorm = 0;
                break;
            }
            case "TID_FEAR_MOVE_TIMEOVER":
            {
                if ((sandStorm == 1) && (npc.getX() == 175745) && (npc.getY() == 245178))
                {
                    sandStorm = 2;
                    moveChance = 0;
                    npc.disableCoreAI(false);
                    INVISIBLE_NPC.entrySet().forEach(entry -> addSpawn(entry.getKey(), entry.getValue()));
                }
                else if (sandStorm == 1)
                {
                    if (moveChance <= 3)
                    {
                        moveChance++;
                        npc.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(175745, 245178, -14848));
                        startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 5000, npc, null);
                    }
                    else
                    {
                        npc.teleToLocation(175745, 245178, -14848, npc.getHeading());
                        startQuestTimer("TID_FEAR_MOVE_TIMEOVER", 1000, npc, null);
                    }
                }
                break;
            }
            case "CLEAR_STATUS":
            {
                _fafurion = (GrandBoss) addSpawn(FAFURION, 175745, 245178, -14848, 0, false, 0);
                addBoss(_fafurion);
                Broadcast.toAllOnlinePlayers(new Earthquake(175745, 245178, -14848, 20, 10));
                setStatus(ALIVE);
                break;
            }
            case "SKIP_WAITING":
            {
                if (getStatus() == WAITING)
                {
                    cancelQuestTimer("SPAWN_FAFURION", null, null);
                    notifyEvent("SPAWN_FAFURION", null, null);
                    player.sendMessage(getClass().getSimpleName() + ": Skipping waiting time ...");
                }
                else
                {
                    player.sendMessage(getClass().getSimpleName() + ": You can't skip waiting time right now!");
                }
                break;
            }
            case "RESPAWN_FAFURION":
            {
                if (getStatus() == DEAD)
                {
                    setRespawn(0);
                    cancelQuestTimer("CLEAR_STATUS", null, null);
                    notifyEvent("CLEAR_STATUS", null, null);
                    player.sendMessage(getClass().getSimpleName() + ": Antharas has been respawned.");
                }
                else
                {
                    player.sendMessage(getClass().getSimpleName() + ": You can't respawn antharas while antharas is alive!");
                }
                break;
            }
            case "DESPAWN_MINIONS":
            {
                if (getStatus() == IN_FIGHT)
                {
                    _minionCount = 0;
                    for (Creature creature : zone.getCharactersInside())
                    {
                        if ((creature != null) && creature.isNpc() && ((creature.getId() == FAFURION_KINDRED) || (creature.getId() == FAFURION_HERALD_LOKNESS)))
                        {
                            creature.deleteMe();
                        }
                    }
                    if (player != null) // Player cannot be null when is this event is called from a GM command.
                    {
                        player.sendMessage(getClass().getSimpleName() + ": All minions have been deleted!");
                    }
                }
                else if (player != null) // Player cannot be null when is this event is called from a GM command.
                {
                    player.sendMessage(getClass().getSimpleName() + ": You can't despawn minions right now!");
                }
                break;
            }
            case "ABORT_FIGHT":
            {
                if (getStatus() == IN_FIGHT)
                {
                    setStatus(ALIVE);
                    cancelQuestTimer("CHECK_ATTACK", _fafurion, null);
                    cancelQuestTimer("SPAWN_MINION", _fafurion, null);
                    for (Creature creature : zone.getCharactersInside())
                    {
                        if (creature != null)
                        {
                            if (creature.isNpc())
                            {
                                if (creature.getId() == FAFURION)
                                {
                                    creature.teleToLocation(175745, 245178, -14848);
                                }
                                else
                                {
                                    creature.deleteMe();
                                }
                            }
                            else if (creature.isPlayer() && !creature.isGM())
                            {
                                creature.teleToLocation(175745 + getRandom(0), 245178 + getRandom(0), -14848);
                            }
                        }
                    }
                    player.sendMessage(getClass().getSimpleName() + ": Бой был остановлен!");
                }
                else
                {
                    player.sendMessage(getClass().getSimpleName() + ": Ты не можешь остановить бой сейчас!");
                }
                break;
            }
            case "MANAGE_SKILL":
            {
                manageSkills(npc);
                break;
            }
        }
        return super.onEvent(event, npc, player);
    }
   
    @Override
    public String onAggroRangeEnter(Npc npc, Player player, boolean isSummon)
    {
        npc.doCast(DISPEL_BOM.getSkill());
        npc.doDie(player);
        return super.onAggroRangeEnter(npc, player, isSummon);
    }
   
    @Override
    public String onKill(Npc npc, Player killer, boolean isSummon)
    {
        if (zone.isCharacterInZone(killer))
        {
            if (npc.getId() == FAFURION)
            {
                _fafurion = null;
                notifyEvent("DESPAWN_MINIONS", null, null);
                zone.broadcastPacket(new SpecialCamera(npc, 1200, 20, -10, 0, 10000, 13000, 0, 0, 0, 0, 0));
                zone.broadcastPacket(new PlaySound("BS01_D"));
                addSpawn(CUBE, 175745, 245178, -14848, 0, false, 900000);
               
                final long baseIntervalMillis = Config.FAFURION_SPAWN_INTERVAL * 3600000;
                final long randomRangeMillis = Config.FAFURION_SPAWN_RANDOM * 3600000;
                final long respawnTime = baseIntervalMillis + getRandom(-randomRangeMillis, randomRangeMillis);
                setRespawn(respawnTime);
                startQuestTimer("CLEAR_STATUS", respawnTime, null, null);
                cancelQuestTimer("SET_REGEN", npc, null);
                cancelQuestTimer("CHECK_ATTACK", npc, null);
                cancelQuestTimer("SPAWN_MINION", npc, null);
                startQuestTimer("CLEAR_ZONE", 900000, null, null);
                setStatus(DEAD);
            }
            else
            {
                _minionCount--;
            }
        }
        return super.onKill(npc, killer, isSummon);
    }
   
    @Override
    public void onMoveFinished(Npc npc)
    {
        npc.doCast(DISPEL_BOM.getSkill());
        npc.doDie(null);
    }
   
    @Override
    public String onSpawn(Npc npc)
    {
        if (npc.getId() == FAFURION)
        {
            npc.asAttackable().setCanReturnToSpawnPoint(false);
            npc.setRandomWalking(false);
           
            cancelQuestTimer("SET_REGEN", npc, null);
            startQuestTimer("SET_REGEN", 60000, npc, null);
            npc.asAttackable().setOnKillDelay(0);
        }
        else
        {
            for (int i = 1; i <= 6; i++)
            {
                final int x = npc.getTemplate().getParameters().getInt("suicide" + i + "_x");
                final int y = npc.getTemplate().getParameters().getInt("suicide" + i + "_y");
                final Attackable naiad = addSpawn(NAIAD, npc.getX(), npc.getY(), npc.getZ(), 0, true, 15000, true).asAttackable();
                naiad.getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO, new Location(x, y, npc.getZ()));
            }
            npc.deleteMe();
        }
        return super.onSpawn(npc);
    }
   
    @Override
    public String onSpellFinished(Npc npc, Player player, Skill skill)
    {
        if ((skill.getId() == ANTH_FEAR.getSkillId()) || (skill.getId() == ANTH_FEAR_SHORT.getSkillId()))
        {
            startQuestTimer("TID_USED_FEAR", 7000, npc, null);
        }
        startQuestTimer("MANAGE_SKILL", 1000, npc, null);
        return super.onSpellFinished(npc, player, skill);
    }
   
    @Override
    public boolean unload(boolean removeFromList)
    {
        if (_fafurion != null)
        {
            _fafurion.deleteMe();
            _fafurion = null;
        }
        return super.unload(removeFromList);
    }
   
    private int getStatus()
    {
        return GrandBossManager.getInstance().getStatus(FAFURION);
    }
   
    private void addBoss(GrandBoss grandboss)
    {
        GrandBossManager.getInstance().addBoss(grandboss);
    }
   
    private void setStatus(int status)
    {
        GrandBossManager.getInstance().setStatus(FAFURION, status);
    }
   
    private void setRespawn(long respawnTime)
    {
        GrandBossManager.getInstance().getStatSet(FAFURION).set("respawn_time", System.currentTimeMillis() + respawnTime);
    }
   
    private void refreshAiParams(Player attacker, int damage)
    {
        if ((attacker_1 != null) && (attacker == attacker_1))
        {
            if (attacker_1_hate < (damage + 1000))
            {
                attacker_1_hate = damage + getRandom(3000);
            }
        }
        else if ((attacker_2 != null) && (attacker == attacker_2))
        {
            if (attacker_2_hate < (damage + 1000))
            {
                attacker_2_hate = damage + getRandom(3000);
            }
        }
        else if ((attacker_3 != null) && (attacker == attacker_3))
        {
            if (attacker_3_hate < (damage + 1000))
            {
                attacker_3_hate = damage + getRandom(3000);
            }
        }
        else
        {
            final int i1 = Util.min(attacker_1_hate, attacker_2_hate, attacker_3_hate);
            if (attacker_1_hate == i1)
            {
                attacker_1_hate = damage + getRandom(3000);
                attacker_1 = attacker;
            }
            else if (attacker_2_hate == i1)
            {
                attacker_2_hate = damage + getRandom(3000);
                attacker_2 = attacker;
            }
            else if (attacker_3_hate == i1)
            {
                attacker_3_hate = damage + getRandom(3000);
                attacker_3 = attacker;
            }
        }
    }
   
    private void manageSkills(Npc npc)
    {
        if (npc.isCastingNow() || npc.isCoreAIDisabled() || !npc.isInCombat())
        {
            return;
        }
       
        int i1 = 0;
        int i2 = 0;
        Player c2 = null;
        if ((attacker_1 == null) || (npc.calculateDistance3D(attacker_1) > 9000) || attacker_1.isDead())
        {
            attacker_1_hate = 0;
        }
       
        if ((attacker_2 == null) || (npc.calculateDistance3D(attacker_2) > 9000) || attacker_2.isDead())
        {
            attacker_2_hate = 0;
        }
       
        if ((attacker_3 == null) || (npc.calculateDistance3D(attacker_3) > 9000) || attacker_3.isDead())
        {
            attacker_3_hate = 0;
        }
       
        if (attacker_1_hate > attacker_2_hate)
        {
            i1 = 2;
            i2 = attacker_1_hate;
            c2 = attacker_1;
        }
        else if (attacker_2_hate > 0)
        {
            i1 = 3;
            i2 = attacker_2_hate;
            c2 = attacker_2;
        }
       
        if (attacker_3_hate > i2)
        {
            i1 = 4;
            i2 = attacker_3_hate;
            c2 = attacker_3;
        }
        if (i2 > 0)
        {
            if (getRandom(100) < 70)
            {
                switch (i1)
                {
                    case 2:
                    {
                        attacker_1_hate = 500;
                        break;
                    }
                    case 3:
                    {
                        attacker_2_hate = 500;
                        break;
                    }
                    case 4:
                    {
                        attacker_3_hate = 500;
                        break;
                    }
                }
            }
           
            final double distance_c2 = npc.calculateDistance3D(c2);
            final double direction_c2 = npc.calculateDirectionTo(c2);
            SkillHolder skillToCast = null;
            boolean castOnTarget = false;
            if (npc.getCurrentHp() < (npc.getMaxHp() * 0.25))
            {
                if (getRandom(100) < 30)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_MOUTH;
                }
                else if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
                {
                    skillToCast = ANTH_TAIL;
                }
                else if ((getRandom(100) < 40) && (((distance_c2 < 850) && (direction_c2 < 210) && (direction_c2 > 150)) || ((distance_c2 < 425) && (direction_c2 < 270) && (direction_c2 > 90))))
                {
                    skillToCast = ANTH_DEBUFF;
                }
                else if ((getRandom(100) < 10) && (distance_c2 < 1100))
                {
                    skillToCast = ANTH_JUMP;
                }
                else if (getRandom(100) < 10)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_METEOR;
                }
                else if (getRandom(100) < 6)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_BREATH;
                }
                else if (getRandomBoolean())
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK_EX;
                }
                else if (getRandom(100) < 5)
                {
                    castOnTarget = true;
                    skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
                }
                else
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK;
                }
            }
            else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.5))
            {
                if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
                {
                    skillToCast = ANTH_TAIL;
                }
                else if ((getRandom(100) < 40) && (((distance_c2 < 850) && (direction_c2 < 210) && (direction_c2 > 150)) || ((distance_c2 < 425) && (direction_c2 < 270) && (direction_c2 > 90))))
                {
                    skillToCast = ANTH_DEBUFF;
                }
                else if ((getRandom(100) < 10) && (distance_c2 < 1100))
                {
                    skillToCast = ANTH_JUMP;
                }
                else if (getRandom(100) < 7)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_METEOR;
                }
                else if (getRandom(100) < 6)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_BREATH;
                }
                else if (getRandomBoolean())
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK_EX;
                }
                else if (getRandom(100) < 5)
                {
                    castOnTarget = true;
                    skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
                }
                else
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK;
                }
            }
            else if (npc.getCurrentHp() < (npc.getMaxHp() * 0.75))
            {
                if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
                {
                    skillToCast = ANTH_TAIL;
                }
                else if ((getRandom(100) < 10) && (distance_c2 < 1100))
                {
                    skillToCast = ANTH_JUMP;
                }
                else if (getRandom(100) < 5)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_METEOR;
                }
                else if (getRandom(100) < 6)
                {
                    castOnTarget = true;
                    skillToCast = ANTH_BREATH;
                }
                else if (getRandomBoolean())
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK_EX;
                }
                else if (getRandom(100) < 5)
                {
                    castOnTarget = true;
                    skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
                }
                else
                {
                    castOnTarget = true;
                    skillToCast = ANTH_NORM_ATTACK;
                }
            }
            else if ((getRandom(100) < 80) && (((distance_c2 < 1423) && (direction_c2 < 188) && (direction_c2 > 172)) || ((distance_c2 < 802) && (direction_c2 < 194) && (direction_c2 > 166))))
            {
                skillToCast = ANTH_TAIL;
            }
            else if (getRandom(100) < 3)
            {
                castOnTarget = true;
                skillToCast = ANTH_METEOR;
            }
            else if (getRandom(100) < 6)
            {
                castOnTarget = true;
                skillToCast = ANTH_BREATH;
            }
            else if (getRandomBoolean())
            {
                castOnTarget = true;
                skillToCast = ANTH_NORM_ATTACK_EX;
            }
            else if (getRandom(100) < 5)
            {
                castOnTarget = true;
                skillToCast = getRandomBoolean() ? ANTH_FEAR : ANTH_FEAR_SHORT;
            }
            else
            {
                castOnTarget = true;
                skillToCast = ANTH_NORM_ATTACK;
            }
           
            if ((skillToCast != null) && npc.checkDoCastConditions(skillToCast.getSkill()))
            {
                if (castOnTarget)
                {
                    addSkillCastDesire(npc, c2, skillToCast.getSkill(), 100);
                }
                else
                {
                    npc.getAI().setIntention(CtrlIntention.AI_INTENTION_CAST, skillToCast.getSkill(), npc);
                }
            }
        }
    }
   
    public static void main(String[] args)
    {
        new Fafurion();
    }
}

И еще сервак орет на:


Код:
[20/03 17:24:04] GrandBossManager: Updated Фафурион(40024) status to 2
[20/03 17:24:19] Exception on onSpawn() in notifySpawn(): Integer value required, but not specified: suicide1_x!
java.lang.IllegalArgumentException: Integer value required, but not specified: suicide1_x!
    at org.l2jmobius.gameserver.model.StatSet.getInt(StatSet.java:311)
    at ai.bosses.Fafurion.Fafurion.onSpawn(Fafurion.java:673)
    at org.l2jmobius.gameserver.model.quest.Quest.notifySpawn(Quest.java:502)
    at org.l2jmobius.gameserver.model.quest.Quest.lambda$addSpawnId$15(Quest.java:1805)
    at org.l2jmobius.gameserver.model.events.listeners.ConsumerEventListener.executeEvent(ConsumerEventListener.java:44)
    at org.l2jmobius.gameserver.model.events.EventDispatcher.notifyToListeners(EventDispatcher.java:305)
    at org.l2jmobius.gameserver.model.events.EventDispatcher.notifyEventToSingleContainer(EventDispatcher.java:198)
    at org.l2jmobius.gameserver.model.events.EventDispatcher.lambda$notifyEventAsync$1(EventDispatcher.java:160)
    at org.l2jmobius.commons.threads.ThreadPool$RunnableWrapper.run(ThreadPool.java:245)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1575)

[20/03 17:31:02] GlobalVariablesManager: Stored 16 variables.

Подскажите пож, что не так :OnionHead: :Nonono::Imc:
 
Логики суицида мобов не должно быть?
Если не должно, удали
Код:
addSpawnId(INVISIBLE_NPC.keySet());
. Можешь еще удалить в обработке спавна else (обработку левых нпц - не тарас)
Если должна быть, прокинь 6 параметров для INVISIBLE_NPC. Пример, suicide1_y, suicide1_x
Код:
                final int x = npc.getTemplate().getParameters().getInt("suicide" + i + "_x");
                final int y = npc.getTemplate().getParameters().getInt("suicide" + i + "_y");
 
  • Мне нравится
Реакции: Maiden7

    Maiden7

    Баллов: 5
    Зав помощь
Логики суицида мобов не должно быть?
Если не должно, удали
Код:
addSpawnId(INVISIBLE_NPC.keySet());
. Можешь еще удалить в обработке спавна else (обработку левых нпц - не тарас)
Если должна быть, прокинь 6 параметров для INVISIBLE_NPC. Пример, suicide1_y, suicide1_x
Код:
                final int x = npc.getTemplate().getParameters().getInt("suicide" + i + "_x");
                final int y = npc.getTemplate().getParameters().getInt("suicide" + i + "_y");
Спасибо. Пропал ор на суицид.
Остался самый главный момент, статус DEAD не устанавливается после смерти бросса.
 
Спасибо. Пропал ор на суицид.
Остался самый главный момент, статус DEAD не устанавливается после смерти бросса.
попробуй добавить своего босса в таблицу grandboss_data
 
скорее всего
Код:
if (zone.isCharacterInZone(killer))
в onKill не проходит. Проверь зону, находится ли игрок в ней. Можешь так же просто проверку эту убрать на момент теста. Если это решит проблему, настрой свою зону
 
скорее всего
Код:
if (zone.isCharacterInZone(killer))
в onKill не проходит. Проверь зону, находится ли игрок в ней. Можешь так же просто проверку эту убрать на момент теста. Если это решит проблему, настрой свою зону
 
Назад
Сверху