本文整理汇总了C++中CCharEntity::isDead方法的典型用法代码示例。如果您正苦于以下问题:C++ CCharEntity::isDead方法的具体用法?C++ CCharEntity::isDead怎么用?C++ CCharEntity::isDead使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCharEntity
的用法示例。
在下文中一共展示了CCharEntity::isDead方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TryLearningSpells
void TryLearningSpells(CCharEntity* PChar, CMobEntity* PMob) {
if (PMob->m_UsedSkillIds.size() == 0) { // minor optimisation.
return;
}
// prune the learnable blue spells
std::vector<CSpell*> PLearnableSpells;
for (std::map<uint16, uint16>::iterator i=PMob->m_UsedSkillIds.begin(); i != PMob->m_UsedSkillIds.end(); ++i) {
CSpell* PSpell = spell::GetSpellByMonsterSkillId(i->first);
if (PSpell != NULL) {
PLearnableSpells.push_back(PSpell);
}
}
if (PLearnableSpells.size() == 0) {
return;
}
std::vector<CCharEntity*> PBlueMages;
// populate PBlueMages
if (PChar->PParty != NULL) {
for (uint8 i = 0; i < PChar->PParty->members.size(); i++) {
if (PChar->PParty->members[i]->GetMJob() == JOB_BLU && PChar->PParty->members[i]->objtype == TYPE_PC) {
PBlueMages.push_back((CCharEntity*)PChar->PParty->members[i]);
}
}
}
else if (PChar->GetMJob() == JOB_BLU) {
PBlueMages.push_back(PChar);
}
// loop through the list of BLUs and see if they can learn.
for (int i=0; i<PBlueMages.size(); i++) {
CCharEntity* PBlueMage = PBlueMages[i];
if (PBlueMage->isDead()) { // too dead to learn
continue;
}
if (distance(PBlueMage->loc.p, PMob->loc.p) > 100) { // too far away to learn
continue;
}
for (int spell=0; spell<PLearnableSpells.size(); spell++) {
CSpell* PSpell = PLearnableSpells[spell];
if (charutils::hasSpell(PBlueMage, PSpell->getID())) {
continue;
}
uint8 learnableLevel = PSpell->getJob(JOB_BLU);
if (learnableLevel > 0 && learnableLevel < PBlueMage->GetMLevel()+7) { // TODO: Use blue magic skill check rather than level
if (rand()%100 < 33) {
if (charutils::addSpell(PBlueMage, PSpell->getID())) {
PBlueMage->pushPacket(new CMessageBasicPacket(PBlueMage, PBlueMage, PSpell->getID(), 0, MSGBASIC_LEARNS_SPELL));
charutils::SaveSpells(PBlueMage);
PBlueMage->pushPacket(new CCharSpellsPacket(PBlueMage));
}
}
break; // only one attempt at learning a spell, regardless of learn or not.
}
}
}
}
示例2: TryLearningSpells
void TryLearningSpells(CCharEntity* PChar, CMobEntity* PMob) {
if (PMob->m_UsedSkillIds.size() == 0) { // minor optimisation.
return;
}
// prune the learnable blue spells
std::vector<CSpell*> PLearnableSpells;
for (std::map<uint16, uint16>::iterator i=PMob->m_UsedSkillIds.begin(); i != PMob->m_UsedSkillIds.end(); ++i) {
CSpell* PSpell = spell::GetSpellByMonsterSkillId(i->first);
if (PSpell != nullptr) {
PLearnableSpells.push_back(PSpell);
}
}
if (PLearnableSpells.size() == 0) {
return;
}
std::vector<CCharEntity*> PBlueMages;
// populate PBlueMages
if (PChar->PParty != nullptr) {
for (uint8 i = 0; i < PChar->PParty->members.size(); i++) {
if (PChar->PParty->members[i]->GetMJob() == JOB_BLU && PChar->PParty->members[i]->objtype == TYPE_PC) {
PBlueMages.push_back((CCharEntity*)PChar->PParty->members[i]);
}
}
}
else if (PChar->GetMJob() == JOB_BLU) {
PBlueMages.push_back(PChar);
}
// loop through the list of BLUs and see if they can learn.
for (size_t i = 0; i < PBlueMages.size(); i++) {
CCharEntity* PBlueMage = PBlueMages[i];
if (PBlueMage->isDead()) { // too dead to learn
continue;
}
if (distance(PBlueMage->loc.p, PMob->loc.p) > 100) { // too far away to learn
continue;
}
for (size_t spell = 0; spell < PLearnableSpells.size(); spell++) {
CSpell* PSpell = PLearnableSpells[spell];
if (charutils::hasSpell(PBlueMage, static_cast<uint16>(PSpell->getID()))) {
continue;
}
// get the skill cap for the spell level
auto skillLvlForSpell = battleutils::GetMaxSkill(SKILL_BLUE_MAGIC, JOB_BLU, PSpell->getJob(JOB_BLU));
// get player skill level with bonus from gear
auto playerSkillLvl = PBlueMage->GetSkill(SKILL_BLUE_MAGIC);
// make sure the difference between spell skill and player is at most 31 points
if (playerSkillLvl >= skillLvlForSpell - 31)
{
// TODO: check for blue learning bonus and adjust base percent
if (dsprand::GetRandomNumber(100) < 33) {
if (charutils::addSpell(PBlueMage, static_cast<uint16>(PSpell->getID()))) {
PBlueMage->pushPacket(new CMessageBasicPacket(PBlueMage, PBlueMage, static_cast<uint16>(PSpell->getID()), 0, MSGBASIC_LEARNS_SPELL));
charutils::SaveSpell(PBlueMage, static_cast<uint16>(PSpell->getID()));
PBlueMage->pushPacket(new CCharSpellsPacket(PBlueMage));
}
}
break; // only one attempt at learning a spell, regardless of learn or not.
}
}
}
}