public override int ReceiveAndCalculateDamage(GameObject damagedBy, int damage, DamageType damageType, BodyPartType bodyPartAim) { base.ReceiveAndCalculateDamage(damagedBy, damage, damageType, bodyPartAim); BodyPartBehaviour bodyPart = findBodyPart(bodyPartAim); //randomise a bit here? bodyPart.ReceiveDamage(damageType, damage); if (isServer) { int bloodLoss = (int)(damage * BleedFactor(damageType)); LoseBlood(bloodLoss); // don't start bleeding if limb is in ok condition after it received damage switch (bodyPart.Severity) { case DamageSeverity.Moderate: case DamageSeverity.Bad: case DamageSeverity.Critical: AddBloodLoss(bloodLoss); break; } if (headCritical(bodyPart)) { Crit(); } } return(damage); }
/// placeholder based on old code public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart) { foreach (var listener in UIManager.Instance.GetComponentsInChildren <DamageMonitorListener>()) { if (listener.bodyPartType != bodyPart.Type) { continue; } Sprite sprite; switch (bodyPart.Severity) { case DamageSeverity.None: sprite = bodyPart.GreenDamageMonitorIcon; break; case DamageSeverity.Moderate: sprite = bodyPart.YellowDamageMonitorIcon; break; case DamageSeverity.Bad: sprite = bodyPart.OrangeDamageMonitorIcon; break; case DamageSeverity.Critical: sprite = bodyPart.RedDamageMonitorIcon; break; default: sprite = bodyPart.GrayDamageMonitorIcon; break; } listener.GetComponent <Image>().sprite = sprite; } }
/// <summary> /// Determine if there is any blood damage (toxin, oxygen loss) or bleeding that needs to occur /// Server only! /// </summary> public void AffectBloodState(BodyPartType bodyPartType, DamageType damageType, float amount, bool isHeal = false) { BodyPartBehaviour bodyPart = livingHealthBehaviour.FindBodyPart(bodyPartType); if (isHeal) { CheckHealing(bodyPart, damageType, amount); return; } //Check if limb should start bleeding (Bleeding is only for Players, not animals) if (damageType == DamageType.Brute) { int bloodLoss = (int)(Mathf.Clamp(amount, 0f, 10f) * BleedFactor(damageType)); // start bleeding if the limb is really damaged if (bodyPart.BruteDamage > 40) { AddBloodLoss(bloodLoss, bodyPart); } } if (damageType == DamageType.Tox) { ToxinLevel += amount; } }
public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam) { if (actionType == InteractionAction.InteractionActionType.BounceOff) { rigidBody.AddForce((from.transform.position - transform.position).normalized * -1 * pushOffForceRatio, ForceMode2D.Force); rigidBody.velocity = Vector2.ClampMagnitude(rigidBody.velocity, maximumSpeed); } }
/// <summary> /// Subtract an amount of blood from the player. Server Only /// </summary> public void AddBloodLoss(int amount, BodyPartBehaviour bodyPart) { if (amount <= 0) { return; } TryBleed(bodyPart); }
public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam) { if (actionType == InteractionAction.InteractionActionType.Destroy) { Instantiate(destroyParticleEffect, transform.position, Quaternion.identity); Destroy(gameObject); } }
private void TryBleed(BodyPartBehaviour bodyPart) { bodyPart.isBleeding = true; //don't start another coroutine when already bleeding if (!IsBleeding) { IsBleeding = true; } }
private void ServerApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); stackable.ServerConsume(1); HealthBodyPartMessage.Send(targetBodyPart.livingHealthBehaviour.gameObject, targetBodyPart.livingHealthBehaviour.gameObject, targetBodyPart.Type, targetBodyPart.livingHealthBehaviour.GetTotalBruteDamage(), targetBodyPart.livingHealthBehaviour.GetTotalBurnDamage()); }
/// <summary> /// Stops bleeding on all bodyparts. Server Only. /// </summary> public void StopBleedingAll() { for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++) { BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i]; BPB.isBleeding = false; } IsBleeding = false; }
private void ApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); amount--; if (amount == 0) { DisappearObject(); } }
private void ApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); amount--; if (amount == 0) { GetComponent <CustomNetTransform>().DisappearFromWorldServer(); } }
private void ServerSelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart) { void ProgressComplete() { ServerApplyHeal(targetBodyPart); } StandardProgressAction.Create(ProgressConfig, ProgressComplete) .ServerStartProgress(originator.RegisterTile(), 5f, originator); }
private void ApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); timesUsed++; Logger.LogTraceFormat("{0} uses left.", Category.Health, uses - timesUsed); if (uses == timesUsed) { GetComponent <CustomNetTransform>().DisappearFromWorldServer(); } }
private void ApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); timesUsed++; Logger.LogTraceFormat("{0} uses left.", Category.Health, uses - timesUsed); if (uses == timesUsed) { Despawn.ServerSingle(gameObject); } }
public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam) { if (actionType == InteractionAction.InteractionActionType.SuckToMe) { rigidBody.AddForce((from.transform.position - transform.position).normalized * suckForceRatio, ForceMode2D.Force); rigidBody.velocity = Vector2.ClampMagnitude(rigidBody.velocity, maximumSpeed); if (Vector2.SqrMagnitude(transform.position - from.transform.position) <= 1f) { Destroy(gameObject); } } }
/// <summary> /// Stops bleeding on the selected bodypart. The bloodsystem continues bleeding if there's another bodypart bleeding. Server Only. /// </summary> public void StopBleeding(BodyPartBehaviour bodyPart) { bodyPart.isBleeding = false; for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++) { BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i]; if (BPB.isBleeding) { return; } } IsBleeding = false; }
/// <summary> /// Update the PlayerHealth body part hud icon /// </summary> /// <param name="bodyPart"> Body part that requires updating </param> public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart) { for (int i = 0; i < bodyPartListeners.Count; i++) { if (bodyPartListeners[i].bodyPartType != bodyPart.Type) { continue; } if (bodyPartListeners[i] != null) { Color damageColor; Color bodyPartColor = Color.white; switch (bodyPart.Severity) { case DamageSeverity.None: damageColor = damageMonitorColors[0]; break; case DamageSeverity.Light: damageColor = damageMonitorColors[1]; break; case DamageSeverity.LightModerate: damageColor = damageMonitorColors[2]; break; case DamageSeverity.Moderate: damageColor = damageMonitorColors[3]; break; case DamageSeverity.Bad: damageColor = damageMonitorColors[4]; break; case DamageSeverity.Critical: damageColor = damageMonitorColors[5]; bodyPartColor = disabledBodyPartColor; break; case DamageSeverity.Max: default: damageColor = damageMonitorColors[6]; bodyPartColor = destroyedBodyPartColor; break; } bodyPartListeners[i].SetDamageColor(damageColor); bodyPartListeners[i].SetBodyPartColor(bodyPartColor); } } }
/// <summary> /// Update the PlayerHealth body part hud icon /// </summary> /// <param name="bodyPart"> Body part that requires updating </param> public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart) { for (int i = 0; i < bodyPartListeners.Count; i++) { if (bodyPartListeners[i].bodyPartType != bodyPart.Type) { continue; } Sprite sprite; switch (bodyPart.Severity) { case DamageSeverity.None: sprite = bodyPart.BlueDamageMonitorIcon; break; case DamageSeverity.Light: sprite = bodyPart.GreenDamageMonitorIcon; break; case DamageSeverity.LightModerate: sprite = bodyPart.YellowDamageMonitorIcon; break; case DamageSeverity.Moderate: sprite = bodyPart.OrangeDamageMonitorIcon; break; case DamageSeverity.Bad: sprite = bodyPart.DarkOrangeDamageMonitorIcon; break; case DamageSeverity.Critical: sprite = bodyPart.RedDamageMonitorIcon; break; case DamageSeverity.Max: default: sprite = bodyPart.GrayDamageMonitorIcon; break; } if (sprite != null && bodyPartListeners[i] != null && bodyPartListeners[i].image != null) { bodyPartListeners[i].image.sprite = sprite; } } }
/// <summary> /// Where the blood pumping action happens /// </summary> void PumpBlood() { if (IsBleeding) { float bleedVolume = 0; for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++) { BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i]; if (BPB.isBleeding) { bleedVolume += (BPB.BruteDamage * 0.013f); } } LoseBlood(bleedVolume); } //TODO things that could affect heart rate, like low blood, crit status etc }
/// <summary> /// Determine if there is any blood damage (toxin, oxygen loss) or bleeding that needs to occur /// Server only! /// </summary> public void AffectBloodState(BodyPartType bodyPartType, DamageType damageType, float amount, bool isHeal = false) { BodyPartBehaviour bodyPart = livingHealthBehaviour.FindBodyPart(bodyPartType); if (isHeal) { CheckHealing(bodyPart, damageType, amount); return; } //Check if limb should start bleeding (Bleeding is only for Players, not animals) if (damageType == DamageType.Brute) { int bloodLoss = (int)(Mathf.Clamp(amount, 0f, 10f) * BleedFactor(damageType)); // don't start bleeding if limb is in ok condition after it received damage switch (bodyPart.Severity) { case DamageSeverity.Light: case DamageSeverity.LightModerate: case DamageSeverity.Moderate: case DamageSeverity.Bad: case DamageSeverity.Critical: LoseBlood(bloodLoss); AddBloodLoss(bloodLoss); break; default: //For particularly powerful hits when a body part is fine if (amount > 40) { LoseBlood(bloodLoss); AddBloodLoss(bloodLoss); } break; } } if (damageType == DamageType.Tox) { ToxinLevel += amount; } }
private void SelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart) { if (!isSelfHealing) { var progressFinishAction = new FinishProgressAction( reason => { if (reason == FinishProgressAction.FinishReason.INTERRUPTED) { isSelfHealing = false; } else if (reason == FinishProgressAction.FinishReason.COMPLETED) { ApplyHeal(targetBodyPart); isSelfHealing = false; } } ); isSelfHealing = true; UIManager.ProgressBar.StartProgress(originator.transform.position.RoundToInt(), 5f, progressFinishAction, originator); } }
//Do any healing stuff: private void CheckHealing(BodyPartBehaviour bodyPart, DamageType damageType, float healAmt) { //TODO: PRIORITY! Do Blood healing! Logger.Log("Not implemented: Blood healing.", Category.Health); }
private static void Bleed(PlayerScript ps, TortureSeverity severity) { BodyPartBehaviour bodyPart = ps.playerHealth.FindBodyPart(BodyPartType.Chest); ps.playerHealth.bloodSystem.AddBloodLoss(( int )Mathf.Pow(2, ( float )severity), bodyPart); }
private void SelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart) { var progressFinishAction = new ProgressCompleteAction(() => ApplyHeal(targetBodyPart)); UIManager.ServerStartProgress(ProgressAction.SelfHeal, originator.transform.position.RoundToInt(), 5f, progressFinishAction, originator); }
public abstract void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam);
private void ServerApplyHeal(BodyPartBehaviour targetBodyPart) { targetBodyPart.HealDamage(40, healType); stackable.ServerConsume(1); }
//Do any healing stuff: private void CheckHealing(BodyPartBehaviour bodyPart, DamageType damageType, int healAmt) { Debug.Log("TODO PRIORITY: Do Blood Healing!!"); }
private static bool headCritical(BodyPartBehaviour bodyPart) { return(bodyPart.Type.Equals(BodyPartType.HEAD) && bodyPart.Severity == DamageSeverity.Critical); }