AinzOoalGown Posted July 6, 2021 Share Posted July 6, 2021 (edited) I am trying to modify Dayo's Health Regen (free) script to include the other stats in game to make it easier to modify on the fly. However I cant seem to get my logic right, I am probs tired and missing something small but thought I would ask if anyone can spot where Ive went wrong. I know the health system works differently to other stats, as it looks up the rank health as max and uses US_health (damage to player) to deduct rank value so I have modified it so energy gains to US_will, unlike original which deducts from US_health. I have removed the regen from workout.hooks.php. $regenEnergy = $settings->loadSetting("regenEnergy", 1, 1); $regenTimeEnergy = $settings->loadSetting("regenTimeEnergy", 1, 1); $timerEnergy = "energyRegen"; $lastEnergy = $user->getTimer($timerEnergy); $timesEnergy = floor((time() - $lastEnergy) / $regenTimeEnergy); if ($timesEnergy) { if ($user->info->US_energy) { $newEnergy = $user->info->US_energy + ($timesEnergy * $regenEnergy); $maxEnergy = $user->info->US_maxEnergy; $user->set("US_energy", $newEnergy); if ($newEnergy > $maxEnergy) $newEnergy = $maxEnergy; $energy = $user->info->US_energy; if ($energy < 0) $energy = 0; $page->addToTemplate('energy', number_format($energy, 2)); } $user->updateTimer($timerEnergy, $lastEnergy + ($timesEnergy * $regenTimeEnergy)); } Any guidance would be great. Thanks Edited July 6, 2021 by AinzOoalGown Quote Link to comment Share on other sites More sharing options...
PHPStudent Posted July 7, 2021 Share Posted July 7, 2021 Do you mean similar to how stats (energy, brave, will, and health) regenerate in mccodes through crons/timestamps? Soz, I don't have a fix I just wanted clarification. Because I'd also be interested in that if its what you're asking for. Quote Link to comment Share on other sites More sharing options...
AinzOoalGown Posted July 7, 2021 Author Share Posted July 7, 2021 (edited) 5 hours ago, PHPStudent said: Do you mean similar to how stats (energy, brave, will, and health) regenerate in mccodes through crons/timestamps? Soz, I don't have a fix I just wanted clarification. Because I'd also be interested in that if its what you're asking for. I am using Dayo's Health regen module: So this module allows the regeneration of health over time using timestamps. Originally (from my knowledge) the other stats are regenerated in workout.hooks.php and are defined there as set values. The good thing about Dayo's health regen module is that you can set the values and time in admin panel for health regen. So I wanted to take that idea and expand it for the other stats (will, energy, brave) so they can also be set in the admin panel. However I think my math/logic is wrong. As health stat regen is deduction from US_health (US-health is bascially how much damage the player has, so reducing it to zero means a player has full health), where as other stats (will, energy, brave) is a addition (stat / maxStat (100/100)). Edited July 7, 2021 by AinzOoalGown 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.