[Help] Relative paths

Making or wanting help making your own asset? Check in here
Post Reply
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

[Help] Relative paths

Post by Senshi »

This might seem like a very basic problem, but I have to admit I'm kind of stumped with it.

Basic issue: I want to create a teeny tiny mod that uses 100% of original PR stuff and then adds/changes only minor things. Currently I'm trying to set up the basic "clone"-mod.
Thing is, I want to avoid having to copy&paste all contents over. I know that copy&passte works fine, but it's not elegant and a huge waste of HDD resources to have hundreds of duplicate files. Now, I know BF2 allows for relative paths to look outside of the "own" modfolder and all that, but it appears there are limits. And those I do not know, being only firm with BF42 modding.

It was very easy to cover all the basic stuff by simply changing a handful of lines in the clientarchives.con and serverarchives.con.
The uppermost part is there to ensure loading of new stuff should it be added in the minimod. The second part is the load-all-vanilla-PR-things. This works by just adding the ominous ../pr/ relative path to the line, making it read all the zips from the pr archive. If I'm correct, this should cause things to be loaded in a orderly hierarchical fashion, with new files in the upper .zips overwriting the "lower" ones.

Code: Select all

fileManager.mountArchive ../pr/menu/Fonts_custom.zip Fonts
rem WGP Mod Beginn
fileManager.mountArchive Common_client.zip Common
fileManager.mountArchive menu/Fonts_client.zip Fonts
fileManager.mountArchive menu/Menu_client.zip Menu
fileManager.mountArchive objects/common_client.zip Objects
fileManager.mountArchive objects/dynamicobjects_client.zip Objects
fileManager.mountArchive objects/effects_client.zip Objects
fileManager.mountArchive objects/kits_client.zip Objects
fileManager.mountArchive objects/miscobjects_client.zip Objects
fileManager.mountArchive objects/roads_client.zip Objects
fileManager.mountArchive objects/soldiers_client.zip Objects
fileManager.mountArchive objects/staticobjects_client.zip Objects
fileManager.mountArchive objects/vegitation_client.zip Objects
fileManager.mountArchive objects/vehicles_client.zip Objects
fileManager.mountArchive objects/water_client.zip Objects
fileManager.mountArchive objects/weapons_client.zip Objects
fileManager.mountArchive shaders_client_pr.zip Shaders
rem PR Basics Beginn
fileManager.mountArchive ../pr/Common_client.zip Common
fileManager.mountArchive ../pr/menu/Fonts_client.zip Fonts
fileManager.mountArchive ../pr/menu/Menu_client.zip Menu
fileManager.mountArchive ../pr/objects/common_client.zip Objects
fileManager.mountArchive ../pr/objects/dynamicobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/effects_client.zip Objects
fileManager.mountArchive ../pr/objects/kits_client.zip Objects
fileManager.mountArchive ../pr/objects/miscobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/roads_client.zip Objects
fileManager.mountArchive ../pr/objects/soldiers_client.zip Objects
fileManager.mountArchive ../pr/objects/staticobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/vegitation_client.zip Objects
fileManager.mountArchive ../pr/objects/vehicles_client.zip Objects
fileManager.mountArchive ../pr/objects/water_client.zip Objects
fileManager.mountArchive ../pr/objects/weapons_client.zip Objects
fileManager.mountArchive ../pr/shaders_client_pr.zip Shaders
rem BF2 Basic Beginn
fileManager.mountArchive ../bf2/Common_client.zip Common
fileManager.mountArchive ../bf2/Fonts_client.zip Fonts
fileManager.mountArchive ../bf2/Menu_client.zip Menu
fileManager.mountArchive ../bf2/Objects_client.zip Objects
However, as I failed to find a way to make maps being loaded from the vanilla mod (this was soooo easy to do back in BF42...), I thought to put in a small server.zip per map in my mod, including an init.con that tells the game again to look at ../pr/ for all the relevant files. Tested it with al basrah. Works, except for GameModes, which apparently have to be in the server.zip directly. And the info folder, which seems to be mandatory as well. Not that big an issue, they are very small files anyway.

Code: Select all

rem *** Generated by BF2Editor ***
if v_arg1 == BF2Editor

run ../pr/levels/albasrah/Heightdata.con
LevelSettings.InitWorld
run ../pr/levels/albasrah/Terrain.con BF2Editor
run ../pr/levels/albasrah/StaticObjects.con BF2Editor
run ../pr/levels/albasrah/Sounds.con
run ../pr/levels/albasrah/Sky.con BF2Editor
run ../pr/levels/albasrah/Editor/GamePlayObjects.con host
UndergrowthEditable.create
Undergrowth.load ..\prLevels\albasrah\
run ../pr/levels/albasrah/Overgrowth/Overgrowth.con
Overgrowth.editorEnable 1
run ../pr/levels/albasrah/AmbientObjects.con BF2Editor
run ../pr/levels/albasrah/Water.con
run ../pr/levels/albasrah/TriggerableTemplates.con BF2Editor

