Frank Klinton Posted January 16, 2019 Share Posted January 16, 2019 (edited) So basically what I'm trying to do is to set food values to half from the fresh ones, both hunger and health for stale and no bonus health for spoiled and same hunger as stale. So far I came up with this but it doesn't work, it gives you the full fresh bonus. If somebody can help, would much appreciate that. local function OnEat(inst, food) if inst:HasTag("awaken") then if food.prefab == "monstermeat" then inst.components.hunger:DoDelta(25) inst.components.health:DoDelta(10) elseif food.prefab == "monstermeat" and inst.components.perishable:IsStale() then inst.components.hunger:DoDelta(10) inst.components.health:DoDelta(5) elseif food.prefab == "monstermeat" and inst.components.perishable:IsSpoiled() then inst.components.hunger:DoDelta(10) inst.components.health:DoDelta(0) end if food.prefab == "cookedmonstermeat" then inst.components.hunger:DoDelta(25) inst.components.health:DoDelta(10) elseif food.prefab == "cookedmonstermeat" and inst.components.perishable:IsStale() then inst.components.hunger:DoDelta(10) inst.components.health:DoDelta(5) elseif food.prefab == "cookedmonstermeat" and inst.components.perishable:IsSpoiled() then inst.components.hunger:DoDelta(10) inst.components.health:DoDelta(0) end if food.prefab == "monstermeat_dried" then inst.components.hunger:DoDelta(40) inst.components.health:DoDelta(30) elseif food.prefab == "monstermeat_dried" and inst.components.perishable:IsStale() then inst.components.hunger:DoDelta(20) inst.components.health:DoDelta(15) elseif food.prefab == "monstermeat_dried" and inst.components.perishable:IsSpoiled() then inst.components.hunger:DoDelta(20) inst.components.health:DoDelta(0) end if food.prefab == "monsterlasagna" then inst.components.hunger:DoDelta(80) inst.components.health:DoDelta(30) elseif food.prefab == "monsterlasagna" and inst.components.perishable:IsStale() then inst.components.hunger:DoDelta(45) inst.components.health:DoDelta(15) elseif food.prefab == "monsterlasagna" and inst.components.perishable:IsSpoiled() then inst.components.hunger:DoDelta(45) inst.components.health:DoDelta(0) end Edited January 16, 2019 by Frank Klinton Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 16, 2019 Author Share Posted January 16, 2019 It is for specific character I should mention Link to comment Share on other sites More sharing options...
Ultroman Posted January 16, 2019 Share Posted January 16, 2019 (edited) We need your whole character script, in order to see what you're doing wrong. Usually, it's because the modder forgot to actually replace the function. You need to use inst.components.eater:SetOnEatFn(yourOnEatFunction) in order to change the oneatfn function. Also, why don't you just use the food values in the edible-component on the given food and divide them by 2, so it'll work for all food, instead of just the food you've made if-statements for? Is this supposed to only apply to certain types of food? I'm not seeing any "else" for your if-statement. Without that, any food you haven't made an if-statement for, will have no effect. Another problem, which completely abolishes the way you're doing things right now: the chain of events are against you when it comes to influencing the effects of food. Look at the Eat function in the eater-component. 1. It applies the stat-changes. 2. It pushes the event "oneat". 3. It calls the "oneatfn". 4. It calls the OnEaten function on the edible-component of the food. This means that you can only affect things AFTER the stats have been applied, but BEFORE the food is actually eaten (removed/destroyed). This means you would have to subtract half of the value AFTER it is actually applied, which obviously gives problems if the player is close to full in a given stat. The addition would be cut off at full, and then you would subtract the full half afterwards. I think the best move, is to do an AddComponentPostInit("edible", myFunction), make sure it has the spoilage-component, and then change the GetHealth, GetSanity and GetHunger functions on each edible object, and do your checks and alterations for spoilage in there, but only if the eater is your character. Edited January 16, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 16, 2019 Author Share Posted January 16, 2019 (edited) 'kay here goes nothing, character is not mine, I'm just trying to do some tweaks local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { } -- When the character is revived from human -- local function onbecamehuman(inst) -- inst.components.locomotor:SetExternalSpeedMultiplier(inst, "ocsayaka_speed_mod", 1.15) -- end -- local function onbecameghost(inst) -- inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") -- end --No sanity loss during the night local tempCaveVar = false local function updatestats(inst) if TheWorld.state.phase == "day" then elseif TheWorld.state.phase == "dusk" then elseif TheWorld.state.phase == "night" then inst.components.sanity.dapperness = (TUNING.DAPPERNESS_SMALL * 0) elseif tempCaveVar == true then inst.components.sanity.dapperness = (TUNING.DAPPERNESS_SMALL * 0) end end --Demonic Sequence Start-- local function applyForm(inst) if inst.form == "demonic" and inst.components.eater ~= nil then inst.components.eater.strongstomach = true inst:AddTag("spiderwhisperer") inst:AddTag("monster") inst:AddTag("awaken") inst.components.combat.damagemultiplier = 2 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.15) inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED end if inst.form == "normal" and inst.components.eater ~= nil then inst.components.eater.strongstomach = false inst:RemoveTag("spiderwhisperer") inst:RemoveTag("monster") inst:RemoveTag("awaken") inst.components.combat.damagemultiplier = 1 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE) inst.components.sanity.night_drain_mult = 1 inst.components.sanity.neg_aura_mult = 1 inst.components.sanityaura.aura = TUNING.SANITYAURA_MED end end local function becomenormal(inst, silent) if inst.form == "normal" then return end inst.components.talker:Say("Guess I'm back to normal.", 2.5,true) if inst.demontask then inst.demontask:Cancel() inst.demontask = nil end inst.form = "normal" inst.AnimState:SetBuild("ocsayaka") -- inst:RemoveTag("awaken") end local function becomedemonic(inst, silent) if inst.form == "demonic" then return end inst.components.talker:Say("Let's play a little.", 2.5,true) local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("firering_fx") fx.Transform:SetPosition(x, y, z) SpawnPrefab("scorchedground").Transform:SetPosition(inst:GetPosition():Get()) inst.SoundEmitter:PlaySound("dontstarve/creatures/leif/livinglog_burn") inst.form = "demonic" inst.AnimState:SetBuild("ocsayakademon") -- inst:AddTag("awaken") end local function onsanitychange(inst, data, forcesilent) if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent if inst.form == "demonic" then if inst.components.sanity.current > (50) then becomenormal(inst, silent) end elseif inst.form == "normal" then if inst.components.sanity.current < (45) then becomedemonic(inst, silent) end end applyForm(inst) end local function onnewstate(inst) if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then inst._wasnomorph = not inst._wasnomorph if not inst._wasnomorph then onsanitychange(inst) end end end local function onbecameghost(inst) inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") if inst._wasnomorph ~= nil then inst.form = "normal" inst._wasnomorph = nil inst:RemoveEventCallback("sanitydelta", onsanitychange) inst:RemoveEventCallback("newstate", onnewstate) end end local function onbecamehuman(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "ocsayaka_speed_mod", 1.15) -- inst:RemoveTag("awaken") if inst._wasnomorph == nil then inst.form = "normal" inst._wasnomorph = inst.sg:HasStateTag("nomorph") inst:ListenForEvent("sanitydelta", onsanitychange) inst:ListenForEvent("newstate", onnewstate) if inst.demontask then inst.demontask:Cancel() inst.demontask = nil end onsanitychange(inst, nil, true) end end --Demonic Sequence End-- -- local function onbecameghost(inst) -- inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") -- end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end --Gain sanity in rain local function doraincheck(inst) --, dt) --insects local x,y,z = inst.Transform:GetWorldPosition() local e = TheSim:FindEntities(x,y,z,5,nil,nil,{"minotaurchest"}) local dapp = -TUNING.DAPPERNESS_MED_LARGE * 3 * #e --rain local w = TheWorld.state if w.israining then if inst.components.sanity.current > 50 then dapp = dapp + TUNING.DAPPERNESS_MED_LARGE * 1.5 * w.precipitationrate elseif inst.components.sanity.current > 30 then dapp = dapp + TUNING.DAPPERNESS_MED_LARGE*2* w.precipitationrate else dapp = dapp + TUNING.DAPPERNESS_MED_LARGE*2.5* w.precipitationrate end end --moisture if inst.components.moisture and inst.components.moisture:GetMoisture() > 0 and inst.components.moisture:GetMoisturePercent() < 0.15 then dapp = dapp + TUNING.DAPPERNESS_SMALL * -1.25-- + TUNING.MOISTURE_SANITY_PENALTY_MAX/4 end inst.components.sanity.dapperness = dapp end --Food freshness local function getmultfn(inst, food, original_value) local mult = 1 if food.components.edible then if food:HasTag("preparedfood") then mult = 1.25 elseif food.prefab:find("cooked") then mult = 0.9 elseif food.prefab:find("dried") then mult = 0.8 elseif not food.prefab:find("dried") and not food.prefab:find("cooked") then mult = 0.7 end end end local function onkilledother(inst, data) local chance = .45 local chance2 = .75 local victim = data.victim if victim:HasTag("monster") then if math.random() < chance then victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") end end if victim:HasTag("largecreature") then if math.random() < chance2 then victim.components.lootdropper:SpawnLootPrefab("gy") victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") end end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "ocsayaka.tex" ) inst:AddTag("ocsayaka_builder") inst:AddTag("ocsayakaspecific") -- inst.components.playervision:SetCustomCCTable(BEAVERVISION_COLOURCUBES) end local function OnEat(inst, food) if inst:HasTag("awaken") then if food.prefab == "monstermeat" then inst.components.hunger:DoDelta(25) inst.components.health:DoDelta(10) end if food.prefab == "cookedmonstermeat" then inst.components.hunger:DoDelta(40) inst.components.health:DoDelta(10) end if food.prefab == "monstermeat_dried" then inst.components.hunger:DoDelta(50) inst.components.health:DoDelta(30) end if food.prefab == "monsterlasagna" then inst.components.hunger:DoDelta(80) inst.components.health:DoDelta(30) end if food and food.components.edible and food.prefab == "ocsayakasoul" then inst.components.hunger:DoDelta(food.components.edible:GetHunger(inst)*-5); inst.components.sanity:DoDelta(food.components.edible:GetSanity(inst)*-0.5); inst.components.health:DoDelta((food.components.edible:GetHealth(inst)+10)*-3, nil, food.prefab); inst.components.talker:Say("I've devoured your body and your soul.", 2.5,true) end end end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wendy" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" --Meat is good inst.components.eater:SetOnEatFn(OnEat) -- Stats inst.components.health:SetMaxHealth(175) inst.components.hunger:SetMax(125) inst.components.sanity:SetMax(150) inst.form = "normal" inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil -- Sanity Aura inst:AddComponent("sanityaura") -- inst.components.sanityaura.aura = TUNING.SANITYAURA_MED -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE --Slight summer resistance -- inst:AddComponent("insulator") -- inst.components.insulator:SetInsulation(TUNING.INSULATION_MED) -- inst.components.insulator:SetSummer() inst.components.temperature.mintemp = 20 -- Freezer Status inst:AddComponent("heater") inst.components.heater.heatfn = function() return -35 end inst.components.heater:SetThermics(false, true) --Sanity in rain check inst:DoPeriodicTask(0.3 + math.random()*0.1, doraincheck ) inst.components.temperature.hurtrate = 1.15 -- local eater = inst.components.eater -- eater.ignoresspoilage = true -- inst.components.eater.Eat_orig = inst.components.eater.Eat -- function inst.components.eater:Eat( food ) -- if self:CanEat(food) then -- if food.components.edible.sanityvalue < 0 then -- food.components.edible.sanityvalue = -20 -- end -- return inst.components.eater:Eat_orig(food) -- end -- end --Checking time of day inst:WatchWorldState( "startday", function(inst) updatestats(inst) end ) inst:WatchWorldState( "startdusk", function(inst) updatestats(inst) end ) inst:WatchWorldState( "startnight", function(inst) updatestats(inst) end ) updatestats(inst) --Drop Rate for item inst:ListenForEvent("killed", onkilledother) inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("ocsayaka", prefabs, assets, common_postinit, master_postinit, start_inv) Edited January 16, 2019 by Frank Klinton Link to comment Share on other sites More sharing options...
Ultroman Posted January 16, 2019 Share Posted January 16, 2019 (edited) Please just attach the code as a file to a post, instead of posting it as text in a post. It's long and barely readable. Also, when you DO have to post code, you should click the <> icon in the text editor, and paste the code into the box that appears. Edited January 16, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 16, 2019 Author Share Posted January 16, 2019 Why don't I divide, hm... Good question, but I want it only for monster food, not including the Durian. Link to comment Share on other sites More sharing options...
Ultroman Posted January 16, 2019 Share Posted January 16, 2019 Note that I've completely changed my last post, with regards to what I think you should do. It's a very different approach to what you are currently doing. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 16, 2019 Author Share Posted January 16, 2019 ocsayaka.lua 38 minutes ago, Ultroman said: We need your whole character script, in order to see what you're doing wrong. Usually, it's because the modder forgot to actually replace the function. Also, why don't you just use the food values in the edible-component on the given food and divide them by 2, so it'll work for all food, instead of just the food you've made if-statements for? Is this supposed to only apply to certain types of food? I'm not seeing any "else" for your if-statement. Without that, any food you haven't made an if-statement for, will have no effect. I've tried to add "else" and "elseif" but it didn't work. Link to comment Share on other sites More sharing options...
Ultroman Posted January 16, 2019 Share Posted January 16, 2019 OK, if it's only certain foods, you should do AddPrefabPostInit("food_name") for all of the food prefabs, but still follow the idea of changing the GetHealth etc. functions in the edible-component of these foods, like I proposed in the previous post. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 16, 2019 Author Share Posted January 16, 2019 Could you show a sample of how that'll look, please, I don't study .lua unfortunately I just happen to stumble upon all that coding Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 (edited) Hmm...actually there's a much easier way. It seems you want these eating habits only when in a particular form. And I just noticed that there are already modifiers on the eater-component to control the stats you are given from food There is no multiplier for sanity, oddly enough, but you only mentioned hunger and health, and there are multipliers for those. Whenever you change to the form where you want these restrictions, put this code: inst.components.eater.stale_health = 0.5 inst.components.eater.spoiled_health = 0.0 inst.components.eater.stale_hunger = 0.5 inst.components.eater.spoiled_hunger = 0.5 and when you change back to normal, do this code: inst.components.eater.stale_health = 1 inst.components.eater.spoiled_health = 1 inst.components.eater.stale_hunger = 1 inst.components.eater.spoiled_hunger = 1 Edited January 17, 2019 by Ultroman Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 1 minute ago, Ultroman said: Hmm...actually there's a much easier way. It seems you want these eating habits only when in a particular form. And I just noticed that there are already modifiers to control this on the eater-component There is no multiplier for sanity, oddly enough, but you only mentioned hunger and health, and there are multipliers for those. Whenever you change to the form where you want these restrictions, put this code: inst.components.eater.stale_health = 0.5 inst.components.eater.spoiled_health = 0.0 inst.components.eater.stale_hunger = 0.5 inst.components.eater.spoiled_hunger = 0.5 and when you change back to normal, do this code: inst.components.eater.stale_health = 1 inst.components.eater.spoiled_health = 1 inst.components.eater.stale_hunger = 1 inst.components.eater.spoiled_hunger = 1 if food.prefab == "cookedmonstermeat" then inst.components.hunger:DoDelta(40) inst.components.health:DoDelta(10) inst.components.eater.stale_health = 0.5 inst.components.eater.spoiled_health = 0.0 inst.components.eater.stale_hunger = 0.5 inst.components.eater.spoiled_hunger = 0.5 end Like this? Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 No. Delete your entire OnEat function. You don't need it. Then do as I said. You have an "applyform" function, where it changes between the two forms. When it changes to the "awaken" form (where it adds the tag "awaken"), paste in the first lump of code, and in the other part of the code, where it removes the "awaken" tag, paste in the second lump of code. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 Checked for stale monster lasagna, it still give 30 because of inst.components.health:DoDelta(30) It completely ignores inst.components.eater.stale_health = 0.5 I think I got where to put for awakened form local function applyForm(inst) if inst.form == "demonic" and inst.components.eater ~= nil then inst.components.eater.strongstomach = true inst:AddTag("spiderwhisperer") inst:AddTag("monster") inst:AddTag("awaken") inst.components.combat.damagemultiplier = 2 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.15) inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED inst.components.eater.stale_health = 0.5 inst.components.eater.spoiled_health = 0.0 inst.components.eater.stale_hunger = 0.5 inst.components.eater.spoiled_hunger = 0.5 end But I can't seem to understand where to put when it's a "normal" form Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 Yes. That is correct. But I totally forgot that you wanted to have this work for specific food items. This solution will make it affect all food. Remove those four lines again. You still don't need your OnEat function. Delete it, and also delete the line that says inst.components.eater:SetOnEatFn(OnEat) I'll post some code in a minute for altering the food items. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 (edited) So then it's the inst.components.eater:SetOnEatFn(OnEat) And not the the local function OnEat(inst, food) that comes before if inst:HasTag("awaken") then if food.prefab == "monstermeat" then inst.components.hunger:DoDelta(25) inst.components.health:DoDelta(10) end if food.prefab == "cookedmonstermeat" then inst.components.hunger:DoDelta(40) inst.components.health:DoDelta(10) end if food.prefab == "monstermeat_dried" then inst.components.hunger:DoDelta(50) inst.components.health:DoDelta(30) end if food.prefab == "monsterlasagna" then inst.components.hunger:DoDelta(80) inst.components.health:DoDelta(30) end Edited January 17, 2019 by Frank Klinton Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 It's the first one, AND the whole function called OnEat Delete them. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 1 minute ago, Ultroman said: It's the first one, AND the whole function called OnEat Delete them. First one has been deleted Tested on our current stage: Health doesn't add up not in a stale form, not in a fresh form either Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 It doesn't add any at all? Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 Well here's the code maybe I didn't put everything correct, but yeah adds only hunger by default I think (character has a "webber" tag after all) local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Custom starting items local start_inv = { } -- When the character is revived from human -- local function onbecamehuman(inst) -- inst.components.locomotor:SetExternalSpeedMultiplier(inst, "ocsayaka_speed_mod", 1.15) -- end -- local function onbecameghost(inst) -- inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") -- end --No sanity loss during the night local tempCaveVar = false local function updatestats(inst) if TheWorld.state.phase == "day" then elseif TheWorld.state.phase == "dusk" then elseif TheWorld.state.phase == "night" then inst.components.sanity.dapperness = (TUNING.DAPPERNESS_SMALL * 0) elseif tempCaveVar == true then inst.components.sanity.dapperness = (TUNING.DAPPERNESS_SMALL * 0) end end --Demonic Sequence Start-- local function applyForm(inst) if inst.form == "demonic" and inst.components.eater ~= nil then inst.components.eater.strongstomach = true inst:AddTag("spiderwhisperer") inst:AddTag("monster") inst:AddTag("awaken") inst.components.combat.damagemultiplier = 2 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.15) inst.components.sanity.night_drain_mult = 0 inst.components.sanity.neg_aura_mult = 0 inst.components.sanityaura.aura = -TUNING.SANITYAURA_MED inst.components.eater.stale_health = 0.5 inst.components.eater.spoiled_health = 0.0 inst.components.eater.stale_hunger = 0.5 inst.components.eater.spoiled_hunger = 0.5 end if inst.form == "normal" and inst.components.eater ~= nil then inst.components.eater.strongstomach = false inst:RemoveTag("spiderwhisperer") inst:RemoveTag("monster") inst:RemoveTag("awaken") inst.components.combat.damagemultiplier = 1 inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE) inst.components.sanity.night_drain_mult = 1 inst.components.sanity.neg_aura_mult = 1 inst.components.sanityaura.aura = TUNING.SANITYAURA_MED inst.components.eater.stale_health = 1 inst.components.eater.spoiled_health = 1 inst.components.eater.stale_hunger = 1 inst.components.eater.spoiled_hunger = 1 end end local function becomenormal(inst, silent) if inst.form == "normal" then return end inst.components.talker:Say("Guess I'm back to normal.", 2.5,true) if inst.demontask then inst.demontask:Cancel() inst.demontask = nil end inst.form = "normal" inst.AnimState:SetBuild("ocsayaka") -- inst:RemoveTag("awaken") end local function becomedemonic(inst, silent) if inst.form == "demonic" then return end inst.components.talker:Say("Let's play a little.", 2.5,true) local x, y, z = inst.Transform:GetWorldPosition() local fx = SpawnPrefab("firering_fx") fx.Transform:SetPosition(x, y, z) SpawnPrefab("scorchedground").Transform:SetPosition(inst:GetPosition():Get()) inst.SoundEmitter:PlaySound("dontstarve/creatures/leif/livinglog_burn") inst.form = "demonic" inst.AnimState:SetBuild("ocsayakademon") -- inst:AddTag("awaken") end local function onsanitychange(inst, data, forcesilent) if inst.sg:HasStateTag("nomorph") or inst:HasTag("playerghost") or inst.components.health:IsDead() then return end local silent = inst.sg:HasStateTag("silentmorph") or not inst.entity:IsVisible() or forcesilent if inst.form == "demonic" then if inst.components.sanity.current > (50) then becomenormal(inst, silent) end elseif inst.form == "normal" then if inst.components.sanity.current < (45) then becomedemonic(inst, silent) end end applyForm(inst) end local function onnewstate(inst) if inst._wasnomorph ~= inst.sg:HasStateTag("nomorph") then inst._wasnomorph = not inst._wasnomorph if not inst._wasnomorph then onsanitychange(inst) end end end local function onbecameghost(inst) inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") if inst._wasnomorph ~= nil then inst.form = "normal" inst._wasnomorph = nil inst:RemoveEventCallback("sanitydelta", onsanitychange) inst:RemoveEventCallback("newstate", onnewstate) end end local function onbecamehuman(inst) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "ocsayaka_speed_mod", 1.15) -- inst:RemoveTag("awaken") if inst._wasnomorph == nil then inst.form = "normal" inst._wasnomorph = inst.sg:HasStateTag("nomorph") inst:ListenForEvent("sanitydelta", onsanitychange) inst:ListenForEvent("newstate", onnewstate) if inst.demontask then inst.demontask:Cancel() inst.demontask = nil end onsanitychange(inst, nil, true) end end --Demonic Sequence End-- -- local function onbecameghost(inst) -- inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "ocsayaka_speed_mod") -- end -- When loading or spawning the character local function onload(inst) inst:ListenForEvent("ms_respawnedfromghost", onbecamehuman) inst:ListenForEvent("ms_becameghost", onbecameghost) if inst:HasTag("playerghost") then onbecameghost(inst) else onbecamehuman(inst) end end --Gain sanity in rain local function doraincheck(inst) --, dt) --insects local x,y,z = inst.Transform:GetWorldPosition() local e = TheSim:FindEntities(x,y,z,5,nil,nil,{"minotaurchest"}) local dapp = -TUNING.DAPPERNESS_MED_LARGE * 3 * #e --rain local w = TheWorld.state if w.israining then if inst.components.sanity.current > 50 then dapp = dapp + TUNING.DAPPERNESS_MED_LARGE * 1.5 * w.precipitationrate elseif inst.components.sanity.current > 30 then dapp = dapp + TUNING.DAPPERNESS_MED_LARGE*2* w.precipitationrate else dapp = dapp + TUNING.DAPPERNESS_MED_LARGE*2.5* w.precipitationrate end end --moisture if inst.components.moisture and inst.components.moisture:GetMoisture() > 0 and inst.components.moisture:GetMoisturePercent() < 0.15 then dapp = dapp + TUNING.DAPPERNESS_SMALL * -1.25-- + TUNING.MOISTURE_SANITY_PENALTY_MAX/4 end inst.components.sanity.dapperness = dapp end --Food freshness local function getmultfn(inst, food, original_value) local mult = 1 if food.components.edible then if food:HasTag("preparedfood") then mult = 1.25 elseif food.prefab:find("cooked") then mult = 0.9 elseif food.prefab:find("dried") then mult = 0.8 elseif not food.prefab:find("dried") and not food.prefab:find("cooked") then mult = 0.7 end end end local function onkilledother(inst, data) local chance = .45 local chance2 = .75 local victim = data.victim if victim:HasTag("monster") then if math.random() < chance then victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") end end if victim:HasTag("largecreature") then if math.random() < chance2 then victim.components.lootdropper:SpawnLootPrefab("gy") victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") victim.components.lootdropper:SpawnLootPrefab("ocsayakasoul") end end end -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) -- Minimap icon inst.MiniMapEntity:SetIcon( "ocsayaka.tex" ) inst:AddTag("ocsayaka_builder") inst:AddTag("ocsayakaspecific") -- inst.components.playervision:SetCustomCCTable(BEAVERVISION_COLOURCUBES) end local function OnEat(inst, food) if inst:HasTag("awaken") then if food.prefab == "monstermeat" then inst.components.hunger:DoDelta(25) inst.components.health:DoDelta(10) end if food.prefab == "cookedmonstermeat" then inst.components.hunger:DoDelta(40) inst.components.health:DoDelta(10) end if food.prefab == "monstermeat_dried" then inst.components.hunger:DoDelta(50) inst.components.health:DoDelta(30) end if food.prefab == "monsterlasagna" then inst.components.hunger:DoDelta(80) inst.components.health:DoDelta(30) end if food and food.components.edible and food.prefab == "ocsayakasoul" then inst.components.hunger:DoDelta(food.components.edible:GetHunger(inst)*-5); inst.components.sanity:DoDelta(food.components.edible:GetSanity(inst)*-0.5); inst.components.health:DoDelta((food.components.edible:GetHealth(inst)+10)*-3, nil, food.prefab); inst.components.talker:Say("I've devoured your body and your soul.", 2.5,true) end end end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- choose which sounds this character will play inst.soundsname = "wendy" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" --Meat is good -- Stats inst.components.health:SetMaxHealth(175) inst.components.hunger:SetMax(125) inst.components.sanity:SetMax(150) inst.form = "normal" inst._wasnomorph = nil inst.talksoundoverride = nil inst.hurtsoundoverride = nil -- Sanity Aura inst:AddComponent("sanityaura") -- inst.components.sanityaura.aura = TUNING.SANITYAURA_MED -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE --Slight summer resistance -- inst:AddComponent("insulator") -- inst.components.insulator:SetInsulation(TUNING.INSULATION_MED) -- inst.components.insulator:SetSummer() inst.components.temperature.mintemp = 20 -- Freezer Status inst:AddComponent("heater") inst.components.heater.heatfn = function() return -35 end inst.components.heater:SetThermics(false, true) --Sanity in rain check inst:DoPeriodicTask(0.3 + math.random()*0.1, doraincheck ) inst.components.temperature.hurtrate = 1.15 -- local eater = inst.components.eater -- eater.ignoresspoilage = true -- inst.components.eater.Eat_orig = inst.components.eater.Eat -- function inst.components.eater:Eat( food ) -- if self:CanEat(food) then -- if food.components.edible.sanityvalue < 0 then -- food.components.edible.sanityvalue = -20 -- end -- return inst.components.eater:Eat_orig(food) -- end -- end --Checking time of day inst:WatchWorldState( "startday", function(inst) updatestats(inst) end ) inst:WatchWorldState( "startdusk", function(inst) updatestats(inst) end ) inst:WatchWorldState( "startnight", function(inst) updatestats(inst) end ) updatestats(inst) --Drop Rate for item inst:ListenForEvent("killed", onkilledother) inst.OnLoad = onload inst.OnNewSpawn = onload end return MakePlayerCharacter("ocsayaka", prefabs, assets, common_postinit, master_postinit, start_inv) Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 Here's the code you need to put at the bottom of your modmain.lua: local myGetHealth = function(self, eater) local multiplier = 1 local healthvalue = self.gethealthfn ~= nil and self.gethealthfn(self.inst, eater) or self.healthvalue local ignore_spoilage = not self.degrades_with_spoilage or healthvalue < 0 or (eater ~= nil and eater.components.eater ~= nil and eater.components.eater.ignoresspoilage) if not ignore_spoilage and self.inst.components.perishable ~= nil then if self.inst.components.perishable:IsStale() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.stale_health or self.stale_health multiplier = multiplier * 0.5 elseif self.inst.components.perishable:IsSpoiled() then multiplier = 0 end end return multiplier * healthvalue end local myGetHunger = function(self, eater) local multiplier = 1 local ignore_spoilage = not self.degrades_with_spoilage or self.hungervalue < 0 or (eater ~= nil and eater.components.eater ~= nil and eater.components.eater.ignoresspoilage) if not ignore_spoilage and self.inst.components.perishable ~= nil then if self.inst.components.perishable:IsStale() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.stale_hunger or self.stale_hunger multiplier = multiplier * 0.5 elseif self.inst.components.perishable:IsSpoiled() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.spoiled_hunger or self.spoiled_hunger multiplier = multiplier * 0.5 end end return multiplier * self.hungervalue end AddPrefabPostInit("monstermeat", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("cookedmonstermeat", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("monstermeat_dried", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("monsterlasagna", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("ocsayakasoul", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return (inst.components.edible:GetHealth(inst)+10)*-3 else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return inst.components.edible:GetHunger(inst)*-5 else return old_gethunger(self, eater) end end local old_getsanity = inst.components.edible.GetSanity inst.components.edible.GetSanity = function(self, eater) if eater:HasTag("awaken") then return inst.components.edible:GetSanity(inst)*-0.5 else return old_getsanity(self, eater) end end end) Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 And should I leave the code that was above as it is? Link to comment Share on other sites More sharing options...
Ultroman Posted January 17, 2019 Share Posted January 17, 2019 ocsayaka.lua Here's the LUA where I've removed the OnEat entirely. The character does not have the "webber" tag anywhere I can see. There may be a discrepancy between the values you got before and the values you get now. This is because the author of this character mod did not properly change the foods. They adjusted the food values after they had been applied, so you may get lower values than before, That's easily fixed though.Try out some food, and change the values if you feel like it. Right now, all the monstermeat food has its values halved, except health for spoiled food is 0. I made a special case for the "ocsayakasoul" prefab, since it was special. It uses the values put on the item, but very, very weirdly. It multiplies the values put on the food item by negative numbers. You might want to look at that, and just set them to an appropriate value. Link to comment Share on other sites More sharing options...
Frank Klinton Posted January 17, 2019 Author Share Posted January 17, 2019 Now it crashes and didn't tweaked the food right, yeah tell me about, that's so true Got one before it started the server second time (it just froze) That's how modmain.lua looks like PrefabFiles = { "ocsayaka", "ocsayaka_none", "ocsayakademon_none", "ocsayakawhip", "ocsayakademonwhip", "ocsayakarevolver", "ocsayaka_projectile", "ocsayakabandana", "ocsayakasoul", } Assets = { Asset( "IMAGE", "images/saveslot_portraits/ocsayaka.tex" ), Asset( "ATLAS", "images/saveslot_portraits/ocsayaka.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/ocsayaka.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/ocsayaka.xml" ), Asset( "IMAGE", "images/selectscreen_portraits/ocsayaka_silho.tex" ), Asset( "ATLAS", "images/selectscreen_portraits/ocsayaka_silho.xml" ), Asset( "IMAGE", "bigportraits/ocsayaka.tex" ), Asset( "ATLAS", "bigportraits/ocsayaka.xml" ), Asset( "IMAGE", "images/map_icons/ocsayaka.tex" ), Asset( "ATLAS", "images/map_icons/ocsayaka.xml" ), Asset( "IMAGE", "images/avatars/avatar_ocsayaka.tex" ), Asset( "ATLAS", "images/avatars/avatar_ocsayaka.xml" ), Asset( "IMAGE", "images/avatars/avatar_ghost_ocsayaka.tex" ), Asset( "ATLAS", "images/avatars/avatar_ghost_ocsayaka.xml" ), Asset( "IMAGE", "images/avatars/self_inspect_ocsayaka.tex" ), Asset( "ATLAS", "images/avatars/self_inspect_ocsayaka.xml" ), Asset( "IMAGE", "images/names_ocsayaka.tex" ), Asset( "ATLAS", "images/names_ocsayaka.xml" ), Asset( "IMAGE", "bigportraits/ocsayaka_none.tex" ), Asset( "ATLAS", "bigportraits/ocsayaka_none.xml" ), Asset( "ATLAS", "images/hud/ocsayakatab.xml" ), Asset( "IMAGE", "images/hud/ocsayakatab.tex" ), } local require = GLOBAL.require local STRINGS = GLOBAL.STRINGS local resolvefilepath = GLOBAL.resolvefilepath local Ingredient = GLOBAL.Ingredient local RECIPETABS = GLOBAL.RECIPETABS local Recipe = GLOBAL.Recipe local TECH = GLOBAL.TECH -- local NIGHTVISION_COLOURCUBES = -- { -- day = "images/colour_cubes/mole_vision_off_cc.tex", -- dusk = "images/colour_cubes/mole_vision_on_cc.tex", -- night = "images/colour_cubes/mole_vision_on_cc.tex", -- full_moon = "images/colour_cubes/mole_vision_off_cc.tex", -- } -- AddPrefabPostInit("ocsayaka", function(inst) -- inst.nightvision = GLOBAL.net_bool(inst.GUID, "player.customvision", "flipvision") -- inst.nightvision:set_local(false) -- local function FlipFn(inst) -- local val = inst.nightvision:value() -- inst.components.playervision:ForceNightVision(val) -- inst.components.playervision:SetCustomCCTable(val and NIGHTVISION_COLOURCUBES or nil) -- end -- inst:ListenForEvent("flipvision", FlipFn) -- if GLOBAL.TheWorld.ismastersim then -- local function OnPhaseChange(inst, phase) -- inst.nightvision:set(phase == "night") -- end -- inst:WatchWorldState("phase", OnPhaseChange) -- OnPhaseChange(inst, GLOBAL.TheWorld.state.phase) -- end -- end) --Neutral shadows local function MakeNeutral(inst) if GLOBAL.TheWorld.ismastersim then local _CanTarget = inst.components.combat.CanTarget inst.components.combat.CanTarget = function(self, target) local ret = _CanTarget(self, target) if ret and target:HasTag("awaken") then local playertarget = target.components.combat.target local shadowtarget = playertarget and playertarget:HasTag("shadowcreature") if not shadowtarget then return false end end return ret end end end AddPrefabPostInit("crawlinghorror", MakeNeutral) AddPrefabPostInit("terrorbeak", MakeNeutral) AddPrefabPostInit("nightmarebeak", MakeNeutral) AddPrefabPostInit("crawlingnightmare", MakeNeutral) --End --Sayaka's Tab local ocsayakatab = AddRecipeTab( "Sayakas's Tab", 999, "images/hud/ocsayakatab.xml", "ocsayakatab.tex", "ocsayaka_builder") -- AddRecipe("ocsayakawhip", -- {GLOBAL.Ingredient("whip", 3), GLOBAL.Ingredient("goldnugget", 1), GLOBAL.Ingredient("feather_crow", 2)}, -- ocsayakatab, TECH.NONE, nil, nil, nil, nil, "ocsayaka_builder", -- "images/inventoryimages/ocsayakawhip.xml", "ocsayakawhip.tex" ) -- AddRecipe("ocsayakademonwhip", -- {GLOBAL.Ingredient("ocsayakasoul", 8, "images/inventoryimages/ocsayakasoul.xml"), GLOBAL.Ingredient("nightmarefuel", 5), GLOBAL.Ingredient("stinger", 5)}, -- ocsayakatab, TECH.NONE, nil, nil, nil, nil, "ocsayaka_builder", -- "images/inventoryimages/ocsayakademonwhip.xml", "ocsayakademonwhip.tex" ) -- AddRecipe("ocsayakarevolver", -- {GLOBAL.Ingredient("cutstone", 3), GLOBAL.Ingredient("gunpowder", 1), GLOBAL.Ingredient("goldnugget", 2), GLOBAL.Ingredient("marble", 3)}, -- ocsayakatab, TECH.NONE, nil, nil, nil, nil, "ocsayaka_builder", -- "images/inventoryimages/ocsayakarevolver.xml", "ocsayakarevolver.tex" ) AddRecipe("ocsayakabandana", {GLOBAL.Ingredient("pigskin", 2), GLOBAL.Ingredient("silk", 5), GLOBAL.Ingredient("rope", 1)}, ocsayakatab, TECH.NONE, nil, nil, nil, nil, "ocsayaka_builder", "images/inventoryimages/ocsayakabandana.xml", "ocsayakabandana.tex" ) AddRecipe("ocsayakasoul", {GLOBAL.Ingredient("nightmarefuel", 10)}, ocsayakatab, TECH.NONE, nil, nil, nil, nil, "ocsayaka_builder", "images/inventoryimages/ocsayakasoul.xml", "ocsayakasoul.tex" ) local ocsayakawhip_recipe = AddRecipe("ocsayakawhip", {GLOBAL.Ingredient("whip", 1), GLOBAL.Ingredient("feather_crow", 2)}, ocsayakatab, TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/ocsayakawhip.xml", "ocsayakawhip.tex") ocsayakawhip_recipe.tagneeded = false ocsayakawhip_recipe.builder_tag ="ocsayaka_builder" ocsayakawhip_recipe.atlas = resolvefilepath("images/inventoryimages/ocsayakawhip.xml") local ocsayakademonwhip_recipe = AddRecipe("ocsayakademonwhip", {GLOBAL.Ingredient("ocsayakasoul", 8, "images/inventoryimages/ocsayakasoul.xml"), GLOBAL.Ingredient("nightmarefuel", 5), GLOBAL.Ingredient("stinger", 5)}, ocsayakatab, TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/ocsayakademonwhip.xml", "ocsayakademonwhip.tex") ocsayakademonwhip_recipe.tagneeded = false ocsayakademonwhip_recipe.builder_tag ="ocsayaka_builder" ocsayakademonwhip_recipe.atlas = resolvefilepath("images/inventoryimages/ocsayakademonwhip.xml") local ocsayakarevolver_recipe = AddRecipe("ocsayakarevolver", {GLOBAL.Ingredient("gunpowder", 3), GLOBAL.Ingredient("transistor", 2), GLOBAL.Ingredient("marble", 3)}, ocsayakatab, TECH.NONE, nil, nil, nil, nil, nil, "images/inventoryimages/ocsayakarevolver.xml", "ocsayakarevolver.tex") ocsayakarevolver_recipe.tagneeded = false ocsayakarevolver_recipe.builder_tag ="ocsayaka_builder" ocsayakarevolver_recipe.atlas = resolvefilepath("images/inventoryimages/ocsayakarevolver.xml") -- Custom Recipe Desc STRINGS.RECIPE_DESC.OCSAYAKAWHIP = "My personal whip!" STRINGS.RECIPE_DESC.OCSAYAKADEMONWHIP = "I'll take that lust from you." STRINGS.RECIPE_DESC.OCSAYAKAREVOLVER = "No adventure is complete without one of these" STRINGS.RECIPE_DESC.OCSAYAKABANDANA = "They'll never know it was me." STRINGS.RECIPE_DESC.OCSAYAKASOUL = "A warm aura surrounds it." --No Sanity Loss -- local function nolosesanity(self) -- local _DoDelta = self.DoDelta -- self.DoDelta = function(self, delta, overtime) -- if self.inst:HasTag("awaken") then -- return -- end -- return _DoDelta(self, delta, overtime) -- end -- end -- AddComponentPostInit("sanity", nolosesanity) -- The character select screen lines STRINGS.CHARACTER_TITLES.ocsayaka = "The Adventurous Maiden." STRINGS.CHARACTER_NAMES.ocsayaka = "Sayaka" STRINGS.CHARACTER_DESCRIPTIONS.ocsayaka = "*Expert with using whips\n*Loves exploring and cooking\n*Has a dark demonic side" STRINGS.CHARACTER_QUOTES.ocsayaka = "\"Let's murderate em'\"" -- Custom speech strings STRINGS.CHARACTERS.OCSAYAKA = require "speech_ocsayaka" -- The character's name as appears in-game STRINGS.NAMES.OCSAYAKA = "Sayaka" GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.OCSAYAKABANDANA = "I guess this girl likes to play robber or something?" GLOBAL.STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.OCSAYAKABANDANA = "Does scarf girl want to hide face?" GLOBAL.STRINGS.CHARACTERS.WAXWELL.DESCRIBE.OCSAYAKABANDANA = "Yes, I would hide your face as well." GLOBAL.STRINGS.CHARACTERS.WX78.DESCRIBE.OCSAYAKABANDANA = "TARGET APPEARS TO BE PLAIN CLOTH." GLOBAL.STRINGS.CHARACTERS.WILLOW.DESCRIBE.OCSAYAKABANDANA = "Looks very flameable." GLOBAL.STRINGS.CHARACTERS.WENDY.DESCRIBE.OCSAYAKABANDANA = "I guess she played the wild west version of cops and robbers a lot..." GLOBAL.STRINGS.CHARACTERS.WOODIE.DESCRIBE.OCSAYAKABANDANA = "I would use that to wipe the sweat of my head, Eh?" GLOBAL.STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.OCSAYAKABANDANA = "Weird kid with her weird fetish." GLOBAL.STRINGS.CHARACTERS.WEBBER.DESCRIBE.OCSAYAKABANDANA = "So can I be the cop?" GLOBAL.STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.OCSAYAKABANDANA = "Are yöu afriad öf shöwing yöur face?" GLOBAL.STRINGS.CHARACTERS.WINONA.DESCRIBE.OCSAYAKABANDANA = "I got one of those as well at my shop." GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.OCSAYAKAWHIP = "Remember not to mess with her." GLOBAL.STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.OCSAYAKAWHIP = "Why scarf girl use this weak stick?" GLOBAL.STRINGS.CHARACTERS.WAXWELL.DESCRIBE.OCSAYAKAWHIP = "I feel sorry for her friends." GLOBAL.STRINGS.CHARACTERS.WX78.DESCRIBE.OCSAYAKAWHIP = "A WHIP MADE OF LEATHER TO PUNISH OTHER FLESHIES." GLOBAL.STRINGS.CHARACTERS.WILLOW.DESCRIBE.OCSAYAKAWHIP = "I leave's burning marks." GLOBAL.STRINGS.CHARACTERS.WENDY.DESCRIBE.OCSAYAKAWHIP = "Our mother used to punish me and Abigail with this." GLOBAL.STRINGS.CHARACTERS.WOODIE.DESCRIBE.OCSAYAKAWHIP = "You can't cut any tree with this, Eh?" GLOBAL.STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.OCSAYAKAWHIP = "Most teachers have something like this" GLOBAL.STRINGS.CHARACTERS.WEBBER.DESCRIBE.OCSAYAKAWHIP = "We spiders don't like to be whipped" GLOBAL.STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.OCSAYAKAWHIP = "A weak weapön." GLOBAL.STRINGS.CHARACTERS.WINONA.DESCRIBE.OCSAYAKAWHIP = "Yeah, you should keep that in the bed room." GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.OCSAYAKADEMONWHIP = "A soul tugging whip yikes." GLOBAL.STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.OCSAYAKADEMONWHIP = "Scarf girl use stronger weirder stick now?" GLOBAL.STRINGS.CHARACTERS.WAXWELL.DESCRIBE.OCSAYAKADEMONWHIP = "dark magic is flowing through this weapon" GLOBAL.STRINGS.CHARACTERS.WX78.DESCRIBE.OCSAYAKADEMONWHIP = "THIS WHIP IS MADE OF 5% LEATHER AND 95% LUST." GLOBAL.STRINGS.CHARACTERS.WILLOW.DESCRIBE.OCSAYAKADEMONWHIP = "I rather keep my soul burning than taken." GLOBAL.STRINGS.CHARACTERS.WENDY.DESCRIBE.OCSAYAKADEMONWHIP = "Looks scare, But the color is pretty." GLOBAL.STRINGS.CHARACTERS.WOODIE.DESCRIBE.OCSAYAKADEMONWHIP = "Trees don't have souls?, Eh?" GLOBAL.STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.OCSAYAKADEMONWHIP = "Looks like Maxwell isn't the only one who makes evil weapons" GLOBAL.STRINGS.CHARACTERS.WEBBER.DESCRIBE.OCSAYAKADEMONWHIP = "You are not going to take our soul right?" GLOBAL.STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.OCSAYAKADEMONWHIP = "A slightly strönger weapön." GLOBAL.STRINGS.CHARACTERS.WINONA.DESCRIBE.OCSAYAKADEMONWHIP = "Yeah, you should keep that in the dark room." GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.OCSAYAKAREVOLVER = "The female sherrif is in town." GLOBAL.STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.OCSAYAKAREVOLVER = "Why scarf girl play with gun?" GLOBAL.STRINGS.CHARACTERS.WAXWELL.DESCRIBE.OCSAYAKAREVOLVER = "Oh please, Guns are so last year." GLOBAL.STRINGS.CHARACTERS.WX78.DESCRIBE.OCSAYAKAREVOLVER = "WEAPON DETECTED! CAUTION ADVISED!" GLOBAL.STRINGS.CHARACTERS.WILLOW.DESCRIBE.OCSAYAKAREVOLVER = "Can it shoot fire bullets?" GLOBAL.STRINGS.CHARACTERS.WENDY.DESCRIBE.OCSAYAKAREVOLVER = "A thing that ended so many lives..." GLOBAL.STRINGS.CHARACTERS.WOODIE.DESCRIBE.OCSAYAKAREVOLVER = "I'm a lumberjack! Not a redneck!" GLOBAL.STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.OCSAYAKAREVOLVER = "Guns are forbidden here! Do you want to be expelled?" GLOBAL.STRINGS.CHARACTERS.WEBBER.DESCRIBE.OCSAYAKAREVOLVER = "That's a toy gun, right?" GLOBAL.STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.OCSAYAKAREVOLVER = "Önly cöwards use a weapön like this!" GLOBAL.STRINGS.CHARACTERS.WINONA.DESCRIBE.OCSAYAKAREVOLVER = "Now we only need some bottles and start shooting stuff." GLOBAL.STRINGS.CHARACTERS.GENERIC.DESCRIBE.OCSAYAKASOUL = "Does these things even have souls?" GLOBAL.STRINGS.CHARACTERS.WOLFGANG.DESCRIBE.OCSAYAKASOUL = "Why this come out monster?" GLOBAL.STRINGS.CHARACTERS.WAXWELL.DESCRIBE.OCSAYAKASOUL = "Oh my! I could use this for so many things!" GLOBAL.STRINGS.CHARACTERS.WX78.DESCRIBE.OCSAYAKASOUL = "LAST FABRIC OF LIFEFORCE FROM A KILLED MONSTER." GLOBAL.STRINGS.CHARACTERS.WILLOW.DESCRIBE.OCSAYAKASOUL = "BURN THE SOULS! MUHAHAHA!!" GLOBAL.STRINGS.CHARACTERS.WENDY.DESCRIBE.OCSAYAKASOUL = "I wish my soul was this pretty..." GLOBAL.STRINGS.CHARACTERS.WOODIE.DESCRIBE.OCSAYAKASOUL = "Who needs souls anyway? I have lucy, eh?" GLOBAL.STRINGS.CHARACTERS.WICKERBOTTOM.DESCRIBE.OCSAYAKASOUL = "Hmmm this is kinda intresting." GLOBAL.STRINGS.CHARACTERS.WEBBER.DESCRIBE.OCSAYAKASOUL = "We have two souls in one body!" GLOBAL.STRINGS.CHARACTERS.WATHGRITHR.DESCRIBE.OCSAYAKASOUL = "Söuls öf the brave fallen enemies shöuld gö tö Valhalla!" GLOBAL.STRINGS.CHARACTERS.WINONA.DESCRIBE.OCSAYAKASOUL = "I don't think I can put them back with tape." AddMinimapAtlas("images/map_icons/ocsayaka.xml") -- Add mod character to mod character list. Also specify a gender. Possible genders are MALE, FEMALE, ROBOT, NEUTRAL, and PLURAL. AddModCharacter("ocsayaka", "FEMALE") local myGetHealth = function(self, eater) local multiplier = 1 local healthvalue = self.gethealthfn ~= nil and self.gethealthfn(self.inst, eater) or self.healthvalue local ignore_spoilage = not self.degrades_with_spoilage or healthvalue < 0 or (eater ~= nil and eater.components.eater ~= nil and eater.components.eater.ignoresspoilage) if not ignore_spoilage and self.inst.components.perishable ~= nil then if self.inst.components.perishable:IsStale() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.stale_health or self.stale_health multiplier = multiplier * 0.5 elseif self.inst.components.perishable:IsSpoiled() then multiplier = 0 end end return multiplier * healthvalue end local myGetHunger = function(self, eater) local multiplier = 1 local ignore_spoilage = not self.degrades_with_spoilage or self.hungervalue < 0 or (eater ~= nil and eater.components.eater ~= nil and eater.components.eater.ignoresspoilage) if not ignore_spoilage and self.inst.components.perishable ~= nil then if self.inst.components.perishable:IsStale() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.stale_hunger or self.stale_hunger multiplier = multiplier * 0.5 elseif self.inst.components.perishable:IsSpoiled() then multiplier = eater ~= nil and eater.components.eater ~= nil and eater.components.eater.spoiled_hunger or self.spoiled_hunger multiplier = multiplier * 0.5 end end return multiplier * self.hungervalue end AddPrefabPostInit("monstermeat", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("cookedmonstermeat", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("monstermeat_dried", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("monsterlasagna", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return myGetHealth(self, eater) else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return myGetHunger(self, eater) else return old_gethunger(self, eater) end end end) AddPrefabPostInit("ocsayakasoul", function(inst) local old_gethealth = inst.components.edible.GetHealth inst.components.edible.GetHealth = function(self, eater) if eater:HasTag("awaken") then return (inst.components.edible:GetHealth(inst)+10)*-3 else return old_gethealth(self, eater) end end local old_gethunger = inst.components.edible.GetHunger inst.components.edible.GetHunger = function(self, eater) if eater:HasTag("awaken") then return inst.components.edible:GetHunger(inst)*-5 else return old_gethunger(self, eater) end end local old_getsanity = inst.components.edible.GetSanity inst.components.edible.GetSanity = function(self, eater) if eater:HasTag("awaken") then return inst.components.edible:GetSanity(inst)*-0.5 else return old_getsanity(self, eater) end end end) And for "ocsayakasoul" it originally decreased your health like for 10-12 health points and when you've eaten enough to die, it wasn't at 0 health, character died at 11 health points and ghost didn't spawn (that was a bug) so I tried to tweak it so it could give me positive health, and I only came up with that GetHealth(inst)+10)*-3 It gave +10 health but I wanted to make it +5 to balance it more but couldn't and I just kinda sticked with it And yes tested 2nd time, doesn't work same error Link to comment Share on other sites More sharing options...
YakumoYukari Posted January 17, 2019 Share Posted January 17, 2019 local powertable = { -- Rule : 10 per meat value 1, reduced by 25% when cooked or dried. P300 = {"minotaurhorn", "deerclops_eyeball", "tigereye"}, P100 = {"humanmeat"}, P80 = {"humanmeat_cooked", "humanmeat_dried"}, P40 = {"surfnturf"}, P30 = {"bonestew", "dragoonheart", "trunk_winter"}, P25 = {"baconeggs"}, P20 = {"honeyham", "tallbirdegg", "trunk_summer", "turkeydinner", "monsterlasagna"}, P15 = {"tallbirdegg_cooked", "trunk_cooked", "honeynuggets", "hotchili"}, P10 = {"meat", "plantmeat", "shark_fin", "fish", "fish_med", "perogies", "guacamole", "monstermeat"}, P8 = {"meat_dried", "plantmeat_cooked", "fish_med_cooked"}, P5 = {"smallmeat", "eel", "kabobs", "tropical_fish", "batwing", "froglegs", "bird_egg", "fish_raw_small", "meatballs", "frogglebunwich", "unagi", "drumstick" , "doydoyegg"}, P4 = {"monstermeat_dried", "cookedsmallmeat","froglegs_cooked","batwing_cooked", "fish_raw_small_cooked", "cookedmonstermeat", "smallmeat_dried", "eel_cooked", "doydoyegg_cooked", "drumstick_cooked", "bird_egg_cooked"} } local function oneat(inst, food) local key for k, v in pairs(powertable) do for k2, v2 in pairs(v) do if food.prefab == v2 then key = k local delta = tonumber(string.sub(key, 2)) if food.components.perishable ~= nil then delta = delta - delta * ( (1 - food.components.perishable:GetPercent()) * STATUS.POWER_RESTORE_PERISH_MULT ) end DoPowerRestore(inst, delta) break end end end end https://github.com/HimekaidouHatate/YakumoYukari-DST/blob/master/scripts/prefabs/yakumoyukari.lua Refer my code would help. I have implemented the feature in my code that restores the specific amount of a custom stat(called power) related food spoilage. Also, staled or spoiled food has a tag named "staled", "spoiled". So use those too. Link to comment 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