Introduction
This tutorial owes a lot to Jusupov's Bering Spawn and World Locations mods, it was reverse engineering those that got me to this stage. Jusupov has done great work with his location mods but his description of how he did it left out key details and I got pretty stuck for a while so I thought I'd write a tutorial that makes it much clearer.
I wanted to spawn a leopard at Kem Sungai Sejuk because I felt like I was being punished for completing the location by losing access to a cool jet fighter that I could use to get around the map conveniently. I actually restarted the game and left the location 90% complete for a while so that I could have the jet but then I decided to learn how to mod it back in instead. Restoring the jet will be the example I use here though you can use it to put more or less anything anywhere.
Credit goes to Gibbed for his amazing tools, Jusupov for his research on locations and DerPlaya78, Klemen "nNa" Košir and Peter "Zazcallabah" Hamberg for JC2MapViewer that I stole the Settlement filenames from.
Tools
First, I'll talk about the tools I used. Basically everything can be found at justcause2mods.com under modding tools.
Modding Tools[justcause2mods.com]
You'll need Gibbed's Avalance mod tools, I used rev171 though I don't think it matters too much. I also used JC2 Map Viewer because of some info it has on settlements. Both can be found at the mods site. You may want to use the miniBOLO patch because it has some sort of coordinate tool but I didn't use it. There is also a LUA script for JC2MP which can tell you your coordinates and I think people use that now to find out what coordinates the game uses for things.
Unzip them wherever and then make a folder on your desktop and create shortcuts in them to all the Gibbed tools that are found in the /bin directory of whatever build you downloaded. Shortcuts make the rest of this way easier. You'll also need a good text editor or even IDE, I suggest Sublime Text[sublimetext.com] .
Defining The Spawn Location
There are two main parts to spawning any kind of entity. The first is to create a .nlz file that defines the item to be spawned and the second is to instruct JC2 to load the new file.
I'll cover the second part first.
You'll need to extract world.bin from the resource files.
Use Gibbed's archive viewer, open the archives_win32 directory and load pc0.tab from it.
Expand the locations directory and find world.bin at the bottom. Click on it and then right-click and select Save. You'll be asked for somewhere to save it and put it wherever your workspace is. Once you have world.bin, we need to convert it to xml to take a better look, drag and drop it on to the shortcut for Gibbed.Avalanche.BinConvert.exe amd an xml file will be created in the same directory as the world.bin file.
Then open it up and take a look. It's full of xml objects that define locations on the map that need to be loaded when the player gets close. An example is:
<object id="EB20643A"> <value name="file" type="string">wc\33\33x23</value> <value id="2B5EF194" type="vec">2620.352,3634.329,-1542.801</value> <value id="7DF7F859" type="vec">-1311.395,-1283.256,-6036.504</value> </object>
The entry under 'file' declares a filename that holds all the data on the location. The two vec entries appear to define two points of a cube in the gamespace that contain the location. All the IDs are internal constants that we don't know the true names of, which is why they're still just hexadecimal values. They had a real name but it's hashed and no one outside of the developers have any way of recovering the names. But it doesn't really matter.
If you want to find a particular settlement then you need to know it's 'wc' name. You can get this from a resource file found in JC2 Map Viewer. I have no idea how those guys worked out the values but they have a file SettlementInfo\Settlements.xml which contains all the settlements and the game engine name for them. We want 'Kem Sungai Sejuk' so we do a search in this file and find this line:
<settlement id="33x23" index="218" type="military_base" textkey="set_mil_txt_30" totalcount="20" text="Kem Sungai Sejuk" x="17141.4424" y="12369.589" />
That gives us 33x23 which is what we look for in world.xml and we get the entry I showed above.
Now, we copy that entry and change two things:
<object id="EB20643B"> <value name="file" type="string">leopardspawn</value> <value id="2B5EF194" type="vec">2620.352,3634.329,-1542.801</value> <value id="7DF7F859" type="vec">-1311.395,-1283.256,-6036.504</value> </object>The first change is the object id. Make it something unique in the world.bin file. Just increment the last digit and do a find to make sure it's not already used. Then change the filename to something, probably needs to be all lowercase though I haven't tested that. One word, maybe underscores are ok, haven't tested that either. I think it's possible to use directories but there's no need.
This filename is what tells the game engine to load our leopardspawn.nlz file, it will look under the locations directory for a .nlz file with the name given.
This gives us two locations at the same coordinates, so they'll overlap. This is ok because we're only adding in a vehicle. If we added in buildings, it could get complicated but it would probably still work ok. The game doesn't really care which order things get loaded in.
Now we have to repack our new world.xml but before that, we should talk about merging and stuff.
Certain files have to be called a specific name for the JC2 engine to load them, these are things like world.bin and weapons.bin. This causes a problem because there can only be one version of the file and the last one to be loaded will override all the others.
As there is only one world.bin file in the JC2 resources and all locations have to be in it, we have a problem if you have other mods with locations, like Jusupov's 100% completion mod which many people including me consider essential. The solution is to merge the world.xml files which is actually really easy.
Just find the unique bits from each file and cut and paste to put them all into one file which you then pack as shown below. You can use code merge tools to do it or even just FC in DOS, you just need to find which bits each file adds/changes and copy them all into one file. If you're using a programming IDE or a smart text editor then there is probably a file compare function that you can use. There is actually a mod tool called Mod Combiner which *might* do it but I haven't tested it, it's meant to do the same thing for weapons files.
Anyway, once you have one big world.xml, drag it on to the BinConvert shortcut to convert it back to world.bin and then make a folder in dropzone called locations. Put world.bin in locations (remember that it came from locations in the pc0.tab file? It has to go back in the same directory name in dropzone where it will override the pc0.tab version of the file).
That's it. Now JC2 will look for a new file called locations/leopardspawn.nlz. It will check three places, first is all the .tab files in archives_win32, second is dropzone and third is the dlc directory (dlc overrides mods unless you do something special).
That file doesn't exist yet which won't cause a problem but we're about to make it anyway.
Defining The Spawn
First, Use the archive viewer again and start opening the pc*.tab files in archives_win32. The world locations are spread out amongst several of those files but most are in pc0-pc2. The one we want is in pc2.tab. Go to locations, expand wc, expand 33 and then select 33x23.nlz. There is a 33x23.flz one that seems to have the same stuff but not the xml definitions that we need so ignore that.
Click on 33x23.nlz and click on Save. Save it to your workspace.
Then drag the nlz onto your shortcut for Gibbed.Avalanche.SmallUnpack.exe and it will unpack the file for you. Go into the directory and select the 33x23.nl.blo file, drag it on to the BinConvert shortcut and it will create 33x23.nl.xml. Open that in your text editor.
You can see that it's full of xml objects that define various stuff about the location. Objects to spawn, AI behaviour and a few other things. We want a leopard so look for v071_jet_fighter and have a look over the object that holds this and the parents objects up to and including the SpawnSet stuff.
You want the bit that starts:
<object> <object id="F139BA85"> <value name="_class" type="string">CSpawnSet</value>Now find the end of the outermost object and copy and paste into a new file. This is the core of what we'll be meddling with. Also copy and paste the opening and closing tags of the file so that your new file looks like:
<?xml version="1.0" encoding="utf-8"?> <container extension=".blo" format="Raw" endian="Little"> <object> <object id="F139BA85"> <value name="_class" type="string">CSpawnSet</value> ... lots of stuff ... </object> </object> <object tag="inst" /> </container>
Save this file as leopardspawn.nl.xml. We're going to be doing some surgery on it and we don't completely know what we're doing but it seems to work.
Firstly, we don't our leopard to have an ai pilot so find the subobject that starts:
<object id="150019C4"> <value name="_class" type="string">STeamAgentInfo</valueDelete it entirely.
Then do the same for this one:
<object id="489147C1"> <value name="_class" type="string">CTeamComponent</value>I'm not sure but that's probably something to do with the AI pilot again. Get rid of it.
While you're there, go back to 33x23.nl.xml and grab the definition for a land vehicle that doesn't have a pilot, v108_armored_transport will do. That definition can serve as a sort of template for what we're doing. Put it in another file and you can refer back to it as required.
There are a whole lot of keys we probably need to delete here:
CSpawnSet,CTeamComponent1,disable_event,spawn_event,CPlacementComponent1 (the 976B6A1D key, not the object).
Then have a look at the numbers shown and compare them to the unpiloted vehicle. You'll see some differences such as D57278D7 is 1000 vs 200. Change the values for 44140F5E and D57278D7 to match the unpiloted vehicle.
Go to the VehicleComponent subject object and delete these three keys: SSmartObjectInfo4, CTeamComponent1, SSmartObjectInfo3. Those referred to AI stuff we already deleted.
The last bit is the location. It's this key:
<value name="world" type="mat">0.6716046,0,-0.7409098, 0,1,0, 0.7409098,0,0.6716046, 926.9531,298.5703,-4183.563</value>It's a bit mysterious but it seems to define a 3d point and then some sort of 2d rectangular boundary around it. 926.9531,298.5703,-4183.563 appear to be X,Z,Y coordinates with X being East/West and Y being North/South.
The other numbers look like some kind of matrix but I think they might actually be defining some sort of boundary from the set point with the middle triplet 0,1,0 defining which axes are degrees of freedom. I'm just speculating, we don't need to mess with those, just the last set of coordinates.
We want to move the plane slightly so that the original AI spawned plane won't crash into our modded plane when both are spawned at the same time. So we'll nudge it a little west and south and that should have it out of the way. The base isn't neatly lined up on N/S lines but instead runs diagonally across the map so we'll move it 15m in each direction. Edit the coordinates "926.9531,298.5703,-4183.563" to become "911.9531,298.5703,-4158.563". We can check if it's right in game and then adjust it until it's where we want it but I've already done all that and came up with these numbers. They more or less correspond to metres in game so this should move it 15m south and 15m west which puts it neatly next to the original plane without either being in each other's way.
Save the xml file.
Drag the xml file onto BinConvert and you'll get a leopardspawn.nl.blo file.
Make a directory in your workspace called leopardspawn and put leopardspawn.nl.blo into it. Then drag this directory onto Gibbed's SmallPack and it will create a leopardspawn.sarc file (small archive). Rename this file to leopardspawn.nlz and move it into dropzone\locations alongside world.bin. We're nearly done, you can now start JC2 and see if it works.
Packaging For Distribution/upload
JC2 packages its files in an archive with the extension .arc and a matching index file .tab that lists the locations in the archive of the files. No one knows why these aren't combined into one file like every other archiving technique ever used.
If you want to package your mod for upload as arc/tab files then there's one easy step.
When JC2 runs, it takes all the files in dropzone and packages them as one set of arc/tab files called 'separate_files'. The way to package your mods for upload, or to combine lots of mods that don't use the same file, is to run JC2 and wait for the main menu (so that the game has done its work), then alt-tab and copy the separate_files.arc/tab and rename them to something. It needs to start with a letter apparently and it's traditional to use x_ as the first two characters. x_leopardspawn.arc & x_leopardspawn.tab will do fine.
For the reasons listed above, it's also worth separating world.bin from the .nlz file, it will make it easier for other modders to combine it with their world.bin if they want to. The way to separate them is to remove all mods/files except for the ones being packaged and then start JC2, copy the separate_files.arc/tab, then close JC2. Repeat the process for each mod/file that you want to package.
You can leave the arc/tab packaging for now though, it's just for if you upload the mod to justcause2mods.com or any other way of distributing it.
Conclusion
So load up JC2, extract via Blackmarket to Kem Sungai Sejuk (it's the military base just north of Karl's house, between the two mountains) and if you followed my steps correctly, you'll see that your Si47 Leopard should be right where you put it.
You can put multiple vehicles and other stuff into your .nl file as well, when I was positioning the leopard I stuck a second one in the default location so that I could see whether it would cause a problem when the base was still populated. Jusupov used this technique to create/restore a settlement in order to make it possible to get 100%. He claims to have even created roads with it.
The possibilities for this are pretty large, you could create whole towns if you had the time and map making skills. The other stuff in the .flv and .nlz files define the other elements of the location, the .nl file only defines entities which are things like vehicles, people and pickup crates.
Have fun!
Source: https://steamcommunity.com/sharedfiles/filedetails/?id=576235628
More Just Cause 2 guilds
- All Guilds
- "Just Cause 2"
- Trying Everything Once (Update 1)
- Cmo hacer que Just Cause 2 deje de crashear
- Executable updating error how to solve the problem (FIX)
- Just Cause 2 Controls & MP Commands
- Aadir MODs
- Wrecking Ball ,Top of the World and I Believe I Can Fly achievements guide
- MODMOD
- [TR]Modlar ve Yamalar hakknda bilgi