Skip to content

Commit

Permalink
Add mana regeneration code in \Workspace\Entry\ManaRegen.h
Browse files Browse the repository at this point in the history
The work is done.
  • Loading branch information
UnresolvedExternal committed Nov 13, 2020
1 parent d3ea8d8 commit 45d38b6
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Union_IkarusDestroyer/Workspace/Entry/ManaRegen.h
@@ -0,0 +1,25 @@
namespace NAMESPACE
{
CSubscription regenerateMana(ZSUB(Loop), []()
{
if (!ogame || ogame->singleStep || !player || player->attribute[NPC_ATR_HITPOINTS] <= 0)
return;

static int timer = 0;
timer += ztimer->frameTime;

if (timer < Settings::TickRate)
return;

timer -= Settings::TickRate;

const int manaMax = player->attribute[NPC_ATR_MANAMAX];
int& mana = player->attribute[NPC_ATR_MANA];

if (manaMax < Settings::Threshold)
return;

mana += Settings::PerTick ? Settings::PerTick : (manaMax / Settings::Divisor);
mana = CoerceInRange(mana, 0, 0, manaMax);
});
}

0 comments on commit 45d38b6

Please sign in to comment.