Exemplo n.º 1
0
 /// <summary>
 /// Creates an Avatar from a native instance's attributes
 /// </summary>
 internal Avatar(IntPtr pointer)
 {
     Name     = Functions.vp_string(pointer, StringAttributes.AvatarName);
     Id       = Functions.vp_int(pointer, IntAttributes.UserId);
     Session  = Functions.vp_int(pointer, IntAttributes.AvatarSession);
     Type     = Functions.vp_int(pointer, IntAttributes.AvatarType);
     Position = AvatarPosition.FromAvatar(pointer);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Sends a request for a target session to teleport to a specified world and
 /// <see cref="AvatarPosition"/>. Thread-safe.
 /// </summary>
 public void Teleport(int session, string world, AvatarPosition pos)
 {
     lock (instance.Mutex)
         Functions.Call(() =>
                        Functions.vp_teleport_avatar(
                            instance.Pointer,
                            session,
                            world,
                            pos.X, pos.Y, pos.Z,
                            pos.Yaw, pos.Pitch)
                        );
 }
Exemplo n.º 3
0
        internal void OnAvatarTeleported(IntPtr sender)
        {
            if (Teleported == null)
            {
                return;
            }

            var pos     = AvatarPosition.FromTeleport(sender);
            var session = Functions.vp_int(sender, IntAttributes.AvatarSession);
            var world   = Functions.vp_string(sender, StringAttributes.TeleportWorld);

            Teleported(instance, session, pos, world);
        }
Exemplo n.º 4
0
        void cmdGoHome(VPServices app, Avatar who, bool entering)
        {
            AvatarPosition target;
            var query  = from   h in connection.Table<sqlHome>()
                         where  h.UserID == who.Id
                         select h;
            var home   = query.FirstOrDefault();

            if (home == null && entering)
                return;

            if (home != null)
                target = new AvatarPosition(home.X, home.Y, home.Z, home.Pitch, home.Yaw);
            else
                target = AvatarPosition.GroundZero;

            app.Bot.Avatars.Teleport(who.Session, "", target);
            Log.Debug(Name, "Teleported {0} home at {1:f3}, {2:f3}, {3:f3}", who.Name, target.X, target.Y, target.Z);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Updates the bot's own position and rotation using a given
 /// <see cref="AvatarPosition"/>. Chainable and thread-safe.
 /// </summary>
 public Instance GoTo(AvatarPosition position)
 {
     return(GoTo(position.X, position.Y, position.Z, position.Yaw, position.Pitch));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Teleports a target session to a specified world and AvatarPosition
        /// </summary>
        public void Teleport(int session, string world, AvatarPosition pos)
        {
            int rc;
            lock (instance)
                rc = Functions.vp_teleport_avatar(
                    instance.pointer,
                    session,
                    world,
                    pos.X, pos.Y, pos.Z,
                    pos.Yaw, pos.Pitch);

            if (rc != 0) throw new VPException((ReasonCode)rc);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Teleports a target session to a specified AvatarPosition in the same world
 /// </summary>
 public void Teleport(int session, AvatarPosition pos)
 {
     Teleport(session, "", pos);
 }
Exemplo n.º 8
0
        void createHoverText(AvatarPosition pos, int damage, bool critical)
        {
            var offsetX     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var offsetZ     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var description = string.Format("{0}{1}", 0 - damage, critical ? " !!!" : "");
            var color       = damage == 0 ? "blue" : "red";
            var hover       = new VPObject
            {
                Model = "p:fac100x50,s.rwx",
                Rotation = Quaternion.ZeroEuler,
                Action = string.Format("create sign color={0} bcolor=ffff0000 hmargin=20, ambient 1, move 0 2 time=5 wait=10, solid no", color),
                Description = description,
                Position = new Vector3(pos.X + offsetX, pos.Y + .2f, pos.Z + offsetZ)
            };

            app.Bot.Property.AddObject(hover);
            spawned.Add(hover);
        }
Exemplo n.º 9
0
        void createBloodSplat(AvatarPosition pos)
        {
            var offsetX     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var offsetY     = ( (float) VPServices.Rand.Next(0, 100) ) / 5000;
            var offsetZ     = ( (float) VPServices.Rand.Next(-100, 100) ) / 2000;
            var size        = VPServices.Rand.Next(80, 200);

            var hover       = new VPObject
            {
                Model = "p:flat" + size + ".rwx",
                Rotation = Quaternion.ZeroEuler,
                Action = "create texture bloodsplat1.png, normalmap nmap-puddle1, specularmap smap-puddle1, specular .6 30, solid no",
                Position = new Vector3(pos.X + offsetX, pos.Y + offsetY, pos.Z + offsetZ)
            };

            app.Bot.Property.AddObject(hover);
            spawned.Add(hover);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Sends a request for a target session to teleport to a specified
 /// <see cref="AvatarPosition"/> in the same world. Thread-safe.
 /// </summary>
 public void Teleport(int session, AvatarPosition pos)
 {
     Teleport(session, "", pos);
 }
Exemplo n.º 11
0
        bool cmdGround(VPServices app, Avatar who, string data)
        {
            var target = new AvatarPosition
            {
                X     = who.X,
                Y     = 0.1f,
                Z     = who.Z,
                Pitch = who.Pitch,
                Yaw   = who.Yaw
            };

            app.Bot.Avatars.Teleport(who.Session, target);
            return true;
        }
Exemplo n.º 12
0
 /// <summary>
 /// Updates the bot's own position and rotation using an AvatarPosition
 /// </summary>
 public void GoTo(AvatarPosition position)
 {
     GoTo(position.X, position.Y, position.Z, position.Yaw, position.Pitch);
 }