public void KillAvatar(IScenePresence killingAvatar, string killingAvatarMessage, string deadAvatarMessage,
                                   bool TeleportAgent, bool showAgentMessages)
            {
                try {
                    if (showAgentMessages)
                    {
                        if (deadAvatarMessage != "")
                        {
                            m_SP.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true);
                        }
                        //Send it as a blue box at the bottom of the screen rather than as a full popup
                        if (killingAvatar != null && killingAvatarMessage != "")
                        {
                            killingAvatar.ControllingClient.SendAlertMessage(killingAvatarMessage);
                        }
                    }
                } catch (InvalidOperationException) {
                }

                Health = m_combatModule.MaximumHealth;
                if (TeleportAgent)
                {
                    if (m_combatModule.m_shouldRespawn)
                    {
                        if (m_combatModule.m_SecondsBeforeRespawn != 0)
                        {
                            m_SP.AllowMovement = false;
                            HasLeftCombat      = true;
                            respawnTimer       = new Timer {
                                Interval = m_combatModule.m_SecondsBeforeRespawn * 1000, AutoReset = false
                            };
                            //Use this to re-enable movement and combat
                            //Only once
                            respawnTimer.Elapsed += respawn_Elapsed;
                            respawnTimer.Start();
                        }
                        m_SP.Teleport(m_combatModule.m_RespawnPosition);
                    }
                    else
                    {
                        IEntityTransferModule transferModule =
                            m_SP.Scene.RequestModuleInterface <IEntityTransferModule> ();
                        if (transferModule != null)
                        {
                            if (!transferModule.TeleportHome(m_SP.UUID, m_SP.ControllingClient))
                            {
                                if (m_SP.PhysicsActor != null)
                                {
                                    m_SP.PhysicsActor.Flying = true;
                                }
                                m_SP.Teleport(new Vector3(m_SP.Scene.RegionInfo.RegionSizeX / 2,
                                                          m_SP.Scene.RegionInfo.RegionSizeY / 2, 128));
                            }
                        }
                    }
                }

                m_SP.Scene.WhiteCoreEventManager.FireGenericEventHandler("OnAvatarDeath", m_SP);
            }
Beispiel #2
0
        public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
                                     uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportStart(teleportFlags);
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");

            // Reset animations; the viewer does that in teleports.
            if (sp.Animator != null)
            {
                sp.Animator.ResetAnimations();
            }

            try
            {
                string reason = "";
                if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    //First check whether the user is allowed to move at all
                    if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //Now respect things like parcel bans with this
                    if (
                        !sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, teleportFlags, out position,
                                                                      out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    MainConsole.Instance.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.RequestModuleInterface <IScriptControllerModule>()
                    .HandleForceReleaseControls(sp.ControllingClient, sp.UUID);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    // Make sure the user is allowed to leave this region
                    if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }

                    DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message,
                                                 e.StackTrace);
                sp.ControllingClient.SendTeleportFailed("Internal error");
            }
        }
