Jump to content

Custom Perks Not working


Recommended Posts

I am trying to add poison damage and quick picking to my character and tried putting the code for those into the character lua,but it doesn't seem to be working. I first tried to rip the code from other characters that had the exact kind of thing I wanted, even placing it into a similar location but that didn't work, then I tried to follow the tutorials in the forum below:

However, this did not seem to get it working. The tutorial also mentioned about putting this specific coding either above or below the "local fn = function(inst)".I used the sample character to build mine, and did not see this string, so I put it in and put an "end" and the end of the two special perks, but it didn't change the character's behavior in game. I have attached the prefab lua here, as this is the only file I have touched. I am not certain if I need to change coding in another lua file or not, or if I should stick specifically to this single lua file.

epic_sans.lua

Link to comment
Share on other sites

So I've managed to get quick picking to work. I had to post it under this line of code, in my "charactername" prefab lua. The above tutorial does not mention about this in the quick picking part. Took me 4 hours to figure that out.

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)

 

This made the quick picking custom stat work. I also played with the code and made my character mine quickly with the code below. Note: the quick mining is not instant like the quick picking but it is still faster than normal, and there is no mining audio. I'm not sure how to fix this.

-- Quick minin'!
    local handle = inst.sg.sg.actionhandlers[ACTIONS.MINE]
handle.deststate = function(inst) return "doshortaction" end
    local handle = inst.sg.sg.actionhandlers[ACTIONS.MINE]
handle.deststate = function(inst) return "doshortaction" end
Edited by Dragonfire1000
Link to comment
Share on other sites

DS and DST are very different. It's not the best idea to reuse a code from the singleplayer. I think your code breaks the player stategraph and ALL characters will pick/mine quickly if your character is/was in a game session.

1) You should use AddStategraphPostInit in modmain instead:
 

AddStategraphPostInit("wilson", function(self)
    local _oldMineHandler = self.actionhandlers[GLOBAL.ACTIONS.MINE].deststate 
    self.actionhandlers[GLOBAL.ACTIONS.MINE].deststate = function(inst)
        if inst:HasTag("unique_tag_for_you_character") then
            return "doshortaction"
        end

        return _oldMineHandler(inst)
    end
end)

2) doshortaction is actually a state and this state doesn't have a mining sound. You need to create your own or play a sound in the deststate function (second is a really bad option);

3) You also need to update wilson_client stategraph;

4) poison "green screen" requires using of net variables.

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