Exemplo n.º 1
0
        // PvP Command execution
        private static void VSExecute(VSPlayer user, VSCommand command, TSPlayer target)
        {
            // Sets command user and target
            command.User = user;
            command.Target = target;

            // Self-use Check & PvP Check
            if (command.UseSelf == 2 && user.TSPlayer == target)
            {
                user.TSPlayer.SendErrorMessage("[PvP] Error: You cannot use this command on yourself!");
                return;
            }
            if (!PVPCheck(target) && !command.BypassPvp)
            {
                user.TSPlayer.SendErrorMessage("[PvP] Error: Target is not hostile!");
                return;
            }

            // Cooldown Check
            if (VSConfig.config.Cooldowns && !user.TSPlayer.Group.HasPermission("vs.ignore.cooldown"))
            {
                if (command.Counter > 0)
                {
                    user.TSPlayer.SendErrorMessage(string.Format("[PvP] Error: You must wait {0} seconds before using {1} again!",
                        command.Counter, command.Name));
                    return;
                }
                else
                {
                    command.Counter = command.Cooldown;
                }
            }

            // Damage Check
            if (command.Damage != 0)
            {
                VSPlayers[target.UserID].DamagePlayer(command.Damage, command, user);
            }
            if (command.DamageToSelf != 0)
            {
                user.DamagePlayer(command.DamageToSelf, command, user);
            }

            // Effect Check
            if (command.Effect != null)
            {
                foreach (Effect eff in command.Effect)
                {
                    Effect.Event(user, target, eff.Type, eff.Parameter, eff.Parameter2, eff.Who, eff.SetState);
                }
            }

            // Timer Check
            if (command.Timer.Interval != 1)
            {
                command.Timer.Start();
            }

            // Messages Check
            if (command.MsgAll != null)
            {
                Message msg = new Message(command.MsgAll.InitMsg, command.MsgAll.UsePlr1 ? command.User.TSPlayer : null,
                    command.MsgAll.MidMsg, command.MsgAll.UsePlr2 ? command.Target : null, command.MsgAll.EndMsg, command.MsgAll.Color);
                TSPlayer.All.SendMessage(msg.Text, msg.Color);
            }
            if (command.MsgSelf != null)
            {
                Message msg = new Message(command.MsgSelf.InitMsg, command.MsgSelf.UsePlr1 ? command.User.TSPlayer : null,
                    command.MsgSelf.MidMsg, command.MsgSelf.UsePlr2 ? command.Target : null, command.MsgSelf.EndMsg, command.MsgSelf.Color);
                user.TSPlayer.SendMessage(msg.Text, msg.Color);
            }
            if (command.MsgPlayer != null)
            {
                Message msg = new Message(command.MsgPlayer.InitMsg, command.MsgPlayer.UsePlr1 ? command.User.TSPlayer : null,
                    command.MsgPlayer.MidMsg, command.MsgPlayer.UsePlr2 ? command.Target : null, command.MsgPlayer.EndMsg, command.MsgPlayer.Color);
                target.SendMessage(msg.Text, msg.Color);
            }
            return;
        }
Exemplo n.º 2
0
 private static VSCommand VSCommandByAlias(VSPlayer player, string alias)
 {
     foreach (VSCommand cmd in player.VSCommands)
     {
         if (alias == cmd.Alias)
         {
             return cmd;
         }
     }
     return null;
 }
Exemplo n.º 3
0
 private static void SaveToDb(VSPlayer ply)
 {
     foreach (VSCommand cmd in ply.VSCommands)
     {
         VSDatabase.SaveCooldown(ply.UserID, cmd.Alias, cmd.Counter);
     }
 }
Exemplo n.º 4
0
 // Event for the effect. Parameter function vary based on the type. Who is 0 (User) and 1 (target)
 public static void Event(VSPlayer User, TSPlayer Target, EffectTypes type, int Parameter, int Parameter2 = 0,
     int Who = 1, States setstate = States.NONE)
 {
     if (type.Equals(EffectTypes.BUFF))
     {
         try
         {
             if (Who == 0)
                 User.TSPlayer.SetBuff(Parameter, Parameter2 * 60, false);
             else
                 Target.SetBuff(Parameter, Parameter2 * 60, false);
         }
         catch (Exception)
         {
             Log.ConsoleError("[VSSystem] A command has returned an error at Effect parameter: Invalid buff ID");
         }
     }
     else if (type.Equals(EffectTypes.HEALSELF))
     {
         if (Who == 0)
             User.TSPlayer.Heal(Parameter);
         else
             Target.Heal(Parameter);
     }
     else if (type.Equals(EffectTypes.TICKLE))
     {
         if (Who == 0)
         {
             if (VSSystem.ItemCheck(TShock.Utils.GetItemByName("Hand Warmer")[0].netID, User.TSPlayer))
             {
                 User.TSPlayer.DamagePlayer(10000);
                 User.TSPlayer.TPlayer.KillMe(10000, 0, true, " was tickled to death for having Hand Warmer.");
             }
             else
                 User.TSPlayer.SetBuff(47, Parameter * 60, false);
         }
         else
         {
             if (VSSystem.ItemCheck(TShock.Utils.GetItemByName("Hand Warmer")[0].netID, Target))
             {
                 Target.DamagePlayer(10000);
                 Target.TPlayer.KillMe(10000, 0, true, " was tickled to death for having Hand Warmer.");
             }
             else
                 Target.SetBuff(47, Parameter * 60, false);
         }
     }
     else if (type.Equals(EffectTypes.STATE) && setstate != States.NONE)
     {
         if (Who == 0)
             User.SetState(setstate, Parameter);
         else
             VSSystem.VSPlayers[Target.UserID].SetState(setstate, Parameter);
     }
 }
Exemplo n.º 5
0
 public void DamagePlayer(double damage, VSCommand cmd, VSPlayer user)
 {
     if (damage < 0)
     {
         TSPlayer.Heal(VSSystem.Equalize(damage));
     }
     else
     {
         if (cmd.Offensive)
         {
             if (State.ContainsKey(States.BARRIER))
             {
                 Message msg = new Message("Barrier has been disposed!", false, "", false, "", Color.Indigo);
                 RemoveState(States.BARRIER);
                 TSPlayer.SendInfoMessage(msg.Text, msg.Color);
                 return;
             }
             if (State.ContainsKey(States.SHIELD))
             {
                 damage *= 0.8;
             }
             if (State.ContainsKey(States.LOCUS))
             {
                 damage *= 0.5;
             }
         }
         if (user.State.ContainsKey(States.BOOST))
         {
             damage *= 1.2;
         }
         if (user.State.ContainsKey(States.LOCUS))
         {
             damage *= 1.5;
         }
         TSPlayer.DamagePlayer(VSSystem.Equalize(damage, TSPlayer));
     }
 }
Exemplo n.º 6
0
        public static VSPlayer PullPlayer(int UserID)
        {
            String query = "SELECT Name FROM VSPlayers WHERE UserID=@0;";
            VSPlayer player;

            try
            {
                using (var reader = db.QueryReader(query, UserID))
                {
                    while (reader.Read())
                    {
                        player = new VSPlayer(reader.Get<string>("Name"));
                        return player;
                    }
                }
            }
            catch (Exception)
            {
                return null;
            }
            return null;
        }