Exemplo n.º 1
0
        private bool GuildsAreAtWar(EntityDamageEvent damageEvent)
        {
            var player      = damageEvent.Damage.DamageSource.Owner;
            var target      = damageEvent.Entity.Owner;
            var playerGuild = PlayerExtensions.GetGuild(player).Name.ToLower();
            var targetGuild = PlayerExtensions.GetGuild(target).Name.ToLower();

            //PrintToChat(player, playerGuild.ToLower() + " " + targetGuild.ToLower());
            //PrintToChat(player, "Number of wars = " + WarList.Count);
            ////PrintToChat(player, "First war in list = " + WarList[0][0] + " " + WarList[0][1] + " " + WarList[0][2]);

            foreach (var war in WarList)
            {
                PrintToChat(player, playerGuild.ToLower() + " " + targetGuild.ToLower() + " " + war[1].ToLower() + " " + war[2].ToLower());
                if (war[2].ToLower() == playerGuild.ToLower() && war[1].ToLower() == targetGuild.ToLower())
                {
                    return(true);
                }
                if (war[1].ToLower() == playerGuild.ToLower() && war[2].ToLower() == targetGuild.ToLower())
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 2
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            if (e.Entity == null)
            {
                return;
            }
            if (e.Entity.Owner == null)
            {
                return;
            }
            if (e.Damage.DamageSource == null)
            {
                return;
            }
            if (e.Damage.DamageSource.Owner == null)
            {
                return;
            }

            Entity victimeDegats = e.Entity;
            Player joueurVictime = e.Entity.Owner;

            if (victimeDegats != null && joueurVictime != null)
            {
                Entity sourceDegats    = e.Damage.DamageSource;
                Player joueurAttaquant = e.Damage.DamageSource.Owner;

                if (sourceDegats != null && joueurAttaquant != null)
                {
                    if (victimeDegats.IsPlayer && sourceDegats.IsPlayer)
                    {
                        foreach (Duels unDuel in _ListeDuels)
                        {
                            if (unDuel.joueurDefieur == joueurVictime.Id || unDuel.joueurReceveurDefi == joueurVictime.Id)
                            {
                                //si dans la liste des duels
                                if (unDuel.joueurDefieur == joueurAttaquant.Id || unDuel.joueurReceveurDefi == joueurAttaquant.Id)
                                {
                                    //si un duel avant le tueur
                                    if (unDuel.duelEnCours)
                                    {
                                        //si duel actif
                                        if (isDamageKilling(joueurVictime, e.Damage))
                                        {
                                            //si point de vie à 0 tête ou torse
                                            PrintToChat("[0080FF]" + joueurAttaquant.Name + "[FFFFFF]" + GetMessage("WonADuel", joueurAttaquant.Id) + "[0080FF]" + joueurVictime.Name + "[FFFFFF] !");
                                            joueurAttaquant.GetHealth().Heal(100f);
                                            joueurVictime.GetHealth().Heal(100f);
                                            _ListeDuels.Remove(unDuel);
                                            e.Damage.Amount = 0f;
                                            return;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (!pwn)
            {
                return;
            }
            if (damageEvent.Damage.DamageSource.Owner is Player)
            {
                Player damager = damageEvent.Damage.DamageSource.Owner;
                if (!damager.HasPermission("admin"))
                {
                    return;
                }

                //this is needed for some reason, otherwise all animals on server also deal pwnDMG
                if (damager.DisplayName == "Server")
                {
                    return;
                }


                if (damageEvent.Damage.Amount < 0)
                {
                    damageEvent.Damage.Amount = pwnRepair;
                    PrintToChat(damager, "PWN repair! healing " + pwnRepair.ToString() + " damage.");
                    return;
                }
                PrintToChat(damager, "PWN hit! dealing " + pwnDMG.ToString() + " damage.");
                damageEvent.Damage.Amount = pwnDMG;
            }
        }
Exemplo n.º 4
0
 void OnEntityHealthChange(EntityDamageEvent e)
 {
     if (!e.Entity.IsPlayer)
     {
         Puts(e.Entity.name);
     }
 }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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;
     }
 }
Exemplo n.º 7
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            #region Checks
            if (e?.Damage == null)
            {
                return;
            }
            if (e.Damage.DamageSource == null)
            {
                return;
            }
            if (!e.Damage.DamageSource.IsPlayer)
            {
                return;
            }
            if (e.Entity == null)
            {
                return;
            }
            if (e.Entity == e.Damage.DamageSource)
            {
                return;
            }
            if (!Data.ContainsKey(e.Damage.DamageSource.Owner.Id))
            {
                return;
            }
            #endregion

            var player = e.Damage.DamageSource.Owner;
            var data   = Data[player.Id];

            if (e.Damage.Amount >= 0)
            {
                if (!HasPermission(player, "hulk.damage"))
                {
                    return;
                }
                if (e.Cancelled)
                {
                    e.Uncancel();
                }
                e.Damage.Amount = data.GetDamage();
                player.SendMessage($"{Prefix}Hulk dealing {e.Damage.Amount} damage.[-]");
            }
            else
            {
                if (!HasPermission(player, "hulk.heal"))
                {
                    return;
                }
                if (e.Cancelled)
                {
                    e.Uncancel();
                }
                e.Damage.Amount = data.GetHeal();
                player.SendMessage($"{Prefix}Hulk healing {e.Damage.Amount} damage.[-]");
            }
        }
Exemplo n.º 8
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            try
            {
                if (e.Damage == null)
                {
                    return;
                }
                if (e.Entity == null)
                {
                    return;
                }
                if (e.Entity.Owner == null)
                {
                    return;
                }
                if (e.Entity.Owner.Entity == null)
                {
                    return;
                }
                if (!e.Entity.Owner.Entity.IsPlayer)
                {
                    return;
                }

                Player attacker = null;
                if (e.Damage.DamageSource != null)
                {
                    if (e.Damage.DamageSource.Owner != null)
                    {
                        if (e.Damage.DamageSource.Owner.Entity != null)
                        {
                            attacker = e.Damage.DamageSource.Owner;
                        }
                    }
                }

                Player victim = e.Entity.Owner;
                if (!isDamageKilling(victim, e.Damage))
                {
                    return;
                }

                Log(victim.Id + " - " + victim.Name + " - " + e.ToString() + " - " + e.Damage.DamageTypes.ToString(), "PlayerDeath");
                if (attacker != null)
                {
                    Log("Killed by " + attacker.Entity.name, "PlayerDeath");
                }

                foreach (string inventoryObject in GetInventoryContents(victim))
                {
                    Log(" - " + inventoryObject, "PlayerDeath");
                }
            }
            catch
            {
            }
        }
Exemplo n.º 9
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]");
     }
 }
Exemplo n.º 10
0
 public void OnEntityDamage(EntityDamageEvent ev)
 {
     ev.Entity.HP -= ev.Damage;
     if (ev.Entity.HP <= 0)
     {
         Server.Events.Call(new EntityDeathEvent()
         {
             Entity = ev.Entity
         });
     }
 }
Exemplo n.º 11
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            Player Damager   = e.Damage.DamageSource.Owner;
            bool   IsSleeper = e.Entity.name.ToString().Contains("Player Sleeper");

            if (e.Damage.Amount > 0 && IsSleeper)
            {
                PrintToChat("[SERVER] A sleeper was attacked by " + Damager.DisplayName + ", and they were kicked for it. Killing sleeping players is uncool, yo.");
                Server.Kick(Damager, "Attacking a sleeping player.");
            }
        }
Exemplo n.º 12
0
 private void OnEntityHealthChange(EntityDamageEvent e)
 {
     HookCalled("OnEntityHealthChange");
     if (e.Damage.Amount > 0)
     {
         Puts($"{e.Entity} took {e.Damage.Amount} {e.Damage?.DamageTypes} damage from {e.Damage?.DamageSource} ({e.Damage?.Damager?.name})");
     }
     if (e.Damage.Amount < 0)
     {
         Puts($"{e.Entity} gained {e.Damage.Amount} health.");
     }
 }
Exemplo n.º 13
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            #region Null Checks
            if (damageEvent == null)
            {
                return;
            }
            if (damageEvent.Damage == null)
            {
                return;
            }
            if (damageEvent.Damage.DamageSource == null)
            {
                return;
            }
            if (!damageEvent.Damage.DamageSource.IsPlayer)
            {
                return;
            }
            if (damageEvent.Entity == null)
            {
                return;
            }
            if (!damageEvent.Entity.IsPlayer)
            {
                return;
            }
            if (damageEvent.Entity == damageEvent.Damage.DamageSource)
            {
                return;
            }
            #endregion

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

            var boss = GetBoss(damager);
            if (boss != null)
            {
                damageEvent.Damage.Amount = boss.CalculateDamage(damageEvent.Damage.Amount);
                return;
            }

            boss = GetBoss(victim);
            if (boss == null)
            {
                return;
            }

            damageEvent.Damage.Amount = boss.CalculateDefense(damageEvent.Damage.Amount);
        }
