Example #1
0
        bool cannotHit(Avatar who)
        {
            if ( who.X < 1 && who.X > -1 )
                if ( who.Z < 1 && who.Z > -1 )
                    return true;

            var death = who.GetSettingDateTime(keyDeath);
            if ( death.SecondsToNow() < 5 )
                return true;

            return false;
        }
Example #2
0
        void onEnter(Instance sender, Avatar who)
        {
            // Do not teleport users home within 10 seconds of bot's startup
            if ( VPServices.App.LastConnect.SecondsToNow() < 10 )
                return;

            var lastExit = who.GetSettingDateTime(settingLastExit);

            // Ignore bouncing/disconnected users
            if ( lastExit.SecondsToNow() < 10 )
                return;

            // Do not teleport home if bouncing
            if ( who.GetSetting(settingBounce) != null )
                who.DeleteSetting(settingBounce);
            else
                cmdGoHome(VPServices.App, who, true);
        }
Example #3
0
        bool cmdTogglePVP(VPServices app, Avatar who, string data)
        {
            var  lastSwitch = who.GetSettingDateTime(keyLastSwitch);
            bool toggle     = false;

            // Reject if too soon
            if ( lastSwitch.SecondsToNow() < 60 )
            {
                var timeLeft = 60 - lastSwitch.SecondsToNow();
                app.Warn(who.Session, msgTooSoon, timeLeft);
                return true;
            }

            if ( data != "" )
            {
                // Try to parse user given boolean; silently ignore on failure
                if ( !VPServices.TryParseBool(data, out toggle) )
                    return false;
            }
            else
                toggle = !who.GetSettingBool(keyMode);

            // Set new boolean, timeout and if new, health
            who.SetSetting(keyMode, toggle);
            who.SetSetting(keyLastSwitch, DateTime.Now);
            initialHealth(who);

            var verb = toggle ? "enabled" : "disabled";
            app.NotifyAll(msgToggle, verb, who.Name);
            return true;
        }