Jump to content

[DST] Weapon modding - custom sounds and ammo magazine


Recommended Posts

Hi guys. I need a little help with adding firing sound to my gun mod. I wouldn't be able to even start with this mod without K1NGT1GER609, so I am really grateful for his hughe input into this project. I am just a parasite without any programming skills :p.  Let's back to main topic; so what should I do to receive firing sound of firearm ? I mean what codeline shall I use in weapon prefab file. The second part of this topic is about creating ammo magazine with certain amount of bullets inside. Is it possible (for instance of course) to put ammo in special window in my inventory and weapon will know that it should use only this ammo from special slot described as ammo magazine ?

 

Link to comment
Share on other sites

Thinking is one of the hardest things for people to do, and its harder to teach someone else to think and improvise with nothing at the start. I can't really help with the magazine but for sound I can point you in the right direction. For a weapon code wise you'd need something like this in the lua file:

local function onattack_gun(inst, owner, target)
    inst.SoundEmitter:PlaySound("shots/gunshot/gaussrifleshot")    
end

 

inst.entity:AddSoundEmitter()

if not TheWorld.ismastersim then
   return inst
end

inst.components.weapon:SetOnAttack(onattack_gun)

and something like this in the modmain in the assets:

Asset("SOUNDPACKAGE", "sound/gunshots.fev"),
    Asset("SOUND", "sound/gunshots_bank.fsb"),

if you need more information you can check out this link:

The reason I said point you in the right direction is because theres plenty of branching paths to follow on creating a sound file but if you can understand the ideal principle in the guide then you should be fine.

Link to comment
Share on other sites

As a suggestion for the magazine for your gun perhaps making your weapon repairable and don't remove it when it runs out of uses. Then you can repair it by using the magazine of ammo. It's just like you're loading the gun. 

Edited by RedHairedHero
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...