else

run ../pr/levels/albasrah/Heightdata.con
run ../pr/levels/albasrah/Terrain.con v_arg2
run ../pr/levels/albasrah/Sky.con v_arg2
run ../pr/levels/albasrah/CompiledRoads.con
run ../pr/levels/albasrah/Sounds.con
run ../pr/levels/albasrah/SoundDistances.con
run ../pr/levels/albasrah/tmp.con v_arg1
Undergrowth.load ..\pr\Levels\albasrah\
run ../pr/levels/albasrah/Overgrowth/Overgrowth.con
run ../pr/levels/albasrah/Overgrowth/OvergrowthCollision.con
run ../pr/levels/albasrah/AmbientObjects.con
run ../pr/levels/albasrah/Water.con
run ../pr/levels/albasrah/TriggerableTemplates.con
run ../pr/levels/albasrah/SoundDistances.con

endIf

rem ------------------------------- LevelSettings -------------------------------
rem -----------------------------------------------------------------------------

run ../../Factions/faction_init.con 1 "meinsurgent"
run ../../Factions/faction_init.con 2 "gb_ziptie"

rem -----------------------------------------------------------------------------

gameLogic.setBeforeSpawnCamera 253/26/-331 76/-11/0

if v_arg1 == BF2Editor
LevelSettings.CustomTextureSuffix "ab"
else
texturemanager.customTextureSuffix "ab"
endIf
rem -----------------------------------------------------------------------------

GameLogic.MaximumLevelViewDistance 350

rem -----------------------------------------------------------------------------

gameLogic.setDefaultNumberOfTicketsEx 16 1 275
gameLogic.setDefaultNumberOfTicketsEx 16 2 275
gameLogic.setDefaultNumberOfTicketsEx 32 1 275
gameLogic.setDefaultNumberOfTicketsEx 32 2 275
gameLogic.setDefaultNumberOfTicketsEx 64 1 325
gameLogic.setDefaultNumberOfTicketsEx 64 2 325
gameLogic.setDefaultTimeToNextAIWave 8
gameLogic.setTicketLossAtEndPerMin 1000
gameLogic.setTicketLossPerMin 1 10
gameLogic.setTicketLossPerMin 2 10
Problem 1: CTD at 100% loading of map. I guess it's the faction init. How would the relative path have to look like for these?

Problem 2: I am unable to get the vanilla PR music to be loaded. Menu music, loading music, nothing. Why doesn't this work (mod.desc):

Code: Select all

<music> ../pr/common/sound/menu/music/Alkali-Main_Menu.ogg </music> 
And how should it look like correctly?

And can someone explain to me what exactly these "/../" stand for? I don't quite understand them, to be honest. Are they simply a "look-one-folder-up"? Can they be used only in the beginning or also in between? Like mods/../levels?
BobTheSilensious
Posts: 49
Joined: 2009-07-04 15:50

Re: Relative paths

Post by BobTheSilensious »

If you want to make a really small map folders clone, copy the original ones from PR to your mini-mod folder, delete all "client.zip" and "server.zip" (from your midi-mod ones of course). Then, for each map, create two files, one called "clientarchives.con" and the other "serverarchives.con". Edit them like this ->

clientarchives.con

Code: Select all

fileManager.mountArchive ../pr/levels/[color=Red](your_level)[/color]/client.zip levels/[color=Red](your_level)[/color]
serverarchives.con

Code: Select all

fileManager.mountArchive ../pr/levels/[color=Red](your_level)[/color]/server.zip levels/[color=Red](your_level)[/color]
fileManager.mountArchive faction_inits.zip Factions
(replace the "(your_level)" with the corresponding level name)

Then, pack the two files in a zip file, and call it server.zip

Then if you want to add new things to your client.zip/server.zip, you only need to add the modified files to it.


And for the music problem, make sure you didnt changed the path of the music. They should point in your mod, not "../pr/".


That should do the job :)

Sorry for my bad english
Last edited by BobTheSilensious on 2011-04-27 14:38, edited 3 times in total.
Reason: nvm, read too fast, and almost forgot
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

Re: Relative paths

Post by Senshi »

Thank you for the help. The level solution seems pretty sweet, will try that one out ASAP. I thought serverarchives.con only worked in the main mod folder.

