Mobs Invisible

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

Horyon

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

I'm facing a strange bug for a few months. I have add custom npcs to npc: grp and name. So far ok, work etc... problem is always they spawn invisible. I believe its just a visual issue cause after 1 hit using next target, the npc appear. Always after 1 hit he appear.
1685258600658.webp

Lf any help ty!!!
 

Keep with problem @MrKirill1232.

Mobs invisible until get hit
 
World.java -> switchRegion(). Have fun :)
I take a look at this but, my low knowledge dont make me found the problem in there.

OBS: i realese that the only problem is with

Java:
world.spawnGroup("operatives");

that push a group in instance XML


XML:
<group name="operatives" spawnByDefault="false">
            <!-- Operative - 1 Room -->
            <npc id="22998" x="47909" y="248350" z="-6300" heading="0" />
            <npc id="22998" x="47983" y="248607" z="-6300" heading="0" />
            <npc id="22998" x="47844" y="248568" z="-6300" heading="0" />
            <npc id="22998" x="47873" y="248432" z="-6300" heading="0" />
            <npc id="22998" x="47632" y="248406" z="-6300" heading="0" />
            <npc id="22998" x="47843" y="248461" z="-6300" heading="0" />
        </group>

in the Java instance file, normal addspawn works just fine without problem. Only the mobs in this group from xml looks be bugged.
 
I take a look at this but, my low knowledge dont make me found the problem in there.

OBS: i realese that the only problem is with

Java:
world.spawnGroup("operatives");

that push a group in instance XML


XML:
<group name="operatives" spawnByDefault="false">
            <!-- Operative - 1 Room -->
            <npc id="22998" x="47909" y="248350" z="-6300" heading="0" />
            <npc id="22998" x="47983" y="248607" z="-6300" heading="0" />
            <npc id="22998" x="47844" y="248568" z="-6300" heading="0" />
            <npc id="22998" x="47873" y="248432" z="-6300" heading="0" />
            <npc id="22998" x="47632" y="248406" z="-6300" heading="0" />
            <npc id="22998" x="47843" y="248461" z="-6300" heading="0" />
        </group>

in the Java instance file, normal addspawn works just fine without problem. Only the mobs in this group from xml looks be bugged.

Problem is not xml spawn group.

so Elrik point to this
Java:
public void switchRegion(WorldObject object, WorldRegion newRegion)
    {
        final WorldRegion oldRegion = object.getWorldRegion();
        if ((oldRegion == null) || (oldRegion == newRegion))
        {
            return;
        }
        
        final WorldRegion[] oldSurroundingRegions = oldRegion.getSurroundingRegions();
        for (int i = 0; i < oldSurroundingRegions.length; i++)
        {
            final WorldRegion worldRegion = oldSurroundingRegions[i];
            if (newRegion.isSurroundingRegion(worldRegion))
            {
                continue;
            }
            
            final Collection<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
            if (visibleObjects.isEmpty())
            {
                continue;
            }
            
            for (WorldObject wo : visibleObjects)
            {
                if (wo == object)
                {
                    continue;
                }
                
                if (object.isCreature())
                {
                    final Creature objectCreature = (Creature) object;
                    final CreatureAI ai = objectCreature.getAI();
                    if (ai != null)
                    {
                        ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, wo);
                    }
                    
                    if (objectCreature.getTarget() == wo)
                    {
                        objectCreature.setTarget(null);
                    }
                    
                    if (object.isPlayer())
                    {
                        object.sendPacket(new DeleteObject(wo));
                    }
                }
                
                if (wo.isCreature())
                {
                    final Creature woCreature = (Creature) wo;
                    final CreatureAI ai = woCreature.getAI();
                    if (ai != null)
                    {
                        ai.notifyEvent(CtrlEvent.EVT_FORGET_OBJECT, object);
                    }
                    
                    if (woCreature.getTarget() == object)
                    {
                        woCreature.setTarget(null);
                    }
                    
                    if (wo.isPlayer())
                    {
                        wo.sendPacket(new DeleteObject(object));
                    }
                }
            }
        }
        
        final WorldRegion[] newSurroundingRegions = newRegion.getSurroundingRegions();
        for (int i = 0; i < newSurroundingRegions.length; i++)
        {
            final WorldRegion worldRegion = newSurroundingRegions[i];
            if (oldRegion.isSurroundingRegion(worldRegion))
            {
                continue;
            }
            
            final Collection<WorldObject> visibleObjects = worldRegion.getVisibleObjects();
            if (visibleObjects.isEmpty())
            {
                continue;
            }
            
            for (WorldObject wo : visibleObjects)
            {
                if ((wo == object) || (wo.getInstanceWorld() != object.getInstanceWorld()))
                {
                    continue;
                }
                
                if (object.isPlayer() && wo.isVisibleFor((Player) object))
                {
                    wo.sendInfo((Player) object);
                    if (wo.isCreature())
                    {
                        final CreatureAI ai = ((Creature) wo).getAI();
                        if (ai != null)
                        {
                            ai.describeStateToPlayer((Player) object);
                            if (wo.isMonster() && (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE))
                            {
                                ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
                            }
                        }
                    }
                }
                
                if (wo.isPlayer() && object.isVisibleFor((Player) wo))
                {
                    object.sendInfo((Player) wo);
                    if (object.isCreature())
                    {
                        final CreatureAI ai = ((Creature) object).getAI();
                        if (ai != null)
                        {
                            ai.describeStateToPlayer((Player) wo);
                            if (object.isMonster() && (ai.getIntention() == CtrlIntention.AI_INTENTION_IDLE))
                            {
                                ai.setIntention(CtrlIntention.AI_INTENTION_ACTIVE);
                            }
                        }
                    }
                }
            }
        }
 }

whats the issue in code?

ty in advance
 
Try this, but be careful... This is not a fix, but maybe it will help u to understand the problem.
Код:
 //if (oldRegion.isSurroundingRegion(worldRegion))
 //{
 //continue;
 //}
 
Назад
Сверху