Visible only to X players

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

Horyon

Пляшущий с бубном
Участник
Сообщения
220
Розыгрыши
0
Решения
4
Репутация
53
Реакции
78
Баллы
273
Хроники
  1. Shadow of the Kamael
Исходники
Присутствуют
Сборка
L2jMobius Master class ch3
Hello guys.

I have a quest that spawn a NPC, and in one test more than 5 person doing that is kinda bad cause appear 5 same NPC for ppl interact with just tittle change. Its not impossible to see UR npc but maybe have a better way.

In last years i saw a Box event in Innadril, was a masterpiece content cause it only appear for u, and when u done dissapear. And same for other ppl. This can make my quest better.

So i want to spawn this event NPC only for current player doing the quest. Any tip?

Ty for any help... its nice to get back XD
 
Решение
just simple realisation for sample (for OW based server)
Java:
package npc.model;

import java.util.Collections;
import java.util.List;

import l2p.gameserver.holders.npcs.NpcTemplate;
import l2p.gameserver.model.Creature;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.instances.NpcInstance;
import l2p.gameserver.network.s2c.L2GameServerPacket;

public class OnlyOwnerVisibleNpcInstance extends NpcInstance
{
    private Player _owner;

    public OnlyOwnerVisibleNpcInstance(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }

    public void setOwner(Player owner)
    {
        _owner = owner;
    }

    public Player getOwner()
    {
        return _owner;
    }

    @Override
    public void...
save player in npc on spawn -> (Player) addVisibleObject -> (NPC) addPacketList -> send packets only for saved player

it way for OW based servers, but for mobius server there should be something similar
 
just simple realisation for sample (for OW based server)
Java:
package npc.model;

import java.util.Collections;
import java.util.List;

import l2p.gameserver.holders.npcs.NpcTemplate;
import l2p.gameserver.model.Creature;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.instances.NpcInstance;
import l2p.gameserver.network.s2c.L2GameServerPacket;

public class OnlyOwnerVisibleNpcInstance extends NpcInstance
{
    private Player _owner;

    public OnlyOwnerVisibleNpcInstance(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }

    public void setOwner(Player owner)
    {
        _owner = owner;
    }

    public Player getOwner()
    {
        return _owner;
    }

    @Override
    public void broadcastPacket(L2GameServerPacket... packets)
    {
        if (_owner != null)
            _owner.sendPacket(packets);
    }

    @Override
    public void broadcastPacketToOthers(int range, L2GameServerPacket... packets)
    {
        if (_owner != null)
            _owner.sendPacket(packets);
    }

    @Override
    public void broadcastCharInfoImpl()
    {
        if (_owner != null)
            _owner.sendPacket(new NpcInfo(this, _owner).update());
    }

    @Override
    public List<L2GameServerPacket> addPacketList(Player forPlayer, Creature dropper)
    {
        if (forPlayer != _owner)
            return Collections.emptyList();

        return super.addPacketList(forPlayer, dropper);
    }
}
 
Последнее редактирование:
Решение
Ty i'll try adapt to Mobius
just simple realisation for sample (for OW based server)
Java:
package npc.model;

import java.util.Collections;
import java.util.List;

import l2p.gameserver.holders.npcs.NpcTemplate;
import l2p.gameserver.model.Creature;
import l2p.gameserver.model.Player;
import l2p.gameserver.model.instances.NpcInstance;
import l2p.gameserver.network.s2c.L2GameServerPacket;

public class OnlyOwnerVisibleNpcInstance extends NpcInstance
{
    private Player _owner;

    public OnlyOwnerVisibleNpcInstance(int objectId, NpcTemplate template)
    {
        super(objectId, template);
    }

    public void setOwner(Player owner)
    {
        _owner = owner;
    }

    public Player getOwner()
    {
        return _owner;
    }

    @Override
    public void broadcastPacket(L2GameServerPacket... packets)
    {
        if (_owner != null)
            _owner.sendPacket(packets);
    }

    @Override
    public void broadcastPacketToOthers(int range, L2GameServerPacket... packets)
    {
        if (_owner != null)
            _owner.sendPacket(packets);
    }

    @Override
    public void broadcastCharInfoImpl()
    {
        if (_owner != null)
            _owner.sendPacket(new NpcInfo(this, _owner).update());
    }

    @Override
    public List<L2GameServerPacket> addPacketList(Player forPlayer, Creature dropper)
    {
        if (forPlayer != _owner)
            return Collections.emptyList();

        return super.addPacketList(forPlayer, dropper);
    }
}

Ty @Gaikotsu, reading the _owner reference i make my own way to do it.

In mobius there is a Creature(player and npc) option to set invisible(for all). I copy it and save the player ref to exclude himself from setinvisible test. That way now only quest player can see the spawned npc.

Ty again.
 
Ty i'll try adapt to Mobius


Ty @Gaikotsu, reading the _owner reference i make my own way to do it.

In mobius there is a Creature(player and npc) option to set invisible(for all). I copy it and save the player ref to exclude himself from setinvisible test. That way now only quest player can see the spawned npc.

Ty again.
Can you share it?
 
Назад
Сверху Снизу