Beispiel #3
0
        /// <summary>
        ///   Creates a new bot inworld
        /// </summary>
        /// <param name = "FirstName"></param>
        /// <param name = "LastName"></param>
        /// <param name = "cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
        /// <returns>ID of the bot</returns>
        public UUID CreateAvatar(string FirstName, string LastName, IScene scene, UUID cloneAppearanceFrom,
                                 UUID creatorID, Vector3 startPos)
        {
            AgentCircuitData m_aCircuitData = new AgentCircuitData
            {
                child       = false,
                circuitcode = (uint)Util.RandomClass.Next(),
                Appearance  = GetAppearance(cloneAppearanceFrom, scene)
            };

            //Add the circuit data so they can login

            //Sets up appearance
            if (m_aCircuitData.Appearance == null)
            {
                m_aCircuitData.Appearance = new AvatarAppearance {
                    Wearables = AvatarWearable.DefaultWearables
                };
            }
            //Create the new bot data
            BotClientAPI m_character = new BotClientAPI(scene, m_aCircuitData)
            {
                FirstName = FirstName, LastName = LastName
            };

            m_aCircuitData.AgentID          = m_character.AgentId;
            m_aCircuitData.Appearance.Owner = m_character.AgentId;
            List <AvatarAttachment> attachments = m_aCircuitData.Appearance.GetAttachments();

            m_aCircuitData.Appearance.ClearAttachments();
            foreach (AvatarAttachment t in attachments)
            {
                InventoryItemBase item = scene.InventoryService.GetItem(new InventoryItemBase(t.ItemID));
                if (item != null)
                {
                    item.ID     = UUID.Random();
                    item.Owner  = m_character.AgentId;
                    item.Folder = UUID.Zero;
                    scene.InventoryService.AddItemAsync(item, null);
                    //Now fix the ItemID
                    m_aCircuitData.Appearance.SetAttachment(t.AttachPoint, item.ID, t.AssetID);
                }
            }

            scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them inworld
            AddAndWaitUntilAgentIsAdded(scene, m_character);

            IScenePresence SP = scene.GetScenePresence(m_character.AgentId);

            if (SP == null)
            {
                return(UUID.Zero); //Failed!
            }
            Bot bot = new Bot();

            bot.Initialize(SP, creatorID);
            SP.MakeRootAgent(startPos, false, true);
            //Move them
            SP.Teleport(startPos);

            foreach (var presence in scene.GetScenePresences())
            {
                presence.SceneViewer.QueuePresenceForUpdate(SP, PrimUpdateFlags.ForcedFullUpdate);
            }
            IAttachmentsModule attModule = SP.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                foreach (AvatarAttachment att in attachments)
                {
                    attModule.RezSingleAttachmentFromInventory(SP.ControllingClient, att.ItemID, att.AssetID, 0, true);
                }
            }

            IAvatarAppearanceModule appearance = SP.RequestModuleInterface <IAvatarAppearanceModule>();

            appearance.InitialHasWearablesBeenSent = true;

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, bot);
            AddTagToBot(m_character.AgentId, "AllBots", bot.AvatarCreatorID);

            MainConsole.Instance.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");
            //Return their UUID
            return(m_character.AgentId);
        }
        public void EventManagerOnAvatarEnteringNewParcel(IScenePresence avatar, ILandObject oldParcel)
        {
            if (avatar.CurrentParcel != null)
            {
                //Tell the clint about it
                avatar.CurrentParcel.SendLandUpdateToClient(avatar.ControllingClient);

                //Gotta kill all avatars outside the parcel
                foreach (
                    IScenePresence sp in
                        avatar.Scene.Entities.GetPresences()
                              .Where(sp => sp.UUID != avatar.UUID)
                              .Where(sp => sp.CurrentParcel != null))
                {
                    if (sp.CurrentParcelUUID == avatar.CurrentParcelUUID) //Send full updates for those in the sim
                    {
                        if (avatar.CurrentParcel.LandData.Private || (oldParcel != null && oldParcel.LandData.Private))
                            //Either one, we gotta send an update
                        {
                            sp.SceneViewer.RemoveAvatarFromView(avatar);
                            avatar.SceneViewer.RemoveAvatarFromView(sp);
                            sp.SceneViewer.QueuePresenceForFullUpdate(avatar, true);
                            avatar.SceneViewer.QueuePresenceForFullUpdate(sp, true);
                        }
                    }
                    else //Kill those outside the parcel
                    {
                        if (sp.CurrentParcel.LandData.Private || avatar.CurrentParcel.LandData.Private)
                        {
                            sp.ControllingClient.SendKillObject(sp.Scene.RegionInfo.RegionHandle,
                                                                new IEntity[1] {avatar});
                            avatar.ControllingClient.SendKillObject(sp.Scene.RegionInfo.RegionHandle,
                                                                    new IEntity[1] {sp});
                            sp.SceneViewer.RemoveAvatarFromView(avatar);
                            avatar.SceneViewer.RemoveAvatarFromView(sp);
                        }
                    }
                }

                if (UseDwell)
                    avatar.CurrentParcel.LandData.Dwell += 1;
                if (avatar.AbsolutePosition.Z < BAN_LINE_SAFETY_HEIGHT)
                {
                    if (avatar.CurrentParcel.IsBannedFromLand(avatar.UUID))
                    {
                        SendYouAreBannedNotice(avatar);
                        Vector3 pos = GetNearestAllowedPosition(avatar);
                        pos.Z -= avatar.PhysicsActor.Size.Z;
                        avatar.Teleport(pos);
                    }
                    else if (avatar.CurrentParcel.IsRestrictedFromLand(avatar.UUID))
                    {
                        SendYouAreRestrictedNotice(avatar);
                        Vector3 pos = GetNearestAllowedPosition(avatar);
                        pos.Z -= avatar.PhysicsActor.Size.Z;
                        avatar.Teleport(pos);
                    }
                }
            }
        }
        public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
            uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportStart(teleportFlags);
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");

            // Reset animations; the viewer does that in teleports.
            if (sp.Animator != null)
                sp.Animator.ResetAnimations();

            try
            {
                string reason = "";
                if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    //First check whether the user is allowed to move at all
                    if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //Now respect things like parcel bans with this
                    if (
                        !sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, teleportFlags, out position,
                                                                      out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    MainConsole.Instance.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.RequestModuleInterface<IScriptControllerModule>()
                      .HandleForceReleaseControls(sp.ControllingClient, sp.UUID);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    // Make sure the user is allowed to leave this region
                    if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }

                    DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message,
                                                 e.StackTrace);
                sp.ControllingClient.SendTeleportFailed("Internal error");
            }
        }
        public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportStart(teleportFlags);
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");

            // Reset animations; the viewer does that in teleports.
            if(sp.Animator != null)
                sp.Animator.ResetAnimations();

            try
            {
                string reason = "";
                if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    //First check whether the user is allowed to move at all
                    if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //Now respect things like parcel bans with this
                    if (!sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, teleportFlags, out position, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    MainConsole.Instance.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    // Make sure the user is allowed to leave this region
                    if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //MainConsole.Instance.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
                    //    finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);

                    // Check that these are not the same coordinates
                    if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
                        finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
                    {
                        // Can't do. Viewer crashes
                        sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again.");
                        return;
                    }

                    //
                    // This is it
                    //
                    DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
                    //
                    //
                    //
                }
            }
            catch (Exception e)
            {
                MainConsole.Instance.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace);
                sp.ControllingClient.SendTeleportFailed("Internal error");
            }
        }
        public UUID CreateAvatar(string firstName, string lastName, IScene scene, AvatarAppearance avatarApp,
                                 UUID creatorID, Vector3 startPos)
        {
            //Add the circuit data so they can login
            AgentCircuitData m_aCircuitData = new AgentCircuitData
            {
                IsChildAgent = false,
                CircuitCode  = (uint)Util.RandomClass.Next()
            };

            //Create the new bot data
            BotClientAPI m_character = new BotClientAPI(scene, m_aCircuitData);

            m_character.Name       = firstName + " " + lastName;
            m_aCircuitData.AgentID = m_character.AgentId;

            //Set up appearance
            var origOwner = avatarApp.Owner;

            avatarApp.Owner = m_character.AgentId;
            List <AvatarAttachment> attachments = avatarApp.GetAttachments();

            avatarApp.ClearAttachments();
            // get original attachments
            foreach (AvatarAttachment t in attachments)
            {
                InventoryItemBase item = scene.InventoryService.GetItem(origOwner, t.ItemID);
                if (item != null)
                {
                    item.ID     = UUID.Random();
                    item.Owner  = m_character.AgentId;
                    item.Folder = UUID.Zero;
                    scene.InventoryService.AddCacheItemAsync(item);
                    //Now fix the ItemID
                    avatarApp.SetAttachment(t.AttachPoint, item.ID, t.AssetID);
                }
            }

            scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them in world
            AddAndWaitUntilAgentIsAdded(scene, m_character);

            IScenePresence SP = scene.GetScenePresence(m_character.AgentId);

            if (SP == null)
            {
                return(UUID.Zero); //Failed!
            }
            // set this as a NPC character
            SP.IsNpcAgent = true;

            IAvatarAppearanceModule appearance = SP.RequestModuleInterface <IAvatarAppearanceModule>();

            appearance.Appearance = avatarApp;
            appearance.InitialHasWearablesBeenSent = true;
            Bot bot = new Bot();

            bot.Initialize(SP, creatorID);
            try {
                SP.MakeRootAgent(startPos, false, true);
            } catch {
                MainConsole.Instance.ErrorFormat("[BotManager]: Error creating bot {0} as root agent!", m_character.AgentId);
            }
            //Move them
            SP.Teleport(startPos);

            foreach (var presence in scene.GetScenePresences())
            {
                presence.SceneViewer.QueuePresenceForUpdate(SP, PrimUpdateFlags.ForcedFullUpdate);
            }
            IAttachmentsModule attModule = SP.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                foreach (AvatarAttachment att in attachments)
                {
                    attModule.RezSingleAttachmentFromInventory(SP.ControllingClient, att.ItemID, att.AssetID, 0, true);
                }
            }

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, bot);
            AddTagToBot(m_character.AgentId, "AllBots", bot.AvatarCreatorID);

            MainConsole.Instance.InfoFormat("[BotManager]: Added bot {0} to region {1}",
                                            m_character.Name, scene.RegionInfo.RegionName);

            //Return their UUID
            return(m_character.AgentId);
        }
        public void EventManagerOnAvatarEnteringNewParcel (IScenePresence avatar, int localLandID, UUID regionID)
        {
            if (m_scene.RegionInfo.RegionID == regionID)
            {
                ILandObject parcelAvatarIsEntering = GetLandObject(localLandID);

                if (parcelAvatarIsEntering != null)
                {
                    //Tell the clint about it
                    parcelAvatarIsEntering.SendLandUpdateToClient(avatar.ControllingClient);
                    
                    if (UseDwell)
                        parcelAvatarIsEntering.LandData.Dwell += 1;
                    if (avatar.AbsolutePosition.Z < ParcelManagementModule.BAN_LINE_SAFETY_HEIGHT)
                    {
                        if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
                        {
                            SendYouAreBannedNotice(avatar);
                            Vector3 pos = GetNearestAllowedPosition(avatar);
                            avatar.Teleport(pos);
                        }
                        else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
                        {
                            SendYouAreRestrictedNotice(avatar);
                            Vector3 pos = GetNearestAllowedPosition(avatar);
                            avatar.Teleport(pos);
                        }
                    }
                }
            }
        }
        public void EventManagerOnAvatarEnteringNewParcel (IScenePresence avatar, int localLandID, UUID regionID)
        {
            if (m_scene.RegionInfo.RegionID == regionID)
            {
                if (avatar.CurrentParcel != null)
                {
                    //Tell the clint about it
                    avatar.CurrentParcel.SendLandUpdateToClient (avatar.ControllingClient);

                    if (avatar.CurrentParcel.LandData.Private)
                    {
                        //Gotta kill all avatars outside the parcel
                        foreach (IScenePresence sp in avatar.Scene.Entities.GetPresences ())
                        {
                            if (sp.UUID == avatar.UUID)
                                continue;
                            if (sp.CurrentParcelUUID == avatar.CurrentParcelUUID)//Send full updates for those in the sim
                                sp.SceneViewer.QueuePresenceForFullUpdate (avatar);
                            else//Kill those outside the parcel
                                sp.ControllingClient.SendKillObject (sp.Scene.RegionInfo.RegionHandle, 
                                    new IEntity[1] { avatar });
                        }
                    }
                    
                    if (UseDwell)
                        avatar.CurrentParcel.LandData.Dwell += 1;
                    if (avatar.AbsolutePosition.Z < ParcelManagementModule.BAN_LINE_SAFETY_HEIGHT)
                    {
                        if (avatar.CurrentParcel.IsBannedFromLand (avatar.UUID))
                        {
                            SendYouAreBannedNotice(avatar);
                            Vector3 pos = GetNearestAllowedPosition(avatar);
                            avatar.Teleport(pos);
                        }
                        else if (avatar.CurrentParcel.IsRestrictedFromLand (avatar.UUID))
                        {
                            SendYouAreRestrictedNotice(avatar);
                            Vector3 pos = GetNearestAllowedPosition(avatar);
                            avatar.Teleport(pos);
                        }
                    }
                }
            }
        }
