Mafia II: Map editing guide

2k Czech Mafia II game modding.

Moderator: Oleg

User avatar
Oleg
Site Admin
Posts: 14022
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Mafia II: Map editing guide

Post by Oleg »

Mafia II Import/export filter was updated to support map files.

Import and export of map files is identical to vehicles import/export, but you have to toggle Static scene option on export, so a specific export scenario is used. You are allowed to use geometry with different LODs on mesh objects, as well as you can create a proximity objects for entire areas (objects on far distance to render entire city area as single object).

Map files suffer of dynamic and game logic entries, so you can't create light sources or dynamic or destructible objects like light poles trash cans etc. Most of dynamic objects are placed on the map via city_crash.sds file that contains instance objects and their clones locations are spread all over the city area via Translokator_0.bin file. If we get an editor for this file, it would be possible to place interactive and collision-responsible objects on new maps.

The filter is equipped with compatibility options script that lets you configure properties of objects easily. Before you proceed, make sure to set in Settings->General->Compatibility->Default Compatibility Settings = Mafia II

Static collisions
Map file is equipped with static collisions file (Collisions_0.bin) that contain geometry collisions for entire map. Each collision is created as compound object with COL state on it, as well as COL: object name is used. Exporting a static scene will generate collisions out of geometry COL objects. Dummy collisions will generate ItemDesc files that are not used on map collisions (require in-game object instantiation as "live entry"), so ensure you use only geometry object collisions on maps.

Collisions should follow geometry object quite accurate, as the player in game will run on collision surface and will refine pose (especially feet positions) using underlying real geometry object. Thus, for example, you can create collision for steps as flat surface laid on stairs, the player will run fine on them. But as soon as player stops, his feet will be put onto horizontal stair surface with respect to stairs geometry mesh object. You can explore this all by loading original map files.

Per-polygon property is set on collision objects via ID value. When compatibility settings is set to "Mafia II", you can adjust settings in a user-friendly mode. Setting surface property will toggle correct visual and sound FX on collision as well as will generate correct particles and bullet shells (if applies). Two specific types "VEGETAION - GRASS SHORT" and "VEGETATION - GRASS LONG" will generate grass on surface too (GRASS LONG is a Sicily version of grass).

City areas
Game optimization assumes the engine will load at most two city SDS files at a time and one shop SDS if required. Most of time only one city SDS is loaded and when player comes closer to another city area, a respective SDS is loaded and ready to be shown in full detail once player reaches a proper visibility distance for this city area. Thus, an entire city is split into areas and game has SDS association with most of areas. Some areas are a "transition area" from one map part to another and is not explicitly bound to some SDS file (instead it bridges two SDS files).

All city areas are stored in a "city_universe.SDS" file. Unfortunately, it might be a mod conflict when dealing with this file, as all addon maps you install have to provide their own areas stored in a "city_universe.sds" and there is no way to merge different SDS files into one file. The game will inspect player/camera location over "AREA" objects (bound box dummies are used) stored in this file. Then it will check matching AREA objects with "cityareas.bin" file. This file associates "AREA" objects with SDS files game needs to load. The latest file can merge and contain areas from different mods using a console tool (see MafiaIIConsole tool topic for details).

In order to create an area, use Dummy helper of shape Box. Then give it a name starting with AREA. You can toggle off "Solid" option on this dummy, so you can see it in wireframe mode and see what is inside and/or how it overlaps with other areas. Name starting with "AREA" is significant. Mind, you still need to register your newly-created AREAs in cityareas.bin file.

Scene hierarchy
Hierarchy of scene can include several groups or areas or logical branches that you can keep inside root node. These branches should have .group in a tail of name. These groups local axes should be reset to 0,0,0 so you can't move associated dummy object ot place group content in a map (if you do so, use Display\Local axes\Reset to world). These groups are for management and arrangement of massive amount of objects and are not a exported as objects for the game needs (the game can access objects inside groups, but does not deal with the group itself).

Deeper in a hierarchy an object or object assemblies can be used. You can use dummy node to create a branch in case you need to manage several objects as a single entity. Thus, you can create city blocks or individual buildings as a branch with objects inside. You are free to put respective static collision entries (COL: objects) into these branches too, so a visual entry is managed together with respective collision. Local axes are retained, so don't care much on them in this case.

Geometry object can be equipped with .mesh suffix, but this is optional. Geometry can be made a Compound with L0, L1 etc LODs on it if needed. Each geometry object need a visibility range to be specified. By default, filter will assign 10.000 which is likely to be 10 meters. This is quite a few for a map object, so setting a proper LOD distance manually is essential.

The LOD visibility distance is set in user-defined property LOD. The value of -1 toggles highest possible visibility range. If you deal with compound object with several LODs, specify multiple values in LOD user-defined property where first value is for highest-detail (L0), the second is for L1 and so on. For example, LOD property being set to "6000, 25000, -1" will make L0 being visible for 6 meters, L1 for 25 meters and L2 being shown on the rest of distance further.

Limitations
Dynamic and interactive content is not supported. You should remove Actors_0 file in a folder with modded content, as it will not fit a newly-created FrameResource file. Quite likely Prefab_0 file will not work too and worth to be removed from a folder with modded content.
Headshots_Ops
Posts: 8
Joined: Mon Jun 26, 2017 9:40 am

Re: Mafia II: Map editing guide

