コード例 #1
0
void cAbstractStructure::think_repair()
{
    // REPAIRING
    if (bRepair) {
		if (player[iPlayer].credits > 1.0f) {
			TIMER_repair++;

			if (TIMER_repair > 7)
			{
				TIMER_repair=0;
				iHitPoints += structures[getType()].fixhp;
				player[iPlayer].credits--;
				if (player[iPlayer].credits < 0.0f) {
					player[iPlayer].credits = 0.0f;
				}
			}

			// done repairing
			if (iHitPoints >= getMaxHP()) {
				iHitPoints = getMaxHP();
				bRepair=false;
			}
		}
		assert(iHitPoints <= structures[getType()].hp);
	}
}
コード例 #2
0
ファイル: character.cpp プロジェクト: sonicyang/RPGMaker
void Character::setHP(const int a){
    if(a >= 0 && a <= getMaxHP()){
        this->_hp = a;
    }else if(a > getMaxHP()){
        this->_hp = getMaxHP();
    }else{
        this->_hp = 0;
    }
    return;
}
コード例 #3
0
void ServantBerserkerFlail::subHP(int hp, DamageType dt)
{
    bool noDamage = false;

    int r = getRandNum();
    if (((ascension == 1 && r <= getLuk()) ||
         (ascension == 2 && r <= getLuk() * 1.5)) &&
            (dt == D_STR || dt == D_MAG))
    {
        noDamage = true;
        log->addToEventLog(getFullName() + " deflected the attack and took no damage! Spin to Win!");
    }

    if (!noDamage)
    {
        currHP -= hp;
        int mhp = getMaxHP();
        if (currHP > mhp)
            currHP = mhp;
        else if (currHP <= 0)
        {
            currHP = 0;
            remAllDebuffs(false);
        }
    }
}
コード例 #4
0
ファイル: CRole.cpp プロジェクト: Gamex/GameX
void CRole::damage(float damagePoint, CRole* attacker)
{
    float curHP = getCurHP();
    curHP = curHP - damagePoint;
    if (FLT_LE(curHP, 0.f))
    {
        setCurHP(0.f);
        FIGHT_RELATION->removeAllRelation(dynamic_cast<IFightingRelation*>(this));
        changeState(ROLE_STATE_DYING);
    }
    else
    {
        setCurHP(curHP);
        
        if (attacker)
        {
            if (getMovetarget().equals(Point(-1.f, -1.f)))
            {
                setMoveTarget(attacker->getLogicGrid()->getGridPos());
            }
        }
    }
    
    m_pHPBar->setPercentage(getCurHP() / getMaxHP());
    
    BF_MANAGER->wakeUpAllDefender();
}
コード例 #5
0
ファイル: Hero.cpp プロジェクト: ttlg/criticalhit
void Hero::obtainItem( ITEM_ID id )
{
	switch( id )
	{
	case I_PUMPKIN:
		GameScene::raiseKillCnt();
		soundMap["kabo"]->play();
		break;
	case I_PUMPKIN_BOSS:
		GameScene::IamBossIamDead();
		GameScene::raiseKillCnt();
		soundMap["kabo"]->play();
		phase ++;
		break;
	case I_PORTION:
		{
		int mHP = getMaxHP();
		soundMap["recovery"]->play();
		HP += PORTION_RECOVERY;
		if ( mHP < HP ) HP = mHP;
		}
		break;
	case I_KEY:
		// soundMap["key"]->play();
		GameScene::addScript( "getKey"+to_string((long long)keyNum), Point2D( 0.1, 0.16 ), 100 );
		keyNum++;
		break;
	}
}
コード例 #6
0
ファイル: characterShell.cpp プロジェクト: easy63/RPG
int characterShell::getMaxHP(lua_State* pLua)
{
	auto pCharacter = worldShell::CWorldSingleton::instance()->getPlayer()->getCharacter();

	if(pCharacter != nullptr)
		lua_pushinteger(pLua, pCharacter->getMaxHP());

	return 1;
}
コード例 #7
0
ファイル: player.cpp プロジェクト: KenKic/QSanguosha
void Player::setGeneralName(const QString &general_name){
    const General *new_general = Sanguosha->getGeneral(general_name);

    if(this->general != new_general){
        this->general = new_general;
        if(new_general){
            setHp(getMaxHP());
            setKingdom(general->getKingdom());
        }

        emit general_changed();
    }
}
コード例 #8
0
ファイル: ch_att.cpp プロジェクト: wengong-jin/FishTank
void ch_att::getInfo()
{
	x=getX();
	y=getY();
	lev=getLevel();
	point=getPoint();
	exp=getExp();
	hp=getHP();
	maxhp=getMaxHP();
	att=getAtt();
	sp=getSp();
	getMap();
}
コード例 #9
0
void ServantBerserkerClub::subHP(int hp, DamageType dt)
{
    damageFreeTurn = false;
    increases++;

    currHP -= hp;
    int mhp = getMaxHP();
    if (currHP > mhp)
        currHP = mhp;
    else if (currHP <= 0)
    {
        currHP = 0;
        remAllDebuffs(false);
    }
}
コード例 #10
0
ファイル: CRole.cpp プロジェクト: Gamex/GameX
bool CRole::init(const string& unitId, bool editorMode)
{
    do
    {
        m_isEditMode = editorMode;
        
        BREAK_IF(!CSpriteObject::init());
        
        m_faceToPrefix.resize(FACE_TO_MAX);
        m_faceToPrefix[FACE_TO_LEFT_DOWN] = ROLE_FACE_TO_LEFT_PREFIX;
        m_faceToPrefix[FACE_TO_RIGHT_DOWN] = ROLE_FACE_TO_RIGHT_PREFIX;
        m_faceToPrefix[FACE_TO_LEFT_UP] = ROLE_BACK_TO_LEFT_PREFIX;
        m_faceToPrefix[FACE_TO_RIGHT_UP] = ROLE_BACK_TO_RIGHT_PREFIX;

        
        changeState(ROLE_STATE_MOVE);

        setUnitId(unitId);
        
        const DTUnit::_Data* unitData = DTUNIT->getData(getUnitId());
        CC_ASSERT(unitData);
        setGridWidth(unitData->gridWidth);
        setGridHeight(unitData->gridHeight);
        
        setSpeed(unitData->speed);
        setMaxHP(unitData->hp);
        setCurHP(getMaxHP());
        setATK(unitData->atk);
        setAtkSpeed(unitData->rate);
        
        BREAK_IF_FAILED(CSpriteObject::setSpriteFromCcbi(unitData->resourceID.c_str()));
        
        if (!editorMode)
        {
            BREAK_IF_FAILED(createHPBar());
            m_pHPBar->setPercentage(1.f);
            Size sz = getSpriteContentSize();
            m_pHPBar->setPosition(0, sz.height);
        }
        return true;
    } while (false);
    
    return false;
}
コード例 #11
0
ファイル: Character.cpp プロジェクト: vincentlai97/AI2
void Character::UpdateState(std::array<Character *, 3> heroes, std::vector<Character *> monsters, double dt, MsgBoard &msgboard)
{
	float monsterDist = 100;
	Character *monster;
	for (Character *iter : monsters)
	{
		if (glm::distance(iter->getPos(), getPos()) < monsterDist)
		{
			monsterDist = glm::distance(iter->getPos(), getPos());
			monster = iter;
		}
	}
	switch (role)
	{
	case ROLE::KNIGHT:
		if (attacked)
		{
			if (attacker == NULL) attacked = false;
			CallForHeal(heroes, msgboard);
		}
		if (getMaxHP() > hp)
		{
			msgboard.msgboard.at(1) = false;
		}
		if (state == STATE::KNIGHT_PROTECT)
		{
			if (target == attacker) state = STATE::KNIGHT_ATTACK;
		}
		else
		{
			if (monsterDist < 2)
			{
				state = STATE::KNIGHT_ATTACK;
			}
			else if (monsterDist < 15)
			{
				state = STATE::KNIGHT_MOVE;
				target = monster;
			}
			else
				state = STATE::KNIGHT_IDLE;
		}
		break;
	case ROLE::ARCHER:
		if (attacked)
		{
			if (attacker == NULL || glm::distance(getPos(), attacker->getPos()) > 5) attacked = false;
			else
			{
				state = STATE::ARCHER_RETREAT;
				CallForHelp(heroes, msgboard);
			}
		}
		if (!attacked)
		{
			msgboard.msgboard.at(0) = false;
			if (monsterDist < 10)
			{
				state = STATE::ARCHER_ATTACK;
			}
			else if (monsterDist < 20)
			{
				state = STATE::ARCHER_MOVE;
				target = monster;
			}
			else
				state = STATE::ARCHER_IDLE;
		}
		break;
	case ROLE::HEALER:
		if (attacked)
		{
			if (attacker == NULL || glm::distance(getPos(), attacker->getPos()) > 5) attacked = false;
			else state = STATE::ARCHER_RETREAT;
			CallForHelp(heroes, msgboard);
		} 
		if (!attacked)
		{
			Character *knight;
			for (int count = 0; count < 3; ++count)
			{
				if (heroes[count]->role == ROLE::KNIGHT) knight = heroes[count];
			}
			if (glm::distance(getPos(), knight->getPos()) > 5)
			{
				state = STATE::HEALER_MOVE;
				target = knight;
			}
			else
				state = STATE::HEALER_HEAL;
		}
		break;
	case ROLE::MONSTER:
	{
						  Character closestHero;
						  float dist = 15;
						  for (int count = 0; count < 3; ++count)
						  {
							  if (glm::distance(getPos(), heroes[count]->getPos()) < dist)
							  {
								  dist = glm::distance(getPos(), heroes[count]->getPos());
								  target = heroes[count];
								  targetReached = true;
							  }
						  }
						  if (dist < 2)
							  state = STATE::MONSTER_ATTACK;
						  else if (dist < 15)
							  state = STATE::MONSTER_MOVE;
						  else
						  {
							  if (!targetReached)
							  {
								  if (glm::distance(getPos(), target->getPos()) < 2)
								  {
									  delete target;
									  targetReached = true;
								  }
							  }
							  if (targetReached)
							  {
								  target = new Character();
								  target->object = new Object();
								  target->object->translation = glm::translate(glm::vec3(rand() % 100 - 50, rand() % 80 - 40, 0));
								  state = STATE::MONSTER_PATROL;
								  targetReached = false;
							  }
						  }
	}
		break;
	default:
		break;
	}
}
コード例 #12
0
int ServantBerserkerClub::attack(vector<Servant *> defenders, bool counter)
{
    if (actionMPCosts[ascension][0] > currMP)
        return 1; // Not enough MP to attack
    else
    {
        subMP(actionMPCosts[ascension][0]);
        for (unsigned int i = 0; i < defenders.size(); i++)
        {
            // Add the target to the list of previous targets (if they are not
            //  already on it)
            if (!previouslyTargeted(defenders[i]))
                previousTargets.push_back(defenders[i]);

            int dam = 0;
            // Check if you hit the targets
            vector<int> opEvade = defenders[i]->getEvade();
            bool hit = false;
            // Calculate accuracy
            int accuracy = capZero(getHitRate() - opEvade[0]);

            int r = getRandNum();
            if (accuracy >= r)
                hit = true;

            if (opEvade.size() > 1 && hit)
            {
                for (unsigned int j = 1; j < opEvade.size() && hit; j++)
                {
                    r = getRandNum();
                    if (opEvade[j] >= r)
                        hit = false;
                }
            }

            // If you hit, calculate crit chance
            if (hit)
            {
                int attackMult = 1;
                int critChance = capZero(getCriticalRate() -
                                 defenders[i]->getCriticalEvade());
                r = getRandNum();
                if (critChance >= r)
                    attackMult *= 3;

                // If you're at the Final Ascension and have already faced this
                //  target, deal thrice as much damage and decrease DEF by 10
                //  (Barbarian's Wrath)
                if(ascension == 2 && previouslyTargeted(defenders[i]))
                {
                    attackMult *= 3;
                    vector<Stat> tS;
                    tS.push_back(DEF);
                    vector<int> tA;
                    tA.push_back(-10);
                    Debuff* bw = new Debuff("Barbarian's Wrath",
                                            "You tried to fight a Club Berserker twice, and paid the price.",
                                            defenders[i]->getTeam(), tS, tA,
                                            -1);
                    defenders[i]->addDebuff(bw);
                    log->addToEventLog(defenders[i]->getFullName() + " felt " +
                                       getFullName() + "'s Wrath!");
                }

                // Deal the damage
                dam = capZero(getStr() - defenders[i]->getDef()) * attackMult;
                log->addToEventLog(getFullName() + " dealt " +
                                   to_string(dam) + " damage to " +
                                   defenders[i]->getFullName() + ".");
                defenders[i]->subHP(dam, D_STR);

                // Apply the Crushing Blow debuff
                vector<Stat> tStats;
                tStats.push_back(DEF);
                vector<int> tAmounts;
                tAmounts.push_back(-2);
                Debuff* bOut = new Debuff("Crushing Blow",
                                          "You took a blow from a Club Berserker, permanetly denting your armor.",
                                          defenders[i]->getTeam(), tStats,
                                          tAmounts, -1);

                defenders[i]->addDebuff(bOut);

                // Check to see if Barbarian's Might activates
                r = getRandNum();
                if (r <= getLuk() * 2)
                {
                    vector<Stat> tS;
                    tS.push_back(DEF);
                    vector<int> tA;
                    tA.push_back(-5);
                    Debuff* bm = new Debuff("Barbarian's Might",
                                            "You took an incredible blow from a Club Berserker, permanetly denting your armor.",
                                            defenders[i]->getTeam(), tS, tA,
                                            -1);
                    defenders[i]->addDebuff(bm);
                    log->addToEventLog(defenders[i]->getFullName() + " felt " +
                                       getFullName() + "'s Might!");
                }
            }
            else
            {
                log->addToEventLog(getFullName() + " missed " +
                                   defenders[i]->getFullName() + "!");
            }

            // Check to see if the defender is dead. If they are, do not call
            // the counterattack. Additionally, if they are an Avenger and they
            // die, activate Final Revenge.
            // If they are not dead but they are a Berserker, check to see if
            // Mad Counter activates.
            if(defenders[i]->getCurrHP() > 0)
            {
                // Check if the defender is a Berserker. If they are, and they
                // are adjacent to this unit, check to see if Mad Counter
                // activates.
                if (defenders[i]->getClass() == Berserker &&
                    isAdjacent(defenders[i]))
                {
                    r = getRandNum();
                    if (defenders[i]->getLuk() >= r)
                    {
                        // Mad Counter activated! The attacking servant takes
                        // damage equal to the damage they dealt.
                        log->addToEventLog(defenders[i]->getFullName() +
                                           "'s Mad Counter activated, dealing " +
                                           to_string(dam) + " damage back to " +
                                           getFullName() + ".");
                        subHP(dam, C_STR);
                    }
                }
                // Call "attack" on the defending servant for their
                // counterattack, if you are in their range and you are the
                // initiating servant.
                if (defenders[i]->isInRange(this) && counter)
                {
                    vector<Servant *> you;
                    you.push_back(this);
                    defenders[i]->attack(you, false);
                }
            }
            else
            {
                if (defenders[i]->getClass() == Avenger)
                {
                    // Activate Final Revenge
                    Debuff *finRev = defenders[i]->finalRevenge();
                    addDebuff(finRev);
                    if (defenders[i]->getAscensionLvl() == 2)
                    {
                        subHP(.1 * getMaxHP(), OMNI);
                        subMP(.1 * getMaxMP());

                        if (getCurrHP() == 0)
                        {
                            setHP(1);
                        }
                    }
                }
            }
        }
    }

    return 0;
}
コード例 #13
0
// Re-define attack to account for the Vengeance skill
int ServantAvenger::attack(vector<Servant *> defenders, bool counter)
{
    if (actionMPCosts[ascension][0] > currMP)
        return 1; // Not enough MP to attack
    else
    {
        subMP(actionMPCosts[ascension][0]);
        for (unsigned int i = 0; i < defenders.size(); i++)
        {
            int dam = 0;
            // Check if you hit the targets
            vector<int> opEvade = defenders[i]->getEvade();
            bool hit = false;
            // Calculate accuracy
            int accuracy = capZero(getHitRate() - opEvade[0]);

            int r = getRandNum();
            if (accuracy >= r)
                hit = true;

            if (opEvade.size() > 1 && hit)
            {
                for (unsigned int j = 1; j < opEvade.size() && hit; j++)
                {
                    r = getRandNum();
                    if (opEvade[j] >= r)
                        hit = false;
                }
            }

            // If you hit, calculate crit chance
            // Also check if Skill: Vengeance activates
            if (hit)
            {
                int attackMult = 1;
                int critChance = capZero(getCriticalRate() -
                                 defenders[i]->getCriticalEvade());
                r = getRandNum();
                if (critChance >= r)
                    attackMult *= 3;

                // Check for Vengeance
                int addVengeance = 0;
                r = getRandNum();
                if (getSkl() * 2 >= r)
                {
                    addVengeance = (getMaxHP() - getCurrHP()) * 2;
                    log->addToEventLog(getFullName() + " activated Vengeance!");
                }

                // Deal the damage
                dam = (capZero(getStr() - defenders[i]->getDef()) + addVengeance)
                        * attackMult;
                log->addToEventLog(getFullName() + " dealt " +
                                   to_string(dam) + " damage to " +
                                   defenders[i]->getFullName() + ".");
                defenders[i]->subHP(dam, D_STR);
            }
            else
            {
                log->addToEventLog(getFullName() + " missed " +
                                   defenders[i]->getFullName() + "!");
            }

            // Check to see if the defender is dead. If they are, do not call
            // the counterattack. Additionally, if they are an Avenger and they
            // die, activate Final Revenge.
            // If they are not dead but they are a Berserker, check to see if
            // Mad Counter activates.
            if(defenders[i]->getCurrHP() > 0)
            {
                // Check if the defender is a Berserker. If they are, and they
                // are adjacent to this unit, check to see if Mad Counter
                // activates.
                if (defenders[i]->getClass() == Berserker &&
                    isAdjacent(defenders[i]))
                {
                    r = getRandNum();
                    if (defenders[i]->getLuk() >= r)
                    {
                        // Mad Counter activated! The attacking servant takes
                        // damage equal to the damage they dealt.
                        log->addToEventLog(defenders[i]->getFullName() +
                                           "' Mad Counter activated, dealing " +
                                           to_string(dam) + " damage back to " +
                                           getFullName() + ".");
                        subHP(dam, C_STR);
                    }
                }
                // Call "attack" on the defending servant for their
                // counterattack, if you are in their range and you are the
                // initiating servant.
                if (defenders[i]->isInRange(this) && counter)
                {
                    vector<Servant *> you;
                    you.push_back(this);
                    defenders[i]->attack(you, false);
                }
            }
            else
            {
                if (defenders[i]->getClass() == Avenger)
                {
                    // Activate Final Revenge
                    Debuff *finRev = defenders[i]->finalRevenge();
                    addDebuff(finRev);
                    if (defenders[i]->getAscensionLvl() == 2)
                    {
                        subHP(.1 * getMaxHP(), OMNI);
                        subMP(.1 * getMaxMP());

                        if (getCurrHP() == 0)
                        {
                            setHP(1);
                        }
                    }
                }
            }
        }
    }

    return 0;
}
コード例 #14
0
ファイル: character.cpp プロジェクト: easy63/RPG
void CCharacter::addHP(int _iPlusHP)
{
	rStatus.iHP += _iPlusHP;
	if(getHP() > getMaxHP())
		rStatus.iHP = getMaxHP();
}
コード例 #15
0
ファイル: character.cpp プロジェクト: easy63/RPG
CCharacter::CCharacter()
{
	update();
	rStatus.iHP = getMaxHP();
	rStatus.iMana = getMaxMagic();
}
コード例 #16
0
ファイル: player.cpp プロジェクト: Lycio/FolkExtensionMod
int Player::getMaxHp() const{
    return getMaxHP();
}
コード例 #17
0
/***** Function re-definitions *****/
int ServantAssassin::attack(vector<Servant *> defenders, bool counter)
{
    if (actionMPCosts[ascension][0] > currMP)
        return 1; // Not enough MP to attack
    else
    {
        subMP(actionMPCosts[ascension][0]);
        for (unsigned int i = 0; i < defenders.size(); i++)
        {
            int dam = 0;
            // Check if you hit the targets
            vector<int> opEvade = defenders[i]->getEvade();
            bool hit = false;
            // Calculate accuracy
            int accuracy = capZero(getHitRate() - opEvade[0]);

            int r = getRandNum();
            if (accuracy >= r)
                hit = true;

            // Skill: Presence Detection skips all other evasion checks!

            // If you hit, calculate crit chance
            if (hit)
            {
                int attackMult = 1;
                int critChance = capZero(getCriticalRate() -
                                 defenders[i]->getCriticalEvade());
                r = getRandNum();
                if (critChance >= r)
                    attackMult *= 3;

                // Calculate the chance of Lethality
                r = getRandNum();
                if (getSkl() / 8 > r)
                {
                    dam = defenders[i]->getMaxHP() * attackMult;

                    log->addToEventLog(getFullName() +
                                       " activated Lethality against " +
                                       defenders[i]->getFullName() + "!" +
                                       to_string(dam) + " damage dealt!");
                    defenders[i]->subHP(dam, D_STR);
                }
                else
                {
                    // Deal the damage
                    dam = capZero(getStr() - defenders[i]->getDef()) * attackMult;

                    log->addToEventLog(getFullName() + " dealt " +
                                       to_string(dam) + " damage to " +
                                       defenders[i]->getFullName() + ".");
                    defenders[i]->subHP(dam, D_STR);
                }

                // Add the weapon-specific debuff to the target
                Debuff *deb = new Debuff(classDebuff->getDebuffName(),
                                         classDebuff->getDebuffDescrip(),
                                         defenders[i]->getTeam(),
                                         classDebuff->getDebuffStats(),
                                         classDebuff->getDebuffAmounts(),
                                         classDebuff->getTurnsRemaining());

                defenders[i]->addDebuff(deb);
            }
            else
            {
                log->addToEventLog(getFullName() + " missed " +
                                   defenders[i]->getFullName() + "!");
            }

            // Check to see if the defender is dead. If they are, do not call
            // the counterattack. Additionally, if they are an Avenger and they
            // die, activate Final Revenge.
            // If they are not dead but they are a Berserker, check to see if
            // Mad Counter activates.
            if(defenders[i]->getCurrHP() > 0)
            {
                // Check if the defender is a Berserker. If they are, and they
                // are adjacent to this unit, check to see if Mad Counter
                // activates.
                if (defenders[i]->getClass() == Berserker &&
                    isAdjacent(defenders[i]))
                {
                    r = getRandNum();
                    if (defenders[i]->getLuk() >= r)
                    {
                        // Mad Counter activated! The attacking servant takes
                        // damage equal to the damage they dealt.
                        log->addToEventLog(defenders[i]->getFullName() +
                                           "' Mad Counter activated, dealing " +
                                           to_string(dam) + " damage back to " +
                                           getFullName() + ".");
                        subHP(dam, C_STR);
                    }
                }
                // Call "attack" on the defending servant for their
                // counterattack, if you are in their range and you are the
                // initiating servant.
                if (defenders[i]->isInRange(this) && counter)
                {
                    vector<Servant *> you;
                    you.push_back(this);
                    defenders[i]->attack(you, false);
                }
            }
            else
            {
                if (defenders[i]->getClass() == Avenger)
                {
                    // Activate Final Revenge
                    Debuff *finRev = defenders[i]->finalRevenge();
                    addDebuff(finRev);
                    if (defenders[i]->getAscensionLvl() == 2)
                    {
                        subHP(.1 * getMaxHP(), OMNI);
                        subMP(.1 * getMaxMP());

                        if (getCurrHP() == 0)
                        {
                            setHP(1);
                        }
                    }
                }
            }
        }
    }

    return 0;
}
コード例 #18
0
int ServantBerserkerFlail::attack(vector<Servant *> defenders, bool counter)
{
    if (actionMPCosts[ascension][0] > currMP)
        return 1; // Not enough MP to attack
    else
    {
        subMP(actionMPCosts[ascension][0]);
        bool npActive = false;

        // Check if Lashing Out activates
        // "Hitting all adjacent opponents" only applies to the first two
        //  ascension levels, as Maelstrom of Death trumps Lashing Out
        int r = getRandNum();

        // Cratered Debuff
        vector<Stat> tS;
        tS.push_back(SPD);
        tS.push_back(DEF);
        vector<int> tA;
        tA.push_back(-5);
        tA.push_back(2);
        // Get the Team of the opposing team
        /*Team otherTeam = All;
        vector<vector<Servant*>> pField = field->getServantLocations();
        for (unsigned int i = 0; i < pField.size(); i++)
        {
            for(unsigned int j = 0; j < pField[i].size(); j++)
            {
                if(pField[i][j] != NULL && pField[i][j]->getTeam() != getTeam())
                {
                    otherTeam = pField[i][j]->getTeam();
                }
            }
        }*/
        Debuff* br = new Debuff("Cratered", "The ground has been cratered.",
                                All, tS, tA, -1);

        vector<Coordinate> crateredRange;

        if (ascension <= 1 && r < getLuk())
        {
            // Add all adjacent servants to the defenders vector (as long as
            //  they aren't already in it)
            vector<Servant*> adj = field->getAllInRange(this, getLowToHighRange(1,1));
            for (unsigned int i = 0; i < adj.size(); i++)
            {
                bool isIn = false;
                for (unsigned int j = 0; j < defenders.size() && !isIn; j++)
                {
                    if (adj[i] == defenders[j])
                        isIn = true;
                }

                if (!isIn)
                    defenders.push_back(adj[i]);
            }

            crateredRange = getAbsoluteRange(1,1,this);
        }
        else if (ascension == 2 && r < getLuk() * 1.5)
        {
            crateredRange = getAbsoluteRange(1,2,this);
        }

        // Apply the cratered debuff to the appropriate spaces
        field->addDebuffToRange(br, crateredRange);

        for (unsigned int i = 0; i < defenders.size(); i++)
        {
            int dam = 0;
            // Check if you hit the targets
            vector<int> opEvade = defenders[i]->getEvade();
            bool hit = false;
            // Calculate accuracy
            int accuracy = capZero(getHitRate() - opEvade[0]);

            r = getRandNum();
            if (accuracy >= r)
                hit = true;

            // Maelstrom of Death doubles accuracy and prevents other evasion
            //  skills from activating
            if (ascension == 2)
                accuracy *= 2;

            if (opEvade.size() > 1 && hit && ascension <= 1)
            {
                for (unsigned int j = 1; j < opEvade.size() && hit; j++)
                {
                    r = getRandNum();
                    if (opEvade[j] >= r)
                        hit = false;
                }
            }

            // If you hit, calculate crit chance
            if (hit)
            {
                int attackMult = 1;
                int critChance = capZero(getCriticalRate() -
                                 defenders[i]->getCriticalEvade());

                // Spin To Win triples crit chance
                if (ascension >= 1)
                    critChance *= 3;

                // Maelstrom of Death also doubles crit chance
                if (ascension == 2)
                    critChance *= 2;

                r = getRandNum();
                if (critChance >= r)
                    attackMult *= 3;

                // Deal the damage
                dam = capZero(getStr() - defenders[i]->getDef()) * attackMult;
                log->addToEventLog(getFullName() + " dealt " +
                                   to_string(dam) + " damage to " +
                                   defenders[i]->getFullName() + ".");
                defenders[i]->subHP(dam, D_STR);
            }
            else
            {
                log->addToEventLog(getFullName() + " missed " +
                                   defenders[i]->getFullName() + "!");
            }

            // Check to see if the defender is dead. If they are, do not call
            // the counterattack. Additionally, if they are an Avenger and they
            // die, activate Final Revenge.
            // If they are not dead but they are a Berserker, check to see if
            // Mad Counter activates.
            if(defenders[i]->getCurrHP() > 0)
            {
                // Check if the defender is a Berserker. If they are, and they
                // are adjacent to this unit, check to see if Mad Counter
                // activates.
                if (defenders[i]->getClass() == Berserker &&
                    isAdjacent(defenders[i]))
                {
                    r = getRandNum();
                    if (defenders[i]->getLuk() >= r)
                    {
                        // Mad Counter activated! The attacking servant takes
                        // damage equal to the damage they dealt.
                        log->addToEventLog(defenders[i]->getFullName() +
                                           "'s Mad Counter activated, dealing " +
                                           to_string(dam) + " damage back to " +
                                           getFullName() + ".");
                        subHP(dam, C_STR);
                    }
                }
                // Call "attack" on the defending servant for their
                // counterattack, if you are in their range and you are the
                // initiating servant.
                // However if the servant is at their final ascension, or if
                //  Lashing out activates, targets cannot counter
                if (!npActive && counter && defenders[i]->isInRange(this))
                {
                    vector<Servant *> you;
                    you.push_back(this);
                    defenders[i]->attack(you, false);
                }
            }
            else
            {
                if (defenders[i]->getClass() == Avenger)
                {
                    // Activate Final Revenge
                    Debuff *finRev = defenders[i]->finalRevenge();
                    addDebuff(finRev);
                    if (defenders[i]->getAscensionLvl() == 2)
                    {
                        subHP(.1 * getMaxHP(), OMNI);
                        subMP(.1 * getMaxMP());

                        if (getCurrHP() == 0)
                        {
                            setHP(1);
                        }
                    }
                }
            }
        }
    }

    return 0;
}