- crouching (allows placing signal items at the bottom of a room and may be useful when doctors are added (CPR animation, using medical items on dead bodies?))

- changes to the dying logic: characters will be unconscious when their health or oxygen goes below 0.0, and die when it drops to -100.0 (if either of the values is below zero, it will automatically decrease so the character will quickly die without medical care)
- fixed LightSprite being drawn on LightComponents even if the item is inside an inventory
- characters extend their arm more when placing signal items
This commit is contained in:
Regalis
2016-03-20 20:15:47 +02:00
parent fc8b30c974
commit 0dbfb54b5f
11 changed files with 160 additions and 83 deletions

View File

@@ -124,7 +124,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -159,7 +159,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -193,7 +193,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -230,7 +230,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -269,7 +269,7 @@
<Body width="16" height="8" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -302,7 +302,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -336,7 +336,7 @@
<Body width="31" height="24" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -367,7 +367,7 @@
<Body width="31" height="24" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -398,7 +398,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -431,7 +431,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
<Holdable selectkey="Action" aimpos="65,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -463,7 +463,7 @@
<Body width="16" height="16" density="30"/>
<Holdable selectkey="Action" aimpos="35,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
<Holdable selectkey="Action" aimpos="65,-10" handle1="0,0" attachable="true" aimable="true" PickingTime="5.0"
slots="Any,RightHand,LeftHand" msg="Detach [Wrench]">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -493,7 +493,7 @@
<Body width="32" height="30" density="30"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>
@@ -526,7 +526,7 @@
<Body width="20" height="16" density="20"/>
<Holdable selectkey="Action" slots="Any,RightHand,LeftHand" msg="Detach [Wrench]" PickingTime="5.0"
aimpos="35,-10" handle1="0,0" attachable="true" aimable="true">
aimpos="65,-10" handle1="0,0" attachable="true" aimable="true">
<requireditem name="Wrench" type="Equipped"/>
</Holdable>

View File

