Zackreaver Posted May 10, 2015 Share Posted May 10, 2015 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. Link to comment https://forums.kleientertainment.com/forums/topic/53796-detecting-user-of-prestihatitator/ Share on other sites More sharing options...
DarkXero Posted May 10, 2015 Share Posted May 10, 2015 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 thisAddComponentPostInit("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) Link to comment https://forums.kleientertainment.com/forums/topic/53796-detecting-user-of-prestihatitator/#findComment-636333 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