// /mob/living/carbon/take_overall_damage(brute, burn, updating_health = 1) // damage MANY bodyparts, in random order public override void TakeOverallDamage(int brute, int burn, bool updatingHealth) { Debug.Log("Carbon TakeOverallDamage"); if ((StatusFlags & MobStatusFlag.GODMODE) != 0) { return; // GODMODE } bool update = true; List <int> indexes = new List <int>(); for (int i = 0; i < BodyParts.Count; i++) { indexes.Add(i); } indexes = indexes.Shuffle <int>().ToList <int>(); foreach (int i in indexes) { if (brute < 0 && burn < 0) { break; } BodyPart picked = BodyParts[i].GetComponent <BodyPart>(); int brutePerPart = (int)DMMath.Round(brute / indexes.Count, 0.01); int burnPerPart = (int)DMMath.Round(burn / indexes.Count, 0.01); int bruteWas = picked.BruteDamage; int burnWas = picked.BurnDamage; bool tmpUpdate = picked.ReceiveDamage <Carbon>(brutePerPart, burnPerPart, false); if (update != true) { update = tmpUpdate; } brute -= (picked.BruteDamage - bruteWas); burn -= (picked.BurnDamage - burnWas); } if (updatingHealth) { UpdateHealth(); } // TODO: Damage overlays if (update) { UpdateDamageOverlays(); } }
private static string GenerateButtonText(CraftingRecipe craftingRecipe) { if (craftingRecipe.CraftingTime.Approx(0)) { return("Craft"); } StringBuilder stringBuilder = new StringBuilder(); return(stringBuilder .Append("Craft (") .Append(DMMath.Round(craftingRecipe.CraftingTime, 0.1)) .Append(" sec.)").ToString()); }
// See receive_damage in body_parts.dm // This is as close as possible to the original definition public bool ReceiveDamage <T>(int brute, int burn, bool updatingHealth = true) where T : Living { //Debug.Log(this.gameObject.name + " received damage brute: " + brute + " burn: " + burn); T owner = this.GetComponentInParent <T>(); if (owner != null && ((owner.StatusFlags & MobStatusFlag.GODMODE) != 0)) { return(false); //godmode } // TODO support damage multipliers int[] bruteArr = { brute, 0 }; brute = bruteArr.Max(); int[] burnArr = { burn, 0 }; burn = burnArr.Max(); int canInflict = MaxDamage - (BruteDamage + BurnDamage); if (canInflict <= 0) { return(false); } if ((brute + burn) < canInflict) { //Debug.Log(this.gameObject.name + " applying Damage brute: " + brute + " burn: " + burn); BruteDamage += brute; BurnDamage += burn; } else { if (brute > 0) { if (burn > 0) { brute = (int)DMMath.Round((brute / (brute + burn)) * canInflict, 1); burn = canInflict - brute; //gets whatever damage is left over BruteDamage += brute; BurnDamage += burn; } else { BruteDamage += canInflict; } } else { if (burn > 0) { BurnDamage += canInflict; } else { Debug.Log(this.gameObject.name + " received no damage"); return(false); } } } if (owner != null && updatingHealth) { owner.UpdateHealth(); } return(true); }