本文整理汇总了C++中CreatureVector类的典型用法代码示例。如果您正苦于以下问题:C++ CreatureVector类的具体用法?C++ CreatureVector怎么用?C++ CreatureVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreatureVector类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pushCreatures
void Monster::pushCreatures(Tile* tile)
{
CreatureVector* creatures = tile->getCreatures();
if(!creatures)
return;
bool effect = false;
Monster* monster = NULL;
for(uint32_t i = 0; i < creatures->size();)
{
if((monster = creatures->at(i)->getMonster()) && monster->isPushable())
{
if(pushCreature(monster))
continue;
monster->setDropLoot(LOOT_DROP_NONE);
monster->changeHealth(-monster->getHealth());
if(!effect)
effect = true;
}
++i;
}
if(effect)
g_game.addMagicEffect(tile->getPosition(), MAGIC_EFFECT_BLOCKHIT);
}
示例2: makeCreatures
void Tile::__internalAddThing(uint32_t, Thing* thing)
{
thing->setParent(this);
if(Creature* creature = thing->getCreature())
{
g_game.clearSpectatorCache();
CreatureVector* creatures = makeCreatures();
creatures->insert(creatures->begin(), creature);
++thingCount;
return;
}
Item* item = thing->getItem();
if(!item)
return;
TileItemVector* items = makeItemList();
if(items && items->size() >= 0xFFFF)
return/* RET_NOTPOSSIBLE*/;
if(item->isGroundTile())
{
if(!ground)
{
ground = item;
++thingCount;
}
}
else if(item->isAlwaysOnTop())
{
bool isInserted = false;
for(ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it)
{
if(Item::items[(*it)->getID()].alwaysOnTopOrder <= Item::items[item->getID()].alwaysOnTopOrder)
continue;
items->insert(it, item);
++thingCount;
isInserted = true;
break;
}
if(!isInserted)
{
items->push_back(item);
++thingCount;
}
}
else
{
items->insert(items->getBeginDownItem(), item);
++items->downItemCount;
++thingCount;
}
updateTileFlags(item, false);
}
示例3: makeCreatures
void Tile::internalAddThing(uint32_t, Thing* thing)
{
thing->setParent(this);
Creature* creature = thing->getCreature();
if (creature) {
g_game.map.clearSpectatorCache();
CreatureVector* creatures = makeCreatures();
creatures->insert(creatures->begin(), creature);
} else {
Item* item = thing->getItem();
if (item == nullptr) {
return;
}
const ItemType& itemType = Item::items[item->getID()];
if (itemType.isGroundTile()) {
if (ground == nullptr) {
ground = item;
setTileFlags(item);
}
return;
}
TileItemVector* items = makeItemList();
if (items->size() >= 0xFFFF) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
if (itemType.alwaysOnTop) {
bool isInserted = false;
for (ItemVector::iterator it = items->getBeginTopItem(), end = items->getEndTopItem(); it != end; ++it) {
if (Item::items[(*it)->getID()].alwaysOnTopOrder > itemType.alwaysOnTopOrder) {
items->insert(it, item);
isInserted = true;
break;
}
}
if (!isInserted) {
items->push_back(item);
}
} else {
items->insert(items->getBeginDownItem(), item);
items->addDownItemCount(1);
}
setTileFlags(item);
}
}
示例4: makeCreatures
void Tile::__addThing(Creature* actor, int32_t index, Thing* thing)
{
if(Creature* creature = thing->getCreature())
{
g_game.clearSpectatorCache();
creature->setParent(this);
CreatureVector* creatures = makeCreatures();
creatures->insert(creatures->begin(), creature);
++thingCount;
return;
}
Item* item = thing->getItem();
if(!item)
{
#ifdef __DEBUG_MOVESYS__
std::cout << "[Failure - Tile::__addThing] item == NULL" << std::endl;
DEBUG_REPORT
#endif
return/* RET_NOTPOSSIBLE*/;
}
示例5: removePlayers
void House::removePlayers(bool ignoreInvites)
{
PlayerVector kickList;
for(HouseTileList::iterator it = houseTiles.begin(); it != houseTiles.end(); ++it)
{
CreatureVector* creatures = (*it)->getCreatures();
if(!creatures)
continue;
Player* player = nullptr;
for(CreatureVector::iterator cit = creatures->begin(); cit != creatures->end(); ++cit)
{
if((player = (*cit)->getPlayer()) && !player->isRemoved()
&& (ignoreInvites || !isInvited(player)))
kickList.push_back(player);
}
}
if(kickList.empty())
return;
for(PlayerVector::iterator it = kickList.begin(); it != kickList.end(); ++it)
removePlayer((*it), false);
}
示例6: getCreatures
void Tile::removeThing(Thing* thing, uint32_t count)
{
Creature* creature = thing->getCreature();
if (creature) {
CreatureVector* creatures = getCreatures();
if (creatures) {
CreatureVector::iterator it = std::find(creatures->begin(), creatures->end(), thing);
if (it != creatures->end()) {
g_game.map.clearSpectatorCache();
creatures->erase(it);
}
}
return;
}
Item* item = thing->getItem();
if (!item) {
return;
}
int32_t index = getThingIndex(item);
if (index == -1) {
return;
}
if (item == ground) {
ground->setParent(nullptr);
ground = nullptr;
SpectatorVec list;
g_game.map.getSpectators(list, getPosition(), true);
onRemoveTileItem(list, std::vector<int32_t>(list.size(), 0), item);
return;
}
TileItemVector* items = getItemList();
if (!items) {
return;
}
const ItemType& itemType = Item::items[item->getID()];
if (itemType.alwaysOnTop) {
auto it = std::find(items->getBeginTopItem(), items->getEndTopItem(), item);
if (it == items->getEndTopItem()) {
return;
}
std::vector<int32_t> oldStackPosVector;
SpectatorVec list;
g_game.map.getSpectators(list, getPosition(), true);
for (Creature* spectator : list) {
if (Player* tmpPlayer = spectator->getPlayer()) {
oldStackPosVector.push_back(getStackposOfItem(tmpPlayer, item));
}
}
item->setParent(nullptr);
items->erase(it);
onRemoveTileItem(list, oldStackPosVector, item);
} else {
auto it = std::find(items->getBeginDownItem(), items->getEndDownItem(), item);
if (it == items->getEndDownItem()) {
return;
}
if (itemType.stackable && count != item->getItemCount()) {
uint8_t newCount = static_cast<uint8_t>(std::max<int32_t>(0, static_cast<int32_t>(item->getItemCount() - count)));
item->setItemCount(newCount);
onUpdateTileItem(item, itemType, item, itemType);
} else {
std::vector<int32_t> oldStackPosVector;
SpectatorVec list;
g_game.map.getSpectators(list, getPosition(), true);
for (Creature* spectator : list) {
if (Player* tmpPlayer = spectator->getPlayer()) {
oldStackPosVector.push_back(getStackposOfItem(tmpPlayer, item));
}
}
item->setParent(nullptr);
items->erase(it);
items->addDownItemCount(-1);
onRemoveTileItem(list, oldStackPosVector, item);
}
}
}
示例7: getItemList
void Tile::replaceThing(uint32_t index, Thing* thing)
{
int32_t pos = index;
Item* item = thing->getItem();
if (item == nullptr) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
Item* oldItem = nullptr;
bool isInserted = false;
if (ground) {
if (pos == 0) {
oldItem = ground;
ground = item;
isInserted = true;
}
--pos;
}
TileItemVector* items = getItemList();
if (items && !isInserted) {
int32_t topItemSize = getTopItemCount();
if (pos < topItemSize) {
ItemVector::iterator it = items->getBeginTopItem();
it += pos;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
pos -= topItemSize;
}
CreatureVector* creatures = getCreatures();
if (creatures) {
if (!isInserted && pos < static_cast<int32_t>(creatures->size())) {
return /*RETURNVALUE_NOTPOSSIBLE*/;
}
pos -= static_cast<uint32_t>(creatures->size());
}
if (items && !isInserted) {
int32_t downItemSize = getDownItemCount();
if (pos < downItemSize) {
ItemVector::iterator it = items->getBeginDownItem() + pos;
oldItem = *it;
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
}
if (isInserted) {
item->setParent(this);
resetTileFlags(oldItem);
setTileFlags(item);
const ItemType& oldType = Item::items[oldItem->getID()];
const ItemType& newType = Item::items[item->getID()];
onUpdateTileItem(oldItem, oldType, item, newType);
oldItem->setParent(nullptr);
return /*RETURNVALUE_NOERROR*/;
}
}
示例8: makeCreatures
void Tile::__addThing(int32_t index, Thing* thing)
{
Creature* creature = thing->getCreature();
if (creature)
{
g_game.clearSpectatorCache();
creature->setParent(this);
CreatureVector* creatures = makeCreatures();
creatures->insert(creatures->begin(), creature);
++thingCount;
}
else
{
Item* item = thing->getItem();
if (!item)
{
#ifdef __DEBUG__MOVESYS__
std::cout << "Failure: [Tile::__addThing] item == NULL" << std::endl;
DEBUG_REPORT
#endif
return /*RET_NOTPOSSIBLE*/;
}
TileItemVector* items = getItemList();
if (items && items->size() > 0xFFFF)
{
return /*RET_NOTPOSSIBLE*/;
}
item->setParent(this);
if (item->isGroundTile())
{
if (!ground)
{
ground = item;
++thingCount;
onAddTileItem(item);
}
else
{
const ItemType& oldType = Item::items[ground->getID()];
const ItemType& newType = Item::items[item->getID()];
int32_t oldGroundIndex = __getIndexOfThing(ground);
Item* oldGround = ground;
ground->setParent(NULL);
g_game.FreeThing(ground);
ground = item;
updateTileFlags(oldGround, true);
updateTileFlags(item, false);
onUpdateTileItem(oldGround, oldType, item, newType);
postRemoveNotification(oldGround, NULL, oldGroundIndex, true);
}
}
else if (item->isAlwaysOnTop())
{
if (item->isSplash())
{
//remove old splash if exists
if (items)
{
for (ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it)
{
if ((*it)->isSplash())
{
int32_t oldSplashIndex = __getIndexOfThing(*it);
Item* oldSplash = *it;
__removeThing(oldSplash, 1);
oldSplash->setParent(NULL);
g_game.FreeThing(oldSplash);
postRemoveNotification(oldSplash, NULL, oldSplashIndex, true);
break;
}
}
}
}
bool isInserted = false;
if (items)
{
for (ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it)
{
//Note: this is different from internalAddThing
if (Item::items[item->getID()].alwaysOnTopOrder <= Item::items[(*it)->getID()].alwaysOnTopOrder)
{
items->insert(it, item);
++thingCount;
isInserted = true;
break;
}
}
}
else
{
items = makeItemList();
}
//.........这里部分代码省略.........
示例9: getKillers
bool Creature::onDeath()
{
DeathList deathList = getKillers();
bool deny = false;
CreatureEventList prepareDeathEvents = getCreatureEvents(CREATURE_EVENT_PREPAREDEATH);
for(CreatureEventList::iterator it = prepareDeathEvents.begin(); it != prepareDeathEvents.end(); ++it)
{
if(!(*it)->executePrepareDeath(this, deathList) && !deny)
deny = true;
}
if(deny)
return false;
int32_t i = 0, size = deathList.size(), limit = g_config.getNumber(ConfigManager::DEATH_ASSISTS) + 1;
if(limit > 0 && size > limit)
size = limit;
Creature* tmp = NULL;
CreatureVector justifyVec;
for(DeathList::iterator it = deathList.begin(); it != deathList.end(); ++it, ++i)
{
if(it->isNameKill())
continue;
if(it == deathList.begin())
it->setLast();
if(i < size)
{
if(it->getKillerCreature()->getPlayer())
tmp = it->getKillerCreature();
else if(it->getKillerCreature()->getPlayerMaster())
tmp = it->getKillerCreature()->getMaster();
}
if(tmp)
{
if(std::find(justifyVec.begin(), justifyVec.end(), tmp) == justifyVec.end())
{
it->setJustify();
justifyVec.push_back(tmp);
}
tmp = NULL;
}
if(!it->getKillerCreature()->onKilledCreature(this, (*it)) && it->isLast())
return false;
}
for(CountMap::iterator it = damageMap.begin(); it != damageMap.end(); ++it)
{
if((tmp = g_game.getCreatureByID(it->first)))
tmp->onTargetKilled(this);
}
dropCorpse(deathList);
if(master)
master->removeSummon(this);
return true;
}
示例10: getCreatures
void Tile::__removeThing(Thing* thing, uint32_t count)
{
Creature* creature = thing->getCreature();
if (creature) {
CreatureVector* creatures = getCreatures();
if (creatures) {
CreatureVector::iterator it = std::find(creatures->begin(), creatures->end(), thing);
if (it != creatures->end()) {
g_game.clearSpectatorCache();
creatures->erase(it);
}
}
return;
}
Item* item = thing->getItem();
if (item) {
int32_t index = __getIndexOfThing(item);
if (index == -1) {
return;
}
if (item == ground) {
const SpectatorVec& list = g_game.getSpectators(getPosition());
std::vector<uint32_t> oldStackPosVector;
for (SpectatorVec::const_iterator it = list.begin(), end = list.end(); it != end; ++it) {
if (Player* tmpPlayer = (*it)->getPlayer()) {
oldStackPosVector.push_back(getClientIndexOfThing(tmpPlayer, ground));
}
}
ground->setParent(NULL);
ground = NULL;
onRemoveTileItem(list, oldStackPosVector, item);
return;
}
if (item->isAlwaysOnTop()) {
TileItemVector* items = getItemList();
if (items) {
for (ItemVector::iterator it = items->getBeginTopItem(); it != items->getEndTopItem(); ++it) {
if (*it == item) {
const SpectatorVec& list = g_game.getSpectators(getPosition());
std::vector<uint32_t> oldStackPosVector;
for (SpectatorVec::const_iterator iit = list.begin(), iend = list.end(); iit != iend; ++iit) {
if (Player* tmpPlayer = (*iit)->getPlayer()) {
oldStackPosVector.push_back(getClientIndexOfThing(tmpPlayer, *it));
}
}
(*it)->setParent(NULL);
items->erase(it);
onRemoveTileItem(list, oldStackPosVector, item);
return;
}
}
}
} else {
TileItemVector* items = getItemList();
if (items) {
for (ItemVector::iterator it = items->getBeginDownItem(); it != items->getEndDownItem(); ++it) {
if (*it == item) {
if (item->isStackable() && count != item->getItemCount()) {
uint8_t newCount = (uint8_t)std::max<int32_t>(0, (int32_t)(item->getItemCount() - count));
updateTileFlags(item, true);
item->setItemCount(newCount);
updateTileFlags(item, false);
const ItemType& it = Item::items[item->getID()];
onUpdateTileItem(item, it, item, it);
} else {
const SpectatorVec& list = g_game.getSpectators(getPosition());
std::vector<uint32_t> oldStackPosVector;
for (SpectatorVec::const_iterator iit = list.begin(), iend = list.end(); iit != iend; ++iit) {
if (Player* tmpPlayer = (*iit)->getPlayer()) {
oldStackPosVector.push_back(getClientIndexOfThing(tmpPlayer, *it));
}
}
(*it)->setParent(NULL);
items->erase(it);
--items->downItemCount;
onRemoveTileItem(list, oldStackPosVector, item);
}
//.........这里部分代码省略.........
示例11: getItemList
void Tile::__replaceThing(uint32_t index, Thing* thing)
{
int32_t pos = index;
Item* item = thing->getItem();
if (item == NULL) {
return /*RET_NOTPOSSIBLE*/;
}
Item* oldItem = NULL;
bool isInserted = false;
if (ground) {
if (pos == 0) {
oldItem = ground;
ground = item;
isInserted = true;
}
--pos;
}
TileItemVector* items = getItemList();
if (items && !isInserted) {
int32_t topItemSize = getTopItemCount();
if (pos < topItemSize) {
ItemVector::iterator it = items->getBeginTopItem();
it += pos;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
pos -= topItemSize;
}
CreatureVector* creatures = getCreatures();
if (creatures) {
if (!isInserted && pos < (int32_t)creatures->size()) {
return /*RET_NOTPOSSIBLE*/;
}
pos -= (uint32_t)creatures->size();
}
if (items && !isInserted) {
int32_t downItemSize = getDownItemCount();
if (pos < downItemSize) {
ItemVector::iterator it = items->begin();
it += pos;
pos = 0;
oldItem = (*it);
it = items->erase(it);
items->insert(it, item);
isInserted = true;
}
}
if (isInserted) {
item->setParent(this);
updateTileFlags(oldItem, true);
updateTileFlags(item, false);
const ItemType& oldType = Item::items[oldItem->getID()];
const ItemType& newType = Item::items[item->getID()];
onUpdateTileItem(oldItem, oldType, item, newType);
oldItem->setParent(NULL);
return /*RET_NOERROR*/;
}
}