2badatmodding Posted November 22, 2023 Share Posted November 22, 2023 (edited) Hello using Ultraman's tutorials i used the code in this and the only thing not working is my character goes invincible when in their second form. here is my code local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/wombo.zip" ), Asset( "ANIM", "anim/evilwombo.zip" ), } local MakePlayerCharacter = require "prefabs/player_common" local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), } local prefabs = {} -- Your character's stats TUNING.WOMBO_HEALTH = 120 TUNING.WOMBO_HUNGER = 120 TUNING.WOMBO_SANITY = 100 -- Custom starting inventory TUNING.GAMEMODE_STARTING_ITEMS.DEFAULT.WOMBO = { } local start_inv = {} for k, v in pairs(TUNING.GAMEMODE_STARTING_ITEMS) do start_inv[string.lower(k)] = v.WOMBO 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, "esctemplate_speed_mod", 1) end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "esctemplate_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("playermonster") -- inst:AddTag("monster") -- Minimap icon inst.MiniMapEntity:SetIcon( "wombo.tex" ) end -- abstraction form local isInSecondForm = false local function TurnBackToNormal(inst) -- Do whatever is needed to be in the normal state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("wombo") isInSecondForm = false end local function TurnIntoSecondForm(inst) -- Do whatever is needed to be in the shadow creature state. -- You at least need to change the animation build, if your character needs to look different. inst.AnimState:SetBuild("evilwombo") isInSecondForm = true end local function OnSanityDrop(inst, data) -- Make sure not to react while the player is dead. if inst:HasTag("playerghost") or inst.components.health and inst.components.health:IsDead() then return end -- If sanity drops below 1, we become a shadow creature. if not isInSecondForm and inst.components.sanity.current < 1 then TurnIntoSecondForm(inst) -- Otherwise, if sanity gets back above 50, we become normal again. elseif isInSecondForm and inst.components.sanity.current > 50 then TurnBackToNormal(inst) end 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 = "willow" -- Uncomment if "wathgrithr"(Wigfrid) or "webber" voice is used --inst.talker_path_override = "dontstarve_DLC001/characters/" -- Stats inst.components.health:SetMaxHealth(TUNING.WOMBO_HEALTH) inst.components.hunger:SetMax(TUNING.WOMBO_HUNGER) inst.components.sanity:SetMax(TUNING.WOMBO_SANITY) -- Damage multiplier (optional) inst.components.combat.damagemultiplier = 1 -- Hunger rate (optional) inst.components.hunger.hungerrate = 1 * TUNING.WILSON_HUNGER_RATE inst.OnLoad = onload inst.OnNewSpawn = onload -- Put this in master_postinit function inst:ListenForEvent("sanitydelta", OnSanityDrop) end return MakePlayerCharacter("wombo", prefabs, assets, common_postinit, master_postinit, prefabs) EDIT: turns it i misplaced local assets = { Asset("SCRIPT", "scripts/prefabs/player_common.lua"), Asset( "ANIM", "anim/pomni.zip" ), Asset( "ANIM", "anim/abstraction.zip" ), } All fixed Edited November 22, 2023 by 2badatmodding Link to comment https://forums.kleientertainment.com/forums/topic/152555-invinsible-when-in-second-form-fixed/ 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