UPDATED AS OF 08/04/2012 - 10:02
Ok so I got pestered for this, so here it is.
100% Custom Loot tables, no loot suppression, full control of what loot spawns in your server and where.
Steps:
To test that it is running check your CLIENT rpt logs
C:\Users\<username>\AppData\Local\ArmA 2 OA
and look for
SPAWNING WITH CUSTOM LOOT
Once this is showing in your client log files the code is running correctly, you can now start your modifying process.
First order of business is to remove the testing line
So remove
from line 16 of building_spawnLoot.sqf
Best to remove this line to reduce spam of the client log files.
We will take hospital loot for adding for testing, since its the smallest so easy to read.
You must always remember the last object in the list must not have a trailing comma. This will make the engine expect another object and throw up script errors.
so to add another object. I would put a comma after ["MedBox0","object"] and then add my item.
When you add an object, remember to add a chance value in the correct position, trailing commas work the same in this section.
So I have added an AS50 spawn to the hospital with the same chance to spawn as a medical box.
You may want to go for some more realistic loot but examples are examples.
Other key factors you must watch for. The loot CLASS there are several classes for loot.
Best practice is find the item from another table and copy its data,
if you are unsure use generic, it is used for everything that isn't a weapon or box/backpack.
This code was made to be simple so some features of 1.7.6 base was changed to allow this to work. It uses the old 1.7.5 style loot weights rather than the 1.7.6 CBL_Base design so loot may seem to drop differently. But you have to make sacrifices for custom loot. Or you can go through the effort of redoing this to incorporate it, but this works. Why fight it.
Any problems do post here. Please don't PM me, If I fix a problem, might as well let everyone see and learn from any mistakes.
Further more. Enjoy your custom loot tables. (Try not to over run your server with high loot drops
)
FAQ:
Q. I don't run Chernarus will this code work with other maps?
A. This code is designed on Chernarus' loot tables. You will need to look at the config.cpp file for the map you are running and copy the values for its loot tables to match up correctly. (If you do this, please be kind enough to share for everyone else.)
Q. Does this allow us to spawn banned weapons?
A. No. Weapons are banned at the games start up process which cannot but undone without adding a new mod to override the bans (rMod)
Q. Does this fix allow us to change crash site loot?
A. No Crash sites use a separate method for spawning its loot. This code will not be ran during that method. You will need to modify server_spawnCrashSite.sqf in the same retrospect as this edit to allow custom loot tables there also. I will post another tutorial soon on how to achieve this.
Q. I did this tutorial but there is no loot. What have I done wrong?
A. Post your mission PBO. I'm sure someone or myself will help find the problem. Not everyone is perfect.
Q. Are these tables the default tables?
A. Yes these tables are default Chernarus as of 1.7.6.1
Q. If I did this can I just customize one building or do I have to customize everyone?
A. Loot is spawned based of the buildings loot type. so all Barns go under the Farm class. If you change the farm class anything under farm will change.
You can however add more classes and assign all of the same building to this new class. But you cannot make a single specific building spawn certain loot.
Ok so I got pestered for this, so here it is.
100% Custom Loot tables, no loot suppression, full control of what loot spawns in your server and where.
Steps:
- Decompress your mission pbo
- Create a fixes folder
- create building_spawnLoot.sqf
- Put this code into it http://pastebin.com/UPHj1Q02
- open init.sqf
- after
Code:
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf";//Compile regular functions progressLoadingScreen 1.0;
Code:building_spawnLoot = compile preprocessFileLineNumbers "fixes\building_spawnLoot.sqf";
- save your work and pack your pbo.
To test that it is running check your CLIENT rpt logs
C:\Users\<username>\AppData\Local\ArmA 2 OA
and look for
SPAWNING WITH CUSTOM LOOT
Once this is showing in your client log files the code is running correctly, you can now start your modifying process.
First order of business is to remove the testing line
So remove
Code:
diag_log "SPAWNING WITH CUSTOM LOOT";//Remove This line after testing
Best to remove this line to reduce spam of the client log files.
We will take hospital loot for adding for testing, since its the smallest so easy to read.
Code:
case "Hospital": {
_itemTypes = [
["","trash"],
["","hospital"],
["MedBox0","object"]
];
_itemChance = [
0.2,
1,
0.2
];
};
so to add another object. I would put a comma after ["MedBox0","object"] and then add my item.
Code:
case "Hospital": {
_itemTypes = [
["","trash"],
["","hospital"],
["MedBox0","object"],
["BAF_AS50_scoped","weapon"]
];
_itemChance = [
0.2,
1,
0.2,
1
];
};
So I have added an AS50 spawn to the hospital with the same chance to spawn as a medical box.
You may want to go for some more realistic loot but examples are examples.
Other key factors you must watch for. The loot CLASS there are several classes for loot.
Code:
object
weapon
magazine
generic
if you are unsure use generic, it is used for everything that isn't a weapon or box/backpack.
This code was made to be simple so some features of 1.7.6 base was changed to allow this to work. It uses the old 1.7.5 style loot weights rather than the 1.7.6 CBL_Base design so loot may seem to drop differently. But you have to make sacrifices for custom loot. Or you can go through the effort of redoing this to incorporate it, but this works. Why fight it.
Any problems do post here. Please don't PM me, If I fix a problem, might as well let everyone see and learn from any mistakes.
Further more. Enjoy your custom loot tables. (Try not to over run your server with high loot drops
FAQ:
Q. I don't run Chernarus will this code work with other maps?
A. This code is designed on Chernarus' loot tables. You will need to look at the config.cpp file for the map you are running and copy the values for its loot tables to match up correctly. (If you do this, please be kind enough to share for everyone else.)
Q. Does this allow us to spawn banned weapons?
A. No. Weapons are banned at the games start up process which cannot but undone without adding a new mod to override the bans (rMod)
Q. Does this fix allow us to change crash site loot?
A. No Crash sites use a separate method for spawning its loot. This code will not be ran during that method. You will need to modify server_spawnCrashSite.sqf in the same retrospect as this edit to allow custom loot tables there also. I will post another tutorial soon on how to achieve this.
Q. I did this tutorial but there is no loot. What have I done wrong?
A. Post your mission PBO. I'm sure someone or myself will help find the problem. Not everyone is perfect.
Q. Are these tables the default tables?
A. Yes these tables are default Chernarus as of 1.7.6.1
Q. If I did this can I just customize one building or do I have to customize everyone?
A. Loot is spawned based of the buildings loot type. so all Barns go under the Farm class. If you change the farm class anything under farm will change.
You can however add more classes and assign all of the same building to this new class. But you cannot make a single specific building spawn certain loot.