@@ -72,6 +72,8 @@ namespace Barotrauma
steeringManager.Update(moveSpeed);
Character.AnimController.IgnorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X*0.5f));
(Character.AnimController as HumanoidAnimController).Crouching = false;
if (!Character.AnimController.InWater)
{
@@ -125,6 +127,8 @@ namespace Barotrauma
public override void OnAttacked(IDamageable attacker, float amount)
{
if (amount <= 0.0f) return;
var enemy = attacker as Character;
if (enemy == null || enemy == Character) return;

View File

@@ -6,7 +6,7 @@ namespace Barotrauma
{
class AnimController : Ragdoll
{
public enum Animation { None, Climbing, UsingConstruction, Struggle };
public enum Animation { None, Climbing, UsingConstruction, Struggle, CPR };
public Animation Anim;
public Direction TargetDir;

View File

@@ -9,6 +9,8 @@ namespace Barotrauma
{
class HumanoidAnimController : AnimController
{
public bool Crouching;
private bool aiming;
private float walkAnimSpeed;
@@ -17,6 +19,30 @@ namespace Barotrauma
private float thighTorque;
protected override float HeadPosition
{
get
{
return Crouching ? base.HeadPosition : base.HeadPosition;
}
}
protected override float TorsoPosition
{
get
{
return Crouching ? base.TorsoPosition - base.HeadPosition * 0.3f : base.TorsoPosition;
}
}
protected override float TorsoAngle
{
get
{
return Crouching ? base.TorsoAngle+0.5f : base.TorsoAngle;
}
}
public HumanoidAnimController(Character character, XElement element)
: base(character, element)
{
@@ -182,6 +208,16 @@ namespace Barotrauma
break;
case Animation.UsingConstruction:
UpdateStanding();
break;
case Animation.CPR:
if (character.SelectedCharacter == null)
{
Anim = Animation.None;
return;
}
DragCharacter(character.SelectedCharacter);
break;
default:
if (inWater)
@@ -268,6 +304,8 @@ namespace Barotrauma
Vector2 stepSize = new Vector2(
this.stepSize.X * walkPosX * runningModifier,
this.stepSize.Y * walkPosY * runningModifier * runningModifier);
if (Crouching) stepSize *= 0.5f;
float footMid = waist.SimPosition.X;// (leftFoot.SimPosition.X + rightFoot.SimPosition.X) / 2.0f;
@@ -300,43 +338,46 @@ namespace Barotrauma
if (!onGround || (LowestLimb.SimPosition.Y - floorY > 0.5f && stairs == null)) return;
float? ceilingY = null;
if (Submarine.PickBody(head.SimPosition, head.SimPosition + Vector2.UnitY, null, Physics.CollisionWall)!=null)
{
ceilingY = Submarine.LastPickedPosition.Y;
if (ceilingY - floorY < HeadPosition) Crouching = true;
}
getUpSpeed = getUpSpeed * Math.Max(head.SimPosition.Y - colliderPos.Y, 0.5f);
torso.pullJoint.Enabled = true;
head.pullJoint.Enabled = true;
waist.pullJoint.Enabled = true;
if (stairs != null)
{
if (LowestLimb.SimPosition.Y < stairs.SimPosition.Y) IgnorePlatforms = true;
torso.pullJoint.Enabled = true;
torso.pullJoint.WorldAnchorB = new Vector2(
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.35f, getUpSpeed * 0.8f),
MathHelper.SmoothStep(torso.SimPosition.Y, colliderPos.Y + TorsoPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f));
head.pullJoint.Enabled = true;
head.pullJoint.WorldAnchorB = new Vector2(
MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * 0.4f, getUpSpeed * 0.8f),
MathHelper.SmoothStep(head.SimPosition.X, footMid + movement.X * (Crouching ? 1.0f : 0.4f), getUpSpeed * 0.8f),
MathHelper.SmoothStep(head.SimPosition.Y, colliderPos.Y + HeadPosition - Math.Abs(walkPosX * 0.05f), getUpSpeed * 2.0f));
waist.pullJoint.Enabled = true;
waist.pullJoint.WorldAnchorB = waist.SimPosition;// +movement * 0.3f;
}
else
{
torso.pullJoint.Enabled = true;
torso.pullJoint.WorldAnchorB =
MathUtils.SmoothStep(torso.SimPosition,
new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + TorsoPosition), getUpSpeed);
head.pullJoint.Enabled = true;
head.pullJoint.WorldAnchorB =
MathUtils.SmoothStep(head.SimPosition,
new Vector2(footMid + movement.X * 0.3f, colliderPos.Y + HeadPosition), getUpSpeed*1.2f);
new Vector2(footMid + movement.X * (Crouching && Math.Sign(movement.X)==Math.Sign(Dir) ? 1.0f : 0.3f), colliderPos.Y + HeadPosition), getUpSpeed*1.2f);
waist.pullJoint.Enabled = true;
waist.pullJoint.WorldAnchorB = waist.SimPosition + movement * 0.1f;
//MathUtils.SmoothStep(waist.SimPosition,
//new Vector2(footMid + movement.X * 0.4f, colliderPos.Y + HeadPosition), getUpSpeed);
}
@@ -416,12 +457,20 @@ namespace Barotrauma
{
float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
//MoveLimb(leftFoot, footPos, 2.5f);
for (int i = -1; i < 2; i+=2 )
{
Vector2 footPos = new Vector2(
colliderPos.X,
Crouching ? waist.SimPosition.X + Math.Sign(stepSize.X*i)*Dir*0.3f : waist.SimPosition.X,
colliderPos.Y - 0.2f);
MoveLimb(leftFoot, footPos, 2.5f);
MoveLimb(rightFoot, footPos, 2.5f);
var foot = i == -1 ? rightFoot : leftFoot;
MoveLimb(foot, footPos, Math.Abs(foot.SimPosition.X - footPos.X)*50.0f);
}
leftFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
rightFoot.body.SmoothRotate(Dir * MathHelper.PiOver2, 5.0f);
@@ -850,7 +899,6 @@ namespace Barotrauma
targetLimb.pullJoint.Enabled = true;
targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition;
}
@@ -1039,30 +1087,49 @@ namespace Barotrauma
foreach (Limb limb in Limbs)
{
bool mirror = false;
bool flipAngle = false;
bool wrapAngle = false;
switch (limb.type)
{
case LimbType.LeftHand:
case LimbType.LeftArm:
case LimbType.RightHand:
case LimbType.RightArm:
if (!limb.pullJoint.Enabled)
{
difference = limb.body.SimPosition - torso.SimPosition;
difference = Vector2.Transform(difference, torsoTransform);
difference.Y = -difference.Y;
TrySetLimbPosition(limb, limb.SimPosition, torso.SimPosition + Vector2.Transform(difference, -torsoTransform));
}
limb.body.SetTransform(limb.body.SimPosition, -limb.body.Rotation);
mirror = true;
flipAngle = true;
break;
case LimbType.LeftThigh:
case LimbType.LeftLeg:
case LimbType.LeftFoot:
case LimbType.RightThigh:
case LimbType.RightLeg:
case LimbType.RightFoot:
mirror = true;
flipAngle = true;
wrapAngle = true;
break;
default:
if (!inWater) limb.body.SetTransform(limb.body.SimPosition,
MathUtils.WrapAnglePi(limb.body.Rotation * (limb.DoesFlip ? -1.0f : 1.0f)));
flipAngle = limb.DoesFlip;
break;
}
if (!limb.pullJoint.Enabled && mirror)
{
difference = limb.body.SimPosition - torso.SimPosition;
difference = Vector2.Transform(difference, torsoTransform);
difference.Y = -difference.Y;
TrySetLimbPosition(limb, limb.SimPosition, torso.SimPosition + Vector2.Transform(difference, -torsoTransform));
}
float angle = flipAngle ? -limb.body.Rotation : limb.body.Rotation;
if (wrapAngle) angle = MathUtils.WrapAnglePi(angle);
limb.body.SetTransform(limb.body.SimPosition, angle);
}
}
}
}

