diff --git a/Subsurface/Content/Characters/Coelanth/coelanth.xml b/Subsurface/Content/Characters/Coelanth/coelanth.xml index a71ff7337..12eabe94d 100644 --- a/Subsurface/Content/Characters/Coelanth/coelanth.xml +++ b/Subsurface/Content/Characters/Coelanth/coelanth.xml @@ -15,7 +15,7 @@ - + diff --git a/Subsurface/Content/Characters/Crawler/crawler.xml b/Subsurface/Content/Characters/Crawler/crawler.xml index da7669615..42ae65e14 100644 --- a/Subsurface/Content/Characters/Crawler/crawler.xml +++ b/Subsurface/Content/Characters/Crawler/crawler.xml @@ -30,7 +30,7 @@ - + @@ -76,6 +76,6 @@ + attackcooldown="3.0"/> diff --git a/Subsurface/Content/Characters/Fractalguardian/fractalguardian.xml b/Subsurface/Content/Characters/Fractalguardian/fractalguardian.xml index 164d3d575..310dcd6eb 100644 --- a/Subsurface/Content/Characters/Fractalguardian/fractalguardian.xml +++ b/Subsurface/Content/Characters/Fractalguardian/fractalguardian.xml @@ -9,7 +9,7 @@ - + diff --git a/Subsurface/Content/Characters/Fractalguardian2/fractalguardian2.xml b/Subsurface/Content/Characters/Fractalguardian2/fractalguardian2.xml index b1901152c..a7aae8f8d 100644 --- a/Subsurface/Content/Characters/Fractalguardian2/fractalguardian2.xml +++ b/Subsurface/Content/Characters/Fractalguardian2/fractalguardian2.xml @@ -9,7 +9,7 @@ - + diff --git a/Subsurface/Content/Characters/Mantis/mantis.xml b/Subsurface/Content/Characters/Mantis/mantis.xml index ccdb37ae8..76d879210 100644 --- a/Subsurface/Content/Characters/Mantis/mantis.xml +++ b/Subsurface/Content/Characters/Mantis/mantis.xml @@ -46,7 +46,7 @@ - + diff --git a/Subsurface/Content/Characters/Moloch/moloch.xml b/Subsurface/Content/Characters/Moloch/moloch.xml index c4b6ba180..d8be447a5 100644 --- a/Subsurface/Content/Characters/Moloch/moloch.xml +++ b/Subsurface/Content/Characters/Moloch/moloch.xml @@ -11,7 +11,7 @@ - + diff --git a/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml b/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml index ab4cdb716..c5cf24d6e 100644 --- a/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml +++ b/Subsurface/Content/Characters/TigerThresher/tigerthresher.xml @@ -17,7 +17,7 @@ - + diff --git a/Subsurface/Source/Characters/AICharacter.cs b/Subsurface/Source/Characters/AICharacter.cs index 71341552d..40aa1f941 100644 --- a/Subsurface/Source/Characters/AICharacter.cs +++ b/Subsurface/Source/Characters/AICharacter.cs @@ -78,11 +78,11 @@ namespace Barotrauma if (attacker!=null) aiController.OnAttacked(attacker, amount); } - public override AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = false) + public override AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false) { - AttackResult result = base.AddDamage(attacker, position, attack, deltaTime, playSound); + AttackResult result = base.AddDamage(attacker, worldPosition, attack, deltaTime, playSound); - aiController.OnAttacked(attacker, (result.Damage + result.Bleeding)/Math.Max(health,1.0f)); + aiController.OnAttacked(attacker, (result.Damage + result.Bleeding) / Math.Max(health,1.0f)); return result; } diff --git a/Subsurface/Source/Characters/Attack.cs b/Subsurface/Source/Characters/Attack.cs index 9d26273be..bb49645ab 100644 --- a/Subsurface/Source/Characters/Attack.cs +++ b/Subsurface/Source/Characters/Attack.cs @@ -49,6 +49,8 @@ namespace Barotrauma public readonly float Force; + public readonly float TargetForce; + private Sound sound; private ParticleEmitterPrefab particleEmitterPrefab; @@ -105,6 +107,8 @@ namespace Barotrauma Force = ToolBox.GetAttributeFloat(element,"force", 0.0f); + TargetForce = ToolBox.GetAttributeFloat(element, "targetforce", 0.0f); + Stun = ToolBox.GetAttributeFloat(element, "stun", 0.0f); string soundPath = ToolBox.GetAttributeString(element, "sound", ""); diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 11c96891e..f10d24db9 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -1200,9 +1200,7 @@ namespace Barotrauma public virtual AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false) { - - - var attackResult = AddDamage(worldPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound); + var attackResult = AddDamage(worldPosition, attack.DamageType, attack.GetDamage(deltaTime), attack.GetBleedingDamage(deltaTime), attack.Stun, playSound, attack.TargetForce); var attackingCharacter = attacker as Character; if (attackingCharacter != null && attackingCharacter.AIController == null) @@ -1213,28 +1211,28 @@ namespace Barotrauma return attackResult; } - public AttackResult AddDamage(Vector2 simPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound) + public AttackResult AddDamage(Vector2 worldPosition, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound, float attackForce = 0.0f) { StartStun(stun); - + Limb closestLimb = null; float closestDistance = 0.0f; foreach (Limb limb in AnimController.Limbs) { - float distance = Vector2.Distance(simPosition, limb.SimPosition); + float distance = Vector2.Distance(worldPosition, limb.WorldPosition); if (closestLimb == null || distance < closestDistance) { closestLimb = limb; closestDistance = distance; } } + + if (Math.Abs(attackForce) > 0.0f) + { + closestLimb.body.ApplyForce((closestLimb.WorldPosition - worldPosition) * attackForce); + } - Vector2 pull = simPosition - closestLimb.SimPosition; - if (pull != Vector2.Zero) pull = Vector2.Normalize(pull); - closestLimb.body.ApplyForce(pull*Math.Min(amount*100.0f, 100.0f)); - - - AttackResult attackResult = closestLimb.AddDamage(simPosition, damageType, amount, bleedingAmount, playSound); + AttackResult attackResult = closestLimb.AddDamage(worldPosition, damageType, amount, bleedingAmount, playSound); AddDamage(damageType == DamageType.Burn ? CauseOfDeath.Burn : causeOfDeath, attackResult.Damage, null); diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 501b408f4..5c967f7bb 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -649,7 +649,7 @@ namespace Barotrauma } - public AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = true) + public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = true) { float damageAmount = attack.GetDamage(deltaTime); Condition -= damageAmount; diff --git a/Subsurface/Source/Map/IDamageable.cs b/Subsurface/Source/Map/IDamageable.cs index 9b56fc410..17c4e4061 100644 --- a/Subsurface/Source/Map/IDamageable.cs +++ b/Subsurface/Source/Map/IDamageable.cs @@ -24,6 +24,6 @@ namespace Barotrauma get; } - AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound=true); + AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound=true); } } diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 69ed2284a..12c77e3a4 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -533,12 +533,12 @@ namespace Barotrauma return sectionPos; } - public AttackResult AddDamage(IDamageable attacker, Vector2 position, Attack attack, float deltaTime, bool playSound = false) + public AttackResult AddDamage(IDamageable attacker, Vector2 worldPosition, Attack attack, float deltaTime, bool playSound = false) { if (Submarine.Loaded != null && Submarine.Loaded.GodMode && Submarine == Submarine.Loaded) return new AttackResult(0.0f, 0.0f); if (!prefab.HasBody || prefab.IsPlatform) return new AttackResult(0.0f, 0.0f); - Vector2 transformedPos = position; + Vector2 transformedPos = worldPosition; if (Submarine != null) transformedPos -= Submarine.Position; int i = FindSectionIndex(transformedPos); @@ -551,7 +551,7 @@ namespace Barotrauma if (playSound && !SectionBodyDisabled(i)) { DamageSoundType damageSoundType = (attack.DamageType == DamageType.Blunt) ? DamageSoundType.StructureBlunt : DamageSoundType.StructureSlash; - SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, position); + SoundPlayer.PlayDamageSound(damageSoundType, damageAmount, worldPosition); } AddDamage(i, damageAmount);