void OnLootEntity(BasePlayer player, BaseCombatEntity entity) { if (RepairOnLoot) { if (entity.LookupPrefab().name == "small_stash_deployed.prefab") { entity.health = entity.MaxHealth(); if (Debug) { Puts("Stash health restored"); } } } }
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { string entity_name = null; if (!hitInfo.damageTypes.Has(DamageType.Decay)) { return(null); } try { entity_name = entity.LookupPrefab().name; } catch { return(null); } #if DEBUG Puts($"OnEntityTakeDamage: START CHECKING {entity_name}."); #endif string pos = entity.transform.position.ToString(); ulong hitEntityOwnerID = entity.OwnerID != 0 ? entity.OwnerID: hitInfo.HitEntity.OwnerID; float before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); float multiplier = 1.0f; // First, we check for protected entities (NeverDecay) if (configData.NeverDecay.Contains(entity_name)) { multiplier = 0.0f; #if DEBUGND Puts($"OnEntityTakeDamage: START Skipping cupboard check for {entity_name} {pos} - will NOT decay!"); Puts("OnEntityTakeDamage: END Set damage for " + entity_name + " to " + multiplier.ToString() + ", was " + before.ToString() + "."); #endif // Apply our damage rules and return hitInfo.damageTypes.Scale(Rust.DamageType.Decay, multiplier); return(null); } #if DEBUG Puts($"OnEntityTakeDamage: START Checking {entity_name} at {pos}"); #endif // Second, we check for attached (BLOCK) or nearby (ENTITY) cupboard BuildingBlock block = entity as BuildingBlock; string isblock = ""; string buildGrade = ""; bool hascup = false; if (block != null) { isblock = " (building block)"; hascup = CheckCupboardBlock(block, hitInfo, entity_name); if (hascup) { multiplier = 0.0f; switch (block.grade) { case BuildingGrade.Enum.Twigs: if (configData.DecayTwig == true) { multiplier = configData.TwigRate; } break; case BuildingGrade.Enum.Wood: if (configData.DecayWood == true) { multiplier = configData.WoodRate; } break; case BuildingGrade.Enum.Stone: if (configData.DecayStone == true) { multiplier = configData.StoneRate; } break; case BuildingGrade.Enum.Metal: if (configData.DecayMetal == true) { multiplier = configData.MetalRate; } break; case BuildingGrade.Enum.TopTier: if (configData.DecayArmor == true) { multiplier = configData.ArmorRate; } break; } #if DEBUG switch (block.grade) { case BuildingGrade.Enum.Twigs: buildGrade = "(TWIG)"; break; case BuildingGrade.Enum.Wood: buildGrade = "(Wood)"; break; case BuildingGrade.Enum.Stone: buildGrade = "(Stone)"; break; case BuildingGrade.Enum.Metal: buildGrade = "(Metal)"; break; case BuildingGrade.Enum.TopTier: buildGrade = "(Armor)"; break; } Puts($"OnEntityTakeDamage: Block - Found cupboard attached to {entity_name}{buildGrade}"); #endif } else { #if DEBUG Puts($"OnEntityTakeDamage: Block - MISSING cupboard attached to {entity_name}{buildGrade}!"); Puts("OnEntityTakeDamage: END Set damage for " + entity_name + buildGrade + " to standard rate of " + before.ToString() + "."); #endif return(null); // Standard damage rates apply } } else if (CheckCupboardEntity(entity, hitInfo, entity_name)) { // Unprotected Entity with cupboard multiplier = 0.0f; #if DEBUG Puts($"OnEntityTakeDamage: Entity - Found cupboard near {entity_name}"); #endif } else { // Unprotected Entity with NO Cupboard #if DEBUG Puts($"OnEntityTakeDamage: Entity - MISSING cupboard near {entity_name}"); Puts("OnEntityTakeDamage: END Set damage for " + entity_name + " to standard rate of " + before.ToString() + "."); #endif return(null); // Standard damage rates apply } // Apply our damage rules and return hitInfo.damageTypes.Scale(Rust.DamageType.Decay, multiplier); #if DEBUG Puts("OnEntityTakeDamage: END Set damage for " + entity_name + isblock + " to " + multiplier.ToString() + ", was " + before.ToString() + "."); #endif return(null); }
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { var tick = DateTime.Now; entity_name = entity.LookupPrefab().name; try { if (!hitInfo.damageTypes.Has(Rust.DamageType.Decay)) { return; } var block = entity as BuildingBlock; if (entity.LookupPrefab().name == "campfire" || entity.LookupPrefab().name == "skull_fire_pit") { ProcessCampfireDamage(hitInfo); } else if (entity.LookupPrefab().name == "box.wooden.large" || entity.LookupPrefab().name == "woodbox_deployed" || entity.LookupPrefab().name == "CoffinStorage") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_boxMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("deployed") || entity.LookupPrefab().name.Contains("reinforced") || entity.LookupPrefab().name.Contains("shopfront") || entity.LookupPrefab().name.Contains("bars") || entity.LookupPrefab().name.Contains("shutter") || entity.LookupPrefab().name.Contains("netting") || entity.LookupPrefab().name.Contains("door") || entity.LookupPrefab().name.Contains("hatch") || entity.LookupPrefab().name.Contains("garagedoor") || entity.LookupPrefab().name.Contains("cell") || entity.LookupPrefab().name.Contains("fence") || entity.LookupPrefab().name.Contains("grill") || entity.LookupPrefab().name.Contains("Candle") || entity.LookupPrefab().name.Contains("Strobe") || entity.LookupPrefab().name.Contains("speaker") || entity.LookupPrefab().name.Contains("Fog") || entity.LookupPrefab().name.Contains("Graveyard")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("furnace")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_furnaceMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("sedan")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_sedanMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "SAM_Static") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_samMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "HotAirBalloon") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_baloonMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "BBQ.Deployed") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_bbqMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("watchtower")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_watchtowerMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "WaterBarrel" || entity.LookupPrefab().name == "jackolantern.angry" || entity.LookupPrefab().name == "jackolantern.happy" || entity.LookupPrefab().name == "water_catcher_small" || entity.LookupPrefab().name == "water_catcher_large") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "beartrap" || entity.LookupPrefab().name == "landmine" || entity.LookupPrefab().name == "spikes.floor") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_trapMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("barricade")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_barricadeMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "gates.external.high.stone") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high stone gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "gates.external.high.wood") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high wood gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "wall.external.high.stone") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high stone wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "wall.external.high.wood") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high wood wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "mining.pumpjack") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, 0.0f); if (c_outputToRcon) { Puts($"Decay (pumpjack) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "Rowboat" || entity.LookupPrefab().name == "RHIB") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_boatMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (block != null) { ProcessBuildingDamage(block, hitInfo); } else { Puts($"Unsupported decaying entity detected: {entity.LookupPrefab().name} --- please notify author"); } } finally { var ms = (DateTime.Now - tick).TotalMilliseconds; if (ms > 10) { Puts($"NoDecay.OnEntityTakeDamage took {ms} ms to execute."); } } }
object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { if (!enabled) { return(null); } if (entity == null || hitInfo == null) { return(null); } if (!hitInfo.damageTypes.Has(Rust.DamageType.Decay)) { return(null); } float damageAmount = 0f; DateTime tick = DateTime.Now; string entity_name = entity.LookupPrefab().name; // Puts($"Decay Entity: {entity_name}"); string owner = entity.OwnerID.ToString(); bool mundane = false; bool isBlock = false; if (configData.Global.usePermission) { if (permission.UserHasPermission(owner, "nodecay.use") || owner == "0") { if (owner != "0") { OutputRcon($"{entity_name} owner {owner} has NoDecay permission!"); } } else { OutputRcon($"{entity_name} owner {owner} does NOT have NoDecay permission. Standard decay in effect."); return(null); } } if (configData.Global.protectedDays > 0 && entity.OwnerID > 0) { long lc = 0; lastConnected.TryGetValue(entity.OwnerID.ToString(), out lc); if (lc > 0) { long now = ToEpochTime(DateTime.UtcNow); float days = Math.Abs((now - lc) / 86400); if (days > configData.Global.protectedDays) { OutputRcon($"Allowing decay for owner offline for {configData.Global.protectedDays.ToString()} days"); return(null); } else { OutputRcon($"Owner was last connected {days.ToString()} days ago and is still protected..."); } } } try { float before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); if (entity is BuildingBlock) { if (configData.Global.useJPipes) { if ((bool)JPipes?.Call("IsPipe", entity)) { if ((bool)JPipes?.Call("IsNoDecayEnabled")) { OutputRcon("Found a JPipe with nodecay enabled"); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, 0f); return(null); } } } damageAmount = ProcessBuildingDamage(entity, before); isBlock = true; } else if (entity is ModularCar) { var garage = entity.GetComponentInParent <ModularCarGarage>(); if (garage != null && configData.Global.protectVehicleOnLift) { return(null); } } else { // Main check for non-building entities/deployables foreach (KeyValuePair <string, List <string> > entities in entityinfo) { //private Dictionary<string, List<string>> entityinfo = new Dictionary<string, List<string>>(); if (entities.Value.Contains(entity_name)) { OutputRcon($"Found {entity_name} listed in {entities.Key}"); if (configData.multipliers.ContainsKey(entities.Key)) { damageAmount = before * configData.multipliers[entities.Key]; break; } } } } // Check non-building entities for cupboard in range if (configData.Global.requireCupboard && configData.Global.cupboardCheckEntity && !isBlock) { // Verify that we should check for a cupboard and ensure that one exists. // If so, multiplier will be set to entityCupboardMultiplier. OutputRcon($"NoDecay checking for local cupboard.", mundane); if (CheckCupboardEntity(entity, mundane)) { damageAmount = before * configData.multipliers["entityCupboard"]; } } NextTick(() => { OutputRcon($"Decay ({entity_name}) before: {before} after: {damageAmount}, item health {entity.health.ToString()}", mundane); entity.health -= damageAmount; if (entity.health == 0 && configData.Global.DestroyOnZero) { OutputRcon($"Entity {entity_name} completely decayed - destroying!", mundane); if (entity == null) { return; } entity.Kill(BaseNetworkable.DestroyMode.Gib); } }); return(true); // Cancels this hook for any of the entities above unless unsupported (for decay only). } finally { double ms = (DateTime.Now - tick).TotalMilliseconds; if (ms > configData.Global.warningTime || configData.Debug.outputMundane) { Puts($"NoDecay.OnEntityTakeDamage on {entity_name} took {ms} ms to execute."); } } }
private void OnEntityDeath(BaseCombatEntity entity, HitInfo info) { if (entity == null) { return; } if (!Economics && !ServerRewards) { return; } if (!info?.Initiator?.ToPlayer()) { return; } var player = info.Initiator.ToPlayer(); var animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", "")); amount = 0; if (entity.ToPlayer() != null && !(entity is NPCPlayer)) { var victim = entity.ToPlayer(); if (player == victim) { return; } amount = config.Settings.Rewards[PluginRewards.Player]; animal = "player"; if (Friends && config.Settings.Rewards[PluginRewards.PlayerFriend] != 0) { bool isFriend = Friends.Call <bool>("HasFriend", victim.userID, player.userID); bool isFriendReverse = Friends.Call <bool>("HasFriend", player.userID, victim.userID); if (isFriend && isFriendReverse) { amount = config.Settings.Rewards[PluginRewards.PlayerFriend]; animal = "friend"; } } if (Clans && config.Settings.Rewards[PluginRewards.ClanMember] != 0) { string victimclan = Clans.Call <string>("GetClanOf", victim.userID); string playerclan = Clans.Call <string>("GetClanOf", player.userID); if (victimclan == playerclan) { amount = config.Settings.Rewards[PluginRewards.ClanMember]; animal = "clan member"; } } } else { if (entity is NPCMurderer) { animal = "Murderer"; config.Settings.Rewards.TryGetValue(animal, out amount); } else if (entity is NPCPlayerApex) { animal = "Scientist"; config.Settings.Rewards.TryGetValue(animal, out amount); } else if (entity.GetComponent("BaseNpc")) { animal = UppercaseFirst(entity.LookupPrefab().ToString().Replace("[0]", "")); config.Settings.Rewards.TryGetValue(animal, out amount); } } if (amount != 0) { GiveCredit(player, "kill", amount, animal); } }
private object OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitinfo) { if (!enabled) { return(null); } if (entity == null || hitinfo == null) { return(null); } float damageAmount = 0f; string entity_name = entity.LookupPrefab().name; ulong owner = entity.OwnerID; switch (hitinfo.damageTypes.GetMajorityDamageType().ToString()) { case "Decay": float before = hitinfo.damageTypes.Get(Rust.DamageType.Decay); damageAmount = before * configData.Global.DecayMultiplier; if (entity is BuildingBlock) { if ((bool)JPipes?.Call("IsPipe", entity) && (bool)JPipes?.Call("IsNoDecayEnabled")) { DoLog("Found a JPipe with nodecay enabled"); hitinfo.damageTypes.Scale(Rust.DamageType.Decay, 0f); return(null); } damageAmount = before * configData.Global.DecayMultiplier; } NextTick(() => { DoLog($"Decay ({entity_name}) before: {before} after: {damageAmount}, item health {entity.health.ToString()}"); entity.health -= damageAmount; if (entity.health == 0) { DoLog($"Entity {entity_name} completely decayed - destroying!"); if (entity == null) { return; } entity.Kill(BaseNetworkable.DestroyMode.Gib); } }); return(true); // Cancels this hook (for decay only). Decay handled on NextTick. default: if (configData.Global.EnablePVE) { try { object CanTakeDamage = Interface.CallHook("CanEntityTakeDamage", new object[] { entity, hitinfo }); if (CanTakeDamage != null && CanTakeDamage is bool && (bool)CanTakeDamage) { return(null); } } catch { } string source = hitinfo.Initiator?.GetType().Name; string target = entity?.GetType().Name; if (source == "BasePlayer" && target == "BasePlayer") { return(true); // Block player to player damage } if (source == "BasePlayer" && (target == "BuildingBlock" || target == "Door" || target == "wall.window")) { BasePlayer pl = hitinfo.Initiator as BasePlayer; if (pl != null && owner == pl.userID) { return(null); } // Block damage to non-owned building return(true); } } break; } return(null); }
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { DateTime tick = DateTime.Now; string entity_name = entity.LookupPrefab().name; string owner = entity.OwnerID.ToString(); if (c_usePermission) { if (permission.UserHasPermission(owner, "nodecay.use") || owner == "0") { if (owner != "0") { OutputRcon($"{entity_name} owner {owner} has NoDecay permission!"); } } else { OutputRcon($"{entity_name} owner {owner} does NOT have NoDecay permission. Standard decay in effect."); return; } } try { if (!hitInfo.damageTypes.Has(Rust.DamageType.Decay)) { return; } var block = entity as BuildingBlock; float before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); if (block != null) { ProcessBuildingDamage(block, entity, hitInfo); } else if (entity_name == "campfire" || entity_name == "skull_fire_pit") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_campfireMultiplier); OutputRcon($"Decay campfire before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "box.wooden.large" || entity_name == "woodbox_deployed" || entity_name == "CoffinStorage") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_boxMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name.Contains("deployed") || entity_name.Contains("reinforced") || entity_name.Contains("shopfront") || entity_name.Contains("bars") || entity_name.Contains("shutter") || entity_name.Contains("netting") || (entity_name.Contains("door") && !entity_name.Contains("doorway")) || entity_name.Contains("hatch") || entity_name.Contains("garagedoor") || entity_name.Contains("cell") || entity_name.Contains("fence") || entity_name.Contains("grill") || entity_name.Contains("Candle") || entity_name.Contains("Strobe") || entity_name.Contains("speaker") || entity_name.Contains("Fog") || entity_name.Contains("Graveyard")) { if (c_requireCupboard && c_CupboardEntity) { // Verify that we should check for a cupboard and ensure that one exists. // If not, multiplier will be standard of 1.0f. OutputRcon($"NoDecay checking for local cupboard."); if (CheckCupboard(entity)) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); } } else { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); } OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name.Contains("furnace")) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_furnaceMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name.Contains("sedan")) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_sedanMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "SAM_Static") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_samMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "HotAirBalloon") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_baloonMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}", true); } else if (entity_name == "BBQ.Deployed") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_bbqMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name.Contains("watchtower")) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_watchtowerMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "WaterBarrel" || entity_name == "jackolantern.angry" || entity_name == "jackolantern.happy" || entity_name == "water_catcher_small" || entity_name == "water_catcher_large") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "beartrap" || entity_name == "landmine" || entity_name == "spikes.floor") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_trapMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name.Contains("barricade")) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_barricadeMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "gates.external.high.stone") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); OutputRcon($"Decay (high stone gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "gates.external.high.wood") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); OutputRcon($"Decay (high wood gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "wall.external.high.stone") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); OutputRcon($"Decay (high stone wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "wall.external.high.wood") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); OutputRcon($"Decay (high wood wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "mining.pumpjack") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, 0.0f); OutputRcon($"Decay (pumpjack) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } else if (entity_name == "Rowboat" || entity_name == "RHIB") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_boatMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}", true); } else if (entity_name == "minicopter.entity") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_minicopterMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}", true); } else if (entity_name.Contains("TestRidableHorse")) { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_horseMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}", true); } else if (entity_name == "ScrapTransportHelicopter") { hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_scrapcopterMultiplier); OutputRcon($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}", true); } else { Puts($"Unsupported decaying entity detected: {entity_name} --- please notify author"); } } finally { double ms = (DateTime.Now - tick).TotalMilliseconds; if (ms > 10 || c_outputMundane) { Puts($"NoDecay.OnEntityTakeDamage on {entity_name} took {ms} ms to execute."); } } }
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { var started = DateTime.Now; try { if (hitInfo.damageTypes.Has(Rust.DamageType.Decay)) { var block = entity as BuildingBlock; if (block == null) { // Process deployables ProcessEntity(entity, hitInfo, config.DecayConfig.deployables, entity.LookupPrefab().name); } else if (block.grade == BuildingGrade.Enum.Twigs || block.grade == BuildingGrade.Enum.Wood || block.grade == BuildingGrade.Enum.Stone || block.grade == BuildingGrade.Enum.Metal || block.grade == BuildingGrade.Enum.TopTier) { // Process Twigs + all foundation types of higher tiers ProcessEntity(entity, hitInfo, config.DecayConfig.buildingBlocks, block.grade.ToString()); } } } finally { if (config.DeveloperDebug) { var ms = (DateTime.Now - started).TotalMilliseconds; if (ms > 10) { Puts($"OnEntityTakeDamage took {ms} ms to execute."); } } } }
void OnEntityTakeDamage(BaseCombatEntity entity, HitInfo hitInfo) { var tick = DateTime.Now; entity_name = entity.LookupPrefab().name; try { if (!hitInfo.damageTypes.Has(Rust.DamageType.Decay)) { return; } var block = entity as BuildingBlock; if (entity.LookupPrefab().name == "campfire") { ProcessCampfireDamage(hitInfo); } else if (entity.LookupPrefab().name == "box.wooden.large" || entity.LookupPrefab().name == "woodbox_deployed") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_boxMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("deployed")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("furnace")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_furnaceMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "WaterBarrel" || entity.LookupPrefab().name == "jackolantern.angry" || entity.LookupPrefab().name == "jackolantern.happy" || entity.LookupPrefab().name == "water_catcher_small" || entity.LookupPrefab().name == "water_catcher_large") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_deployablesMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "beartrap" || entity.LookupPrefab().name == "landmine" || entity.LookupPrefab().name == "spikes.floor") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_trapMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name.Contains("barricade")) { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_barricadeMultiplier); if (c_outputToRcon) { Puts($"Decay ({entity_name}) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "gates.external.high.stone") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high stone gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "gates.external.high.wood") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high wood gate) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "wall.external.high.stone") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highStoneWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high stone wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "wall.external.high.wood") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, c_highWoodWallMultiplier); if (c_outputToRcon) { Puts($"Decay (high wood wall) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (entity.LookupPrefab().name == "mining.pumpjack") { var before = hitInfo.damageTypes.Get(Rust.DamageType.Decay); hitInfo.damageTypes.Scale(Rust.DamageType.Decay, 0.0f); if (c_outputToRcon) { Puts($"Decay (pumpjack) before: {before} after: {hitInfo.damageTypes.Get(Rust.DamageType.Decay)}"); } } else if (block != null) { ProcessBuildingDamage(block, hitInfo); } else { Puts($"Unsupported decaying entity detected: {entity.LookupPrefab().name} --- please notify author"); } } finally { var ms = (DateTime.Now - tick).TotalMilliseconds; if (ms > 10) { Puts($"NoDecay.OnEntityTakeDamage took {ms} ms to execute."); } } }