Struggling with a passive regeneration
Hello, uhm... I'm working with a mod for a game which is not really my own, I've "owned" the mod for a couple years now but the mod was not originally my own, I mention that because I don't really understand how everything in here actually works? Anyways, what I'm currently struggling to do is add a little bit of passive regneration to a dome shield. In the screenshot are two bits of code, the top half is unrelated to passive regenration but you can see the bottom half is heavily based off the top half. What the top half does is check to see if the shield is at or above 40% health while the shield is off, in which case it will turn itself back on (and set the
CurrentDamageSustained
to 40% of ShieldStats.MaxEnergy
. The bottom half is my attempt to add a passive regeneration. What I'm wanting to do is, if the shield is on and not at full health, regenerate ShieldStats.PassiveRegen
amount of health every 2 seconds (the 2 seconds bit, as you can see, is not added yet.)) Admittedly, I am working with a very complex mod while not having any C# coding experience outside of this mod, so I've been able to do a couple small things before, but only with guidance from other people. Now that I'm in this server, I want to try asking in here.
This is my first time posting here so let me know if I did something wrong in terms of any rules here 😅8 Replies
Also, I apologize for doing this, but I'm going to sleep and then going to work as soon as I get up, so if I don't reply for like, a good 12 hours... Sorry about that.
is this real time or turns? is there a game time object?
Real time, not turn based. The game is called From The Depths
I believe there is a game time object? I might need clarification just to be sure
As an aside, you should look into strengthening your general C# knowledge if you plan on doing this in the future. It'll be way easier to get into other peoples code if you can read it...
This is quite true. I should probably look into simpler projects for practice 😅
Here's a good overview of some introductory resources:
https://learn.microsoft.com/en-us/dotnet/csharp/
C# Guide - .NET managed language
The C# guide has everything you need to learn C# and get started writing .NET apps. Learn C# programming - for beginning developers, developers new to C#, and experienced C# / .NET developers.
Oh sweet, I'll look through this when I'm back from a trip I'm about to take. not much point looking at it for half a day and then leaving for 3 weeks. Thanks for this!
So I realized when coming back to this today... it's because this is at the top of the code. I didn't realize what "return" was doing, I think XD