Troubleshoot Custom Weapons/Attachments for Modders
You're working on a custom weapon/attachment and run into a specific issue you have no idea how to deal with?
Then this is for you, this is a collection of known common/uncommon problems you might run into while working on a custom weapon/attachment and how to deal with them.
Softlock
-
[Description]
When your game freezes while trying to load an asset (for example trying to inspect a weapon or attach an attachment) its called a softlock.
-
[What to do]
[Custom Weapon]
You try to preview your new custom weapon for the first time and it causes a softlock, those are the things you can do:
- Check your default_blueprint. Are the attachment IDs correct? Are there attachments listed that don't even exist?
- Check the BLT Log for any errors related to missing assets on your custom weapon
- Check if the paths in your default_blueprint part assets (unit/object/mat_cfg) are all correct.
- Use an elimination method in which you only try to preview the gun one attachment at a time and comment the rest out to find the attachment thats causing the issue. Then use step 3.
- Check if you didn't forget to add any needed asset paths (unit/model/object/mat_cfg)
[Custom Attachment]
You try to preview your new custom attachment for the first time and it causes a softlock, those are the things you can do:
- Check the BLT Log for any errors related to missing assets on your custom attachment
- Check if the paths in your part assets (unit/object/mat_cfg) are all correct.
Weapon Crash
-
[Description]
Equipping or previewing a specific custom weapon crashes your game (can also apply to equipping or previewing an attachment).
-
Crash 1
The crash looks something like this: (Note the _add_part() lib/managers/weaponfactorymanager
)
Application has crashed: access violation
-------------------------------
Callstack:
payday2_win32_release (???) ???
payday2_win32_release (???) ???
payday2_win32_release (???) ???
payday2_win32_release (???) ???
payday2_win32_release (???) ???
-------------------------------
Current thread: Main
Script stack:
_add_part() lib/managers/weaponfactorymanager.lua:743
_add_part() lib/managers/weaponfactorymanager.lua:708
assemble_from_blueprint() lib/managers/weaponfactorymanager.lua:627
assemble_from_blueprint() @mods/WeaponLib/modules/different_akimbos/menuraycastweaponbase.lua:18
clbk() lib/managers/menu/menuscenemanager.lua:2186
lib/managers/dynamicresourcemanager.lua:220
-------------------------------
-
[What to do]
- First find the attachment thats causing this issue (If you can't find it use an elimination method like on Softlock step 4)
- Your based_on for the attachment is not the same as the .object/.unit files. (For example the luger magazine as based_on for magazine assets from the 5/7)
-
Crash 2
The crash looks something like this:
PAYDAY 2 Crash log
Application has crashed: C++ exception
[string "lib/managers/weaponfactorymanager.lua"]:984: attempt to index a nil value
SCRIPT STACK
get_ammo_data_from_weapon() @mods/WeaponLib-Release/modules/weaponfactorymanager_caching/weaponfactorymanager.lua:51
original() @mods/WeaponLib-Release/modules/general_fixes/newraycastweaponbase.lua:211
_update_stats_values() @mods/base/req/core/Hooks.lua:260
make_fakeweaponbase() @mods/More Weapon Stats/lua/blackmarketgui.lua:787
mws_get_popup_data() @mods/More Weapon Stats/lua/blackmarketgui.lua:614
original() @mods/More Weapon Stats/lua/blackmarketgui.lua:560
show_stats() @mods/base/req/core/Hooks.lua:260
on_slot_selected() lib/managers/menu/blackmarketgui.lua:6672
ddi_original_blackmarketgui_mousepressed() lib/managers/menu/blackmarketgui.lua:6282
mouse_pressed() @mods/Drag and Drop Inventory/blackmarketgui.lua:19
mouse_pressed() lib/managers/menu/menucomponentmanager.lua:1458
mouse_pressed() @mods/base/lua/MenuComponentManager.lua:24
mouse_pressed() lib/managers/menu/menurenderer.lua:368
mouse_press() lib/managers/menu/menuinput.lua:570
lib/managers/mousepointermanager.lua:341
-------------------------------
Callstack:
payday2_win32_release (???) ???
payday2_win32_release (???) zip_get_name
payday2_win32_release (???) zip_get_name
-------------------------------
-
[What to do]
- First find the attachment thats causing this issue (If you can't find it use an elimination method like on Softlock step 4) (NOTE: this crash is caused by a stock type attachment)
- Your attachment tries to add a stock_adapter that doesn't exist on the gun, either add the stock_adapter to the gun or remove the line that tries to add the stock adapter.
Weapon Crash 2
-
[Description]
Clicking on the weapon causes a crash. The crash looks something like this:
PAYDAY 2 Crash log
Application has crashed: C++ exception
[string "lib/managers/weaponfactorymanager.lua"]:1617: attempt to index a nil value
SCRIPT STACK
_check_sound_switch() lib/units/weapons/newraycastweaponbase.lua:694
original() @mods/WeaponLib-Release/modules/general_fixes/newraycastweaponbase.lua:83
_update_stats_values() @mods/base/req/core/Hooks.lua:260
make_fakeweaponbase() @mods/More Weapon Stats/lua/blackmarketgui.lua:787
mws_get_popup_data() @mods/More Weapon Stats/lua/blackmarketgui.lua:614
original() @mods/More Weapon Stats/lua/blackmarketgui.lua:560
show_stats() @mods/base/req/core/Hooks.lua:260
on_slot_selected() lib/managers/menu/blackmarketgui.lua:6672
ddi_original_blackmarketgui_mousepressed() lib/managers/menu/blackmarketgui.lua:6282
mouse_pressed() @mods/Drag and Drop Inventory/blackmarketgui.lua:19
mouse_pressed() lib/managers/menu/menucomponentmanager.lua:1458
mouse_pressed() @mods/base/lua/MenuComponentManager.lua:24
mouse_pressed() lib/managers/menu/menurenderer.lua:368
mouse_press() lib/managers/menu/menuinput.lua:570
lib/managers/mousepointermanager.lua:341
-------------------------------
Callstack:
payday2_win32_release (???) ???
payday2_win32_release (???) zip_get_name
payday2_win32_release (???) zip_get_name
-
[What to do]
- You probably forgot to close one of your xml tags like
<Weapon>
, either try to find the unclosed tag manually or run it through an XML validator
Weapon Crash 3
-
[Description]
Going into a heist with a custom weapon causes a crash. The crash looks something like this:
Application has crashed: C++ exception
[string "lib/units/weapons/newnpcraycastweaponbase.lua"]:19: attempt to index a nil value
SCRIPT STACK
spawn_unit() =[C]
add_unit_by_factory_blueprint() lib/units/beings/player/huskplayerinventory.lua:144
add_unit_by_factory_name() lib/units/beings/player/huskplayerinventory.lua:134
_perform_switch_equipped_weapon() @mods/Third Person/thirdperson.lua:199
synch_equipped_weapon() lib/units/beings/player/huskplayerinventory.lua:21
set_equipped_weapon() lib/network/handlers/unitnetworkhandler.lua:61
@mods/BeardLib/Hooks/NetworkHooks.lua:105
send_to_peers_synched() @mods/Third Person/lua/basenetworksession.lua:52
send() lib/network/base/extensions/networkbaseextension.lua:11
_send_equipped_weapon() lib/units/beings/player/playerinventory.lua:389
equip_selection() lib/units/beings/player/playerinventory.lua:344
original() lib/units/beings/player/states/playerstandard.lua:5185
_start_action_equip_weapon() @mods/base/req/core/Hooks.lua:260
_update_equip_weapon_timers() lib/units/beings/player/states/playerstandard.lua:3291
_update_check_actions() lib/units/beings/player/states/playerstandard.lua:883
original() lib/units/beings/player/states/playerstandard.lua:435
update() @mods/base/req/core/Hooks.lua:185
original() lib/units/beings/player/playermovement.lua:271
@mods/base/req/core/Hooks.lua:260
-
[What to do]
- Note the
_perform_switch_equipped_weapon() @mods/Third Person/thirdperson.lua
this crash is caused by using both WeaponLib and the ThirdPerson mod, to fix it either disable or remove the ThirdPerson mod. If this exact crash still keeps hapening afterwards contact me on Discord (Killerwolf#2636)
Custom Attachment Points Issues
-
[Description]
Custom attachment points from your weapontweakdata don't have an effect ingame, i.e changing the values doesn't move them.
-
[What to do]
- Check if you weapontweakdata is hooked
- Check if your hook has a unique name and isn't being overwritten by a post hook with the same name (this usually happens when copying files from another custom weapon and then forgetting to change stuff for the new weapon)
- If all the above isn't the issue check if your weapons .unit and npc.unit have the correct values example:
<extensions>
<extension class="ScriptUnitData" name="unit_data" />
<extension name="base" class="NewRaycastWeaponBase" >
<var name="name_id" value="tti" /> <!-- value should be the same as your weapons ID -->
</extension>
</extensions>
Weapon disappears from your inventory
-
[Description]
When you restart your game the custom weapon is gone from your inventory.
-
[What to do]
- A part defined in the
default_blueprint
is either not in theuses_parts
or doesn't exist at all