nein228 Posted December 18, 2021 Share Posted December 18, 2021 (edited) \English is not my native language, the sentences may be strange. sorry. I copied Wigfrid's singing ability to custom character, but it doesn't work properly on the client. Several attempts have been made, but all have failed. I don't know how to fix it... How do I make it work on the client as well? I have attached the full script of the character here. It is a mod to be used with a friend, so it must be fixed. please help! Any help would be greatly appreciated... eta.lua Spoiler local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } -- Your character's stats TUNING.ETA_HEALTH = 250 TUNING.ETA_HUNGER = 150 TUNING.ETA_SANITY = 100 -- Custom starting inventory TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.ETA = { "eword", "battlesong_sanityaura", "battlesong_sanitygain" } local start_inv = {} for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do start_inv[string.lower(k)] = v.ETA end local prefabs = FlattenTree(start_inv, true) -- When the character is revived from human local function onbecamehuman(inst) -- Set speed when not a ghost (optional) inst.components.locomotor:SetExternalSpeedMultiplier(inst, "eta_speed_mod", 1) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "eta_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 -- This initializes for both the server and client. Tags can be added here. local common_postinit = function(inst) inst:AddTag("battlesinger") inst.AnimState:AddOverrideBuild("wathgrithr_sing") -- Minimap icon inst.MiniMapEntity:SetIcon( "eta.tex" ) end -- Perfect Self perk, stolen from Senshimi (again (well not quite but...) ) -- local function IsValidVictim(victim) return victim ~= nil and not ((victim:HasTag("prey") and not victim:HasTag("hostile")) or victim:HasTag("veggie") or victim:HasTag("structure") or victim:HasTag("wall") or victim:HasTag("balloon") or victim:HasTag("groundspike") or victim:HasTag("smashable") or victim:HasTag("companion")) and victim.components.health ~= nil and victim.components.combat ~= nil end local function GetInspiration(inst) if inst.components.singinginspiration ~= nil then return inst.components.singinginspiration:GetPercent() elseif inst.player_classified ~= nil then return inst.player_classified.currentinspiration:value() / TUNING.INSPIRATION_MAX else return 0 end end local function GetInspirationSong(inst, slot) if inst.components.singinginspiration ~= nil then return inst.components.singinginspiration:GetActiveSong(slot) elseif inst.player_classified ~= nil then return INSPIRATION_BATTLESONG_DEFS.GetBattleSongDefFromNetID(inst.player_classified.inspirationsongs[slot] ~= nil and inst.player_classified.inspirationsongs[slot]:value() or 0) else return nil end end local function CalcAvailableSlotsForInspiration(inst, inspiration_precent) inspiration_precent = inspiration_precent or GetInspiration(inst) local slots_available = 0 for i = #TUNING.BATTLESONG_THRESHOLDS, 1, -1 do if inspiration_precent > TUNING.BATTLESONG_THRESHOLDS[i] then slots_available = i break end end return slots_available end -- This initializes for the server only. Components are added here. local master_postinit = function(inst) -- Set starting inventory inst.starting_inventory = start_inv[TheNet:GetServerGameMode()] or start_inv.default -- 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/" -- Stats inst.components.health:SetMaxHealth(TUNING.ETA_HEALTH) inst.components.hunger:SetMax(TUNING.ETA_HUNGER) inst.components.sanity:SetMax(TUNING.ETA_SANITY) inst.components.sanity.night_drain_mult = 1.5 inst.components.sanity.neg_aura_mult = 1.3 inst:AddComponent("singinginspiration") inst.components.singinginspiration:SetCalcAvailableSlotsForInspirationFn(CalcAvailableSlotsForInspiration) inst.components.singinginspiration:SetValidVictimFn(IsValidVictim) inst.GetInspiration = GetInspiration inst.GetInspirationSong = GetInspirationSong inst.CalcAvailableSlotsForInspiration = CalcAvailableSlotsForInspiration -- Damage multiplier (optional) inst.components.combat.damagemultiplier = TUNING.WATHGRITHR_DAMAGE_MULT inst.components.health:SetAbsorptionAmount(TUNING.WATHGRITHR_ABSORPTION) -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.customidleanim = "idle_wathgrithr" inst.OnLoad = onload inst.OnNewSpawn = onload -- DoPeriodicTask calls the given function every X seconds. -- I set it to 1.0. You can set it to e.g. 0.5 seconds if you want. inst:DoPeriodicTask(1.0, function(inst) -- Do nothing if the player is dead. if inst.components.health:IsDead() or inst:HasTag("playerghost") then return end -- Store the position of the player in x, y, z variables. local x,y,z = inst.Transform:GetWorldPosition() -- Description of important function, which finds specific entities within a range: -- TheSim:FindEntities(x, y, z, radius, mustHaveTags, cantHaveTags, mustHaveOneOfTheseTags) -- We have limited it to any player that is not a ghost or in limbo. -- I have set the radius to be the one used for standard negative auras. You can set it to whatever radius you want. local ents = TheSim:FindEntities(x, y, z, TUNING.SANITY_EFFECT_RANGE, {"player"}, {"playerghost", "INLIMBO"}, nil) for i, v in ipairs(ents) do if v and v:IsValid() and v.prefab == "gamma" then inst.components.sanity:DoDelta(0.2, true) -- "true" disables the pulse on the badge and disables that it plays a sound. end end end) end return MakePlayerCharacter("eta", prefabs, assets, common_postinit, master_postinit, prefabs) Edited December 18, 2021 by nein228 Link to comment https://forums.kleientertainment.com/forums/topic/136283-help-custom-character-mod-not-working-on-client/ 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