snake-biscuits / bsp_tool Goto Github PK
View Code? Open in Web Editor NEWPython library for analysing .bsp files
License: GNU General Public License v3.0
Python library for analysing .bsp files
License: GNU General Public License v3.0
TODO: find / make at least one guide
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO
I made a small script to play around with bsp_tool:
from bsp_tool import load_bsp
from bsp_tool.branches.respawn.apex_legends import LUMP
file = "/home/lee/Code/Mine/Analysis/ApexLegends/Maps/KingsCanyon/mp_rr_canyonlands_staging.bsp"
bsp = load_bsp(file)
bsp.read_lump(LUMP.ENTITIES)
Note I do have the ...0000.bsp_lump
.
But I'm unable to retrieve the entities lump:
$ python3 test.py
Loading mp_rr_canyonlands_staging.bsp (rBSP version 49)...
ERROR PARSING TEXDATA:
TEXDATA lump is an unusual size (400 / 36). Wrong engine branch?
Loaded mp_rr_canyonlands_staging.bsp
Traceback (most recent call last):
File "/home/lee/Code/Others/bsp_tool/test.py", line 6, in <module>
bsp.read_lump(LUMP.ENTITIES)
File "/home/lee/Code/Others/bsp_tool/bsp_tool/respawn.py", line 29, in read_lump
self.file.seek(self.branch.lump_header_address[LUMP])
ValueError: seek of closed file
After this I'm going to probably export the vertices to see some point clouds (as you've done in lump_analysis.py
).
Have you gotten chunks of the level to render with planes? Do you know how LOD is handled?
TODO
mapsrc/GtKRadiant/Quake 3 Arena/mp_lobby.map
-> maps/Quake 3 Arena/mp_lobby.bsp
sources.txt
crediting mapper / contributormaps/mp_lobby.bsp
in a .pk3
& copy into Quake 3 Arena/baseq3
.bsp.info.txt
file with vbspinfo output or compile logq3map2 -info > mp_lobby.bsp.info.txt
(anonymous filepaths)TODO
Maps are fullbright, we're working on it: see this MRVN-Radiant Issue for details
remap.exe -info
currently doesn't work for Titanfall Engine maps, so no .bsp.info.txt
mp_crossfire.map
uses Valve220 texture mapping, which breaks on compile
mapsrc/MRVN-Radiant/Titanfall 2/mp_crossfire.map
-> maps/Titanfall 2/mp_crossfire.bsp
sources.txt
crediting mapper(s) / contributor(s).bsp.info.txt
file with vbspinfo output or compile logNOTE: I'm manually copying maps into Northstar for testing rn, the workflow is a mess
how to use?
mapsrc/CoD4Radiant/mp_lobby.map
-> maps/Call of Duty 4/mp/mp_lobby.d3dbsp
sources.txt
entry crediting mapper / contributor.bsp.info.txt
file with vbspinfo output or compile logcod3map -info > mp_lobby.bsp.info.txt
mapsrc/CoD4Radiant/mp_test.map
-> maps/Call of Duty 4/mp/mp_test.d3dbsp
mapsrc/CoD4Radiant/test.map
-> maps/Call of Duty 4/test.d3dbsp
mapsrc/CoD4Radiant/test_traverses.map
-> maps/Call of Duty 4/test_traverses.d3dbsp
TODO: find at least one guide / tutorial
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoI'm currently trying to interact with the VPK using https://github.com/ValvePython/vpk but in my two samples, it says it's missing a magic number, and in the other it says it's invalid.
Does Apex Legends use some special VPK variant?
Hello! I didn't find a way to contact you directly so I have to ask it here.
I run a community and EU/RU server of the game called Counter-Strike Online 2 which works on the modified Source engine. It is possible to add different custom content to the game, but not the maps.
I'm looking for someone who is experienced in the .bsp format to create a map converter: CSS -> CSO2 or CSGO -> CSO2. If you like to try it I will drop you few CSO2 maps for investigation.
Error 1) Different BSP version, 100 expected. Can be bypassed by editing .bsp file in hex editor.
Error 2) Funny lump size. Stuck here.
I heard some guys bypassed the funny lump size error by adding zeroes at the end of the lumps, but they gave up at the upcoming errors.
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile logActive Mods / Modding Community
Once installed, CoD2ModTools will add a Docs/
folder to the CoD2 install
You will need to edit windows registry so the installer can find your CoD installation:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Activision\Call of Duty 2]
"InstallPath"="C:\\Program Files (x86)\\Activision\\Call of Duty 2\\"
"InstallDrive"="C:\\"
"Language"="enu"
"Version"="1.3"
"codkey"="XXXXXXXXXXXXXXXXXXXX"
"EXEString"="C:\\Program Files (x86)\\Activision\\Call of Duty 2\\cod2sp_s.exe"
"MultiEXEString"="C:\\Program Files (x86)\\Activision\\Call of Duty 2\\cod2mp_s.exe"
"QA"="15.3"
NOTE:
Wow6432Node\Activision
is for 64-bit systems, make a copy inActivision\
for x86
NOTE: I copied my steam install to the pre-steam
Program Files (x86)/Activision
install dir
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile logNOTE: CoD2ModTools includes ~38MB of
.map
files, ~32MB of which are prefabs
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile logThanks to Quake Mapping Discord for sharing the tools
Need to identify mapping tools / pipelines and provide test maps for as many games as possible
All without distributing any copyrighted maps
ace_team
arkane
gearbox
id_software
infinity_ward
ion_storm
loiste
nexon
outerlight
raven
respawn
ritual
strata
troika
utoplanet
valve
wild_tangent
SDK is pre-steampipe, so assets will need to be extracted from
.vpk
s
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfosources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoNOTE: The SDK is Unofficial and based on Half-Life 2 Beta Leaks
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoEditing attrs of an object returned by a BspLump don’t update BspLump.changes, need to do some soft copies probably
Slice overriding & insertion don’t seem to work either.
Both of these need tests and more
>>> BspLump[i].x = new_val
>>> BspLump[i].x
old_val
editing a lump should be as easy as modifying the contents of a list
Titanfall 2 .bsps has different formats for internal (.bsp) REAL_TIME_LIGHTS
& the external (.bsp_lump) lump
To deal with this all ValveBsp & RespawnBsp will need another member to hold external lumps
Methods for copying between internal & external lumps will also be needed
When saving options will need to be added for folding lumps into the internal .bsp
While RespawnBsp has no headers in .bsp_lump
files, ValveBsp includes a header at the start of .lmp
files
ValveBsp can also have multiple numbered lump files
Managing mounting these lumps will likely grow to be quite complex
However, keeping headers to exclusively the headers defined in the .bsp will simplify things
(the c++ implementation really shows how simple the process can be)
RespawnBsp .ent headers could also probably get their own member
Especially since they are tied to theENTITY_PARTITION
lump
TODO: find at least one guide / tutorial
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO: find at least one guide / tutorial
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO: look around for modding projects / communities
qbsp -hexen2
)sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO
Thanks Fifty.
struct CellAABBNode_t {
Vector3f mins;
uint32_t num_children: 8;
uint32_t first_child: 16;
uint32_t child_flags: 8;
Vector3f maxs;
uint32_t num_obj_refs: 8;
uint32_t first_obj_ref: 16;
uint32_t obj_ref_flags: 8;
};
Looks like respawn structs use bitfields a lot
This makes sense with the "Extreme SIMD" method of vec4(a.xyz, a.metadata)
valve.source.Leaf
also uses a bitfield
at present we just write a getter & setter property for each member
This means CellAABBNode
would need 12 property methods
Automating this would minimize errors & reduce bloat
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile logThanks to Quake Mapping Discord for sharing the tools
canyonlands_staging uses rBSP version 49, which is even newer than the 48 noted in the file.
SDK is pre-steampipe, so assets will need to be extracted from
.vpk
s
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoUPDATE: This isn't actually a bug, turns out I forgot the code handles this case and didn't check before creating the issue :P
Still, an update would be nice
Try handling this like https://github.com/pySourceSDK / ValveVMF
Where instead of a dict
a list
of [(key, value)]
tuples store all keys without duplicates
This will require:
Entities.search
ENTITIES
lumps
test/maps/Team Fortress 2/test2.bsp
to match QtPyHammer-devs/vmf_tool's test2.vmf
NOTE: io_import_rbsp will also need updating to support these changes
This might also be a good opportunity to use ValveVMF's parser on values
And even using ValveFGD & custom classes for entities
However this would likely require some re-engineering (of ValveVMF) to allow feeding the system flat nodes (unnamed curly brace groups)
Not to mention some extra details to the parser, and maybe a deeper look at .fgd generation
NOTE: Many source engine titles have .fgd files available via the VDC: link
Maybe extenstions/fgd.py
or bsp_tool_examples would be a place to try this out
It would be preferable for the core lib to continue to function without any external dependencies
ValveVMF parsing can also be quite slow, so deferring it's use until needed would be ideal
I am working on a program which automatically adds an eventlistener to any given csgo .bsp file. I have already made a progress on adding the entities to the bsp and the only thing left is to save the map to a new bsp file. I just wanted to know if any progress was made in the past 4 months ?
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile logThanks to Quake Mapping Discord for sharing the tools
Call of Duty/Tools/bin/q3map.exe
)NOTE:
instscript.vdf
in steam install should make a 32-bit registry key, maybe?
sources.txt
entry crediting mapper / contributor.bsp.info.txt
file with compile logmapsrc/TrenchBroom/Quake/mp_lobby.map
-> maps/Quake/mp_lobby.bsp
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoq3map2
maybe? (think I saw some references in the public source code)TODO: find / make at least one guide
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO
NOTE: Requires Titanfall Online Revival access to run a server to test maps
NOTE: Need to match
.vmt
shaders (VertexLitGeneric
etc.) to vertex types
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoNOTE: Need R5Reloaded client to test maps
TODO: find / make at least one guide
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfosources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoAll functions / classes that return a base.Bsp subclass should accept either an open binary file or bytestring in the place of a filename, this would allow for loading .bsp
s from within archives without unpacking
And other sources I'm sure
as part of such a system a path handler for indexing files inside archives would be needed
“game/archive.ext/maps/target.bsp” ->
archive = game/archive.ext
bsp = bsp_tool.load_bsp(archive.read(“maps/target.bsp”))
Changes would also have to be made to how bsps record and relate to their “folder” & “filename”
Opening an archive only once and scanning it for .bsp
files would also be useful for tests
Good luck writing back to the archive, unless you want to add a Read-Only mode...
When mapping out methods / lump formats it would be quite handy to use importlib to reload branch scripts and reload a single lump
>>> import bsp_tool
>>> import my_branch_script
>>> bsp = bsp_tool.load_bsp("maps/subject.bsp", branch=my_branch_script)
ERROR LOADING LUMP_XX:
...
# edit my_branch_script.py
>>> import importlib
>>> importlib.reload(my_branch_script)
>>> bsp.set_branch(my_branch_script)
>>> bsp.reload("LUMP_XX")
or even writing a test lump class live in editor
>>> import bsp_tool
>>> import enum
>>> class BranchScript:
... class LUMP(enum.Enum):
... LUMP_XX = 42
... lump_header_address = {LUMP.LUMP_XX: (16 + 42 * 16)}
... LUMP_CLASSES = dict()
... SPECIAL_LUMP_CLASSES = dict()
... methods = []
>>> branch_script = BranchScript()
>>> class Xx(bsp_tool.branches.base.MappedArray):
... _format = "3f"
... _mapping = [*"xyz"]
>>> branch_script.LUMP_CLASSES["LUMP_XX"] = Xx
>>> bsp = bsp_tool.load_bsp("maps/subject.bsp", branch=branch_script)
ERROR LOADING LUMP_XX
...
>>> class NewXx(bsp_tool.branches.base.MappedArray):
... _format = "4f"
... _mapping = [*"xyzw"]
>>> bsp.branch.LUMP_CLASSES["LUMP_XX"] = NewXx
>>> bsp.reload("LUMP_XX")
Though even this theorised process could be simplified a little, but loading new lump classes faster would be a very helpful tool
Steam > Library > Tools
)sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoNice tool you've built here! I'm a researcher, interested in building virtual environments for people to explore, such that I can scan their brains while they navigate through the maps. The goal is to learn something about how the brain encodes navigation. This tool could put a lot more maps at my disposal for my experiments (doing bsp export / conversion manually through e.g. nem's tools is tedious and doesn't work well on linux / mac, which are my primary computers). So - out of curiosity - are you still developing this? There are a few small bugs in the code that I've caught (could submit a PR for those if you're interested), and there are some other things that I haven't had time to dig into (some geometry errors for some maps, no material exporter implemented yet). But before I get too deep here, I wanted to know if this is an ongoing project that you plan to improve, or just a quickie side project.
Cheers,
Mark
TODO: find at least one guide / tutorial
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO: find / make at least one guide
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoPlease add ReadMe description of how to use it.
Steam > Library > Tools
)sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoTODO: Extract a complete
.bsp
from.bpk
files
TODO: find / make at least one guide
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfomapsrc/TrenchBroom/Quake 2/mp_lobby.map
-> maps/Quake 2/mp_lobby.bsp
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoAppears this is unused, but I'm not sure if that was just put there in a haste or is actually reality. I could not find any information on LUMP_PHYSLEVEL which I suspect may be the alternative lump which holds collision data.
sources.txt
crediting mapper / contributor.bsp.info.txt
file with compile log / bspinfoAny changes made to a .bsp should be saved back to that .bsp by bsp_tool
The user shouldn't have to worry about specifics like lump containing offsets
However confirming the saved map is valid will not be a feature at this time
(could use an optional branch script method as a fuzzy validator for engine limit checks etc.)
NOTE: this means
Quake
/GoldSrc
lumps likeMIP_TEXTURES
need to be handled with SpecialLumpClasses
or maybe even a new class in thelumps
module
base.Bsp
subclasses with a functional & tested .save_as()
methodtests/test_save.py
needs to be content aware, otherwise saves must be byte-for-byteNeed to bring more automation to auto-detect
Adding a new game should be as simple as writing a new branch script
Setting defaults for each (FILE_MAGIC, BSP_VERSION)
may remain automated for a while though
Could default to mainline IdTech / Source Titles?
The way bsp headers are handled also needs to be refactored
VBSP v20 Vindictus, DarkMessiah headers & Ubertools .bsps don't play nice with the current system
Bsp base classes also don't do enough work, a lot of copy-pasted code needs to be eliminated
ace_team
arkane.dark_messiah_mp
gearbox.blue_shift
nexon.cso2_2018
nexon.vindictus
nexon.vindictus69
outerlight.outerlight
raven.hexen2
raven.soldier_of_fortune2
raven.soldier_of_fortune
ritual.sin
utoplanet.merubasu
valve.alien_swarm
valve.left4dead2
valve.left4dead
valve.source_filmmaker
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.