Post by Headshots_Ops »

Thanks for adding map support, will you be able to get interiors to import aswell? the ones in the shops folder? they seem to import empty.
User avatar
Oleg
Site Admin
Posts: 14022
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Mafia II: Map editing guide

Post by Oleg »

I haven't inspected them yet, but I assume it might contain specific object types that are not handled on import. I have a high priority pending task in GTA filter that needs to be sorted out, then I could be able to inspect shop files.
User avatar
Mentossini
Posts: 26
Joined: Mon Jan 13, 2020 1:34 pm

Re: Mafia II: Map editing guide

Post by Mentossini »

Oleg wrote: Sun Dec 23, 2018 10:12 am I haven't inspected them yet, but I assume it might contain specific object types that are not handled on import. I have a high priority pending task in GTA filter that needs to be sorted out, then I could be able to inspect shop files.
Is there a chance that you will fix it? It would be wonderful. Shops are still not imported. There are also problems with some collisions of the city itself.

Есть вероятность того, что ты поправишь это? Было бы чудесно. Магазины (интерьеры из папки Shops) всё так же не импортируются. Так же есть проблемы с импортом некоторых коллизий самого города.
User avatar
Oleg
Site Admin
Posts: 14022
Joined: Fri Feb 06, 2004 3:54 am
Contact:

Re: Mafia II: Map editing guide

Post by Oleg »

Вряд ли. Структура игры достаточно запутанная. Если в тот момент, когда я её разбирал и был полностью погружен в структуру, я какую-то часть не разобрал, то очень маловероятно, что спустя такой срок я что-то смогу там еще разобрать.
User avatar
agens
Posts: 59
Joined: Fri Feb 20, 2015 8:16 am

Re: Mafia II: Map editing guide

Post by agens »

Ну на самом деле структура моделей что у карт, что у локаций (shops) одинаковая. Хотя конечно у моделей в игре есть определенные свойства, которые zmodeler переписывает значениями 0, но это не влияет на импорт, экспорт и на работу как то в игре. Проблема того что Zmodeler не может загружать магазины (shops) в том что в них находятся затемняющие боксы для освещения. И проблема даже не в этом что они там есть, а в том что сам Zmodeler не умеет считывать сферы или сетку у которых локальная ось смещена за пределы её границ, эта даже в программе вы не сможете сделать физически. Оси двигаются только у моделей. От этого и не работает импорт.
Для того что бы считать локации, вы должны воспользоваться Toolkit, в этой программе есть Map Editor, с помощью него вы должны удалить затемняющие боксы, но возможно и этого будет не достаточно, иногда в локациях есть ещё не понятные моменты, толи для камеры служат или ещё для чего, не содержащие в себе модель объект, вам нужно будет и их удалить, затем сохранить и запаковать всё в sds. А потом уже распаковывать архив для Zmodeler. И только после этого,всё будет импортироваться в программу.

В остальном с помощью Zmodeler по сей день всё делаю в работе с машинами, скинами, картами, оружие в игре, но без Toolkit к сожалению не обойтись в не которых моментах. В нем есть всё не обходимое, что бы где то подправить ошибки, после Zmodeler. Если бы в Zmodeler3 был бы тот же экспортер, цены бы не было. Для локаций и карт желательно учитывать ещё такой файл как Actors, что бы все расставленные объекты стояли по своим местам,а не в куче в одном месте.
User avatar
Mentossini
Posts: 26
Joined: Mon Jan 13, 2020 1:34 pm

Re: Mafia II: Map editing guide

Post by Mentossini »

agens wrote: Fri Dec 15, 2023 10:40 pm Ну на самом деле структура моделей что у карт, что у локаций (shops) одинаковая. Хотя конечно у моделей в игре есть определенные свойства, которые zmodeler переписывает значениями 0, но это не влияет на импорт, экспорт и на работу как то в игре. Проблема того что Zmodeler не может загружать магазины (shops) в том что в них находятся затемняющие боксы для освещения. И проблема даже не в этом что они там есть, а в том что сам Zmodeler не умеет считывать сферы или сетку у которых локальная ось смещена за пределы её границ, эта даже в программе вы не сможете сделать физически. Оси двигаются только у моделей. От этого и не работает импорт.
Для того что бы считать локации, вы должны воспользоваться Toolkit, в этой программе есть Map Editor, с помощью него вы должны удалить затемняющие боксы, но возможно и этого будет не достаточно, иногда в локациях есть ещё не понятные моменты, толи для камеры служат или ещё для чего, не содержащие в себе модель объект, вам нужно будет и их удалить, затем сохранить и запаковать всё в sds. А потом уже распаковывать архив для Zmodeler. И только после этого,всё будет импортироваться в программу.

В остальном с помощью Zmodeler по сей день всё делаю в работе с машинами, скинами, картами, оружие в игре, но без Toolkit к сожалению не обойтись в не которых моментах. В нем есть всё не обходимое, что бы где то подправить ошибки, после Zmodeler. Если бы в Zmodeler3 был бы тот же экспортер, цены бы не было. Для локаций и карт желательно учитывать ещё такой файл как Actors, что бы все расставленные объекты стояли по своим местам,а не в куче в одном месте.
Да, спасибо. Тоже использую Toolkit, хоть и не сильно разбираюсь в нём. Но за совет с удалением именно затемняющих боксов - спасибо.
Post Reply