Example #1
0
        bool InNoLootZone(BasePlayer victim, BasePlayer attacker)
        {
            // Event Manager plugin support - http://oxidemod.org/plugins/event-manager.740/
            if (EventManager != null)
            {
                if (!((bool)EventManager.Call("isPlaying", victim)))
                {
                    return(false);
                }
                Player.Reply(attacker, Lang("NoLootZone", attacker.UserIDString));
                return(true);
            }

            // Zone Manager plugin support - http://oxidemod.org/plugins/zones-manager.739/
            if (ZoneManager != null)
            {
                var noLooting = Enum.Parse(ZoneManager.GetType().GetNestedType("ZoneFlags"), "NoPlayerLoot", true);
                if (!((bool)ZoneManager.Call("HasPlayerFlag", victim, noLooting)))
                {
                    return(false);
                }
                Player.Reply(attacker, Lang("NoLootZone", attacker.UserIDString));
                return(true);
            }

            return(false);
        }
Example #2
0
        void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo)
        {
            if (hitInfo != null &&
                hitInfo.Initiator != null &&
                hitInfo.Initiator.ToPlayer() != null)
            {
                BasePlayer player = hitInfo.Initiator.ToPlayer();

                if (ZoneManager != null)
                {
                    object canBeWounded = ZoneManager.Call("CanBeWounded", player, hitInfo);

                    if (canBeWounded == null)
                    {
                        return;
                    }
                }

                TimedExplosive explosion = null;

                if (hitInfo.WeaponPrefab != null &&
                    hitInfo.WeaponPrefab.ToString().Contains("explosive"))
                {
                    explosion = (hitInfo.WeaponPrefab.GetEntity() as TimedExplosive);
                }

                if (entity.ShortPrefabName.ToString().Contains("player") &&
                    (
                        explosion == null ||
                        explosion.explosionRadius >= player.Distance(entity.GetEntity())
                    )
                    )
                {
                    float totalDamage = (float)0.0;

                    foreach (Rust.DamageType damageType in Enum.GetValues(typeof(Rust.DamageType))) //calculate the damage the player would take
                    {
                        try
                        {
                            if (hitInfo.damageTypes.Get(damageType) > (float)0.0)
                            {
                                if (hitInfo.damageTypes.Get(damageType) > player.baseProtection.Get(damageType)) //damage of attack surpass player protection
                                {
                                    totalDamage += hitInfo.damageTypes.Get(damageType) - player.baseProtection.Get(damageType);
                                }
                            }
                        }
                        catch
                        { }
                    }

                    if (player.health <= totalDamage)
                    {
                        //if (!popupsEnabled)
                        SendReply(player, localization["AboutToDie"]);
                    }
                    //else
                    //    PopupNotifications.Call("CreatePopupNotification", localization["AboutToDie"], player);
                }
            }
        }