Beispiel #10
0
            public void KillAvatar(uint killerObjectLocalID, bool TeleportAgent)
            {
                string         deadAvatarMessage;
                IScenePresence killingAvatar        = null;
                string         killingAvatarMessage = "You fragged " + m_SP.Name;

                if (killerObjectLocalID == 0)
                {
                    deadAvatarMessage = "You committed suicide!";
                    if (FireOnDeadEvent)
                    {
                        FireDeadAvatarEvent(m_SP.Name, m_SP, null);
                    }
                }
                else
                {
                    // Try to get the avatar responsible for the killing
                    killingAvatar = m_SP.Scene.GetScenePresence(killerObjectLocalID);
                    if (killingAvatar == null)
                    {
                        // Try to get the object which was responsible for the killing
                        ISceneChildEntity part = m_SP.Scene.GetSceneObjectPart(killerObjectLocalID);
                        if (part == null)
                        {
                            // Cause of death: Unknown
                            deadAvatarMessage = "You died!";
                            if (FireOnDeadEvent)
                            {
                                FireDeadAvatarEvent("", m_SP, null);
                            }
                        }
                        else
                        {
                            // Try to find the avatar wielding the killing object
                            killingAvatar = m_SP.Scene.GetScenePresence(part.OwnerID);
                            if (killingAvatar == null)
                            {
                                UserAccount account = m_SP.Scene.UserAccountService.GetUserAccount(m_SP.Scene.RegionInfo.ScopeID, part.OwnerID);
                                deadAvatarMessage = String.Format("You impaled yourself on {0} owned by {1}!", part.Name, account.Name);
                                if (FireOnDeadEvent)
                                {
                                    FireDeadAvatarEvent(account.Name, m_SP, part.ParentEntity);
                                }
                            }
                            else
                            {
                                killingAvatarMessage = String.Format("You fragged {0}!", m_SP.Name);
                                if (FireOnDeadEvent)
                                {
                                    FireDeadAvatarEvent(killingAvatar.Name, m_SP, part.ParentEntity);
                                }
                                deadAvatarMessage = String.Format("You got killed by {0}!", killingAvatar.Name);
                            }
                        }
                    }
                    else
                    {
                        ISceneChildEntity part = m_SP.Scene.GetSceneObjectPart(killerObjectLocalID);
                        if (part == null)
                        {
                            // Cause of death: Unknown
                            killingAvatarMessage = String.Format("You fragged {0}!", m_SP.Name);
                            deadAvatarMessage    = String.Format("You got killed by {0}!", killingAvatar.Name);
                            if (FireOnDeadEvent)
                            {
                                FireDeadAvatarEvent(killingAvatar.Name, m_SP, null);
                            }
                        }
                        else
                        {
                            killingAvatarMessage = String.Format("You fragged {0}!", m_SP.Name);
                            deadAvatarMessage    = String.Format("You got killed by {0}!", killingAvatar.Name);
                            if (FireOnDeadEvent)
                            {
                                FireDeadAvatarEvent(killingAvatar.Name, m_SP, part.ParentEntity);
                            }
                        }
                    }
                }
                try
                {
                    m_SP.ControllingClient.SendAgentAlertMessage(deadAvatarMessage, true);
                    if (killingAvatar != null)
                    {
                        killingAvatar.ControllingClient.SendAlertMessage(killingAvatarMessage);
                    }
                }
                catch (InvalidOperationException)
                { }

                Health = MaximumHealth;
                if (TeleportAgent)
                {
                    if (m_shouldRespawn)
                    {
                        if (m_SecondsBeforeRespawn != 0)
                        {
                            m_SP.AllowMovement = false;
                            this.HasLeftCombat = true;
                            System.Timers.Timer t = new System.Timers.Timer();
                            //Use this to reenable movement and combat
                            t.Interval = m_SecondsBeforeRespawn * 1000;
                            t.Enabled  = true;
                            t.Elapsed += new System.Timers.ElapsedEventHandler(t_Elapsed);
                        }
                        m_SP.Teleport(m_RespawnPosition);
                    }
                    else
                    {
                        IEntityTransferModule transferModule = m_SP.Scene.RequestModuleInterface <IEntityTransferModule>();
                        if (transferModule != null)
                        {
                            transferModule.TeleportHome(m_SP.UUID, m_SP.ControllingClient);
                        }
                    }
                }
            }