Exemplo n.º 14
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.");
                }
            }
        }
Exemplo n.º 15
0
 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");
 }
Exemplo n.º 16
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.");
             }
         }
     }
 }
Exemplo n.º 17
0
        public override void TakeHit(Entity source, int damage = 1, DamageCause cause = DamageCause.Unknown)
        {
            if (Entity.Level is OpenLevel lvl)
            {
                int h = Health;
                EntityDamageEvent damageEvent = new EntityDamageEvent(base.Entity, source,
                                                                      cause, h, h - damage);
                lvl.EventDispatcher.DispatchEvent(damageEvent);
                if (damageEvent.IsCancelled)
                {
                    return;
                }
            }

            base.TakeHit(source, damage, cause);
        }
Exemplo n.º 18
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;
            }
        }
Exemplo n.º 19
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]");
            }
        }
Exemplo n.º 20
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (!dannyHelp)
            {
                return;
            }

            if (damageEvent.Damage.Amount < 0)
            {
                return;
            }
            var thisName = damageEvent.Damage.DamageSource.Owner.Name.ToLower();

            if (thisName == "lord scorpyon" || thisName == "ultrunz von dicksby" || thisName == "duke dan" || thisName == "Odin")
            {
                //if (!damageEvent.Entity.name.Contains("Crest")) return;
                damageEvent.Damage.Amount = 1000000f;
                PrintToChat(damageEvent.Damage.DamageSource.Owner, "SUPA-DAMAGE!");
            }
        }
