本文整理汇总了C++中Thing::getItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Thing::getItem方法的具体用法?C++ Thing::getItem怎么用?C++ Thing::getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Thing
的用法示例。
在下文中一共展示了Thing::getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onCreatureMove
uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, const Position& fromPos, MoveEvent_t eventType)
{
const Position& pos = tile->getPosition();
uint32_t ret = 1;
MoveEvent* moveEvent = getEvent(tile, eventType);
if (moveEvent) {
ret &= moveEvent->fireStepEvent(creature, nullptr, pos, fromPos);
}
for (size_t i = tile->getFirstIndex(), j = tile->getLastIndex(); i < j; ++i) {
Thing* thing = tile->getThing(i);
if (!thing) {
continue;
}
Item* tileItem = thing->getItem();
if (!tileItem) {
continue;
}
moveEvent = getEvent(tileItem, eventType);
if (moveEvent) {
ret &= moveEvent->fireStepEvent(creature, tileItem, pos, fromPos);
}
}
return ret;
}
示例2: onCreatureMove
uint32_t MoveEvents::onCreatureMove(Creature* creature, const Tile* tile, bool isIn)
{
MoveEvent_t eventType;
if (isIn) {
eventType = MOVE_EVENT_STEP_IN;
} else {
eventType = MOVE_EVENT_STEP_OUT;
}
Position pos = tile->getPosition();
uint32_t ret = 1;
MoveEvent* moveEvent = getEvent(tile, eventType);
if (moveEvent) {
ret = ret & moveEvent->fireStepEvent(creature, nullptr, pos);
}
for (int32_t i = tile->__getFirstIndex(), j = tile->__getLastIndex(); i < j; ++i) {
Thing* thing = tile->__getThing(i);
if (thing) {
Item* tileItem = thing->getItem();
if (tileItem) {
moveEvent = getEvent(tileItem, eventType);
if (moveEvent) {
ret = ret & moveEvent->fireStepEvent(creature, tileItem, pos);
}
}
}
}
return ret;
}
示例3: removeThing
void Commands::removeThing(Player* player, const std::string& cmd, const std::string& param)
{
Position pos = player->getPosition();
pos = getNextPosition(player->direction, pos);
Tile* removeTile = g_game.getMap()->getTile(pos);
if (!removeTile) {
player->sendTextMessage(MSG_STATUS_SMALL, "Tile not found.");
g_game.addMagicEffect(pos, NM_ME_POFF);
return;
}
Thing* thing = removeTile->getTopVisibleThing(player);
if (!thing) {
player->sendTextMessage(MSG_STATUS_SMALL, "Object not found.");
g_game.addMagicEffect(pos, NM_ME_POFF);
return;
}
if (Creature* creature = thing->getCreature()) {
g_game.removeCreature(creature, true);
} else {
Item* item = thing->getItem();
if (item) {
if (item->isGroundTile()) {
player->sendTextMessage(MSG_STATUS_SMALL, "You may not remove a ground tile.");
g_game.addMagicEffect(pos, NM_ME_POFF);
return;
}
g_game.internalRemoveItem(item, std::max<int32_t>(1, std::min<int32_t>(atoi(param.c_str()), item->getItemCount())));
g_game.addMagicEffect(pos, NM_ME_MAGIC_BLOOD);
}
}
}
示例4: onCreatureMove
uint32_t MoveEvents::onCreatureMove(Creature* creature, Tile* tile, bool isIn)
{
MoveEvent_t eventType;
if(isIn){
eventType = MOVE_EVENT_STEP_IN;
}
else{
eventType = MOVE_EVENT_STEP_OUT;
}
uint32_t ret = 1;
MoveEvent* moveEvent = getEvent(tile, eventType);
if(moveEvent){
ret = ret & moveEvent->fireStepEvent(creature, NULL, tile->getPosition());
}
int32_t j = tile->__getLastIndex();
Item* tileItem = NULL;
for(int32_t i = tile->__getFirstIndex(); i < j; ++i){
Thing* thing = tile->__getThing(i);
if(thing && (tileItem = thing->getItem())){
moveEvent = getEvent(tileItem, eventType);
if(moveEvent){
ret = ret & moveEvent->fireStepEvent(creature, tileItem, tile->getPosition());
}
}
}
return ret;
}
示例5: queryAdd
ReturnValue DepotChest::queryAdd(int32_t index, const Thing& thing, uint32_t count,
uint32_t flags, Creature* actor/* = nullptr*/) const
{
const Item* item = thing.getItem();
if (item == nullptr) {
return RETURNVALUE_NOTPOSSIBLE;
}
bool skipLimit = hasBitSet(FLAG_NOLIMIT, flags);
if (!skipLimit) {
int32_t addCount = 0;
if ((item->isStackable() && item->getItemCount() != count)) {
addCount = 1;
}
if (item->getTopParent() != this) {
if (const Container* container = item->getContainer()) {
addCount = container->getItemHoldingCount() + 1;
} else {
addCount = 1;
}
}
if (getItemHoldingCount() + addCount > maxDepotItems) {
return RETURNVALUE_DEPOTISFULL;
}
}
return Container::queryAdd(index, thing, count, flags, actor);
}
示例6: __queryDestination
Cylinder* Tile::__queryDestination(int32_t& index, const Thing* thing, Item** destItem,
uint32_t& flags)
{
Tile* destTile = NULL;
*destItem = NULL;
if(floorChangeDown()){
int dx = getTilePosition().x;
int dy = getTilePosition().y;
int dz = getTilePosition().z + 1;
Tile* downTile = g_game.getTile(dx, dy, dz);
if(downTile){
if(downTile->floorChange(NORTH))
dy += 1;
if(downTile->floorChange(SOUTH))
dy -= 1;
if(downTile->floorChange(EAST))
dx -= 1;
if(downTile->floorChange(WEST))
dx += 1;
destTile = g_game.getTile(dx, dy, dz);
}
}
else if(floorChange()){
int dx = getTilePosition().x;
int dy = getTilePosition().y;
int dz = getTilePosition().z - 1;
if(floorChange(NORTH))
dy -= 1;
if(floorChange(SOUTH))
dy += 1;
if(floorChange(EAST))
dx += 1;
if(floorChange(WEST))
dx -= 1;
destTile = g_game.getTile(dx, dy, dz);
}
if(destTile == NULL){
destTile = this;
}
else{
flags |= FLAG_NOLIMIT; //Will ignore that there is blocking items/creatures
}
if(destTile){
Thing* destThing = destTile->getTopDownItem();
if(destThing)
*destItem = destThing->getItem();
}
return destTile;
}
示例7: queryMaxCount
ReturnValue Container::queryMaxCount(int32_t index, const Thing& thing, uint32_t count,
uint32_t& maxQueryCount, uint32_t flags) const
{
const Item* item = thing.getItem();
if (item == nullptr) {
maxQueryCount = 0;
return RETURNVALUE_NOTPOSSIBLE;
}
if (hasBitSet(FLAG_NOLIMIT, flags)) {
maxQueryCount = std::max<uint32_t>(1, count);
return RETURNVALUE_NOERROR;
}
int32_t freeSlots = std::max<int32_t>(capacity() - size(), 0);
if (item->isStackable()) {
uint32_t n = 0;
if (index == INDEX_WHEREEVER) {
//Iterate through every item and check how much free stackable slots there is.
uint32_t slotIndex = 0;
for (Item* containerItem : itemlist) {
if (containerItem != item && containerItem->equals(item) && containerItem->getItemCount() < 100) {
uint32_t remainder = (100 - containerItem->getItemCount());
if (queryAdd(slotIndex++, *item, remainder, flags) == RETURNVALUE_NOERROR) {
n += remainder;
}
}
}
} else {
const Item* destItem = getItemByIndex(index);
if (item->equals(destItem) && destItem->getItemCount() < 100) {
uint32_t remainder = 100 - destItem->getItemCount();
if (queryAdd(index, *item, remainder, flags) == RETURNVALUE_NOERROR) {
n = remainder;
}
}
}
maxQueryCount = freeSlots * 100 + n;
if (maxQueryCount < count) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
} else {
maxQueryCount = freeSlots;
if (maxQueryCount == 0) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
}
return RETURNVALUE_NOERROR;
}
示例8: __queryDestination
Cylinder* Container::__queryDestination(int32_t& index, const Thing* thing, Item** destItem,
uint32_t& flags)
{
if(index == 254 /*move up*/){
index = INDEX_WHEREEVER;
*destItem = NULL;
Container* parentContainer = dynamic_cast<Container*>(getParent());
if(parentContainer)
return parentContainer;
else
return this;
}
else if(index == 255 /*add wherever*/){
index = INDEX_WHEREEVER;
*destItem = NULL;
return this;
}
else{
if(index >= (int32_t)capacity()){
/*
if you have a container, maximize it to show all 20 slots
then you open a bag that is inside the container you will have a bag with 8 slots
and a "grey" area where the other 12 slots where from the container
if you drop the item on that grey area
the client calculates the slot position as if the bag has 20 slots
*/
index = INDEX_WHEREEVER;
}
if(index != INDEX_WHEREEVER){
Thing* destThing = __getThing(index);
if(destThing)
*destItem = destThing->getItem();
Cylinder* subCylinder = dynamic_cast<Cylinder*>(*destItem);
if(subCylinder){
index = INDEX_WHEREEVER;
*destItem = NULL;
return subCylinder;
}
}
}
return this;
}
示例9: queryRemove
ReturnValue Container::queryRemove(const Thing& thing, uint32_t count, uint32_t flags) const
{
int32_t index = getThingIndex(&thing);
if (index == -1) {
return RETURNVALUE_NOTPOSSIBLE;
}
const Item* item = thing.getItem();
if (item == nullptr) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (count == 0 || (item->isStackable() && count > item->getItemCount())) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (!item->isMoveable() && !hasBitSet(FLAG_IGNORENOTMOVEABLE, flags)) {
return RETURNVALUE_NOTMOVEABLE;
}
return RETURNVALUE_NOERROR;
}
示例10: onItemMove
uint32_t MoveEvents::onItemMove(Item* item, Tile* tile, bool isAdd)
{
MoveEvent_t eventType1, eventType2;
if (isAdd) {
eventType1 = MOVE_EVENT_ADD_ITEM;
eventType2 = MOVE_EVENT_ADD_ITEM_ITEMTILE;
} else {
eventType1 = MOVE_EVENT_REMOVE_ITEM;
eventType2 = MOVE_EVENT_REMOVE_ITEM_ITEMTILE;
}
uint32_t ret = 1;
MoveEvent* moveEvent = getEvent(tile, eventType1);
if (moveEvent) {
ret &= moveEvent->fireAddRemItem(item, nullptr, tile->getPosition());
}
moveEvent = getEvent(item, eventType1);
if (moveEvent) {
ret &= moveEvent->fireAddRemItem(item, nullptr, tile->getPosition());
}
for (size_t i = tile->getFirstIndex(), j = tile->getLastIndex(); i < j; ++i) {
Thing* thing = tile->getThing(i);
if (!thing) {
continue;
}
Item* tileItem = thing->getItem();
if (!tileItem || tileItem == item) {
continue;
}
moveEvent = getEvent(tileItem, eventType2);
if (moveEvent) {
ret &= moveEvent->fireAddRemItem(item, tileItem, tile->getPosition());
}
}
return ret;
}
示例11: queryAdd
ReturnValue Inbox::queryAdd(int32_t, const Thing& thing, uint32_t,
uint32_t flags, Creature*) const
{
if (!hasBitSet(FLAG_NOLIMIT, flags)) {
return RETURNVALUE_CONTAINERNOTENOUGHROOM;
}
const Item* item = thing.getItem();
if (!item) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (item == this) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
if (!item->isPickupable()) {
return RETURNVALUE_CANNOTPICKUP;
}
return RETURNVALUE_NOERROR;
}
示例12: onItemMove
uint32_t MoveEvents::onItemMove(Item* item, Tile* tile, bool isAdd)
{
MoveEvent_t eventType1;
MoveEvent_t eventType2;
if(isAdd){
eventType1 = MOVE_EVENT_ADD_ITEM;
eventType2 = MOVE_EVENT_ADD_ITEM_ITEMTILE;
}
else{
eventType1 = MOVE_EVENT_REMOVE_ITEM;
eventType2 = MOVE_EVENT_REMOVE_ITEM_ITEMTILE;
}
uint32_t ret = 1;
MoveEvent* moveEvent = getEvent(tile, eventType1);
if(moveEvent){
ret = ret & moveEvent->fireAddRemItem(item, NULL, tile->getPosition());
}
moveEvent = getEvent(item, eventType1);
if(moveEvent){
ret = ret & moveEvent->fireAddRemItem(item, NULL, tile->getPosition());
}
int32_t j = tile->__getLastIndex();
Item* tileItem = NULL;
for(int32_t i = tile->__getFirstIndex(); i < j; ++i){
Thing* thing = tile->__getThing(i);
if(thing && (tileItem = thing->getItem()) && (tileItem != item)){
moveEvent = getEvent(tileItem, eventType2);
if(moveEvent){
ret = ret & moveEvent->fireAddRemItem(item, tileItem, tile->getPosition());
}
}
}
return ret;
}
示例13: queryAdd
ReturnValue Reward::queryAdd(int32_t, const Thing& thing, uint32_t,
uint32_t, Creature* actor/* = nullptr*/) const
{
if (actor) {
return RETURNVALUE_NOTPOSSIBLE;
}
const Item* item = thing.getItem();
if (!item) {
return RETURNVALUE_NOTPOSSIBLE;
}
if (item == this) {
return RETURNVALUE_THISISIMPOSSIBLE;
}
if (!item->isPickupable()) {
return RETURNVALUE_CANNOTPICKUP;
}
return RETURNVALUE_NOERROR;
}
示例14: __queryAdd
ReturnValue Tile::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
bool childIsOwner /*= false*/) const
{
Thing* iithing = NULL;
if(const Creature* creature = thing->getCreature()){
if(!creatures.empty())
return RET_NOTPOSSIBLE;
if(ground == NULL)
return RET_NOTPOSSIBLE;
if(const Monster* monster = creature->getMonster()){
if(hasFlag(TILESTATE_PROTECTIONZONE))
return RET_NOTPOSSIBLE;
if(const MagicEffectItem* fieldItem = getFieldItem()){
const MagicEffectTargetCreatureCondition* magicTargetCondition = fieldItem->getCondition();
if(magicTargetCondition){
if((monster->getImmunities() & magicTargetCondition->attackType) != magicTargetCondition->attackType){
return RET_NOTPOSSIBLE;
}
}
}
if(floorChange() || getTeleportItem()){
return RET_NOTPOSSIBLE;
}
for(uint32_t i = 0; i < getThingCount(); ++i){
iithing = __getThing(i);
if(const Item* iitem = iithing->getItem()){
const ItemType& iiType = Item::items[iitem->getID()];
if(iiType.blockSolid){
if(!monster->canPushItems() || !iiType.moveable){
return RET_NOTPOSSIBLE;
}
}
}
}
return RET_NOERROR;
}
else if(const Player* player = creature->getPlayer()){
if(hasFlag(TILESTATE_PROTECTIONZONE) && player->pzLocked){
return RET_PLAYERISPZLOCKED;
}
}
for(uint32_t i = 0; i < getThingCount(); ++i){
iithing = __getThing(i);
if(const Item* iitem = iithing->getItem()){
const ItemType& iiType = Item::items[iitem->getID()];
if(iiType.blockSolid){
//check if this a creature that just is about to login/spawn
//those can be placed here if the blocking item is moveable
if(!creature->getParent()){
if(!iiType.moveable)
return RET_NOTPOSSIBLE;
}
else
return RET_NOTPOSSIBLE;
}
}
}
}
else if(const Item* item = thing->getItem()){
//If its a new (summoned item) always accept it
if(thing->getParent() == NULL){
return RET_NOERROR;
}
if(ground == NULL)
return RET_NOTPOSSIBLE;
if(!creatures.empty() && item->isBlocking())
return RET_NOTENOUGHROOM;
for(uint32_t i = 0; i < getThingCount(); ++i){
iithing = __getThing(i);
if(const Item* iitem = iithing->getItem()){
const ItemType& iiType = Item::items[iitem->getID()];
if(iiType.blockSolid){
if(item->isPickupable()){
//experimental
//if((iiType.isVertical || iiType.isHorizontal) && item->isHangable()){
// ItemVector::const_iterator iit;
// for(iit = downItems.begin(); iit != downItems.end(); ++iit){
// if((*iit)->isHangable())
// return RET_NOTENOUGHROOM;
// }
//}
//else
//.........这里部分代码省略.........
示例15: __queryAdd
ReturnValue Tile::__queryAdd(int32_t index, const Thing* thing, uint32_t count,
uint32_t flags) const
{
const CreatureVector* creatures = getCreatures();
const TileItemVector* items = getItemList();
if(const Creature* creature = thing->getCreature())
{
if(ground)
{
if(const Monster* monster = creature->getMonster())
{
const ItemType& iType = Item::items[ground->getID()];
if(ground->getID() == 11756)
return RET_NOTPOSSIBLE;
if(ground->getID() == 4821)
return RET_NOTPOSSIBLE;
if(ground->getID() == 4822)
return RET_NOTPOSSIBLE;
if(ground->getID() == 4823)
return RET_NOTPOSSIBLE;
if(ground->getID() == 4824)
return RET_NOTPOSSIBLE;
if(ground->getID() == 4825)
return RET_NOTPOSSIBLE;
}
}
if(hasBitSet(FLAG_NOLIMIT, flags))
return RET_NOERROR;
if(hasBitSet(FLAG_PATHFINDING, flags))
{
if(floorChange() || positionChange())
return RET_NOTPOSSIBLE;
}
if(!ground)
return RET_NOTPOSSIBLE;
if(const Monster* monster = creature->getMonster())
{
if((hasFlag(TILESTATE_PROTECTIONZONE)) && monster->isSummon())
return RET_NOERROR;
if(floorChange() || positionChange())
return RET_NOTPOSSIBLE;
if(monster->canPushCreatures() && !monster->isSummon())
{
if(creatures)
{
Creature* tmp = NULL;
for(uint32_t i = 0; i < creatures->size(); ++i)
{
tmp = creatures->at(i);
if(creature->canWalkthrough(tmp))
continue;
if(!tmp->getMonster() || !tmp->isPushable() ||
(tmp->getMonster()->isSummon() &&
tmp->getMonster()->isPlayerSummon()))
return RET_NOTPOSSIBLE;
}
}
}
else if(creatures && !creatures->empty())
{
for(CreatureVector::const_iterator cit = creatures->begin(); cit != creatures->end(); ++cit)
{
if(!creature->canWalkthrough(*cit))
return RET_NOTENOUGHROOM;
}
}
if(hasFlag(TILESTATE_IMMOVABLEBLOCKSOLID))
return RET_NOTPOSSIBLE;
if(hasBitSet(FLAG_PATHFINDING, flags) && hasFlag(TILESTATE_IMMOVABLENOFIELDBLOCKPATH))
return RET_NOTPOSSIBLE;
if((hasFlag(TILESTATE_BLOCKSOLID) || (hasBitSet(FLAG_PATHFINDING, flags) && hasFlag(TILESTATE_NOFIELDBLOCKPATH)))
&& (!(monster->canPushItems() || hasBitSet(FLAG_IGNOREBLOCKITEM, flags))))
return RET_NOTPOSSIBLE;
MagicField* field = getFieldItem();
if(field && !field->isBlocking(monster))
{
CombatType_t combatType = field->getCombatType();
//There is 3 options for a monster to enter a magic field
//1) Monster is immune
if(!monster->isImmune(combatType))
{
//1) Monster is "strong" enough to handle the damage
//2) Monster is already afflicated by this type of condition
if(!hasBitSet(FLAG_IGNOREFIELDDAMAGE, flags))
return RET_NOTPOSSIBLE;
if(!monster->canPushItems() && !monster->hasCondition(
Combat::DamageToConditionType(combatType), false))
return RET_NOTPOSSIBLE;
//.........这里部分代码省略.........