Beispiel #11
0
        public virtual void Teleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            string reason = "";

            sp.ControllingClient.SendTeleportStart(teleportFlags);
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "requesting");

            // Reset animations; the viewer does that in teleports.
            if (sp.Animator != null)
            {
                sp.Animator.ResetAnimations();
            }

            try
            {
                if (finalDestination.RegionHandle == sp.Scene.RegionInfo.RegionHandle)
                {
                    //First check whether the user is allowed to move at all
                    if (!sp.Scene.Permissions.AllowedOutgoingLocalTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //Now respect things like parcel bans with this
                    if (!sp.Scene.Permissions.AllowedIncomingTeleport(sp.UUID, position, out position, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    m_log.DebugFormat(
                        "[ENTITY TRANSFER MODULE]: RequestTeleportToLocation {0} within {1}",
                        position, sp.Scene.RegionInfo.RegionName);

                    sp.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
                    sp.Teleport(position);
                }
                else // Another region possibly in another simulator
                {
                    // Make sure the user is allowed to leave this region
                    if (!sp.Scene.Permissions.AllowedOutgoingRemoteTeleport(sp.UUID, out reason))
                    {
                        sp.ControllingClient.SendTeleportFailed(reason);
                        return;
                    }
                    //m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Final destination is x={0} y={1} uuid={2}",
                    //    finalDestination.RegionLocX / Constants.RegionSize, finalDestination.RegionLocY / Constants.RegionSize, finalDestination.RegionID);

                    // Check that these are not the same coordinates
                    if (finalDestination.RegionLocX == sp.Scene.RegionInfo.RegionLocX &&
                        finalDestination.RegionLocY == sp.Scene.RegionInfo.RegionLocY)
                    {
                        // Can't do. Viewer crashes
                        sp.ControllingClient.SendTeleportFailed("Space warp! You would crash. Move to a different region and try again.");
                        return;
                    }

                    //
                    // This is it
                    //
                    DoTeleport(sp, finalDestination, position, lookAt, teleportFlags);
                    //
                    //
                    //
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Exception on teleport: {0}\n{1}", e.Message, e.StackTrace);
                sp.ControllingClient.SendTeleportFailed("Internal error");
            }
        }