public void GetHit(StatesManager s, RuntimeWeapon c, HitPosition hp) { HumanBodyBones t = HumanBodyBones.Chest; if (hp != null) { t = hp.bone; } float baseDamage = c.stats.GetDamage(); //float baseDamage = 25; switch (t) { case HumanBodyBones.Head: anim.Play("damage 2"); baseDamage *= 2; baseDamage += Random.Range(-5, 5); break; case HumanBodyBones.Chest: anim.Play("damage 2"); baseDamage += Random.Range(-12, 12); break; case HumanBodyBones.LeftUpperArm: baseDamage *= .5f; anim.Play("damage 1"); baseDamage += Random.Range(-12, 12); break; case HumanBodyBones.RightUpperArm: baseDamage *= .5f; anim.Play("damage 1"); baseDamage += Random.Range(-12, 12); break; } health -= Mathf.RoundToInt(baseDamage); if (health < 0) { a_hook.enabled = false; StartCoroutine(EnableRagdoll_AfterDelay(.1f)); states.isDead = true; } }
void HandleDamage(RaycastHit h, RuntimeWeapon c, Vector3 d) { Rigidbody rigid = h.transform.GetComponent <Rigidbody>(); if (rigid != null) { if (!rigid.isKinematic) { rigid.AddForceAtPosition(d * 20, h.point, ForceMode.Impulse); } } StatesManager st = h.transform.GetComponentInParent <StatesManager>(); if (st != null) { if (st != this) { if (st.states.isDead) { return; } HitPosition hitPos = h.transform.GetComponent <HitPosition>(); GameObject p = objPool.RequestObject("BloodSplat_FX"); p.transform.position = h.point; st.GetHit(this, c, hitPos); } } else { GameObject p = objPool.RequestObject("bullet_hit"); p.transform.position = h.point; p.transform.LookAt(a_hook.aimPivot.position); } }