ScrewdriverLad Posted October 4, 2022 Share Posted October 4, 2022 I'm making a character that will die every 22 Minutes - no stopping it, but they have their own way to revive themselves. However, I'm not sure how I would do that. I've been looking at Wanda and I saw a few various strings that could help, but I honestly need some help. Is there anyone I could talk to who can help with this? Additional information: I want a specific song to begin quietly playing once they've got about 2 minutes left, and I want them to be able to revive without losing any max HP. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/ Share on other sites More sharing options...
Rickzzs Posted October 5, 2022 Share Posted October 5, 2022 Your description reminds me of Outer Wilds where the world dies every serveral minutes. Wanda's mechanism is that she loses health constantly. While a general way to trigger immediate death is using timer component and wait to push a death event, with no penalty. If you want an age-like countdown, it is possible that you add Wanda's clock to the UI, or something like Nightmare Phase Indicator mod. You may want to save health when death and set it when resurrection. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1600965 Share on other sites More sharing options...
ScrewdriverLad Posted October 7, 2022 Author Share Posted October 7, 2022 On 10/4/2022 at 6:33 PM, Rickzzs said: Your description reminds me of Outer Wilds where the world dies every serveral minutes. Wanda's mechanism is that she loses health constantly. While a general way to trigger immediate death is using timer component and wait to push a death event, with no penalty. If you want an age-like countdown, it is possible that you add Wanda's clock to the UI, or something like Nightmare Phase Indicator mod. You may want to save health when death and set it when resurrection. You know, that's actually what the mod is for! I'm making the Hatchling as a character! Do you know of some guide that I could use to get a more detailed, step-by-step explanation? Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1601568 Share on other sites More sharing options...
Boogiepop210 Posted October 8, 2022 Share Posted October 8, 2022 On 10/4/2022 at 3:27 PM, ScrewdriverLad said: I'm making a character that will die every 22 Minutes - no stopping it, but they have their own way to revive themselves. However, I'm not sure how I would do that. I've been looking at Wanda and I saw a few various strings that could help, but I honestly need some help. Is there anyone I could talk to who can help with this? Additional information: I want a specific song to begin quietly playing once they've got about 2 minutes left, and I want them to be able to revive without losing any max HP. The death part I can do function whatever(inst) -- you can name the function whatever if inst.components.health and not inst.components.health:IsDead() or inst:HasTag("playerghost") then inst:PushEvent("death") end inst:DoPeriodicTask(1620, whatever, 1620) or function whatever(inst) -- you can name the function whatever if inst.components.health and not inst.components.health:IsDead() or inst:HasTag("playerghost") then inst.components.health:Kill() end inst:DoPeriodicTask(1620, whatever, 1620) I'm pretty bad at doing modding I'm better at using the console but that should work. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1601673 Share on other sites More sharing options...
Rickzzs Posted October 8, 2022 Share Posted October 8, 2022 (edited) I'll explain it further. First, you want to wait for 22 minutes. So you write in prefabpostinit function that if not inst.components.timer then inst:AddComponent("timer") end inst.components.timer:StartTimer("when the sun explodes",22*60) function YouGetKilled(data) -- check if it is our timer if not data or data.name~="when the sun explodes" then return end -- kill yourself here end inst:ListenForEvent("timerdone", YouGetKilled) Second, kill your self if inst.components.health then if not inst.components.health:IsDead() then inst.components.health:Kill() end end -- revive yourself here Third, revive your self -- assume you have a home if inst.components.homeseeker then inst.Transform:SetPosition(inst.components.homeseeker:GetHomePos()) end -- revive inst:PushEvent("ms_respawnedfromghost") Last, don't forget to start another timer inst:ListenForEvent("ms_respawnedfromghost", function() if inst.components.timer:TimerExist("when the sun explodes") then inst.components.timer:StopTimer("when the sun explodes") end inst.components.timer:StartTimer("when the sun explodes",60*22) end) Edited October 15, 2022 by Rickzzs Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1601731 Share on other sites More sharing options...
ScrewdriverLad Posted October 9, 2022 Author Share Posted October 9, 2022 Woah, thank you both for the help! Rickzzs, what do you mean with the "--assume you have a home"? Would that be, say, a meat effigy or something similar? Spoiler I plan on giving them a Nomai Mask that revives them, so it would likely work the same. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1601879 Share on other sites More sharing options...
Rickzzs Posted October 9, 2022 Share Posted October 9, 2022 4 hours ago, ScrewdriverLad said: Woah, thank you both for the help! Rickzzs, what do you mean with the "--assume you have a home"? Would that be, say, a meat effigy or something similar? Hide contents I plan on giving them a Nomai Mask that revives them, so it would likely work the same. Hatchling does have a home, so a direct way to code such thing is by adding homeseeker component. And you can define where Hatchling's home is, like a spaceship. Still it is up to you to decide. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1601912 Share on other sites More sharing options...
ScrewdriverLad Posted October 9, 2022 Author Share Posted October 9, 2022 11 hours ago, Rickzzs said: Hatchling does have a home, so a direct way to code such thing is by adding homeseeker component. And you can define where Hatchling's home is, like a spaceship. Still it is up to you to decide. Alright! How do I set components? sorry for all these questions, I'm still pretty unfamiliar with lua... Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1602027 Share on other sites More sharing options...
Rickzzs Posted October 10, 2022 Share Posted October 10, 2022 5 hours ago, ScrewdriverLad said: Alright! How do I set components? sorry for all these questions, I'm still pretty unfamiliar with lua... Sorry for not providing examples, but as for grammar things, you can either learn from documents and tutorials, or learn from official codes and mods. There are tutorials in this forum to tell you what a component is, and there are official codes and mods out there, where you can copy&paste. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1602113 Share on other sites More sharing options...
ScrewdriverLad Posted October 10, 2022 Author Share Posted October 10, 2022 15 hours ago, Rickzzs said: Sorry for not providing examples, but as for grammar things, you can either learn from documents and tutorials, or learn from official codes and mods. There are tutorials in this forum to tell you what a component is, and there are official codes and mods out there, where you can copy&paste. That's totally fine! Thank you so much! On 10/8/2022 at 7:14 AM, Rickzzs said: I'll explain it further. First, you want to wait for 22 minutes. So you write in prefabpostinit function that if not inst.components.timer then inst:AddComponent("timer") end inst.components.timer:StartTimer("when the sun explodes",22*60) function YouGetKilled() -- kill yourself here end inst:ListenForEvent("timerdone", YouGetKilled) Second, kill your self if inst.components.health then if not inst.components.health:IsDead() then inst.components.health:Kill() end end -- revive yourself here Third, revive your self -- assume you have a home if inst.components.homeseeker then inst.Transform:SetPosition(inst.components.homeseeker:GetHomePos()) end -- revive inst:PushEvent("ms_respawnedfromghost") Last, don't forget to start another timer inst:ListenForEvent("ms_respawnedfromghost", function() if inst.components.timer:TimerExist("when the sun explodes") then inst.components.timer:StopTimer("when the sun explodes") end inst.components.timer:StartTimer("when the sun explodes",60*22) end) Oh, and one last thing! I would be putting these into the character's lua file, right? (In this case, warthian.lua?) Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1602199 Share on other sites More sharing options...
Rickzzs Posted October 10, 2022 Share Posted October 10, 2022 Yes, and you can open any character's file and start to copy from its fn/master_init/common_init. Link to comment https://forums.kleientertainment.com/forums/topic/143566-how-do-i-make-a-character-with-a-timer/#findComment-1602258 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