Ejemplo n.º 1
0
        public static void WriteAction(Client victim, Attacked attack, bool fatal)
        {
            if (LogDate != DateTime.Now.Date)
            {
                OpenLog();
            }

            double distance = victim.Session.Position.DistanceTo(attack.By.Session.Position);

            if (fatal)
            {
                actionLog.WriteLine(Timestamp + "\t" +
                                    victim.MinecraftUsername + "\tkilled by\t" + attack.By.MinecraftUsername + "\t" + attack.Item + "\t" + distance.ToString("0.00"));
            }
            else
            {
                actionLog.WriteLine(Timestamp + "\t" +
                                    victim.MinecraftUsername + "\tattacked by\t" + attack.By.MinecraftUsername + "\t" + attack.Item + "\t" + distance.ToString("0.00"));
            }
            actionLog.Flush();
        }
Ejemplo n.º 2
0
 public static void WriteAction(Client victim, Attacked attack, bool fatal)
 {
     if (LogDate != DateTime.Now.Date)
         OpenLog();
     
     double distance = victim.Session.Position.DistanceTo(attack.By.Session.Position);
     
     if (fatal)
         actionLog.WriteLine(Timestamp + "\t" +
             victim.MinecraftUsername + "\tkilled by\t" + attack.By.MinecraftUsername + "\t" + attack.Item + "\t" + distance.ToString("0.00"));
     else
         actionLog.WriteLine(Timestamp + "\t" +
             victim.MinecraftUsername + "\tattacked by\t" + attack.By.MinecraftUsername + "\t" + attack.Item + "\t" + distance.ToString("0.00"));
     actionLog.Flush();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// return true to block packet
        /// </summary>
        bool UseEntityFromClient(UseEntity ue)
        {
            //Attack others
            if (ue.Type == UseEntity.Types.Attack)
            {
                //Admin instant kill using bedrock
                if (Player.Admin() &&
                    this.ActiveItem != null &&
                    this.ActiveItem.ItemID == BlockID.Bedrock)
                {
                    
                    VanillaSession dust = World.Main.GetPlayer(ue.Target);
                    if (dust == null)
                    {
                        Player.TellSystem(Chat.Purple, "Failed to find player");
                        return true;
                    }
                    dust.SendToBackend(new ChatMessageClient("/kill"));
                    Log.WritePlayer(this, "Admin kill: " + dust.Player.MinecraftUsername);
                    return true;
                }
                
                if (Player.Settings.Cloaked != null)
                    return false;

                Debug.WriteLine("Attacked: " + ue.Target);
                VanillaSession target = World.Main.GetPlayer(ue.Target);
                
                if (target == null && Player.Settings.Cloaked == null)
                {
                    Entity e = World.Main.GetEntity(ue.Target);
                    var m = e as Mob;
                    var v = e as Vehicle;
                    WorldRegion cr = CurrentRegion;
                    //prevent killing mobs and villagers inside region
                    if (cr != null && cr.Type == "protected" && (cr.IsResident(Player) == false))
                    {
                        if (m != null && m.Type >= MobType.Pig)
                        {
                            Player.TellSystem(Chat.Pink, "No killing inside this region");
                            return true;
                        }
                        if (v != null && v.Type == Vehicles.Frame)
                        {
                            //Protect frames
                            Debug.WriteLine("Frame protected");
                            return true;
                        }
                    }
                    if (m != null && m.Owner != "")
                    {
                        //this could prevent killing of tamed animals   
                    }
                }
                if (target != null && target.Player.Settings.Cloaked == null)
                {
                    
                    if (this.ActiveItem != null)
                    {
                        switch (this.ActiveItem.ItemID)
                        {
                            case BlockID.Rose:
                            case BlockID.Dandelion:
                                PlayerInteraction.Prod(this.Player, target.Player);
                                return true;
                        }
                    }
                    
                    //Anywhere but war
                    WorldRegion r = CurrentRegion;
                    if (r != null && r.Type == "war")
                    {
                        //War Zone
                        //r.Say (Chat.Yellow + Name + Chat.Gold + " attacked " + Chat.Yellow + target.Name + Chat.Gold + " using " + newAttack.Item);
                        SendToBackend(ue);
                        return true;
                    }
                    
                    //Anywhere but war
                    if (Player.PvP == false)
                    {
                        Player.TellSystem(Chat.Purple, "PvP active");
                        Player.PvP = true;
                    }
                    
                    Attacked newAttack = new Attacked(this.Player);
                    
                    if (target.Attacker == null || target.Attacker.Timestamp.AddSeconds(10) < DateTime.Now)
                    {
                        //Regular zone
                        if (target.Player.PvP == false && ((r == null) || (r.IsResident(Player) == false)))
                        {
                            if (target.lastPvpMessage < DateTime.Now)
                            {
                                target.lastPvpMessage = DateTime.Now.AddSeconds(5);
                                PlayerInteraction.Prod(target.Player);
                                target.Player.TellSystem(Chat.Pink, Player.Name + " can't hurt you");
                            }
                            Player.TellSystem(Chat.Pink, "You challenge " + target.Player.Name + " to a fight to the " + Chat.Red + "death");
                            return true;
                        }
                        
                        string msg = Player.Name + " attacked " + target.Player.Name + " using " + newAttack.Item;
                        Chatting.Parser.SayFirehose(Chat.Gray, msg);
                        target.TellSystem(Chat.Gray, msg);
                        this.TellSystem(Chat.Gray, msg);
                        Log.WriteAction(target.Player, newAttack, false);
                    }
                    target.Attacker = newAttack;
                }
                return false;
            }
            else
            {
                //Right click
                Mob m = World.Main.GetEntity(ue.Target) as Mob;
                if (m == null)
                    return false;
                if (m.Owner == "")
                    return false;

                if (m.Type == MobType.Ocelot)
                    this.TellSystem(Chat.Pink, "Meow " + m.Owner);
                else if (m.Type == MobType.Wolf)
                    this.TellSystem(Chat.Pink, "Woof " + m.Owner);
                else
                    this.TellSystem(Chat.Pink, "Owner: " + m.Owner);

                return false;
            }
        }