Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add mana regeneration code in \Workspace\Entry\ManaRegen.h
The work is done.
- Loading branch information
1 parent
d3ea8d8
commit 45d38b6
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |