wayjieuus Posted February 23, 2023 Share Posted February 23, 2023 Hi! I am not great at coding and I want to make a character mod with my friend, but we want a character, who can revive after a couple second, but with a little low stats. I can't find an example for my code, so I'm a little confused about it. Link to comment https://forums.kleientertainment.com/forums/topic/146121-how-can-i-make-a-character-who-automatically-reviving-after-a-death/ Share on other sites More sharing options...
Merkyrrie Posted February 23, 2023 Share Posted February 23, 2023 Do you want the stats to simply not start at max value, or for the max value to be lowered like what happens to your health when revived with a telltale heart? Either way, you can do this with a DoTaskInTime in the onbecameghost function in your character prefab (If you're starting from the template) Spoiler -- New function, somewhere above onbecameghost local function DoRessurect(inst) if inst:HasTag("playerghost") then inst:PushEvent("respawnfromghost") -- This sends a pushevent which is listened to in player_common_extensions that handles respawning end if inst.revivetimer ~= nil then inst.revivetimer:Cancel() inst.revivetimer = nil end end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "mycharacter_speed_mod") -- The new parts of this function, RemoveExternalSpeedMultiplier above should already be here if inst.revivetimer ~= nil then inst.revivetimer:Cancel() end inst.revivetimer = inst:DoTaskInTime(5, DoRessurect) -- 5 can be whatever you want, I recommend adding a TUNING variable in your modmain to handle the number, so it can be changed easily along with other TUNING variables you might add end This will already spawn you with lowered stats, but they may not be what you want them to be yet 1 Link to comment https://forums.kleientertainment.com/forums/topic/146121-how-can-i-make-a-character-who-automatically-reviving-after-a-death/#findComment-1621741 Share on other sites More sharing options...
wayjieuus Posted February 24, 2023 Author Share Posted February 24, 2023 11 hours ago, Merkyrrie said: Do you want the stats to simply not start at max value, or for the max value to be lowered like what happens to your health when revived with a telltale heart? Either way, you can do this with a DoTaskInTime in the onbecameghost function in your character prefab (If you're starting from the template) Hide contents -- New function, somewhere above onbecameghost local function DoRessurect(inst) if inst:HasTag("playerghost") then inst:PushEvent("respawnfromghost") -- This sends a pushevent which is listened to in player_common_extensions that handles respawning end if inst.revivetimer ~= nil then inst.revivetimer:Cancel() inst.revivetimer = nil end end local function onbecameghost(inst) -- Remove speed modifier when becoming a ghost inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "mycharacter_speed_mod") -- The new parts of this function, RemoveExternalSpeedMultiplier above should already be here if inst.revivetimer ~= nil then inst.revivetimer:Cancel() end inst.revivetimer = inst:DoTaskInTime(5, DoRessurect) -- 5 can be whatever you want, I recommend adding a TUNING variable in your modmain to handle the number, so it can be changed easily along with other TUNING variables you might add end This will already spawn you with lowered stats, but they may not be what you want them to be yet Thank you so much for help! but I don't think I wrote it right..? Link to comment https://forums.kleientertainment.com/forums/topic/146121-how-can-i-make-a-character-who-automatically-reviving-after-a-death/#findComment-1621776 Share on other sites More sharing options...
Merkyrrie Posted February 24, 2023 Share Posted February 24, 2023 There doesn't need to be a second onbecameghost function, the DoRessurect function can be out on its own. Just delete lines 32-34 and line 44 Link to comment https://forums.kleientertainment.com/forums/topic/146121-how-can-i-make-a-character-who-automatically-reviving-after-a-death/#findComment-1621838 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