Coder Social home page Coder Social logo

libswbf2 / swbf2phoenix Goto Github PK

View Code? Open in Web Editor NEW
70.0 70.0 12.0 10.43 MB

A re-implementation of the old Star Wars Battlefront II (2005) game, utilizing the Unity game engine

License: GNU Affero General Public License v3.0

C# 96.00% Batchfile 0.57% ShaderLab 2.05% Shell 0.50% GLSL 0.88%

swbf2phoenix's Introduction

LibSWBF2

C++ Library handling files from Star Wars Battlefront 2 (2005) and the Mod Tools.
still developing. Looking for participants.

Join us on Discord

This library is capable of reading various proprietary file formats from the old Star Wars Battlefront 2 game, focusing primarily on munged file formats, and providing desired data (models, textures, terrain, sounds, etc...) to the user in a high level, easy to use manner.
From how this library is implemented on a low level, altering any value, or even creating a munged file from scratch is technically possible, although at this point write serializers are not implemented yet.

Examples

How to grab the image data of a single texture (no nullptr/success checks applied here for more readability)

using LibSWBF2::Wrappers::Level;
using LibSWBF2::Wrappers::Texture;
using LibSWBF2::ETextureFormat;

Level* lvl = Level::FromFile("geo1.lvl");
const Texture* texture = lvl->GetTexture("geo_main_1");

uint16_t width, height;
const uint8_t* data;

// param 1: Desired format you want the image data to be in. 
//          Resulting data is always uncompressed. 
//          The lib handles decompression and conversion, if necessary
// param 2: Mip map index. Use 0 to always get the highest available resolution.
texture->GetImageData(ETextureFormat::B8_G8_R8_A8, 0, width, height, data);

// ... now, do what you want with the image data. copy, export, whatever.

Level::Destroy(lvl);

Note that the data pointer will get invalid once the Level instance is destroyed.

Everything else is handled in a similar manner. An overview of available calls:

GetModels()
GetTextures()
GetWorlds()
GetTerrains()
GetScripts()
GetSounds()

GetModel(String modelName)
GetTexture(String textureName)
GetWorld(String worldName)
GetTerrain(String terrainName)
GetScript(String scriptName)
GetSound(String soundName)

Supported file formats

  • MSH
  • LVL
  • BNK
  • ZAFBIN
  • ZAABIN

Build

This project uses CMake

swbf2phoenix's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

swbf2phoenix's Issues

Implement Map Boundary Check

Check whether the player “leaves” the map. A Map Boundary is defined as a special path in ZE like this:

grafik

The Zero Editor just allows for oval like convex path shapes. Multiple, overlapping boundaries are possible, like on Hoth:

grafik

Technically, you could also define other shapes by changing the path name inside the .BND world file manually to another path previously defined in ZE. Although I don't know the behaviour of the original game engine when dealing with such shapes, there's probably a reason for the ZE to only allow convex oval shapes.

grafik

Humanoid Animation Controller

Finish the humanoid Animation controller, a.k.a. do a proper implementation covering all animation banks and such. Combo files will be a separate task.

Fix Lua Runtime Callback pool

Having just a fixed amount of Lua callbacks available could lead to broken Lua behaviour for maps using more than 200.

What I can think of right now:

  • Greatly increase available callback pool (meh)
  • Provide some other callback pointer mapping within the Lua DLL we can then use in C# to determine who exactly is calling us

Also, ensure all callbacks are indeed removed when the Environment gets deleted!

grafik

grafik

liblua50 error on Mac

When trying to build the project on Mac appears an error about liblua50-swbf2-x64 not found. There is an error with the file name.
To solve this open LuaWrapper.cs:19 to const string LIB_NAME = "liblua50"; and copy the file called liblua50.dylib from SWBF2Phoenix/lua5.0-swbf2-x64/bin to Assets/Lib

Map Texture placement

The placement of the Map textures is not quite right atm. The first approach was to take the mean of all command posts positions as a base to figure out the dimensions to use.

