bool BTPc::hasTag(const std::string &t) const { BTGame *game = BTGame::getGame(); if (t[0] == '!') return !hasTag(t.c_str() + 1); bool answer = (std::find<>(tag.begin(), tag.end(), t) != tag.end()); if (answer) return answer; if (monster != BTMONSTER_NONE) { BTFactory<BTMonster> &monList = game->getMonsterList(); return monList[monster].hasTag(t); } else { if (0 == t.compare(genderNames[gender])) return true; if (0 == t.compare(game->getRaceList()[race]->name)) return true; if (0 == t.compare(game->getJobList()[job]->name)) return true; } return false; }
std::string BTPc::attack(BTCombatant *defender, int weapon, int &numAttacksLeft, int &activeNum) { BTGame *game = BTGame::getGame(); BTFactory<BTItem> &itemList = game->getItemList(); BTFactory<BTMonster> &monList = game->getMonsterList(); BTDice damageDice(1, 2); IShort chanceXSpecial(0); IShort xSpecial(BTEXTRADAMAGE_NONE); bool melee = true; if (-1 == weapon) { if (BTMONSTER_NONE != monster) { damageDice = monList[monster].getMeleeDamage(); chanceXSpecial = 100; xSpecial = monList[monster].getMeleeExtra(); } else { XMLVector<BTSkill*> &skill = game->getSkillList(); for (int i = 0; i < skill.size(); ++i) { if ((skill[i]->special == BTSKILLSPECIAL_BAREHANDS) && (hasSkillUse(i))) { BTDice *skillDice = skill[i]->getRoll(getSkill(i)); if (skillDice) damageDice = *skillDice; break; } } } } else { BTItem &itemWeapon = itemList[weapon]; damageDice = itemWeapon.getDamage(); chanceXSpecial = itemWeapon.getChanceXSpecial(); xSpecial = itemWeapon.getXSpecial(); if ((BTITEM_ARROW == itemWeapon.getType()) || (BTITEM_THROWNWEAPON == itemWeapon.getType())) melee = false; } if (stat[BTSTAT_ST] > 14) damageDice.setModifier(damageDice.getModifier() + stat[BTSTAT_ST] - 14); std::string cause; std::string effect; if (-1 == weapon) { if (BTMONSTER_NONE == monster) { cause = "punches at"; effect = "and strikes"; } else { cause = monList[monster].getMeleeMessage(); effect = "and hits"; } } else { BTItem &itemWeapon = itemList[weapon]; cause = itemWeapon.getCause(); effect = itemWeapon.getEffect(); if ((effect.length() >= 4) && (0 == strcmp(effect.c_str() + effect.length() - 4, " for"))) effect.resize(effect.length() - 4); } return BTCombatant::attack(defender, melee, cause, effect, damageDice, chanceXSpecial, xSpecial, numAttacksLeft, activeNum); }