zyxerdima Posted December 26, 2017 Share Posted December 26, 2017 Hello, Recently I've started work on a mod with a key conception of a long-term build action. Let me explain what long-term action means – while for most characters building new object (Alchemy Engine for example) takes X sec., I want it to be N*X sec. Instead of 1 sec. it would be 30 sec. for example. I know that new character, Winona, makes thinks faster, so I’ve looked at winona.lua for making opposite – found Tag named “fastbuilder”, and I found “dolongaction” Tag, but that's not what I need. (Maybe I need Tag, but I don’t really know where they described it and how it works). Also I’ve digged around Placer and Prefab but did not find anything useful. In addition to long-term action I’m as well unsuccessfuly looking for how to change making animation itself – not standard “twirl with hands” but digging with shovel. (Using my mod player one will be able to create an object – let’s say a pit in the ground, and creating of it should be long and painstaking – maybe even few Hounds would be spawned and a friend would have to defend our digger.) So I’m asking for help here. All messages will be appreciated. Link to comment Share on other sites More sharing options...
zyxerdima Posted December 27, 2017 Author Share Posted December 27, 2017 OK, so during my exploration around SGwilson.lua I found few States - "domediumaction"/'dolongaction" and ActionHandler(ACTIONS.BUILD, ...) therefore figured out how to make building process lasts longer (for example 3 sec.): local longdigging_state = State { name = "dolongdigging", onenter = function(inst) inst.sg:GoToState("dolongaction", 3) end, } local build_handler = ActionHandler(ACTIONS.BUILD, function(inst, action) if (action ~= nil and action.recipe ~= nil and action.recipe == "my_huge_pit") then return "dolongdigging" else return inst:HasTag("fastbuilder") and "domediumaction" or "dolongaction" end end) AddStategraphActionHandler("wilson", build_handler) AddStategraphState("wilson", longdigging_state) And instead of make animation to do digging animation during building I just copied "dolongaction" State and simply changed animations from inst.AnimState:PlayAnimation("build_pre") inst.AnimState:PushAnimation("build_loop", true) to inst.AnimState:PlayAnimation("shovel_pre") inst.AnimState:PushAnimation("shovel_loop", true) And all works almost fine, just few glitches found: 1. If calling inst.sg:GoToState("dolongaction", 3) (with parameter timeout = 3 or more) player after end of building will be placed at the center of just created object. At timeout = 2 it happens sometime. At timout = 1 theres no such behawior. Have no idea why, really. If someone know why - let me know. 2. Digging animation continues without shovel in hands - I guess it should be fixed using inst.components.inventory:Equip but inst.components.inventory:Equip("goldenshovel") doesn't work for me now. In general - I'm not sure about ActionHandler(ACTIONS.BUILD) solution - since it probably is overriding of existing handler, but I don't know how to (override) cancel building action trigger in my Prefab. If I could cancel trigger - I would be able to create my own Handler. But keep exploring and making next steps, cheers. Link to comment 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