Unstable v0.19.1.0
This commit is contained in:
@@ -125,8 +125,7 @@ namespace Barotrauma
|
||||
var file = CharacterPrefab.FindBySpeciesName(SpeciesName)?.ContentFile;
|
||||
if (file == null)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to find config file for species \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
DebugConsole.ThrowError($"Failed to find config file for species \"{SpeciesName}\"");
|
||||
yield break;
|
||||
}
|
||||
else
|
||||
@@ -147,6 +146,32 @@ namespace Barotrauma
|
||||
{
|
||||
DebugConsole.NewMessage("Initialized MonsterEvent (" + SpeciesName + ")", Color.White);
|
||||
}
|
||||
|
||||
monsters = new List<Character>();
|
||||
|
||||
//+1 because Range returns an integer less than the max value
|
||||
int amount = Rand.Range(MinAmount, MaxAmount + 1);
|
||||
for (int i = 0; i < amount; i++)
|
||||
{
|
||||
string seed = Level.Loaded.Seed + i.ToString();
|
||||
Character createdCharacter = Character.Create(SpeciesName, Vector2.Zero, seed, characterInfo: null, isRemotePlayer: false, hasAi: true, createNetworkEvent: true, throwErrorIfNotFound: false);
|
||||
if (createdCharacter == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error in MonsterEvent: failed to spawn the character \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
continue;
|
||||
}
|
||||
if (GameMain.GameSession.IsCurrentLocationRadiated())
|
||||
{
|
||||
AfflictionPrefab radiationPrefab = AfflictionPrefab.RadiationSickness;
|
||||
Affliction affliction = new Affliction(radiationPrefab, radiationPrefab.MaxStrength);
|
||||
createdCharacter?.CharacterHealth.ApplyAffliction(null, affliction);
|
||||
// TODO test multiplayer
|
||||
createdCharacter?.Kill(CauseOfDeathType.Affliction, affliction, log: false);
|
||||
}
|
||||
createdCharacter.DisabledByEvent = true;
|
||||
monsters.Add(createdCharacter);
|
||||
}
|
||||
}
|
||||
|
||||
private List<Level.InterestingPosition> GetAvailableSpawnPositions()
|
||||
@@ -487,9 +512,6 @@ namespace Barotrauma
|
||||
|
||||
spawnPending = false;
|
||||
|
||||
//+1 because Range returns an integer less than the max value
|
||||
int amount = Rand.Range(MinAmount, MaxAmount + 1);
|
||||
monsters = new List<Character>();
|
||||
float scatterAmount = scatter;
|
||||
if (SpawnPosType.HasFlag(Level.PositionType.SidePath))
|
||||
{
|
||||
@@ -508,9 +530,9 @@ namespace Barotrauma
|
||||
scatterAmount = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < amount; i++)
|
||||
int i = 0;
|
||||
foreach (Character monster in monsters)
|
||||
{
|
||||
string seed = Level.Loaded.Seed + i.ToString();
|
||||
CoroutineManager.Invoke(() =>
|
||||
{
|
||||
//round ended before the coroutine finished
|
||||
@@ -533,45 +555,33 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Character createdCharacter = Character.Create(SpeciesName, pos, seed, characterInfo: null, isRemotePlayer: false, hasAi: true, createNetworkEvent: true, throwErrorIfNotFound: false);
|
||||
if (createdCharacter == null)
|
||||
{
|
||||
DebugConsole.AddWarning($"Error in MonsterEvent: failed to spawn the character \"{SpeciesName}\". Content package: \"{prefab.ConfigElement?.ContentPackage?.Name ?? "unknown"}\".");
|
||||
disallowed = true;
|
||||
return;
|
||||
}
|
||||
monster.Enabled = true;
|
||||
monster.DisabledByEvent = false;
|
||||
monster.AnimController.SetPosition(FarseerPhysics.ConvertUnits.ToSimUnits(pos));
|
||||
|
||||
var eventManager = GameMain.GameSession.EventManager;
|
||||
if (eventManager != null)
|
||||
{
|
||||
if (SpawnPosType.HasFlag(Level.PositionType.MainPath) || SpawnPosType.HasFlag(Level.PositionType.SidePath))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthMain += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthMain += monster.Params.AI.CombatStrength;
|
||||
eventManager.AddTimeStamp(this);
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Ruin))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthRuins += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthRuins += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Wreck))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthWrecks += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthWrecks += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
else if (SpawnPosType.HasFlag(Level.PositionType.Cave))
|
||||
{
|
||||
eventManager.CumulativeMonsterStrengthCaves += createdCharacter.Params.AI.CombatStrength;
|
||||
eventManager.CumulativeMonsterStrengthCaves += monster.Params.AI.CombatStrength;
|
||||
}
|
||||
}
|
||||
if (GameMain.GameSession.IsCurrentLocationRadiated())
|
||||
{
|
||||
AfflictionPrefab radiationPrefab = AfflictionPrefab.RadiationSickness;
|
||||
Affliction affliction = new Affliction(radiationPrefab, radiationPrefab.MaxStrength);
|
||||
createdCharacter?.CharacterHealth.ApplyAffliction(null, affliction);
|
||||
// TODO test multiplayer
|
||||
createdCharacter?.Kill(CauseOfDeathType.Affliction, affliction, log: false);
|
||||
}
|
||||
monsters.Add(createdCharacter);
|
||||
|
||||
if (monsters.Count == amount)
|
||||
if (monster == monsters.Last())
|
||||
{
|
||||
spawnReady = true;
|
||||
//this will do nothing if the monsters have no swarm behavior defined,
|
||||
@@ -587,6 +597,7 @@ namespace Barotrauma
|
||||
value: Timing.TotalTime - GameMain.GameSession.RoundStartTime);
|
||||
}
|
||||
}, delayBetweenSpawns * i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user