private void SlipIntoShock() { string line = "<color=red>" + gameObject.name + " is experiencing shock from loss of blood!</color>"; BattleReport.AddToBattleReport(line); stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.InShock, 30f); }
private void VomitCheck(int severity) { if (severity >= vomitThreshold) { if (UnityEngine.Random.Range(0, 100) > myCombatSkills.statusResistance / (severity + 1)) { stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.Vomitting, severity + 1); string line = "<color=blue>The injury causes " + gameObject.name + " to vomit!</color>"; BattleReport.AddToBattleReport(line); } } }
private void DownedCheck(int severity) { if (severity >= downedThreshold) { if (UnityEngine.Random.Range(0, 100) > myCombatSkills.statusResistance / (severity + 1)) { stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.Downed, severity + 1); string line = "<color=blue>" + gameObject.name + " is knocked to the ground!</color>"; BattleReport.AddToBattleReport(line); } } }
private void KnockoutCheck(int severity) { int multiplier = 10; // * severityLevel to get time knocked out if (severity >= knockoutThreshold) { if (UnityEngine.Random.Range(0, 100) > myCombatSkills.statusResistance / (severity + 1)) { int duration = severity * multiplier; myBody.unconscious = true; stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.Unconscious, duration); string line = "<color=blue>" + gameObject.name + " has been knocked unconscious by the attack!</color>"; BattleReport.AddToBattleReport(line); } } }
private void Attack() { AttackInfo myAttack; AttackTimer attackTimer = usm.attackTimer; BodyPartController myBody = usm.bodyController; CombatSkills mySkills = usm.combatSkills; if (Random.Range(0, 100) <= 75) { if (!myBody.PartTooInjured(attack1Parts)) { AttackAnimation(); myAttack = mySkills.RequestAttackInfo(attack1Parts[0].MyWeapon()); } else { string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack1Parts[0].MyWeapon().name + "</color>"; FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red); BattleReport.AddToBattleReport(line); attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack //unit reactions -> run away if not player? return; } } else { if (!myBody.PartTooInjured(attack2Parts)) { AttackAnimation(); myAttack = mySkills.RequestAttackInfo(attack2Parts[0].MyWeapon()); } else { string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack2Parts[0].MyWeapon().name + "</color>"; FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red); BattleReport.AddToBattleReport(line); attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack //unit reactions -> run away if not player? return; } } Debug.Log(gameObject.name + " attacking with reset timer of " + myAttack.speed); targetBody.RecieveAttack(myAttack, transform); //should reset back to whatever weapon was used attackTimer.ResetAttackTimer(myAttack.speed); }
public void TakeDamage(AttackInfo recievedAttack) { DamageInfo damageInfo = DetermineSeverityLevel(recievedAttack); int severity = damageInfo.severityLevel; string line; if (severity >= 0) { if (severity > currentSeverityLevel) { currentSeverityLevel = severity; if (dollPart != null) { dollPart.SeverityColor(severity); } } string log; if (dollPart != null) { //Debug.Log(gameObject.name + " is logging for " + damageInfo.damageType + " damage!"); log = dollPart.LogInjury(severity, damageInfo.damageType); } string unitName = gameObject.name; string injuryString = GetInjuryString(damageInfo.damageType, severity); if (injuryString == null) { Debug.LogError("injury string is null for " + damageInfo.damageType.ToString() + " severity " + severity); } line = string.Format(injuryString, unitName, damageInfo.weaponName, damageInfo.attackerName); string[] filters = new string[] { gameObject.name, damageInfo.attackerName }; BattleReport.AddToBattleReport(line, filters); StatusChecks(severity); Bleed(damageInfo); } else { line = recievedAttack.attackerName + " 's " + recievedAttack.weapon.name + " does no damage to " + gameObject.name + "'s " + name; ReportFilter.AddToFilterList(gameObject.name); ReportFilter.AddToFilterList(damageInfo.attackerName); BattleReport.AddToBattleReport(line); } }
private bool Hit() { if (Incapacitated()) { return(true); } if (Random.Range(0, 100) <= attackReaction.dodge) { string line = "<color=blue>" + gameObject.name + " dodged the attack!</color>"; FloatingTextController.CreateFloatingText("Dodge", transform, Color.blue); anim.Dodge(); mySkills.ExperienceGain(CombatSkills.CombatSkill.Dodge, 50f); ReportFilter.AddToFilterList(gameObject.name); BattleReport.AddToBattleReport(line); return(false); } else if (Random.Range(0, 100) <= attackReaction.block) { string line = "<color=blue>" + gameObject.name + " blocked the attack!</color>"; FloatingTextController.CreateFloatingText("Block", transform, Color.blue); anim.Block(); mySkills.ExperienceGain(CombatSkills.CombatSkill.Block, 50f); ReportFilter.AddToFilterList(gameObject.name); BattleReport.AddToBattleReport(line); return(false); } else if (Random.Range(0, 100) <= attackReaction.parry) { string line = "<color=blue>" + gameObject.name + " parried the attack!</color>"; FloatingTextController.CreateFloatingText("Parry", transform, Color.blue); anim.Parry(); mySkills.ExperienceGain(CombatSkills.CombatSkill.Parry, 50f); GetComponent <AttackTimer>().ResetAttackTimer(0f); //allow unit to retaliate immediately ReportFilter.AddToFilterList(gameObject.name); BattleReport.AddToBattleReport(line); return(false); } return(true); }
private void CantBreathCheck(int severity) { if (severity >= cantBreathThreshold) { if (severity >= suffocationThreshold && !myBody.suffocating) //if the injury was bad enough and not already suffocating { myBody.suffocating = true; string line = "<color=red>" + gameObject.name + " is suffocating!</color>"; BattleReport.AddToBattleReport(line); stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.Suffocating, 30f); return; //don't do cantBreath check } if (UnityEngine.Random.Range(0, 100) > myCombatSkills.statusResistance / (severity + 1)) { string line = "<color=blue>" + gameObject.name + " is struggling to breathe!</color>"; BattleReport.AddToBattleReport(line); stateMachine.TriggerTemporaryState(IncapacitatedState.TemporaryState.CantBreathe, severity + 1); } } }
public virtual void RecieveAttack(AttackInfo recievedAttack, Transform myAttacker) { //don't keep reacting to the same attack if (stateMachine.currentState != StateMachine.States.Fight || stateMachine.currentState != StateMachine.States.Flight || stateMachine.currentState != StateMachine.States.FightOrFlight) { stateMachine.currentThreat = myAttacker; stateMachine.RequestChangeState(StateMachine.States.FightOrFlight); } if (Hit()) { BodyPart bodyPart = GetRandomPart(); bodyPart.TakeDamage(recievedAttack); } if (PartTooInjured(vitalParts)) { stateMachine.RequestChangeState(StateMachine.States.Dead); string line = "<color=red>" + gameObject.name + " has been mortally wounded!</color>"; BattleReport.AddToBattleReport(line); } }