Skip to content

Commit

Permalink
v0.5.1.2: spawnitem console command, "spawn inside" always spawns cha…
Browse files Browse the repository at this point in the history
…racters in the main sub, a new music clip, modified the topwindow sprite a bit
  • Loading branch information
Regalis committed Aug 31, 2016
1 parent 8142cc7 commit 2c51ba5
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 30 deletions.
3 changes: 3 additions & 0 deletions Subsurface/Barotrauma.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,9 @@
<None Include="Content\Sounds\Music\Enter the Maze.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Music\Phantom From Space.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Content\Sounds\Music\Road to Hell.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Binary file modified Subsurface/Content/Map/testroom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
1 change: 1 addition & 0 deletions Subsurface/Content/Sounds/sounds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

<music file="Content/Sounds/Music/Enter the Maze.ogg" type="repair" priorityrange="30,60"/>
<music file="Content/Sounds/Music/Static Motion.ogg" type="repair" priorityrange="50,80"/>
<music file="Content/Sounds/Music/Phantom From Space.ogg" type="monster" priorityrange="25,60"/>
<music file="Content/Sounds/Music/Unseen Horrors.ogg" type="monster" priorityrange="40,100"/>

<music file="Content/Sounds/Music/amb_JD_drone_clattering_machine.ogg" type="deep"/>
Expand Down
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.1.1")]
[assembly: AssemblyFileVersion("0.5.1.1")]
[assembly: AssemblyVersion("0.5.1.2")]
[assembly: AssemblyFileVersion("0.5.1.2")]
54 changes: 52 additions & 2 deletions Subsurface/Source/DebugConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public static void ExecuteCommand(string command, GameMain game)
NewMessage(" ", Color.Cyan);

NewMessage("spawn [creaturename] [near/inside/outside]: spawn a creature at a random spawnpoint (use the second parameter to only select spawnpoints near/inside/outside the submarine)", Color.Cyan);
NewMessage("spawnitem [itemname] [cursor/inventory]: spawn an item at the position of the cursor, in the inventory of the controlled character or at a random spawnpoint if the last parameter is omitted", Color.Cyan);

NewMessage(" ", Color.Cyan);

Expand All @@ -200,7 +201,7 @@ public static void ExecuteCommand(string command, GameMain game)
NewMessage("revive: bring the controlled character back from the dead", Color.Cyan);

NewMessage(" ", Color.Cyan);

NewMessage("fixwalls: fixes all the walls", Color.Cyan);
NewMessage("fixitems: fixes every item/device in the sub", Color.Cyan);
NewMessage("oxygen: replenishes the oxygen in every room to 100%", Color.Cyan);
Expand All @@ -219,6 +220,7 @@ public static void ExecuteCommand(string command, GameMain game)
UpdaterUtil.SaveFileList("filelist.xml");
break;
case "spawn":
case "spawncharacter":
if (commands.Length == 1) return;

Character spawnedCharacter = null;
Expand All @@ -231,7 +233,7 @@ public static void ExecuteCommand(string command, GameMain game)
switch (commands[2].ToLowerInvariant())
{
case "inside":
spawnPoint = WayPoint.GetRandom(SpawnType.Human);
spawnPoint = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
break;
case "outside":
spawnPoint = WayPoint.GetRandom(SpawnType.Enemy);
Expand Down Expand Up @@ -294,6 +296,54 @@ public static void ExecuteCommand(string command, GameMain game)
GameMain.Server.SendCharacterSpawnMessage(spawnedCharacter);
}

break;
case "spawnitem":
if (commands.Length < 2) return;

Vector2? spawnPos = null;
Inventory spawnInventory = null;

int extraParams = 0;
switch (commands.Last())
{
case "cursor":
extraParams = 1;
spawnPos = GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
break;
case "inventory":
extraParams = 1;
spawnInventory = Character.Controlled == null ? null : Character.Controlled.Inventory;
break;
default:
extraParams = 0;
break;
}

string itemName = string.Join(" ", commands.Skip(1).Take(commands.Length - extraParams - 1)).ToLowerInvariant();

var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab;
if (itemPrefab == null)
{
ThrowError("Item \""+itemName+"\" not found!");
return;
}

if (spawnPos == null && spawnInventory == null)
{
var wp = WayPoint.GetRandom(SpawnType.Human, null, Submarine.MainSub);
spawnPos = wp == null ? Vector2.Zero : wp.WorldPosition;
}

if (spawnPos != null)
{
Item.Spawner.QueueItem(itemPrefab, (Vector2)spawnPos, false);

}
else if (spawnInventory != null)
{
Item.Spawner.QueueItem(itemPrefab, (Inventory)spawnInventory, false);
}

break;
case "disablecrewai":
HumanAIController.DisableCrewAI = !HumanAIController.DisableCrewAI;
Expand Down
46 changes: 20 additions & 26 deletions Subsurface/Source/Items/ItemSpawner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ public ItemSpawner()
spawnQueue = new Queue<Pair<ItemPrefab, object>>();
}

//public void QueueItem(ItemPrefab itemPrefab, Vector2 position, bool isNetworkMessage = false)
//{
// if (!isNetworkMessage && GameMain.Client!=null)
// {
// //clients aren't allowed to spawn new items unless the server says so
// return;
// }
public void QueueItem(ItemPrefab itemPrefab, Vector2 worldPosition, bool isNetworkMessage = false)
{
if (!isNetworkMessage && GameMain.Client != null)
{
//clients aren't allowed to spawn new items unless the server says so
return;
}

// var itemInfo = new Pair<ItemPrefab, object>();
// itemInfo.First = itemPrefab;
// itemInfo.Second = position;
var itemInfo = new Pair<ItemPrefab, object>();
itemInfo.First = itemPrefab;
itemInfo.Second = worldPosition;

// spawnQueue.Enqueue(itemInfo);
//}
spawnQueue.Enqueue(itemInfo);
}

public void QueueItem(ItemPrefab itemPrefab, Inventory inventory, bool isNetworkMessage = false)
{
Expand Down Expand Up @@ -58,26 +58,22 @@ public void Update()
{
var itemInfo = spawnQueue.Dequeue();

//if (itemInfo.Second is Vector2)
//{
// //todo: take multiple subs into account
// Vector2 position = (Vector2)itemInfo.Second - Submarine.MainSub.HiddenSubPosition;

// items.Add(new Item(itemInfo.First, position, null));
// inventories.Add(null);
if (itemInfo.Second is Vector2)
{
var item = new Item(itemInfo.First, (Vector2)itemInfo.Second, null);
AddToSpawnedList(item);

//}
//else
if (itemInfo.Second is Inventory)
items.Add(item);
}
else if (itemInfo.Second is Inventory)
{
var item = new Item(itemInfo.First, Vector2.Zero, null);
AddToSpawnedList(item);

var inventory = (Inventory)itemInfo.Second;
inventory.TryPutItem(item, null, false);
inventory.TryPutItem(item, item.AllowedSlots, false);

items.Add(item);
//inventories.Add(inventory);
}
}

Expand Down Expand Up @@ -131,8 +127,6 @@ public void ReadNetworkData(Lidgren.Network.NetBuffer message)
Vector2 pos = Vector2.Zero;
ushort inventoryId = message.ReadUInt16();

Submarine sub = null;

int inventorySlotIndex = -1;

if (inventoryId > 0)
Expand Down
10 changes: 10 additions & 0 deletions Subsurface/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
---------------------------------------------------------------------------------------------------------
v0.5.1.2
---------------------------------------------------------------------------------------------------------

- hacked clients can't join a full server or change the name of their character anymore
- option to choose which character to control using the "control" command when there are multiple
characters/creatures with the same name
- a console command for spawning items
- the server logs show who sent each chat message

---------------------------------------------------------------------------------------------------------
v0.5.1.1
---------------------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 2c51ba5

Please sign in to comment.