Пример #1
0
void AureolaSpell::update(const sf::Time& frameTime) {
    sf::Vector2f nextPosition;
    calculateNextPosition(frameTime, nextPosition);
    sf::Vector2f diff = nextPosition - getPosition();

    // check collisions with main char
    if (m_ownerType != GameObjectType::_LevelMainCharacter && !m_isOwnerControlled) {
        checkCollisionsWithMainChar(getBoundingBox());
    }
    // check collisions with enemies
    checkCollisionsWithEnemies(getBoundingBox());
    MovableGameObject::update(frameTime);
    GameObject::updateTime(m_data.activeDuration, frameTime);

    // check collisions with owner
    if (m_isReturning && m_mob->getBoundingBox()->intersects(*getBoundingBox())) {
        m_mob->addHeal(getHeal());
        setDisposed();
    }

    if (m_data.activeDuration == sf::Time::Zero) {
        setDisposed();
    }

    if (!m_isReturning) {
        m_rangeLeft -= norm(diff);
        if (m_rangeLeft <= 0.f) {
            m_isReturning = true;
            m_absVel = std::sqrt(getVelocity().x * getVelocity().x + getVelocity().y * getVelocity().y);
        }
    }
    else {
        setSpriteRotation(atan2(getVelocity().y, getVelocity().x));
    }
}
Пример #2
0
int splRejuvenate(Creature* player, cmd* cmnd, SpellData* spellData) {
    Creature* target=0;
    int     heal=0, mpHeal=0;

    if(!(player->getClass() == CreatureClass::CLERIC && player->getDeity() == CERIS) && spellData->how == CastType::CAST && !player->isCt()) {
        player->print("%s does not grant you the power to cast that spell.\n", gConfig->getDeity(player->getDeity())->getName().c_str());
        return(0);
    }



    if(player->getLevel() < 13 && !player->isCt()) {
        player->print("You are not high enough in your order to cast that spell.\n");
        return(0);
    }

    if(player->mp.getCur() < 8 && spellData->how == CastType::CAST) {
        player->print("Not enough magic points.\n");
        return(0);
    }


    if(player->flagIsSet(P_NO_TICK_MP)) {
        player->print("You cannot cast that spell right now.\n");
        return(0);
    }

    // Rejuvenate self
    if(cmnd->num == 2) {

        if( player->hp.getCur() >= player->hp.getMax() &&
            player->mp.getCur() >= player->mp.getMax() &&
            !player->checkStaff("You are already at full health and magic right now.\n") )
            return(0);

        if(spellData->how == CastType::CAST) {

            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            heal = getHeal(player, 0, S_REJUVENATE);
            mpHeal = getHeal(player, 0, S_REJUVENATE);

            if(!player->isCt()) {
                player->lasttime[LT_SPELL].ltime = time(0);
                player->lasttime[LT_SPELL].interval = 24L;
            }
            player->mp.decrease(8);

        } else {
            heal = mrand(1,8);
            mpHeal = mrand(1,8);
        }

        player->doHeal(player, heal);
        player->mp.increase(mpHeal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL) {

            player->print("Rejuvenate spell cast.\n");
            broadcast(player->getSock(), player->getParent(), "%M casts a rejuvenate spell on %sself.",
                player, player->himHer());

        } else {
            player->print("You feel revitalized.\n");
        }

    // Cast rejuvenate on another player or monster
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);
        if(!target) {
            player->print("That person is not here.\n");
            return(0);
        }

        if(!canCastHealing(player, target, true))
            return(0);

        if(target->hp.getCur() >= target->hp.getMax() && target->mp.getCur() >= target->mp.getMax()) {
            player->print("%M is at full health and magic right now.\n", target);
            return(0);
        }

        if(target->flagIsSet(P_NO_TICK_MP) || target->flagIsSet(P_NO_TICK_HP)) {
            player->print("Your rejuvinating magic is ineffective.\n");
            return(0);
        }

        if(target->inCombat(false))
            player->smashInvis();

        if(spellData->how == CastType::CAST && !player->isCt()) {
            player->lasttime[LT_SPELL].ltime = time(0);
            player->lasttime[LT_SPELL].interval = 24L;
        }


        if(spellData->how == CastType::CAST) {
            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            player->mp.decrease(8);
            heal = getHeal(player, target, S_REJUVENATE);
            mpHeal = getHeal(player, target, S_REJUVENATE);

        } else {
            heal = mrand(1,8);
            mpHeal = mrand(1,8);
        }

        heal = player->doHeal(target, heal);
        mpHeal = target->mp.increase(mpHeal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {

            player->print("Rejuvenate spell cast on %N.\n", target);
            target->print("%M casts a rejuvenate spell on you.\n", player);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a rejuvenate spell on %N.",
                player, target);

            niceExp(player, target, (heal+mpHeal)/2, spellData->how);
        }
    }

    return(1);
}
Пример #3
0
int castHealingSpell(Creature* player, cmd* cmnd, SpellData* spellData, const char* spellName, const char* feelBetter, int flag, int defaultAmount) {
    Creature* target=0;
    char    capSpellName[25];
    int     heal=0;

    strcpy(capSpellName, spellName);
    capSpellName[0] = toupper(capSpellName[0]);

    if(player->getClass() == CreatureClass::LICH) {
        player->print("Your class prevents you from casting that spell.\n");
        return(0);
    }


    // Self
    if(cmnd->num == 2) {

        if( player->hp.getCur() >= player->hp.getMax() &&
            !player->checkStaff("You are already at full health right now.\n") )
            return(0);

        if(spellData->how == CastType::CAST) {

            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            heal = getHeal(player, 0, flag);

        } else
            heal = defaultAmount;

        player->doHeal(player, heal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL) {
            player->print("%s spell cast.\n", capSpellName);
            broadcast(player->getSock(), player->getParent(), "%M casts a %s spell on %sself.",
                player, spellName, player->himHer());
            return(1);
        } else {
            player->print("%s\n", feelBetter);
            return(1);
        }

    // Cast vigor on another player or monster
    } else {
        if(player->noPotion( spellData))
            return(0);

        cmnd->str[2][0] = up(cmnd->str[2][0]);
        target = player->getParent()->findCreature(player, cmnd->str[2], cmnd->val[2], false);
        if(!target) {
            player->print("That person is not here.\n");
            return(0);
        }

        if(!canCastHealing(player, target))
            return(0);

        if(target->inCombat(false))
            player->smashInvis();

        if(spellData->how == CastType::CAST) {
            if(player->isPlayer())
                player->getAsPlayer()->statistics.healingCast();
            heal = getHeal(player, target, flag);
        } else {
            heal = defaultAmount;
        }

        heal = player->doHeal(target, heal);

        if(spellData->how == CastType::CAST || spellData->how == CastType::SCROLL || spellData->how == CastType::WAND) {
            player->print("%s spell cast on %N.\n", capSpellName, target);
            target->print("%M casts a %s spell on you.\n",  player, spellName);
            broadcast(player->getSock(), target->getSock(), player->getParent(), "%M casts a %s spell on %N.",
                player, spellName, target);

            niceExp(player, target, heal, spellData->how);
            return(1);
        }
    }

    return(1);
}