FOnline Development > 3D Development
Problems porting weapons to FOnline
Luther Blissett:
Sorry I've not tested much in the newest revisions - I have no idea about the start_server_client.fos to be honest. If client_main.fos is also no longer used, then I assume this info must be put somewhere else instead. Basically it's these bits below you're looking for - in mine they're pretty much at the end of the client_main.fos file, but if that file doesn't exist, perhaps the same code has been put in a different file?
If so, you can find the bits which look like this :
--- Code: ---#ifdef PLAYERS_3D
int GetHandleValue(uint16 pid)
{
if(pid == 0 || (pid >= 1000 && pid <=1100)) return 0;
int handle = 0;
switch(pid)
{
case PID_ZIP_GUN: handle = ATTRIBUTE_Handle_Weapon_22Autoloader; break;
case PID_9MM_MAUSER: handle = ATTRIBUTE_Handle_Weapon_9mmAutoloader; break;
case PID_10MM_PISTOL: handle = ATTRIBUTE_Handle_Weapon_22Autoloader; break;
case PID_14MM_PISTOL: handle = ATTRIBUTE_Handle_Weapon_22Autoloader; break;
case PID_DESERT_EAGLE: handle = ATTRIBUTE_Handle_Weapon_45Autoloader; break;
[...]
case PID_BROWN_BAG:
case PID_BACKPACK: handle = 0; break;
// Generic item
default: handle = 0; break;
}
return handle;
}
#endif
--- End code ---
Then replace them with bits which look like this instead :
--- Code: ---#ifdef PLAYERS_3D
int GetHandleValue(uint16 pid)
{
if(pid == 0 || (pid >= 1000 && pid <=1100)) return 0;
int handle = 0;
switch(pid)
{
case 1 : handle = 1 ; break;
case 2 : handle = 2 ; break;
case 3 : handle = 3 ; break;
case 4 : handle = 4 ; break;
case 5 : handle = 5 ; break;
case 6 : handle = 6 ; break;
case 7 : handle = 7 ; break;
case 8 : handle = 8 ; break;
case 9 : handle = 9 ; break;
[...]
case 498 : handle = 498 ; break;
case 499 : handle = 499 ; break;
case 500 : handle = 500 ; break;
// Generic item
default: handle = 0; break;
}
return handle;
}
#endif
--- End code ---
Hopefully that would get the weapons working (because it's done by number instead of specific name, it should work regardless of what the files are called).
You can have multiple textures on a single object - you just need the object to have several different materials, which can be altered by subsets. Have a quick look through the thing I wrote up here : #2 - Testing custom body textures. That should help to explain most of it I think.
In short, the different texture numbers (Texture 0, 1, 2) are for diffuse, normal and specular. They're not for multiple textures on the same model. Like this :
--- Code: ---Value 10 Root Texture 0 diffuse.png Texture 1 normalmap.png Texture 2 specularmap.png
--- End code ---
Note that I never managed to get normal maps to work. Specular and diffuse did work.
If you looked at the tutorial link, you should roughly understand the subsets on the main body. You can of course add subsets to any other model. There's a little annotated code here from when I was testing hair subsets :
--- Code: ---# testing the subsets
Value 90 Root Attach longhairtestsubsets.x Texture 0 hair_brown.png
# character shows in game with fully brown hair, covering all materials
Value 91 Root Attach longhairtestsubsets.x
Subset 0 Texture 0 hair_purple.png
Subset 1 Texture 0 hair_grey.png
Subset 2 Texture 0 hair_red.png
Subset 3 Texture 0 hair_white.png
# character shows in game with
# purple side of head (subset 0 therefore material 1)
# grey top of head (subset 1 therefore material 2)
# red long part of hair (subset 2, therefore material 3)
# white non existent.
--- End code ---
The hair model was split into three areas with different materials (material 1, 2 and 3). The material at the top of the materials list (irrespective of its name) seemed to be treated as subset 0. The others followed in sequence.
Hope that all makes sense.
E3245:
So that would mean that Subset 0 = Material ID 0, Subset 1 = Material ID 1, etc?
Luther Blissett:
Different 3D programs may call the materials something different (like 1,2,3 instead of 0,1,2 or not give them a number at all) but basically, yes. It should do as you described.
E3245:
Okay, I finally got the textures to load, but I tried to replace the code in the client_main.fos, but it messes up the models. Like the assault rifle model is now the baseball bat instead of the sawed-off shotgun. Is this supposed to happen?
Plus I still can't figure out how to link the weapon to the model. Would Case 1 be ProtoID #1 and handle would be the attribute of the weapon? I need a clear understanding of this because I am confused.
Luther Blissett:
You're unfortunately getting to the point where I start having to say "I don't know" - but it definitely shouldn't be showing the wrong models. I THINK the problem is with an older version of the _FOHuman.fo3d. The layer you want to be looking at is "# Right Handle Layer 1" (this corresponds to param 151 by in game code).
In different versions I have, one starts with :
(I've spoilered the three chunks of code here)
--- Code: ---# Right Handle
Layer 1
Value 1 Attach WP_bazooka.x Link R_Handle_1 Scale 1 RotX -90 RotY -15
Value 2 Attach WP_223Autoloader.fo3d Link R_Handle_1 Scale 50
Value 3 Attach WP_223Autoloader_GunSilencer.fo3d Link R_Handle_1 Scale 50
Value 4 Attach WP_Minigun.fo3d Link R_Handle_1
Value 5 Attach WP_club.x
--- End code ---
another starts with :
--- Code: ---# Right Handle
Layer 1
Value 4 Attach WP_knife.x Texture 0 WP_knife.bmp Link R_Handle_1 Scale 3.5 RotY -90 MoveX 1
Value 5 Attach WP_club.x Link R_Handle_1 Scale 1.2 RotZ 110 RotX 90 RotY 9
Value 6 Attach WP_sledgehammer.x Link L_Handle_1 Scale 2.5 RotX 85 RotY 11 RotZ -70 MoveX 2
Value 7 Attach WP_spear.fo3d Link R_Handle_1 Scale 0.56 RotY 180 RotX 6 MoveX 3 MoveY -4
--- End code ---
I've also got one grouped in sections, which I believe to be the newest and best
--- Code: ---# Right Handle
Layer 1
#Pistols
Value 241 Attach WP_223pistol.x Link R_Handle_1 Scale 3.7 RotY -90 RotZ 10 MoveX 4 MoveY 1
Value 313 Attach WP_magnum.x Texture 0 ITEM_44magnum.jpg Link R_Handle_1 Scale 2.3 RotY -90 RotZ 10 MoveX 4 MoveY 1
--- End code ---
The former has objects listed at every number, the middle has only objects listed at the correct number for their object ID and the latter is grouped in sections.
I've uploaded the last one here > FOHuman.fo3d.
If you're lucky, you can maybe drop that in and it will just work. What you ask about linking weapon/model... that's what it's meant to do, but might not do yet :(
The layer IDs SHOULD correspond to the object IDs, and the code in CLIENT_main.fos :
--- Code: ---case 1 : handle = 1 ; break;
--- End code ---
should be pretty much saying "When it's ID#1, look at value#1 in the Fo3d" (I think). This should mean that some of the numbers don't exist any more, so there is no line for wearing armour ID#4 (layer 3 value 4), because ID#4 is a knife, so will only be in Layer 1 (active hand) and possible Layer 2 (inactive hand). The general skin and hair layers aren't drawing numbers from the object IDs, so should currently be simply in sequence (i.e. 1, 2, 3, 4 etc).
Basically, the main problem is that loads of this stuff is half done, and various bits are uploaded in different places, with different bits working. I've tested lots of things myself, but it means my own in-progress "FOHuman" is completely incompatible with Karpov's in-progress "FOHuman". It also means I have 5 or 6 different versions of FOHuman in different folders. They can be combined later with things like "Winmerge" or manually correcting them though.
For the general question about how the bits link together, it's again a little beyond my knowledge, but I'd assume anyone who's successfully added extra objects to the game (like the 2238 devs) should know how this all works properly.
The bits I am aware of are roughly as follows :
server\data\ItemNames.lst < this lists all objects in game, and ID numbers. I'm not sure if it's just for reference, or whether it affects anything
server\proto\weapon.fopro < this gives all the info for each of the weapons. "Pid" is the ID and the "Weapon.Anim1=" line specifies which animation set to use. You can see these animation sets listed at the bottom of _FOHuman.fo3d, though it shows as ABCD instead of 1234 (i.e. knife uses Weapon.Anim1=4, which corresponds to animation set "Anim D". Armour is in "armor.fopro".
server\text\engl\foobj.msg < These are the in-game names for the objects. Seems to follow ID00 = short name, ID01 = description, i.e. assault rifle is ID 23, so 2300 = "Assault Rifle" etc. I don't know if these are hardcoded from ID, or whether they're specified in a file somewhere.
server\scripts\CLIENT_main.fos < has loads of other stuff in I don't understand, but also contains the object/animation links at the bottom. The older one said :
--- Code: ---case PID_10MM_PISTOL: handle = ATTRIBUTE_Handle_Weapon_22Autoloader; break;
--- End code ---
Which meant "when you equip the object with "10MM_PISTOL" ID, load the model "Weapon_22Autoloader".
The newer one should say :
--- Code: ---case 1 : handle = 1 ; break;
--- End code ---
"When you equip the object with ID 1, load the model listed under value 1 in the relevant layer of the fo3d file".
I hope that makes some sense to you - I only just understand what I'm trying to say myself ???
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version