Jump to content

Recommended Posts

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.

@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 ;) 

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!

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 :p 

I thought it was silly when he would just emit light after eating the battery :p. 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.

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
×
  • Create New...