Exemplo n.º 21
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;
             }
         }
     }
 }
Exemplo n.º 22
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            //var attacker = damageEvent.Damage.DamageSource.Owner;
            var target = damageEvent.Entity.Owner;

            if (theBoss == null)
            {
                return;
            }

            //Other creatures on the server
            //if(attacker.DisplayName == "Server") return;

            //Was the boss hurt by a player?
            if (target == theBoss)
            {
                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
                    )
                {
//						PrintToChat(attacker, "[FF0000]Raid[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }

            // if(attacker == theBoss)
            // {
            // //Did the boss hurt another player's face?
            // 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
            // ){
            // PrintToChat(attacker, "[FF0000]Raid[FFFFFF] : Your foe deals you a devastating! blow!");
            // damageEvent.Damage.Amount = damageEvent.Damage.Amount * (damageIncrease/100);
            // }
            // }
        }
Exemplo n.º 23
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (!damageEvent.Entity.IsPlayer)
            {
                var    victim = damageEvent.Entity;
                Health h      = victim.TryGet <Health>();
                if (h.ToString().Contains("Plague Villager"))
                {
                    return;
                }
                if (!h.IsDead)
                {
                    return;
                }

                var hunter = damageEvent.Damage.DamageSource.Owner;

                // Give the rewards to the player
                var xp = random.Next(1, xpRewardForPve);

                // Special bonuses
                if (h.ToString().Contains("Werewolf"))
                {
                    xp = xp + 10;
                }
                if (h.ToString().Contains("Bear"))
                {
                    xp = xp + 5;
                }
                if (h.ToString().Contains("Wolf"))
                {
                    xp = xp + 3;
                }

                // Notify everyone
                PrintToChat(hunter, "[FFFFFF]You learned from your hunting and gained some experience! [FFFFFF]([00FF00]+" + xp.ToString() + "[FFFFFF])");
                AddRankXp(hunter, xp);

                SaveRankData();
            }
        }
