Jump to content

Recommended Posts

There's a character I'm working on, that when I have the character prototype something on the prestihatitator, I want that character to have a 100% chance to spawn a rabbit, as opposed to the original 10%.

 

I only want this to trigger for the desired character, not for any other characters.  But I can't seem to figure out if it's possible to detect the user of the research machine.

Unless you make a FindEntities to pick up players near the structure, nothing gets passed.

 

You can hook pretty much everything in your character's builder component to make it so if your character prototypes something, and it's using the prestihatitator, it spawns a rabbit in the self.current_prototyper position.

 

To make activate pass the person as a parameter, it ends up like this

AddComponentPostInit("prototyper", function(self)	function self:Activate(activator)		if self.onactivate then			self.onactivate(self.inst, activator)		end	endend)AddComponentPostInit("builder", function(self)	function self:ActivateCurrentResearchMachine()		if self.current_prototyper and self.current_prototyper.components.prototyper then			self.current_prototyper.components.prototyper:Activate(self.inst)		end	endend)local function onactivate(inst, activator)	if not inst:HasTag("burnt") then 		inst.AnimState:PlayAnimation("use")		inst.AnimState:PushAnimation("idle")		inst.AnimState:PushAnimation("proximity_loop", true)		inst.SoundEmitter:PlaySound("dontstarve/common/researchmachine_lvl4_run", "sound")		inst:DoTaskInTime(1.5, function()			if not inst:HasTag("burnt") then				if (math.random() <= 0.1) or (activator.prefab == "wilson") then					local rabbit = GLOBAL.SpawnPrefab("rabbit")					rabbit.Transform:SetPosition(inst.Transform:GetWorldPosition())				end				inst.SoundEmitter:PlaySound("dontstarve/common/researchmachine_lvl4_ding")			end		end)	endendAddPrefabPostInit("researchlab4", function(inst)	inst.components.prototyper.onactivate = onactivateend)

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