Jump to content

Grillby Information  

10 members have voted

  1. 1. Should Grillby set things near him on fire if near them for too long?

    • Yes
      2
    • Yes, but not man-made objects
      4
    • No, being able to light objects with his hands is enough
      3
    • No, he shouldn't be able to, nor should he be allowed to light objects with his hands
      1
  2. 2. Do you have any ideas you are completely against in this mod?

    • Fuel Bar
      1
    • Ice Flingomatic targeting system
      0
    • Automatically cooking food
      0
    • Giving off light if above a certain Fuel level
      0
    • Severe penalties when wet (despite drying faster)
      0
    • Extra sanity around fire, Papyrus, Sans, or other sources
      1
    • Alcoholic Drinks (meaning the alcohol system and Alcohol Poisoning)
      1
    • Normal Drinks (meaning the Juice Bar entirely)
      0
    • Sanity loss around all water, even unavoidable water
      1
    • Lack of ability to freeze or overheat
      2
    • Nothing (since the forums require the field if you answer Question #1)
      5
  3. 3. If I were to remove the Alcohol System, what would you like to see in place of it (as the drinks need a debuff for balancing)?

    • Sanity loss (getting drunk and seeing things)
      3
    • Health penalties (alcohol is unhealthy)
      3
    • Hunger penalties (not sure why this would be, plus this would be redundant, probably not included)
      0
    • No penalties (drink away)
      1
    • Other (leave a comment below!)
      0


Recommended Posts

Note to all: If you vote against a poll option, please leave a comment so I know why you don't like it and how it should change. Otherwise, I have nothing to go on. I want everyone to input to Grillby! :D

Okay, so I'm looking to make a character mod. I'm working with a couple of people to recreate Grillby from Undertale. He's already basically working and has his custom sounds, textures, and all of that good stuff.

Ya5Autm.png

Credit given to OddVibe for the picture of Grillby. Formatting into Don't Starve (text, window, etc) done by me.

There's a lot of things I plan to add to him (and he's almost complete; thanks guys!). However, as I'm not a coding genius, I'm curious as if you guys have a solution for a couple of ideas, the main one that needs to be made being the title of the post. I'll also list a bunch of other ideas I'm not sure where to start with in case anyone wants to help. If someone helps a lot I may very well add them as a contributor to the mod if they wish, so help is definitely appreciated.

Important Issue as of Now: Custom Research Lab

Alright, I'm looking into making a custom research lab, specifically a Juice Bar that allows Grillby to create custom drinks. I plan to do the bar texturing myself, as well as the item texturing, but I need a basis for creating research labs, and some information on how to include a structure. If anyone can offer a base structure to use to start with, it would help.

I also need crafting recipes to be able to load from the drink bar in a similar fashion to how the recipes in mods call for TECH.NONE and RECIPETABS.FARM (examples). I would want those to be TECH.GRILLBYBAR and I'll keep it in the Food tab to avoid including a whole new tab since that often creates lag.

Can anyone offer some basic help with this? I'm almost done with him!

The list of remaining features are here:

Spoiler

 

 The features left to code are gaining sanity near Sans, lighting objects on fire with his fists, including enemies, a low chance of lighting picked things on fire, custom voice lines, saying stuff when wet even slightly, inability to overheat, easily freezing, the Juice Bar and his drinks. He also needs to give off light and heat if above like 70% hunger and health, alcoholic sanity loss, gain sanity around fires, include the slight glow and bloom from Shovel Knight if possible, and I need to import the new textures when Rimpula is done. Otherwise, he's all set, since it seems like a lot, but the hardest part is really the Bar and Drinks.

 

Important Bugs: None Right Now!

