Beispiel #1
0
    public float CalculateExposure(bool countArmor)
    {
        if ((this.radiationZones == null) || (this.radiationZones.Count == 0))
        {
            return(0f);
        }
        Vector3 origin = base.origin;
        float   num    = 0f;

        foreach (RadiationZone zone in this.radiationZones)
        {
            num += zone.GetExposureForPos(origin);
        }
        if (countArmor)
        {
            HumanBodyTakeDamage takeDamage = base.takeDamage as HumanBodyTakeDamage;
            if (takeDamage != null)
            {
                float armorValue = takeDamage.GetArmorValue(4);
                if (armorValue > 0f)
                {
                    num *= 1f - Mathf.Clamp((float)(armorValue / 200f), (float)0f, (float)1f);
                }
            }
        }
        return(num);
    }
Beispiel #2
0
    public float CalculateExposure(bool countArmor)
    {
        if (this.radiationZones == null || this.radiationZones.Count == 0)
        {
            return(0f);
        }
        Vector3 vector3        = base.origin;
        float   exposureForPos = 0f;

        foreach (RadiationZone radiationZone in this.radiationZones)
        {
            exposureForPos = exposureForPos + radiationZone.GetExposureForPos(vector3);
        }
        if (countArmor)
        {
            HumanBodyTakeDamage humanBodyTakeDamage = base.takeDamage as HumanBodyTakeDamage;
            if (humanBodyTakeDamage)
            {
                float armorValue = humanBodyTakeDamage.GetArmorValue(4);
                if (armorValue > 0f)
                {
                    exposureForPos = exposureForPos * (1f - Mathf.Clamp(armorValue / 200f, 0f, 1f));
                }
            }
        }
        return(exposureForPos);
    }
Beispiel #3
0
 void cmdCurePlayer(NetUser netuser, string command, string[] args)
 {
     if (!permission.UserHasPermission(netuser.playerClient.userID.ToString(), "advmetabolism.allowed"))
     {
         SendReply(netuser, GetMessage("NoPermissionCure", netuser.userID.ToString()));
         return;
     }
     else if (args.Length != 1)
     {
         var rootControllable = netuser.playerClient.rootControllable;
         if (!rootControllable)
         {
             return;
         }
         var rootCharacter = rootControllable.rootCharacter;
         if (!rootCharacter)
         {
             return;
         }
         Metabolism metabolism = rootControllable.GetComponent <Metabolism>();
         metabolism.AddCalories(3000);
         float radLevel = metabolism.GetRadLevel();
         metabolism.AddAntiRad(radLevel);
         FallDamage fallDamage = rootControllable.GetComponent <FallDamage>();
         fallDamage.ClearInjury();
         HumanBodyTakeDamage humanBodyTakeDamage = rootControllable.GetComponent <HumanBodyTakeDamage>();
         humanBodyTakeDamage.SetBleedingLevel(0);
         SendReply(netuser, GetMessage("CureSelf", netuser.userID.ToString()));
         return;
     }
     else
     {
         NetUser targetuser = rust.FindPlayer(args[0]);
         if (targetuser != null)
         {
             var rootControllable = netuser.playerClient.rootControllable;
             if (!rootControllable)
             {
                 return;
             }
             var rootCharacter = rootControllable.rootCharacter;
             if (!rootCharacter)
             {
                 return;
             }
             Metabolism metabolism = rootControllable.GetComponent <Metabolism>();
             metabolism.AddCalories(3000);
             float radLevel = metabolism.GetRadLevel();
             metabolism.AddAntiRad(radLevel);
             FallDamage fallDamage = rootControllable.GetComponent <FallDamage>();
             fallDamage.ClearInjury();
             HumanBodyTakeDamage humanBodyTakeDamage = rootControllable.GetComponent <HumanBodyTakeDamage>();
             humanBodyTakeDamage.SetBleedingLevel(0);
             SendReply(netuser, GetMessage("CureTargetReply", netuser.userID.ToString()) + targetuser.displayName);
             SendReply(targetuser, GetMessage("CureTargetMessage", netuser.userID.ToString()) + netuser.displayName);
         }
     }
 }
    public virtual void UseItem(IConsumableItem item)
    {
        Inventory  inventory = item.inventory;
        Metabolism local     = inventory.GetLocal <Metabolism>();

        if (local == null)
        {
            return;
        }
        if (!local.CanConsumeYet())
        {
            return;
        }
        local.MarkConsumptionTime();
        float single = Mathf.Min(local.GetRemainingCaloricSpace(), this.calories);

        if (this.calories > 0f)
        {
            local.AddCalories(single);
        }
        if (this.litresOfWater > 0f)
        {
            local.AddWater(this.litresOfWater);
        }
        if (this.antiRads > 0f)
        {
            local.AddAntiRad(this.antiRads);
        }
        if (this.healthToHeal != 0f)
        {
            HumanBodyTakeDamage humanBodyTakeDamage = inventory.GetLocal <HumanBodyTakeDamage>();
            if (humanBodyTakeDamage != null)
            {
                if (this.healthToHeal <= 0f)
                {
                    TakeDamage.HurtSelf(inventory.idMain, Mathf.Abs(this.healthToHeal), null);
                }
                else
                {
                    humanBodyTakeDamage.HealOverTime(this.healthToHeal);
                }
            }
        }
        if (this.poisonAmount > 0f)
        {
            local.AddPoison(this.poisonAmount);
        }
        int num = 1;

        if (item.Consume(ref num))
        {
            inventory.RemoveItem(item.slot);
        }
    }
