IntensuwweSoois Posted March 24, 2015 Share Posted March 24, 2015 Is there any way I can do this, character specific to my custom char. I have no idea where to start, so any help would be great!Thanks Link to comment https://forums.kleientertainment.com/forums/topic/52324-using-fertilizer-during-winter/ Share on other sites More sharing options...
DarkXero Posted March 24, 2015 Share Posted March 24, 2015 (edited) EDIT: I modded my RoG branch and broke it.You shouldn't be able to fertilize in winter in RoG. Edited March 28, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/52324-using-fertilizer-during-winter/#findComment-624650 Share on other sites More sharing options...
IntensuwweSoois Posted March 28, 2015 Author Share Posted March 28, 2015 I don't follow.In the RoG beta branch, anybody can fertilize farms in winter.I am trying to make my character able to grow plants from farms, in the thick of winter (snowing time)Normally characters cant, as the farms become inactive, what I want is for this char to be able to use them. Link to comment https://forums.kleientertainment.com/forums/topic/52324-using-fertilizer-during-winter/#findComment-625543 Share on other sites More sharing options...
DarkXero Posted March 28, 2015 Share Posted March 28, 2015 (edited) I looked back at my RoG branch and noticed some things that caused bugs.You are correct. Now regarding your request. We can take the very long road or the gigantic road. The gigantic road:local old1 = GLOBAL.ACTIONS.FERTILIZE.fnGLOBAL.ACTIONS.FERTILIZE.fn = function(act) if act.target.components.crop and not act.target.components.crop:IsReadyForHarvest() and act.invobject and act.invobject.components.fertilizer and act.doer.prefab == "wilson" then local obj = act.doer.components.inventory:RemoveItem(act.invobject) obj.bypasswinter = true if act.target.components.crop:Fertilize(obj) then return true else obj.bypasswinter = nil act.doer.components.inventory:GiveItem(obj) return false end else return old1(act) endendAddComponentPostInit("crop", function(self) local old2 = self.Fertilize function self:Fertilize(fertilizer) TheSim:FindEntities(pt.x, pt.y, pt.z, range, must_tags, cant_tags, must_oneoftags) if fertilizer.bypasswinter then self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate self.inst.AnimState:SetPercent("grow", self.growthpercent) if self.growthpercent >=1 then self.inst.AnimState:PlayAnimation("grow_pst") self:Mature() self.task:Cancel() self.task = nil end fertilizer:Remove() return true else return old2(self, fertilizer) end endend)This does exactly as requested. The long road:AddComponentPostInit("crop", function(self) local old = self.Fertilize function self:Fertilize(fertilizer) local pt = self.inst:GetPosition() local ents = GLOBAL.TheSim:FindEntities(pt.x, pt.y, pt.z, 5, {"player", "greenthumb"}, {"playerghost"}) if #ents > 0 then self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate self.inst.AnimState:SetPercent("grow", self.growthpercent) if self.growthpercent >=1 then self.inst.AnimState:PlayAnimation("grow_pst") self:Mature() self.task:Cancel() self.task = nil end fertilizer:Remove() return true else return old(self, fertilizer) end endend)-- inst:AddTag("greenthumb") in master_postinit of characterCrops will grow when someone with the greenthumb tag stands very close, so it doesn't matter who really fertilizes, as long as the guy with the perk is there. Edited March 28, 2015 by DarkXero Link to comment https://forums.kleientertainment.com/forums/topic/52324-using-fertilizer-during-winter/#findComment-625590 Share on other sites More sharing options...
IntensuwweSoois Posted March 28, 2015 Author Share Posted March 28, 2015 I looked back at my RoG branch and noticed some things that caused bugs.You are correct. Now regarding your request. We can take the very long road or the gigantic road. The gigantic road:local old1 = GLOBAL.ACTIONS.FERTILIZE.fnGLOBAL.ACTIONS.FERTILIZE.fn = function(act) if act.target.components.crop and not act.target.components.crop:IsReadyForHarvest() and act.invobject and act.invobject.components.fertilizer and act.doer.prefab == "wilson" then local obj = act.doer.components.inventory:RemoveItem(act.invobject) obj.bypasswinter = true if act.target.components.crop:Fertilize(obj) then return true else obj.bypasswinter = nil act.doer.components.inventory:GiveItem(obj) return false end else return old1(act) endendAddComponentPostInit("crop", function(self) local old2 = self.Fertilize function self:Fertilize(fertilizer) TheSim:FindEntities(pt.x, pt.y, pt.z, range, must_tags, cant_tags, must_oneoftags) if fertilizer.bypasswinter then self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate self.inst.AnimState:SetPercent("grow", self.growthpercent) if self.growthpercent >=1 then self.inst.AnimState:PlayAnimation("grow_pst") self:Mature() self.task:Cancel() self.task = nil end fertilizer:Remove() return true else return old2(self, fertilizer) end endend)This does exactly as requested. The long road:AddComponentPostInit("crop", function(self) local old = self.Fertilize function self:Fertilize(fertilizer) local pt = self.inst:GetPosition() local ents = GLOBAL.TheSim:FindEntities(pt.x, pt.y, pt.z, 5, {"player", "greenthumb"}, {"playerghost"}) if #ents > 0 then self.growthpercent = self.growthpercent + fertilizer.components.fertilizer.fertilizervalue * self.rate self.inst.AnimState:SetPercent("grow", self.growthpercent) if self.growthpercent >=1 then self.inst.AnimState:PlayAnimation("grow_pst") self:Mature() self.task:Cancel() self.task = nil end fertilizer:Remove() return true else return old(self, fertilizer) end endend)-- inst:AddTag("greenthumb") in master_postinit of characterCrops will grow when someone with the greenthumb tag stands very close, so it doesn't matter who really fertilizes, as long as the guy with the perk is there. Thanks a ton! Still familiarizing myself with the games code, so the help is greatly appreciated.Thnks again Link to comment https://forums.kleientertainment.com/forums/topic/52324-using-fertilizer-during-winter/#findComment-625614 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