Hi, I’m trying to smoothly increase an integer value over time on keypress (well, it’ll be done with more than a keypress, but for testing keypress is fine).
It’s something like Oblivion’s potions where it can “increase health 10 points for 2 seconds” which will increase health by 20 points total, smoothly increasing the health by 10 over each second. I need this to work with completely arbitrary numbers and it won’t always be applied to just the player, so doing the math on tick won’t work.
I thought about using a timer that gets called X times (X being the “health” in this example) and calls a function after Y seconds that increases X by 1 (Y seconds being 1/X), but that didn’t work. I tried using a for loop that runs X times on a single keypress. I’m sadly out of ideas.
Thank you for your reply (sorry for the delay, as well), but it seems you skipped over the body of the question in reading. There’s a bit more to my question than just the title.
Create a SetTimerByFunctionName with your preferred UpdateIntervall (it is looping).
This Timer starts a Function or a CustomEvent (here: HealthPotion).
In the CustomEventHealthPotion your CurrentHealth gets increased by your PotionHealthPerSeconds multiplied by your UpdateIntervall for every execution (Execution = Every UpdateIntervall).
When the potion is depleted (PotionDuration <= 0), then the TimerHandleActiveTimer can be accessed to disable your Timer.
Definitely on the right track with this, thank you! Arbitrary values are still a struggle, and I’m not entirely sure potion stacking would work at all. Weirdly difficult to make an effect like this that is clean, it seems lol
Which kind of potion stacking do you mean? You press 2 times for the potion and you get both effects or you press 2 times and then you get the first potion and after this is depleted you get the second one? For your arbitrary values you can just use RandomFloatInRange or do you want something different?
Potion stacking means both effects get applied at the same time (so when one health potion finishes regenerating your health, the other one keeps going so both regenerate the amount they need to). Arbitrary values basically just means being able to plug in whatever numbers I want for the effect
So you press for Potion Small 4HP 10 sec and Potion Medium 10HP 15sec and you would get 14HP for 10sec and then 10HP for 5 sec? And not 4HP for 10sec and after those 10sec 10HP for 15sec?
Maybe this would work as a “stack all at once” and disable those which are depleted. The other ones will go on. It is not polished, but it should be a good starting point.