Option to make MonsterEvents spawn more monsters when previous ones are killed (to prevent predators from clearing the ocean of weaker creatures)
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
<Randomevents>
|
<Randomevents>
|
||||||
<MonsterEvent name="Under attack" description=""
|
<MonsterEvent name="Under attack" description=""
|
||||||
characterfile="Content/Characters/Crawler/crawler.xml"
|
characterfile="Content/Characters/Crawler/crawler.xml"
|
||||||
commonness="10"
|
commonness="15"
|
||||||
difficulty="10"
|
difficulty="10"
|
||||||
minamount="2" maxamount="3"
|
minamount="2" maxamount="3"
|
||||||
|
repeat="true"
|
||||||
spawntype="mainpath,cave,ruin"
|
spawntype="mainpath,cave,ruin"
|
||||||
musictype="monster"/>
|
musictype="monster"/>
|
||||||
|
|
||||||
@@ -20,13 +21,14 @@
|
|||||||
characterfile="Content/Characters/Moloch/moloch.xml"
|
characterfile="Content/Characters/Moloch/moloch.xml"
|
||||||
commonness="10"
|
commonness="10"
|
||||||
difficulty="30"
|
difficulty="30"
|
||||||
spawntype="mainpath"
|
spawntype="mainpath"
|
||||||
musictype="monster"/>
|
musictype="monster"/>
|
||||||
|
|
||||||
<MonsterEvent name="Under attack" description=""
|
<MonsterEvent name="Under attack" description=""
|
||||||
characterfile="Content/Characters/Mantis/mantis.xml"
|
characterfile="Content/Characters/Mantis/mantis.xml"
|
||||||
commonness="10"
|
commonness="10"
|
||||||
difficulty="15"
|
difficulty="15"
|
||||||
|
repeat="true"
|
||||||
minamount="1" maxamount="2"
|
minamount="1" maxamount="2"
|
||||||
spawntype="mainpath,cave,ruin"
|
spawntype="mainpath,cave,ruin"
|
||||||
musictype="monster"/>
|
musictype="monster"/>
|
||||||
@@ -70,7 +72,7 @@
|
|||||||
commonness="5"
|
commonness="5"
|
||||||
difficulty="10"
|
difficulty="10"
|
||||||
minamount="2" maxamount="3"
|
minamount="2" maxamount="3"
|
||||||
|
repeat="true"
|
||||||
spawntype="mainpath,cave,ruin"
|
spawntype="mainpath,cave,ruin"
|
||||||
musictype="monster"/>
|
musictype="monster"/>
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ namespace Barotrauma
|
|||||||
private bool spawnDeep;
|
private bool spawnDeep;
|
||||||
|
|
||||||
private bool disallowed;
|
private bool disallowed;
|
||||||
|
|
||||||
|
private bool repeat;
|
||||||
|
|
||||||
private Level.PositionType spawnPosType;
|
private Level.PositionType spawnPosType;
|
||||||
|
|
||||||
@@ -39,7 +41,9 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
characterFile = ToolBox.GetAttributeString(element, "characterfile", "");
|
characterFile = ToolBox.GetAttributeString(element, "characterfile", "");
|
||||||
|
|
||||||
minAmount = ToolBox.GetAttributeInt(element, "minamount", 1);
|
int defaultAmount = ToolBox.GetAttributeInt(element, "amount", 1);
|
||||||
|
|
||||||
|
minAmount = ToolBox.GetAttributeInt(element, "minamount", defaultAmount);
|
||||||
maxAmount = Math.Max(ToolBox.GetAttributeInt(element, "maxamount", 1), minAmount);
|
maxAmount = Math.Max(ToolBox.GetAttributeInt(element, "maxamount", 1), minAmount);
|
||||||
|
|
||||||
var spawnPosTypeStr = ToolBox.GetAttributeString(element, "spawntype", "");
|
var spawnPosTypeStr = ToolBox.GetAttributeString(element, "spawntype", "");
|
||||||
@@ -52,6 +56,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
|
spawnDeep = ToolBox.GetAttributeBool(element, "spawndeep", false);
|
||||||
|
|
||||||
|
repeat = ToolBox.GetAttributeBool(element, "repeat", repeat);
|
||||||
|
|
||||||
if (GameMain.NetworkMember != null)
|
if (GameMain.NetworkMember != null)
|
||||||
{
|
{
|
||||||
List<string> monsterNames = GameMain.NetworkMember.monsterEnabled.Keys.ToList();
|
List<string> monsterNames = GameMain.NetworkMember.monsterEnabled.Keys.ToList();
|
||||||
@@ -67,18 +73,17 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
base.Init();
|
base.Init();
|
||||||
|
|
||||||
SpawnMonsters();
|
SpawnMonsters(Rand.Range(minAmount, maxAmount, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SpawnMonsters()
|
private Character[] SpawnMonsters(int amount)
|
||||||
{
|
{
|
||||||
if (disallowed) return;
|
if (disallowed) return null;
|
||||||
|
|
||||||
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
|
Vector2 spawnPos = Level.Loaded.GetRandomInterestingPosition(true, spawnPosType, true);
|
||||||
|
|
||||||
int amount = Rand.Range(minAmount, maxAmount, false);
|
|
||||||
|
|
||||||
monsters = new Character[amount];
|
var monsters = new Character[amount];
|
||||||
|
|
||||||
if (spawnDeep) spawnPos.Y -= Level.Loaded.Size.Y;
|
if (spawnDeep) spawnPos.Y -= Level.Loaded.Size.Y;
|
||||||
|
|
||||||
@@ -88,6 +93,8 @@ namespace Barotrauma
|
|||||||
spawnPos.Y += Rand.Range(-0.5f, 0.5f, false);
|
spawnPos.Y += Rand.Range(-0.5f, 0.5f, false);
|
||||||
monsters[i] = Character.Create(characterFile, spawnPos, null, GameMain.Client != null);
|
monsters[i] = Character.Create(characterFile, spawnPos, null, GameMain.Client != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return monsters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float deltaTime)
|
public override void Update(float deltaTime)
|
||||||
@@ -97,7 +104,29 @@ namespace Barotrauma
|
|||||||
Finished();
|
Finished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (monsters == null) SpawnMonsters();
|
|
||||||
|
if (monsters == null)
|
||||||
|
{
|
||||||
|
monsters = SpawnMonsters(Rand.Range(minAmount, maxAmount, false));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (repeat)
|
||||||
|
{
|
||||||
|
//clients aren't allowed to spawn more monsters mid-round
|
||||||
|
if (GameMain.Client != null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < monsters.Length; i++)
|
||||||
|
{
|
||||||
|
if (monsters[i] == null || monsters[i].Removed || monsters[i].IsDead)
|
||||||
|
{
|
||||||
|
monsters[i] = SpawnMonsters(1)[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isFinished) return;
|
if (isFinished) return;
|
||||||
|
|
||||||
@@ -128,7 +157,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (monstersDead) Finished();
|
if (monstersDead && !repeat) Finished();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user