private static LifeStatus HurtShared(IDBase attacker, IDBase victim, TakeDamage.Quantity damageQuantity, out DamageEvent damage, object extraData = null) { damage = new DamageEvent(); TakeDamage takeDamage; if (victim) { IDMain dMain = victim.idMain; if (dMain) { takeDamage = (!(dMain is Character) ? dMain.GetLocal <TakeDamage>() : ((Character)dMain).takeDamage); if (takeDamage && !takeDamage.takenodamage) { takeDamage.MarkDamageTime(); damage.victim.id = victim; damage.attacker.id = attacker; damage.amount = damageQuantity.@value; damage.sender = takeDamage; damage.status = (!takeDamage.dead ? LifeStatus.IsAlive : LifeStatus.IsDead); damage.damageTypes = (DamageTypeFlags)0; damage.extraData = extraData; if ((int)damageQuantity.Unit == -1) { takeDamage.ApplyDamageTypeList(ref damage, damageQuantity.list); } takeDamage.Hurt(ref damage); return(damage.status); } } } damage.victim.id = null; damage.attacker.id = null; damage.amount = 0f; damage.sender = null; damage.damageTypes = (DamageTypeFlags)0; damage.status = LifeStatus.Failed; damage.extraData = extraData; return(LifeStatus.Failed); }
public static bool TakeDamage_HurtShared(TakeDamage take, ref DamageEvent damage, TakeDamage.Quantity quantity) { object[] array = new object[] { take, damage, quantity }; bool asBoolean = Method.Invoke("RustExtended.RustHook.TakeDamage_HurtShared", array).AsBoolean; damage = (DamageEvent)array[1]; return(asBoolean); }
private static LifeStatus HurtShared(IDBase attacker, IDBase victim, TakeDamage.Quantity damageQuantity, object extraData = null) { DamageEvent damageEvent; return(TakeDamage.HurtShared(attacker, victim, damageQuantity, out damageEvent, extraData)); }
public static LifeStatus HurtSelf(IDBase victim, TakeDamage.Quantity damageQuantity, object extraData = null) { return(TakeDamage.HurtShared(victim, victim, damageQuantity, extraData)); }
public static bool DamageOverride(TakeDamage take, ref DamageEvent damage, ref TakeDamage.Quantity quantity) { if (damage.attacker.idMain != damage.victim.idMain) { if (!Core.OverrideDamage || float.IsInfinity(damage.amount)) { return(true); } if ((damage.victim.id.GetComponent <Character>() == null) && (damage.attacker.client != null)) { ulong ownerID = (damage.victim.client != null) ? damage.victim.client.userID : ((ulong)0L); if (damage.victim.idMain is DeployableObject) { ownerID = (damage.victim.idMain as DeployableObject).ownerID; } if (damage.victim.idMain is StructureComponent) { ownerID = (damage.victim.idMain as StructureComponent)._master.ownerID; } ulong num2 = (damage.attacker.client != null) ? damage.attacker.client.userID : ((ulong)0L); if (damage.attacker.idMain is DeployableObject) { num2 = (damage.attacker.idMain as DeployableObject).ownerID; } if (damage.attacker.idMain is StructureComponent) { num2 = (damage.attacker.idMain as StructureComponent)._master.ownerID; } if (((ownerID == num2) || Users.SharedGet(ownerID, num2)) && (Core.OwnershipDestroy || Core.DestoryOwnership.ContainsKey(damage.attacker.client.userID))) { Config.Get("OVERRIDE.DAMAGE", damage.attacker.idMain.name.Replace("(Clone)", "") + ".DAMAGE", ref damage.amount, true); return(true); } } bool result = true; if ((damage.attacker.client != null) && (damage.attacker.idMain is Character)) { WeaponImpact extraData = damage.extraData as WeaponImpact; string str = (extraData != null) ? extraData.dataBlock.name : "Hunting Bow"; string str2 = str.Replace(" ", "") + ".DAMAGE"; string key = str2 + "." + damage.victim.idMain.name.Replace("(Clone)", ""); string str4 = str2 + ".HEADSHOT"; if (Config.Get("OVERRIDE.DAMAGE", key, ref result, true) && !result) { return(false); } float[] numArray = (extraData != null) ? new float[] { extraData.dataBlock.damageMin, extraData.dataBlock.damageMax } : new float[] { 75f, 75f }; Config.Get("OVERRIDE.DAMAGE", (damage.bodyPart == BodyPart.Head) ? str4 : str2, ref numArray, true); damage.amount = UnityEngine.Random.Range(Math.Min(numArray[0], numArray[1]), Math.Max(numArray[0], numArray[1])); if ((extraData != null) && (damage.extraData is BulletWeaponDataBlock)) { damage.amount *= (damage.extraData as BulletWeaponDataBlock).IsSilenced(extraData.itemRep) ? 0.8f : 1f; } if ((extraData != null) && (damage.extraData is BulletWeaponImpact)) { quantity = new DamageTypeList(0f, damage.amount, 0f, 0f, 0f, 0f); } else { quantity = new DamageTypeList(0f, 0f, damage.amount, 0f, 0f, 0f); } damage.amount = 0f; if (quantity.Unit == TakeDamage.Unit.List) { ApplyDamageTypeList(take, ref damage, quantity.DamageTypeList); } Helper.Log(string.Concat(new object[] { "Damage: ", damage.attacker.idMain, "[", damage.attacker.networkViewID, "] from ", str, " hit ", damage.victim.idMain, "[", damage.victim.networkViewID, "] on ", damage.amount, "(", numArray[0], "-", numArray[1], ") pts." }), false); } else if (!(damage.attacker.idMain is Character)) { float baseReturnDmg = 0f; float explosionRadius = 0f; if (damage.attacker.id is TimedGrenade) { baseReturnDmg = (damage.attacker.id as TimedGrenade).damage; explosionRadius = (damage.attacker.id as TimedGrenade).explosionRadius; } if (damage.attacker.id is TimedExplosive) { baseReturnDmg = (damage.attacker.id as TimedExplosive).damage; explosionRadius = (damage.attacker.id as TimedExplosive).explosionRadius; } if (damage.attacker.id is SpikeWall) { baseReturnDmg = (damage.attacker.id as SpikeWall).baseReturnDmg; explosionRadius = 0f; } if (baseReturnDmg > 0f) { string str5 = damage.attacker.idMain.name.Replace("(Clone)", "") + ".DAMAGE"; string str6 = str5 + "." + damage.victim.idMain.name.Replace("(Clone)", ""); if (Config.Get("OVERRIDE.DAMAGE", str6, ref result, true) && !result) { return(false); } Config.Get("OVERRIDE.DAMAGE", str5, ref baseReturnDmg, true); if (explosionRadius > 0f) { RaycastHit hit; bool flag2; MeshBatchInstance instance; Vector3 center = damage.victim.idMain.collider.bounds.center; Vector3 a = damage.attacker.idMain.collider.bounds.center; Vector3 direction = center - a; float distance = Vector3.Distance(a, center); if (Facepunch.MeshBatch.MeshBatchPhysics.Raycast(a, direction, out hit, distance, 0x10360401, out flag2, out instance)) { IDMain main = flag2 ? instance.idMain : IDBase.GetMain(hit.collider); GameObject obj2 = (main != null) ? main.gameObject : hit.collider.gameObject; if (obj2 != damage.victim.idMain.gameObject) { damage.amount = (1f - Mathf.Clamp01(distance / explosionRadius)) * baseReturnDmg; if (flag2) { damage.amount *= 0.1f; } } } } if (damage.attacker.id is SpikeWall) { quantity = new DamageTypeList(0f, 0f, damage.amount, 0f, 0f, 0f); } else { quantity = new DamageTypeList(0f, 0f, 0f, damage.amount, 0f, 0f); } damage.amount = 0f; if (quantity.Unit == TakeDamage.Unit.List) { ApplyDamageTypeList(take, ref damage, quantity.DamageTypeList); } } Helper.Log(string.Concat(new object[] { "Damage: ", damage.attacker.idMain, "[", damage.attacker.networkViewID, "] owned ", damage.attacker.client, " hit ", damage.victim.idMain, "[", damage.victim.networkViewID, "] on ", damage.amount, "(", baseReturnDmg, ") pts." }), false); } } return(true); }