Exemplo n.º 24
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            if (e.Damage.Amount < 0)
            {
                return;
            }
            var sleeper = e.Entity.GetComponentInChildren <PlayerSleeperObject>();

            if (sleeper == null)
            {
                return;
            }
            var sleeperId = sleeper.SleeperId;

            if (IsAttackable(sleeperId))
            {
                return;
            }
            e.Damage.Amount = 0;
            if (!e.Damage.DamageSource.IsPlayer)
            {
                return;
            }
            var attacker = e.Damage.DamageSource.Owner;

            if (!NotifyAttacker)
            {
                return;
            }
            if (!notifications.ContainsKey(attacker))
            {
                notifications.Add(attacker, 0);
            }
            if ((int)(GetTimestamp() - notifications[attacker]) < TimeBetweenNotifications)
            {
                return;
            }
            SendMessage(attacker, PlayerNotification);
            notifications[attacker] = GetTimestamp();
        }
Exemplo n.º 25
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 {
            }
        }
Exemplo n.º 26
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            if (damageEvent.Damage.DamageSource.Owner is Player)
            {
                Player player       = damageEvent.Damage.DamageSource.Owner;
                double CurrentLevel = Convert.ToDouble(GetCurrentLevel(player));
                double damage       = Convert.ToDouble(damageEvent.Damage.Amount);
                double damageBonus  = 0;

                if (damageEvent.Entity.Owner is Player)
                {
                    damageBonus = playerDamageBonusPercentage;
                }
                else if (damageEvent.Entity.Owner.DisplayName == "server")
                {
                    damageBonus = monsterDamageBonusPercentage;
                }

                damageBonus = (CurrentLevel - 1) * damageBonus;
                damage      = damage * (damageBonus / 100 + 1);
                damageEvent.Damage.Amount = Convert.ToInt32(damage);
            }
        }
Exemplo n.º 27
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            if (LogEntities == false)
            {
                return;
            }
            string str            = "";
            string entityPosition = e.Entity.Position.x + "," + e.Entity.Position.y + "," + e.Entity.Position.x;

            if (e.Damage.Amount > 0)
            {
                if (e.Damage.DamageSource.IsPlayer)
                {
                    str += e.Damage.DamageSource.Owner.Name + " has done ";
                }
                else
                {
                    str += e.Damage.DamageSource.name + " has done ";
                }

                str += e.Damage.Amount + " [" + e.Damage.DamageTypes + "] damage points to ";

                if (e.Entity.IsPlayer)
                {
                    str += e.Entity.Owner.Name;
                }
                else if (IsAnimal(e))
                {
                    str += e.Entity.name;
                }
                else
                {
                    str += e.Entity.name;
                }

                str += " with a " + e.Damage.Damager.name + " at [" + entityPosition + "].";
                if ((CrestSpecial == true && e.Entity.name.Contains("Crest")) || (SleeperSpecial == true && e.Entity.name.Contains("Sleep")))
                {
                    Log("Special", str);
                    return;
                }
                else
                {
                    Log("Entities", str);
                }
            }

            if (e.Damage.Amount < 0)
            {
                if (e.Entity.IsPlayer)
                {
                    str += e.Entity.Owner.Name + " has gained " + (e.Damage.Amount * -1) + " health points.";

                    Log("Entities", str);
                }
                else
                {
                    str += e.Entity.name + " has gained " + (e.Damage.Amount * -1) + " health points";
                    if (e.Damage.DamageSource.IsPlayer)
                    {
                        str += " from " + e.Damage.DamageSource.Owner.Name;
                    }
                    str += ".";

                    Log("Entities", str);
                }
            }
        }
