Esempio n. 1
0
 private void OnEntityHealthChange(EntityDamageEvent damageEvent)
 {
     if (damageEvent == null)
     {
         return;
     }
     if (damageEvent.Damage == null)
     {
         return;
     }
     if (damageEvent.Entity == null)
     {
         return;
     }
     if (!damageEvent.Entity.IsPlayer)
     {
         return;
     }
     if (damageEvent.Damage.Amount < 0)
     {
         return;
     }
     if (damageEvent.Damage.DamageTypes == CodeHatch.Damaging.DamageType.Plague && PlagueDamageOff)
     {
         damageEvent.Cancel();
         damageEvent.Damage.Amount = 0f;
     }
 }
Esempio n. 2
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            string damageSource = e.Damage.Damager.name.ToString();

            if (!warOn)
            {
                if (e.Damage.DamageSource.Owner is Player && !(e.Entity is Player))
                {
                    Player player = e.Damage.DamageSource.Owner;
                    if (adminSiegeException)
                    {
                        if (player.HasPermission("WarTime.Exception"))
                        {
                            return;
                        }
                    }
                    if (damageSource.Contains("Trebuchet") || damageSource.Contains("Ballista"))
                    {
                        e.Cancel(GetMessage("PunishReason"));
                        e.Damage.Amount = 0f;
                        PrintToChat(GetMessage("ChatPrefix") + GetMessage("SiegeUsed"));
                        if (punish == "kick")
                        {
                            Server.Kick(player, GetMessage("PunishReason"));
                        }
                        if (punish == "ban")
                        {
                            Server.Ban(player, banTime, GetMessage("PunishReason"));
                        }
                    }
                }
                return;
            }
        }
Esempio n. 3
0
 void OnEntityHealthChange(EntityDamageEvent damageEvent)
 {
     if (damageEvent.Damage.Amount > 0 && damageEvent.Entity.IsPlayer && damageEvent.Damage.DamageSource.IsPlayer && damageEvent.Entity != damageEvent.Damage.DamageSource && pdmg == false)
     {
         damageEvent.Cancel();
         damageEvent.Damage.Amount = 0f;
         SendReply(damageEvent.Damage.DamageSource.Owner, "[FF0000]Player-Damage is currently DISABLED.[FFFFFF]");
     }
 }
 private void OnEntityHealthChange(EntityDamageEvent damageEvent)
 {
     if (damageEvent.Damage.Amount < 0)
     {
         return;
     }
     if (!damageEvent.Entity.name.Contains("Crest"))
     {
         return;
     }
     damageEvent.Cancel("No damage to crest");
     damageEvent.Damage.Amount = 0f;
     PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]You can't damage another players crest.  If this crest needs removed due to a rule violation please request assistance from an admin.#ffffff");
 }
Esempio n. 5
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (damageEvent.Damage.Amount > 0)
            {
                bool sleepingplayer = damageEvent.Entity.name.ToString().Contains("Player Sleeper");

                if (sleepingplayer)
                {
                    damageEvent.Cancel("No damage to sleeping player");
                    damageEvent.Damage.Amount = 0f;
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]You can't attack a sleeping player.");
                }
            }
        }
Esempio n. 6
0
 private void OnEntityHealthChange(EntityDamageEvent damageEvent)
 {
     if (damageEvent.Entity.IsPlayer)
     {
         foreach (Vector2 mark in marks)
         {
             float distance = Math.Abs(Vector2.Distance(mark, new Vector2(damageEvent.Entity.Position.x, damageEvent.Entity.Position.z)));
             if (distance <= maxDistance)
             {
                 damageEvent.Cancel("No damage area");
                 damageEvent.Damage.Amount = 0f;
                 PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]You can't attack a person in this area.");
             }
         }
     }
 }
Esempio n. 7
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (!Active)
            {
                return;
            }
            if (damageEvent == null)
            {
                return;
            }
            if (damageEvent.Damage == null)
            {
                return;
            }
            if (damageEvent.Damage.Amount <= 0)
            {
                return;
            }
            if (damageEvent.Damage.DamageSource == null)
            {
                return;
            }
            if (damageEvent.Entity == null)
            {
                return;
            }
            if (damageEvent.Damage.DamageSource == damageEvent.Entity)
            {
                return;
            }
            if (!damageEvent.Damage.DamageSource.IsPlayer)
            {
                return;
            }
            if (!damageEvent.Entity.IsPlayer)
            {
                return;
            }

            if ((_NoFriendlyFire.Contains(damageEvent.Damage.DamageSource.Owner.Id) || _NoFriendlyFire.Contains(damageEvent.Entity.Owner.Id)) &&
                damageEvent.Entity.Owner.GetGuild() == damageEvent.Damage.DamageSource.Owner.GetGuild())
            {
                damageEvent.Cancel("No Friendly Fire");
                damageEvent.Damage.Amount = 0f;
                return;
            }
        }