grafik

Maps can however define a "Mapbounds" region that is apparently used for this calculation. Find out how exactly, and how the engine behaves when no "Mapbounds" region is present. Then implement it accordingly.

grafik

Vehicles don't get destroyed on map switch

When switching to another map, or the main menu, all spawned vehicles don't get destroyed with the map itself. They should get destroyed when PhxRuntimeScene::Destroy is called.

grafik

Movie Playback

Needs implementation of LibSWBF2/LibSWBF2#35 first.

From a quick search, I found these Lua API calls regarding movies:

ScriptCB_OpenMovie
ScriptCB_CloseMovie
ScriptCB_PlayMovie
ScriptCB_StopMovie
ScriptCB_IsMoviePlaying
ScriptCB_PlayInGameMovie
SetMissionEndMovie

Where ScriptCB_PlayInGameMovie and SetMissionEndMovie are used in map scripts, while the rest is used in UI scripts.

There're also these commented out calls:
grafik

But Idk whether these are simply not used or the API call was removed. Test this out.

State Machine that incorporates Combo's

We need to create an animation state machine that mirrors the original one in such a way that Combo definitions are useable. Combo definitions are used by artists to override or declare new animations states, transitions, etc.

grafik

Simple AI

Needs #10 to be implemented beforehand.

Implement a simple AI, using the available AI goals used in the AddAIGoal Lua API calls. Also, make the AI goal changeable through said API call.

grafik

User input wrapping

Wrap user input from Unity to the specific Battlefront user inputs, like used in combo files:

grafik

AI Navigation Paths

In the ZE, you can define planning paths with hubs and connections between them:

grafik

Question is, will we use this information, or use Unity's Navigation Mesh, or a hybrid of both?
Note that different planning paths can target different types of AI: Soldier, Hover, Flyer, etc.

Also import AI HintNodes:

grafik

Commandpost Icons

Implement the rotating (and randomly jittering) holo icon displayed on command posts. Implement a custom shader for the holo effect (fragment shader) and the jittering (vertex shader).

Find out what defines the 3D command post icon of a team and ensure the correct icon is displayed accordingly.

grafik

Implement Entity Markers

Implement entity markers, as used in the campaign. The respective Lua API calls are MapAddEntityMarker and MapRemoveEntityMarker.

Note that Entity Markers:

  • Can be of any color
  • Are also displayed as pulsating circles on the map
  • Are displayed on the HUD corner when not in the view frustum (maybe with a padding?)
  • There can be multiple active at once

grafik

Directional Lights with Bounding Region

In ZE, you can place directional lights that are bound to a specific region, meaning the directional light will only be in effect within the bounds of that region, instead of globally. Here's an example on Mustafar of a directional light, color 255,255,255, being bound to a region called "walkway 2".

grafik

Unity doesn't have a possibility out of the box for directional lights to replicate that behaviour, instead we're currently disabling those lights, as they would emit everything globally otherwise:

grafik

Question is, how to approach this? Should we create our custom default shader that takes these lights into account and illuminate everything within the bounds of that region respectively? Or should we replace them with Area lights? Or make an array of Spotlights (please don't)?

Map Animations (Phoenix)

Needs Importer Issue #4 to be done beforehand.

In ZE, you can define Animations to move objects around. These can be triggered in Lua via PlayAnimation, PauseAnimation and RewindAnimation. One example of this would be the bridge on Mustafar, moving down when the control panels are destroyed and moving up again when repaired.

grafik

Store references to all created map animations in PhxRuntimeScene and let the Lua API calls PlayAnimation, PauseAnimation and RewindAnimation trigger the respective action for a given animation name.

Implement Objective Popup

In the campaign, objective popup overlays are used to inform the player of a new objective. The respective Lua API calls is ShowObjectiveTextPopup and uses a localization path for the input text.

Note that the popup will pause the game in singleplayer.

grafik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.