Setting weapon model for a pre-existing weapon.

For discussion and release of fan maps made by the community.
SolarDawn
Posts: 4
Joined: Sun Mar 10, 2025 5:31 pm

Setting weapon model for a pre-existing weapon.

Postby SolarDawn » Sun Mar 10, 2025 5:37 pm

Hello. I'm interested in changing the model of a weapon, which is in this case the AR2, and I would anticipate this would be executed via Python. I've already managed to change models for units through editing the modelname attribute, but the same logic sadly does not apply for weapons. I also have tried setmodel and setviewmodel, but either I am inputting the command incorrectly or they do not work for weapons either.

The scripts I am attempting to edit are in hl2wars > python > wars_game > weapons. Thanks in advance for any help.
Sandern
Developer
Posts: 1981
Joined: Thu Nov 22, 2024 6:58 pm
Location: Netherlands
Contact:

Re: Setting weapon model for a pre-existing weapon.

Postby Sandern » Sun Mar 10, 2025 5:39 pm

Weapon models are still edited in the weapon scripts file. So for smg1 you edit "scripts/weapon_smg1.txt".
SolarDawn
Posts: 4
Joined: Sun Mar 10, 2025 5:31 pm

Re: Setting weapon model for a pre-existing weapon.

Postby SolarDawn » Sun Mar 10, 2025 5:57 pm

Ok, thanks, and my appreciations once more for the fast reply. I am wondering whether the Half Life 2 Wars weapon models are finetuned for their purpose? I have imported in weapon models from Garry's Mod but I seem to only receive the dreaded red error sign when I replace the weapon. Of course, the filepath may be wrong, and I am looking into that now. I am using a "hl2wars/models" filepath currently, which worked with models. Do you think that this differs for weapons?

Thanks again for your time.

EDIT: The weapon model now appears, but is simply dropped at his feet. I fixed the previous issue via simply removing "hl2wars" from the filepath.
Sandern
Developer
Posts: 1981
Joined: Thu Nov 22, 2024 6:58 pm
Location: Netherlands
Contact:

Re: Setting weapon model for a pre-existing weapon.

Postby Sandern » Sun Mar 10, 2025 6:39 pm

SolarDawn wrote:Ok, thanks, and my appreciations once more for the fast reply. I am wondering whether the Half Life 2 Wars weapon models are finetuned for their purpose? I have imported in weapon models from Garry's Mod but I seem to only receive the dreaded red error sign when I replace the weapon. Of course, the filepath may be wrong, and I am looking into that now. I am using a "hl2wars/models" filepath currently, which worked with models. Do you think that this differs for weapons?

Thanks again for your time.

EDIT: The weapon model now appears, but is simply dropped at his feet. I fixed the previous issue via simply removing "hl2wars" from the filepath.


It should be a path like "models/weapons/w_smg1.mdl", so "hl2wars" in front shouldn't be needed.

There might be incompatibility issues with models not compiled for Alien Swarm. That might explain why the weapon appears at the feet of the soldiers. Most likely it fails to do "bone merge" with the unit, so the model bones don't match with the ones of the unit model.
SolarDawn
Posts: 4
Joined: Sun Mar 10, 2025 5:31 pm

Re: Setting weapon model for a pre-existing weapon.

Postby SolarDawn » Sun Mar 10, 2025 6:41 pm

Thanks for the reply. In order to rectify the issues with the model, will I have to use 3ds Max or some other form of program to edit the weapon model to suit the bone mesh?
redspike474
Contributor
Posts: 2
Joined: Sun Mar 10, 2025 7:21 pm

Re: Setting weapon model for a pre-existing weapon.

Postby redspike474 » Sun Mar 10, 2025 8:31 pm

Hello !
You can fix this issue by decompiling the model using Studio compiler
http://www.chaosincarnate.net/cannonfodder/studiocompiler.php

This should output a working Qc file and Smd's that you can then recompile back into a model.

The characters in hl2wars use

$bonemerge "ValveBiped.Bip01_R_Hand" just the same as in half-life 2
Which means there must be a bone called ValveBiped.Bip01_R_Hand on the weapon so that it can be merged with the characters and thus appear in his hand.

So this is pretty easy but can take some tweaking to look correct. If you load into 3dsmax Male_05_reference.smd which you will have if you have sourcesdk installed. it will be in
Program Files (x86)\Steam\steamapps\Yourusername\sourcesdk_content\hl2mp\modelsrc\humans_sdk\Male\Group03\

Do not edit the character or the location of his bones or you will break things, next import your decompiled weapon smd into the scene , you will want to move it and its bones as one , which should already happen but just encase it doesn't make sure you have the mesh and bones selected when your moving it around the scene.
Move your weapon to the correct location in the characters hand.
When your happy with the location hide the characters mesh so that you can only see his bones.
Select your weapon, your weapons bones and select the characters bone called ValveBiped.Bip01_R_Hand. ** note ** make sure not to select the rest of characters bones.
Export this selection over your weapons original reference smd. (make sure you make a backup first)

To check if you have exported everything correctly open this new smd in notepad and see if in the bone list at the top there is ValveBiped.Bip01_R_Hand
If there isnt then you didn't have the correct selection when exporting.
next use studio compiler to recompile your model, make sure your new model is referenced in the weapons script.
test in game !

Let me know how it goes, hopefully that will get it working for you.
SolarDawn
Posts: 4
Joined: Sun Mar 10, 2025 5:31 pm

Re: Setting weapon model for a pre-existing weapon.

Postby SolarDawn » Sat Mar 16, 2025 9:21 pm

My gratitude for the reply and apologies about the belated nature of my own. What version of 3ds Max do you recommend I use? I currently have 3ds Max 8 with Service Pack 3, but I am wondering whether I should use 3ds Max 2009 or an even more recent version. I will also have to install an SMD importer and exporter, correct?
redspike474
Contributor
Posts: 2
Joined: Sun Mar 10, 2025 7:21 pm

Re: Setting weapon model for a pre-existing weapon.

Postby redspike474 » Mon Mar 18, 2025 5:56 pm

I use 2012 and the exporter from here http://www.wunderboy.org/3dapps.php
i am not sure if it supports version 8
if i remember correctly you just put the correct exporter (64bit or 32 depending on your os) in the plugins folder, i am pretty sure it explains on that site anyway.

Return to “Community Maps”

Who is online

Users browsing this forum: No registered users and 2 guests