Unstable 0.1300.0.5

This commit is contained in:
Markus Isberg
2021-04-01 16:09:18 +03:00
parent 862221635c
commit 96b2184811
54 changed files with 429 additions and 122 deletions
@@ -181,10 +181,12 @@ namespace Barotrauma
private set;
} = new HashSet<Submarine>();
public bool IsTargetingPlayer => SelectedAiTarget?.Entity?.Submarine != null && SelectedAiTarget.Entity.Submarine.Info.IsPlayer || SelectedAiTarget?.Entity is Character targetCharacter && targetCharacter.IsPlayer;
public bool IsTargetingPlayerTeam => IsTargetInPlayerTeam(SelectedAiTarget);
public bool IsBeingChasedBy(Character c) => c.AIController is EnemyAIController enemyAI && enemyAI.SelectedAiTarget?.Entity is Character && (enemyAI.State == AIState.Aggressive || enemyAI.State == AIState.Attack);
private bool IsBeingChased => SelectedAiTarget?.Entity is Character targetCharacter && IsBeingChasedBy(targetCharacter);
private bool IsTargetInPlayerTeam(AITarget target) => target?.Entity?.Submarine != null && target.Entity.Submarine.Info.IsPlayer || target?.Entity is Character targetCharacter && targetCharacter.IsOnPlayerTeam;
private bool reverse;
public bool Reverse
{
@@ -2465,11 +2467,17 @@ namespace Barotrauma
default:
if (targetParams.State == AIState.Attack)
{
// In the attack state allow going into non-allowed zone only when chasing a target.
if (State == targetParams.State && SelectedAiTarget == aiTarget) { break; }
}
if (!IsPositionInsideAllowedZone(aiTarget.WorldPosition, out _))
{
continue;
// If we have recently been damaged by the target (or another player/bot in the same team) allow targeting it even when we are in the idle state.
bool isTargetInPlayerTeam = IsTargetInPlayerTeam(aiTarget);
if (Character.LastAttackers.None(a => a.Damage > 0 && a.Character != null && (a.Character == aiTarget.Entity || a.Character.IsOnPlayerTeam && isTargetInPlayerTeam)))
{
continue;
}
}
break;
}
@@ -61,13 +61,22 @@ namespace Barotrauma
protected override void Act(float deltaTime)
{
// Only continue when the get item sub objectives have been completed.
if (subObjectives.Any()) { return; }
if (item.IgnoreByAI)
{
Abandon = true;
return;
}
if (item.ParentInventory != null)
{
if (item.Container != null && !AIObjectiveCleanupItems.IsValidContainer(item.Container, character, allowUnloading: objectiveManager.HasOrders()))
{
// Target was picked up or moved by someone.
Abandon = true;
return;
}
}
// Only continue when the get item sub objectives have been completed.
if (subObjectives.Any()) { return; }
if (HumanAIController.FindSuitableContainer(character, item, ignoredContainers, ref itemIndex, out Item suitableContainer))
{
itemIndex = 0;
@@ -477,7 +477,7 @@ namespace Barotrauma
}
}
public const float KnockbackCooldown = 30.0f;
public const float KnockbackCooldown = 5.0f;
public float KnockbackCooldownTimer;
private float ragdollingLockTimer;
@@ -3310,7 +3310,7 @@ namespace Barotrauma
}
#if CLIENT
if (attacker == Controlled && Controlled != null && Params.UseBossHealthBar)
if (Params.UseBossHealthBar && Controlled != null && Controlled.teamID == attacker?.teamID)
{
CharacterHUD.ShowBossHealthBar(this);
}
@@ -3990,7 +3990,7 @@ namespace Barotrauma
public bool IsProtectedFromPressure()
{
return PressureProtection >= (Level.Loaded?.GetRealWorldDepth(WorldPosition.Y) ?? 0.0f);
return PressureProtection >= (Level.Loaded?.GetRealWorldDepth(WorldPosition.Y) ?? 1.0f);
}
}
}
@@ -344,7 +344,7 @@ namespace Barotrauma
return new string[][]
{
GameMain.NetworkMember.ConnectedClients.Select(c => c.Name).ToArray(),
commands.Select(c => c.names[0]).ToArray()
commands.Select(c => c.names[0]).Union(new string[]{ "All" }).ToArray()
};
}));
@@ -356,7 +356,7 @@ namespace Barotrauma
return new string[][]
{
GameMain.NetworkMember.ConnectedClients.Select(c => c.Name).ToArray(),
new string[0]
commands.Select(c => c.names[0]).Union(new string[]{ "All" }).ToArray()
};
}));
@@ -215,7 +215,7 @@ namespace Barotrauma
float dist = Vector2.DistanceSquared(pos, refSub.WorldPosition);
foreach (Submarine sub in Submarine.Loaded)
{
if (sub.Info.Type != SubmarineType.Player) { continue; }
if (sub.Info.Type != SubmarineType.Player && sub != GameMain.NetworkMember?.RespawnManager?.RespawnShuttle) { continue; }
float minDistToSub = GetMinDistanceToSub(sub);
if (dist < minDistToSub * minDistToSub) { continue; }
@@ -443,6 +443,7 @@ namespace Barotrauma.Items.Components
}
else
{
//not attached -> pick the item instantly, ignoring picking time
return OnPicked(picker);
}
@@ -450,6 +451,10 @@ namespace Barotrauma.Items.Components
public override bool OnPicked(Character picker)
{
if (GameMain.NetworkMember != null && GameMain.NetworkMember.IsClient)
{
return false;
}
if (base.OnPicked(picker))
{
DeattachFromWall();
@@ -347,10 +347,10 @@ namespace Barotrauma.Items.Components
for (int i = item.LastSentSignalRecipients.Count - 1; i >= 0; i--)
{
if (item.LastSentSignalRecipients[i].Condition <= 0.0f) continue;
if (item.LastSentSignalRecipients[i].Prefab.FocusOnSelected)
if (item.LastSentSignalRecipients[i].Item.Condition <= 0.0f) { continue; }
if (item.LastSentSignalRecipients[i].Item.Prefab.FocusOnSelected)
{
return item.LastSentSignalRecipients[i];
return item.LastSentSignalRecipients[i].Item;
}
}
@@ -353,7 +353,7 @@ namespace Barotrauma.Items.Components
{
if (recipient.Item == item || recipient.Item == signal.source) { continue; }
signal.source?.LastSentSignalRecipients.Add(recipient.Item);
signal.source?.LastSentSignalRecipients.Add(recipient);
foreach (ItemComponent ic in recipient.Item.Components)
{
@@ -83,6 +83,8 @@ namespace Barotrauma.Items.Components
item = connectionPanel.Item;
MaxWires = element.GetAttributeInt("maxwires", DefaultMaxWires);
MaxWires = Math.Max(element.Elements().Count(e => e.Name.ToString().Equals("link", StringComparison.OrdinalIgnoreCase)), MaxWires);
MaxPlayerConnectableWires = element.GetAttributeInt("maxplayerconnectablewires", MaxWires);
wires = new Wire[MaxWires];
@@ -152,19 +154,15 @@ namespace Barotrauma.Items.Components
int index = -1;
for (int i = 0; i < MaxWires; i++)
{
if (wireId[i] < 1) index = i;
if (wireId[i] < 1) { index = i; }
}
if (index == -1) break;
if (index == -1) { break; }
int id = subElement.GetAttributeInt("w", 0);
if (id < 0)
{
id = 0;
}
if (id < 0) { id = 0; }
wireId[index] = idRemap.GetOffsetId(id);
break;
case "statuseffect":
Effects.Add(StatusEffect.Load(subElement, item.Name + ", connection " + Name));
break;
@@ -263,9 +261,9 @@ namespace Barotrauma.Items.Components
Connection recipient = wires[i].OtherConnection(this);
if (recipient == null) { continue; }
if (recipient.item == this.item || signal.source?.LastSentSignalRecipients.LastOrDefault() == recipient.item) { continue; }
if (recipient.item == this.item || signal.source?.LastSentSignalRecipients.LastOrDefault() == recipient) { continue; }
signal.source?.LastSentSignalRecipients.Add(recipient.item);
signal.source?.LastSentSignalRecipients.Add(recipient);
Connection connection = recipient;
@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
{
string signalOut = MotionDetected ? Output : FalseOutput;
if (!string.IsNullOrEmpty(signalOut)) item.SendSignal( new Signal(signalOut, 1), "state_out");
if (!string.IsNullOrEmpty(signalOut)) { item.SendSignal(new Signal(signalOut, 1), "state_out"); }
updateTimer -= deltaTime;
if (updateTimer > 0.0f) return;
@@ -173,11 +173,11 @@ namespace Barotrauma.Items.Components
if (signal.source != null)
{
foreach (Item receiverItem in wifiComp.item.LastSentSignalRecipients)
foreach (Connection receiver in wifiComp.item.LastSentSignalRecipients)
{
if (!signal.source.LastSentSignalRecipients.Contains(receiverItem))
if (!signal.source.LastSentSignalRecipients.Contains(receiver))
{
signal.source.LastSentSignalRecipients.Add(receiverItem);
signal.source.LastSentSignalRecipients.Add(receiver);
}
}
}
@@ -439,8 +439,8 @@ namespace Barotrauma.Items.Components
var projectiles = GetLoadedProjectiles(true);
if (projectiles.Any())
{
ItemContainer projectileContainer = projectiles.First().Item.Container?.GetComponent<ItemContainer>();
projectileContainer?.Item.Use(deltaTime, null);
ItemContainer projectileContainer = projectiles.First().Item.Container?.GetComponent<ItemContainer>();
if (projectileContainer?.Item != item) { projectileContainer?.Item.Use(deltaTime, null); }
}
else
{
@@ -593,13 +593,13 @@ namespace Barotrauma
}
/// <summary>
/// A list of items the last signal sent by this item went through
/// A list of connections the last signal sent by this item went through
/// </summary>
public List<Item> LastSentSignalRecipients
public List<Connection> LastSentSignalRecipients
{
get;
private set;
} = new List<Item>(20);
} = new List<Connection>(20);
public string ConfigFile
{
@@ -1921,7 +1921,7 @@ namespace Barotrauma
//if the signal has been passed through this item multiple times already, interrupt it to prevent infinite loops
if (signal.source != null)
{
if (signal.source.LastSentSignalRecipients.Count(recipient => recipient == this) > 2)
if (signal.source.LastSentSignalRecipients.Count(recipient => recipient == connection) > 2)
{
return;
}
@@ -1887,7 +1887,9 @@ namespace Barotrauma
}
}
shortestDistSqr = Math.Min(shortestDistSqr, MathUtils.DistanceSquared((double)point.X, (double)point.Y, (double)startPosition.X, (double)startPosition.Y));
shortestDistSqr = Math.Min(shortestDistSqr, MathUtils.DistanceSquared((double)point.X, (double)point.Y, (double)startExitPosition.X, (double)borders.Bottom));
shortestDistSqr = Math.Min(shortestDistSqr, MathUtils.DistanceSquared((double)point.X, (double)point.Y, (double)endPosition.X, (double)endPosition.Y));
shortestDistSqr = Math.Min(shortestDistSqr, MathUtils.DistanceSquared((double)point.X, (double)point.Y, (double)endExitPosition.X, (double)borders.Bottom));
distanceField.Add((point, Math.Sqrt(shortestDistSqr)));
}
}
@@ -101,6 +101,7 @@ namespace Barotrauma
sl.filePath = filePath;
sl.saveElement = doc.Root;
sl.saveElement.Name = "LinkedSubmarine";
sl.saveElement.SetAttributeValue("filepath", filePath);
return sl;
}
@@ -48,7 +48,14 @@ namespace Barotrauma
if (!Enabled) { return; }
if (steps <= 0) { return; }
IncreaseRadiation(Params.RadiationStep * steps);
float increaseAmount = Params.RadiationStep * steps;
if (Params.MaxRadiation > 0 && Params.MaxRadiation < Amount + increaseAmount)
{
increaseAmount = Params.MaxRadiation - Amount;
}
IncreaseRadiation(increaseAmount);
int amountOfOutposts = Map.Locations.Count(location => location.Type.HasOutpost && !location.IsCriticallyRadiated());
@@ -30,6 +30,9 @@ namespace Barotrauma
[Serialize(defaultValue: 1f, isSaveable: false, "How much is the radiation affliction increased by while in a radiated zone.")]
public float RadiationDamageAmount { get; set; }
[Serialize(defaultValue: -1.0f, isSaveable: false, "Maximum amount of radiation.")]
public float MaxRadiation { get; set; }
[Serialize(defaultValue: "139,0,0,85", isSaveable: false, "The color of the radiated area.")]
public Color RadiationAreaColor { get; set; }
@@ -870,10 +870,10 @@ namespace Barotrauma
foreach (Item item in Item.ItemList)
{
if (item.Submarine != submarine || item.CurrentHull == null ||
item.body == null || !item.body.Enabled) continue;
if (item.Submarine != submarine || item.CurrentHull == null || item.body == null || !item.body.Enabled) { continue; }
item.body.ApplyLinearImpulse(item.body.Mass * impulse, 10.0f);
item.PositionUpdateInterval = 0.0f;
}
float dmg = applyDamage ? impact * ImpactDamageMultiplier : 0.0f;
@@ -8,7 +8,18 @@ namespace Barotrauma.Networking
{
public enum ChatMessageType
{
Default, Error, Dead, Server, Radio, Private, Console, MessageBox, Order, ServerLog, ServerMessageBox, ServerMessageBoxInGame
Default = 0,
Error = 1,
Dead = 2,
Server = 3,
Radio = 4,
Private = 5,
Console = 6,
MessageBox = 7,
Order = 8,
ServerLog = 9,
ServerMessageBox = 10,
ServerMessageBoxInGame = 11
}
public enum PlayerConnectionChangeType { None = 0, Joined = 1, Kicked = 2, Disconnected = 3, Banned = 4 }
@@ -173,7 +173,7 @@ namespace Barotrauma.Networking
#endif
protected ServerSettings serverSettings;
protected TimeSpan updateInterval;
protected DateTime updateTimer;
@@ -55,6 +55,14 @@ namespace Barotrauma.Networking
public State CurrentState { get; private set; }
public bool UseRespawnPrompt
{
get
{
return GameMain.GameSession?.GameMode is CampaignMode && Level.Loaded != null && Level.Loaded?.Type != LevelData.LevelType.Outpost;
}
}
private float maxTransportTime;
private float updateReturnTimer;
@@ -33,6 +33,12 @@
GUI.ScreenChanged = true;
}
SubmarinePreview.Close();
// Make sure the saving indicator is disabled when returning to main menu or lobby
if (this == GameMain.MainMenuScreen || this == GameMain.NetLobbyScreen)
{
GUI.DisableSavingIndicatorDelayed();
}
#endif
}
selected = this;