Item UI replacements, fabricator bugfix, randomly spawning artifacts, AI can fix leaks, LimbAttacks do damage once (not each frame for the duration of the attack)

This commit is contained in:
Regalis
2016-01-14 21:06:08 +02:00
parent eb20af622d
commit 0fc085c86d
33 changed files with 340 additions and 123 deletions
@@ -143,7 +143,6 @@ namespace Barotrauma
private void UpdateNone(float deltaTime)
{
//wander around randomly
//UpdateSteeringWander(deltaTime, 0.8f);
steeringManager.SteeringWander(0.8f);
steeringManager.SteeringAvoid(deltaTime, 1.0f);
@@ -328,9 +327,12 @@ namespace Barotrauma
attackTimer += deltaTime;
limb.body.ApplyTorque(limb.Mass * 50.0f * Character.AnimController.Dir * dir);
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, deltaTime, (limb.soundTimer <= 0.0f));
if (attackTimer >= limb.attack.Duration)
{
limb.attack.DoDamage(Character, damageTarget, limb.WorldPosition, 1.0f, (limb.soundTimer <= 0.0f));
limb.soundTimer = Limb.SoundInterval;
limb.soundTimer = Limb.SoundInterval;
}
}
Vector2 diff = attackPosition - limb.SimPosition;
@@ -96,6 +96,17 @@ namespace Barotrauma
{
if (currentPath == null) return Vector2.Zero;
if (currentPath.CurrentIndex == currentPath.Nodes.Count)
{
Vector2 pos2 = host.SimPosition;
if (character != null && character.Submarine == null)
{
pos2 -= Submarine.Loaded.SimPosition;
}
return currentTarget-pos2;
}
if (canOpenDoors) CheckDoorsInPath();
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
@@ -149,7 +149,10 @@ namespace Barotrauma
if (divingGearObjective != null)
{
divingGearObjective.TryComplete(deltaTime);
return divingGearObjective.IsCompleted();
bool isCompleted = divingGearObjective.IsCompleted();
if (isCompleted) divingGearObjective = null;
return isCompleted;
}
return false;
@@ -165,6 +168,10 @@ namespace Barotrauma
if (character.AnimController.CurrentHull == null) return 0.0f;
currenthullSafety = GetHullSafety(character.AnimController.CurrentHull);
priority = 100.0f - currenthullSafety;
if (divingGearObjective != null && !divingGearObjective.IsCompleted()) priority += 20.0f;
return priority;
}
@@ -25,10 +25,12 @@ namespace Barotrauma
public override float GetPriority(Character character)
{
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * leak.Open;
if (leak.Open == 0.0f) return 0.0f;
float leakSize = (leak.isHorizontal ? leak.Rect.Height : leak.Rect.Width) * Math.Max(leak.Open, 0.1f);
float dist = Vector2.DistanceSquared(character.SimPosition, leak.SimPosition);
dist = Math.Max(dist/1000.0f, 1.0f);
dist = Math.Max(dist/100.0f, 1.0f);
return Math.Min(leakSize/dist, 40.0f);
}
@@ -69,7 +71,7 @@ namespace Barotrauma
{
var repairTool = weldingTool.GetComponent<RepairTool>();
if (repairTool == null) return;
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, ""));
AddSubObjective(new AIObjectiveOperateItem(repairTool, character, "", leak));
}
}
@@ -46,7 +46,7 @@ namespace Barotrauma
this.equip = equip;
currSearchIndex = 0;
this.itemName = itemName;
}
@@ -136,7 +136,18 @@ namespace Barotrauma
public override bool IsCompleted()
{
return character.Inventory.FindItem(itemName) != null;
if (itemName!=null)
{
return character.Inventory.FindItem(itemName) != null;
}
else if (targetItem!= null)
{
return character.Inventory.Items.Contains(targetItem);
}
else
{
return false;
}
}
}
}
@@ -16,18 +16,18 @@ namespace Barotrauma
bool repeat;
//how long until the path to the target is declared unreachable
private float waitUntilPathUnreachable;
public override bool CanBeCompleted
{
get
{
if (repeat) return true;
if (repeat || waitUntilPathUnreachable > 0.0f) return true;
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
//path doesn't exist (= hasn't been searched for yet), assume for now that the target is reachable
if (pathSteering.CurrentPath == null) return true;
//steeringmanager is still targeting some other position, assume for now that the target is reachable
if ((target != null && Vector2.Distance(target.Position, targetPos) > 5.0f) ||
Vector2.Distance(pathSteering.CurrentTarget, targetPos) > 5.0f) return true;
return (!pathSteering.CurrentPath.Unreachable);
}
@@ -43,6 +43,8 @@ namespace Barotrauma
{
this.target = target;
this.repeat = repeat;
waitUntilPathUnreachable = 5.0f;
}
@@ -51,17 +53,20 @@ namespace Barotrauma
{
this.targetPos = simPos;
this.repeat = repeat;
waitUntilPathUnreachable = 5.0f;
}
protected override void Act(float deltaTime)
{
{
waitUntilPathUnreachable -= deltaTime;
if (character.SelectedConstruction!=null && character.SelectedConstruction.GetComponent<Ladder>()==null)
{
character.SelectedConstruction = null;
}
if (target!=null) character.AIController.SelectTarget(target.AiTarget);
if (target != null) character.AIController.SelectTarget(target.AiTarget);
Vector2 currTargetPos = Vector2.Zero;
@@ -71,8 +71,15 @@ namespace Barotrauma
}
}
if (character.AnimController.InWater)
{
character.AIController.SteeringManager.SteeringManual(deltaTime, new Vector2(0.0f, 0.5f));
}
else
{
character.AIController.SteeringManager.SteeringWander();
}
character.AIController.SteeringManager.SteeringWander(1.0f);
return;
}
@@ -57,7 +57,7 @@ namespace Barotrauma
foreach (Gap gap in Gap.GapList)
{
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.1f) continue;
if (gap.IsRoomToRoom || gap.ConnectedDoor != null || gap.Open<0.01f) continue;
AddObjective(new AIObjectiveFixLeak(gap, character));
}
@@ -429,13 +429,13 @@ namespace Barotrauma
pos.Y = -pos.Y;
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X, (int)pos.Y, 5, 5), Color.Red, true, 0.01f);
if (limb.AnimTargetPos == Vector2.Zero) continue;
//if (limb.AnimTargetPos == Vector2.Zero) continue;
Vector2 pos2 = ConvertUnits.ToDisplayUnits(limb.AnimTargetPos);
pos2.Y = -pos2.Y;
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos2.X, (int)pos2.Y, 5, 5), Color.Blue, true, 0.01f);
//Vector2 pos2 = ConvertUnits.ToDisplayUnits(limb.AnimTargetPos);
//pos2.Y = -pos2.Y;
//GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos2.X, (int)pos2.Y, 5, 5), Color.Blue, true, 0.01f);
GUI.DrawLine(spriteBatch, pos, pos2, Color.Green);
//GUI.DrawLine(spriteBatch, pos, pos2, Color.Green);
}
}
@@ -456,7 +456,7 @@ namespace Barotrauma
pos.Y = -pos.Y;
GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X - 10, (int)pos.Y - 10, 20, 20), Color.Cyan, false, 0.01f);
GUI.DrawLine(spriteBatch, pos, new Vector2(limb.Position.X, -limb.Position.Y), limb==RefLimb ? Color.Orange : Color.Cyan);
GUI.DrawLine(spriteBatch, pos, new Vector2(limb.Position.X, -limb.Position.Y), limb == RefLimb ? Color.Orange : Color.Cyan);
}
}
+1 -1
View File
@@ -1044,7 +1044,7 @@ namespace Barotrauma
if (soundStates[i] != state) continue;
if (n == selectedSound && sounds[i]!=null)
{
sounds[i].Play(1.0f, 2000.0f, AnimController.Limbs[0].WorldPosition);
sounds[i].Play(1.0f, soundRange[i], AnimController.Limbs[0].WorldPosition);
return;
}
n++;