CensedPie Posted October 25, 2017 Share Posted October 25, 2017 I currently have a mod that adds in a food item that only wx-78 can eat. I am trying to make it so when he eats it he gets the lightning strike perks (emit light, bonus speed, etc). I can't find how the lightning strike is applied to wx-78. Any attempt to call wx-78's onlightingstrike function gives an error "attempting to call nil value". I can't figure out how the lightning strike triggers wx-78 to overcharge so I can apply it to the prefab I have. Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/ Share on other sites More sharing options...
w00tyd00d Posted October 25, 2017 Share Posted October 25, 2017 @CensedPie This code will at least get the system overload to trigger, just won't have any fancy animation to it. function WxPostInit(inst) local old_oneat = inst.components.eater and inst.components.eater.oneatfn local function new_oneat(inst, food) old_oneat(inst, food) if food and food.prefab == "<your prefab>" then inst.components.playerlightningtarget.onstrikefn(inst) end end if GLOBAL.TheWorld.ismastersim then inst.components.eater:SetOnEatFn(new_oneat) end end AddPrefabPostInit("wx78", WxPostInit) It's at least a step in the right direction Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/#findComment-966958 Share on other sites More sharing options...
CensedPie Posted October 27, 2017 Author Share Posted October 27, 2017 Thank you so much, I managed to make the lightning effect hit him as well by adding local pos = GLOBAL.Vector3(inst.Transform:GetWorldPosition()) GLOBAL.SpawnPrefab("lightning").Transform:SetPosition(pos:Get()) after the onstrikefn call. Works so far! Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/#findComment-967578 Share on other sites More sharing options...
w00tyd00d Posted October 27, 2017 Share Posted October 27, 2017 11 hours ago, CensedPie said: Thank you so much, I managed to make the lightning effect hit him as well by adding local pos = GLOBAL.Vector3(inst.Transform:GetWorldPosition()) GLOBAL.SpawnPrefab("lightning").Transform:SetPosition(pos:Get()) after the onstrikefn call. Works so far! When you call the lightning strike, does it double up the effects of the onstrikefn function? If so, you'll probably want to omit the onstrikefn call if you're going to have him get struck by lightning anyways (as getting hit by lightning calls the onstrikefn automatically), I thought you were trying to look for a way to do it without any lightning involved Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/#findComment-967756 Share on other sites More sharing options...
CensedPie Posted October 28, 2017 Author Share Posted October 28, 2017 I thought it was silly when he would just emit light after eating the battery . I don't think it should give him the double effect since all the function should do is spawn the prefab of lightning. I'll check tomorrow to see if spawning the lightning doubles the effect. Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/#findComment-968070 Share on other sites More sharing options...
w00tyd00d Posted October 29, 2017 Share Posted October 29, 2017 @CensedPie Ah that's true, as long as WX doesn't change to the state of actually getting hit by lightning, I don't think the onstrikefn will be called. Link to comment https://forums.kleientertainment.com/forums/topic/83364-trigger-overcharge-on-wx-78-upon-eating-something/#findComment-968362 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