Fixed mutliplayer-only missions being taken into account in the eventprobability calculation even in single player mode, which missions are sp/mp-only is determined in the mission config files

This commit is contained in:
Regalis
2016-10-06 15:32:38 +03:00
parent 91539c5b84
commit 5e88d91cb8
6 changed files with 25 additions and 16 deletions
+5 -4
View File
@@ -178,11 +178,12 @@
<CombatMission
name="Search and Destroy"
description="[location1] and [location2] are at war! Eliminate the enemy crew and return to base."
commonness="100"
multiplayeronly="true"
commonness="20"
reward="2000"
successmessage="[winner] has defeated [loser]!"
failuremessage="Both crews have perished.">
<message header="Crew eliminated" text="[location1] has fallen! Navigate back to your base."/>
<message header="Crew eliminated" text="[location2] has fallen! Navigate back to your base."/>
failuremessage="Both crews have perished.">
<message header="Crew eliminated" text="[location1] has fallen! Navigate back to your base."/>
<message header="Crew eliminated" text="[location2] has fallen! Navigate back to your base."/>
</CombatMission>
</Missions>
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
class CargoMission : Mission, SinglePlayerMission
class CargoMission : Mission
{
private XElement itemConfig;
@@ -74,6 +74,12 @@ namespace Barotrauma
GameMain.Server.AllowRespawn = false;
}
if (GameMain.NetworkMember == null)
{
DebugConsole.ThrowError("Combat missions cannot be played in the single player mode.");
return;
}
Items.Components.Radar.StartMarker = Locations[0];
Items.Components.Radar.EndMarker = Locations[1];
TeamASub = Submarine.MainSubs[0];
@@ -159,6 +165,8 @@ namespace Barotrauma
public override void End()
{
if (GameMain.NetworkMember==null) return;
bool ADead = TeamACrew.All(c => c.IsDead || c.IsUnconscious);
bool BDead = TeamBCrew.All(c => c.IsDead || c.IsUnconscious);
+9 -9
View File
@@ -148,8 +148,15 @@ namespace Barotrauma
matchingElements = doc.Root.Elements().ToList().FindAll(m => m.Name.ToString().ToLowerInvariant().Replace("mission", "") == missionType);
}
if (isSinglePlayer)
{
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "multiplayeronly", false));
}
else
{
matchingElements.RemoveAll(m => ToolBox.GetAttributeBool(m, "singleplayeronly", false));
}
int i = 0;
foreach (XElement element in matchingElements)
{
@@ -185,8 +192,6 @@ namespace Barotrauma
continue;
}
if (isSinglePlayer && t.GetInterface("Barotrauma.SinglePlayerMission")==null) continue;
ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) });
object instance = constructor.Invoke(new object[] { element });
@@ -253,9 +258,4 @@ namespace Barotrauma
mode.Money += reward;
}
}
interface SinglePlayerMission
{
//all valid single player missions should inherit this
}
}
@@ -5,7 +5,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
class MonsterMission : Mission, SinglePlayerMission
class MonsterMission : Mission
{
private string monsterFile;
@@ -8,7 +8,7 @@ using System.Xml.Linq;
namespace Barotrauma
{
class SalvageMission : Mission, SinglePlayerMission
class SalvageMission : Mission
{
private ItemPrefab itemPrefab;