Music: You are obviously correct. I thought too far ahead with the path change there, obviouly, as I have already defined the pr/common_client.zip as default common. Stupid mistake...

Just tried your method, and it works splendid. Adding new content is sweet an easy this way, that's always a plus ;) .
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

Re: Relative paths

Post by Senshi »

I'll just recycle this thread, as my new problems still concern the same minimod. I have now a pretty well foundation for the mod, but there is a bunch of very weird issues which appear kind of random to me.
  1. Once ingame, you get spammed with a soundeffect (drumroll) and "You have been commended for a medal/promotion" on about every single action you do. Mainly on any actions that involve the Commo Rose (personal or squad one) or any other python effect. Once you are dead and wait for respawn, you get dozens of this sound effect, often overlapping, until you spawn again. Kinda annoying. And where does it come from? I thought award stuff was totally reformed for other uses in PR and there never should be a sound played for it...
  2. Squad commands (Move/Attack/Destroy) get accompanied by the wrong chat message.
  3. Compass is missing the directional marker (the triangle thingie) when any squad order is set.
  4. When firing a weapon, there is no impact effect.
    All of these issues seem to be python-related I think. Except the last. Which seems totally random again.
I'm very confused.

What I did: The above changes to the main client and serverarchives plus the level-transfer-trick of Bob. As I failed to find a way to redirect python usage, I copied 1:1 the original PR python folder. Same with localization, as I also failed to find a redirect way for this.

Any ideas where these issues might originate? If you want, I can upload the mod files for checking as well.
BobTheSilensious
Posts: 49
Joined: 2009-07-04 15:50

Re: Relative paths

Post by BobTheSilensious »

I do not know if you fixed your problem is, if not, I'll tell you how I made mine.

Copy thoses folder

Code: Select all

ai
localization
menu (you can just delete de zip files inside, its only to get PR's cursor)
movies (if you like them)
python
settings
Then thoses files

Code: Select all

clientarchives.con
gamelogicinit.con
init.con
mod.desc
pr.exe
serverarchives.con
tr.exe
This is the only things I have in my mini-mod (and the levels)

Afterwards, I modify my "clientarchives.con" and "serverarchives.con", and I lunch PR and load a map and everything is fine :|



Anyway, if it still not working, upload it like you said and I'll have a look :-)
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

Re: Relative paths

Post by Senshi »

True, it's probably easier to look at my mess directly.

Get it here.
I left out all the levels folders because they only eat up space (40MB...stupid background/load PNGs...) and most certainly are not cause of the mentioned issues.

I don't even have the exe included, they are not needed, right? I just let the installer (Inno Compiler) create a shortcut that links to the "X:\...\Battlefield 2\mods\pr\pr.exe +modPath mods/pr_wgp"

Settings...this folder only contains local settings AFAIK and are not really mandatory, as they are created by the game once they are called (e.g. server options, user settings etc.).

EDIT: Ai is not important, as we exclusively play human vs human battles.
Last edited by Senshi on 2011-04-30 09:41, edited 1 time in total.
BobTheSilensious
Posts: 49
Joined: 2009-07-04 15:50

Re: Relative paths

Post by BobTheSilensious »

Senshi wrote: I don't even have the exe included, they are not needed, right? I just let the installer (Inno Compiler) create a shortcut that links to the "X:\...\Battlefield 2\mods\pr\pr.exe +modPath mods/pr_wgp"

I didnt know you can do that with pr.exe! thats great thanks :mrgreen:

However, it create a small problem... tr.exe seem to not link with the game, so the range and the ugl are not working properly. If you find a solution, tell me how you archive that.


So, I fixed your problem, it was quite simple. You added files that didnt "exist" in the client/serverarchives.con. You only need to clean them and add only the file you have in your folder.

Here, how it should look like:

clientarchives.con

Code: Select all

rem WGP Mod Beginn
fileManager.mountArchive Common_client.zip Common

rem PR Basics Beginn
fileManager.mountArchive ../pr/menu/Fonts_custom.zip Fonts

fileManager.mountArchive ../pr/Common_client.zip Common
fileManager.mountArchive ../pr/menu/Fonts_client.zip Fonts
fileManager.mountArchive ../pr/menu/Menu_client.zip Menu
fileManager.mountArchive ../pr/objects/common_client.zip Objects
fileManager.mountArchive ../pr/objects/dynamicobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/effects_client.zip Objects
fileManager.mountArchive ../pr/objects/kits_client.zip Objects
fileManager.mountArchive ../pr/objects/miscobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/roads_client.zip Objects
fileManager.mountArchive ../pr/objects/soldiers_client.zip Objects
fileManager.mountArchive ../pr/objects/staticobjects_client.zip Objects
fileManager.mountArchive ../pr/objects/vegitation_client.zip Objects
fileManager.mountArchive ../pr/objects/vehicles_client.zip Objects
fileManager.mountArchive ../pr/objects/water_client.zip Objects
fileManager.mountArchive ../pr/objects/weapons_client.zip Objects
fileManager.mountArchive ../pr/shaders_client_pr.zip Shaders
rem BF2 Basic Beginn
fileManager.mountArchive ../bf2/Common_client.zip Common
fileManager.mountArchive ../bf2/Fonts_client.zip Fonts
fileManager.mountArchive ../bf2/Menu_client.zip Menu
fileManager.mountArchive ../bf2/Objects_client.zip Objects
serverarchives.con

Code: Select all

rem WGP Mod Beginn

rem PR Basics Beginn
fileManager.mountArchive ../pr/faction_inits.zip Factions
fileManager.mountArchive ../pr/Common_server.zip Common
fileManager.mountArchive ../pr/menu/Menu_server.zip Menu
fileManager.mountArchive ../pr/objects/common_server.zip Objects
fileManager.mountArchive ../pr/objects/effects_server.zip Objects
fileManager.mountArchive ../pr/objects/kits_server.zip Objects
fileManager.mountArchive ../pr/objects/miscobjects_server.zip Objects
fileManager.mountArchive ../pr/objects/roads_server.zip Objects
fileManager.mountArchive ../pr/objects/soldiers_server.zip Objects
fileManager.mountArchive ../pr/objects/staticobjects_server.zip Objects
fileManager.mountArchive ../pr/objects/vegitation_server.zip Objects
fileManager.mountArchive ../pr/objects/vehicles_server.zip Objects
fileManager.mountArchive ../pr/objects/water_server.zip Objects
fileManager.mountArchive ../pr/objects/weapons_server.zip Objects

fileManager.mountArchive ../bf2/Common_server.zip Common
fileManager.mountArchive ../bf2/Menu_server.zip Menu
fileManager.mountArchive ../bf2/Objects_server.zip Objects
Senshi wrote:Settings...this folder only contains local settings AFAIK and are not really mandatory...
Yup, but since PR use a custom sound.con, you need it if you what proper distant sounds and suppressive effects ;)
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