View File

@@ -117,22 +117,22 @@ namespace Barotrauma
}
}
public float HeadPosition
protected virtual float HeadPosition
{
get { return headPosition; }
}
public float HeadAngle
protected virtual float HeadAngle
{
get { return headAngle; }
}
public float TorsoPosition
protected virtual float TorsoPosition
{
get { return torsoPosition; }
}
public float TorsoAngle
protected virtual float TorsoAngle
{
get { return torsoAngle; }
}

View File

@@ -235,6 +235,11 @@ namespace Barotrauma
}
}
public bool IsUnconscious
{
get { return (needsAir && oxygen < 0.0f) || health < 0.0f; }
}
public bool NeedsAir
{
get { return needsAir; }
@@ -246,8 +251,8 @@ namespace Barotrauma
set
{
if (!MathUtils.IsValid(value)) return;
oxygen = MathHelper.Clamp(value, 0.0f, 100.0f);
if (oxygen == 0.0f) Kill(AnimController.InWater ? CauseOfDeath.Drowning : CauseOfDeath.Suffocation);
oxygen = MathHelper.Clamp(value, -100.0f, 100.0f);
if (oxygen == -100.0f) Kill(AnimController.InWater ? CauseOfDeath.Drowning : CauseOfDeath.Suffocation);
}
}
@@ -269,7 +274,7 @@ namespace Barotrauma
set
{
if (!MathUtils.IsValid(value)) return;
health = MathHelper.Clamp(value, 0.0f, maxHealth);
health = MathHelper.Clamp(value, -100.0f, maxHealth);
}
}
@@ -656,9 +661,13 @@ namespace Barotrauma
Vector2 targetMovement = GetTargetMovement();
AnimController.TargetMovement = targetMovement;
AnimController.IgnorePlatforms = AnimController.TargetMovement.Y < 0.0f;
if (AnimController is HumanoidAnimController)
{
((HumanoidAnimController) AnimController).Crouching = IsKeyDown(InputType.Crouch);
}
if (AnimController.onGround &&
!AnimController.InWater &&
AnimController.Anim != AnimController.Animation.UsingConstruction)
@@ -988,7 +997,7 @@ namespace Barotrauma
networkUpdateSent = false;
}
if (needsAir)
{
bool protectedFromPressure = PressureProtection > 0.0f;
@@ -1016,7 +1025,7 @@ namespace Barotrauma
PressureTimer = 0.0f;
}
}
if (controlled == this)
{
Lights.LightManager.ViewTarget = this;
@@ -1024,6 +1033,12 @@ namespace Barotrauma
ControlLocalPlayer(deltaTime, cam);
}
if (IsUnconscious)
{
UpdateUnconscious(deltaTime);
return;
}
if (controlled==this || !(this is AICharacter)) Control(deltaTime, cam);
UpdateSightRange();
@@ -1052,12 +1067,19 @@ namespace Barotrauma
Health -= bleeding * deltaTime;
Bleeding -= BleedingDecreaseSpeed * deltaTime;
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false);
if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss);
if (!IsDead) LockHands = false;
}
private void UpdateUnconscious(float deltaTime)
{
Stun = Math.Max(5.0f, Stun);
if (oxygen < 0.0f) Oxygen -= deltaTime;
if (health < 0.0f) Health -= Math.Max(bleeding, 1.0f) * deltaTime;
}
private void UpdateSightRange()
{

View File

@@ -10,7 +10,7 @@ namespace Barotrauma.Items.Components
{
class RepairTool : ItemComponent
{
private List<string> fixableEntities;
private readonly List<string> fixableEntities;
private float range;
@@ -80,13 +80,6 @@ namespace Barotrauma.Items.Components
{
this.item = item;
//range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
//range = ConvertUnits.ToSimUnits(range);
//structureFixAmount = ToolBox.GetAttributeFloat(element, "structurefixamount", 1.0f);
//limbFixAmount = ToolBox.GetAttributeFloat(element, "limbfixamount", -0.5f);
fixableEntities = new List<string>();
foreach (XElement subElement in element.Elements())
{
@@ -194,23 +187,13 @@ namespace Barotrauma.Items.Components
}
else if ((targetItem = (targetBody.UserData as Item)) != null)
{
//targetItem.Condition -= structureFixAmount;
targetItem.IsHighlighted = true;
foreach (StatusEffect effect in statusEffects)
{
//if (Array.IndexOf(effect.TargetNames, targetItem.Name) == -1) continue;
effect.Apply(ActionType.OnUse, deltaTime, item, targetItem.AllPropertyObjects);
//targetItem.ApplyStatusEffect(effect, ActionType.OnUse, deltaTime);
}
//ApplyStatusEffects(ActionType.OnUse, 1.0f, null, targ);
}
//if (Character.SecondaryKeyDown.State)
//{
// IPropertyObject propertyObject = targetBody.UserData as IPropertyObject;
// if (propertyObject!=null) ApplyStatusEffects(ActionType.OnUse, 1.0f, item.SimPosition, propertyObject);
// //isActive = true;
//}
return true;
}

View File

@@ -150,9 +150,9 @@ namespace Barotrauma.Items.Components
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, bool editing = false)
{
if (light.LightSprite != null)
if (light.LightSprite != null && (item.body==null || item.body.Enabled))
{
light.LightSprite.Draw(spriteBatch, new Vector2(item.DrawPosition.X, -item.DrawPosition.Y), lightColor * lightBrightness);
light.LightSprite.Draw(spriteBatch, new Vector2(item.DrawPosition.X, -item.DrawPosition.Y), lightColor * lightBrightness, 0.0f, 1.0f, Microsoft.Xna.Framework.Graphics.SpriteEffects.None, item.Sprite.Depth-0.0001f);
}
}

View File

@@ -10,7 +10,7 @@ namespace Barotrauma
Use,
Aim,
Up, Down, Left, Right,
Run,
Run, Crouch,
Chat, CrewOrders
}

View File

@@ -93,14 +93,15 @@ namespace Barotrauma
foreach (Submarine sub in Submarine.SavedSubmarines)
{
GUITextBlock textBlock = new GUITextBlock(
new GUITextBlock(
new Rectangle(0, 0, 0, 25),
sub.Name,
GUI.Style,
Alignment.Left, Alignment.Left, mapList);
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
textBlock.ToolTip = sub.Description;
textBlock.UserData = sub;
sub.Name, GUI.Style,
Alignment.Left, Alignment.Left, mapList)
{
Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f),
ToolTip = sub.Description,
UserData = sub
};
}
if (Submarine.SavedSubmarines.Count > 0) mapList.Select(Submarine.SavedSubmarines[0]);

View File

@@ -2,5 +2,5 @@
<config masterserverurl="http://www.undertowgames.com/baromaster" autocheckupdates="true" musicvolume="0.0" soundvolume="0.0">
<graphicsmode width="1280" height="720" fullscreen="false" />
<contentpackage path="Data/ContentPackages/Vanilla 0.3.xml" />
<keymapping Select="E" Use="0" Aim="1" Up="W" Down="S" Left="A" Right="D" Run="LeftShift" Chat="Tab" CrewOrders="C" />
<keymapping Select="E" Use="0" Aim="1" Up="W" Down="S" Left="A" Right="D" Run="LeftShift" Crouch="LeftControl" Chat="Tab" CrewOrders="C" />
</config>