Beispiel #1
0
        /// <summary>
        /// Respawns a monster or mapobject
        /// </summary>
        /// <param name="c"></param>
        private static void SendRespawn(MapObject c)
        {
            bool isnpc     = MapObject.IsNpc(c);
            bool ismapitem = MapObject.IsMapItem(c);

            c.OnDeregister();
            c.OnSpawn();
            c.OnRegister();

            Regiontree tree = c._currentzone.Regiontree;

            if (isnpc)
            {
                foreach (Character regionObject in tree.SearchActors(SearchFlags.Characters))
                {
                    Actor actor = c as Actor;
                    actor.stance = (byte)StancePosition.Reborn;
                    SMSG_NPCINFO spkt2 = new SMSG_NPCINFO(0);
                    spkt2.ActorID   = actor.id;
                    spkt2.HP        = actor.HPMAX;
                    spkt2.SP        = actor.SPMAX;
                    spkt2.MaxHP     = actor.HPMAX;
                    spkt2.MaxSP     = actor.SPMAX;
                    spkt2.NPCID     = actor.ModelId;
                    spkt2.X         = actor.Position.x;
                    spkt2.Y         = actor.Position.y;
                    spkt2.Z         = actor.Position.z;
                    spkt2.SessionId = regionObject.id;
                    regionObject.client.Send((byte[])spkt2);
                    c.Appears(regionObject);
                }
            }
            else if (ismapitem)
            {
                foreach (Character regionObject in tree.SearchActors(SearchFlags.Characters))
                {
                    MapItem       item  = c as MapItem;
                    SMSG_ITEMINFO spkt2 = new SMSG_ITEMINFO();
                    spkt2.ActorID     = item.id;
                    spkt2.CanInteract = item.IsInteractable(regionObject);
                    spkt2.IsActive    = item.IsHighlighted(regionObject);
                    spkt2.NPCID       = item.ModelId;
                    spkt2.X           = item.Position.x;
                    spkt2.Y           = item.Position.y;
                    spkt2.Z           = item.Position.z;
                    spkt2.SessionId   = regionObject.id;
                    regionObject.client.Send((byte[])spkt2);
                    c.Appears(regionObject);
                }
            }
        }