Feaurie Posted May 7, 2015 Share Posted May 7, 2015 Hi, I'm trying to make a mod for a character who can generate her own heat and use her hands as tools... But neither seems to be working for me. If I'm not mistaken, this is all that is necessary for the character to generate a heat aura right?inst:AddComponent("heater")inst.components.heater.heat = 30As for using her hand as tools, I tried addinginst:AddComponent("tool")inst.components.tool:SetAction(ACTIONS.CHOP)But that didn't work, so I used the code from woodie:inst:AddComponent("worker")inst.components.worker:SetAction(ACTIONS.DIG, 1)inst.components.worker:SetAction(ACTIONS.CHOP, 4)inst.components.worker:SetAction(ACTIONS.MINE, 1)inst.components.worker:SetAction(ACTIONS.HAMMER, 1)But that doesn't work either... And now I'm a bit lost. Any help would be appreciated, thanks! Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/ Share on other sites More sharing options...
Seiai Posted May 7, 2015 Share Posted May 7, 2015 (edited) @Feaurie,as for the heater: yes, this works to generate a heataura(u can test this by placing a thermal stone next to u), however, that aura doesnt apply to yourself.workarounds for that would be to manually increase your temperature with a DoPeriodicTask, or to have something else generate the aura, either an item in your inventory, or an invisible "follower".as for the tools, this is a bit complicated, cause u have to overwrite what happens if u rightclick something while having no items equipped.a good workaround would be to use hotkeys: GLOBAL.TheInput:AddKeyDownHandler(GLOBAL.KEY_R, function()--hotkey "R"local player=GLOBAL.ThePlayerif player and player.prefab=="yourcharactersprefabname" thenlocal target = GLOBAL.TheInput:GetWorldEntityUnderMouse()-- u can use this to get the target under your mousecursorif target then -- ofc u have to check if there is an target--cause your character to do the mine/chop-Action on the target hereelse player.components.talker:Say("Unacceptable command!", 2.5,true)--if u try to use it without a target, this would make your character respondendend end)i however dont know yet, how to make your character do an action.Using a hotkey would also probably be a good idea for enabling/disabling your heatingability, since u dont want to overheat. Edited May 7, 2015 by Seiai Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635299 Share on other sites More sharing options...
DarkXero Posted May 8, 2015 Share Posted May 8, 2015 I can think of three ways to make custom actions. -- We make our actions with the works they produce local myactions = {} myactions[ACTIONS.CHOP] = 4 myactions[ACTIONS.DIG] = 1 myactions[ACTIONS.HAMMER] = 1 myactions[ACTIONS.MINE] = 1 -- We create the component to use the actions inst:AddComponent("worker") -- We assign the actions to our component for k, v in pairs(myactions) do inst.components.worker:SetAction(k, v) end inst:DoTaskInTime(0, function() -- We override the right click uses inst.components.playeractionpicker.rightclickoverride = function(inst, target, position) -- We make a table of actions local actions = {} -- If a target exists, it can be worked on, and we can use one of our actions on it if target and target.components.workable and target.components.workable.workable and myactions[target.components.workable.action] then -- We check that nothing is in our hands if inst.components.inventory and not inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HANDS) then -- We clear the AnimState so we don't see previous shovels or axes inst.AnimState:ClearOverrideSymbol("swap_object") -- We insert the action we want (the one the workable requires) table.insert(actions, target.components.workable.action) end end -- We use this function to sort actions and return Buffered Actions return inst.components.playeractionpicker:SortActionList(actions, target) end end) Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635441 Share on other sites More sharing options...
Feaurie Posted May 8, 2015 Author Share Posted May 8, 2015 Thanks for replying and sorry for the slow reply in turn, couldn't test the code at work @Seiai unfortunately, the aura is not working. I plopped a thermal stone down as you said, and it didn't heat up, even with the temperature cranked waaaay up (100). @DarkXero The code works (almost) perfectly! Thanks! The only small issue I have is that I have to right click repeatedly to chop continuously, which really is barely a problem. I have one question though, is it possible for me to change her animation to a punch instead of the default 'swinging' animations? They look silly (the shovel especially) without the tools . Thanks again! Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635513 Share on other sites More sharing options...
Feaurie Posted May 8, 2015 Author Share Posted May 8, 2015 Evidently I was mistaken about the heater not working... It is. Its just that its only heating up stuff in my inventory. :/ Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635523 Share on other sites More sharing options...
Feaurie Posted May 8, 2015 Author Share Posted May 8, 2015 So I tried making this tiny invisible object that would follow my character around, generating heat:inst.fire = SpawnPrefab("konigsheataura")local follower = inst.fire.entity:AddFollower()follower:FollowSymbol(inst.GUID, "swap_object", 0, -110, 1)Along with the object itself:local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddLight() inst.entity:AddNetwork() inst:AddTag("FX") inst.Light:SetIntensity(.99) inst.Light:SetColour(240 / 255, 165 / 255, 10 / 255) inst.Light:SetFalloff(1) inst.Light:SetRadius(4) inst.Light:Enable(true) inst:AddComponent("propagator") inst.components.propagator.damages = false inst.components.propagator.heatoutput = 0.5 inst.components.propagator.currentheat = 0 inst.components.propagator.propagaterange = 3 inst.components.propagator.damagerange = 0 inst.components.propagator:StartSpreading() inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst.persists = false return instendreturn Prefab("common/fx/konigsheataura", fn, nil, prefabs)But somehow it still isn't working. I added the light so that I could tell it was following me (it is) but it isn't radiating any heat. Can I get some help? Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635605 Share on other sites More sharing options...
DarkXero Posted May 8, 2015 Share Posted May 8, 2015 Alright, I redid the work thing. Put this in modmainlocal multiact = AddAction("MULTI", "Work", function(act) if act.target.components.workable then act.target.components.workable:WorkedBy(act.doer, 1) end return trueend)AddStategraphActionHandler("wilson", GLOBAL.ActionHandler(multiact, "multi"))AddStategraphState("wilson", GLOBAL.State { name = "multi", tags = {"notalking", "autopredict"}, onenter = function(inst) inst.sg.statemem.action = inst:GetBufferedAction() local target = inst.sg.statemem.action and inst.sg.statemem.action.target or nil inst.components.locomotor:Stop() inst.AnimState:PlayAnimation("throw") inst.sg:SetTimeout(cooldown) if target and target:IsValid() then inst:FacePoint(target.Transform:GetWorldPosition()) end end, timeline = { GLOBAL.TimeEvent(7 * GLOBAL.FRAMES, function(inst) inst:PerformBufferedAction() end), GLOBAL.TimeEvent(16 * GLOBAL.FRAMES, function(inst) if inst.components.playercontroller and inst.components.playercontroller:IsAnyOfControlsPressed(GLOBAL.CONTROL_SECONDARY, GLOBAL.CONTROL_ACTION, GLOBAL.CONTROL_CONTROLLER_ALTACTION) and inst.sg.statemem.action and inst.sg.statemem.action.target and inst.sg.statemem.action.target.components.workable and inst.sg.statemem.action.target.components.workable.workleft > 0 then inst:PushBufferedAction(inst.sg.statemem.action) end end), }, events = { GLOBAL.EventHandler("animover", function(inst) if inst.AnimState:AnimDone() then inst.sg:GoToState("idle", true) end end), },})and this in your character's prefab inst:DoTaskInTime(0, function() inst.components.playeractionpicker.rightclickoverride = function(inst, target, position) local actions = {} if target and target.components.workable and target.components.workable.workable then local inv = inst.components.inventory if inv and not inv:GetEquippedItem(EQUIPSLOTS.HANDS) then table.insert(actions, ACTIONS.MULTI) end end return inst.components.playeractionpicker:SortActionList(actions, target) end end) Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635611 Share on other sites More sharing options...
DarkXero Posted May 8, 2015 Share Posted May 8, 2015 Just use heater, like you were doinglocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddLight() inst.entity:AddNetwork() inst:AddTag("FX") inst.Light:SetIntensity(.99) inst.Light:SetColour(240 / 255, 165 / 255, 10 / 255) inst.Light:SetFalloff(1) inst.Light:SetRadius(4) inst.Light:Enable(true) inst.entity:SetPristine() if not TheWorld.ismastersim then return inst end inst:AddComponent("heater") inst.components.heater.heat = 70 inst.persists = false return instend return Prefab("common/fx/konigsheataura", fn, nil, prefabs) Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635630 Share on other sites More sharing options...
ForenSmurf Posted May 8, 2015 Share Posted May 8, 2015 Hi, i'm just here to congratulate you on this awesome thread title Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635711 Share on other sites More sharing options...
Feaurie Posted May 9, 2015 Author Share Posted May 9, 2015 @DarkXero Thanks so much! Everything is working! Just one more small question: Is there a way to set different values for different actions? I suspect its something to do with this code:act.target.components.workable:WorkedBy(act.doer, 2)Because right now she chops down a tree in like 8-ish hits, but mines a rock in half the time. Thanks so much for your help, you're amazing Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635892 Share on other sites More sharing options...
DarkXero Posted May 9, 2015 Share Posted May 9, 2015 local ACTIONS = GLOBAL.ACTIONS local myactions = {} myactions[ACTIONS.CHOP] = 2 myactions[ACTIONS.DIG] = 1 myactions[ACTIONS.HAMMER] = 1 myactions[ACTIONS.MINE] = 1 local multiact = AddAction("MULTI", "Work", function(act) if act.target.components.workable then local action = act.target.components.workable.action local numworks = myactions[action] or 1 act.target.components.workable:WorkedBy(act.doer, numworks) end return true end) Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635935 Share on other sites More sharing options...
Feaurie Posted May 9, 2015 Author Share Posted May 9, 2015 Thanks! Its all working now! :DDD Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-635953 Share on other sites More sharing options...
halfrose Posted September 27, 2015 Share Posted September 27, 2015 local ACTIONS = GLOBAL.ACTIONSlocal myactions = {}myactions[ACTIONS.CHOP] = 2myactions[ACTIONS.DIG] = 1myactions[ACTIONS.HAMMER] = 1myactions[ACTIONS.MINE] = 1local multiact = AddAction("MULTI", "Work", function(act) if act.target.components.workable then local action = act.target.components.workable.action local numworks = myactions[action] or 1 act.target.components.workable:WorkedBy(act.doer, numworks) end return trueend) Any way to make the character chop, mine, attack but not hammer and dig? Link to comment https://forums.kleientertainment.com/forums/topic/53614-some-modding-stuff/#findComment-676328 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