Swapping weapon sounds via LUA
I need a little advice here. I'm working on a script that buffs the rate of fire for the AMCAR to match the AMR-16 (basically making it a lower damage, higher ammo alternative, instead of literally the worst weapon in the game). I've had no trouble increasing the rate of fire, but the problem is the sounds. Because of Payday 2's looping automatic firing sounds, it still sounds like it has the default rate of fire, despite actually firing much faster. I found an old thread discussing swapping weapon sounds via LUA, and tried to do this with the following additions to the WeaponTweakData function in my script:

tweak_data.weapon.amcar.sounds.fire = "m16_fire_single"
tweak_data.weapon.amcar.sounds.fire_single = "m16_fire_single"
tweak_data.weapon.amcar.sounds.fire_auto = "m16_fire"
tweak_data.weapon.amcar.sounds.stop_fire = "m16_stop"

Unfortunately, these cause the game to immediately CTD upon launch (C++ exception, "attempt to index field 'weapon' (a nil value)"). The post that I used as a reference for these is from 2014, so I suspect these are long outdated and no longer functional with how the game currently handles weapon sounds. Is there an alternative, currently working method to swap weapon sounds via LUA, or am I SOL? If it isn't obvious, I am an extreme novice at actually editing LUA scripts and basically all of my knowledge is from reverse engineering existing mods and simple Google searches, so please forgive me and correct me if I'm doing something entirely wrong here (which is probably the case).

Edit: doing some more research, it seems like tweak_data should only be used in independent persistent scripts, and not in weapontweakdata scripts. However, I tried using these same values in a persistent script, and they did absolutely nothing.

Edit dos: I forgot to mention, I've also tried replacing the "tweak_data" prefix with "self" when using the weapontweakdata format, which resulted in the weapon making no firing sounds at all even after loading the weapon (in this case, the AMR-16) into memory. I even tried using the Para's sounds instead and starting a map with both the AMCAR and Para equipped, so that the Para would be 100% fully loaded into memory - still no sounds for the AMCAR. I figure this is probably the closest I've gotten to doing it correctly, but obviously I'm still doing something horribly wrong.
You can probably try use Auto Fire Sound Fix mod so the AMCAR firing sound will match with it RoF

There's some mod here that use weapontweakdata script with PostHook, maybe it could work with your code
But I reccomend just use Auto Fire Sound Fix mod

Forum Jump:

Users browsing this thread: 1 Guest(s)