Diamantes Posted January 20, 2015 Share Posted January 20, 2015 Hi, on my first mod i noticed that there's a bug, when you die you don't have the same movement speed as before you die.(On my mod the character is upgradable).Anyone knows why it happens? Prefab:local MakePlayerCharacter = require "prefabs/player_common"local assets = {Asset( "ANIM", "anim/player_basic.zip" ),Asset( "ANIM", "anim/player_idles_shiver.zip" ),Asset( "ANIM", "anim/player_actions.zip" ),Asset( "ANIM", "anim/player_actions_axe.zip" ),Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),Asset( "ANIM", "anim/player_actions_shovel.zip" ),Asset( "ANIM", "anim/player_actions_blowdart.zip" ),Asset( "ANIM", "anim/player_actions_eat.zip" ),Asset( "ANIM", "anim/player_actions_item.zip" ),Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),Asset( "ANIM", "anim/player_actions_bugnet.zip" ),Asset( "ANIM", "anim/player_actions_fishing.zip" ),Asset( "ANIM", "anim/player_actions_boomerang.zip" ),Asset( "ANIM", "anim/player_bush_hat.zip" ),Asset( "ANIM", "anim/player_attacks.zip" ),Asset( "ANIM", "anim/player_idles.zip" ),Asset( "ANIM", "anim/player_rebirth.zip" ),Asset( "ANIM", "anim/player_jump.zip" ),Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),Asset( "ANIM", "anim/player_teleport.zip" ),Asset( "ANIM", "anim/wilson_fx.zip" ),Asset( "ANIM", "anim/player_one_man_band.zip" ),Asset( "ANIM", "anim/shadow_hands.zip" ),Asset( "SOUND", "sound/sfx.fsb" ),Asset( "SOUND", "sound/wilson.fsb" ),Asset( "ANIM", "anim/beard.zip" ),Asset( "ANIM", "anim/pedobear.zip" ),Asset( "ANIM", "anim/ghost_pedobear_build.zip" ),}local prefabs = {}local start_inv = {"spear","backpack",}--upgradeslocal function applyupgrades(inst)local max_upgrades = 30local upgrades = 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()inst.components.hunger.max = math.ceil (100 + upgrades * 2) --160inst.components.health.maxhealth = math.ceil (100 + upgrades * 3.33) --200inst.components.sanity.max = math.ceil (100 + upgrades * 2) --160inst.components.locomotor.walkspeed = math.ceil (6 + upgrades / 15)inst.components.locomotor.runspeed = math.ceil (8 + upgrades / 15)inst.components.combat.damagemultiplier = math.ceil (1.1 + upgrades / 60) --10inst.components.talker:Say("Level : ".. (inst.level))if inst.level >29 theninst.components.talker:Say("Level : Max!")endinst.components.hunger:SetPercent(hunger_percent)inst.components.health:SetPercent(health_percent)inst.components.sanity:SetPercent(sanity_percent)endlocal function oneat(inst, food)--if food and food.components.edible and food.components.edible.foodtype == "HELLO" thenif food and food.components.edible and food.prefab == "honey" or food.prefab == "butter" then--give an upgrade!inst.level = inst.level + 1applyupgrades(inst)inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")endend-- This initializes for both clients and the hostlocal common_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "willow"-- Minimap iconinst.MiniMapEntity:SetIcon( "pedobear.tex" )endlocal function onpreload(inst, data)if data thenif data.level theninst.level = data.levelapplyupgrades(inst)--re-set these from the save data, because of load-order clipping issuesif data.health and data.health.health then inst.components.health.currenthealth = data.health.health endif data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger endif data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current endinst.components.health:DoDelta(0)inst.components.hunger:DoDelta(0)inst.components.sanity:DoDelta(0)endendendlocal function onsave(inst, data)data.level = inst.leveldata.charge_time = inst.charge_timeend-- This initializes for the host onlylocal master_postinit = function(inst)inst.level = 0inst.components.eater:SetOnEatFn(oneat)applyupgrades(inst)--statsinst.components.health:SetMaxHealth(100)inst.components.hunger:SetMax(100)inst.components.sanity:SetMax(100)inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.5) -- -1 every 4 secsendreturn MakePlayerCharacter("pedobear", prefabs, assets, common_postinit, master_postinit, start_inv) Link to comment https://forums.kleientertainment.com/forums/topic/49449-movement-speed-resets-on-death/ Share on other sites More sharing options...
Auth Posted January 20, 2015 Share Posted January 20, 2015 Hi, on my first mod i noticed that there's a bug, when you die you don't have the same movement speed as before you die.(On my mod the character is upgradable).Anyone knows why it happens? Prefab:local MakePlayerCharacter = require "prefabs/player_common"local assets = {Asset( "ANIM", "anim/player_basic.zip" ),Asset( "ANIM", "anim/player_idles_shiver.zip" ),Asset( "ANIM", "anim/player_actions.zip" ),Asset( "ANIM", "anim/player_actions_axe.zip" ),Asset( "ANIM", "anim/player_actions_pickaxe.zip" ),Asset( "ANIM", "anim/player_actions_shovel.zip" ),Asset( "ANIM", "anim/player_actions_blowdart.zip" ),Asset( "ANIM", "anim/player_actions_eat.zip" ),Asset( "ANIM", "anim/player_actions_item.zip" ),Asset( "ANIM", "anim/player_actions_uniqueitem.zip" ),Asset( "ANIM", "anim/player_actions_bugnet.zip" ),Asset( "ANIM", "anim/player_actions_fishing.zip" ),Asset( "ANIM", "anim/player_actions_boomerang.zip" ),Asset( "ANIM", "anim/player_bush_hat.zip" ),Asset( "ANIM", "anim/player_attacks.zip" ),Asset( "ANIM", "anim/player_idles.zip" ),Asset( "ANIM", "anim/player_rebirth.zip" ),Asset( "ANIM", "anim/player_jump.zip" ),Asset( "ANIM", "anim/player_amulet_resurrect.zip" ),Asset( "ANIM", "anim/player_teleport.zip" ),Asset( "ANIM", "anim/wilson_fx.zip" ),Asset( "ANIM", "anim/player_one_man_band.zip" ),Asset( "ANIM", "anim/shadow_hands.zip" ),Asset( "SOUND", "sound/sfx.fsb" ),Asset( "SOUND", "sound/wilson.fsb" ),Asset( "ANIM", "anim/beard.zip" ),Asset( "ANIM", "anim/pedobear.zip" ),Asset( "ANIM", "anim/ghost_pedobear_build.zip" ),}local prefabs = {}local start_inv = {"spear","backpack",}--upgradeslocal function applyupgrades(inst)local max_upgrades = 30local upgrades = 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()inst.components.hunger.max = math.ceil (100 + upgrades * 2) --160inst.components.health.maxhealth = math.ceil (100 + upgrades * 3.33) --200inst.components.sanity.max = math.ceil (100 + upgrades * 2) --160inst.components.locomotor.walkspeed = math.ceil (6 + upgrades / 15)inst.components.locomotor.runspeed = math.ceil (8 + upgrades / 15)inst.components.combat.damagemultiplier = math.ceil (1.1 + upgrades / 60) --10inst.components.talker:Say("Level : ".. (inst.level))if inst.level >29 theninst.components.talker:Say("Level : Max!")endinst.components.hunger:SetPercent(hunger_percent)inst.components.health:SetPercent(health_percent)inst.components.sanity:SetPercent(sanity_percent)endlocal function oneat(inst, food)--if food and food.components.edible and food.components.edible.foodtype == "HELLO" thenif food and food.components.edible and food.prefab == "honey" or food.prefab == "butter" then--give an upgrade!inst.level = inst.level + 1applyupgrades(inst)inst.SoundEmitter:PlaySound("dontstarve/characters/wx78/levelup")endend-- This initializes for both clients and the hostlocal common_postinit = function(inst)-- choose which sounds this character will playinst.soundsname = "willow"-- Minimap iconinst.MiniMapEntity:SetIcon( "pedobear.tex" )endlocal function onpreload(inst, data)if data thenif data.level theninst.level = data.levelapplyupgrades(inst)--re-set these from the save data, because of load-order clipping issuesif data.health and data.health.health then inst.components.health.currenthealth = data.health.health endif data.hunger and data.hunger.hunger then inst.components.hunger.current = data.hunger.hunger endif data.sanity and data.sanity.current then inst.components.sanity.current = data.sanity.current endinst.components.health:DoDelta(0)inst.components.hunger:DoDelta(0)inst.components.sanity:DoDelta(0)endendendlocal function onsave(inst, data)data.level = inst.leveldata.charge_time = inst.charge_timeend-- This initializes for the host onlylocal master_postinit = function(inst)inst.level = 0inst.components.eater:SetOnEatFn(oneat)applyupgrades(inst)--statsinst.components.health:SetMaxHealth(100)inst.components.hunger:SetMax(100)inst.components.sanity:SetMax(100)inst.components.hunger:SetRate(TUNING.WILSON_HUNGER_RATE * 1.5) -- -1 every 4 secsendreturn MakePlayerCharacter("pedobear", prefabs, assets, common_postinit, master_postinit, start_inv) i thought upgrades always reset upon death? i dont know, Ive never tinkered with upgrades. Link to comment https://forums.kleientertainment.com/forums/topic/49449-movement-speed-resets-on-death/#findComment-604083 Share on other sites More sharing options...
rezecib Posted January 20, 2015 Share Posted January 20, 2015 @Diamantes, Movement speed gets reset on transforming to a ghost and back, because it reconfigures the locomotor component. So you need to listen for ms_respawnedfromghost, passing a function that restores your speed based on your current upgrades. But keep in mind that unless you wrote networking to send the current speed to the clients, clients will not see that they are faster due to client action prediction. Link to comment https://forums.kleientertainment.com/forums/topic/49449-movement-speed-resets-on-death/#findComment-604099 Share on other sites More sharing options...
Diamantes Posted January 21, 2015 Author Share Posted January 21, 2015 Thanks. Link to comment https://forums.kleientertainment.com/forums/topic/49449-movement-speed-resets-on-death/#findComment-604395 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