void RarePotion::CheckRarePotions( int index, int value ) {
zSTRING inst = "";
int isActive = 0;
// магическое зелье
if ( index == 1 && value == 0 ) {
player->attribute[ NPC_ATR_MANAMAX ] -= 200;
player->attribute[ NPC_ATR_MANA ] -= 200;
if ( player->attribute[ NPC_ATR_MANA ] < 0 ) {
player->attribute[ NPC_ATR_MANA ] = 0;
}
}
// зелье неутомимости
else if ( index == 4 && value > 0 ) {
if ( *gameVars.staminaPtr < *gameVars.staminaMaxPtr * 10 ) {
*gameVars.staminaPtr += 15;
if ( *gameVars.staminaPtr > *gameVars.staminaMaxPtr * 10 ) {
*gameVars.staminaPtr = *gameVars.staminaMaxPtr * 10;
}
}
}
// зелье бесконечной маны
else if ( index == 5 && value > 0 ) {
if ( player->attribute[ NPC_ATR_MANA ] < player->attribute[ NPC_ATR_MANAMAX ] ) {
player->attribute[ NPC_ATR_MANA ] += 50;
if ( player->attribute[ NPC_ATR_MANA ] > player->attribute[ NPC_ATR_MANAMAX ] ) {
player->attribute[ NPC_ATR_MANA ] = player->attribute[ NPC_ATR_MANAMAX ];
}
}
}
// зелье регенерации
else if ( index == 7 && value > 0 ) {
if ( player->attribute[ NPC_ATR_HITPOINTS ] < player->attribute[ NPC_ATR_HITPOINTSMAX ] && !player->IsDead() ) {
player->attribute[ NPC_ATR_HITPOINTS ] += ( player->attribute[ NPC_ATR_HITPOINTSMAX ] * 0.03f );
if ( player->attribute[ NPC_ATR_HITPOINTS ] > player->attribute[ NPC_ATR_HITPOINTSMAX ] ) {
player->attribute[ NPC_ATR_HITPOINTS ] = player->attribute[ NPC_ATR_HITPOINTSMAX ];
}
}
}
// зелье скорости
else if ( index == 8 && value == 0 ) {
if ( additionalAcceleration ) {
*additionalAcceleration = *additionalAcceleration - 50;
}
}
// зелье магической мощи
else if ( index == 10 && value == 0 ) {
if ( CountLearnSpell ) {
*CountLearnSpell = *CountLearnSpell - 50;
}
}
for ( int i = 1; i <= 12; i++ ) {
if ( i < 10 ) {
inst = "rarePotion_0" + zSTRING( i ) + "_numOfSec";
} else {
inst = "rarePotion_" + zSTRING( i ) + "_numOfSec";
}
int value = parser->GetScriptInt( inst );
if ( value >= 1 ) {
isActive++;
}
}
if ( !isActive ) {
*rarePotion_isActive = FALSE;
}
}
void RarePotion::Loop() {
//printWin("RefreshLocations loop");
if ( !init ) {
init = TRUE;
Init();
}
// таймеры редких зелий
if ( *rarePotion_isActive == TRUE ) {
if ( !( player->GetInstanceName() == "PC_HERO" ) ) {
return;
}
zSTRING inst = "";
for ( int i = 1; i <= 12; i++ ) {
if ( i < 10 ) {
inst = "rarePotion_0" + zSTRING( i ) + "_numOfSec";
} else {
inst = "rarePotion_" + zSTRING( i ) + "_numOfSec";
}
int value = parser->GetScriptInt( inst );
int tickValue = 1000;
if ( gameVars.accelerationActive ) {
tickValue /= settings.worldTime_AccelerationRatio;
}
if ( value && MainTimer[ AST_TIMER_RarePotions + ( i - 1 ) ].Await( tickValue ) ) {
parser->SetScriptInt( inst, --value );
CheckRarePotions( i, value );
}
}
}
}