private void OnTriggerEnter2D(Collider2D coll) { LivingHealthBehaviour damageable = coll.GetComponent <LivingHealthBehaviour>(); //only harm others if it's not a suicide if (coll.gameObject == shooter && !isSuicide) { return; } //only harm the shooter if it's a suicide if (coll.gameObject != shooter && isSuicide) { return; } if (damageable == null || damageable.IsDead) { return; } var aim = isSuicide ? bodyAim : bodyAim.Randomize(); damageable.ApplyDamage(shooter, damage, damageType, aim); PostToChatMessage.SendItemAttackMessage(weapon.gameObject, shooter, coll.gameObject, damage, aim); Logger.LogTraceFormat("Hit {0} for {1} with HealthBehaviour! bullet absorbed", Category.Firearms, damageable.gameObject.name, damage); ReturnToPool(); }
private IEnumerator CritHonk(PositionalHandApply clickData, LivingHealthBehaviour targetHealth) { yield return(WaitFor.Seconds(0.02f)); SoundManager.PlayNetworkedAtPos(Sound, gameObject.AssumedWorldPosServer(), -1f, true, true, 20, 5); targetHealth.ApplyDamage(clickData.Performer, CritDamage, AttackType.Energy, DamageType.Brute, BodyPartType.Head); }
private void AttackFlesh(Vector2 dir, LivingHealthBehaviour healthBehaviour) { healthBehaviour.ApplyDamage(gameObject, hitDamage, AttackType.Melee, DamageType.Brute, defaultTarget); Chat.AddAttackMsgToChat(gameObject, healthBehaviour.gameObject, defaultTarget, null, attackVerb); SoundManager.PlayNetworkedAtPos("BladeSlice", transform.position); ServerDoLerpAnimation(dir); }
private void DamageOnClose() { var healthBehaviours = matrix.Get <LivingHealthBehaviour>(registerTile.Position); for (var i = 0; i < healthBehaviours.Count; i++) { LivingHealthBehaviour healthBehaviour = healthBehaviours[i]; healthBehaviour.ApplyDamage(gameObject, 500, DamageType.Brute); } }
private void ApplyDamage(float amount, DamageType damageType) { livingHealthBehaviour.ApplyDamage(null, amount, AttackType.Internal, damageType); }
private void ApplyDamage(float amount, DamageType damageType) { livingHealthBehaviour.ApplyDamage(null, amount, damageType); }
public void CmdRequestMeleeAttack(GameObject victim, GameObject weapon, Vector2 stabDirection, BodyPartType damageZone, LayerType layerType) { if (!playerMove.allowInput || playerScript.IsGhost || !victim || !playerScript.playerHealth.serverPlayerConscious ) { return; } if (!allowAttack) { return; } ItemAttributes weaponAttr = weapon.GetComponent <ItemAttributes>(); // If Tilemap LayerType is not None then it is a tilemap being attacked if (layerType != LayerType.None) { var tileChangeManager = victim.GetComponent <TileChangeManager>(); if (tileChangeManager == null) { return; //Make sure its on a matrix that is destructable } //Tilemap stuff: var tileMapDamage = victim.GetComponentInChildren <MetaTileMap>().Layers[layerType].gameObject .GetComponent <TilemapDamage>(); if (tileMapDamage != null) { //Wire cutters should snip the grills instead: if (weaponAttr.itemName == "wirecutters" && tileMapDamage.Layer.LayerType == LayerType.Grills) { tileMapDamage.WireCutGrill((Vector2)transform.position + stabDirection); StartCoroutine(AttackCoolDown()); return; } tileMapDamage.DoMeleeDamage((Vector2)transform.position + stabDirection, gameObject, (int)weaponAttr.hitDamage); playerMove.allowInput = false; RpcMeleeAttackLerp(stabDirection, weapon); StartCoroutine(AttackCoolDown()); return; } return; } //This check cannot be used with TilemapDamage as the transform position is always far away if (!playerScript.IsInReach(victim, true)) { return; } // Consider moving this into a MeleeItemTrigger for knifes //Meaty bodies: LivingHealthBehaviour victimHealth = victim.GetComponent <LivingHealthBehaviour>(); if (victimHealth != null && victimHealth.IsDead && weaponAttr.itemType == ItemType.Knife) { if (victim.GetComponent <SimpleAnimal>()) { SimpleAnimal attackTarget = victim.GetComponent <SimpleAnimal>(); RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; attackTarget.Harvest(); SoundManager.PlayNetworkedAtPos("BladeSlice", transform.position); } else { PlayerHealth attackTarget = victim.GetComponent <PlayerHealth>(); RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; attackTarget.Harvest(); SoundManager.PlayNetworkedAtPos("BladeSlice", transform.position); } } if (victim != gameObject) { RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; } var integrity = victim.GetComponent <Integrity>(); if (integrity != null) { //damaging an object integrity.ApplyDamage((int)weaponAttr.hitDamage, AttackType.Melee, weaponAttr.damageType); } else { //damaging a living thing victimHealth.ApplyDamage(gameObject, (int)weaponAttr.hitDamage, AttackType.Melee, weaponAttr.damageType, damageZone); } SoundManager.PlayNetworkedAtPos(weaponAttr.hitSound, transform.position); if (weaponAttr.hitDamage > 0) { Chat.AddAttackMsgToChat(gameObject, victim, damageZone, weapon); } StartCoroutine(AttackCoolDown()); }
public void CmdRequestMeleeAttack(GameObject victim, string slot, Vector2 stabDirection, BodyPartType damageZone, LayerType layerType) { if (!playerMove.allowInput || playerMove.isGhost || !victim || !playerScript.playerNetworkActions.SlotNotEmpty(slot) || !playerScript.playerHealth.serverPlayerConscious ) { return; } if (!allowAttack) { return; } var weapon = playerScript.playerNetworkActions.Inventory[slot].Item; ItemAttributes weaponAttr = weapon.GetComponent <ItemAttributes>(); // If Tilemap LayerType is not None then it is a tilemap being attacked if (layerType != LayerType.None) { TileChangeManager tileChangeManager = victim.GetComponent <TileChangeManager>(); MetaTileMap metaTileMap = victim.GetComponentInChildren <MetaTileMap>(); if (tileChangeManager == null) { return; } //Tilemap stuff: var tileMapDamage = metaTileMap.Layers[layerType].GetComponent <TilemapDamage>(); if (tileMapDamage != null) { //Wire cutters should snip the grills instead: if (weaponAttr.itemName == "wirecutters" && tileMapDamage.Layer.LayerType == LayerType.Grills) { tileMapDamage.WireCutGrill((Vector2)transform.position + stabDirection); StartCoroutine(AttackCoolDown()); return; } tileMapDamage.DoMeleeDamage((Vector2)transform.position + stabDirection, gameObject, (int)weaponAttr.hitDamage); playerMove.allowInput = false; RpcMeleeAttackLerp(stabDirection, weapon); StartCoroutine(AttackCoolDown()); return; } return; } //This check cannot be used with TilemapDamage as the transform position is always far away if (!playerScript.IsInReach(victim)) { return; } //Meaty bodies: LivingHealthBehaviour victimHealth = victim.GetComponent <LivingHealthBehaviour>(); if (victimHealth.IsDead && weaponAttr.type == ItemType.Knife) { if (victim.GetComponent <SimpleAnimal>()) { SimpleAnimal attackTarget = victim.GetComponent <SimpleAnimal>(); RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; attackTarget.Harvest(); SoundManager.PlayNetworkedAtPos("BladeSlice", transform.position); } else { PlayerHealth attackTarget = victim.GetComponent <PlayerHealth>(); RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; attackTarget.Harvest(); SoundManager.PlayNetworkedAtPos("BladeSlice", transform.position); } return; } if (victim != gameObject) { RpcMeleeAttackLerp(stabDirection, weapon); playerMove.allowInput = false; } victimHealth.ApplyDamage(gameObject, (int)weaponAttr.hitDamage, DamageType.Brute, damageZone); if (weaponAttr.hitDamage > 0) { PostToChatMessage.SendItemAttackMessage(weapon, gameObject, victim, (int)weaponAttr.hitDamage, damageZone); } SoundManager.PlayNetworkedAtPos(weaponAttr.hitSound, transform.position); StartCoroutine(AttackCoolDown()); }