//Miss overload void GunshotEffect(ScriptModelController missedModel) { //Shoot projectile randomly GameObject hotProj = Instantiate(bulletPrefab, transform.position, transform.rotation) as GameObject; hotProj.transform.parent = junkContainer.transform; Vector3 attackVector = (missedModel.gameObject.transform.position ) + new Vector3(0, (Random.value - 0.5F) * 4, (Random.value - 0.5F) * 4) //Magic numbers - projectileSpawn.position; hotProj.GetComponent <Rigidbody>().AddForce(attackVector * projectileSpeed); //Sound effect gunSound.Play(); //Muzzle Flash hotFlash = Instantiate(muzzleFlashPrefab, transform.position, transform.rotation) as GameObject; StartCoroutine("EndFlash"); }
void DecapitateModel(ScriptModelController targetCharacter, int damage) { //Instantiate(bloodLeak, targetCharacter.spine.transform.FindChild("spineBox1")); }
public void InitiateActionEffect(Result result) { //Reset "local" variables propelVector = Vector3.zero; partIsDestroyed = false; //For all damage, if limb is broken, spurt blood and dismember. If not, spurt blood only //Get attack direction rangedAttack = result.actingCharacter. GetComponentInChildren <ScriptControllerTargeting> ().rangedAttack; rangedAttack.Normalize(); //Debug.Log(result.targetNetHitProfile.head.ToString() + result.targetNetHitProfile.body.ToString() + // result.targetNetHitProfile.leftArm.ToString() + result.targetNetHitProfile.rightArm.ToString() + // result.targetNetHitProfile.leftLeg.ToString() + result.targetNetHitProfile.rightLeg.ToString()); //Upon successful attack if (result.success) { ScriptModelController targetModelController = result.targetCharacter. GetComponentInChildren <ScriptModelController> (); //Ragdoll entire character if dead if (!result.targetCharacter.inPlay) { Ragdollify(result.targetCharacter.gameObject); } GameObject modelPart = null; //If damage is inflicted on body part and that body part is destroyed if (result.targetNetHitProfile.head < 0) { //Assign execution variables modelPart = targetModelController.head; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.head * propelForceConstant; if (result.targetCharacter.currentHitProfile.head <= 0) { partIsDestroyed = true; } } if (result.targetNetHitProfile.body < 0) { modelPart = targetModelController.spine; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.body * propelForceConstant; if (result.targetCharacter.currentHitProfile.body <= 0) { partIsDestroyed = true; } } if (result.targetNetHitProfile.leftArm < 0) { modelPart = targetModelController.leftArm; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.leftArm * propelForceConstant; if (result.targetCharacter.currentHitProfile.leftArm <= 0) { partIsDestroyed = true; } } if (result.targetNetHitProfile.rightArm < 0) { modelPart = targetModelController.rightArm; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.rightArm * propelForceConstant; if (result.targetCharacter.currentHitProfile.rightArm <= 0) { partIsDestroyed = true; } } if (result.targetNetHitProfile.leftLeg < 0) { modelPart = targetModelController.leftLeg; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.leftLeg * propelForceConstant; if (result.targetCharacter.currentHitProfile.leftLeg <= 0) { partIsDestroyed = true; } } if (result.targetNetHitProfile.rightLeg < 0) { modelPart = targetModelController.rightLeg; propelVector = rangedAttack * -result.targetCharacter.currentHitProfile.rightLeg * propelForceConstant; if (result.targetCharacter.currentHitProfile.rightLeg <= 0) { partIsDestroyed = true; } } //Assign struckBox randomly based on model part (if not already assigned by alpha) if (result.playerShotInfo.shotLocation == null) { result.playerShotInfo.shotLocation = modelPart.transform.GetChild((int)Mathf.Floor(Random.value * modelPart.transform.childCount)).gameObject; } //Fire weapon at target's part if there is a struckBox if (result.playerShotInfo.shotLocation) { result.actingCharacter.GetComponentInChildren <ScriptModelController> ().weapon.GetComponent <ScriptWeapon> ().SendMessage("GunshotEffect", result.playerShotInfo.shotLocation); //Debug.Log(struckBox.name); } else { Debug.Log("struckBox requested but not assigned"); } // hotSheet.gameObject.GetComponentInChildren<ScriptModelController>().SendMessage("WeaponEffect"); //Dismember if destroyed if (partIsDestroyed) { // Ragdollify (modelPart); // BreakJoints (result.playerShotInfo.shotLocation); // print ("propel vector, model part: " + propelVector +", " + modelPart); // Propel (propelVector, modelPart); // modelPart.transform.parent = junkContainer; } //Spurt blood //GameObject bloodBox = breakBox; //targetModelController.spine.transform.FindChild("spineBox1").gameObject; GameObject hotLeak = Instantiate(bloodLeak, result.playerShotInfo.shotLocation.transform.position, result.playerShotInfo.shotLocation.transform.rotation) as GameObject; hotLeak.transform.parent = result.playerShotInfo.shotLocation.transform; } else if (result.success == false) { //Fire weapon straight ahead result.actingCharacter.GetComponentInChildren <ScriptModelController> (). weapon.SendMessage("GunshotEffect", result.playerShotInfo.shotRay); //natural shot ray } else { Debug.Log("Something went horribly wrong"); } }