MrDoge124 Posted December 26, 2021 Share Posted December 26, 2021 Hello, I've been trying to get a blunderbuss to take ammo like a slingshot. So far I've managed to get it to take slingshot ammo and fire it. But there are a few issues. Mainly with adding the small ui slot above the hand slot ui. I cannot get this to show up. I did however get it to take the ammo by changing "inst.components.container.canbeopened" to true but this crashes the game when you try to open the container. [00:03:04]: [string "scripts/widgets/containerwidget.lua"]:30: attempt to index local 'widget' (a nil value) Secondly it seems to use the default swinging animation and not the blunderbuss animations. I'm not sure what's causing that. If anyone as any ideas on how to fix the issues, please let me know. Thanks for your time! Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/ Share on other sites More sharing options...
skittles sour Posted December 26, 2021 Share Posted December 26, 2021 The error is that the widget has not been loaded correctly by the game. The second problem has to do with the wilson stategraph's action handlers, where you would need to tell it to do a blunderbuss shoot animation when it enters an attack state. There exists a blunderbuss mod with container in the DST workshop and also another one in the DS workshop that adds a container. You can take a look at how they handled the blunderbuss. Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1528391 Share on other sites More sharing options...
MrDoge124 Posted December 27, 2021 Author Share Posted December 27, 2021 I've found an example mod, I've just got to change what kind of ammo it accepts. Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1528555 Share on other sites More sharing options...
MrDoge124 Posted January 8, 2022 Author Share Posted January 8, 2022 Sorry for the late reply, but I cannot figure out how I would make the damage change with the ammo. I was thinking I could pull the damage value out of the slingshotammo.lua but I don't know how I'd do that. Any ideas? Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1531368 Share on other sites More sharing options...
Monti18 Posted January 10, 2022 Share Posted January 10, 2022 You can do something like this: Spoiler local function OnAmmoLoaded(inst,data) if data ~= nil and data.item ~= nil then if data.item.components.weapon then local damage = data.item.components.weapon.damage --do whatever you want to do with the information of the damage of the ammo --for example damagechange: local old_damage = inst.components.weapon.damage inst.components.weapon:SetDamage(old_damage + damage) end end end local function OnAmmoLoaded(inst,data) if data ~= nil and data.prev_item ~= nil then if data.prev_item.components.weapon then local damage = data.prev_item.components.weapon.damage --do whatever you want to do with the information of the damage of the ammo --for example damagechange: local old_damage = inst.components.weapon.damage inst.components.weapon:SetDamage(old_damage - damage) end end end --fn of blunderbluss inst:ListenForEvent("itemlose", OnAmmoUnloaded) inst:ListenForEvent("itemget", OnAmmoLoaded) 2 Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1531675 Share on other sites More sharing options...
MrDoge124 Posted January 11, 2022 Author Share Posted January 11, 2022 I've tried to implement the code you've suggested but I haven't had any luck with it. It might be my fault, but it would help if I showed you what the code for the gun looks like. I've attached the code to this post. gun.lua Thanks for all of the help so far! Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1531897 Share on other sites More sharing options...
Monti18 Posted January 12, 2022 Share Posted January 12, 2022 If I don't know where the mod is going wrong, I just add a ton of print statements to see where it stops, this way you can see where the code breaks. As for your case here, I think it has to do that you add an onattack fn, but your weapon uses a projectile. If you compare your code to the one of the slingshot, you will see that the code that you have in the onattack fn is called in the SetOnProjectileLaunched fn. As your weapon launches a projectile, the onattack fn is never called, instead it tries the SetOnProjectileLaunched, but as that one is empty, it just does nothing. I would try to use the slingshot prefab to get the projectile launching done with the SetOnProjectileLaunched fn. You're welcome! Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1531999 Share on other sites More sharing options...
MrDoge124 Posted January 12, 2022 Author Share Posted January 12, 2022 I'm having some trouble with the data parts. I think the data if parts aren't working as I cannot seem to print anywhere in the function. I'm not sure why it isn't working, it might be where I merged the code into my exsisting OnAmmoLoaded function, as I don't think you can have two OnAmmoLoaded functions at the same time. Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1532209 Share on other sites More sharing options...
Monti18 Posted January 13, 2022 Share Posted January 13, 2022 It's not clear to me from which piece of code you're talking, but if you have 2 OnAmmoLoaded functions declared, the second one will overwrite the first one. You could also try to start from scratch with slingshot.lua and add all the things you added one after the other so that you can see where problems happen. Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1532367 Share on other sites More sharing options...
MrDoge124 Posted January 13, 2022 Author Share Posted January 13, 2022 (edited) Ok so I got the slinghshot.lua and added a few things. I managed to get it to function like the slingshot but have the visuals of the blunderbuss! It takes the ammo and sets the damage appropriately. Now I'm going to see if I can get custom ammo working. Should just be able to make a copy of slingshotammo.lua and go from there. Thanks for your help! Edited January 18, 2022 by MrDoge124 1 Link to comment https://forums.kleientertainment.com/forums/topic/136520-adding-the-slingshot-ammo-system-to-a-blunderbuss/#findComment-1532490 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now