Esempio n. 8
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            GameClock.TimeBlock TimeBlock = GameClock.Instance.CurrentTimeBlock;

            if (
                damageEvent.Damage.Amount > 0 && // taking damage
                damageEvent.Entity.IsPlayer && // entity taking damage is player
                damageEvent.Damage.DamageSource.IsPlayer && // entity delivering damage is a player
                damageEvent.Entity != damageEvent.Damage.DamageSource && // entity taking damage is not taking damage from self
                !IsNight()    // Not night time
                )
            {
                damageEvent.Cancel("Can Only Kill At Night");
                damageEvent.Damage.Amount = 0f;
                PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]You can only attack other players at night.[FFFFFF]");
            }
        }
Esempio n. 9
0
 private void OnEntityHealthChange(EntityDamageEvent damageEvent)
 {
     foreach (var tradeMaster in _NoFriendlyFire)
     {
         if (tradeMaster.ToLower() == damageEvent.Entity.Owner.DisplayName.ToLower())
         {
             if (
                 damageEvent.Damage.Amount > 0 && // taking damage
                 damageEvent.Entity.IsPlayer && // entity taking damage is player
                 damageEvent.Damage.DamageSource.IsPlayer && // entity delivering damage is a player
                 damageEvent.Entity != damageEvent.Damage.DamageSource && // entity taking damage is not taking damage from self
                 damageEvent.Entity.Owner.GetGuild().DisplayName == damageEvent.Damage.DamageSource.Owner.GetGuild().DisplayName    // both entities are in the same guild
                 )
             {
                 damageEvent.Cancel("No Friendly Fire");
                 damageEvent.Damage.Amount = 0f;
             }
         }
     }
 }
Esempio n. 10
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            try
            {
                Player attacker = e.Damage.DamageSource.Owner;
                Player victim   = e.Entity.Owner;
                if (attacker == null || victim == null || attacker == victim)
                {
                    return;
                }

                PlayerLevel attackerLevel = getPlayerFromLevelData(attacker);
                PlayerLevel victimLevel   = getPlayerFromLevelData(victim);

                if (e.Entity.name.Contains("Crest") && attackerLevel.currentLevel < 6)
                {
                    sendError(attacker, "Pas de dégats au crest avant le niveau 5");
                    e.Damage.Amount = 0f;
                    return;
                }
                bool isVictimPlayer = e.Entity.IsPlayer;

                if (attacker == null || victim == null || attacker == victim || !isVictimPlayer)
                {
                    return;
                }
                if (attackerLevel.currentLevel < 6 || victimLevel.currentLevel < 6)
                {
                    //TODO translate
                    sendError(attacker, "Pas de dégats aux joueurs avant votre/leur niveau 5");
                    e.Damage.Amount = 0f;
                    e.Cancel();
                    return;
                }
            }
            catch {
            }
        }
Esempio n. 11
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            #region Checks
            if (e == null)
            {
                return;
            }
            if (e.Cancelled)
            {
                return;
            }
            if (e.Damage == null)
            {
                return;
            }
            if (e.Damage.DamageSource == null)
            {
                return;
            }
            if (!e.Damage.DamageSource.IsPlayer)
            {
                return;
            }
            if (e.Damage.DamageSource.Owner == null)
            {
                return;
            }
            if (e.Entity == null)
            {
                return;
            }
            if (!e.Entity.IsPlayer)
            {
                return;
            }
            if (e.Entity.Owner == null)
            {
                return;
            }
            if (e.Entity == e.Damage.DamageSource)
            {
                return;
            }
            if (e.Damage.Amount < 0)
            {
                return;
            }
            #endregion

            var damager = e.Damage.DamageSource.Owner;
            var victim  = e.Entity.Owner;

            CheckPlayerExcists(damager);
            CheckPlayerExcists(victim);

            var damagerData = Data[damager.Id];
            var victimData  = Data[victim.Id];

            if (damagerData.Race == null || victimData.Race == null)
            {
                return;
            }

            if (damagerData.Race.CanDamage(victimData.Race.Name))
            {
                return;
            }

            e.Cancel();
            e.Damage.Amount = 0f;
        }