Skip to content

Commit

Permalink
Add new Cooking Pots
Browse files Browse the repository at this point in the history
Switch Node effects are now moved to individual meshes for each cooking
pot. There are now three utensils you can stew with:
- Metal Bucket (vanilla)
- Wooden Bucket (vanilla)
- Cooking Pot (new)

The Cooking Pot has a higher capacity and can be purchased at any
camping gear merchant
  • Loading branch information
jhaakma committed Jul 17, 2021
1 parent ca71260 commit 962fb05
Show file tree
Hide file tree
Showing 34 changed files with 238 additions and 188 deletions.
Binary file modified Data Files/Ashfall.esp
Binary file not shown.
Binary file removed Data Files/Icons/ashfall/cookingPot.dds
Binary file not shown.
Binary file added Data Files/Icons/ashfall/cooking_pot.dds
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ local function updateBoilers(e)
end

--Amount of water determines how quickly it boils
local filledAmount = boilerRef.data.waterAmount / common.staticConfigs.capacities[boilerRef.data.utensil]
local filledAmount = boilerRef.data.waterAmount / boilerRef.data.waterCapacity
common.log:trace("BOILER filledAmount: %s", filledAmount)
local filledAmountEffect = math.remap(filledAmount, 0.0, 1.0, maxSpeedForCapacity, 1.0)
common.log:trace("BOILER filledAmountEffect: %s", filledAmountEffect)
Expand Down
27 changes: 27 additions & 0 deletions Data Files/MWSE/mods/mer/ashfall/camping/campfire/campfireInit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,33 @@ end

local function registerCampfire(e)
if e.reference.disabled then return end

--Do some stuff to update old campfires
if e.reference.data then
if e.reference.data.kettleId then
common.log:info("Found campfire with kettleId, replacing with utensilId")
e.reference.data.utensilId = e.reference.data.kettleId
e.reference.data.kettleId = nil
end

if e.reference.data.utensil ~= nil and e.reference.data.utensilId == nil then
if e.reference.data.utensil == "kettle" then
e.reference.data.utensilId = "ashfall_kettle"
else
e.reference.data.utensilId = table.choice{"misc_com_bucket_metal", "misc_com_bucket_01", "ashfall_cooking_pot"}
end
common.log:info("Found campfire with a utensil and no utensilId, setting to %s",
e.reference.data.utensilId)
end

