示例#1
0
        bool onResponse(VPServices app, Avatar targetAv, bool yes)
        {
            var sourceReq = isRequested(targetAv.Name);

            // Reject non-requested
            if (sourceReq.Equals(JoinInvite.Nobody))
            {
                app.Warn(targetAv.Session, msgNoRequests);
                return(true);
            }

            requests.Remove(sourceReq);
            // Rejected requests
            if (!yes)
            {
                app.Notify(sourceReq.By, msgRequestRejected);
                return(true);
            }

            var target = app.GetUser(targetAv.Session);
            var source = app.GetUser(sourceReq.By);

            // Reject phantom users
            if (target == null)
            {
                return(true);
            }

            // Reject if source has gone away
            if (source == null)
            {
                app.Warn(targetAv.Session, msgNotPresent);
                return(Log.Info(Name, "Rejecting response by {0} as they have left", source.Name));
            }

            var targetPos     = sourceReq.Invite ? source.Position : target.Position;
            var targetSession = sourceReq.Invite ? target.Session : source.Session;
            var targetMsg     = sourceReq.Invite ? msgInvited : msgJoined;

            app.Notify(target.Session, targetMsg, source.Name);
            app.Bot.Avatars.Teleport(targetSession, "", new Vector3(targetPos.X, targetPos.Y, targetPos.Z), 0, 0);
            return(true);
        }
示例#2
0
        void awardPoint(string who)
        {
            var user   = app.GetUser(who);
            var points = user.GetSettingInt(keyTriviaPoints);

            if (user.IsBot)
            {
                Log.Fine(tag, "Not awarding point to {0} as they are a bot", who);
                return;
            }

            points++;
            user.SetSetting(keyTriviaPoints, points);
            Log.Fine(tag, "{0} is now up to {1} points", who, points);

            if (points % 10 == 0)
            {
                app.NotifyAll("{0} is climbing the scoreboard with {1} points!", who, points);
            }
        }
        bool onResponse(VPServices app, Avatar targetAv, bool yes)
        {
            var sourceReq = isRequested(targetAv.Name);

            // Reject non-requested
            if ( sourceReq.Equals(JoinInvite.Nobody) )
            {
                app.Warn(targetAv.Session, msgNoRequests);
                return true;
            }

            requests.Remove(sourceReq);
            // Rejected requests
            if ( !yes )
            {
                app.Notify(sourceReq.By, msgRequestRejected);
                return true;
            }

            var target = app.GetUser(targetAv.Session);
            var source = app.GetUser(sourceReq.By);

            // Reject phantom users
            if ( target == null )
                return true;

            // Reject if source has gone away
            if ( source == null )
            {
                app.Warn(targetAv.Session, msgNotPresent);
                return Log.Info(Name, "Rejecting response by {0} as they have left", source.Name);
            }

            var targetPos     = sourceReq.Invite ? source.Position : target.Position;
            var targetSession = sourceReq.Invite ? target.Session : source.Session;
            var targetMsg     = sourceReq.Invite ? msgInvited : msgJoined;
            app.Notify(target.Session, targetMsg, source.Name);
            app.Bot.Avatars.Teleport(targetSession, "", new Vector3(targetPos.X, targetPos.Y, targetPos.Z), 0, 0);
            return true;
        }
示例#4
0
        void onClick(Instance bot, AvatarClick click)
        {
            if (click.TargetSession == 0)
            {
                return;
            }

            var source = app.GetUser(click.SourceSession);
            var target = app.GetUser(click.TargetSession);

            // Needed as there is no intermediate click event
            if (source == null)
            {
                return;
            }

            // Null session suggests bot
            if (target == null)
            {
                hitBot(source);
                return;
            }

            if (!source.GetSettingBool(keyMode, false) || !target.GetSettingBool(keyMode, false))
            {
                return;
            }

            var diffX = Math.Abs(source.X - target.X);
            var diffY = Math.Abs(source.Y - target.Y);
            var diffZ = Math.Abs(source.Z - target.Z);

            if (diffX > .5 || diffY > .4 || diffZ > .5)
            {
                return;
            }

            if (cannotHit(source) || cannotHit(target))
            {
                createHoverText(target.Position, 0, false);
                return;
            }

            var targetHealth = target.GetSettingInt(keyHealth, 100);
            var critical     = VPServices.Rand.Next(100) <= 10;
            var damage       = VPServices.Rand.Next(5, 25) * (critical ? 3 : 1);

            createHoverText(target.Position, damage, critical);
            createBloodSplat(target.Position);

            if (targetHealth - damage <= 0)
            {
                app.AlertAll(msgKill, target.Name, source.Name);

                target.SetSetting(keyDeath, DateTime.Now);
                target.SetSetting(keyHealth, 100);
                source.SetSetting(keyHealth, source.GetSettingInt(keyHealth) + 5);
                bot.Avatars.Teleport(click.TargetSession, AvatarPosition.GroundZero);
            }
            else
            {
                target.SetSetting(keyHealth, targetHealth - damage);
            }
        }