MarfMasterofDesaster Posted May 30, 2017 Share Posted May 30, 2017 The code: local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} local start_inv = { } 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 local common_postinit = function(inst) inst.MiniMapEntity:SetIcon( "marf.tex" ) inst:AddTag("master") end local function applyupgrades(inst) local max_upgrades = 46 inst.level = math.min(inst.level, max_upgrades) local hunger_percent = inst.components.hunger:GetPercent() local health_percent = inst.components.health:GetPercent() local sanity_percent = inst.components.sanity:GetPercent() local locomotorwalkspeed_percent = inst.components.locomotor.walkspeed:GetNumber() local locomotorrunspeed_percent = inst.components.locomotor.runspeed:GetNumber() local combatdamagemultiplier_percent = inst.components.combat.damagemultiplier:GetNumber() inst.components.hunger.max = math.ceil(75 + inst.level * (250 - 75) / max_upgrades) inst.components.health.maxhealth = math.ceil(100 + inst.level * (350 - 75) / max_upgrades) inst.components.sanity.max = math.ceil(300 + inst.level * (100 - 300) / max_upgrades) inst.components.locomotor.walkspeed = math.ceil(3.5 + inst.level * (5 - 3.5) / max_upgrades) inst.components.locomotor.runspeed = math.ceil(5.25 + inst.level * (7.5 - 5.25) / max_upgrades) inst.components.combat.damagemultiplier = math.ceil(0.83 + inst.level * (1.66 - 0.83) / max_upgrades) inst.components.hunger:SetPercent(hunger_percent) inst.components.health:SetPercent(health_percent) inst.components.sanity:SetPercent(sanity_percent) inst.components.locomotor.walkspeed:SetPercent(locomotorwalkspeed_percent) inst.components.locomotor.runspeed:SetPercent(locomotorrunspeed_percent) inst.components.combat.damagemultiplier(combatdamagemultiplier_percent) end local function oneat(inst, food) if food and food.components.edible and food.components.edible.foodtype == FOODTYPE.GEARS then --give an upgrade! inst.level = inst.level + 1 applyupgrades(inst) inst.HUD.controls.status.heart:PulseGreen() inst.HUD.controls.status.stomach:PulseGreen() inst.HUD.controls.status.brain:PulseRed() end end local function onpreload(inst, data) if data ~= nil and data.level ~= nil then inst.level = data.level applyupgrades(inst) --re-set these from the save data, because of load-order clipping issues if data.health and data.health.health then inst.components.health:SetCurrentHealth(data.health.health) end if data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger end if data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current end if data.locomotor.walkspeed and data.locomotor.walkspeed.current then inst.components.locomotor.walkspeed.current = data.locomotor.walkspeed.current end if data.locomotor.runspeed and data.locomotor.runspeed.current then inst.components.locomotor.runspeed.current = data.locomotor.runspeed.current end if data.combat.damagemultiplier and data.combat.damagemultiplier.current then inst.components.combat.damagemultiplier.current = data.combat.damagemultiplier.current end inst.components.health:DoDelta(0) inst.components.hunger:DoDelta(0) inst.components.sanity:DoDelta(0) inst.components.locomotor.walkspeed:DoDelta(0) inst.components.locomotor.runspeed:DoDelta(0) inst.components.combat.damagemultiplier:DoDelta(0) end end local function onsave(inst, data) data.level = inst.level > 0 and inst.level or nil end local master_postinit = function(inst) inst.soundsname = "wilson" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" inst.components.health:SetMaxHealth(100) inst.components.hunger:SetMax(75) inst.components.sanity:SetMax(300) inst.components.locomotor.walkspeed = 3.5 inst.components.locomotor.runspeed = 5.25 inst.components.combat.damagemultiplier = 0.83 inst.components.hunger.hungerrate = 1.66 * TUNING.WILSON_HUNGER_RATE inst.components.sanity.neg_aura_mult = 1.33 inst.components.sanity.night_drain_mult = 0 inst.level = 0 inst.components.eater:SetCanEatGears() inst.components.eater:SetOnEatFn(oneat) applyupgrades(inst) inst.components.reader = true inst.OnLoad = onload inst.OnNewSpawn = onload inst.OnPreload = onpreload inst.OnSave = onsave end return MakePlayerCharacter("marf", prefabs, assets, common_postinit, master_postinit, start_inv) I don't know how to tell it that locomotor walk and runspeed are different values, damagemultiplier too. Is it even possible? Please help me with this. 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