if e.reference.data.utensilId ~= nil and e.reference.data.waterCapacity == nil then
local data = common.staticConfigs.utensils[e.reference.data.utensilId]
local capacity = data and data.capacity or 100
e.reference.data.waterCapacity = capacity
common.log:info("Found campfire with a utensil and no water capacity, setting to %s. utensilID: %s",
capacity, e.reference.data.utensilId)
end
end
local dynamicConfig = campfireConfig.getConfig(e.reference.object.id)
local isActivator = activatorConfig.list.campfire:isActivator(e.reference.object.id)
local initialised = e.reference.data and e.reference.data.campfireInitialised
Expand Down
26 changes: 16 additions & 10 deletions Data Files/MWSE/mods/mer/ashfall/camping/campfire/campfireMenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,25 @@ local buttonMapping = {
"addIngredient",
"addWater",
"emptyPot",
"removePot",
-- "removePot",
"removeUtensil",
},
["Kettle"] = {
"drink",
"brewTea",
"addWater",
"fillContainer",
"emptyKettle",
"removeKettle",
-- "removeKettle",
"removeUtensil",
},
["Supports"] = {
"addKettle",
"addPot",
"removeKettle",
"removePot",
"addUtensil",
-- "addKettle",
-- "addPot",
-- "removeKettle",
"removeUtensil",
-- "removePot",
"removeSupports",
},
["Campfire"] = {
Expand All @@ -41,10 +45,12 @@ local buttonMapping = {
"removeSupports",
"addGrill",
"removeGrill",
"addKettle",
"addPot",
"removeKettle",
"removePot",
"addUtensil",
-- "addKettle",
-- "addPot",
-- "removeKettle",
"removeUtensil",
-- "removePot",
--"wait", -- replaced by cushions
"extinguish",
"destroy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ local function updateTooltip(e)
centerText(fuelLabel)
end
elseif label.text == "Kettle" or label.text == "Cooking Pot" then
local waterAmount = campfire.data.waterAmount
local waterAmount = campfire.data.waterAmount or 0
if waterAmount then
--WATER
local waterHeat = campfire.data.waterHeat or 0
local waterLabel = labelBorder:createLabel{
text = string.format(
"Water: %d/%d %s| Heat: %d/100",
math.ceil(waterAmount),
common.staticConfigs.capacities[campfire.data.utensil],
campfire.data.waterCapacity,
( campfire.data.waterType == "dirty" and "(Dirty) " or ""),
waterHeat)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ end

--Update the water level of the cooking pot
local function updateWaterHeight(campfire)
if not campfire.data.waterCapacity then return end
local scaleMax = 1.3
local heightMax = 28
local waterLevel = campfire.data.waterAmount or 0
local scale = math.min(math.remap(waterLevel, 0, common.staticConfigs.capacities.cookingPot, 1, scaleMax), scaleMax )
local height = math.min(math.remap(waterLevel, 0, common.staticConfigs.capacities.cookingPot, 0, heightMax), heightMax)
local scale = math.min(math.remap(waterLevel, 0, campfire.data.waterCapacity, 1, scaleMax), scaleMax )
local height = math.min(math.remap(waterLevel, 0, campfire.data.waterCapacity, 0, heightMax), heightMax)

local waterNode = campfire.sceneNode:getObjectByName("POT_WATER")
if waterNode then
Expand All @@ -127,22 +128,33 @@ local function updateWaterHeight(campfire)
stewNode.translation.z = height
stewNode.scale = scale
end
local steamNode = campfire.sceneNode:getObjectByName("POT_STEAM")
if steamNode then
steamNode.translation.z = height
end
end

--Update the size of the steam coming off a cooking pot
local function updateSteamScale(campfire)
local hasSteam = (
campfire.data.utensil == "cookingPot" and
campfire.data.waterHeat and
campfire.data.waterHeat >= common.staticConfigs.hotWaterHeatValue
)
if hasSteam then
local steamScale = math.min(math.remap(campfire.data.waterHeat, common.staticConfigs.hotWaterHeatValue
, 100, 0.5, 1.0), 1.0)
local steamNode = campfire.sceneNode:getObjectByName("POT_STEAM")
if steamNode then steamNode = steamNode.children[1] end
steamNode.scale = steamScale
end
-- local hasSteam = (
-- campfire.data.utensil == "cookingPot" and
-- campfire.data.waterHeat and
-- campfire.data.waterHeat >= common.staticConfigs.hotWaterHeatValue
-- )
-- if hasSteam then
-- local steamScale = math.min(math.remap(campfire.data.waterHeat, common.staticConfigs.hotWaterHeatValue
-- , 100, 0.5, 1.0), 1.0)
-- local steamNode = campfire.sceneNode:getObjectByName("POT_STEAM")
-- if steamNode then steamNode = steamNode.children[1] end
-- steamNode.scale = steamScale

-- local potSteam = campfire.sceneNode:getObjectByName("POT_STEAM")
-- if potSteam then
-- local steamScale = math.min(math.remap(campfire.data.waterHeat, common.staticConfigs.hotWaterHeatValue, 100, 0.1, 1.0), 1.0)
-- local materialProperty = potSteam:getObjectByName("SuperSpray"):getProperty(0x2)
-- materialProperty.alpha = steamScale
-- end
-- end
end

--Update the collision box of the campfire
Expand Down Expand Up @@ -212,17 +224,17 @@ local function moveOriginToAttachPoint(node)
end

local function updateAttachNodes(e)
common.log:debug("Ashfall:UpdateAttachNodes")
common.log:trace("Ashfall:UpdateAttachNodes")
local campfire = e.campfire
local sceneNode = campfire.sceneNode
local hangNode = sceneNode:getObjectByName("HANG_UTENSIL")
local utensil = campfire.data.kettleId or "ashfall_kettle"
local utensil = campfire.data.utensilId
if hangNode then
common.log:trace("has hangNode")
common.log:trace("children: %s", #hangNode.children)
if campfire.data.utensil == "kettle" then
if campfire.data.utensil and utensil then
if not idToNameMappings[campfire.data.utensil] then
common.log:trace("No valid utensil type set on data.utensil")
common.log:error("No valid utensil type set on data.utensil")
return
end
common.log:trace("Has utensil")
Expand All @@ -233,7 +245,12 @@ local function updateAttachNodes(e)
end

common.log:trace("utensil is a valid object")
local mesh = tes3.loadMesh(utensilObj.mesh):clone()
local utensilData = common.staticConfigs.utensils[utensil:lower()]
if not utensilData then
common.log:error("%s is not a valid utensil, but was set to campfire.data.utensilId")
end
local meshId = utensilData and utensilData.meshOverride or utensilObj.mesh
local mesh = tes3.loadMesh(meshId):clone()
mesh.name = idToNameMappings[campfire.data.utensil]
moveOriginToAttachPoint(mesh)
hangNode:attachChild(mesh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,20 @@ local ignorePatterns = {
}


local function addCookingPot(campfire)
campfire.data.utensil = "cookingPot"
campfire.data.utensilId = table.choice{"misc_com_bucket_metal", "misc_com_bucket_01", "ashfall_cooking_pot"}
campfire.data.waterCapacity = common.staticConfigs.utensils[campfire.data.utensilId].capacity
campfire.data.dynamicConfig.cookingPot = "static"
end

local function addKettle(campfire)
campfire.data.dynamicConfig.kettle = "static"
campfire.data.utensil = "kettle"
campfire.data.utensilId = table.choice{"ashfall_kettle", "ashfall_kettle_02"}
campfire.data.waterCapacity = common.staticConfigs.utensils[campfire.data.utensilId].capacity
end

local function attachRandomStuff(campfire)
if string.find(campfire.cell.id:lower(), "tomb") then return end
if campfire.data.staticCampfireInitialised then return end
Expand All @@ -109,11 +123,10 @@ local function attachRandomStuff(campfire)
campfire.data.hasSupports = true
end
if campfire.data.dynamicConfig.kettle == "static" then
campfire.data.utensil = "kettle"
campfire.data.kettleId = "ashfall_kettle"
addKettle(campfire)
end
if campfire.data.dynamicConfig.cookingPot == "static" then
campfire.data.utensil = "cookingPot"
addCookingPot(campfire)
end
if campfire.data.dynamicConfig.grill == "static" then
campfire.data.hasGrill = true
Expand All @@ -138,14 +151,15 @@ local function attachRandomStuff(campfire)
end
--add tea to kettleswaterHeat
if campfire.data.utensil == "kettle" then
campfire.data.kettleId = "ashfall_kettle"
addKettle(campfire)
if math.random() < randomStuffChances.tea then
local teaType = table.choice(common.staticConfigs.teaConfig.validTeas)
campfire.data.waterType = teaType
campfire.data.teaProgress = 100
end
--add random stew to cooking pots
elseif campfire.data.utensil == "cookingPot" then
addCookingPot(campfire)
if math.random() < randomStuffChances.stew then
campfire.data.ladle = true
campfire.data.stewLevels = {}
Expand Down Expand Up @@ -176,7 +190,7 @@ local function setInitialState(campfire, vanillaRef, data, hasSupports)
--prevent removal of supports for kitbashing reasons
campfire.data.dynamicConfig.supports = "static"
if data.hasCookingPot then
campfire.data.utensil = "cookingPot"
addCookingPot(campfire)
end
elseif data.hasPlatform == true then
campfire.data.dynamicConfig.supports = "none"
Expand All @@ -195,7 +209,7 @@ local function setInitialState(campfire, vanillaRef, data, hasSupports)
else
campfire:deleteDynamicLightAttachment()
end
event.trigger("Ashfall:UpdateAttachNodes", { campfire = campfire })

timer.delayOneFrame(function()
event.trigger("Ashfall:registerReference", { reference = campfire} )
end)
Expand Down Expand Up @@ -381,7 +395,7 @@ local function replaceCampfire(e)

setInitialState(campfire, e.reference, data, vanillaConfig.supports)
attachRandomStuff(campfire)

event.trigger("Ashfall:UpdateAttachNodes", { campfire = campfire })

campfire.scale = e.reference.scale
if vanillaConfig.scale then
Expand Down
1 change: 1 addition & 0 deletions Data Files/MWSE/mods/mer/ashfall/camping/cooking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ local function clearUtensilData(e)
if e.removeUtensil then
campfire.data.utensil = nil
campfire.data.ladle = nil
campfire.data.utensilId = nil
end
if not e.isContainer then
tes3.removeSound{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,22 @@ end


local function addIngredient(e)
local campfire = e.campfire
--Cool down stew
e.campfire.data.stewProgress = e.campfire.data.stewProgress or 0
e.campfire.data.stewProgress = math.max(( e.campfire.data.stewProgress - stewIngredientCooldownAmount ), 0)
campfire.data.stewProgress = campfire.data.stewProgress or 0
campfire.data.stewProgress = math.max(( campfire.data.stewProgress - stewIngredientCooldownAmount ), 0)

--initialise stew levels
e.campfire.data.stewLevels = e.campfire.data.stewLevels or {}
e.campfire.data.stewLevels[e.foodType] = e.campfire.data.stewLevels[e.foodType] or 0
campfire.data.stewLevels = campfire.data.stewLevels or {}
campfire.data.stewLevels[e.foodType] = campfire.data.stewLevels[e.foodType] or 0
--Add ingredient to stew
common.log:trace("old stewLevel: %s", e.campfire.data.stewLevels[e.foodType])
local waterRatio = e.campfire.data.waterAmount / common.staticConfigs.capacities.cookingPot
common.log:trace("old stewLevel: %s", campfire.data.stewLevels[e.foodType])
local waterRatio = campfire.data.waterAmount / campfire.data.waterCapacity
common.log:trace("waterRatio: %s", waterRatio)
local ingredAmountToAdd = e.amount * common.staticConfigs.stewIngredAddAmount / waterRatio
common.log:trace("ingredAmountToAdd: %s", ingredAmountToAdd)
e.campfire.data.stewLevels[e.foodType] = math.min(e.campfire.data.stewLevels[e.foodType] + ingredAmountToAdd, 100)
common.log:trace("new stewLevel: %s", e.campfire.data.stewLevels[e.foodType])
campfire.data.stewLevels[e.foodType] = math.min(campfire.data.stewLevels[e.foodType] + ingredAmountToAdd, 100)
common.log:trace("new stewLevel: %s", campfire.data.stewLevels[e.foodType])

common.skills.survival:progressSkill(skillSurvivalStewIngredIncrement*e.amount)
tes3.player.object.inventory:removeItem{
Expand Down Expand Up @@ -76,7 +77,7 @@ local function ingredientSelect(campfire, foodType)
common.data.inventorySelectStew = nil
if e.item then
common.log:debug("Selecting ingredient amount for stew")
local waterRatio = campfire.data.waterAmount / common.staticConfigs.capacities.cookingPot
local waterRatio = campfire.data.waterAmount / campfire.data.waterCapacity
local stewLevel = (campfire.data.stewLevels and campfire.data.stewLevels[foodType] or 0)
local adjustedIngredAmount = common.staticConfigs.stewIngredAddAmount / waterRatio
common.log:debug("adjustedIngredAmount: %s", adjustedIngredAmount)
Expand Down

This file was deleted.

Loading

0 comments on commit 962fb05

Please sign in to comment.