Jump to content

Trying to make an axe murderer


Recommended Posts

I'm currently working on a character designed to specialize in wielding axes as both a tool and a weapon and so far she worked until I realized there is something in my code making her work a little too well.  Basically, if I equip anything in her head or body slot while she's holding an axe, she gains extra buffs on top of what she's already got, but the real issue is one part of her is chopping trees in less hits which crashes because it is looking for a tool tag that doesn't exist on armors or hats.  This is my first mod ever and I don't have much coding experience in general (hoping to change that with modding) so I'm sure it's likely something stupidly obvious but I've spent 3 days scouring the code and trying various things to brute force an answer, but it either doesn't fix it or just crashes.

This is the section of code causing this issue (as far as I can tell)

--When equipping axe.
local function onequip(inst, data)
    local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
    if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
        data.item.components.equippable.dapperness = -TUNING.DAPPERNESS_MED
    end
    local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
    if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
        data.item.components.equippable.walkspeedmult = 2
    end
--Test for EquipBody and EquipHead negators
--    local equipped_body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY)
--    if equipped_body ~= nil then
--        data.item.components.equippable.walkspeedmult = 1
--    end
--    local equipped_head = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD)
--    if equipped_head ~= nil then
--        data.item.components.equippable.walkspeedmult = 1
--    end
--End Test
    local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
    if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
        inst.components.combat.damagemultiplier = 5
    end
--    local equipped_hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS)
--    if equipped_hand ~= nil and equipped_hand:HasTag("CHOP_tool") then
--        data.item.components.tool:SetAction(ACTIONS.CHOP, 2)
--    end
end

https://pastebin.com/zJZd2L2n This is the full code (some has changed but not to a degree that warrants reuploading it again)

I did have a test solution in there that sort of worked, but again the main issue goes back to the reduced number of chops since the issue stems from the code trying to apply itself to head and body slots. Unfortunately, a workaround like that won't work on that issue, so I'm trying to find the root of the problem itself which should fix all of it.  I appreciate any help I can get on this.

Link to comment
Share on other sites

After trying a few other ideas, I went back to the negators I created and put an indefinite pin in her tree chopping perk, but that has only led to either the negators disallowing her buffs to trigger if the axe is equipped last and coding it in reverse order causes the body and head to apply buffs again.  In testing this, I did learn that if your character runs fast enough, they can fall into the water very easily. So I'm once again back to the original issue that persists, I need to find a way to make the code ONLY apply to the hands slot and completely ignore the body and head slot.  If anyone knows a better way to code this so that happens, I would be eternally grateful.

Link to comment
Share on other sites

So after a few weeks of trying to figure out a solution, I wasn't able to find anything and got discouraged and I temporarily gave up and recently came back to it to try again but I've only ended up hitting my head on the same walls a second time.  Thus I'm back here in the hopes that someone hears my plea this time.  I feel like the issue has to be something simple I'm missing or something I just don't know about, but I don't want to scrap the project as a lost cause, rather I'd like to learn what exactly it is that I'm clearly not getting in order to make Wizzie the best mod I can make her and to advance my skills for future characters.

Link to comment
Share on other sites

Sorry, life got out of hand on me. This is one of the more recent ones, but I haven't had time to try again more recently. I've got a LOT of error messages trying out various things so I'm not even sure which one goes with my current iterations issue. One issue I know never threw an error though was the ability to increase movement speed when equipping an axe, it seems to read all of my slots and not just my hand slot. So x2 speed when you equip an axe, x4 upon equipping a hat, x6 when equipping armor. And fun fact, if you run fast enough you can just shoot off and fall into the water.

WizzieErrorMessageLatest.jpg

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...