Md5 hashes for maps, enemy AI changes HumanoidAnimController bugfixes, HitArmor sounds

This commit is contained in:
Regalis
2015-06-06 14:38:25 +03:00
parent 1f42e4a4db
commit 95c8e0f486
28 changed files with 411 additions and 137 deletions
+15 -12
View File
@@ -380,27 +380,30 @@ namespace Subsurface
Body closestBody = Map.CheckVisibility(rayStart, rayEnd);
Structure closestStructure = (closestBody == null) ? null : closestBody.UserData as Structure;
if (targetCharacter != null)
{
//if target is a character that isn't visible, ignore
if (closestStructure != null) continue;
//if (targetCharacter != null)
//{
// //if target is a character that isn't visible, ignore
// if (closestStructure != null) continue;
//prefer targets with low health
valueModifier = valueModifier / targetCharacter.Health;
}
else
{
// //prefer targets with low health
// valueModifier = valueModifier / targetCharacter.Health;
//}
//else
//{
if (targetDamageable != null)
{
valueModifier = valueModifier / targetDamageable.Health;
valueModifier = valueModifier / targetDamageable.Health;
}
else if (closestStructure!=null)
{
valueModifier = valueModifier / (closestStructure as IDamageable).Health;
}
else
{
valueModifier = valueModifier / 1000.0f;
}
}
//}
@@ -8,12 +8,26 @@ using System.Xml.Linq;
namespace Subsurface
{
public enum DamageType { None, Blunt, Slash };
public enum DamageType { None, Blunt, Slash };
struct AttackResult
{
public readonly float damage;
public readonly float bleeding;
public readonly bool hitArmor;
public AttackResult(float damage, float bleeding, bool hitArmor=false)
{
this.damage = damage;
this.bleeding = bleeding;
this.hitArmor = hitArmor;
}
}
class Attack
{
public enum Type
{
None, PinchCW, PinchCCW
@@ -67,7 +81,7 @@ namespace Subsurface
priority = ToolBox.GetAttributeFloat(element, "priority", 1.0f);
}
public void DoDamage(IDamageable target, Vector2 position, float deltaTime, bool playSound=true)
public AttackResult DoDamage(IDamageable target, Vector2 position, float deltaTime, bool playSound=true)
{
float damageAmount = 0.0f;
//DamageSoundType damageSoundType = DamageSoundType.None;
@@ -89,7 +103,14 @@ namespace Subsurface
if (duration > 0.0f) damageAmount *= deltaTime;
float bleedingAmount = (duration == 0.0f) ? bleedingDamage : bleedingDamage * deltaTime;
if (damageAmount>0.0f) target.AddDamage(position, damageType, damageAmount, bleedingAmount, stun, playSound);
if (damageAmount > 0.0f)
{
return target.AddDamage(position, damageType, damageAmount, bleedingAmount, stun, playSound);
}
else
{
return new AttackResult(0.0f, 0.0f);
}
}
}
}
+2 -2
View File
@@ -654,7 +654,7 @@ namespace Subsurface
}
}
public void AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound = false)
public AttackResult AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, float stun, bool playSound = false)
{
animController.StunTimer = Math.Max(animController.StunTimer, stun);
@@ -675,7 +675,7 @@ namespace Subsurface
closestLimb.body.ApplyForce(pull*Math.Min(amount*100.0f, 100.0f));
closestLimb.AddDamage(position, damageType, amount, bleedingAmount, playSound);
return closestLimb.AddDamage(position, damageType, amount, bleedingAmount, playSound);
}
@@ -33,7 +33,7 @@ namespace Subsurface
{
case Physics.CollisionStairs:
Structure structure = fixture.Body.UserData as Structure;
if (stairs == null)
if (stairs == null && (!inWater || TargetMovement.Y>0.0f))
{
if (LowestLimb.SimPosition.Y<structure.SimPosition.Y)
{
@@ -80,7 +80,7 @@ namespace Subsurface
if (onFloorTimer <= 0.0f)
{
onGround = false;
if (GetLimb(LimbType.Torso).inWater) inWater = true;
//TODO: joku järkevämpi systeemi
//if (!inWater && lastTimeOnFloor + 200 < gameTime.TotalGameTime.Milliseconds)
// stunTimer = Math.Max(stunTimer, (float)gameTime.TotalGameTime.TotalMilliseconds + 100.0f);
+12 -4
View File
@@ -257,11 +257,11 @@ namespace Subsurface
body.ApplyLinearImpulse((deltaPos - vel * 0.5f) * body.Mass, pullPos);
}
public void AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, bool playSound)
public AttackResult AddDamage(Vector2 position, DamageType damageType, float amount, float bleedingAmount, bool playSound)
{
DamageSoundType damageSoundType = (damageType == DamageType.Blunt) ? DamageSoundType.LimbBlunt : DamageSoundType.LimbSlash;
bool hitArmor = false;
if (armorSector != Vector2.Zero)
{
float rot = body.Rotation;
@@ -273,7 +273,13 @@ namespace Subsurface
float angleDiff = ToolBox.GetShortestAngle(ToolBox.VectorToAngle(position - SimPosition), mid);
if (Math.Abs(angleDiff) < (armorSector.Y-armorSector.X) / 2.0f) return;
if (Math.Abs(angleDiff) < (armorSector.Y - armorSector.X) / 2.0f)
{
hitArmor = true;
damageSoundType = DamageSoundType.LimbArmor;
damage /= armorValue;
bleedingAmount /= armorValue;
}
}
if (playSound)
@@ -284,7 +290,7 @@ namespace Subsurface
Bleeding += bleedingAmount;
Damage += amount;
float bloodAmount = (int)Math.Min((int)(amount * 2.0f), 20);
float bloodAmount = hitArmor ? 0 : (int)Math.Min((int)(amount * 2.0f), 20);
//if (closestLimb.Damage>=100.0f)
//{
// bloodAmount *= 2;
@@ -311,6 +317,8 @@ namespace Subsurface
{
Game1.particleManager.CreateParticle("waterblood", SimPosition, Vector2.Zero);
}
return new AttackResult(amount, bleedingAmount, hitArmor);
}
public void Update(float deltaTime)
+1 -1
View File
@@ -442,7 +442,7 @@ namespace Subsurface
inWater = false;
headInWater = false;
if (ConvertUnits.ToSimUnits(currentHull.Surface)-floorY> HeadPosition)
if (ConvertUnits.ToSimUnits(currentHull.Surface)-floorY> HeadPosition*0.95f)
inWater = true;
}