Other Issues (Not Main Focus)

  • THE FUEL BAR! Scrapped due to coding issues.
  • How to gain sanity around other modded characters (specifically, Sans and Papyrus). I believe I can do this without help now.
  • How to light objects on fire with nothing equipped. Need help with this!
  • How to create an Alcohol system if you drink too many of his finest drinks and die from Alcohol Poisoning (being reconsidered). Scrapped.
    • Possibly make the drinks simply cause Sanity loss instead?
  • How to make it so that he can't freeze or overheat, but instead Fuel drain decreases and increases in Summer and Winter (respectively). Scrapped along with Fuel System. Instead he'll probably be unable to overheat but easily freeze.
  • Deciding whether or not he should light things near him on fire when at high fuel amounts or when near objects for too long (not including man-made objects so he doesn't burn everything to the ground). More in need of opinions, but code help is nice here too (being reconsidered). Scrapped. Going to be replaced with the ability to manually light objects and potentially the ability to light things he picks at a low chance.
  • Need more votes!
  • Full list can be found above the Important Bugs tab in the Spoiler.

 

As with any of my posts, any and all feedback, even critical, is appreciated! Just don't be surprised if I don't agree with you since I don't agree about things very often. Thanks for reading, thanks for submitting comments if you do, whatever you do, thank you and have a great day.

Edited by NyctoDarkMatter
New issue at main. Juice Bar! Almost done!
Link to comment
Share on other sites

5 hours ago, NyctoDarkMatter said:

Cooking Food in the Inventory

local function CookItem(item)
	local owner = item.components.inventoryitem.owner
	if owner and owner.prefab == "grillby" then
		local product = item.components.cookable:Cook(owner, owner)
		item:Remove()
		owner.components.inventory:GiveItem(product)
	end
end

local function OnItemGet(inst, data)
	local item = data.item
	if item and item:HasTag("cookable") and data.slot and not item._grillbytask then
		item._grillbytask = item:DoTaskInTime(math.random(3, 5), CookItem)
	end
end

inside the prefab file and

inst:ListenForEvent("itemget", OnItemGet)

inside the master_postinit.

Link to comment
Share on other sites

Hey DarkXero! It's you again. I dunno if you remember me, you helped with the whole Zoidberg sanity thing. As soon as I'm done with this pixel art I'm making I'll test that out and see if it works, cuz that would be really cool if you just came up and fixed my issue.

It definitely looks good from my standpoint. Calling function CookItem after a time is a good way to do it and I didn't think about the math.random. My issues were that I didn't know about the cookable tag and function OnItemGet. Plus I wouldn't have realized to ListenForEvent. I always forget that. Looks solid. Thanks man!

Link to comment
Share on other sites

2 hours ago, DarkXero said:

inst:ListenForEvent("itemget", OnItemGet)

inside the master_postinit.

I tried what you said and I'm getting this crashlog. Any idea why? I put the inst:ListenForEvent("itemget", OnItemGet) in the master_postinit. It gets to the character select and if I try to click anything it crashes there.

Making sure, the master_postinit is this right?

-- This initializes for the server only. Components are added here.
local master_postinit = function(inst)
	-- Playing custom sounds.
	inst.soundsname = "grillby"
	
	
	-- Stats	
	inst.components.health:SetMaxHealth(150)
	-- Somewhat higher maximum Health to offset his requirement of Hunger and Fuel.
	inst.components.hunger:SetMax(130)
	-- Lower maximum Hunger since he does in fact cook food automatically.
	inst.components.sanity:SetMax(250)
	-- Seems like a pretty sane guy.
	
	-- Damage multiplier (optional)
    inst.components.combat.damagemultiplier = 1
	
	-- Hunger rate (optional)
	inst.components.hunger.hungerrate = 0.9 * TUNING.WILSON_HUNGER_RATE

	inst:ListenForEvent("itemget", OnItemGet)
	--Listening for item pickup for potential cooking.

	inst.OnLoad = onload
    inst.OnNewSpawn = onload
end

Thanks for the help BTW.

log.txt

Link to comment
Share on other sites

Setting ablaze everything near him? That dude's bar is made of wood and he's fine! At most, I'd expect a small chance for harvested plants and the likes to catch fire (that can be prevented by not picking anything, and as such, feels fair).

Link to comment
Share on other sites

21 minutes ago, Mobbstar said:

Setting ablaze everything near him? That dude's bar is made of wood and he's fine! At most, I'd expect a small chance for harvested plants and the likes to catch fire (that can be prevented by not picking anything, and as such, feels fair).

I see what you're saying. Maybe I could do that, though I'm not sure how. Maybe something similar to the code that DarkXero just gave me that when he picks up anything flammable, it has a chance of catching on fire.

2 hours ago, DarkXero said:

@NyctoDarkMatter


[00:00:46]: [string "../mods/Grillby/scripts/prefabs/grillby.lua"]:86: variable 'OnItemGet' is not declared

The code I posted over the ListenForEvent goes inside the prefab file, not in the modmain.

It also goes OVER master_postinit, master_postinit is UNDER that code.

 

DarkXero! It works, but we have a small issue. If you pick up food quickly (Like, pick up 10 Meat in this example), when it cooks, it cooks into 1 Meat. Any way to fix that? I think making it instant might fix that but I want to try to keep the short delay cuz it's nice.

Link to comment
Share on other sites

You probably need a loop for that, which calls the stackable component to retrieve one item from the stack at a time.

I suggest you implement a listener to cancel the cooking if needed, I guess it'd look like this:

local function OnItemLose(inst, data)
	local item = data.item
	if item and item._grillbytask then
		item._grillbytask:Cancel()
		item._grillbytask = nil
	end
end
inst:ListenForEvent("itemlose", OnItemLose)
Link to comment
Share on other sites

18 minutes ago, Mobbstar said:

You probably need a loop for that, which calls the stackable component to retrieve one item from the stack at a time.

I suggest you implement a listener to cancel the cooking if needed, I guess it'd look like this:


local function OnItemLose(inst, data)
	local item = data.item
	if item and item._grillbytask then
		item._grillbytask:Cancel()
		item._grillbytask = nil
	end
end

inst:ListenForEvent("itemlose", OnItemLose)

This didn't change anything that I noticed, although it did fix the issue of cooking an item that I was holding in my cursor to take to the backpack.

How would I go about implementing a loop? I'm still learning code, so when I see this code, it makes sense, but I'm not really sure where to add my own, if that makes sense. I can read code and fix some errors usually, but I'm not that great at coding myself (which makes this project insanely daunting).

Link to comment
Share on other sites

1 hour ago, Mobbstar said:

Setting ablaze everything near him? That dude's bar is made of wood and he's fine! At most, I'd expect a small chance for harvested plants and the likes to catch fire (that can be prevented by not picking anything, and as such, feels fair).

@Mobbstar, do you know how I would code for something to happen randomly upon picking it up? I want to give any burnable item he picks up a 1% chance to burn, and I'm using DarkXero's code as a base, in this way:

--Attempting to write a script to rarely burn items accidentally.
local function OnItemGet(inst, data)
	local item = data.item
	if item and item:HasTag("burnable") and data.slot and not item._grillbytask and --(RANDOMCHANCEHERE)-- then
		--possibly drop item here?
		item._grillbytask = item:DoTaskInTime(math.random(0, 2), Ignite)
	end
end

Not sure if that would work or how to add random chance, calling upon you for help with that. Assuming I would also have to apply the bugfix that I'll hopefully receive from the great @DarkXero to make sure that an entire stack of items doesn't burn, cuz that would suck.

Link to comment
Share on other sites

To fix the stack issue, change the cook function to (I think):

local function CookItem(item)
    local owner = item.components.inventoryitem.owner
    if owner and owner.prefab == "grillby" then
        if item.components.stackable and item.components.stackable:GetSize() > 1 then
          for i = 1, item.components.stackable:GetSize() do --count from "1" to "stacksize"
            local single = item.components.stackable:Get(1) --get one and use that instead
            local product = single.components.cookable:Cook(owner, owner)
            single:Remove()
            owner.components.inventory:GiveItem(product)
          end
        else
          local product = item.components.cookable:Cook(owner, owner)
          item:Remove()
          owner.components.inventory:GiveItem(product)
        end
    end
end
Edited by Mobbstar
better formatting
Link to comment
Share on other sites

20 minutes ago, Mobbstar said:

To fix the stack issue, change the cook function to (I think):


local function CookItem(item)
    local owner = item.components.inventoryitem.owner
    if owner and owner.prefab == "grillby" then
        if item.components.stackable and item.components.stackable:GetSize() > 1 then
          for i = 1, item.components.stackable:GetSize() do --count from "1" to "stacksize"
            local single = item.components.stackable:Get(1) --get one and use that instead
            local product = single.components.cookable:Cook(owner, owner)
            single:Remove()
            owner.components.inventory:GiveItem(product)
          end
        else
          local product = item.components.cookable:Cook(owner, owner)
          item:Remove()
          owner.components.inventory:GiveItem(product)
        end
    end
end

New code gives an error in-game upon picking up 10 Meat, @Mobbstar:

[string "../mods/Grillby/scripts/prefaps/grillby.lua"]:63: attempt to call method 'GetSize' (a nil value)
LUA ERROR stack traceback:
../mods/Grillby/scripts/prefabs/grillby.lua:63 in (field) fn (Lua) <60-76>

Is GetSize the wrong function? That seems to be what the game is complaining about. Lines 60-76 are what you posted and 63 is:

if item.components.stackable and item.components.stackable:GetSize() > 1 then

I wouldn't know any more than you, so I don't know what to fix, haha. Sorry for all the difficulty!

Link to comment
Share on other sites

57 minutes ago, NyctoDarkMatter said:

This didn't change anything that I noticed, although it did fix the issue of cooking an item that I was holding in my cursor to take to the backpack.

I intended this, I consider inventory all the item slots + active item slot.

Try with

local function CookItem(item)
	local owner = item.components.inventoryitem.owner
	if owner and owner.prefab == "grillby" and owner.components.inventory:GetActiveItem() ~= item then
		local num = item.components.stackable and item.components.stackable:StackSize() or 1
		for i = 1, num, 1 do
			local product = item.components.cookable:Cook(owner, owner)
			owner.components.inventory:GiveItem(product)
		end
		item:Remove()
	end
	item._grillbytask = nil
end

local function OnItemGet(inst, data)
	local item = data.item
	if item and item:HasTag("cookable") and data.slot and not item._grillbytask then
		item._grillbytask = item:DoTaskInTime(math.random(3, 5), CookItem)
	end
end

It cooks everything and it doesn't cook stuff in your active item slot.

Link to comment
Share on other sites

1 hour ago, DarkXero said:

I intended this, I consider inventory all the item slots + active item slot.

Try with


<snip>

It cooks everything and it doesn't cook stuff in your active item slot.

That one works, haha. It's counting them properly now. I'll have to mess around with that basic code and create a similar one to have a chance of burning your items into ash when picking them up (if they're flammable).

Link to comment
Share on other sites

On 18/1/2016 at 9:12 PM, NyctoDarkMatter said:

Ice Flingomatics

---
--- Flingo snowball tossing to entities with grillby tag
---

local NOTAGS = { "FX", "NOCLICK", "DECOR", "INLIMBO", "burnt" }
local GBTAGS = { "grillby" }

local function OnDetectedItemTimeOut(inst, self, target)
    self.detectedItems[target] = nil
end

local function RegisterDetectedItem(inst, self, target)
    self.detectedItems[target] = inst:DoTaskInTime(2, OnDetectedItemTimeOut, self, target)
end

local function LookForGrillbys(inst, self, force)
	if not force and inst.sg ~= nil and inst.sg:HasStateTag("busy") then
		return
	end
	local x, y, z = inst.Transform:GetWorldPosition()
	local ents = GLOBAL.TheSim:FindEntities(x, y, z, self.range, GBTAGS, NOTAGS)
	local target = nil
	for i, v in ipairs(ents) do
		if not self.detectedItems[v] then
			target = v
		end
	end
	if target ~= nil then
		RegisterDetectedItem(inst, self, target)
		if self.onfindfire ~= nil then
			self.onfindfire(inst, target:GetPosition())
		end
	end
end

AddComponentPostInit("firedetector", function(self)
	local _Activate = self.Activate
	self.Activate = function(self, randomizedStartTime)
		_Activate(self, randomizedStartTime)
		local _DT = self.detectTask.fn
		self.detectTask.fn = function(inst, self, force)
			_DT(inst, self, force)
			LookForGrillbys(self.inst, self, force)
		end
	end
	local _DetectFire = self.DetectFire
	self.DetectFire = function(self)
		_DetectFire(self)
		if self.detectTask ~= nil then
			LookForGrillbys(self.inst, self, force)
		end
	end
end)


--
-- Snowball calls function on entities with grillby tag
--

local function SnowgrillEffect(inst)
	inst.components.moisture:DoDelta(20)
	inst.components.health:DoDelta(-5)
	inst.components.sanity:DoDelta(-5)
	inst.components.hunger:DoDelta(-5)
end

AddPrefabPostInit("snowball", function(inst)
	if inst.components.wateryprotection == nil then return end
	local self = inst.components.wateryprotection
	local _SpreadProtectionAtPoint = self.SpreadProtectionAtPoint
	self.SpreadProtectionAtPoint = function(self, x, y, z, dist, noextinguish)
		_SpreadProtectionAtPoint(self, x, y, z, dist, noextinguish)
		local ents = GLOBAL.TheSim:FindEntities(x, y, z, dist or 4, GBTAGS, NOTAGS)
		for i, v in ipairs(ents) do
			SnowgrillEffect(v)
		end
	end
end)

in modmain.lua.

Add the "grillby" tag for your character in the custom_postinit.

Link to comment
Share on other sites

35 minutes ago, DarkXero said:

<snip>

in modmain.lua.

Add the "grillby" tag for your character in the custom_postinit.

It worked! Definitely and wholly worked, and I was even able to modify the sanity penalties and such to my liking because you made it easy. I'll modify the main post soon with the biggest issue of them all; the Fuel Bar.

DarkXero, how can I give you some Rep for these? xD This is insanely helpful.

Edited by NyctoDarkMatter
DarkXero!
Link to comment
Share on other sites

I can make this a bit simpler. The MAIN thing I need is for someone to post the code for draining Wetness at a higher rate while wet. If I can do that, I can write a similar code to drain all of his other stats when wet, but I'm not sure how to make Wetness drain faster. I've tried looking at codes of heat sources and umbrellas and such, but I mainly find resistances, not draining.

Link to comment
Share on other sites

@Muche Probably, but I'm not sure quite how to apply that into code. You see, I know how to cause Sanity drain / gain (example being the Slinky from my Zoidberg mod) and I figured it would be the same for Health and Hunger, but I wasn't sure how to make the water burn away faster. How would I use that bit of code in a character's prefab file to make them do that?

Also, can someone provide a list of water sources in Don't Starve (not Shipwrecked, but yes to RoG)? Such as Rain, Ponds, anything that has to do with Water or Wetness? I want Grillby to be afraid of anything that could potentially put him out.

qbHvXrp.gif?noredirect

Edited by NyctoDarkMatter
Fixed a typo.
Link to comment
Share on other sites

I was thinking something like this (into modmain):

local function MoisturePostInit(self)
	local old_GetDryingRate = self.GetDryingRate
	function self:GetDryingRate(moisturerate)
		local rate = old_GetDryingRate(self, moisturerate)
		if self.inst ~= nil and self.inst.prefab == "grillby" then
			rate = rate + 1 -- something, no idea how big this should be
		end
	    return math.clamp(rate, 0, self.maxDryingRate + self.maxPlayerTempDrying)
	end
end
AddComponentPostInit("moisture", MoisturePostInit)

 

Link to comment
Share on other sites

On 18/1/2016 at 9:12 PM, NyctoDarkMatter said:

Having very slight lag spikes even on my gaming computer. I'll look into the issue some more as it happened when I added the Flingomatic code. This makes sense that it would lag when it scans for Grillby, except that it lags even when there is no Flingomatic spawned, or nearby, or anywhere at all. It may have been my world after I messed with some code so I'll go back and see. Any ideas from anyone what's causing it? Especially you, @DarkXero, since you coded a bunch of it? Haha. If the lag spikes are unavoidable in current form I'll look into cutting some stuff out. As I said, more testing is needed.

What happens if you remove the code, lag still persists? I didn't notice any lag while testing.

Link to comment
Share on other sites

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
 Share

×
  • Create New...