Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.27 KB | None | 0 0
  1. bool Game::doMoveBar(uint32_t playerId, uint8_t opId)
  2. {
  3. Player* player = getPlayerByID(playerId);
  4. Container* container;
  5. for(int32_t i = SLOT_FIRST; i < SLOT_LAST; ++i)
  6. {
  7. if(Item* item = player->getInventoryItem((slots_t)i))
  8. {
  9. boost::any value = (item)->getAttribute("poke");
  10. boost::any border = (item)->getAttribute("ballorder");
  11.  
  12. if(value.type() == typeid(std::string) && border.type() == typeid(int32_t))
  13. {
  14. if(boost::any_cast<int32_t>(border) == opId && i == 8)
  15. return false;
  16.  
  17.  
  18. if(boost::any_cast<int32_t>(border) == opId && i == 10)
  19. {
  20. Thing* bthing = player->__getThing(10);
  21. Thing* ballPoke = player->__getThing(8);
  22. if(ballPoke && !ballPoke->getItem()->isNotMoveable())
  23. {
  24. if(bthing)
  25. {
  26. boost::any bbpb1 = ballPoke->getItem()->getAttribute("poke");
  27. boost::any bbpb2 = bthing->getItem()->getAttribute("poke");
  28. boost::any borderS = bthing->getItem()->getAttribute("ballorder");
  29.  
  30.  
  31. if (!bbpb1.empty() && !bbpb2.empty() && borderS.type() == typeid(int32_t))
  32. {
  33. int32_t pouitS = boost::any_cast<int32_t>(borderS);
  34. if(opId == pouitS)
  35. {
  36. Cylinder* acylinder = ballPoke->getItem()->getParent();
  37. Cylinder* bcylinder = bthing->getItem()->getParent();
  38. int32_t aitemIndex = acylinder->__getIndexOfThing(ballPoke->getItem());
  39. int32_t bitemIndex = bcylinder->__getIndexOfThing(bthing->getItem());
  40. internalRemoveItem(NULL, ballPoke->getItem());
  41. internalRemoveItem(NULL, bthing->getItem());
  42.  
  43. Item* aa = Item::CreateItem(ballPoke->getItem()->getID(), ballPoke->getItem()->getItemCount());
  44. aa->copyAttributes(ballPoke->getItem());
  45. internalAddItem(NULL, acylinder, aa, INDEX_WHEREEVER, FLAG_NOLIMIT);
  46. int16_t stcpos;
  47. Position posa;
  48. Position posb;
  49. posb.x = 65535; posb.y = 10; posb.z = 0;
  50. internalGetPosition(aa, posa, stcpos);
  51. playerMoveThing(playerId, posa, aa->getClientID(), 0, posb, 1);
  52.  
  53. Item* bb = Item::CreateItem(bthing->getItem()->getID(), bthing->getItem()->getItemCount());
  54. bb->copyAttributes(bthing->getItem());
  55. internalAddItem(NULL, acylinder, bb, INDEX_WHEREEVER, FLAG_NOLIMIT);
  56. internalGetPosition(bb, posa, stcpos);
  57. posb.y = 8;
  58. playerMoveThing(playerId, posa, bb->getClientID(), 0, posb, 1);
  59. return true;
  60. }
  61. }
  62. }
  63. }else
  64. {
  65. if(bthing)
  66. {
  67. boost::any bbpb1 = bthing->getItem()->getAttribute("poke");
  68. boost::any borderS = bthing->getItem()->getAttribute("ballorder");
  69. if (!bbpb1.empty() && borderS.type() == typeid(int32_t))
  70. {
  71. int32_t pouitS = boost::any_cast<int32_t>(borderS);
  72. if(opId == pouitS)
  73. {
  74. int16_t stcpos;
  75. Position posa;
  76. Position posb;
  77. posb.x = 65535; posb.y = 8; posb.z = 0;
  78. internalGetPosition(bthing->getItem(), posa, stcpos);
  79. playerMoveThing(playerId, posa, bthing->getItem()->getClientID(), 0, posb, 1);
  80. return true;
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. ///////////////////////////////////////////////
  88. if(item->getContainer())
  89. {
  90. container = item->getContainer();
  91. for(ContainerIterator sb = container->begin(), end = container->end(); sb != end; ++sb)
  92. {
  93. Item* ballSLot = (*sb)->getItem();
  94. if(ballSLot);
  95. {
  96. boost::any value = ballSLot->getAttribute("poke");
  97. boost::any border = ballSLot->getAttribute("ballorder");
  98. if(value.type() == typeid(std::string) && border.type() == typeid(int32_t))
  99. {
  100. int32_t pouit = boost::any_cast<int32_t>(border);
  101. if(opId == pouit)
  102. {
  103. Thing* ballPoke = player->__getThing(8);
  104. if(ballPoke && !ballPoke->getItem()->isNotMoveable())
  105. {
  106. Cylinder* ballPokeCylinder = ballPoke->getItem()->getParent(); //slot8
  107. Cylinder* ballOrderCylinder = ballSLot->getParent(); //slotbag
  108. int32_t ballPokeIndex = ballPokeCylinder->__getIndexOfThing(ballPoke->getItem()); //slot8
  109. int32_t ballOrderIndex = ballOrderCylinder->__getIndexOfThing(ballSLot); //slotbag
  110. internalRemoveItem(NULL, ballPoke->getItem()); //slot8
  111. internalRemoveItem(NULL, ballSLot); //slotbag
  112.  
  113. Item* CreateBallSLot = Item::CreateItem(ballSLot->getID(), ballSLot->getItemCount()); //slotbag
  114. CreateBallSLot->copyAttributes(ballSLot); //slotbag
  115. internalAddItem(NULL, ballPokeCylinder, CreateBallSLot, INDEX_WHEREEVER, FLAG_NOLIMIT); //slotbag
  116.  
  117. Item* CreateBallBag = Item::CreateItem(ballPoke->getItem()->getID(), ballPoke->getItem()->getItemCount()); //slot8
  118. CreateBallBag->copyAttributes(ballPoke->getItem()); //slot8
  119. internalPlayerAddItem(NULL, player, CreateBallBag, false);//
  120. return true;
  121. }else
  122. {
  123. Cylinder* ballOrderCylinder = ballSLot->getParent();
  124. int32_t ballOrderIndex = ballOrderCylinder->__getIndexOfThing(ballSLot);
  125. internalRemoveItem(NULL, ballSLot);
  126. Item* CreateBallSLot = Item::CreateItem(ballSLot->getID(), ballSLot->getItemCount());
  127. CreateBallSLot->copyAttributes(ballSLot);
  128. internalPlayerAddItem(NULL, player, CreateBallSLot, false);
  129. return true;
  130. }
  131. }
  132. }
  133. }
  134. }
  135. }
  136. }
  137. }
  138. return false;
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement