Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Game::doMoveBar(uint32_t playerId, uint8_t opId)
- {
- Player* player = getPlayerByID(playerId);
- Container* container;
- for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
- {
- if(Item* item = player->getInventoryItem((slots_t)i))
- {
- boost::any value = (item)->getAttribute("poke");
- boost::any border = (item)->getAttribute("ballorder");
- if(value.type() == typeid(std::string) && border.type() == typeid(int32_t))
- {
- if(boost::any_cast<int32_t>(border) == opId && i == 8)
- return false;
- if(boost::any_cast<int32_t>(border) == opId && i == 10)
- {
- Thing* bthing = player->__getThing(10);
- Thing* ballPoke = player->__getThing(8);
- if(ballPoke && !ballPoke->getItem()->isNotMoveable())
- {
- if(bthing)
- {
- boost::any bbpb1 = ballPoke->getItem()->getAttribute("poke");
- boost::any bbpb2 = bthing->getItem()->getAttribute("poke");
- boost::any borderS = bthing->getItem()->getAttribute("ballorder");
- if (!bbpb1.empty() && !bbpb2.empty() && borderS.type() == typeid(int32_t))
- {
- int32_t pouitS = boost::any_cast<int32_t>(borderS);
- if(opId == pouitS)
- {
- Cylinder* acylinder = ballPoke->getItem()->getParent();
- Cylinder* bcylinder = bthing->getItem()->getParent();
- int32_t aitemIndex = acylinder->__getIndexOfThing(ballPoke->getItem());
- int32_t bitemIndex = bcylinder->__getIndexOfThing(bthing->getItem());
- internalRemoveItem(NULL, ballPoke->getItem());
- internalRemoveItem(NULL, bthing->getItem());
- Item* aa = Item::CreateItem(ballPoke->getItem()->getID(), ballPoke->getItem()->getItemCount());
- aa->copyAttributes(ballPoke->getItem());
- internalAddItem(NULL, acylinder, aa, INDEX_WHEREEVER, FLAG_NOLIMIT);
- int16_t stcpos;
- Position posa;
- Position posb;
- posb.x = 65535; posb.y = 10; posb.z = 0;
- internalGetPosition(aa, posa, stcpos);
- playerMoveThing(playerId, posa, aa->getClientID(), 0, posb, 1);
- Item* bb = Item::CreateItem(bthing->getItem()->getID(), bthing->getItem()->getItemCount());
- bb->copyAttributes(bthing->getItem());
- internalAddItem(NULL, acylinder, bb, INDEX_WHEREEVER, FLAG_NOLIMIT);
- internalGetPosition(bb, posa, stcpos);
- posb.y = 8;
- playerMoveThing(playerId, posa, bb->getClientID(), 0, posb, 1);
- return true;
- }
- }
- }
- }else
- {
- if(bthing)
- {
- boost::any bbpb1 = bthing->getItem()->getAttribute("poke");
- boost::any borderS = bthing->getItem()->getAttribute("ballorder");
- if (!bbpb1.empty() && borderS.type() == typeid(int32_t))
- {
- int32_t pouitS = boost::any_cast<int32_t>(borderS);
- if(opId == pouitS)
- {
- int16_t stcpos;
- Position posa;
- Position posb;
- posb.x = 65535; posb.y = 8; posb.z = 0;
- internalGetPosition(bthing->getItem(), posa, stcpos);
- playerMoveThing(playerId, posa, bthing->getItem()->getClientID(), 0, posb, 1);
- return true;
- }
- }
- }
- }
- }
- }
- ///////////////////////////////////////////////
- if(item->getContainer())
- {
- container = item->getContainer();
- for(ContainerIterator sb = container->begin(), end = container->end(); sb != end; ++sb)
- {
- Item* ballSLot = (*sb)->getItem();
- if(ballSLot);
- {
- boost::any value = ballSLot->getAttribute("poke");
- boost::any border = ballSLot->getAttribute("ballorder");
- if(value.type() == typeid(std::string) && border.type() == typeid(int32_t))
- {
- int32_t pouit = boost::any_cast<int32_t>(border);
- if(opId == pouit)
- {
- Thing* ballPoke = player->__getThing(8);
- if(ballPoke && !ballPoke->getItem()->isNotMoveable())
- {
- Cylinder* ballPokeCylinder = ballPoke->getItem()->getParent(); //slot8
- Cylinder* ballOrderCylinder = ballSLot->getParent(); //slotbag
- int32_t ballPokeIndex = ballPokeCylinder->__getIndexOfThing(ballPoke->getItem()); //slot8
- int32_t ballOrderIndex = ballOrderCylinder->__getIndexOfThing(ballSLot); //slotbag
- internalRemoveItem(NULL, ballPoke->getItem()); //slot8
- internalRemoveItem(NULL, ballSLot); //slotbag
- Item* CreateBallSLot = Item::CreateItem(ballSLot->getID(), ballSLot->getItemCount()); //slotbag
- CreateBallSLot->copyAttributes(ballSLot); //slotbag
- internalAddItem(NULL, ballPokeCylinder, CreateBallSLot, INDEX_WHEREEVER, FLAG_NOLIMIT); //slotbag
- Item* CreateBallBag = Item::CreateItem(ballPoke->getItem()->getID(), ballPoke->getItem()->getItemCount()); //slot8
- CreateBallBag->copyAttributes(ballPoke->getItem()); //slot8
- internalPlayerAddItem(NULL, player, CreateBallBag, false);//
- return true;
- }else
- {
- Cylinder* ballOrderCylinder = ballSLot->getParent();
- int32_t ballOrderIndex = ballOrderCylinder->__getIndexOfThing(ballSLot);
- internalRemoveItem(NULL, ballSLot);
- Item* CreateBallSLot = Item::CreateItem(ballSLot->getID(), ballSLot->getItemCount());
- CreateBallSLot->copyAttributes(ballSLot);
- internalPlayerAddItem(NULL, player, CreateBallSLot, false);
- return true;
- }
- }
- }
- }
- }
- }
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement