Script aCis 382 Spawn/Despawn Monster when Boss is Alive

AntiVirus

Путник
Пользователь
Сообщения
13
Розыгрыши
0
Репутация
0
Реакции
0
Баллы
83
Хроники
  1. Interlude
Исходники
Присутствуют
Сборка
l2replica
Hello everyone guys, i am newbie in java at all... i am try to write a script for my server, i want 5 monstersIDs to get control from boss. if the boss is alive then all monsters can get spawn and respawn normally but when raid boss is dead then monsters will stop get respawn until raidboss get back alive again. i am try to make this code mostly from chatgpt .

i know what i have wrapper to return null but its because i dont know how i need to write it correct in my project aCis
382.
Java:
package net.sf.l2j.gameserver.scripting.scripts.custom;

import java.util.ArrayList;
import java.util.List;

import net.sf.l2j.gameserver.model.World;
import net.sf.l2j.gameserver.model.actor.Npc;
import net.sf.l2j.gameserver.model.actor.Player;
import net.sf.l2j.gameserver.scripting.Quest;

public class FafurionGhostEvent extends Quest
{
    private static final int BOSS_ID = 210;
    private static final int[] GHOST_IDS = {207, 208, 209, 211, 212};

    // Ghost spawn coordinates: x, y, z, heading
    private static final int[][] GHOST_LOCS = {
            {212000, 120000, -3700, 0},
            {213000, 119500, -3650, 0},
            {211500, 118800, -3720, 0},
            {212500, 119000, -3680, 0},
            {213200, 118500, -3660, 0}
    };

    private final List<Npc> spawnedGhosts = new ArrayList<>();

    public FafurionGhostEvent()
    {
        super(-1, "custom");

        addSpawnId(BOSS_ID);
        addKillId(BOSS_ID);
    }
    private Npc addSpawn(int npcId, int x, int y, int z, int heading, boolean unused1, int unused2)
    {
        addSpawn(npcId, x, y, z, heading);


        return null;
    }

    private void addSpawn(int npcId, int x, int y, int z, int heading) {
    }

    @Override
    public String onSpawn(Npc npc)
    {
        if (npc.getNpcId() == BOSS_ID)
        {
            for (int i = 0; i < GHOST_IDS.length; i++)
            {
                int ghostId = GHOST_IDS[i];
                int[] loc = GHOST_LOCS[i % GHOST_LOCS.length];

                Npc ghost = addSpawn(ghostId, loc[0], loc[1], loc[2], loc[3], false, 0);
                if (ghost != null)
                {
                    spawnedGhosts.add(ghost);
                }
            }
            System.out.println("FafurionGhostEvent: Spawned ghosts because boss spawned.");
        }
        return null;
    }



    
    public String onKill(Npc npc, Player killer, boolean isPet)
    {
        if (npc.getNpcId() == BOSS_ID)
        {
            for (Object obj : World.getInstance().getObjects())
            {
                if (obj instanceof Npc)
                {
                    Npc ghost = (Npc) obj;
                    int id = ghost.getNpcId();
                    if (id == 207 || id == 208 || id == 209 || id == 211 || id == 212)
                        ghost.deleteMe();
                }
            }
            System.out.println("FafurionGhostEvent: Despawned ghosts because boss died.");
        }
        return null;
    }



    public static void main(String[] args)
    {
        new FafurionGhostEvent();
    }
}


thanks in advance guys peace <3 !!!
 

Похожие темы

Данный сайт использует cookie. Вы должны принять их для продолжения использования. Узнать больше…