The_BFME_API 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package The_BFME_API --version 1.0.0                
NuGet\Install-Package The_BFME_API -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="The_BFME_API" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add The_BFME_API --version 1.0.0                
#r "nuget: The_BFME_API, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install The_BFME_API as a Cake Addin
#addin nuget:?package=The_BFME_API&version=1.0.0

// Install The_BFME_API as a Cake Tool
#tool nuget:?package=The_BFME_API&version=1.0.0                

The-BFME-API

This Library allows you to launch and interact with BFME games as well as create virual LAN network rooms to play together even when you and other players are not on the same network.

Supported games

  • BFME1

Features

  • Create virtual LAN networks so you and your opponents can play while on completely different networks
  • Launch BFME as host or offhost and automaticaly:
    • Create a new room if host, or join the room the host created on that network if offhost
    • Set player username
    • Set player color
    • Select player army
    • Select player team
    • Select spot on map
    • Select map
    • Start the match
    • Detect who won the match

Spot detection

With some pretty clever code, this library is able to automaticaly detect spots from any map, and assign an index to them.

Spot detection example image.

There is also a MapSpotPreviewTool tool that allows you to render this image from any map image provided. This is extremely useful for mapmakers who want to make sure they put players on the same team in the correct spots.

Examples

There is a NetworkExample and a GameExample in this repository, those can provide a good understanding on how to use the library, but here are some basic examples...

Game client
// Create a game client and assign the player parameters to it
Bfme1Client gameClient = new Bfme1Client
{
    CancelationAssertion = CancellationAssertion,
    Username = "Hello world",
    PlayerColor = PlayerColor.Purple,
    MapId = "maps_5Cmap_20mp_20dagorlad_5Cmap_20mp_20dagorlad_2Emap",
    Army = PlayerArmy.Mordor,
    Team = PlayerTeam.Team4,
    Spot = 0
};

// Launch as host
await gameClient.LaunchAsHost();

// Launch as offhost
await gameClient.LaunchAsOffhost();

// If you are the host, start the game
gameClient.StartGame();

// Wait here until the win screen apears
await gameClient.WaitForWinScreen();

// And finaly close the game
await gameClient.CloseGame();
Networking
// Open a new virtual LAN network (virtual LAN network = room)
string newRoomId = await NetworkManagement.OpenRoom();

// Create a networking client
NetworkClient client = new NetworkClient();
await client.CleanUp();

// Join a room (in this case the one we just created)
await client.JoinRoom(newRoomId);

// Leave your room
await client.LeaveRoom();

// Close a room (in this case the one we just created)
await NetworkManagement.CloseRoom(newRoomId);

// And finaly dispose the client when we are done using it
client.Dispose();

Additional info

  • You can get a map's Id by doing the following:
    • Open the game
    • Go to Multiplayer>Network>Create game
    • Select the desired map
    • Click cancel
    • Open %appdata%/My Battle for Middle-earth Files/Network.ini and the Id of the map is the value for Map
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.1 98 10/17/2023
1.3.0 96 10/17/2023
1.2.1 100 10/16/2023
1.2.0 101 10/16/2023
1.1.1 102 10/15/2023
1.1.0 150 10/15/2023
1.0.0 150 10/14/2023