Exemplo n.º 28
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            HookCalled("OnEntityHealthChange");
            if (e.Damage.Amount > 0)
                Puts($"{e.Entity} took {e.Damage.Amount} {e.Damage?.DamageTypes} damage from {e.Damage?.DamageSource} ({e.Damage?.Damager?.name})");

            if (e.Damage.Amount < 0)
                Puts($"{e.Entity} gained {e.Damage.Amount} health.");
        }
Exemplo n.º 29
0
        private void OnEntityHealthChange(EntityDamageEvent damageEvent)
        {
            //var attacker = damageEvent.Damage.DamageSource.Owner;
            var target = damageEvent.Entity.Owner;

            if (Boss1 == null && Boss2 == null && Boss3 == null && Boss4 == null && Boss5 == null)
            {
                return;
            }

            //Other creatures on the server
            //if(attacker.DisplayName == "Server") return;

            //Was the boss hurt by a player?
            if (target == Boss1)
            {
                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
                    )
                {
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]Battle[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }
            if (target == Boss2)
            {
                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
                    )
                {
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]Battle[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }
            if (target == Boss3)
            {
                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
                    )
                {
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]Battle[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }
            if (target == Boss4)
            {
                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
                    )
                {
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]Battle[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }
            if (target == Boss5)
            {
                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
                    )
                {
                    PrintToChat(damageEvent.Damage.DamageSource.Owner, "[FF0000]Battle[FFFFFF] : Your attacks are doing less damage to this person!");
                    double damageTaken = damageEvent.Damage.Amount * (damageReduction / 100);
                    damageEvent.Damage.Amount = (int)damageTaken;
                }
            }

            if (target != Boss1 && target != Boss2 && target != Boss3 && target != Boss4 && target != Boss5)
            {
                //Did the boss hurt another player's face?
                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
                    )
                {
                    PrintToChat(damageEvent.Entity.Owner, "[FF0000]Battle[FFFFFF] : Your foe deals you a devastating blow!");
                    double damageGiven = damageEvent.Damage.Amount * (damageIncrease / 100);
                    damageEvent.Damage.Amount = (int)damageGiven;
                }
            }
        }
Exemplo n.º 30
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;
        }
Exemplo n.º 31
0
        private void OnEntityHealthChange(EntityDamageEvent e)
        {
            try
            {
                if (e == null)
                {
                    return;
                }
                if (e.Damage == null)
                {
                    return;
                }
                if (e.Damage.Amount <= 0)
                {
                    return;
                }
                if (e.Damage.DamageSource == null)
                {
                    return;
                }
                if (e.Damage.DamageSource.Owner == null)
                {
                    return;
                }
                if (e.Damage.DamageSource.Owner.Entity == null)
                {
                    return;
                }
                if (!e.Damage.DamageSource.Owner.Entity.IsPlayer)
                {
                    return;
                }
                if (e.Entity == null)
                {
                    return;
                }
                if (e.Entity.Owner == null)
                {
                    return;
                }
                if (e.Entity.Owner.Entity == null)
                {
                    return;
                }
                if (!e.Entity.Owner.Entity.IsPlayer)
                {
                    return;
                }

                Player attacker = e.Damage.DamageSource.Owner;
                Player victim   = e.Entity.Owner;
                if (attacker == victim)
                {
                    return;
                }

                Zone victimZone = getPlayerZone(victim);

                if (victimZone != null)
                {
                    if (!victimZone.playerDamage)
                    {
                        sendError(attacker, string.Format(GetMessage("NoPvPInZone")));
                        e.Damage.Amount = 0f;
                        return;
                    }
                }
            }
            catch {
            }
        }