Beispiel #5
0
    public virtual bool CanBandage()
    {
        HumanBodyTakeDamage component = base.inventory.gameObject.GetComponent <HumanBodyTakeDamage>();

        return((component.IsBleeding() || ((component.healthLossFraction > 0f) && base.datablock.DoesGiveBlood())) && ((Time.time - this.lastBandageTime) > 1.5f));
    }
Beispiel #6
0
 protected override bool CheckPrerequesits()
 {
     this.humanBodyTakeDamage = base.takeDamage as HumanBodyTakeDamage;
     return((this.humanBodyTakeDamage != null) && base.networkViewOwner.isClient);
 }
Beispiel #7
0
 protected override bool CheckPrerequesits()
 {
     this.humanBodyTakeDamage = base.takeDamage as HumanBodyTakeDamage;
     return (!this.humanBodyTakeDamage ? false : base.networkViewOwner.isClient);
 }
Beispiel #8
0
        private void SetPlayerDeathTags(HumanBodyTakeDamage humanBodyTakeDamage, DamageEvent damage, ref DeathTags tags)
        {
            Metabolism metabolism = damage.attacker.id.GetComponent <Metabolism>();
            FallDamage fallDamage = damage.attacker.id.GetComponent <FallDamage>();

            tags.killed   = damage.victim.client?.netUser.displayName ?? UNKNOWN;
            tags.killedId = damage.victim.client?.netUser.userID.ToString() ?? UNKNOWN;
            tags.bodypart = damage.bodyPart.GetNiceName();
            if (damage.attacker.id.GetComponentInChildren <BasicWildLifeAI>())
            {
                tags.deathType = DeathTypes.entity;
                var mutant = damage.attacker.idMain?.ToString().Contains("Mutant") ?? false;
                if (damage.attacker.id.GetComponent <WolfAI>())
                {
                    tags.killer = (mutant) ? "Mutant Wolf" : "Wolf";
                    return;
                }
                if (damage.attacker.id.GetComponent <BearAI>())
                {
                    tags.killer = (mutant) ? "Mutant Bear" : "Bear";
                    return;
                }
            }

            if (damage.attacker.id.GetComponent <DeployableObject>())
            {
                tags.deathType = DeathTypes.human;
                tags.killerId  = damage.attacker.id.GetComponent <DeployableObject>().creatorID.ToString();
                if (damage.attacker.id.GetComponent <SpikeWall>())
                {
                    tags.weapon = "Spike Wall";
                }
                else if (damage.attacker.id.GetComponent <TimedExplosive>())
                {
                    tags.weapon = "Explosive Charge";
                }
                return;
            }

            if (damage.attacker.id.GetComponent <TimedGrenade>())
            {
                tags.deathType = DeathTypes.human;
                tags.weapon    = "F1 Grenade";
                return;
            }

            if (damage.attacker.client == damage.victim.client)
            {
                tags.deathType = DeathTypes.suicide;
                tags.killerId  = tags.killedId;
                float fallDmg = (float)fallDamage?.GetType().GetField("injuredTime", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(fallDamage);

                if (damage.damageTypes == 0 && WaterLine.Height != 0f && humanBodyTakeDamage.transform.position.y <= WaterLine.Height)
                {
                    tags.weapon = tags.weapon.Equals(UNKNOWN) ? "Water" : tags.weapon;
                }
                else if (damage.attacker.id.GetComponent <Radiation>() && metabolism.GetRadLevel() >= 500f)
                {
                    tags.weapon = tags.weapon.Equals(UNKNOWN) ? "Radiation" : tags.weapon;
                }
                else if (fallDamage != null && fallDamage.GetLegInjury() >= 1f)
                {
                    tags.weapon = tags.weapon.Equals(UNKNOWN) ? "Falling" : tags.weapon;
                }
                else if (humanBodyTakeDamage.IsBleeding())
                {
                    tags.weapon = tags.weapon.Equals(UNKNOWN) ? "Bleeding" : tags.weapon;
                }
                if (tags.weapon.Equals(UNKNOWN))
                {
                    tags.weapon = "Suicide";
                }
            }
            else if (damage.victim.client && damage.attacker.client)
            {
                tags.deathType = DeathTypes.human;
                if (humanBodyTakeDamage.IsBleeding())
                {
                    tags.weapon = tags.weapon.Equals(UNKNOWN) ? "Bleeding" : tags.weapon;
                }
            }
        }