Re: Relative paths

Post by Senshi »

Alright, a big thanks, man! I didn't know BF2 was allergic to "empty paths". Another thing BF42 was more modder-friendly in... ;)


And you are correct. The tr.exe sadly won't be launched :( . Missed that one as well. Will have to transfer them as well, then.

Sigh...knowing BF42 code inside out doesn't help all that much when modding BF2...

Expect a Special thanks mention in the mod! :thumbsup:

EDIT: Argh again. Copying over pr.exe and tr.exe doesn't do the trick. When I try to launch it with the pr.exe in that folder, it immediately crashes "has reported an error". After the process starts, I get the splashscreen and in the first split second it already spawns the "error/shutdown" message. I don't get it.
The only action done: The mods\pr_wgp\menu\External\FlashMenu\images\news\prnews1.png gets overwritten with a blank file.
If I have no menu folder in it at all, it gets created and the only file is the same prnews1.png (in the correct subfolder).

Again...weird...
I changed the client/serverarchives.zip as per your suggestion and copied the tr.exe and pr.exe into the pr_wgp folder. Plus I pushed the menu folder over, deleting the .zips in it (fonts etc.). But the last one is irrelevant to the issue, if I delete the menu folder completely, the aforementioned blank file is created anyway.

I feel dumb now :( .
Last edited by Senshi on 2011-04-30 17:59, edited 2 times in total.
BobTheSilensious
Posts: 49
Joined: 2009-07-04 15:50

Re: Relative paths

Post by BobTheSilensious »

Wow, I've never thought BF2 was so touchy... it was your mods.dec file. Replace the "f?r" to "fur" in the description and NOW it should work :-D
User avatar
Senshi
PR:BF2 Developer
Posts: 358
Joined: 2010-04-29 10:44

Re: Relative paths

Post by Senshi »

Geez, incredible. Using "?" and similar Umlaute (german thing...) was no issue in BF42...and now it is. A new engine with many steps forward and simultaneously a bunch of steps backwards ;) .

Once more, a giant thank you. That would have been one of the last places I'd have checked...
BobTheSilensious
Posts: 49
Joined: 2009-07-04 15:50

Re: Relative paths

Post by BobTheSilensious »

No problem mate! If you come across other problems, feel free to ask :razz:
Post Reply

Return to “PR:BF2 Community Modding”