P_ITEM cChar::getWeapon() { unsigned int ci=0; P_ITEM pi; vector<SERIAL> vecContainer = contsp.getData(serial); for ( ci = 0; ci < vecContainer.size(); ci++) { pi = FindItemBySerial(vecContainer[ci]); if (pi != NULL) if ((pi->layer==1 && pi->type!=9) // not a spellbook (hozonko) || (pi->layer==2 && !getShield()) ) //Morrolan don't check for shields { return pi; } } return NULL; }
void UnitClass::drawUnitPosition() { const Position &pos = getPosition(); const BWAPI::UnitType &type = getType(); Player player = getPlayer(); const int barHeight = 4; if((!isCompleted() || isMorphing()) && accessibility() != AccessType::Prediction) { double progress = getCompletedTime() - BWAPI::Broodwar->getFrameCount(); if(isMorphing()) progress /= getBuildType().buildTime(); else progress /= type.buildTime(); progress = 1.0 - progress; BWAPI::Color barColour = isMorphing() ? BWAPI::Colors::Red : BWAPI::Colors::Purple; Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() + type.dimensionDown() + barHeight - 1); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, barColour, player->getColor()); } if(type.maxShields() > 0) { double progress = getShield(); progress /= type.maxShields(); Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp() - barHeight + 2); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, BWAPI::Colors::Blue, player->getColor()); } if(type.maxHitPoints() > 0) { double progress = getHealth(); progress /= type.maxHitPoints(); Position bottomLeft(pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp() + 1); DrawingHelper::Instance().drawProgressBar(bottomLeft, type.dimensionLeft()+type.dimensionRight(), barHeight, progress, BWAPI::Colors::Green, player->getColor()); } BWAPI::Broodwar->drawBox(BWAPI::CoordinateType::Map, pos.x() - type.dimensionLeft(), pos.y() - type.dimensionUp(), pos.x() + type.dimensionRight(), pos.y() + type.dimensionDown(), player->getColor()); BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y(), "%s", player->getName().c_str()); AccessType access = accessibility(); BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+10, "%s", AccessType::getName(access.underlying()).c_str()); int existTime = getExistTime() - BWAPI::Broodwar->getFrameCount(); int completeTime = getCompletedTime() - BWAPI::Broodwar->getFrameCount() - existTime; BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+20, "%d : %d", existTime, completeTime); if(isMorphing()) BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+30, "Morphing"); else if(isCompleted()) BWAPI::Broodwar->drawTextMap(pos.x() + type.dimensionRight(), pos.y()+30, "Completed"); Position target = getTargetPosition(); BWAPI::Broodwar->drawLine(BWAPI::CoordinateType::Map, pos.x(), pos.y(), target.x(), target.y(), player->getColor()); }
int UnitClass::totalHitPoints() { return getHealth() + getShield() + getDefenseMatrixPoints(); }
Creature::operator BoardCreatureData() const { BoardCreatureData data {getId(), getHealth(), getAttack(), getShield(), BoardCreatureData::shieldTypes[getShieldType()]}; return data; }